Use textproto package descriptors
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@quixos/camino-package-runtime",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"generate": "rm -rf src/camino src/quixos && protoc --plugin=protoc-gen-es=../todo-runtime/node_modules/.bin/protoc-gen-es --es_out=src --es_opt=target=ts,import_extension=js --proto_path=../../quixos-protocol/proto --proto_path=$QUIXOS_PROTO_PATH ../../quixos-protocol/proto/quixos/refs.proto ../../quixos-protocol/proto/quixos/runtime.proto ../../quixos-protocol/proto/camino/schema.proto ../../quixos-protocol/proto/camino/api.proto",
|
||||
"typecheck": "npm run generate && tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.12.1",
|
||||
"@connectrpc/connect": "^2.1.2",
|
||||
"@connectrpc/connect-node": "^2.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,525 @@
|
||||
// @generated by protoc-gen-es v2.12.1 with parameter "target=ts,import_extension=js"
|
||||
// @generated from file camino/schema.proto (package camino, syntax proto3)
|
||||
/* eslint-disable */
|
||||
|
||||
import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
|
||||
import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
||||
import type { FunctionRef } from "../quixos/refs_pb.js";
|
||||
import { file_quixos_refs } from "../quixos/refs_pb.js";
|
||||
import type { Message } from "@bufbuild/protobuf";
|
||||
|
||||
/**
|
||||
* Describes the file camino/schema.proto.
|
||||
*/
|
||||
export const file_camino_schema: GenFile = /*@__PURE__*/
|
||||
fileDesc("ChNjYW1pbm8vc2NoZW1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TUFOWV9VTklRVUUQBBIQCgxNQU5ZX09SREVSRUQQBSpUCg5Eb2NSZWZTdHJlbmd0aBIgChxET0NfUkVGX1NUUkVOR1RIX1VOU1BFQ0lGSUVEEAASDAoIU09GVF9SRUYQARISCg5QUk9KRUNURURfRURHRRACKmcKEEZpZWxkU3RvcmFnZUtpbmQSIgoeRklFTERfU1RPUkFHRV9LSU5EX1VOU1BFQ0lGSUVEEAASCgoGU1RPUkVEEAESCwoHREVSSVZFRBACEggKBExBWlkQAxIMCghFWFRFUk5BTBAEYgZwcm90bzM", [file_quixos_refs]);
|
||||
|
||||
/**
|
||||
* @generated from message camino.SymbolRef
|
||||
*/
|
||||
export type SymbolRef = Message<"camino.SymbolRef"> & {
|
||||
/**
|
||||
* @generated from field: string namespace = 1;
|
||||
*/
|
||||
namespace: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string name = 2;
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string version = 3;
|
||||
*/
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string hash = 4;
|
||||
*/
|
||||
hash: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.SymbolRef.
|
||||
* Use `create(SymbolRefSchema)` to create a new message.
|
||||
*/
|
||||
export const SymbolRefSchema: GenMessage<SymbolRef> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 0);
|
||||
|
||||
/**
|
||||
* @generated from message camino.Ref
|
||||
*/
|
||||
export type Ref = Message<"camino.Ref"> & {
|
||||
/**
|
||||
* @generated from field: string object_id = 1;
|
||||
*/
|
||||
objectId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.Ref.
|
||||
* Use `create(RefSchema)` to create a new message.
|
||||
*/
|
||||
export const RefSchema: GenMessage<Ref> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 1);
|
||||
|
||||
/**
|
||||
* @generated from message camino.CrdtText
|
||||
*/
|
||||
export type CrdtText = Message<"camino.CrdtText"> & {
|
||||
/**
|
||||
* @generated from field: bytes payload = 1;
|
||||
*/
|
||||
payload: Uint8Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.CrdtText.
|
||||
* Use `create(CrdtTextSchema)` to create a new message.
|
||||
*/
|
||||
export const CrdtTextSchema: GenMessage<CrdtText> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 2);
|
||||
|
||||
/**
|
||||
* @generated from message camino.CrdtRichText
|
||||
*/
|
||||
export type CrdtRichText = Message<"camino.CrdtRichText"> & {
|
||||
/**
|
||||
* @generated from field: bytes payload = 1;
|
||||
*/
|
||||
payload: Uint8Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.CrdtRichText.
|
||||
* Use `create(CrdtRichTextSchema)` to create a new message.
|
||||
*/
|
||||
export const CrdtRichTextSchema: GenMessage<CrdtRichText> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 3);
|
||||
|
||||
/**
|
||||
* @generated from message camino.CrdtJson
|
||||
*/
|
||||
export type CrdtJson = Message<"camino.CrdtJson"> & {
|
||||
/**
|
||||
* @generated from field: bytes payload = 1;
|
||||
*/
|
||||
payload: Uint8Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.CrdtJson.
|
||||
* Use `create(CrdtJsonSchema)` to create a new message.
|
||||
*/
|
||||
export const CrdtJsonSchema: GenMessage<CrdtJson> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 4);
|
||||
|
||||
/**
|
||||
* @generated from message camino.ClassSchema
|
||||
*/
|
||||
export type ClassSchema = Message<"camino.ClassSchema"> & {
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef id = 1;
|
||||
*/
|
||||
id?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: uint32 version = 2;
|
||||
*/
|
||||
version: number;
|
||||
|
||||
/**
|
||||
* @generated from field: repeated camino.FieldSchema fields = 3;
|
||||
*/
|
||||
fields: FieldSchema[];
|
||||
|
||||
/**
|
||||
* @generated from field: repeated camino.EdgeSchema edges = 4;
|
||||
*/
|
||||
edges: EdgeSchema[];
|
||||
|
||||
/**
|
||||
* @generated from field: repeated camino.MethodSchema methods = 5;
|
||||
*/
|
||||
methods: MethodSchema[];
|
||||
|
||||
/**
|
||||
* @generated from field: repeated camino.MigrationSpec migrations = 6;
|
||||
*/
|
||||
migrations: MigrationSpec[];
|
||||
|
||||
/**
|
||||
* @generated from field: string source_file = 7;
|
||||
*/
|
||||
sourceFile: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string proto_message = 8;
|
||||
*/
|
||||
protoMessage: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.ClassSchema.
|
||||
* Use `create(ClassSchemaSchema)` to create a new message.
|
||||
*/
|
||||
export const ClassSchemaSchema: GenMessage<ClassSchema> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 5);
|
||||
|
||||
/**
|
||||
* @generated from message camino.FieldSchema
|
||||
*/
|
||||
export type FieldSchema = Message<"camino.FieldSchema"> & {
|
||||
/**
|
||||
* @generated from field: string name = 1;
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* @generated from field: uint32 tag = 2;
|
||||
*/
|
||||
tag: number;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.TypeRef type = 3;
|
||||
*/
|
||||
type?: TypeRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.ConflictStrategy conflict = 4;
|
||||
*/
|
||||
conflict: ConflictStrategy;
|
||||
|
||||
/**
|
||||
* @generated from field: bool repeated = 5;
|
||||
*/
|
||||
repeated: boolean;
|
||||
|
||||
/**
|
||||
* @generated from field: bool optional = 6;
|
||||
*/
|
||||
optional: boolean;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.FieldStorage storage = 7;
|
||||
*/
|
||||
storage?: FieldStorage | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.FieldSchema.
|
||||
* Use `create(FieldSchemaSchema)` to create a new message.
|
||||
*/
|
||||
export const FieldSchemaSchema: GenMessage<FieldSchema> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 6);
|
||||
|
||||
/**
|
||||
* @generated from message camino.FieldStorage
|
||||
*/
|
||||
export type FieldStorage = Message<"camino.FieldStorage"> & {
|
||||
/**
|
||||
* @generated from field: camino.FieldStorageKind kind = 1;
|
||||
*/
|
||||
kind: FieldStorageKind;
|
||||
|
||||
/**
|
||||
* @generated from field: quixos.FunctionRef resolver = 2;
|
||||
*/
|
||||
resolver?: FunctionRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: bool cache = 3;
|
||||
*/
|
||||
cache: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.FieldStorage.
|
||||
* Use `create(FieldStorageSchema)` to create a new message.
|
||||
*/
|
||||
export const FieldStorageSchema: GenMessage<FieldStorage> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 7);
|
||||
|
||||
/**
|
||||
* @generated from message camino.TypeRef
|
||||
*/
|
||||
export type TypeRef = Message<"camino.TypeRef"> & {
|
||||
/**
|
||||
* @generated from field: string proto_type = 1;
|
||||
*/
|
||||
protoType: string;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef symbol = 2;
|
||||
*/
|
||||
symbol?: SymbolRef | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.TypeRef.
|
||||
* Use `create(TypeRefSchema)` to create a new message.
|
||||
*/
|
||||
export const TypeRefSchema: GenMessage<TypeRef> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 8);
|
||||
|
||||
/**
|
||||
* @generated from message camino.EdgeSchema
|
||||
*/
|
||||
export type EdgeSchema = Message<"camino.EdgeSchema"> & {
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef id = 1;
|
||||
*/
|
||||
id?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: string source_field = 2;
|
||||
*/
|
||||
sourceField: string;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef from_class = 3;
|
||||
*/
|
||||
fromClass?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef to_class = 4;
|
||||
*/
|
||||
toClass?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.Cardinality cardinality = 5;
|
||||
*/
|
||||
cardinality: Cardinality;
|
||||
|
||||
/**
|
||||
* @generated from field: string inverse = 6;
|
||||
*/
|
||||
inverse: string;
|
||||
|
||||
/**
|
||||
* @generated from field: repeated camino.FieldSchema fields = 7;
|
||||
*/
|
||||
fields: FieldSchema[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.EdgeSchema.
|
||||
* Use `create(EdgeSchemaSchema)` to create a new message.
|
||||
*/
|
||||
export const EdgeSchemaSchema: GenMessage<EdgeSchema> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 9);
|
||||
|
||||
/**
|
||||
* @generated from message camino.MethodSchema
|
||||
*/
|
||||
export type MethodSchema = Message<"camino.MethodSchema"> & {
|
||||
/**
|
||||
* @generated from field: string name = 1;
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* @generated from field: quixos.FunctionRef function = 2;
|
||||
*/
|
||||
function?: FunctionRef | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.MethodSchema.
|
||||
* Use `create(MethodSchemaSchema)` to create a new message.
|
||||
*/
|
||||
export const MethodSchemaSchema: GenMessage<MethodSchema> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 10);
|
||||
|
||||
/**
|
||||
* @generated from message camino.MigrationSpec
|
||||
*/
|
||||
export type MigrationSpec = Message<"camino.MigrationSpec"> & {
|
||||
/**
|
||||
* @generated from field: uint32 from_version = 1;
|
||||
*/
|
||||
fromVersion: number;
|
||||
|
||||
/**
|
||||
* @generated from field: uint32 to_version = 2;
|
||||
*/
|
||||
toVersion: number;
|
||||
|
||||
/**
|
||||
* @generated from field: quixos.FunctionRef function = 3;
|
||||
*/
|
||||
function?: FunctionRef | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.MigrationSpec.
|
||||
* Use `create(MigrationSpecSchema)` to create a new message.
|
||||
*/
|
||||
export const MigrationSpecSchema: GenMessage<MigrationSpec> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 11);
|
||||
|
||||
/**
|
||||
* @generated from message camino.DocRefDeclaration
|
||||
*/
|
||||
export type DocRefDeclaration = Message<"camino.DocRefDeclaration"> & {
|
||||
/**
|
||||
* @generated from field: string local_name = 1;
|
||||
*/
|
||||
localName: string;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef type = 2;
|
||||
*/
|
||||
type?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.SymbolRef target_class = 3;
|
||||
*/
|
||||
targetClass?: SymbolRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.DocRefStrength strength = 4;
|
||||
*/
|
||||
strength: DocRefStrength;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message camino.DocRefDeclaration.
|
||||
* Use `create(DocRefDeclarationSchema)` to create a new message.
|
||||
*/
|
||||
export const DocRefDeclarationSchema: GenMessage<DocRefDeclaration> = /*@__PURE__*/
|
||||
messageDesc(file_camino_schema, 12);
|
||||
|
||||
/**
|
||||
* @generated from enum camino.ConflictStrategy
|
||||
*/
|
||||
export enum ConflictStrategy {
|
||||
/**
|
||||
* @generated from enum value: CONFLICT_STRATEGY_UNSPECIFIED = 0;
|
||||
*/
|
||||
CONFLICT_STRATEGY_UNSPECIFIED = 0,
|
||||
|
||||
/**
|
||||
* @generated from enum value: REPLACE = 1;
|
||||
*/
|
||||
REPLACE = 1,
|
||||
|
||||
/**
|
||||
* @generated from enum value: PRESERVE_CONFLICTS = 2;
|
||||
*/
|
||||
PRESERVE_CONFLICTS = 2,
|
||||
|
||||
/**
|
||||
* @generated from enum value: CRDT = 3;
|
||||
*/
|
||||
CRDT = 3,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the enum camino.ConflictStrategy.
|
||||
*/
|
||||
export const ConflictStrategySchema: GenEnum<ConflictStrategy> = /*@__PURE__*/
|
||||
enumDesc(file_camino_schema, 0);
|
||||
|
||||
/**
|
||||
* @generated from enum camino.Cardinality
|
||||
*/
|
||||
export enum Cardinality {
|
||||
/**
|
||||
* @generated from enum value: CARDINALITY_UNSPECIFIED = 0;
|
||||
*/
|
||||
CARDINALITY_UNSPECIFIED = 0,
|
||||
|
||||
/**
|
||||
* @generated from enum value: OPTIONAL_ONE = 1;
|
||||
*/
|
||||
OPTIONAL_ONE = 1,
|
||||
|
||||
/**
|
||||
* @generated from enum value: EXACTLY_ONE = 2;
|
||||
*/
|
||||
EXACTLY_ONE = 2,
|
||||
|
||||
/**
|
||||
* @generated from enum value: MANY = 3;
|
||||
*/
|
||||
MANY = 3,
|
||||
|
||||
/**
|
||||
* @generated from enum value: MANY_UNIQUE = 4;
|
||||
*/
|
||||
MANY_UNIQUE = 4,
|
||||
|
||||
/**
|
||||
* @generated from enum value: MANY_ORDERED = 5;
|
||||
*/
|
||||
MANY_ORDERED = 5,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the enum camino.Cardinality.
|
||||
*/
|
||||
export const CardinalitySchema: GenEnum<Cardinality> = /*@__PURE__*/
|
||||
enumDesc(file_camino_schema, 1);
|
||||
|
||||
/**
|
||||
* @generated from enum camino.DocRefStrength
|
||||
*/
|
||||
export enum DocRefStrength {
|
||||
/**
|
||||
* @generated from enum value: DOC_REF_STRENGTH_UNSPECIFIED = 0;
|
||||
*/
|
||||
DOC_REF_STRENGTH_UNSPECIFIED = 0,
|
||||
|
||||
/**
|
||||
* @generated from enum value: SOFT_REF = 1;
|
||||
*/
|
||||
SOFT_REF = 1,
|
||||
|
||||
/**
|
||||
* @generated from enum value: PROJECTED_EDGE = 2;
|
||||
*/
|
||||
PROJECTED_EDGE = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the enum camino.DocRefStrength.
|
||||
*/
|
||||
export const DocRefStrengthSchema: GenEnum<DocRefStrength> = /*@__PURE__*/
|
||||
enumDesc(file_camino_schema, 2);
|
||||
|
||||
/**
|
||||
* @generated from enum camino.FieldStorageKind
|
||||
*/
|
||||
export enum FieldStorageKind {
|
||||
/**
|
||||
* @generated from enum value: FIELD_STORAGE_KIND_UNSPECIFIED = 0;
|
||||
*/
|
||||
FIELD_STORAGE_KIND_UNSPECIFIED = 0,
|
||||
|
||||
/**
|
||||
* @generated from enum value: STORED = 1;
|
||||
*/
|
||||
STORED = 1,
|
||||
|
||||
/**
|
||||
* @generated from enum value: DERIVED = 2;
|
||||
*/
|
||||
DERIVED = 2,
|
||||
|
||||
/**
|
||||
* @generated from enum value: LAZY = 3;
|
||||
*/
|
||||
LAZY = 3,
|
||||
|
||||
/**
|
||||
* @generated from enum value: EXTERNAL = 4;
|
||||
*/
|
||||
EXTERNAL = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the enum camino.FieldStorageKind.
|
||||
*/
|
||||
export const FieldStorageKindSchema: GenEnum<FieldStorageKind> = /*@__PURE__*/
|
||||
enumDesc(file_camino_schema, 3);
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
import http from "node:http";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import { createClient, type Client } from "@connectrpc/connect";
|
||||
import {
|
||||
connectNodeAdapter,
|
||||
createConnectTransport,
|
||||
} from "@connectrpc/connect-node";
|
||||
import {
|
||||
CaminoService,
|
||||
CrdtValueSchema,
|
||||
ListValueSchema,
|
||||
NullValueSchema,
|
||||
ObjectValueSchema,
|
||||
RefValueSchema,
|
||||
ValueSchema,
|
||||
type Value,
|
||||
} from "./camino/api_pb.js";
|
||||
import {
|
||||
HandshakeResponseSchema,
|
||||
InvokeResponseSchema,
|
||||
PackageRuntime,
|
||||
type InvokeRequest,
|
||||
} from "./quixos/runtime_pb.js";
|
||||
import { FunctionRefSchema } from "./quixos/refs_pb.js";
|
||||
|
||||
declare const objectRefBrand: unique symbol;
|
||||
|
||||
export type ObjectRef<ClassId extends string> = string & {
|
||||
readonly [objectRefBrand]: ClassId;
|
||||
};
|
||||
|
||||
export type CaminoClient = Client<typeof CaminoService>;
|
||||
|
||||
export type { InvokeRequest, Value };
|
||||
|
||||
export type Field<T> = {
|
||||
set(value: T): Promise<void>;
|
||||
};
|
||||
|
||||
export type RuntimeHandler<Context> = (
|
||||
context: Context,
|
||||
) => Promise<unknown> | unknown;
|
||||
|
||||
export type RuntimeFunctionSpec<ExportName extends string = string> = {
|
||||
exportName: ExportName;
|
||||
symbol: string;
|
||||
};
|
||||
|
||||
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
||||
Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
|
||||
const bytesToBase64 = (value: Uint8Array) =>
|
||||
Buffer.from(value).toString("base64");
|
||||
|
||||
const base64ToBytes = (value: string) => Buffer.from(value, "base64");
|
||||
|
||||
export const jsToProtoValue = (value: unknown): Value => {
|
||||
if (value === null || value === undefined) {
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "nullValue",
|
||||
value: create(NullValueSchema, {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
if (typeof value === "boolean") {
|
||||
return create(ValueSchema, {
|
||||
kind: { case: "boolValue", value },
|
||||
});
|
||||
}
|
||||
if (typeof value === "number") {
|
||||
return create(ValueSchema, {
|
||||
kind: { case: "numberValue", value },
|
||||
});
|
||||
}
|
||||
if (typeof value === "bigint") {
|
||||
return create(ValueSchema, {
|
||||
kind: { case: "integerValue", value: value.toString() },
|
||||
});
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return create(ValueSchema, {
|
||||
kind: { case: "stringValue", value },
|
||||
});
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
return create(ValueSchema, {
|
||||
kind: { case: "bytesValue", value },
|
||||
});
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "listValue",
|
||||
value: create(ListValueSchema, {
|
||||
values: value.map(jsToProtoValue),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
if (isRecord(value)) {
|
||||
if (typeof value.$caminoRef === "string") {
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "refValue",
|
||||
value: create(RefValueSchema, {
|
||||
objectId: value.$caminoRef,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
if (
|
||||
typeof value.$caminoBytes === "string" &&
|
||||
Object.keys(value).every((key) => key === "$caminoBytes")
|
||||
) {
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "bytesValue",
|
||||
value: base64ToBytes(value.$caminoBytes),
|
||||
},
|
||||
});
|
||||
}
|
||||
if (
|
||||
typeof value.$caminoCrdtType === "string" &&
|
||||
typeof value.$caminoCrdtPayload === "string"
|
||||
) {
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "crdtValue",
|
||||
value: create(CrdtValueSchema, {
|
||||
type: value.$caminoCrdtType,
|
||||
encoding:
|
||||
typeof value.$caminoCrdtEncoding === "string"
|
||||
? value.$caminoCrdtEncoding
|
||||
: "base64",
|
||||
payload: base64ToBytes(value.$caminoCrdtPayload),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
return create(ValueSchema, {
|
||||
kind: {
|
||||
case: "objectValue",
|
||||
value: create(ObjectValueSchema, {
|
||||
fields: jsObjectToProtoFields(value),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
throw new Error(`Unsupported Camino RPC value: ${typeof value}`);
|
||||
};
|
||||
|
||||
export const protoValueToJs = (value: Value | undefined): unknown => {
|
||||
switch (value?.kind.case) {
|
||||
case "nullValue":
|
||||
case undefined:
|
||||
return null;
|
||||
case "boolValue":
|
||||
case "numberValue":
|
||||
case "stringValue":
|
||||
return value.kind.value;
|
||||
case "integerValue":
|
||||
return value.kind.value;
|
||||
case "bytesValue":
|
||||
return bytesToBase64(value.kind.value);
|
||||
case "listValue":
|
||||
return value.kind.value.values.map(protoValueToJs);
|
||||
case "objectValue":
|
||||
return protoFieldsToJs(value.kind.value.fields);
|
||||
case "refValue":
|
||||
return value.kind.value.objectId;
|
||||
case "crdtValue":
|
||||
return {
|
||||
$caminoCrdtType: value.kind.value.type,
|
||||
$caminoCrdtEncoding: value.kind.value.encoding,
|
||||
$caminoCrdtPayload: bytesToBase64(value.kind.value.payload),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const jsObjectToProtoFields = (value: Record<string, unknown>) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(value)
|
||||
.filter(([, fieldValue]) => fieldValue !== undefined)
|
||||
.map(([key, fieldValue]) => [key, jsToProtoValue(fieldValue)]),
|
||||
);
|
||||
|
||||
export const protoFieldsToJs = (
|
||||
fields: Record<string, Value> | undefined,
|
||||
): Record<string, unknown> =>
|
||||
Object.fromEntries(
|
||||
Object.entries(fields ?? {}).map(([key, value]) => [
|
||||
key,
|
||||
protoValueToJs(value),
|
||||
]),
|
||||
);
|
||||
|
||||
export const objectRef = <ClassId extends string>(objectId: string) =>
|
||||
objectId as ObjectRef<ClassId>;
|
||||
|
||||
export const createField = <T>(
|
||||
camino: CaminoClient,
|
||||
objectId: string,
|
||||
fieldName: string,
|
||||
): Field<T> => ({
|
||||
async set(value) {
|
||||
await camino.setField({
|
||||
objectId,
|
||||
fieldName,
|
||||
value: jsToProtoValue(value),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const serveQuixosPackageRuntime = <
|
||||
Context,
|
||||
Spec extends readonly RuntimeFunctionSpec[],
|
||||
>(params: {
|
||||
packageNamespace: string;
|
||||
packageName: string;
|
||||
runtimeProtocolVersion: string;
|
||||
functions: Spec;
|
||||
implementation: {
|
||||
[Name in Spec[number]["exportName"]]: RuntimeHandler<Context>;
|
||||
};
|
||||
createContext: (camino: CaminoClient, request: InvokeRequest) => Context;
|
||||
}) => {
|
||||
const host = process.env.QUIXOS_RUNTIME_HOST ?? "127.0.0.1";
|
||||
const port = Number(process.env.QUIXOS_RUNTIME_PORT ?? "0");
|
||||
const caminoUrl = process.env.CAMINO_URL ?? "http://127.0.0.1:7310";
|
||||
const camino = createClient(
|
||||
CaminoService,
|
||||
createConnectTransport({ baseUrl: caminoUrl, httpVersion: "1.1" }),
|
||||
);
|
||||
|
||||
if (!Number.isInteger(port) || port <= 0) {
|
||||
throw new Error("QUIXOS_RUNTIME_PORT must be a positive integer");
|
||||
}
|
||||
|
||||
const functionRefs = params.functions.map((entry) =>
|
||||
create(FunctionRefSchema, {
|
||||
packageNamespace: params.packageNamespace,
|
||||
packageName: params.packageName,
|
||||
symbol: entry.symbol,
|
||||
}),
|
||||
);
|
||||
|
||||
const handler = connectNodeAdapter({
|
||||
routes: (router) => {
|
||||
router.service(PackageRuntime, {
|
||||
async handshake() {
|
||||
return create(HandshakeResponseSchema, {
|
||||
packageNamespace: params.packageNamespace,
|
||||
packageName: params.packageName,
|
||||
runtimeProtocolVersion: params.runtimeProtocolVersion,
|
||||
functions: functionRefs,
|
||||
});
|
||||
},
|
||||
|
||||
async invoke(request) {
|
||||
try {
|
||||
const symbol = request.function?.symbol ?? "";
|
||||
const spec = params.functions.find(
|
||||
(entry) => entry.symbol === symbol,
|
||||
);
|
||||
if (!spec) {
|
||||
throw new Error(
|
||||
`Unknown ${params.packageName} function: ${symbol}`,
|
||||
);
|
||||
}
|
||||
const runtimeFunction = (
|
||||
params.implementation as Record<string, RuntimeHandler<Context>>
|
||||
)[spec.exportName];
|
||||
if (!runtimeFunction) {
|
||||
throw new Error(
|
||||
`Missing ${params.packageName} implementation export: ${spec.exportName}`,
|
||||
);
|
||||
}
|
||||
return create(InvokeResponseSchema, {
|
||||
ok: true,
|
||||
result: jsToProtoValue(
|
||||
await runtimeFunction(params.createContext(camino, request)),
|
||||
),
|
||||
});
|
||||
} catch (error) {
|
||||
return create(InvokeResponseSchema, {
|
||||
ok: false,
|
||||
result: jsToProtoValue(null),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const server = http.createServer((request, response) => {
|
||||
void handler(request, response);
|
||||
});
|
||||
const close = () => server.close(() => process.exit(0));
|
||||
|
||||
server.listen(port, host, () => {
|
||||
process.stderr.write(
|
||||
`${params.packageName} listening on ${host}:${port}\n`,
|
||||
);
|
||||
});
|
||||
process.on("SIGTERM", close);
|
||||
process.on("SIGINT", close);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
// @generated by protoc-gen-es v2.12.1 with parameter "target=ts,import_extension=js"
|
||||
// @generated from file quixos/refs.proto (package quixos, syntax proto3)
|
||||
/* eslint-disable */
|
||||
|
||||
import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
|
||||
import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
||||
import type { Message } from "@bufbuild/protobuf";
|
||||
|
||||
/**
|
||||
* Describes the file quixos/refs.proto.
|
||||
*/
|
||||
export const file_quixos_refs: GenFile = /*@__PURE__*/
|
||||
fileDesc("ChFxdWl4b3MvcmVmcy5wcm90bxIGcXVpeG9zImMKC0Z1bmN0aW9uUmVmEhkKEXBhY2thZ2VfbmFtZXNwYWNlGAEgASgJEhQKDHBhY2thZ2VfbmFtZRgCIAEoCRIOCgZzeW1ib2wYAyABKAkSEwoLdmVyc2lvbl9yZWYYBCABKAliBnByb3RvMw");
|
||||
|
||||
/**
|
||||
* @generated from message quixos.FunctionRef
|
||||
*/
|
||||
export type FunctionRef = Message<"quixos.FunctionRef"> & {
|
||||
/**
|
||||
* @generated from field: string package_namespace = 1;
|
||||
*/
|
||||
packageNamespace: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string package_name = 2;
|
||||
*/
|
||||
packageName: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string symbol = 3;
|
||||
*/
|
||||
symbol: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string version_ref = 4;
|
||||
*/
|
||||
versionRef: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message quixos.FunctionRef.
|
||||
* Use `create(FunctionRefSchema)` to create a new message.
|
||||
*/
|
||||
export const FunctionRefSchema: GenMessage<FunctionRef> = /*@__PURE__*/
|
||||
messageDesc(file_quixos_refs, 0);
|
||||
@@ -0,0 +1,148 @@
|
||||
// @generated by protoc-gen-es v2.12.1 with parameter "target=ts,import_extension=js"
|
||||
// @generated from file quixos/runtime.proto (package quixos.runtime, syntax proto3)
|
||||
/* eslint-disable */
|
||||
|
||||
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
||||
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
||||
import type { Value } from "../camino/api_pb.js";
|
||||
import { file_camino_api } from "../camino/api_pb.js";
|
||||
import type { FunctionRef } from "./refs_pb.js";
|
||||
import { file_quixos_refs } from "./refs_pb.js";
|
||||
import type { Message } from "@bufbuild/protobuf";
|
||||
|
||||
/**
|
||||
* Describes the file quixos/runtime.proto.
|
||||
*/
|
||||
export const file_quixos_runtime: GenFile = /*@__PURE__*/
|
||||
fileDesc("ChRxdWl4b3MvcnVudGltZS5wcm90bxIOcXVpeG9zLnJ1bnRpbWUiMQoQSGFuZHNoYWtlUmVxdWVzdBIdChVvcmNoX3Byb3RvY29sX3ZlcnNpb24YASABKAkijgEKEUhhbmRzaGFrZVJlc3BvbnNlEhkKEXBhY2thZ2VfbmFtZXNwYWNlGAEgASgJEhQKDHBhY2thZ2VfbmFtZRgCIAEoCRIgChhydW50aW1lX3Byb3RvY29sX3ZlcnNpb24YAyABKAkSJgoJZnVuY3Rpb25zGAQgAygLMhMucXVpeG9zLkZ1bmN0aW9uUmVmItYBCg1JbnZva2VSZXF1ZXN0EhUKDWludm9jYXRpb25faWQYASABKAkSJQoIZnVuY3Rpb24YAiABKAsyEy5xdWl4b3MuRnVuY3Rpb25SZWYSEQoJb2JqZWN0X2lkGAMgASgJEjcKBWlucHV0GAQgAygLMigucXVpeG9zLnJ1bnRpbWUuSW52b2tlUmVxdWVzdC5JbnB1dEVudHJ5GjsKCklucHV0RW50cnkSCwoDa2V5GAEgASgJEhwKBXZhbHVlGAIgASgLMg0uY2FtaW5vLlZhbHVlOgI4ASJKCg5JbnZva2VSZXNwb25zZRIKCgJvaxgBIAEoCBIdCgZyZXN1bHQYAiABKAsyDS5jYW1pbm8uVmFsdWUSDQoFZXJyb3IYAyABKAkyqwEKDlBhY2thZ2VSdW50aW1lElAKCUhhbmRzaGFrZRIgLnF1aXhvcy5ydW50aW1lLkhhbmRzaGFrZVJlcXVlc3QaIS5xdWl4b3MucnVudGltZS5IYW5kc2hha2VSZXNwb25zZRJHCgZJbnZva2USHS5xdWl4b3MucnVudGltZS5JbnZva2VSZXF1ZXN0Gh4ucXVpeG9zLnJ1bnRpbWUuSW52b2tlUmVzcG9uc2ViBnByb3RvMw", [file_camino_api, file_quixos_refs]);
|
||||
|
||||
/**
|
||||
* @generated from message quixos.runtime.HandshakeRequest
|
||||
*/
|
||||
export type HandshakeRequest = Message<"quixos.runtime.HandshakeRequest"> & {
|
||||
/**
|
||||
* @generated from field: string orch_protocol_version = 1;
|
||||
*/
|
||||
orchProtocolVersion: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message quixos.runtime.HandshakeRequest.
|
||||
* Use `create(HandshakeRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const HandshakeRequestSchema: GenMessage<HandshakeRequest> = /*@__PURE__*/
|
||||
messageDesc(file_quixos_runtime, 0);
|
||||
|
||||
/**
|
||||
* @generated from message quixos.runtime.HandshakeResponse
|
||||
*/
|
||||
export type HandshakeResponse = Message<"quixos.runtime.HandshakeResponse"> & {
|
||||
/**
|
||||
* @generated from field: string package_namespace = 1;
|
||||
*/
|
||||
packageNamespace: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string package_name = 2;
|
||||
*/
|
||||
packageName: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string runtime_protocol_version = 3;
|
||||
*/
|
||||
runtimeProtocolVersion: string;
|
||||
|
||||
/**
|
||||
* @generated from field: repeated quixos.FunctionRef functions = 4;
|
||||
*/
|
||||
functions: FunctionRef[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message quixos.runtime.HandshakeResponse.
|
||||
* Use `create(HandshakeResponseSchema)` to create a new message.
|
||||
*/
|
||||
export const HandshakeResponseSchema: GenMessage<HandshakeResponse> = /*@__PURE__*/
|
||||
messageDesc(file_quixos_runtime, 1);
|
||||
|
||||
/**
|
||||
* @generated from message quixos.runtime.InvokeRequest
|
||||
*/
|
||||
export type InvokeRequest = Message<"quixos.runtime.InvokeRequest"> & {
|
||||
/**
|
||||
* @generated from field: string invocation_id = 1;
|
||||
*/
|
||||
invocationId: string;
|
||||
|
||||
/**
|
||||
* @generated from field: quixos.FunctionRef function = 2;
|
||||
*/
|
||||
function?: FunctionRef | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: string object_id = 3;
|
||||
*/
|
||||
objectId: string;
|
||||
|
||||
/**
|
||||
* @generated from field: map<string, camino.Value> input = 4;
|
||||
*/
|
||||
input: { [key: string]: Value };
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message quixos.runtime.InvokeRequest.
|
||||
* Use `create(InvokeRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const InvokeRequestSchema: GenMessage<InvokeRequest> = /*@__PURE__*/
|
||||
messageDesc(file_quixos_runtime, 2);
|
||||
|
||||
/**
|
||||
* @generated from message quixos.runtime.InvokeResponse
|
||||
*/
|
||||
export type InvokeResponse = Message<"quixos.runtime.InvokeResponse"> & {
|
||||
/**
|
||||
* @generated from field: bool ok = 1;
|
||||
*/
|
||||
ok: boolean;
|
||||
|
||||
/**
|
||||
* @generated from field: camino.Value result = 2;
|
||||
*/
|
||||
result?: Value | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: string error = 3;
|
||||
*/
|
||||
error: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message quixos.runtime.InvokeResponse.
|
||||
* Use `create(InvokeResponseSchema)` to create a new message.
|
||||
*/
|
||||
export const InvokeResponseSchema: GenMessage<InvokeResponse> = /*@__PURE__*/
|
||||
messageDesc(file_quixos_runtime, 3);
|
||||
|
||||
/**
|
||||
* @generated from service quixos.runtime.PackageRuntime
|
||||
*/
|
||||
export const PackageRuntime: GenService<{
|
||||
/**
|
||||
* @generated from rpc quixos.runtime.PackageRuntime.Handshake
|
||||
*/
|
||||
handshake: {
|
||||
methodKind: "unary";
|
||||
input: typeof HandshakeRequestSchema;
|
||||
output: typeof HandshakeResponseSchema;
|
||||
},
|
||||
/**
|
||||
* @generated from rpc quixos.runtime.PackageRuntime.Invoke
|
||||
*/
|
||||
invoke: {
|
||||
methodKind: "unary";
|
||||
input: typeof InvokeRequestSchema;
|
||||
output: typeof InvokeResponseSchema;
|
||||
},
|
||||
}> = /*@__PURE__*/
|
||||
serviceDesc(file_quixos_runtime, 0);
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user