84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
import { type Value } from "./camino/api_pb.js";
|
|
import { liveValue, type RuntimeHandler, type DerivedHandler } from "./index.js";
|
|
export type { QxObjectRef } from "./references.js";
|
|
declare const watchBrand: unique symbol;
|
|
export type QxWatchHandle = string & {
|
|
readonly [watchBrand]: true;
|
|
};
|
|
export type MessageBinding<T> = {
|
|
encode(value: T): Value;
|
|
decode(value: Value): T;
|
|
};
|
|
export type QxLiveValue = ReturnType<typeof liveValue>;
|
|
export declare const opaqueReactPropsBinding: MessageBinding<Record<string, unknown>>;
|
|
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
|
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
|
export type QxDerived<C, O> = {
|
|
kind: "derived";
|
|
get: QxHandler<C, O>;
|
|
};
|
|
export type QxSession<C> = {
|
|
id: string;
|
|
run<T>(work: (context: C) => Promise<T>): Promise<T>;
|
|
close(): Promise<void>;
|
|
};
|
|
export type QxContextLifecycle<C> = {
|
|
signal?: AbortSignal;
|
|
openSession?: () => Promise<QxSession<C>>;
|
|
};
|
|
export declare const qxDerived: <C, O>(get: QxHandler<C, O>) => QxDerived<C, O>;
|
|
/** Versioned binding ABI. This mirrors the language-neutral value IR. */
|
|
export type QxValueType = {
|
|
kind: "builtin";
|
|
name: "unit" | "watch-handle";
|
|
} | {
|
|
kind: "scalar";
|
|
name: string;
|
|
} | {
|
|
kind: "message";
|
|
descriptorId: string;
|
|
} | {
|
|
kind: "record";
|
|
fields: Record<string, QxValueType>;
|
|
} | {
|
|
kind: "object-ref";
|
|
expectation: unknown;
|
|
} | {
|
|
kind: "optional" | "list";
|
|
value: QxValueType;
|
|
};
|
|
export type QxOperationSpec = {
|
|
id: string;
|
|
inputType: QxValueType;
|
|
outputType: QxValueType;
|
|
};
|
|
export type QxPortSpec = {
|
|
kind: "state";
|
|
id: string;
|
|
valueType: QxValueType;
|
|
primitives: string[];
|
|
} | {
|
|
kind: "edge";
|
|
id: string;
|
|
primitives: string[];
|
|
} | {
|
|
kind: "interface";
|
|
id: string;
|
|
operations: Record<string, QxOperationSpec>;
|
|
} | {
|
|
kind: "constructor";
|
|
id: string;
|
|
inputType: QxValueType;
|
|
};
|
|
export type QxHandlerSpec = {
|
|
inputType: QxValueType;
|
|
outputType: QxValueType;
|
|
eventType?: QxValueType;
|
|
ports: Record<string, QxPortSpec>;
|
|
};
|
|
export type QxMessages = Record<string, MessageBinding<any>>;
|
|
export declare const decodeQxValue: (type: QxValueType, value: Value | undefined, messages: QxMessages) => any;
|
|
export declare const encodeQxValue: (type: QxValueType, value: any, messages: QxMessages) => Value;
|
|
/** The sole unchecked cast connects generated contracts to the dynamic RPC runtime. */
|
|
export declare const bindQxHandler: <C, O>(spec: QxHandlerSpec, handler: QxHandler<C, O> | QxDerived<C, O>, messages: QxMessages) => RuntimeHandler | DerivedHandler;
|
|
//# sourceMappingURL=bindings.d.ts.map
|