Publish built Camino package runtime artifacts
This commit is contained in:
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
import { type Client } from "@connectrpc/connect";
|
||||
import { type CaminoAutomergeDoc } from "@quixos/camino-datatypes/crdt-automerge";
|
||||
import { CaminoService, type Value } from "./camino/api_pb.js";
|
||||
import { type InvokeRequest } from "./quixos/runtime_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 DerivedDependency = {
|
||||
kind: "object";
|
||||
objectId: string;
|
||||
} | {
|
||||
kind: "field";
|
||||
objectId: string;
|
||||
fieldName: string;
|
||||
} | {
|
||||
kind: "edges";
|
||||
objectId: string;
|
||||
sourceField?: string;
|
||||
};
|
||||
export declare const recordDerivedDependency: (dependency: DerivedDependency) => void;
|
||||
export declare const getActiveDerivedDependencies: () => DerivedDependency[];
|
||||
export declare const runWithDerivedDependencyTracking: <T>(fn: () => Promise<T> | T) => Promise<{
|
||||
value: T;
|
||||
dependencies: DerivedDependency[];
|
||||
}>;
|
||||
export type Field<T> = {
|
||||
get(): Promise<T | undefined>;
|
||||
set(value: T): Promise<void>;
|
||||
};
|
||||
export type CrdtField<T> = Field<CaminoAutomergeDoc<T>> & {
|
||||
change(fn: (doc: {
|
||||
value: T;
|
||||
}) => void): Promise<CaminoAutomergeDoc<T>>;
|
||||
replaceFromJson(value: T): Promise<void>;
|
||||
};
|
||||
export type LiveFieldValue<T> = {
|
||||
$caminoValue: T;
|
||||
$caminoSource: {
|
||||
field: {
|
||||
objectId: string;
|
||||
fieldName: string;
|
||||
fieldType?: string;
|
||||
fieldStorage?: string;
|
||||
conflictStrategy?: string;
|
||||
revision?: number | string | bigint;
|
||||
};
|
||||
};
|
||||
};
|
||||
export declare const liveFieldValue: <T>(params: {
|
||||
value: T;
|
||||
objectId: string;
|
||||
fieldName: string;
|
||||
fieldType?: string;
|
||||
fieldStorage?: string;
|
||||
conflictStrategy?: string;
|
||||
revision?: number | string | bigint;
|
||||
}) => LiveFieldValue<T>;
|
||||
export type RuntimeHandler<Context> = (context: Context) => Promise<unknown> | unknown;
|
||||
export type FieldOperation<Context> = {
|
||||
get?: RuntimeHandler<Context>;
|
||||
set?: RuntimeHandler<Context>;
|
||||
watchStart?: RuntimeHandler<Context>;
|
||||
watchStop?: RuntimeHandler<Context>;
|
||||
};
|
||||
export declare const fieldOps: <Context>(operation: FieldOperation<Context>) => FieldOperation<Context>;
|
||||
export declare const derivedWithDeps: <Context>(operation: {
|
||||
get: RuntimeHandler<Context>;
|
||||
}) => FieldOperation<Context>;
|
||||
export type RuntimeFunctionSpec<ExportName extends string = string> = {
|
||||
exportName: ExportName;
|
||||
symbol: string;
|
||||
operation?: string;
|
||||
field?: {
|
||||
name: string;
|
||||
type?: string;
|
||||
storage?: string;
|
||||
conflict?: string;
|
||||
};
|
||||
};
|
||||
type FieldCodec = {
|
||||
fieldType?: string;
|
||||
conflictStrategy?: string;
|
||||
};
|
||||
export declare const jsToProtoValue: (value: unknown, codec?: FieldCodec) => Value;
|
||||
export declare const protoValueToJs: (value: Value | undefined) => unknown;
|
||||
export declare const jsObjectToProtoFields: (value: Record<string, unknown>) => {
|
||||
[k: string]: Value;
|
||||
};
|
||||
export declare const protoFieldsToJs: (fields: Record<string, Value> | undefined) => Record<string, unknown>;
|
||||
export declare const canonicalFieldParams: (params: Record<string, Value> | undefined) => string;
|
||||
export declare const fieldOperationKey: (params: {
|
||||
objectId: string;
|
||||
fieldName: string;
|
||||
input?: Record<string, Value>;
|
||||
}) => string;
|
||||
export declare const objectRef: <ClassId extends string>(objectId: string) => ObjectRef<ClassId>;
|
||||
export declare const createField: <T>(camino: CaminoClient, objectId: string, fieldName: string, codec?: FieldCodec) => Field<T>;
|
||||
export declare const createCrdtField: <T>(camino: CaminoClient, objectId: string, fieldName: string, fieldType: string) => CrdtField<T>;
|
||||
export declare const serveQuixosPackageRuntime: <Context, Spec extends readonly RuntimeFunctionSpec[]>(params: {
|
||||
packageNamespace: string;
|
||||
packageName: string;
|
||||
runtimeProtocolVersion: string;
|
||||
functions: Spec;
|
||||
implementation: { [Name in Spec[number]["exportName"]]: RuntimeHandler<Context> | FieldOperation<Context>; };
|
||||
createContext: (camino: CaminoClient, request: InvokeRequest) => Context;
|
||||
}) => void;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
Reference in New Issue
Block a user