Files
camino-package-runtime/dist/index.d.ts
T
2026-09-08 15:42:20 -07:00

85 lines
3.2 KiB
TypeScript

import http from "node:http";
export * from "./bindings.js";
import { type Client, type ConnectRouter } from "@connectrpc/connect";
import { CaminoService, type Value } from "./camino/api_pb.js";
import { OrchestratorRuntime } from "./quixos/orch_pb.js";
export type CaminoClient = Client<typeof CaminoService>;
export type OrchClient = Client<typeof OrchestratorRuntime>;
export type RuntimeDependency = {
kind: "state";
objectId: string;
attachmentId: string;
} | {
kind: "edge";
objectId: string;
attachmentId: string;
projectionId: string;
};
export declare const objectRef: (objectId: string) => {
$quixosRef: string;
};
export declare const liveValue: (value: Value) => {
$quixosValue: Value;
};
export declare const jsToProtoValue: (value: unknown) => Value;
export declare const protoValueToJs: (value: Value | undefined) => unknown;
export declare const protoFieldsToJs: (fields: Record<string, Value>) => {
[k: string]: unknown;
};
export type StatePort<T = unknown> = {
slotId: string;
get(): Promise<T>;
live(): Promise<ReturnType<typeof liveValue>>;
set(value: T): Promise<void>;
};
export type EdgePort = {
edgeTypeId: string;
projectionId: string;
resolve(): Promise<string[]>;
connect(targetObjectId: string): Promise<void>;
disconnect(targetObjectId: string): Promise<void>;
};
export type InterfacePort = {
objectId: string;
interfaceRevisionId: string;
invoke(operationId: string, input?: Record<string, unknown>): Promise<unknown>;
live(operationId: string, input?: Record<string, unknown>): Promise<ReturnType<typeof liveValue>>;
};
export type ConstructorPort = {
atomId: string;
construct(input?: Record<string, unknown>): Promise<string>;
};
export type RuntimePort = StatePort | EdgePort | InterfacePort | ConstructorPort;
export type RuntimeContext = {
objectId: string;
input: Record<string, unknown>;
inputProto: Record<string, Value>;
ports: ReadonlyMap<string, RuntimePort>;
state<T = unknown>(portId: string): StatePort<T>;
edge(portId: string): EdgePort;
interface(portId: string): InterfacePort;
constructor(portId: string): ConstructorPort;
};
export declare const createRuntimeContext: (camino: CaminoClient, orch: OrchClient, request: RuntimeRequest) => RuntimeContext;
export type RuntimeHandler = (context: RuntimeContext) => unknown | Promise<unknown>;
export type DerivedHandler = {
kind: "derived";
get: RuntimeHandler;
};
export declare const derived: (get: RuntimeHandler) => DerivedHandler;
export declare const createPackageRuntimeRoutes: (config: {
packageRevisionId: string;
exports: Record<string, RuntimeHandler | DerivedHandler>;
caminoUrl?: string;
orchUrl?: string;
}) => (router: ConnectRouter) => ConnectRouter;
export declare const servePackageRuntime: (config: {
packageRevisionId: string;
exports: Record<string, RuntimeHandler | DerivedHandler>;
}) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
type RuntimeRequest = {
objectId: string;
input: Record<string, Value>;
dependencies: import("./quixos/refs_pb.js").InjectedDependency[];
};
//# sourceMappingURL=index.d.ts.map