@party-stack/ontology-server 0.11.8 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/composition.d.ts +1 -1
- package/lib/composition.d.ts.map +1 -1
- package/lib/routing.d.ts +1 -1
- package/lib/routing.d.ts.map +1 -1
- package/lib/rpc.d.ts +41 -2
- package/lib/rpc.d.ts.map +1 -1
- package/lib/rpc.js +23 -0
- package/lib/rpc.js.map +1 -1
- package/lib/rpcWorker.js +6 -0
- package/lib/rpcWorker.js.map +1 -1
- package/package.json +4 -4
package/lib/composition.d.ts
CHANGED
|
@@ -461,7 +461,7 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
461
461
|
/** Ordinary provider capabilities of a replica server; speculative state remains a separate extension. */
|
|
462
462
|
export declare const replicaServerBackend: (replica: ReplicaService, backend: OntologyBackendService) => OntologyBackendService;
|
|
463
463
|
/** One role/policy composition for transports with an already authenticated binding. */
|
|
464
|
-
export declare const ontologyServerHandlers: <R = never>(options: OntologyServerBindingOptions<R>) => Layer.Layer<import("effect/rpc/Rpc").Handler<"Accept"> | import("effect/rpc/Rpc").Handler<"AckDelivery"> | import("effect/rpc/Rpc").Handler<"Acknowledge"> | import("effect/rpc/Rpc").Handler<"ApplyAction"> | import("effect/rpc/Rpc").Handler<"AttachmentMetadata"> | import("effect/rpc/Rpc").Handler<"Changes"> | import("effect/rpc/Rpc").Handler<"ClearPin"> | import("effect/rpc/Rpc").Handler<"ControlOutbox"> | import("effect/rpc/Rpc").Handler<"CreateAttachment"> | import("effect/rpc/Rpc").Handler<"Decrypt"> | import("effect/rpc/Rpc").Handler<"DeleteLocalData"> | import("effect/rpc/Rpc").Handler<"Demand"> | import("effect/rpc/Rpc").Handler<"Describe"> | import("effect/rpc/Rpc").Handler<"LoadSubset"> | import("effect/rpc/Rpc").Handler<"OpenClient"> | import("effect/rpc/Rpc").Handler<"PullChanges"> | import("effect/rpc/Rpc").Handler<"Query"> | import("effect/rpc/Rpc").Handler<"QueryFunction"> | import("effect/rpc/Rpc").Handler<"Read"> | import("effect/rpc/Rpc").Handler<"ReadAttachment"> | import("effect/rpc/Rpc").Handler<"ReadPin"> | import("effect/rpc/Rpc").Handler<"ReleaseOwner"> | import("effect/rpc/Rpc").Handler<"ReplicaStatus"> | import("effect/rpc/Rpc").Handler<"ResolveActionParameters"> | import("effect/rpc/Rpc").Handler<"SetPin"> | import("effect/rpc/Rpc").Handler<"Submit"> | import("effect/rpc/Rpc").Handler<"SubscribeSelection"> | import("effect/rpc/Rpc").Handler<"SubscribeState"> | import("effect/rpc/Rpc").Handler<"Traces"> | import("effect/rpc/Rpc").Handler<"ValidateAction"> | import("effect/rpc/Rpc").Handler<"WatchChanges"> | import("effect/rpc/Rpc").Handler<"WatchPin"> | import("effect/rpc/Rpc").Handler<"WatchSubset"> | import("effect/rpc/Rpc").Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, Exclude<Exclude<R, never>, Scope.Scope> | Exclude<Exclude<Exclude<R, never>, Scope.Scope>, Scope.Scope>>;
|
|
464
|
+
export declare const ontologyServerHandlers: <R = never>(options: OntologyServerBindingOptions<R>) => Layer.Layer<import("effect/rpc/Rpc").Handler<"Accept"> | import("effect/rpc/Rpc").Handler<"AckDelivery"> | import("effect/rpc/Rpc").Handler<"Acknowledge"> | import("effect/rpc/Rpc").Handler<"ApplyAction"> | import("effect/rpc/Rpc").Handler<"AttachmentMetadata"> | import("effect/rpc/Rpc").Handler<"Changes"> | import("effect/rpc/Rpc").Handler<"ClearPin"> | import("effect/rpc/Rpc").Handler<"ControlOutbox"> | import("effect/rpc/Rpc").Handler<"CreateAttachment"> | import("effect/rpc/Rpc").Handler<"Decrypt"> | import("effect/rpc/Rpc").Handler<"DeleteLocalData"> | import("effect/rpc/Rpc").Handler<"Demand"> | import("effect/rpc/Rpc").Handler<"Describe"> | import("effect/rpc/Rpc").Handler<"LoadSubset"> | import("effect/rpc/Rpc").Handler<"OpenClient"> | import("effect/rpc/Rpc").Handler<"PullChanges"> | import("effect/rpc/Rpc").Handler<"Query"> | import("effect/rpc/Rpc").Handler<"QueryFunction"> | import("effect/rpc/Rpc").Handler<"Read"> | import("effect/rpc/Rpc").Handler<"ReadAttachment"> | import("effect/rpc/Rpc").Handler<"ReadPin"> | import("effect/rpc/Rpc").Handler<"ReleaseOwner"> | import("effect/rpc/Rpc").Handler<"ReplicaStatus"> | import("effect/rpc/Rpc").Handler<"ResolveActionParameters"> | import("effect/rpc/Rpc").Handler<"SetPin"> | import("effect/rpc/Rpc").Handler<"Submit"> | import("effect/rpc/Rpc").Handler<"SubscribeSelection"> | import("effect/rpc/Rpc").Handler<"SubscribeState"> | import("effect/rpc/Rpc").Handler<"Traces"> | import("effect/rpc/Rpc").Handler<"UpdateView"> | import("effect/rpc/Rpc").Handler<"ValidateAction"> | import("effect/rpc/Rpc").Handler<"WatchChanges"> | import("effect/rpc/Rpc").Handler<"WatchPin"> | import("effect/rpc/Rpc").Handler<"WatchSubset"> | import("effect/rpc/Rpc").Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, Exclude<Exclude<R, never>, Scope.Scope> | Exclude<Exclude<Exclude<R, never>, Scope.Scope>, Scope.Scope>>;
|
|
465
465
|
//#endregion
|
|
466
466
|
export type { OntologyInternalAccess };
|
|
467
467
|
//# sourceMappingURL=composition.d.ts.map
|
package/lib/composition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition.d.ts","names":["_$__attachmentTransfers_js0.AttachmentTransferPolicy","_$__rpc_js0.OntologyRpcRequest","_$__errorProjection_js0.OntologyErrorProjection"],"sources":["../src/composition.ts"],"mappings":";;;;;;;;;;YAeY,qBAAqB,cAC7B,SAAS,YACR,OAAO,OAAO,yBAAyB,cAAc,IAAI,MAAM;KAG/D,OAAO,KAAK,KACb,yBAAyB;KAGxB;WACY;WAAwB,SAAS;;WACjC;WAAwB,SAAS;;WAE/B;WACA,SAAS;WACT,OAAO;;WAGP;WACA,SAAS;WACT,SAAS;WACT;WACA;;KAEd;WAEc,SAAS;WACT,iCAAiC;;WAEnC;WAA0B;;;YAG/B,6BAA6B,aAAa,OAAO,KAAK,OAAO;;YAE7D,uBAAuB,aAAa,OAAO,KACnD,SAEO;WAAqB;;WAET;WACA;WACA,eAAe,qBAAqB;;WAGpC;WACA,iCAAiC;WACjC,cAAc,qBAAqB;;qBAM7C,wBAAuE,GAAC,SAAA,OAAA,KAAA,SAAA,OAAA;;;;;;;;;;;EA1C9D;;;;;;;;;;;;;;;;EACA;;;;;;;;;;;;;;;;EAEE;EAEC,OAAA;;;;;;;;;;;;;;;;EAGD;EAEG,SAAA;EACuB;;;;;GA0DjD,iWAAA,MAAA;qBAEW,qBAAiE,GAAC;;;;;;;;;;;EAvExD;;;;;;;;;;;;;;;;EACA;;;;;;;;;;;;;;;;EAEE;EAEC,OAAA;;;;;;;;;;;;;;;;EAGD;EAEG,SAAA;EACuB;;;;;;;;;;;;;;;;EAX5B;;;;;EAmG4B;;;;;;;;;;;;;EAlG5B;;;;;EAkG4B;;;;;;;;;;;;;EAhG1B;EAEC,OAAA;;;;;EA8FyB;;;;;;;;;;;;;EA3F1B;EAEG,SAAA;EACuB;;;;;EAwFA;;;;;;;;;;;;;;;EAnG5B;EAkHP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjHO;EAiHP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA/GS;EAEC,OAAA;EA6GV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA1GS;EAEG,SAAA;EACuB;EAuGnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMd;;qBAGW,uBAAoB,SACpB,gBAAc,SACd,2BACV;;qBA0CU,yBAA0B,WAAS,SAAW,6BAA6B,OAAE,MAAA,+BAAA,6CAAA,kDAAA,kDAAA,kDAAA,yDAAA,8CAAA,+CAAA,oDAAA,uDAAA,8CAAA,sDAAA,6CAAA,+CAAA,iDAAA,iDAAA,kDAAA,4CAAA,oDAAA,2CAAA,qDAAA,8CAAA,mDAAA,oDAAA,8DAAA,6CAAA,6CAAA,yDAAA,qDAAA,6CAAA,qDAAA,mDAAA,+CAAA,kDAAA,kCAA/BE,yBAA+B,iWAAA,QAAA,QAAA,WAAA,MAAA,SAAA,QAAA,QAAA,QAAA,WAAA,MAAA,QAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"composition.d.ts","names":["_$__attachmentTransfers_js0.AttachmentTransferPolicy","_$__rpc_js0.OntologyRpcRequest","_$__errorProjection_js0.OntologyErrorProjection"],"sources":["../src/composition.ts"],"mappings":";;;;;;;;;;YAeY,qBAAqB,cAC7B,SAAS,YACR,OAAO,OAAO,yBAAyB,cAAc,IAAI,MAAM;KAG/D,OAAO,KAAK,KACb,yBAAyB;KAGxB;WACY;WAAwB,SAAS;;WACjC;WAAwB,SAAS;;WAE/B;WACA,SAAS;WACT,OAAO;;WAGP;WACA,SAAS;WACT,SAAS;WACT;WACA;;KAEd;WAEc,SAAS;WACT,iCAAiC;;WAEnC;WAA0B;;;YAG/B,6BAA6B,aAAa,OAAO,KAAK,OAAO;;YAE7D,uBAAuB,aAAa,OAAO,KACnD,SA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A,iDAAA,qDAAA,mDAAA,+CAAA,kDAAA,kCAA/BE,yBAA+B,iWAAA,QAAA,QAAA,WAAA,MAAA,SAAA,QAAA,QAAA,QAAA,WAAA,MAAA,QAAA,MAAA"}
|
package/lib/routing.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export interface MakeOntologyServer {
|
|
|
89
89
|
}
|
|
90
90
|
export declare const makeOntologyServer: MakeOntologyServer;
|
|
91
91
|
/** One RPC server dispatches all targets, including calls in the same HTTP batch. */
|
|
92
|
-
export declare const ontologyServerDispatch: <R = never>(router: OntologyServer<R>) => Layer.Layer<Rpc.Handler<"Accept"> | Rpc.Handler<"AckDelivery"> | Rpc.Handler<"Acknowledge"> | Rpc.Handler<"ApplyAction"> | Rpc.Handler<"AttachmentMetadata"> | Rpc.Handler<"Changes"> | Rpc.Handler<"ClearPin"> | Rpc.Handler<"ControlOutbox"> | Rpc.Handler<"CreateAttachment"> | Rpc.Handler<"Decrypt"> | Rpc.Handler<"DeleteLocalData"> | Rpc.Handler<"Demand"> | Rpc.Handler<"Describe"> | Rpc.Handler<"LoadSubset"> | Rpc.Handler<"OpenClient"> | Rpc.Handler<"PullChanges"> | Rpc.Handler<"Query"> | Rpc.Handler<"QueryFunction"> | Rpc.Handler<"Read"> | Rpc.Handler<"ReadAttachment"> | Rpc.Handler<"ReadPin"> | Rpc.Handler<"ReleaseOwner"> | Rpc.Handler<"ReplicaStatus"> | Rpc.Handler<"ResolveActionParameters"> | Rpc.Handler<"SetPin"> | Rpc.Handler<"Submit"> | Rpc.Handler<"SubscribeSelection"> | Rpc.Handler<"SubscribeState"> | Rpc.Handler<"Traces"> | Rpc.Handler<"ValidateAction"> | Rpc.Handler<"WatchChanges"> | Rpc.Handler<"WatchPin"> | Rpc.Handler<"WatchSubset"> | Rpc.Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, never, Exclude<Exclude<R, never>, Scope.Scope>>;
|
|
92
|
+
export declare const ontologyServerDispatch: <R = never>(router: OntologyServer<R>) => Layer.Layer<Rpc.Handler<"Accept"> | Rpc.Handler<"AckDelivery"> | Rpc.Handler<"Acknowledge"> | Rpc.Handler<"ApplyAction"> | Rpc.Handler<"AttachmentMetadata"> | Rpc.Handler<"Changes"> | Rpc.Handler<"ClearPin"> | Rpc.Handler<"ControlOutbox"> | Rpc.Handler<"CreateAttachment"> | Rpc.Handler<"Decrypt"> | Rpc.Handler<"DeleteLocalData"> | Rpc.Handler<"Demand"> | Rpc.Handler<"Describe"> | Rpc.Handler<"LoadSubset"> | Rpc.Handler<"OpenClient"> | Rpc.Handler<"PullChanges"> | Rpc.Handler<"Query"> | Rpc.Handler<"QueryFunction"> | Rpc.Handler<"Read"> | Rpc.Handler<"ReadAttachment"> | Rpc.Handler<"ReadPin"> | Rpc.Handler<"ReleaseOwner"> | Rpc.Handler<"ReplicaStatus"> | Rpc.Handler<"ResolveActionParameters"> | Rpc.Handler<"SetPin"> | Rpc.Handler<"Submit"> | Rpc.Handler<"SubscribeSelection"> | Rpc.Handler<"SubscribeState"> | Rpc.Handler<"Traces"> | Rpc.Handler<"UpdateView"> | Rpc.Handler<"ValidateAction"> | Rpc.Handler<"WatchChanges"> | Rpc.Handler<"WatchPin"> | Rpc.Handler<"WatchSubset"> | Rpc.Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, never, Exclude<Exclude<R, never>, Scope.Scope>>;
|
|
93
93
|
//#endregion
|
|
94
94
|
export {};
|
|
95
95
|
//# sourceMappingURL=routing.d.ts.map
|
package/lib/routing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","names":[],"sources":["../src/routing.ts"],"mappings":";;;;;;;;;;;;;qBAoBa;iBAgBI,iBAAiB,GAAG;GAChC,mBAAmB,OAAO,OAAO,GAAG,cAAc,IAAI,MAAM;;;wBAIjD,eAAe,QAAQ,mBAAmB,mBAAmB;;wBAiB7D,YAAY,aAAa;;qBAqD5B,0BAAwB,QAAA,UAAA;qBAIxB,yBAAu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S,cAAc,IAAI,MAAM;GACjF,iBAAiB,+BACd,SAAS,qBAAqB,GAAG,SAClC,OAAO,OAAO,eAAe,QAAQ,GAAG,MAAM,SAAS,cAAc,IAAI,WAAW,MAAM;;qBAEpF,oBAAoB;;qBAGpB,yBAA0B,WAAS,QAAU,eAAe,OAAE,MAAA,MAAA,IAAA,oBAAA,IAAA,yBAAA,IAAA,yBAAA,IAAA,yBAAA,IAAA,gCAAA,IAAA,qBAAA,IAAA,sBAAA,IAAA,2BAAA,IAAA,8BAAA,IAAA,qBAAA,IAAA,6BAAA,IAAA,oBAAA,IAAA,sBAAA,IAAA,wBAAA,IAAA,wBAAA,IAAA,yBAAA,IAAA,mBAAA,IAAA,2BAAA,IAAA,kBAAA,IAAA,4BAAA,IAAA,qBAAA,IAAA,0BAAA,IAAA,2BAAA,IAAA,qCAAA,IAAA,oBAAA,IAAA,oBAAA,IAAA,gCAAA,IAAA,4BAAA,IAAA,oBAAA,IAAA,wBAAA,IAAA,4BAAA,IAAA,0BAAA,IAAA,sBAAA,IAAA,yBAAA,IAAA,kCAAA,gCAAA,QAAA,QAAA,WAAA,MAAA"}
|
package/lib/rpc.d.ts
CHANGED
|
@@ -1185,7 +1185,27 @@ export declare const OntologyRpcs: RpcGroup.RpcGroup<Rpc.Rpc<"Accept", Schema.Co
|
|
|
1185
1185
|
}>>>;
|
|
1186
1186
|
readonly eventCount: Schema.optional<Schema.Number>;
|
|
1187
1187
|
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
1188
|
-
}>>, typeof BackendError>, Schema.Never, typeof OntologyErrorProjection, never> | Rpc.Rpc<"
|
|
1188
|
+
}>>, typeof BackendError>, Schema.Never, typeof OntologyErrorProjection, never> | Rpc.Rpc<"UpdateView", Schema.Struct<{
|
|
1189
|
+
session: Schema.Struct<{
|
|
1190
|
+
readonly client: Schema.Struct<{
|
|
1191
|
+
readonly sourceId: Schema.NonEmptyString;
|
|
1192
|
+
readonly clientId: Schema.NonEmptyString;
|
|
1193
|
+
readonly resumeKey: Schema.NonEmptyString;
|
|
1194
|
+
}>;
|
|
1195
|
+
readonly connectionId: Schema.NonEmptyString;
|
|
1196
|
+
}>;
|
|
1197
|
+
view: Schema.Codec<{
|
|
1198
|
+
readonly generation: number;
|
|
1199
|
+
readonly selection: {
|
|
1200
|
+
readonly subsets: readonly {
|
|
1201
|
+
readonly objectType: string;
|
|
1202
|
+
readonly query?: import("@party-stack/ontology-storage").Query | undefined;
|
|
1203
|
+
}[];
|
|
1204
|
+
readonly actionIds: readonly string[];
|
|
1205
|
+
readonly inspectActions?: boolean | undefined;
|
|
1206
|
+
};
|
|
1207
|
+
}, string, never, never>;
|
|
1208
|
+
}>, Schema.Void, typeof BackendError, typeof OntologyErrorProjection, never> | Rpc.Rpc<"ValidateAction", Schema.Codec<{
|
|
1189
1209
|
readonly name: string;
|
|
1190
1210
|
readonly parameters: {
|
|
1191
1211
|
readonly [x: string]: unknown;
|
|
@@ -2897,6 +2917,21 @@ export declare const makeOntologyRpcClient: Effect.Effect<{
|
|
|
2897
2917
|
readonly [x: string]: string | number | boolean;
|
|
2898
2918
|
};
|
|
2899
2919
|
}[], BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced"> | import("effect/rpc/RpcClientError").RpcClientError, never>;
|
|
2920
|
+
readonly UpdateView: <const AsQueue extends boolean = false, const Discard = false>(input: {
|
|
2921
|
+
readonly session: {
|
|
2922
|
+
readonly client: {
|
|
2923
|
+
readonly sourceId: string;
|
|
2924
|
+
readonly clientId: string;
|
|
2925
|
+
readonly resumeKey: string;
|
|
2926
|
+
};
|
|
2927
|
+
readonly connectionId: string;
|
|
2928
|
+
};
|
|
2929
|
+
readonly view: unknown;
|
|
2930
|
+
}, options?: {
|
|
2931
|
+
readonly headers?: import("effect/http/Headers").Input | undefined;
|
|
2932
|
+
readonly context?: Context.Context<never> | undefined;
|
|
2933
|
+
readonly discard?: Discard | undefined;
|
|
2934
|
+
} | undefined) => Effect.Effect<Discard extends true ? void : void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced"> | import("effect/rpc/RpcClientError").RpcClientError | (Discard extends true ? never : BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">), never>;
|
|
2900
2935
|
readonly ValidateAction: <const AsQueue extends boolean = false, const Discard = false>(input: unknown, options?: {
|
|
2901
2936
|
readonly headers?: import("effect/http/Headers").Input | undefined;
|
|
2902
2937
|
readonly context?: Context.Context<never> | undefined;
|
|
@@ -3052,6 +3087,10 @@ export type OntologyRpcRequest = OntologyOperationRequest | {
|
|
|
3052
3087
|
readonly operation: "SubscribeState";
|
|
3053
3088
|
readonly session: ClientSession;
|
|
3054
3089
|
readonly view: ClientView;
|
|
3090
|
+
} | {
|
|
3091
|
+
readonly operation: "UpdateView";
|
|
3092
|
+
readonly session: ClientSession;
|
|
3093
|
+
readonly view: ClientView;
|
|
3055
3094
|
} | {
|
|
3056
3095
|
readonly operation: "AckDelivery";
|
|
3057
3096
|
readonly kind: "committed" | "speculative";
|
|
@@ -3098,7 +3137,7 @@ export interface OntologyRpcServerOptions<R = never> extends ErrorProjectionOpti
|
|
|
3098
3137
|
}
|
|
3099
3138
|
/** Administrative resources use the same ontology RPCs and transport. Access is
|
|
3100
3139
|
* still gated by the parent endpoint before the resource is acquired. */
|
|
3101
|
-
export declare const ontologyRpcHandlers: <R>(options: OntologyRpcServerOptions<R>) => Layer.Layer<Rpc.Handler<"Accept"> | Rpc.Handler<"AckDelivery"> | Rpc.Handler<"Acknowledge"> | Rpc.Handler<"ApplyAction"> | Rpc.Handler<"AttachmentMetadata"> | Rpc.Handler<"Changes"> | Rpc.Handler<"ClearPin"> | Rpc.Handler<"ControlOutbox"> | Rpc.Handler<"CreateAttachment"> | Rpc.Handler<"Decrypt"> | Rpc.Handler<"DeleteLocalData"> | Rpc.Handler<"Demand"> | Rpc.Handler<"Describe"> | Rpc.Handler<"LoadSubset"> | Rpc.Handler<"OpenClient"> | Rpc.Handler<"PullChanges"> | Rpc.Handler<"Query"> | Rpc.Handler<"QueryFunction"> | Rpc.Handler<"Read"> | Rpc.Handler<"ReadAttachment"> | Rpc.Handler<"ReadPin"> | Rpc.Handler<"ReleaseOwner"> | Rpc.Handler<"ReplicaStatus"> | Rpc.Handler<"ResolveActionParameters"> | Rpc.Handler<"SetPin"> | Rpc.Handler<"Submit"> | Rpc.Handler<"SubscribeSelection"> | Rpc.Handler<"SubscribeState"> | Rpc.Handler<"Traces"> | Rpc.Handler<"ValidateAction"> | Rpc.Handler<"WatchChanges"> | Rpc.Handler<"WatchPin"> | Rpc.Handler<"WatchSubset"> | Rpc.Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, never, Exclude<Exclude<R, never>, Scope.Scope> | Exclude<Exclude<Exclude<R, never>, Scope.Scope>, Scope.Scope>>;
|
|
3140
|
+
export declare const ontologyRpcHandlers: <R>(options: OntologyRpcServerOptions<R>) => Layer.Layer<Rpc.Handler<"Accept"> | Rpc.Handler<"AckDelivery"> | Rpc.Handler<"Acknowledge"> | Rpc.Handler<"ApplyAction"> | Rpc.Handler<"AttachmentMetadata"> | Rpc.Handler<"Changes"> | Rpc.Handler<"ClearPin"> | Rpc.Handler<"ControlOutbox"> | Rpc.Handler<"CreateAttachment"> | Rpc.Handler<"Decrypt"> | Rpc.Handler<"DeleteLocalData"> | Rpc.Handler<"Demand"> | Rpc.Handler<"Describe"> | Rpc.Handler<"LoadSubset"> | Rpc.Handler<"OpenClient"> | Rpc.Handler<"PullChanges"> | Rpc.Handler<"Query"> | Rpc.Handler<"QueryFunction"> | Rpc.Handler<"Read"> | Rpc.Handler<"ReadAttachment"> | Rpc.Handler<"ReadPin"> | Rpc.Handler<"ReleaseOwner"> | Rpc.Handler<"ReplicaStatus"> | Rpc.Handler<"ResolveActionParameters"> | Rpc.Handler<"SetPin"> | Rpc.Handler<"Submit"> | Rpc.Handler<"SubscribeSelection"> | Rpc.Handler<"SubscribeState"> | Rpc.Handler<"Traces"> | Rpc.Handler<"UpdateView"> | Rpc.Handler<"ValidateAction"> | Rpc.Handler<"WatchChanges"> | Rpc.Handler<"WatchPin"> | Rpc.Handler<"WatchSubset"> | Rpc.Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, never, Exclude<Exclude<R, never>, Scope.Scope> | Exclude<Exclude<Exclude<R, never>, Scope.Scope>, Scope.Scope>>;
|
|
3102
3141
|
export type OntologyRpcClient = Effect.Success<ReturnType<typeof RpcClient.make<RpcGroup.Rpcs<typeof OntologyRpcs>>>>;
|
|
3103
3142
|
/** HTTP byte operations use the same incompatibility notification as typed RPC. */
|
|
3104
3143
|
export declare const observeOntologyClientFailure: <A, R>(client: OntologyClient, work: Effect.Effect<A, BackendError, R>) => Effect.Effect<A, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R>;
|
package/lib/rpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","names":["OntologyDescription"],"sources":["../src/rpc.ts"],"mappings":";;;;;;;;;;;;;;cAmEM,kBAAgB,OAAA;
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","names":["OntologyDescription"],"sources":["../src/rpc.ts"],"mappings":";;;;;;;;;;;;;;cAmEM,kBAAgB,OAAA;qBA0DT,cAAY,SAAA,SAAA,IAAA,cAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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QACnC,kBAAkB,UAAU,KAAK,SAAS,YAAY;;qBAiE7C,+BAAgC,GAAG,GAAC,QACrC,gBAAc,MAChB,OAAO,OAAO,GAAG,cAAc,OAAE,OAAA,OAAA,GAAA,iWAAA;;qBAuL9B,6BAA0B,QAVvB,mBAAiB,UACf,0BACT,OAAO,OAAO,gBAAgB,cAAc,MAAM;;;;;;qBAc9C,oCAAiC,QAhB9B,mBAAiB,UACf,0BACT,OAAO,OAAO,gBAAgB,cAAc,MAAM"}
|
package/lib/rpc.js
CHANGED
|
@@ -45,6 +45,12 @@ const ReplicaRpcs = RpcGroup.make(Rpc.make("Describe", {
|
|
|
45
45
|
success: DeliveryFrameCodec,
|
|
46
46
|
error: BackendError,
|
|
47
47
|
stream: true
|
|
48
|
+
}), Rpc.make("UpdateView", {
|
|
49
|
+
payload: {
|
|
50
|
+
session: ClientSessionSchema,
|
|
51
|
+
view: ClientViewCodec
|
|
52
|
+
},
|
|
53
|
+
error: BackendError
|
|
48
54
|
}), Rpc.make("AckDelivery", {
|
|
49
55
|
payload: {
|
|
50
56
|
kind: Schema.Literals(["committed", "speculative"]),
|
|
@@ -101,6 +107,7 @@ const clientSyncOperations = /* @__PURE__ */ new Set([
|
|
|
101
107
|
"SubscribeSelection",
|
|
102
108
|
"AckDelivery",
|
|
103
109
|
"SubscribeState",
|
|
110
|
+
"UpdateView",
|
|
104
111
|
"OpenClient",
|
|
105
112
|
"Read",
|
|
106
113
|
"Submit",
|
|
@@ -248,6 +255,18 @@ const baseOntologyRpcHandlers = (options) => {
|
|
|
248
255
|
} : change)
|
|
249
256
|
})));
|
|
250
257
|
})),
|
|
258
|
+
UpdateView: (request, context) => authorize({
|
|
259
|
+
operation: "UpdateView",
|
|
260
|
+
...request
|
|
261
|
+
}, context.headers).pipe(Effect.andThen(() => {
|
|
262
|
+
if (snapshots || !source.subscribe) return unavailableDelivery();
|
|
263
|
+
return source.updateView ? source.updateView(request.session, request.view) : Effect.fail(new BackendError({
|
|
264
|
+
operation: "UpdateView",
|
|
265
|
+
kind: "ViewReplaced",
|
|
266
|
+
retryable: true,
|
|
267
|
+
message: "This source replaces views by subscribing again."
|
|
268
|
+
}));
|
|
269
|
+
})),
|
|
251
270
|
AckDelivery: (request, context) => authorize({
|
|
252
271
|
operation: "AckDelivery",
|
|
253
272
|
...request
|
|
@@ -558,6 +577,10 @@ const openProtocolClient = Effect.fnUntraced(function* (client, options, accept,
|
|
|
558
577
|
kind: "speculative",
|
|
559
578
|
position
|
|
560
579
|
}).pipe(Effect.mapError(unavailable)) : void 0,
|
|
580
|
+
updateView: description.stateDelivery ? (session, view) => client.UpdateView({
|
|
581
|
+
session,
|
|
582
|
+
view
|
|
583
|
+
}).pipe(Effect.mapError(unavailable)) : void 0,
|
|
561
584
|
acknowledge: (session, revision, through, viewGeneration) => client.Acknowledge({
|
|
562
585
|
session,
|
|
563
586
|
revision,
|
package/lib/rpc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.js","names":[],"sources":["../src/rpc.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport {\n ClientLeaseSchema,\n ClientSessionSchema,\n ClientTokenSchema,\n} from \"@party-stack/ontology-backend/clients\";\nimport { DeliveryFrameCodec, DeliveryPositionSchema } from \"@party-stack/ontology-backend/delivery\";\nimport { OntologyDescriptionCodec } from \"@party-stack/ontology-backend/description\";\nimport {\n CompiledSubsetCodec,\n ClientStateCodec,\n ClientSubmissionCodec,\n ClientViewCodec,\n ObjectSelectionCodec,\n} from \"@party-stack/ontology-backend/protocol\";\nimport { objectSubset } from \"@party-stack/ontology-backend/subset\";\nimport { pinOntology } from \"@party-stack/ontology-replica\";\nimport {\n ontologyDefinitionSignature,\n ontologyDefinitionContractSignature,\n ontologyDefinitionContractHash,\n ontologyDefinitionHash,\n} from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport {\n Cause,\n Context,\n Deferred,\n Effect,\n Exit,\n Layer,\n PubSub,\n Schema,\n Scope,\n Stream,\n SubscriptionRef,\n} from \"effect\";\nimport { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from \"effect/rpc\";\nimport { expectedBindingHeaders, withExpectedBinding } from \"./bindingFence.js\";\nimport {\n OntologyErrorProjection,\n errorProjectionLayer,\n projectStateFailures,\n projectActionFailure,\n type ErrorProjectionOptions,\n} from \"./errorProjection.js\";\nimport {\n OntologyOperationRpcs,\n ontologyOperationHandlers,\n makeOntologyOperationsClient,\n type OntologyOperationRequest,\n type OntologyOperationsClient,\n} from \"./operations.js\";\nimport { RpcActivity } from \"./rpcActivity.js\";\nimport { makeRpcBackend } from \"./rpcBackend.js\";\nimport type { AttachmentTransferPolicy } from \"./attachmentTransfers.js\";\nimport type { ObjectSelection } from \"@party-stack/ontology-backend\";\nimport type { ClientSession, ClientToken } from \"@party-stack/ontology-backend/clients\";\nimport type { DeliveryFrame } from \"@party-stack/ontology-backend/delivery\";\nimport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nimport type { ClientSubmission, ClientView, OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { CompiledSubset } from \"@party-stack/ontology-backend/subset\";\nimport type { ReplicaService, ReplicaPinControls } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { Headers } from \"effect/http/Headers\";\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst DeliveryStrategy = Schema.Literals([\"auto\", \"snapshot\", \"incremental\"]);\nconst Description = OntologyDescriptionCodec;\nconst ReplicaRpcs = RpcGroup.make(\n Rpc.make(\"Describe\", { success: Description, error: BackendError }),\n Rpc.make(\"SubscribeSelection\", {\n payload: { selection: ObjectSelectionCodec, resume: Schema.optional(DeliveryPositionSchema) },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"SubscribeState\", {\n payload: {\n session: ClientSessionSchema,\n view: ClientViewCodec,\n resume: Schema.optional(DeliveryPositionSchema),\n },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"AckDelivery\", {\n payload: { kind: Schema.Literals([\"committed\", \"speculative\"]), position: DeliveryPositionSchema },\n error: BackendError,\n }),\n Rpc.make(\"Accept\", { payload: ClientSubmissionCodec, error: BackendError }),\n Rpc.make(\"OpenClient\", {\n payload: { resume: Schema.optional(ClientTokenSchema) },\n success: ClientLeaseSchema,\n error: BackendError,\n }),\n Rpc.make(\"Read\", {\n payload: { session: ClientSessionSchema, view: Schema.optional(ClientViewCodec) },\n success: ClientStateCodec,\n error: BackendError,\n }),\n Rpc.make(\"Submit\", { payload: ClientSubmissionCodec, success: ClientStateCodec, error: BackendError }),\n Rpc.make(\"Acknowledge\", {\n payload: {\n session: ClientSessionSchema,\n revision: Counter,\n through: Counter,\n viewGeneration: Schema.optional(Counter),\n },\n error: BackendError,\n }),\n Rpc.make(\"Demand\", {\n payload: CompiledSubsetCodec,\n success: Schema.Literal(\"ready\"),\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"Changes\", { success: Schema.Literal(\"invalidate\"), error: BackendError, stream: true })\n);\n\nexport const OntologyRpcs = ReplicaRpcs.merge(OntologyOperationRpcs).middleware(OntologyErrorProjection);\n\n// Client-only telemetry middleware: classification follows the RPC schema, not\n// method-name guesses or elapsed duration. The server wire contract is unchanged.\nclass SubscriptionTracing extends RpcMiddleware.Service<SubscriptionTracing>()(\n \"@party-stack/ontology-server/SubscriptionTracing\",\n { requiredForClient: true }\n) {}\nconst subscriptionTracingLayer = RpcMiddleware.layerClient(SubscriptionTracing, ({ rpc, request, next }) =>\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? Effect.annotateCurrentSpan(\"activity\", Context.get(rpc.annotations, RpcActivity)).pipe(\n Effect.andThen(next(request))\n )\n : next(request)\n);\nexport const makeTracedRpcClient = <Rpcs extends Rpc.Any>(group: RpcGroup.RpcGroup<Rpcs>) =>\n RpcClient.make(group.middleware(SubscriptionTracing)).pipe(Effect.provide(subscriptionTracingLayer));\n\n/** The in-process transport keeps the same subscription/transfer trace classification. */\nexport const makeTracedRpcClientNoSerialization = <Rpcs extends Rpc.Any, E>(\n group: RpcGroup.RpcGroup<Rpcs>,\n options: Parameters<\n typeof RpcClient.makeNoSerialization<Rpc.AddMiddleware<Rpcs, typeof SubscriptionTracing>, E>\n >[1]\n) =>\n RpcClient.makeNoSerialization(group.middleware(SubscriptionTracing), options).pipe(\n Effect.provide(subscriptionTracingLayer)\n );\n\nexport const makeOntologyRpcClient = makeTracedRpcClient(OntologyRpcs);\n\nexport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nexport interface OntologyClientOptions {\n /** Previously accepted, public source binding; never inferred from cached rows. */\n readonly description?: OntologyDescription;\n /** Validate/adopt definition compatibility after source/context/protocol checks. */\n readonly validate?: (fresh: OntologyDescription) => Effect.Effect<void, BackendError>;\n /** Notification only. Coordinate replacement outside this client scope. */\n readonly onIncompatible?: (error: BackendError) => Effect.Effect<void>;\n}\nexport interface OntologyClientDefinitionStatus {\n readonly status: \"retained\" | \"current\" | \"incompatible\";\n readonly refreshing: boolean;\n readonly error?: BackendError;\n}\nexport interface OntologyClientDefinition {\n readonly get: Effect.Effect<OntologyClientDefinitionStatus>;\n readonly changes: Stream.Stream<OntologyClientDefinitionStatus>;\n /** Explicit, coalesced metadata acquisition. Never required before ordinary operations. */\n readonly refresh: Effect.Effect<OntologyDescription, BackendError>;\n}\n/** A scoped client of an ontology server, separate from Connect's account connections. */\n/** One transport shared by independently scoped, ontology-bound handles. */\nexport interface OntologyServerClient {\n readonly ontology: (\n name?: string,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>;\n}\n\nexport interface OntologyClient {\n /** The accepted description used to construct this binding's fixed capabilities. */\n readonly description: OntologyDescription;\n readonly definition: OntologyClientDefinition;\n readonly sourceId: string;\n readonly definitionHash?: string;\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n readonly context?: Record<string, unknown>;\n readonly operations: OntologyOperationsClient;\n /** Pin controls on the selected persistent replica, when the server advertises them. */\n readonly pins?: ReplicaPinControls;\n /** Ordinary ontology operations over the selected replica's download inventory. */\n readonly pinBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** Finite operations are available for all server roles. */\n readonly backend: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n readonly replication:\n | { readonly kind: \"committed\" }\n | { readonly kind: \"speculative\"; readonly source: OntologySource };\n}\n\nexport type OntologyRpcRequest =\n | OntologyOperationRequest\n | { readonly operation: \"Describe\" | \"Changes\" }\n | { readonly operation: \"OpenClient\"; readonly resume?: ClientToken }\n | { readonly operation: \"Read\"; readonly session: ClientSession; readonly view?: ClientView }\n | { readonly operation: \"Submit\" | \"Accept\"; readonly submission: ClientSubmission }\n | {\n readonly operation: \"SubscribeSelection\";\n readonly selection: ObjectSelection;\n }\n | { readonly operation: \"SubscribeState\"; readonly session: ClientSession; readonly view: ClientView }\n | {\n readonly operation: \"AckDelivery\";\n readonly kind: \"committed\" | \"speculative\";\n readonly position: import(\"@party-stack/ontology-backend/delivery\").DeliveryPosition;\n }\n | {\n readonly operation: \"Acknowledge\";\n readonly session: ClientSession;\n readonly revision: number;\n readonly through: number;\n readonly viewGeneration?: number;\n }\n | { readonly operation: \"Demand\"; readonly subset: CompiledSubset };\n\n/** Bind to an authenticated source/principal partition. Authorization is mandatory:\n * granting domain row access alone does not authorize action parameters or base\n * state inspection. Restricted sources must also project their returned state.\n */\nexport interface OntologyRpcServerOptions<R = never> extends ErrorProjectionOptions {\n /** Already projected client context. Never use request payloads as trusted context. */\n readonly context?: Record<string, unknown>;\n readonly attachmentTransfers?: AttachmentTransferPolicy<R>;\n /** Opt into downstream watches, change reads and replication sessions. Finite\n * queries/actions and the backend's own upstream lifecycle remain available.\n */\n readonly enableRealtime?: boolean;\n /** Outgoing replication only. Snapshot uses invalidations and finite reads;\n * incremental requires native selected delivery. Auto preserves capability selection.\n */\n readonly deliveryStrategy?: Schema.Schema.Type<typeof DeliveryStrategy>;\n /** Server-controlled selected-delivery capacity, frame and acknowledgment bounds. */\n readonly delivery?: import(\"@party-stack/ontology-backend/delivery\").DeliveryPolicy;\n readonly source?: OntologySource;\n readonly replica?: ReplicaService;\n readonly pins?: ReplicaPinControls;\n readonly traces?: TraceStore;\n readonly backend?: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n /** Worker bootstrap may run while transport starts accepting requests. */\n readonly ready?: Effect.Effect<void, BackendError, R>;\n /** Explicit local-partition administration; omitted helpers cannot delete data or stop an owner. */\n readonly deleteLocalData?: Effect.Effect<void, BackendError, R>;\n readonly releaseOwner?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (\n request: OntologyRpcRequest,\n headers: Headers\n ) => Effect.Effect<void, BackendError, R>;\n}\n\n// This gate also rejects direct RPC calls: capability discovery is not enforcement.\nconst clientSyncOperations: ReadonlySet<OntologyRpcRequest[\"operation\"]> = new Set([\n \"WatchSubset\",\n \"WatchChanges\",\n \"PullChanges\",\n \"SubscribeSelection\",\n \"AckDelivery\",\n \"SubscribeState\",\n \"OpenClient\",\n \"Read\",\n \"Submit\",\n \"Accept\",\n \"Acknowledge\",\n \"Demand\",\n \"Changes\",\n]);\n\nconst baseOntologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) => {\n const clientSync = options.enableRealtime === true;\n const bindingAuthorization = withExpectedBinding(options);\n const authorize = Effect.fnUntraced(function* (request: OntologyRpcRequest, headers: Headers) {\n yield* bindingAuthorization(request, headers);\n if (!clientSync && clientSyncOperations.has(request.operation))\n return yield* new BackendError({\n operation: request.operation,\n kind: \"NotImplemented\",\n message: \"Client synchronization is disabled on this endpoint.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n });\n });\n const snapshots = options.deliveryStrategy === \"snapshot\";\n // Snapshot readers must not silently switch to the committed journal path.\n // Its watch stream can still provide ordinary subset invalidation hints.\n const operationOptions = snapshots\n ? {\n ...options,\n get replica() {\n return options.replica;\n },\n get backend() {\n const backend = options.backend;\n if (!backend) return undefined;\n const watch = backend.changes?.watch;\n return {\n ...backend,\n changes: undefined,\n watchSubset: backend.watchSubset ?? (watch ? () => watch : undefined),\n };\n },\n }\n : options;\n const unavailableSource = () =>\n Effect.fail(\n new BackendError({\n operation: \"replication\",\n kind: \"NotImplemented\",\n message: \"This endpoint serves stateless operations only.\",\n retryable: false,\n })\n );\n const unavailableDelivery = () =>\n Effect.fail(\n new BackendError({\n operation: \"delivery\",\n kind: \"NotImplemented\",\n message: \"Selected incremental delivery is disabled or unavailable on this endpoint.\",\n retryable: false,\n })\n );\n const source: OntologySource = options.source ?? {\n sourceId: options.backend?.sourceId ?? \"stateless\",\n supportsIdempotency: options.backend?.supportsIdempotency ?? false,\n openClient: unavailableSource,\n read: unavailableSource,\n submit: unavailableSource,\n acknowledge: unavailableSource,\n demand: () => Stream.fromEffect(unavailableSource()),\n subscribeChanges: unavailableSource(),\n };\n return ReplicaRpcs.toLayer({\n Describe: (_, context) =>\n authorize({ operation: \"Describe\" }, context.headers).pipe(\n Effect.andThen(options.ready ?? Effect.void),\n Effect.andThen(\n Effect.gen(function* () {\n const strategy = yield* Schema.decodeUnknownEffect(DeliveryStrategy)(\n options.deliveryStrategy ?? \"auto\"\n ).pipe(\n Effect.mapError(\n () =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid delivery strategy.\",\n retryable: false,\n })\n )\n );\n const committedDelivery =\n clientSync &&\n Boolean(\n options.backend?.subscribeSelection && options.backend.acknowledgeDelivery\n );\n const speculativeDelivery =\n clientSync &&\n Boolean(source.subscribe && source.acknowledgeDelivery && source.accept);\n if (\n clientSync &&\n strategy === \"incremental\" &&\n !(options.source ? speculativeDelivery : committedDelivery)\n )\n return yield* new BackendError({\n operation: \"describe\",\n kind: \"NotImplemented\",\n message: \"This source does not support incremental selected delivery.\",\n retryable: false,\n });\n const signature = options.ir\n ? yield* Effect.try({\n try: () => ontologyDefinitionSignature(options.ir!),\n catch: (cause) =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid ontology definition.\",\n retryable: false,\n cause,\n }),\n })\n : undefined;\n // Cached per definition: Describe must not rehash a large IR per client.\n const definitionHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n return {\n version: 1 as const,\n replication:\n clientSync && options.source\n ? (\"speculative\" as const)\n : (\"committed\" as const),\n definitionHash,\n sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? \"stateless\",\n ir: options.ir,\n context: options.context,\n supportsIdempotency:\n options.source?.supportsIdempotency ??\n options.backend?.supportsIdempotency ??\n false,\n delivery: !snapshots && committedDelivery,\n stateDelivery: Boolean(options.source) && !snapshots && speculativeDelivery,\n changes: clientSync && Boolean(operationOptions.backend?.changes),\n watchChanges: clientSync && Boolean(operationOptions.backend?.changes?.watch),\n watchSubset:\n clientSync &&\n Boolean(\n operationOptions.backend?.watchSubset ||\n options.ir?.objectTypes.some(\n (type) =>\n typeof operationOptions.backend?.refresh?.(\n objectSubset(type.name)\n )?.pollIntervalMs === \"number\"\n )\n ),\n actionParameterResolution: Boolean(\n options.backend?.resolveActionParameters || options.replica\n ),\n queries: Boolean(options.backend),\n pins: Boolean(options.pins ?? options.replica),\n attachments: options.backend\n ? options.backend.attachments && {\n stage: Boolean(options.backend.attachments.stage),\n }\n : options.replica\n ? { stage: true }\n : undefined,\n encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica),\n };\n })\n )\n ),\n SubscribeSelection: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize(\n { operation: \"SubscribeSelection\", selection: request.selection },\n context.headers\n );\n if (snapshots || !options.backend?.subscribeSelection)\n return yield* unavailableDelivery();\n const delivery = yield* options.backend.subscribeSelection(\n request.selection,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.mapEffect((frame) =>\n Effect.gen(function* () {\n if (!frame.metadata) return frame;\n if (frame.metadata.sourceId !== options.backend!.sourceId)\n return yield* new BackendError({\n operation: \"delivery\",\n kind: \"SourceMismatch\",\n message: \"The committed delivery source changed.\",\n retryable: false,\n });\n // The endpoint binds one logical source/session lifetime. A replica\n // server's committed facet forwards upstream rows under that identity.\n return {\n ...frame,\n metadata: {\n ...frame.metadata,\n sourceId:\n options.source?.sourceId ??\n options.backend?.sourceId ??\n \"stateless\",\n },\n };\n })\n )\n );\n })\n ),\n SubscribeState: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize({ operation: \"SubscribeState\", ...request }, context.headers);\n if (snapshots || !source.subscribe) return yield* unavailableDelivery();\n const delivery = yield* source.subscribe(\n request.session,\n request.view,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.map((frame) => ({\n ...frame,\n changes: frame.changes.map((change) =>\n change.kind === \"put\" &&\n (change.record.kind === \"pending\" || change.record.kind === \"completed\")\n ? {\n ...change,\n record: {\n ...change.record,\n value: projectActionFailure(change.record.value, options),\n },\n }\n : change\n ),\n }))\n );\n })\n ),\n AckDelivery: (request, context) =>\n authorize({ operation: \"AckDelivery\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots) return unavailableDelivery();\n const ack =\n request.kind === \"committed\"\n ? options.backend?.acknowledgeDelivery\n : source.acknowledgeDelivery;\n return ack ? ack(request.position) : unavailableSource();\n })\n ),\n Accept: (request, context) =>\n authorize({ operation: \"Accept\", submission: request }, context.headers).pipe(\n Effect.andThen(() => (source.accept ? source.accept(request) : unavailableSource()))\n ),\n OpenClient: (request, context) =>\n authorize({ operation: \"OpenClient\", ...request }, context.headers).pipe(\n Effect.andThen(() => source.openClient(request.resume))\n ),\n Read: (request, context) =>\n authorize({ operation: \"Read\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.read(request.session, request.view).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Submit: (request, context) =>\n authorize({ operation: \"Submit\", submission: request }, context.headers).pipe(\n Effect.andThen(() =>\n source.submit(request).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Acknowledge: (request, context) =>\n authorize({ operation: \"Acknowledge\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.acknowledge(\n request.session,\n request.revision,\n request.through,\n request.viewGeneration\n )\n )\n ),\n Demand: (subset, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Demand\", subset }, context.headers);\n return source.demand(subset).pipe(Stream.as(\"ready\" as const));\n })\n ),\n Changes: (_, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Changes\" }, context.headers);\n const changes = options.source ? yield* source.subscribeChanges : undefined;\n if (!changes) return yield* unavailableSource();\n // A new stream is a repair boundary, not proof that no updates were missed.\n return Stream.concat(\n Stream.make(\"invalidate\" as const),\n Stream.map(changes, () => \"invalidate\" as const)\n );\n })\n ),\n }).pipe(\n Layer.merge(ontologyOperationHandlers(operationOptions, authorize)),\n Layer.merge(errorProjectionLayer(options))\n );\n};\n\nconst resourceHeader = \"x-party-stack-resource\";\n\n/** Administrative resources use the same ontology RPCs and transport. Access is\n * still gated by the parent endpoint before the resource is acquired. */\nexport const ontologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);\n const pins = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.replica)\n return yield* new BackendError({\n operation: \"pins\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint does not own downloads.\",\n });\n const backend = yield* options.replica.demand.pins.backend;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend,\n ir: pinOntology,\n context: options.context,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => options.authorize({ operation: \"ReadPin\" }, headers),\n }),\n scope\n );\n })\n );\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n type Handler = RpcGroup.HandlersFrom<Rpcs>[Rpcs[\"_tag\"]];\n const handlers = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => {\n const invoke = (payload: never, request: Parameters<Handler>[1]) =>\n Effect.gen(function* () {\n const resource = request.headers[resourceHeader];\n if (resource !== undefined && resource !== \"pins\")\n return yield* new BackendError({\n operation: \"ontology.resource\",\n kind: \"NotFound\",\n retryable: false,\n message: \"Unknown ontology resource.\",\n });\n if (resource === \"pins\")\n yield* options.authorize({ operation: \"ReadPin\" }, request.headers);\n const context = resource === \"pins\" ? yield* pins : ordinary;\n const handler = yield* OntologyRpcs.accessHandler(tag as Rpcs[\"_tag\"]).pipe(\n Effect.provideContext(context)\n );\n return handler(payload, request);\n });\n return [\n tag,\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? (payload: never, request: Parameters<Handler>[1]) =>\n Stream.unwrap(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Stream.Stream<unknown, BackendError, R>\n )\n )\n )\n : (payload: never, request: Parameters<Handler>[1]) =>\n Effect.flatten(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Effect.Effect<unknown, BackendError, R>\n )\n )\n ),\n ];\n })\n ) as unknown as {\n readonly [Procedure in Rpcs as Procedure[\"_tag\"]]: Rpc.ToHandlerFn<\n Procedure,\n R | Scope.Scope\n >;\n };\n return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));\n })\n );\n\nconst selectPinResource = (client: OntologyRpcClient): OntologyRpcClient =>\n Object.fromEntries(\n [...OntologyRpcs.requests.keys()].map((tag) => [\n tag,\n (payload: unknown, settings?: { readonly headers?: Record<string, string> }) =>\n Reflect.apply(Reflect.get(client, tag), client, [\n payload,\n { ...settings, headers: { ...settings?.headers, [resourceHeader]: \"pins\" } },\n ]),\n ])\n ) as OntologyRpcClient;\n\nexport type OntologyRpcClient = Effect.Success<\n ReturnType<typeof RpcClient.make<RpcGroup.Rpcs<typeof OntologyRpcs>>>\n>;\nconst unavailable = (cause: unknown) => classifyBackendFailure(\"remote.protocol\", cause);\nconst copyDescription = (description: OntologyDescription) =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(Description)(Schema.encodeSync(Description)(description)),\n catch: (cause) =>\n new BackendError({\n operation: \"remote.describe\",\n kind: \"InvalidResponse\",\n retryable: false,\n message: \"Invalid ontology description.\",\n cause,\n }),\n });\n\nconst descriptionValue = Table.make<unknown>({ name: \"ontology-description-identity\" });\nconst sameDescriptionValue = (left: unknown, right: unknown) =>\n descriptionValue.encode(left) === descriptionValue.encode(right);\nconst protocolIdentity = (description: OntologyDescription) => ({\n version: description.version,\n replication: description.replication,\n supportsIdempotency: description.supportsIdempotency,\n delivery: Boolean(description.delivery),\n stateDelivery: Boolean(description.stateDelivery),\n changes: Boolean(description.changes),\n watchChanges: Boolean(description.watchChanges),\n watchSubset: Boolean(description.watchSubset),\n actionParameterResolution: Boolean(description.actionParameterResolution),\n queries: Boolean(description.queries),\n pins: Boolean(description.pins),\n attachments: Boolean(description.attachments),\n stageAttachments: Boolean(description.attachments?.stage),\n encrypted: Boolean(description.encrypted),\n});\nconst checkBootstrapBinding = (accepted: OntologyDescription, fresh: OntologyDescription) =>\n Effect.gen(function* () {\n if (fresh.sourceId !== accepted.sourceId)\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology source changed.\",\n });\n if (!sameDescriptionValue(fresh.context ?? {}, accepted.context ?? {}))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology context changed.\",\n });\n if (!sameDescriptionValue(protocolIdentity(fresh), protocolIdentity(accepted)))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology protocol capabilities changed.\",\n });\n });\n\nconst definitionFailure: unique symbol = Symbol(\"OntologyClient.definitionFailure\");\ninterface InternalDefinition extends OntologyClientDefinition {\n readonly [definitionFailure]: (error: BackendError) => Effect.Effect<void>;\n}\n/** HTTP byte operations use the same incompatibility notification as typed RPC. */\nexport const observeOntologyClientFailure = <A, R>(\n client: OntologyClient,\n work: Effect.Effect<A, BackendError, R>\n) =>\n work.pipe(\n Effect.tapError(\n (error) =>\n (client.definition as Partial<InternalDefinition>)[definitionFailure]?.(error) ?? Effect.void\n )\n );\n\ntype AcceptDescription = (\n description: OntologyDescription\n) => Effect.Effect<OntologyDescription, BackendError>;\n\nconst makeDefinitionClient = Effect.fnUntraced(function* (\n raw: OntologyRpcClient,\n description: OntologyDescription,\n options: OntologyClientOptions | undefined\n) {\n const scope = yield* Effect.scope;\n const state = yield* SubscriptionRef.make<OntologyClientDefinitionStatus>({\n status: options?.description ? \"retained\" : \"current\",\n refreshing: false,\n });\n yield* Effect.addFinalizer(() => PubSub.shutdown(state.pubsub));\n let attempt: Deferred.Deferred<OntologyDescription, BackendError> | undefined;\n const incompatible = (error: BackendError) =>\n error.kind === \"SchemaMismatch\" || error.kind === \"SourceMismatch\";\n const notify = (error: BackendError) => options?.onIncompatible?.(error) ?? Effect.void;\n const failed = Effect.fnUntraced(function* (error: BackendError) {\n const previous = yield* SubscriptionRef.get(state);\n yield* SubscriptionRef.set(state, {\n ...previous,\n status: incompatible(error) ? \"incompatible\" : previous.status,\n refreshing: false,\n error: previous.status === \"incompatible\" && !incompatible(error) ? previous.error : error,\n });\n if (\n incompatible(error) &&\n (previous.status !== \"incompatible\" || previous.error?.kind !== error.kind)\n )\n yield* notify(error).pipe(\n Effect.catchCause((cause) =>\n Effect.logError(\"Ontology incompatibility callback failed\", cause)\n ),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n const validate =\n options?.validate ??\n ((fresh: OntologyDescription) =>\n (!fresh.ir && !description.ir) ||\n (fresh.ir &&\n description.ir &&\n ontologyDefinitionContractSignature(fresh.ir) ===\n ontologyDefinitionContractSignature(description.ir))\n ? Effect.void\n : Effect.fail(\n new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology definition changed.\",\n })\n ));\n const refresh = Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n if (attempt) return restore(Deferred.await(attempt));\n const pending = Deferred.makeUnsafe<OntologyDescription, BackendError>();\n attempt = pending;\n const check = SubscriptionRef.update(state, (current) => ({ ...current, refreshing: true })).pipe(\n Effect.andThen(raw.Describe().pipe(Effect.mapError(unavailable))),\n Effect.tap((fresh) => checkBootstrapBinding(description, fresh)),\n Effect.tap(validate),\n Effect.tap(() => SubscriptionRef.set(state, { status: \"current\", refreshing: false })),\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {\n const error = Cause.findErrorOption(exit.cause);\n yield* failed(\n error._tag === \"Some\" ? error.value : unavailable(Cause.squash(exit.cause))\n );\n }\n if (attempt === pending) attempt = undefined;\n yield* Deferred.done(pending, exit);\n })\n ),\n Effect.catchCause(() => Effect.void)\n );\n return Effect.forkIn(check, scope, { startImmediately: true }).pipe(\n Effect.andThen(restore(Deferred.await(pending)))\n );\n })\n );\n const report = Effect.fnUntraced(function* (error: BackendError) {\n if (!incompatible(error)) return;\n yield* failed(error);\n // Rebinding a source/account needs an explicit acquisition. A metadata\n // refresh must not turn that failure into permission to reset its cache.\n if (error.kind === \"SourceMismatch\") return;\n yield* refresh.pipe(\n Effect.catchCause(() => Effect.void),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n const headers = expectedBindingHeaders(description);\n // Delivery metadata already carries the contract hash. Check it at the\n // client boundary too, so a receiver's schema failure reaches definition\n // lifecycle handling even when the transport successfully delivered a frame.\n const schemaHash = yield* Effect.cached(\n Effect.suspend(() =>\n description.ir ? ontologyDefinitionContractHash(description.ir) : Effect.succeed(undefined)\n ).pipe(Effect.mapError(unavailable))\n );\n const checkFrame = Effect.fnUntraced(function* (frame: DeliveryFrame) {\n if (frame.metadata) {\n if (frame.metadata.sourceId !== description.sourceId)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The delivered ontology source changed.\",\n });\n const expected = yield* schemaHash;\n if (expected !== undefined && frame.metadata.schemaHash !== expected)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The delivered ontology definition changed.\",\n });\n }\n return frame;\n });\n const client = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => [\n tag,\n (payload: unknown, options?: { readonly headers?: Record<string, string> }) => {\n const invoke = () =>\n Reflect.apply(Reflect.get(raw, tag), raw, [\n payload,\n tag === \"Describe\"\n ? options\n : { ...options, headers: { ...options?.headers, ...headers } },\n ]);\n if (RpcSchema.isStreamSchema(rpc.successSchema)) {\n const stream =\n tag === \"SubscribeSelection\" || tag === \"SubscribeState\"\n ? (invoke() as Stream.Stream<DeliveryFrame, BackendError>).pipe(\n Stream.mapEffect(checkFrame)\n )\n : (invoke() as Stream.Stream<unknown, BackendError>);\n return stream.pipe(Stream.tapError(report));\n }\n return (invoke() as Effect.Effect<unknown, BackendError>).pipe(Effect.tapError(report));\n },\n ])\n ) as unknown as OntologyRpcClient;\n const definition: InternalDefinition = {\n get: SubscriptionRef.get(state),\n changes: SubscriptionRef.changes(state),\n refresh,\n [definitionFailure]: report,\n };\n return {\n client,\n definition,\n };\n});\n\nconst makeProtocolClient = (accept: AcceptDescription) => {\n const open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope> = Effect.fn(\"RemoteOntology.protocol\")(\n function* (client: OntologyRpcClient, options?: OntologyClientOptions) {\n return yield* openProtocolClient(client, options, accept, open);\n }\n );\n return open;\n};\n/** Use the same source contract with Effect RPC's worker, HTTP or socket transport. */\nexport const makeOntologyProtocolClient = makeProtocolClient(copyDescription);\n/** Same-runtime transports without serialization receive the server's own,\n * already validated description. Skip the defensive wire copy: re-encoding and\n * decoding a large definition dominates startup on mobile JavaScript engines,\n * and sharing the definition object lets per-definition signature caches apply.\n */\nexport const makeTrustedOntologyProtocolClient = makeProtocolClient(Effect.succeed);\n\nconst openProtocolClient = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n options: OntologyClientOptions | undefined,\n accept: AcceptDescription,\n open: (client: OntologyRpcClient) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n): Effect.fn.Return<OntologyClient, BackendError, Scope.Scope> {\n // Serialized RPC clients already decoded Describe with its success schema, and\n // a same-runtime client receives the server's validated value: neither needs a\n // second encode/decode copy. Only a caller-retained description is copied.\n const description = yield* options?.description\n ? accept(options.description)\n : client.Describe().pipe(Effect.mapError(unavailable));\n if (options?.description && !description.ir)\n return yield* new BackendError({\n operation: \"remote.bootstrap\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A retained ontology description must include its definition.\",\n });\n const described = yield* makeDefinitionClient(client, description, options);\n const pinBackend = description.pins\n ? open(selectPinResource(client)).pipe(Effect.map((resource) => resource.backend))\n : undefined;\n client = described.client;\n const operations = yield* makeOntologyOperationsClient(client);\n const common = {\n description,\n definition: described.definition,\n operations,\n pins: description.pins ? operations.pins : undefined,\n pinBackend,\n sourceId: description.sourceId,\n definitionHash: description.definitionHash,\n ir: description.ir,\n context: description.context,\n backend: makeRpcBackend(client, description, operations),\n };\n if (description.replication === \"committed\") return { ...common, replication: { kind: \"committed\" } };\n const source: OntologySource = {\n sourceId: description.sourceId,\n outbox: operations.outbox,\n supportsIdempotency: description.supportsIdempotency,\n openClient: (resume) => client.OpenClient({ resume }).pipe(Effect.mapError(unavailable)),\n read: (session, view) => client.Read({ session, view }).pipe(Effect.mapError(unavailable)),\n submit: (request) => client.Submit(request).pipe(Effect.mapError(unavailable)),\n accept: description.stateDelivery\n ? (request) => client.Accept(request).pipe(Effect.mapError(unavailable))\n : undefined,\n subscribe: description.stateDelivery\n ? (session, view, _policy, resume) =>\n Effect.succeed({\n frames: client\n .SubscribeState({ session, view, resume })\n .pipe(Stream.mapError(unavailable)),\n acknowledge: (position) =>\n client\n .AckDelivery({ kind: \"speculative\", position })\n .pipe(Effect.mapError(unavailable)),\n })\n : undefined,\n acknowledgeDelivery: description.stateDelivery\n ? (position) =>\n client.AckDelivery({ kind: \"speculative\", position }).pipe(Effect.mapError(unavailable))\n : undefined,\n acknowledge: (session, revision, through, viewGeneration) =>\n client\n .Acknowledge({ session, revision, through, viewGeneration })\n .pipe(Effect.mapError(unavailable)),\n subscribeChanges: Effect.succeed(\n client.Changes().pipe(\n Stream.map(() => undefined),\n Stream.mapError(unavailable)\n )\n ),\n demand: (subset) => client.Demand(subset).pipe(Stream.as(undefined), Stream.mapError(unavailable)),\n };\n return { ...common, replication: { kind: \"speculative\", source } };\n});\n\nexport { errorProjectionLayer } from \"./errorProjection.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS,OAAO;AAAiB,CAAC,CAAC;AACnG,MAAM,mBAAmB,OAAO,SAAS;CAAC;CAAQ;CAAY;AAAa,CAAC;AAC5E,MAAM,cAAc;AACpB,MAAM,cAAc,SAAS,KACzB,IAAI,KAAK,YAAY;CAAE,SAAS;CAAa,OAAO;AAAa,CAAC,GAClE,IAAI,KAAK,sBAAsB;CAC3B,SAAS;EAAE,WAAW;EAAsB,QAAQ,OAAO,SAAS,sBAAsB;CAAE;CAC5F,SAAS;CACT,OAAO;CACP,QAAQ;AACZ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;GAAE,MAAM;GAAe;EAAO;CAAE;AACrE,CAAC"}
|
|
1
|
+
{"version":3,"file":"rpc.js","names":[],"sources":["../src/rpc.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport {\n ClientLeaseSchema,\n ClientSessionSchema,\n ClientTokenSchema,\n} from \"@party-stack/ontology-backend/clients\";\nimport { DeliveryFrameCodec, DeliveryPositionSchema } from \"@party-stack/ontology-backend/delivery\";\nimport { OntologyDescriptionCodec } from \"@party-stack/ontology-backend/description\";\nimport {\n CompiledSubsetCodec,\n ClientStateCodec,\n ClientSubmissionCodec,\n ClientViewCodec,\n ObjectSelectionCodec,\n} from \"@party-stack/ontology-backend/protocol\";\nimport { objectSubset } from \"@party-stack/ontology-backend/subset\";\nimport { pinOntology } from \"@party-stack/ontology-replica\";\nimport {\n ontologyDefinitionSignature,\n ontologyDefinitionContractSignature,\n ontologyDefinitionContractHash,\n ontologyDefinitionHash,\n} from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport {\n Cause,\n Context,\n Deferred,\n Effect,\n Exit,\n Layer,\n PubSub,\n Schema,\n Scope,\n Stream,\n SubscriptionRef,\n} from \"effect\";\nimport { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from \"effect/rpc\";\nimport { expectedBindingHeaders, withExpectedBinding } from \"./bindingFence.js\";\nimport {\n OntologyErrorProjection,\n errorProjectionLayer,\n projectStateFailures,\n projectActionFailure,\n type ErrorProjectionOptions,\n} from \"./errorProjection.js\";\nimport {\n OntologyOperationRpcs,\n ontologyOperationHandlers,\n makeOntologyOperationsClient,\n type OntologyOperationRequest,\n type OntologyOperationsClient,\n} from \"./operations.js\";\nimport { RpcActivity } from \"./rpcActivity.js\";\nimport { makeRpcBackend } from \"./rpcBackend.js\";\nimport type { AttachmentTransferPolicy } from \"./attachmentTransfers.js\";\nimport type { ObjectSelection } from \"@party-stack/ontology-backend\";\nimport type { ClientSession, ClientToken } from \"@party-stack/ontology-backend/clients\";\nimport type { DeliveryFrame } from \"@party-stack/ontology-backend/delivery\";\nimport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nimport type { ClientSubmission, ClientView, OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { CompiledSubset } from \"@party-stack/ontology-backend/subset\";\nimport type { ReplicaService, ReplicaPinControls } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { Headers } from \"effect/http/Headers\";\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst DeliveryStrategy = Schema.Literals([\"auto\", \"snapshot\", \"incremental\"]);\nconst Description = OntologyDescriptionCodec;\nconst ReplicaRpcs = RpcGroup.make(\n Rpc.make(\"Describe\", { success: Description, error: BackendError }),\n Rpc.make(\"SubscribeSelection\", {\n payload: { selection: ObjectSelectionCodec, resume: Schema.optional(DeliveryPositionSchema) },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"SubscribeState\", {\n payload: {\n session: ClientSessionSchema,\n view: ClientViewCodec,\n resume: Schema.optional(DeliveryPositionSchema),\n },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"UpdateView\", {\n payload: { session: ClientSessionSchema, view: ClientViewCodec },\n error: BackendError,\n }),\n Rpc.make(\"AckDelivery\", {\n payload: { kind: Schema.Literals([\"committed\", \"speculative\"]), position: DeliveryPositionSchema },\n error: BackendError,\n }),\n Rpc.make(\"Accept\", { payload: ClientSubmissionCodec, error: BackendError }),\n Rpc.make(\"OpenClient\", {\n payload: { resume: Schema.optional(ClientTokenSchema) },\n success: ClientLeaseSchema,\n error: BackendError,\n }),\n Rpc.make(\"Read\", {\n payload: { session: ClientSessionSchema, view: Schema.optional(ClientViewCodec) },\n success: ClientStateCodec,\n error: BackendError,\n }),\n Rpc.make(\"Submit\", { payload: ClientSubmissionCodec, success: ClientStateCodec, error: BackendError }),\n Rpc.make(\"Acknowledge\", {\n payload: {\n session: ClientSessionSchema,\n revision: Counter,\n through: Counter,\n viewGeneration: Schema.optional(Counter),\n },\n error: BackendError,\n }),\n Rpc.make(\"Demand\", {\n payload: CompiledSubsetCodec,\n success: Schema.Literal(\"ready\"),\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"Changes\", { success: Schema.Literal(\"invalidate\"), error: BackendError, stream: true })\n);\n\nexport const OntologyRpcs = ReplicaRpcs.merge(OntologyOperationRpcs).middleware(OntologyErrorProjection);\n\n// Client-only telemetry middleware: classification follows the RPC schema, not\n// method-name guesses or elapsed duration. The server wire contract is unchanged.\nclass SubscriptionTracing extends RpcMiddleware.Service<SubscriptionTracing>()(\n \"@party-stack/ontology-server/SubscriptionTracing\",\n { requiredForClient: true }\n) {}\nconst subscriptionTracingLayer = RpcMiddleware.layerClient(SubscriptionTracing, ({ rpc, request, next }) =>\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? Effect.annotateCurrentSpan(\"activity\", Context.get(rpc.annotations, RpcActivity)).pipe(\n Effect.andThen(next(request))\n )\n : next(request)\n);\nexport const makeTracedRpcClient = <Rpcs extends Rpc.Any>(group: RpcGroup.RpcGroup<Rpcs>) =>\n RpcClient.make(group.middleware(SubscriptionTracing)).pipe(Effect.provide(subscriptionTracingLayer));\n\n/** The in-process transport keeps the same subscription/transfer trace classification. */\nexport const makeTracedRpcClientNoSerialization = <Rpcs extends Rpc.Any, E>(\n group: RpcGroup.RpcGroup<Rpcs>,\n options: Parameters<\n typeof RpcClient.makeNoSerialization<Rpc.AddMiddleware<Rpcs, typeof SubscriptionTracing>, E>\n >[1]\n) =>\n RpcClient.makeNoSerialization(group.middleware(SubscriptionTracing), options).pipe(\n Effect.provide(subscriptionTracingLayer)\n );\n\nexport const makeOntologyRpcClient = makeTracedRpcClient(OntologyRpcs);\n\nexport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nexport interface OntologyClientOptions {\n /** Previously accepted, public source binding; never inferred from cached rows. */\n readonly description?: OntologyDescription;\n /** Validate/adopt definition compatibility after source/context/protocol checks. */\n readonly validate?: (fresh: OntologyDescription) => Effect.Effect<void, BackendError>;\n /** Notification only. Coordinate replacement outside this client scope. */\n readonly onIncompatible?: (error: BackendError) => Effect.Effect<void>;\n}\nexport interface OntologyClientDefinitionStatus {\n readonly status: \"retained\" | \"current\" | \"incompatible\";\n readonly refreshing: boolean;\n readonly error?: BackendError;\n}\nexport interface OntologyClientDefinition {\n readonly get: Effect.Effect<OntologyClientDefinitionStatus>;\n readonly changes: Stream.Stream<OntologyClientDefinitionStatus>;\n /** Explicit, coalesced metadata acquisition. Never required before ordinary operations. */\n readonly refresh: Effect.Effect<OntologyDescription, BackendError>;\n}\n/** A scoped client of an ontology server, separate from Connect's account connections. */\n/** One transport shared by independently scoped, ontology-bound handles. */\nexport interface OntologyServerClient {\n readonly ontology: (\n name?: string,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>;\n}\n\nexport interface OntologyClient {\n /** The accepted description used to construct this binding's fixed capabilities. */\n readonly description: OntologyDescription;\n readonly definition: OntologyClientDefinition;\n readonly sourceId: string;\n readonly definitionHash?: string;\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n readonly context?: Record<string, unknown>;\n readonly operations: OntologyOperationsClient;\n /** Pin controls on the selected persistent replica, when the server advertises them. */\n readonly pins?: ReplicaPinControls;\n /** Ordinary ontology operations over the selected replica's download inventory. */\n readonly pinBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** Finite operations are available for all server roles. */\n readonly backend: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n readonly replication:\n | { readonly kind: \"committed\" }\n | { readonly kind: \"speculative\"; readonly source: OntologySource };\n}\n\nexport type OntologyRpcRequest =\n | OntologyOperationRequest\n | { readonly operation: \"Describe\" | \"Changes\" }\n | { readonly operation: \"OpenClient\"; readonly resume?: ClientToken }\n | { readonly operation: \"Read\"; readonly session: ClientSession; readonly view?: ClientView }\n | { readonly operation: \"Submit\" | \"Accept\"; readonly submission: ClientSubmission }\n | {\n readonly operation: \"SubscribeSelection\";\n readonly selection: ObjectSelection;\n }\n | { readonly operation: \"SubscribeState\"; readonly session: ClientSession; readonly view: ClientView }\n | { readonly operation: \"UpdateView\"; readonly session: ClientSession; readonly view: ClientView }\n | {\n readonly operation: \"AckDelivery\";\n readonly kind: \"committed\" | \"speculative\";\n readonly position: import(\"@party-stack/ontology-backend/delivery\").DeliveryPosition;\n }\n | {\n readonly operation: \"Acknowledge\";\n readonly session: ClientSession;\n readonly revision: number;\n readonly through: number;\n readonly viewGeneration?: number;\n }\n | { readonly operation: \"Demand\"; readonly subset: CompiledSubset };\n\n/** Bind to an authenticated source/principal partition. Authorization is mandatory:\n * granting domain row access alone does not authorize action parameters or base\n * state inspection. Restricted sources must also project their returned state.\n */\nexport interface OntologyRpcServerOptions<R = never> extends ErrorProjectionOptions {\n /** Already projected client context. Never use request payloads as trusted context. */\n readonly context?: Record<string, unknown>;\n readonly attachmentTransfers?: AttachmentTransferPolicy<R>;\n /** Opt into downstream watches, change reads and replication sessions. Finite\n * queries/actions and the backend's own upstream lifecycle remain available.\n */\n readonly enableRealtime?: boolean;\n /** Outgoing replication only. Snapshot uses invalidations and finite reads;\n * incremental requires native selected delivery. Auto preserves capability selection.\n */\n readonly deliveryStrategy?: Schema.Schema.Type<typeof DeliveryStrategy>;\n /** Server-controlled selected-delivery capacity, frame and acknowledgment bounds. */\n readonly delivery?: import(\"@party-stack/ontology-backend/delivery\").DeliveryPolicy;\n readonly source?: OntologySource;\n readonly replica?: ReplicaService;\n readonly pins?: ReplicaPinControls;\n readonly traces?: TraceStore;\n readonly backend?: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n /** Worker bootstrap may run while transport starts accepting requests. */\n readonly ready?: Effect.Effect<void, BackendError, R>;\n /** Explicit local-partition administration; omitted helpers cannot delete data or stop an owner. */\n readonly deleteLocalData?: Effect.Effect<void, BackendError, R>;\n readonly releaseOwner?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (\n request: OntologyRpcRequest,\n headers: Headers\n ) => Effect.Effect<void, BackendError, R>;\n}\n\n// This gate also rejects direct RPC calls: capability discovery is not enforcement.\nconst clientSyncOperations: ReadonlySet<OntologyRpcRequest[\"operation\"]> = new Set([\n \"WatchSubset\",\n \"WatchChanges\",\n \"PullChanges\",\n \"SubscribeSelection\",\n \"AckDelivery\",\n \"SubscribeState\",\n \"UpdateView\",\n \"OpenClient\",\n \"Read\",\n \"Submit\",\n \"Accept\",\n \"Acknowledge\",\n \"Demand\",\n \"Changes\",\n]);\n\nconst baseOntologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) => {\n const clientSync = options.enableRealtime === true;\n const bindingAuthorization = withExpectedBinding(options);\n const authorize = Effect.fnUntraced(function* (request: OntologyRpcRequest, headers: Headers) {\n yield* bindingAuthorization(request, headers);\n if (!clientSync && clientSyncOperations.has(request.operation))\n return yield* new BackendError({\n operation: request.operation,\n kind: \"NotImplemented\",\n message: \"Client synchronization is disabled on this endpoint.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n });\n });\n const snapshots = options.deliveryStrategy === \"snapshot\";\n // Snapshot readers must not silently switch to the committed journal path.\n // Its watch stream can still provide ordinary subset invalidation hints.\n const operationOptions = snapshots\n ? {\n ...options,\n get replica() {\n return options.replica;\n },\n get backend() {\n const backend = options.backend;\n if (!backend) return undefined;\n const watch = backend.changes?.watch;\n return {\n ...backend,\n changes: undefined,\n watchSubset: backend.watchSubset ?? (watch ? () => watch : undefined),\n };\n },\n }\n : options;\n const unavailableSource = () =>\n Effect.fail(\n new BackendError({\n operation: \"replication\",\n kind: \"NotImplemented\",\n message: \"This endpoint serves stateless operations only.\",\n retryable: false,\n })\n );\n const unavailableDelivery = () =>\n Effect.fail(\n new BackendError({\n operation: \"delivery\",\n kind: \"NotImplemented\",\n message: \"Selected incremental delivery is disabled or unavailable on this endpoint.\",\n retryable: false,\n })\n );\n const source: OntologySource = options.source ?? {\n sourceId: options.backend?.sourceId ?? \"stateless\",\n supportsIdempotency: options.backend?.supportsIdempotency ?? false,\n openClient: unavailableSource,\n read: unavailableSource,\n submit: unavailableSource,\n acknowledge: unavailableSource,\n demand: () => Stream.fromEffect(unavailableSource()),\n subscribeChanges: unavailableSource(),\n };\n return ReplicaRpcs.toLayer({\n Describe: (_, context) =>\n authorize({ operation: \"Describe\" }, context.headers).pipe(\n Effect.andThen(options.ready ?? Effect.void),\n Effect.andThen(\n Effect.gen(function* () {\n const strategy = yield* Schema.decodeUnknownEffect(DeliveryStrategy)(\n options.deliveryStrategy ?? \"auto\"\n ).pipe(\n Effect.mapError(\n () =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid delivery strategy.\",\n retryable: false,\n })\n )\n );\n const committedDelivery =\n clientSync &&\n Boolean(\n options.backend?.subscribeSelection && options.backend.acknowledgeDelivery\n );\n const speculativeDelivery =\n clientSync &&\n Boolean(source.subscribe && source.acknowledgeDelivery && source.accept);\n if (\n clientSync &&\n strategy === \"incremental\" &&\n !(options.source ? speculativeDelivery : committedDelivery)\n )\n return yield* new BackendError({\n operation: \"describe\",\n kind: \"NotImplemented\",\n message: \"This source does not support incremental selected delivery.\",\n retryable: false,\n });\n const signature = options.ir\n ? yield* Effect.try({\n try: () => ontologyDefinitionSignature(options.ir!),\n catch: (cause) =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid ontology definition.\",\n retryable: false,\n cause,\n }),\n })\n : undefined;\n // Cached per definition: Describe must not rehash a large IR per client.\n const definitionHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n return {\n version: 1 as const,\n replication:\n clientSync && options.source\n ? (\"speculative\" as const)\n : (\"committed\" as const),\n definitionHash,\n sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? \"stateless\",\n ir: options.ir,\n context: options.context,\n supportsIdempotency:\n options.source?.supportsIdempotency ??\n options.backend?.supportsIdempotency ??\n false,\n delivery: !snapshots && committedDelivery,\n stateDelivery: Boolean(options.source) && !snapshots && speculativeDelivery,\n changes: clientSync && Boolean(operationOptions.backend?.changes),\n watchChanges: clientSync && Boolean(operationOptions.backend?.changes?.watch),\n watchSubset:\n clientSync &&\n Boolean(\n operationOptions.backend?.watchSubset ||\n options.ir?.objectTypes.some(\n (type) =>\n typeof operationOptions.backend?.refresh?.(\n objectSubset(type.name)\n )?.pollIntervalMs === \"number\"\n )\n ),\n actionParameterResolution: Boolean(\n options.backend?.resolveActionParameters || options.replica\n ),\n queries: Boolean(options.backend),\n pins: Boolean(options.pins ?? options.replica),\n attachments: options.backend\n ? options.backend.attachments && {\n stage: Boolean(options.backend.attachments.stage),\n }\n : options.replica\n ? { stage: true }\n : undefined,\n encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica),\n };\n })\n )\n ),\n SubscribeSelection: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize(\n { operation: \"SubscribeSelection\", selection: request.selection },\n context.headers\n );\n if (snapshots || !options.backend?.subscribeSelection)\n return yield* unavailableDelivery();\n const delivery = yield* options.backend.subscribeSelection(\n request.selection,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.mapEffect((frame) =>\n Effect.gen(function* () {\n if (!frame.metadata) return frame;\n if (frame.metadata.sourceId !== options.backend!.sourceId)\n return yield* new BackendError({\n operation: \"delivery\",\n kind: \"SourceMismatch\",\n message: \"The committed delivery source changed.\",\n retryable: false,\n });\n // The endpoint binds one logical source/session lifetime. A replica\n // server's committed facet forwards upstream rows under that identity.\n return {\n ...frame,\n metadata: {\n ...frame.metadata,\n sourceId:\n options.source?.sourceId ??\n options.backend?.sourceId ??\n \"stateless\",\n },\n };\n })\n )\n );\n })\n ),\n SubscribeState: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize({ operation: \"SubscribeState\", ...request }, context.headers);\n if (snapshots || !source.subscribe) return yield* unavailableDelivery();\n const delivery = yield* source.subscribe(\n request.session,\n request.view,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.map((frame) => ({\n ...frame,\n changes: frame.changes.map((change) =>\n change.kind === \"put\" &&\n (change.record.kind === \"pending\" || change.record.kind === \"completed\")\n ? {\n ...change,\n record: {\n ...change.record,\n value: projectActionFailure(change.record.value, options),\n },\n }\n : change\n ),\n }))\n );\n })\n ),\n UpdateView: (request, context) =>\n authorize({ operation: \"UpdateView\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots || !source.subscribe) return unavailableDelivery();\n return source.updateView\n ? source.updateView(request.session, request.view)\n : Effect.fail(\n new BackendError({\n operation: \"UpdateView\",\n kind: \"ViewReplaced\",\n retryable: true,\n message: \"This source replaces views by subscribing again.\",\n })\n );\n })\n ),\n AckDelivery: (request, context) =>\n authorize({ operation: \"AckDelivery\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots) return unavailableDelivery();\n const ack =\n request.kind === \"committed\"\n ? options.backend?.acknowledgeDelivery\n : source.acknowledgeDelivery;\n return ack ? ack(request.position) : unavailableSource();\n })\n ),\n Accept: (request, context) =>\n authorize({ operation: \"Accept\", submission: request }, context.headers).pipe(\n Effect.andThen(() => (source.accept ? source.accept(request) : unavailableSource()))\n ),\n OpenClient: (request, context) =>\n authorize({ operation: \"OpenClient\", ...request }, context.headers).pipe(\n Effect.andThen(() => source.openClient(request.resume))\n ),\n Read: (request, context) =>\n authorize({ operation: \"Read\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.read(request.session, request.view).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Submit: (request, context) =>\n authorize({ operation: \"Submit\", submission: request }, context.headers).pipe(\n Effect.andThen(() =>\n source.submit(request).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Acknowledge: (request, context) =>\n authorize({ operation: \"Acknowledge\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.acknowledge(\n request.session,\n request.revision,\n request.through,\n request.viewGeneration\n )\n )\n ),\n Demand: (subset, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Demand\", subset }, context.headers);\n return source.demand(subset).pipe(Stream.as(\"ready\" as const));\n })\n ),\n Changes: (_, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Changes\" }, context.headers);\n const changes = options.source ? yield* source.subscribeChanges : undefined;\n if (!changes) return yield* unavailableSource();\n // A new stream is a repair boundary, not proof that no updates were missed.\n return Stream.concat(\n Stream.make(\"invalidate\" as const),\n Stream.map(changes, () => \"invalidate\" as const)\n );\n })\n ),\n }).pipe(\n Layer.merge(ontologyOperationHandlers(operationOptions, authorize)),\n Layer.merge(errorProjectionLayer(options))\n );\n};\n\nconst resourceHeader = \"x-party-stack-resource\";\n\n/** Administrative resources use the same ontology RPCs and transport. Access is\n * still gated by the parent endpoint before the resource is acquired. */\nexport const ontologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);\n const pins = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.replica)\n return yield* new BackendError({\n operation: \"pins\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint does not own downloads.\",\n });\n const backend = yield* options.replica.demand.pins.backend;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend,\n ir: pinOntology,\n context: options.context,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => options.authorize({ operation: \"ReadPin\" }, headers),\n }),\n scope\n );\n })\n );\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n type Handler = RpcGroup.HandlersFrom<Rpcs>[Rpcs[\"_tag\"]];\n const handlers = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => {\n const invoke = (payload: never, request: Parameters<Handler>[1]) =>\n Effect.gen(function* () {\n const resource = request.headers[resourceHeader];\n if (resource !== undefined && resource !== \"pins\")\n return yield* new BackendError({\n operation: \"ontology.resource\",\n kind: \"NotFound\",\n retryable: false,\n message: \"Unknown ontology resource.\",\n });\n if (resource === \"pins\")\n yield* options.authorize({ operation: \"ReadPin\" }, request.headers);\n const context = resource === \"pins\" ? yield* pins : ordinary;\n const handler = yield* OntologyRpcs.accessHandler(tag as Rpcs[\"_tag\"]).pipe(\n Effect.provideContext(context)\n );\n return handler(payload, request);\n });\n return [\n tag,\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? (payload: never, request: Parameters<Handler>[1]) =>\n Stream.unwrap(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Stream.Stream<unknown, BackendError, R>\n )\n )\n )\n : (payload: never, request: Parameters<Handler>[1]) =>\n Effect.flatten(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Effect.Effect<unknown, BackendError, R>\n )\n )\n ),\n ];\n })\n ) as unknown as {\n readonly [Procedure in Rpcs as Procedure[\"_tag\"]]: Rpc.ToHandlerFn<\n Procedure,\n R | Scope.Scope\n >;\n };\n return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));\n })\n );\n\nconst selectPinResource = (client: OntologyRpcClient): OntologyRpcClient =>\n Object.fromEntries(\n [...OntologyRpcs.requests.keys()].map((tag) => [\n tag,\n (payload: unknown, settings?: { readonly headers?: Record<string, string> }) =>\n Reflect.apply(Reflect.get(client, tag), client, [\n payload,\n { ...settings, headers: { ...settings?.headers, [resourceHeader]: \"pins\" } },\n ]),\n ])\n ) as OntologyRpcClient;\n\nexport type OntologyRpcClient = Effect.Success<\n ReturnType<typeof RpcClient.make<RpcGroup.Rpcs<typeof OntologyRpcs>>>\n>;\nconst unavailable = (cause: unknown) => classifyBackendFailure(\"remote.protocol\", cause);\nconst copyDescription = (description: OntologyDescription) =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(Description)(Schema.encodeSync(Description)(description)),\n catch: (cause) =>\n new BackendError({\n operation: \"remote.describe\",\n kind: \"InvalidResponse\",\n retryable: false,\n message: \"Invalid ontology description.\",\n cause,\n }),\n });\n\nconst descriptionValue = Table.make<unknown>({ name: \"ontology-description-identity\" });\nconst sameDescriptionValue = (left: unknown, right: unknown) =>\n descriptionValue.encode(left) === descriptionValue.encode(right);\nconst protocolIdentity = (description: OntologyDescription) => ({\n version: description.version,\n replication: description.replication,\n supportsIdempotency: description.supportsIdempotency,\n delivery: Boolean(description.delivery),\n stateDelivery: Boolean(description.stateDelivery),\n changes: Boolean(description.changes),\n watchChanges: Boolean(description.watchChanges),\n watchSubset: Boolean(description.watchSubset),\n actionParameterResolution: Boolean(description.actionParameterResolution),\n queries: Boolean(description.queries),\n pins: Boolean(description.pins),\n attachments: Boolean(description.attachments),\n stageAttachments: Boolean(description.attachments?.stage),\n encrypted: Boolean(description.encrypted),\n});\nconst checkBootstrapBinding = (accepted: OntologyDescription, fresh: OntologyDescription) =>\n Effect.gen(function* () {\n if (fresh.sourceId !== accepted.sourceId)\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology source changed.\",\n });\n if (!sameDescriptionValue(fresh.context ?? {}, accepted.context ?? {}))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology context changed.\",\n });\n if (!sameDescriptionValue(protocolIdentity(fresh), protocolIdentity(accepted)))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology protocol capabilities changed.\",\n });\n });\n\nconst definitionFailure: unique symbol = Symbol(\"OntologyClient.definitionFailure\");\ninterface InternalDefinition extends OntologyClientDefinition {\n readonly [definitionFailure]: (error: BackendError) => Effect.Effect<void>;\n}\n/** HTTP byte operations use the same incompatibility notification as typed RPC. */\nexport const observeOntologyClientFailure = <A, R>(\n client: OntologyClient,\n work: Effect.Effect<A, BackendError, R>\n) =>\n work.pipe(\n Effect.tapError(\n (error) =>\n (client.definition as Partial<InternalDefinition>)[definitionFailure]?.(error) ?? Effect.void\n )\n );\n\ntype AcceptDescription = (\n description: OntologyDescription\n) => Effect.Effect<OntologyDescription, BackendError>;\n\nconst makeDefinitionClient = Effect.fnUntraced(function* (\n raw: OntologyRpcClient,\n description: OntologyDescription,\n options: OntologyClientOptions | undefined\n) {\n const scope = yield* Effect.scope;\n const state = yield* SubscriptionRef.make<OntologyClientDefinitionStatus>({\n status: options?.description ? \"retained\" : \"current\",\n refreshing: false,\n });\n yield* Effect.addFinalizer(() => PubSub.shutdown(state.pubsub));\n let attempt: Deferred.Deferred<OntologyDescription, BackendError> | undefined;\n const incompatible = (error: BackendError) =>\n error.kind === \"SchemaMismatch\" || error.kind === \"SourceMismatch\";\n const notify = (error: BackendError) => options?.onIncompatible?.(error) ?? Effect.void;\n const failed = Effect.fnUntraced(function* (error: BackendError) {\n const previous = yield* SubscriptionRef.get(state);\n yield* SubscriptionRef.set(state, {\n ...previous,\n status: incompatible(error) ? \"incompatible\" : previous.status,\n refreshing: false,\n error: previous.status === \"incompatible\" && !incompatible(error) ? previous.error : error,\n });\n if (\n incompatible(error) &&\n (previous.status !== \"incompatible\" || previous.error?.kind !== error.kind)\n )\n yield* notify(error).pipe(\n Effect.catchCause((cause) =>\n Effect.logError(\"Ontology incompatibility callback failed\", cause)\n ),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n const validate =\n options?.validate ??\n ((fresh: OntologyDescription) =>\n (!fresh.ir && !description.ir) ||\n (fresh.ir &&\n description.ir &&\n ontologyDefinitionContractSignature(fresh.ir) ===\n ontologyDefinitionContractSignature(description.ir))\n ? Effect.void\n : Effect.fail(\n new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology definition changed.\",\n })\n ));\n const refresh = Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n if (attempt) return restore(Deferred.await(attempt));\n const pending = Deferred.makeUnsafe<OntologyDescription, BackendError>();\n attempt = pending;\n const check = SubscriptionRef.update(state, (current) => ({ ...current, refreshing: true })).pipe(\n Effect.andThen(raw.Describe().pipe(Effect.mapError(unavailable))),\n Effect.tap((fresh) => checkBootstrapBinding(description, fresh)),\n Effect.tap(validate),\n Effect.tap(() => SubscriptionRef.set(state, { status: \"current\", refreshing: false })),\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {\n const error = Cause.findErrorOption(exit.cause);\n yield* failed(\n error._tag === \"Some\" ? error.value : unavailable(Cause.squash(exit.cause))\n );\n }\n if (attempt === pending) attempt = undefined;\n yield* Deferred.done(pending, exit);\n })\n ),\n Effect.catchCause(() => Effect.void)\n );\n return Effect.forkIn(check, scope, { startImmediately: true }).pipe(\n Effect.andThen(restore(Deferred.await(pending)))\n );\n })\n );\n const report = Effect.fnUntraced(function* (error: BackendError) {\n if (!incompatible(error)) return;\n yield* failed(error);\n // Rebinding a source/account needs an explicit acquisition. A metadata\n // refresh must not turn that failure into permission to reset its cache.\n if (error.kind === \"SourceMismatch\") return;\n yield* refresh.pipe(\n Effect.catchCause(() => Effect.void),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n const headers = expectedBindingHeaders(description);\n // Delivery metadata already carries the contract hash. Check it at the\n // client boundary too, so a receiver's schema failure reaches definition\n // lifecycle handling even when the transport successfully delivered a frame.\n const schemaHash = yield* Effect.cached(\n Effect.suspend(() =>\n description.ir ? ontologyDefinitionContractHash(description.ir) : Effect.succeed(undefined)\n ).pipe(Effect.mapError(unavailable))\n );\n const checkFrame = Effect.fnUntraced(function* (frame: DeliveryFrame) {\n if (frame.metadata) {\n if (frame.metadata.sourceId !== description.sourceId)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The delivered ontology source changed.\",\n });\n const expected = yield* schemaHash;\n if (expected !== undefined && frame.metadata.schemaHash !== expected)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The delivered ontology definition changed.\",\n });\n }\n return frame;\n });\n const client = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => [\n tag,\n (payload: unknown, options?: { readonly headers?: Record<string, string> }) => {\n const invoke = () =>\n Reflect.apply(Reflect.get(raw, tag), raw, [\n payload,\n tag === \"Describe\"\n ? options\n : { ...options, headers: { ...options?.headers, ...headers } },\n ]);\n if (RpcSchema.isStreamSchema(rpc.successSchema)) {\n const stream =\n tag === \"SubscribeSelection\" || tag === \"SubscribeState\"\n ? (invoke() as Stream.Stream<DeliveryFrame, BackendError>).pipe(\n Stream.mapEffect(checkFrame)\n )\n : (invoke() as Stream.Stream<unknown, BackendError>);\n return stream.pipe(Stream.tapError(report));\n }\n return (invoke() as Effect.Effect<unknown, BackendError>).pipe(Effect.tapError(report));\n },\n ])\n ) as unknown as OntologyRpcClient;\n const definition: InternalDefinition = {\n get: SubscriptionRef.get(state),\n changes: SubscriptionRef.changes(state),\n refresh,\n [definitionFailure]: report,\n };\n return {\n client,\n definition,\n };\n});\n\nconst makeProtocolClient = (accept: AcceptDescription) => {\n const open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope> = Effect.fn(\"RemoteOntology.protocol\")(\n function* (client: OntologyRpcClient, options?: OntologyClientOptions) {\n return yield* openProtocolClient(client, options, accept, open);\n }\n );\n return open;\n};\n/** Use the same source contract with Effect RPC's worker, HTTP or socket transport. */\nexport const makeOntologyProtocolClient = makeProtocolClient(copyDescription);\n/** Same-runtime transports without serialization receive the server's own,\n * already validated description. Skip the defensive wire copy: re-encoding and\n * decoding a large definition dominates startup on mobile JavaScript engines,\n * and sharing the definition object lets per-definition signature caches apply.\n */\nexport const makeTrustedOntologyProtocolClient = makeProtocolClient(Effect.succeed);\n\nconst openProtocolClient = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n options: OntologyClientOptions | undefined,\n accept: AcceptDescription,\n open: (client: OntologyRpcClient) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n): Effect.fn.Return<OntologyClient, BackendError, Scope.Scope> {\n // Serialized RPC clients already decoded Describe with its success schema, and\n // a same-runtime client receives the server's validated value: neither needs a\n // second encode/decode copy. Only a caller-retained description is copied.\n const description = yield* options?.description\n ? accept(options.description)\n : client.Describe().pipe(Effect.mapError(unavailable));\n if (options?.description && !description.ir)\n return yield* new BackendError({\n operation: \"remote.bootstrap\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A retained ontology description must include its definition.\",\n });\n const described = yield* makeDefinitionClient(client, description, options);\n const pinBackend = description.pins\n ? open(selectPinResource(client)).pipe(Effect.map((resource) => resource.backend))\n : undefined;\n client = described.client;\n const operations = yield* makeOntologyOperationsClient(client);\n const common = {\n description,\n definition: described.definition,\n operations,\n pins: description.pins ? operations.pins : undefined,\n pinBackend,\n sourceId: description.sourceId,\n definitionHash: description.definitionHash,\n ir: description.ir,\n context: description.context,\n backend: makeRpcBackend(client, description, operations),\n };\n if (description.replication === \"committed\") return { ...common, replication: { kind: \"committed\" } };\n const source: OntologySource = {\n sourceId: description.sourceId,\n outbox: operations.outbox,\n supportsIdempotency: description.supportsIdempotency,\n openClient: (resume) => client.OpenClient({ resume }).pipe(Effect.mapError(unavailable)),\n read: (session, view) => client.Read({ session, view }).pipe(Effect.mapError(unavailable)),\n submit: (request) => client.Submit(request).pipe(Effect.mapError(unavailable)),\n accept: description.stateDelivery\n ? (request) => client.Accept(request).pipe(Effect.mapError(unavailable))\n : undefined,\n subscribe: description.stateDelivery\n ? (session, view, _policy, resume) =>\n Effect.succeed({\n frames: client\n .SubscribeState({ session, view, resume })\n .pipe(Stream.mapError(unavailable)),\n acknowledge: (position) =>\n client\n .AckDelivery({ kind: \"speculative\", position })\n .pipe(Effect.mapError(unavailable)),\n })\n : undefined,\n acknowledgeDelivery: description.stateDelivery\n ? (position) =>\n client.AckDelivery({ kind: \"speculative\", position }).pipe(Effect.mapError(unavailable))\n : undefined,\n updateView: description.stateDelivery\n ? (session, view) => client.UpdateView({ session, view }).pipe(Effect.mapError(unavailable))\n : undefined,\n acknowledge: (session, revision, through, viewGeneration) =>\n client\n .Acknowledge({ session, revision, through, viewGeneration })\n .pipe(Effect.mapError(unavailable)),\n subscribeChanges: Effect.succeed(\n client.Changes().pipe(\n Stream.map(() => undefined),\n Stream.mapError(unavailable)\n )\n ),\n demand: (subset) => client.Demand(subset).pipe(Stream.as(undefined), Stream.mapError(unavailable)),\n };\n return { ...common, replication: { kind: \"speculative\", source } };\n});\n\nexport { errorProjectionLayer } from \"./errorProjection.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS,OAAO;AAAiB,CAAC,CAAC;AACnG,MAAM,mBAAmB,OAAO,SAAS;CAAC;CAAQ;CAAY;AAAa,CAAC;AAC5E,MAAM,cAAc;AACpB,MAAM,cAAc,SAAS,KACzB,IAAI,KAAK,YAAY;CAAE,SAAS;CAAa,OAAO;AAAa,CAAC,GAClE,IAAI,KAAK,sBAAsB;CAC3B,SAAS;EAAE,WAAW;EAAsB,QAAQ,OAAO,SAAS,sBAAsB;CAAE;CAC5F,SAAS;CACT,OAAO;CACP,QAAQ;AACZ,CAAC,GACD,IAAI,KAAK,kBAAkB;CACvB,SAAS;EACL,SAAS;EACT,MAAM;EACN,QAAQ,OAAO,SAAS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;EAAK,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,WAAW,CAAC,IACzF,KAAA;EACN,cAAc,SAAS,UAAU,SAAS,mBACtC,OACK,YAAY;GAAE;GAAS;GAAU;GAAS;EAAe,CAAC,CAAC,CAC3D,KAAK,OAAO,SAAS,WAAW,CAAC;EAC1C,kBAAkB,OAAO,QACrB,OAAO,QAAQ,CAAC,CAAC,KACb,OAAO,UAAU,KAAA,CAAS,GAC1B,OAAO,SAAS,WAAW,CAC/B,CACJ;EACA,SAAS,WAAW,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,OAAO,GAAG,KAAA,CAAS,GAAG,OAAO,SAAS,WAAW,CAAC;CACrG;CACA,OAAO;EAAE,GAAG;EAAQ,aAAa;GAAE,MAAM;GAAe;EAAO;CAAE;AACrE,CAAC"}
|
package/lib/rpcWorker.js
CHANGED
|
@@ -125,6 +125,12 @@ const serveOpenedOntologyWorker = Effect.fn("OntologyServer.openWorker")(functio
|
|
|
125
125
|
accept: (request) => Effect.flatMap(current, (value) => value.accept(request)),
|
|
126
126
|
subscribe: (session, view, policy, resume) => Effect.flatMap(current, (value) => value.subscribe(session, view, policy, resume)),
|
|
127
127
|
acknowledgeDelivery: (position) => Effect.flatMap(current, (value) => value.acknowledgeDelivery(position)),
|
|
128
|
+
updateView: (session, view) => Effect.flatMap(current, (value) => value.updateView ? value.updateView(session, view) : Effect.fail(new BackendError({
|
|
129
|
+
operation: "UpdateView",
|
|
130
|
+
kind: "ViewReplaced",
|
|
131
|
+
retryable: true,
|
|
132
|
+
message: "This source replaces views by subscribing again."
|
|
133
|
+
}))),
|
|
128
134
|
acknowledge: (...args) => Effect.flatMap(current, (value) => value.acknowledge(...args)),
|
|
129
135
|
demand: (subset) => Stream.unwrap(Effect.map(current, (value) => value.demand(subset))),
|
|
130
136
|
subscribeChanges: Effect.flatMap(current, (value) => value.subscribeChanges)
|
package/lib/rpcWorker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpcWorker.js","names":[],"sources":["../src/rpcWorker.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport { replicaStateSource } from \"@party-stack/ontology-replica/infrastructure\";\nimport { Cause, Deferred, Effect, Exit, Fiber, Layer, Scope, Stream } from \"effect\";\nimport { RpcClient, RpcServer } from \"effect/rpc\";\nimport { Worker, type WorkerRunner } from \"effect/workers\";\nimport { projectOntologyBackend } from \"./authorization.js\";\nimport { replicaServerBackend } from \"./composition.js\";\nimport { withInternalCommands } from \"./internalAccess.js\";\nimport { ontologyServerDispatch, selectOntology } from \"./routing.js\";\nimport {\n makeOntologyProtocolClient,\n ontologyRpcHandlers,\n OntologyRpcs,\n makeOntologyRpcClient,\n} from \"./rpc.js\";\nimport type { OntologyServer } from \"./routing.js\";\nimport type { OntologyRpcServerOptions, OntologyServerClient, OntologyClientOptions } from \"./rpc.js\";\nimport type { OntologyBackendService } from \"@party-stack/ontology-backend\";\nimport type { OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { ReplicaService } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { WorkerError } from \"effect/workers/WorkerError\";\n\n/** Supply a platform runner for the worker global or an individual MessagePort.\n * Multiple port servers can share the same source without sharing request scopes.\n */\nexport const serveOntologyWorker = Effect.fn(\"OntologyServer.serveWorker\")(function* <R>(\n options:\n | OntologyRpcServerOptions<R>\n | OntologyServer<R>\n | Effect.Effect<OntologyServer<R>, unknown, R | Scope.Scope>\n): Effect.fn.Return<\n Fiber.Fiber<never, WorkerError>,\n BackendError,\n R | Scope.Scope | WorkerRunner.WorkerRunnerPlatform\n> {\n let router: OntologyServer<R> | undefined;\n if (Effect.isEffect(options)) {\n // Start the transport while the native owner is opening. Describe waits\n // for this result, so startup errors arrive as typed RPC failures.\n const ready = yield* Deferred.make<OntologyServer<R>, BackendError>();\n const startup = yield* Scope.fork(yield* Effect.scope);\n yield* options.pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"worker.open\", cause)),\n Scope.provide(startup),\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(startup, exit) : Effect.void)),\n Effect.catchDefect((cause) =>\n Effect.fail(\n new BackendError({\n operation: \"worker.open\",\n kind: \"Internal\",\n retryable: false,\n message: \"Ontology server startup failed.\",\n cause,\n })\n )\n ),\n Effect.tapCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : Effect.logError(\"Ontology worker startup failed\", cause)\n ),\n Effect.matchEffect({\n onFailure: (error) => Deferred.fail(ready, error),\n onSuccess: (server) => Deferred.succeed(ready, server),\n }),\n Effect.forkScoped\n );\n router = {\n _tag: \"OntologyServer\",\n bind: (...args) => Effect.flatMap(Deferred.await(ready), (server) => server.bind(...args)),\n invalidate: (target) =>\n Effect.flatMap(Deferred.await(ready), (server) => server.invalidate(target)),\n forget: (target) => Effect.flatMap(Deferred.await(ready), (server) => server.forget(target)),\n partitions: Effect.flatMap(Deferred.await(ready), (server) => server.partitions),\n syncOnce: (target, settings) =>\n Effect.flatMap(Deferred.await(ready), (server) => server.syncOnce(target, settings)),\n };\n } else if (\"_tag\" in options) router = options;\n return yield* RpcServer.make(OntologyRpcs).pipe(\n Effect.provide(\n router\n ? ontologyServerDispatch(router)\n : ontologyRpcHandlers(options as OntologyRpcServerOptions<R>)\n ),\n Effect.provide(RpcServer.layerProtocolWorkerRunner),\n Effect.forkScoped({ startImmediately: true })\n );\n});\n\n/** The platform spawner supplies one Worker, SharedWorker or MessagePort.\n * The enclosing scope owns RPC requests, streams and the connection lifetime.\n */\nexport const makeOntologyWorkerClient = Effect.fn(\"OntologyClient.worker\")(function* (options?: {\n /** Worker transport startup deadline; does not limit ontology/backend initialization. */\n readonly connectionTimeoutMs?: number;\n readonly ontology?: string;\n}): Effect.fn.Return<\n OntologyServerClient,\n BackendError,\n Scope.Scope | Worker.WorkerPlatform | Worker.Spawner\n> {\n const timeout = options?.connectionTimeoutMs ?? 5_000;\n if (!Number.isFinite(timeout) || timeout < 1)\n return yield* new BackendError({\n operation: \"worker.connect\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"Worker connection timeout must be positive.\",\n });\n const connectionScope = yield* Scope.fork(yield* Effect.scope);\n return yield* Scope.provide(\n Effect.gen(function* () {\n const ready = yield* Deferred.make<void, BackendError>();\n const platform = yield* Worker.WorkerPlatform;\n const handshake = Worker.WorkerPlatform.of({\n spawn<O, I>(id: number) {\n return Effect.map(platform.spawn<O, I>(id), (worker): Worker.Worker<O, I> => ({\n ...worker,\n run(handler, settings) {\n return worker\n .run(handler, {\n onSpawn: Effect.andThen(\n settings?.onSpawn ?? Effect.void,\n Deferred.succeed(ready, undefined)\n ),\n })\n .pipe(\n Effect.tapCause((cause) =>\n Deferred.fail(\n ready,\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker transport failed.\",\n cause: Cause.squash(cause),\n })\n )\n )\n );\n },\n }));\n },\n });\n // Build in the connection's Scope: providing a scoped transport only to the\n // client constructor would close its worker pool as soon as construction returns.\n const transport = yield* Layer.build(\n // Subscriptions last for a view's lifetime. A finite pool permit count\n // would let them starve commands on this shared port; RPC stream\n // acknowledgements provide flow control for the actual bytes.\n RpcClient.layerProtocolWorker({ size: 1, concurrency: Number.POSITIVE_INFINITY })\n ).pipe(\n Effect.provideService(Worker.WorkerPlatform, handshake),\n Effect.mapError(\n (cause) =>\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker transport failed.\",\n cause,\n })\n )\n );\n // The platform's ready message confirms transport startup. Describe\n // can legitimately wait longer for storage, authentication or a backend.\n yield* Deferred.await(ready).pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker handshake timed out.\",\n })\n ),\n })\n );\n const rpc = yield* makeOntologyRpcClient.pipe(Effect.provideContext(transport));\n return {\n ontology: Effect.fn(\"OntologyClient.select\")(function* (\n selected?: string,\n clientOptions?: OntologyClientOptions\n ) {\n const name = selected ?? options?.ontology;\n const client = name === undefined ? rpc : selectOntology(rpc, name);\n return yield* makeOntologyProtocolClient(client, clientOptions);\n }),\n };\n }),\n connectionScope\n ).pipe(\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(connectionScope, exit) : Effect.void))\n );\n});\n\nexport interface ServeOpenedOntologyWorkerOptions<R = never> extends Omit<\n OntologyRpcServerOptions<R>,\n \"source\" | \"replica\" | \"backend\" | \"traces\" | \"ready\" | \"deleteLocalData\" | \"releaseOwner\" | \"authorize\"\n> {\n readonly dangerouslyAllowInternalAccess: true;\n /** Resources acquired here belong to the worker's Scope. */\n readonly open: Effect.Effect<\n {\n readonly replica: ReplicaService;\n readonly backend?: OntologyBackendService;\n readonly context?: Record<string, unknown>;\n readonly traces?: TraceStore;\n readonly deleteLocalData?: Effect.Effect<void, BackendError>;\n },\n BackendError,\n R | Scope.Scope\n >;\n}\n\n/** Start serving before restoring private state. Describe waits for readiness and\n * receives typed startup failures. Platform transport/Runtime remain caller supplied.\n */\nexport const serveOpenedOntologyWorker = Effect.fn(\"OntologyServer.openWorker\")(function* <R>(\n options: ServeOpenedOntologyWorkerOptions<R>\n) {\n if (options.dangerouslyAllowInternalAccess !== true)\n return yield* new BackendError({\n operation: \"worker.open\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A private replica worker requires explicit internal access for its app ports.\",\n });\n const ready = yield* Deferred.make<OntologySource, BackendError>();\n const released = yield* Deferred.make<void>();\n let opened: Effect.Success<typeof options.open> | undefined;\n let source: OntologySource | undefined;\n let backend: OntologyBackendService | undefined;\n let view: Effect.Success<ReturnType<typeof projectOntologyBackend>> | undefined;\n const current = Deferred.await(ready);\n const startupScope = yield* Scope.fork(yield* Effect.scope);\n const proxy: OntologySource = {\n get sourceId() {\n return source?.sourceId ?? \"initializing\";\n },\n get supportsIdempotency() {\n return source?.supportsIdempotency ?? false;\n },\n openClient: (resume) => Effect.flatMap(current, (value) => value.openClient(resume)),\n read: (session, view) => Effect.flatMap(current, (value) => value.read(session, view)),\n submit: (request) => Effect.flatMap(current, (value) => value.submit(request)),\n accept: (request) => Effect.flatMap(current, (value) => value.accept!(request)),\n subscribe: (session, view, policy, resume) =>\n Effect.flatMap(current, (value) => value.subscribe!(session, view, policy, resume)),\n acknowledgeDelivery: (position) =>\n Effect.flatMap(current, (value) => value.acknowledgeDelivery!(position)),\n acknowledge: (...args) => Effect.flatMap(current, (value) => value.acknowledge(...args)),\n demand: (subset) => Stream.unwrap(Effect.map(current, (value) => value.demand(subset))),\n subscribeChanges: Effect.flatMap(current, (value) => value.subscribeChanges),\n };\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n opened = yield* options.open;\n source = replicaStateSource(opened.replica);\n if (opened.backend) backend = replicaServerBackend(opened.replica, opened.backend);\n if (opened.replica.ir.policy) {\n if (!backend)\n return yield* new BackendError({\n operation: \"worker.open\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A policy-bound worker requires a backend for projected operations.\",\n });\n view = yield* projectOntologyBackend(\n {\n backend,\n ir: opened.replica.ir,\n context: opened.context ?? opened.replica.context,\n },\n \"upstream\"\n );\n backend = view.backend;\n }\n yield* Deferred.succeed(ready, source);\n }).pipe(\n Scope.provide(startupScope),\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(startupScope, exit) : Effect.void)),\n Effect.catchDefect(() =>\n Effect.fail(\n new BackendError({\n operation: \"worker.open\",\n kind: \"Internal\",\n retryable: false,\n message: \"Ontology worker initialization failed.\",\n })\n )\n ),\n Effect.catch((error) => Deferred.fail(ready, error))\n )\n );\n const server = yield* serveOntologyWorker({\n ...options,\n authorize: (request, headers) =>\n Effect.flatMap(current, () =>\n view ? withInternalCommands(view.authorize, true)(request, headers) : Effect.void\n ),\n get source() {\n // Private commands do not make raw replica state safe to project.\n return view ? undefined : proxy;\n },\n get replica() {\n return opened?.replica;\n },\n get backend() {\n return backend;\n },\n get ir() {\n return view?.ir ?? opened?.replica.ir;\n },\n get context() {\n return view?.context ?? opened?.context ?? opened?.replica.context;\n },\n get traces() {\n return opened?.traces;\n },\n ready: Effect.asVoid(current),\n deleteLocalData: Effect.flatMap(\n current,\n () =>\n opened?.deleteLocalData ??\n Effect.fail(\n new BackendError({\n operation: \"worker.deleteLocalData\",\n kind: \"NotImplemented\",\n message: \"Local partition deletion is unavailable.\",\n retryable: false,\n })\n )\n ),\n releaseOwner: Deferred.succeed(released, undefined).pipe(Effect.asVoid),\n });\n yield* Effect.raceFirst(Fiber.join(server), Deferred.await(released));\n}, Effect.scoped);\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAa,sBAAsB,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACvE,SAQF;CACE,IAAI;CACJ,IAAI,OAAO,SAAS,OAAO,GAAG;EAG1B,MAAM,QAAQ,OAAO,SAAS,KAAsC;EACpE,MAAM,UAAU,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;EACrD,OAAO,QAAQ,KACX,OAAO,UAAU,UAAU,uBAAuB,eAAe,KAAK,CAAC,GACvE,MAAM,QAAQ,OAAO,GACrB,OAAO,QAAQ,SAAU,KAAK,UAAU,IAAI,IAAI,MAAM,MAAM,SAAS,IAAI,IAAI,OAAO,IAAK,GACzF,OAAO,aAAa,UAChB,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,WAAW;GACX,SAAS;GACT;EACJ,CAAC,CACL,CACJ,GACA,OAAO,UAAU,UACb,MAAM,kBAAkB,KAAK,IACvB,OAAO,OACP,OAAO,SAAS,kCAAkC,KAAK,CACjE,GACA,OAAO,YAAY;GACf,YAAY,UAAU,SAAS,KAAK,OAAO,KAAK;GAChD,YAAY,WAAW,SAAS,QAAQ,OAAO,MAAM;EACzD,CAAC,GACD,OAAO,UACX;EACA,SAAS;GACL,MA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iB,OAAO,QACpB,eAEI,QAAQ,mBACR,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL,CACR;EACA,cAAc,SAAS,QAAQ,UAAU,KAAA,CAAS,CAAC,CAAC,KAAK,OAAO,MAAM;CAC1E,CAAC;CACD,OAAO,OAAO,UAAU,MAAM,KAAK,MAAM,GAAG,SAAS,MAAM,QAAQ,CAAC;AACxE,GAAG,OAAO,MAAM"}
|
|
1
|
+
{"version":3,"file":"rpcWorker.js","names":[],"sources":["../src/rpcWorker.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport { replicaStateSource } from \"@party-stack/ontology-replica/infrastructure\";\nimport { Cause, Deferred, Effect, Exit, Fiber, Layer, Scope, Stream } from \"effect\";\nimport { RpcClient, RpcServer } from \"effect/rpc\";\nimport { Worker, type WorkerRunner } from \"effect/workers\";\nimport { projectOntologyBackend } from \"./authorization.js\";\nimport { replicaServerBackend } from \"./composition.js\";\nimport { withInternalCommands } from \"./internalAccess.js\";\nimport { ontologyServerDispatch, selectOntology } from \"./routing.js\";\nimport {\n makeOntologyProtocolClient,\n ontologyRpcHandlers,\n OntologyRpcs,\n makeOntologyRpcClient,\n} from \"./rpc.js\";\nimport type { OntologyServer } from \"./routing.js\";\nimport type { OntologyRpcServerOptions, OntologyServerClient, OntologyClientOptions } from \"./rpc.js\";\nimport type { OntologyBackendService } from \"@party-stack/ontology-backend\";\nimport type { OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { ReplicaService } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { WorkerError } from \"effect/workers/WorkerError\";\n\n/** Supply a platform runner for the worker global or an individual MessagePort.\n * Multiple port servers can share the same source without sharing request scopes.\n */\nexport const serveOntologyWorker = Effect.fn(\"OntologyServer.serveWorker\")(function* <R>(\n options:\n | OntologyRpcServerOptions<R>\n | OntologyServer<R>\n | Effect.Effect<OntologyServer<R>, unknown, R | Scope.Scope>\n): Effect.fn.Return<\n Fiber.Fiber<never, WorkerError>,\n BackendError,\n R | Scope.Scope | WorkerRunner.WorkerRunnerPlatform\n> {\n let router: OntologyServer<R> | undefined;\n if (Effect.isEffect(options)) {\n // Start the transport while the native owner is opening. Describe waits\n // for this result, so startup errors arrive as typed RPC failures.\n const ready = yield* Deferred.make<OntologyServer<R>, BackendError>();\n const startup = yield* Scope.fork(yield* Effect.scope);\n yield* options.pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"worker.open\", cause)),\n Scope.provide(startup),\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(startup, exit) : Effect.void)),\n Effect.catchDefect((cause) =>\n Effect.fail(\n new BackendError({\n operation: \"worker.open\",\n kind: \"Internal\",\n retryable: false,\n message: \"Ontology server startup failed.\",\n cause,\n })\n )\n ),\n Effect.tapCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : Effect.logError(\"Ontology worker startup failed\", cause)\n ),\n Effect.matchEffect({\n onFailure: (error) => Deferred.fail(ready, error),\n onSuccess: (server) => Deferred.succeed(ready, server),\n }),\n Effect.forkScoped\n );\n router = {\n _tag: \"OntologyServer\",\n bind: (...args) => Effect.flatMap(Deferred.await(ready), (server) => server.bind(...args)),\n invalidate: (target) =>\n Effect.flatMap(Deferred.await(ready), (server) => server.invalidate(target)),\n forget: (target) => Effect.flatMap(Deferred.await(ready), (server) => server.forget(target)),\n partitions: Effect.flatMap(Deferred.await(ready), (server) => server.partitions),\n syncOnce: (target, settings) =>\n Effect.flatMap(Deferred.await(ready), (server) => server.syncOnce(target, settings)),\n };\n } else if (\"_tag\" in options) router = options;\n return yield* RpcServer.make(OntologyRpcs).pipe(\n Effect.provide(\n router\n ? ontologyServerDispatch(router)\n : ontologyRpcHandlers(options as OntologyRpcServerOptions<R>)\n ),\n Effect.provide(RpcServer.layerProtocolWorkerRunner),\n Effect.forkScoped({ startImmediately: true })\n );\n});\n\n/** The platform spawner supplies one Worker, SharedWorker or MessagePort.\n * The enclosing scope owns RPC requests, streams and the connection lifetime.\n */\nexport const makeOntologyWorkerClient = Effect.fn(\"OntologyClient.worker\")(function* (options?: {\n /** Worker transport startup deadline; does not limit ontology/backend initialization. */\n readonly connectionTimeoutMs?: number;\n readonly ontology?: string;\n}): Effect.fn.Return<\n OntologyServerClient,\n BackendError,\n Scope.Scope | Worker.WorkerPlatform | Worker.Spawner\n> {\n const timeout = options?.connectionTimeoutMs ?? 5_000;\n if (!Number.isFinite(timeout) || timeout < 1)\n return yield* new BackendError({\n operation: \"worker.connect\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"Worker connection timeout must be positive.\",\n });\n const connectionScope = yield* Scope.fork(yield* Effect.scope);\n return yield* Scope.provide(\n Effect.gen(function* () {\n const ready = yield* Deferred.make<void, BackendError>();\n const platform = yield* Worker.WorkerPlatform;\n const handshake = Worker.WorkerPlatform.of({\n spawn<O, I>(id: number) {\n return Effect.map(platform.spawn<O, I>(id), (worker): Worker.Worker<O, I> => ({\n ...worker,\n run(handler, settings) {\n return worker\n .run(handler, {\n onSpawn: Effect.andThen(\n settings?.onSpawn ?? Effect.void,\n Deferred.succeed(ready, undefined)\n ),\n })\n .pipe(\n Effect.tapCause((cause) =>\n Deferred.fail(\n ready,\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker transport failed.\",\n cause: Cause.squash(cause),\n })\n )\n )\n );\n },\n }));\n },\n });\n // Build in the connection's Scope: providing a scoped transport only to the\n // client constructor would close its worker pool as soon as construction returns.\n const transport = yield* Layer.build(\n // Subscriptions last for a view's lifetime. A finite pool permit count\n // would let them starve commands on this shared port; RPC stream\n // acknowledgements provide flow control for the actual bytes.\n RpcClient.layerProtocolWorker({ size: 1, concurrency: Number.POSITIVE_INFINITY })\n ).pipe(\n Effect.provideService(Worker.WorkerPlatform, handshake),\n Effect.mapError(\n (cause) =>\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker transport failed.\",\n cause,\n })\n )\n );\n // The platform's ready message confirms transport startup. Describe\n // can legitimately wait longer for storage, authentication or a backend.\n yield* Deferred.await(ready).pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(\n new BackendError({\n operation: \"worker.connect\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"Ontology worker handshake timed out.\",\n })\n ),\n })\n );\n const rpc = yield* makeOntologyRpcClient.pipe(Effect.provideContext(transport));\n return {\n ontology: Effect.fn(\"OntologyClient.select\")(function* (\n selected?: string,\n clientOptions?: OntologyClientOptions\n ) {\n const name = selected ?? options?.ontology;\n const client = name === undefined ? rpc : selectOntology(rpc, name);\n return yield* makeOntologyProtocolClient(client, clientOptions);\n }),\n };\n }),\n connectionScope\n ).pipe(\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(connectionScope, exit) : Effect.void))\n );\n});\n\nexport interface ServeOpenedOntologyWorkerOptions<R = never> extends Omit<\n OntologyRpcServerOptions<R>,\n \"source\" | \"replica\" | \"backend\" | \"traces\" | \"ready\" | \"deleteLocalData\" | \"releaseOwner\" | \"authorize\"\n> {\n readonly dangerouslyAllowInternalAccess: true;\n /** Resources acquired here belong to the worker's Scope. */\n readonly open: Effect.Effect<\n {\n readonly replica: ReplicaService;\n readonly backend?: OntologyBackendService;\n readonly context?: Record<string, unknown>;\n readonly traces?: TraceStore;\n readonly deleteLocalData?: Effect.Effect<void, BackendError>;\n },\n BackendError,\n R | Scope.Scope\n >;\n}\n\n/** Start serving before restoring private state. Describe waits for readiness and\n * receives typed startup failures. Platform transport/Runtime remain caller supplied.\n */\nexport const serveOpenedOntologyWorker = Effect.fn(\"OntologyServer.openWorker\")(function* <R>(\n options: ServeOpenedOntologyWorkerOptions<R>\n) {\n if (options.dangerouslyAllowInternalAccess !== true)\n return yield* new BackendError({\n operation: \"worker.open\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A private replica worker requires explicit internal access for its app ports.\",\n });\n const ready = yield* Deferred.make<OntologySource, BackendError>();\n const released = yield* Deferred.make<void>();\n let opened: Effect.Success<typeof options.open> | undefined;\n let source: OntologySource | undefined;\n let backend: OntologyBackendService | undefined;\n let view: Effect.Success<ReturnType<typeof projectOntologyBackend>> | undefined;\n const current = Deferred.await(ready);\n const startupScope = yield* Scope.fork(yield* Effect.scope);\n const proxy: OntologySource = {\n get sourceId() {\n return source?.sourceId ?? \"initializing\";\n },\n get supportsIdempotency() {\n return source?.supportsIdempotency ?? false;\n },\n openClient: (resume) => Effect.flatMap(current, (value) => value.openClient(resume)),\n read: (session, view) => Effect.flatMap(current, (value) => value.read(session, view)),\n submit: (request) => Effect.flatMap(current, (value) => value.submit(request)),\n accept: (request) => Effect.flatMap(current, (value) => value.accept!(request)),\n subscribe: (session, view, policy, resume) =>\n Effect.flatMap(current, (value) => value.subscribe!(session, view, policy, resume)),\n acknowledgeDelivery: (position) =>\n Effect.flatMap(current, (value) => value.acknowledgeDelivery!(position)),\n updateView: (session, view) =>\n Effect.flatMap(current, (value) =>\n value.updateView\n ? value.updateView(session, view)\n : Effect.fail(\n new BackendError({\n operation: \"UpdateView\",\n kind: \"ViewReplaced\",\n retryable: true,\n message: \"This source replaces views by subscribing again.\",\n })\n )\n ),\n acknowledge: (...args) => Effect.flatMap(current, (value) => value.acknowledge(...args)),\n demand: (subset) => Stream.unwrap(Effect.map(current, (value) => value.demand(subset))),\n subscribeChanges: Effect.flatMap(current, (value) => value.subscribeChanges),\n };\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n opened = yield* options.open;\n source = replicaStateSource(opened.replica);\n if (opened.backend) backend = replicaServerBackend(opened.replica, opened.backend);\n if (opened.replica.ir.policy) {\n if (!backend)\n return yield* new BackendError({\n operation: \"worker.open\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A policy-bound worker requires a backend for projected operations.\",\n });\n view = yield* projectOntologyBackend(\n {\n backend,\n ir: opened.replica.ir,\n context: opened.context ?? opened.replica.context,\n },\n \"upstream\"\n );\n backend = view.backend;\n }\n yield* Deferred.succeed(ready, source);\n }).pipe(\n Scope.provide(startupScope),\n Effect.onExit((exit) => (Exit.isFailure(exit) ? Scope.close(startupScope, exit) : Effect.void)),\n Effect.catchDefect(() =>\n Effect.fail(\n new BackendError({\n operation: \"worker.open\",\n kind: \"Internal\",\n retryable: false,\n message: \"Ontology worker initialization failed.\",\n })\n )\n ),\n Effect.catch((error) => Deferred.fail(ready, error))\n )\n );\n const server = yield* serveOntologyWorker({\n ...options,\n authorize: (request, headers) =>\n Effect.flatMap(current, () =>\n view ? withInternalCommands(view.authorize, true)(request, headers) : Effect.void\n ),\n get source() {\n // Private commands do not make raw replica state safe to project.\n return view ? undefined : proxy;\n },\n get replica() {\n return opened?.replica;\n },\n get backend() {\n return backend;\n },\n get ir() {\n return view?.ir ?? opened?.replica.ir;\n },\n get context() {\n return view?.context ?? opened?.context ?? opened?.replica.context;\n },\n get traces() {\n return opened?.traces;\n },\n ready: Effect.asVoid(current),\n deleteLocalData: Effect.flatMap(\n current,\n () =>\n opened?.deleteLocalData ??\n Effect.fail(\n new BackendError({\n operation: \"worker.deleteLocalData\",\n kind: \"NotImplemented\",\n message: \"Local partition deletion is unavailable.\",\n retryable: false,\n })\n )\n ),\n releaseOwner: Deferred.succeed(released, undefined).pipe(Effect.asVoid),\n });\n yield* Effect.raceFirst(Fiber.join(server), Deferred.await(released));\n}, Effect.scoped);\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAa,sBAAsB,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACvE,SAQF;CACE,IAAI;CACJ,IAAI,OAAO,SAAS,OAAO,GAAG;EAG1B,MAAM,QAAQ,OAAO,SAAS,KAAsC;EACpE,MAAM,UAAU,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;EACrD,OAAO,QAAQ,KACX,OAAO,UAAU,UAAU,uBAAuB,eAA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AO,kBACH,OAAO,KACH,IAAI,aAAa;EACb,WAAW;EACX,MAAM;EACN,WAAW;EACX,SAAS;CACb,CAAC,CACL,CACJ,GACA,OAAO,OAAO,UAAU,SAAS,KAAK,OAAO,KAAK,CAAC,CACvD,CACJ;CACA,MAAM,SAAS,OAAO,oBAAoB;EACtC,GAAG;EACH,YAAY,SAAS,YACjB,OAAO,QAAQ,eACX,OAAO,qBAAqB,KAAK,WAAW,IAAI,CAAC,CAAC,SAAS,OAAO,IAAI,OAAO,IACjF;EACJ,IAAI,SAAS;GAET,OAAO,OAAO,KAAA,IAAY;EAC9B;EACA,IAAI,UAAU;GACV,OAAO,QAAQ;EACnB;EACA,IAAI,UAAU;GACV,OAAO;EACX;EACA,IAAI,KAAK;GACL,OAAO,MAAM,MAAM,QAAQ,QAAQ;EACvC;EACA,IAAI,UAAU;GACV,OAAO,MAAM,WAAW,QAAQ,WAAW,QAAQ,QAAQ;EAC/D;EACA,IAAI,SAAS;GACT,OAAO,QAAQ;EACnB;EACA,OAAO,OAAO,OAAO,OAAO;EAC5B,iBAAiB,OAAO,QACpB,eAEI,QAAQ,mBACR,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL,CACR;EACA,cAAc,SAAS,QAAQ,UAAU,KAAA,CAAS,CAAC,CAAC,KAAK,OAAO,MAAM;CAC1E,CAAC;CACD,OAAO,OAAO,UAAU,MAAM,KAAK,MAAM,GAAG,SAAS,MAAM,QAAQ,CAAC;AACxE,GAAG,OAAO,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/ontology-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"effect": "^4.0.5",
|
|
40
|
-
"@party-stack/ontology-backend": "0.
|
|
41
|
-
"@party-stack/ontology-replica": "0.
|
|
40
|
+
"@party-stack/ontology-backend": "0.5.0",
|
|
41
|
+
"@party-stack/ontology-replica": "0.5.1",
|
|
42
42
|
"@party-stack/ontology-spec": "0.4.0",
|
|
43
43
|
"@party-stack/ontology-storage": "0.3.1",
|
|
44
44
|
"@party-stack/runtime": "0.6.2"
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.2.0",
|
|
52
52
|
"vite-plus": "1.2.0",
|
|
53
53
|
"@party-stack/build-config": "0.2.0",
|
|
54
|
-
"@party-stack/connect": "0.4.
|
|
54
|
+
"@party-stack/connect": "0.4.1"
|
|
55
55
|
}
|
|
56
56
|
}
|