Compare commits

...

2 Commits

Author SHA1 Message Date
Quixos Subtree Publisher 97e91221d7 Publish camino-package-runtime from ea0fcae12ae515b454cd60405dcc482415836294 2026-07-13 01:44:16 +00:00
Timothy J. Aveni 2bf0e44646 Wrap field operation results with provenance 2026-07-12 18:44:16 -07:00
2 changed files with 52 additions and 6 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"version": 1,
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git",
"sourceCommit": "3feca0fc7f9face8c43f12dc0edbb46173059de5",
"sourceCommit": "ea0fcae12ae515b454cd60405dcc482415836294",
"sourcePath": "quixos-instance/packages/camino-package-runtime",
"exportName": "camino-package-runtime",
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git"
+51 -5
View File
@@ -414,6 +414,12 @@ export type RuntimeFunctionSpec<ExportName extends string = string> = {
exportName: ExportName;
symbol: string;
operation?: string;
field?: {
name: string;
type?: string;
storage?: string;
conflict?: string;
};
};
class AsyncEventQueue<T> implements AsyncIterableIterator<T> {
@@ -698,10 +704,43 @@ const derivedDependencyToProto = (dependency: DerivedDependency) =>
sourceField: dependency.kind === "edges" ? dependency.sourceField ?? "" : "",
});
const derivedEmissionToProto = (event: DerivedWatchEmission): WatchEvent =>
const fieldSourceForSpec = (
spec: RuntimeFunctionSpec,
objectId: string,
): LiveFieldValue<unknown>["$caminoSource"] | undefined => {
if (!spec.field) {
return undefined;
}
return {
field: {
objectId,
fieldName: spec.field.name,
...(spec.field.type ? { fieldType: spec.field.type } : {}),
...(spec.field.storage ? { fieldStorage: spec.field.storage } : {}),
...(spec.field.conflict ? { conflictStrategy: spec.field.conflict } : {}),
},
};
};
const wrapFieldResult = (
spec: RuntimeFunctionSpec,
objectId: string,
value: unknown,
) => {
const source = fieldSourceForSpec(spec, objectId);
return source ? { $caminoValue: value, $caminoSource: source } : value;
};
const derivedEmissionToProtoForSpec = (
spec: RuntimeFunctionSpec,
objectId: string,
event: DerivedWatchEmission,
): WatchEvent =>
create(WatchEventSchema, {
watchId: event.watchId,
value: jsToProtoValue(event.value ?? null),
value: jsToProtoValue(
event.error ? null : wrapFieldResult(spec, objectId, event.value ?? null),
),
dependencies: event.dependencies.map(derivedDependencyToProto),
error: event.error ?? "",
initial: event.initial,
@@ -895,11 +934,16 @@ export const serveQuixosPackageRuntime = <
async invoke(request) {
try {
const { runtimeFunction } = resolveRuntimeFunction(request.function);
const { spec, runtimeFunction } = resolveRuntimeFunction(request.function);
const value = await runtimeFunction(
params.createContext(trackingCamino, request),
);
return create(InvokeResponseSchema, {
ok: true,
result: jsToProtoValue(
await runtimeFunction(params.createContext(trackingCamino, request)),
spec.operation === "get"
? wrapFieldResult(spec, request.objectId, value)
: value,
),
});
} catch (error) {
@@ -929,7 +973,9 @@ export const serveQuixosPackageRuntime = <
}
const sink: DerivedWatchSink = {
publish(event) {
queue.push(derivedEmissionToProto(event));
queue.push(
derivedEmissionToProtoForSpec(spec, request.objectId, event),
);
},
};
const result = await watchSinkStorage.run(sink, async () =>