@party-stack/ontology-server 0.0.0-stage → 0.11.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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +493 -2
  3. package/lib/attachmentHttp.d.ts +15 -0
  4. package/lib/attachmentHttp.d.ts.map +1 -0
  5. package/lib/attachmentHttp.js +235 -0
  6. package/lib/attachmentHttp.js.map +1 -0
  7. package/lib/attachmentTransfers.d.ts +115 -0
  8. package/lib/attachmentTransfers.d.ts.map +1 -0
  9. package/lib/attachmentTransfers.js +208 -0
  10. package/lib/attachmentTransfers.js.map +1 -0
  11. package/lib/authorization.d.ts +21 -0
  12. package/lib/authorization.d.ts.map +1 -0
  13. package/lib/authorization.js +385 -0
  14. package/lib/authorization.js.map +1 -0
  15. package/lib/bindingFence.d.ts +27 -0
  16. package/lib/bindingFence.d.ts.map +1 -0
  17. package/lib/bindingFence.js +39 -0
  18. package/lib/bindingFence.js.map +1 -0
  19. package/lib/composition.d.ts +467 -0
  20. package/lib/composition.d.ts.map +1 -0
  21. package/lib/composition.js +102 -0
  22. package/lib/composition.js.map +1 -0
  23. package/lib/definitionProjection.d.ts +21 -0
  24. package/lib/definitionProjection.d.ts.map +1 -0
  25. package/lib/definitionProjection.js +441 -0
  26. package/lib/definitionProjection.js.map +1 -0
  27. package/lib/errorProjection.d.ts +22 -0
  28. package/lib/errorProjection.d.ts.map +1 -0
  29. package/lib/errorProjection.js +72 -0
  30. package/lib/errorProjection.js.map +1 -0
  31. package/lib/http.d.ts +23 -0
  32. package/lib/http.d.ts.map +1 -0
  33. package/lib/http.js +17 -0
  34. package/lib/http.js.map +1 -0
  35. package/lib/index.d.ts +5 -0
  36. package/lib/index.js +3 -0
  37. package/lib/internalAccess.d.ts +10 -0
  38. package/lib/internalAccess.d.ts.map +1 -0
  39. package/lib/internalAccess.js +18 -0
  40. package/lib/internalAccess.js.map +1 -0
  41. package/lib/operations.d.ts +1265 -0
  42. package/lib/operations.d.ts.map +1 -0
  43. package/lib/operations.js +621 -0
  44. package/lib/operations.js.map +1 -0
  45. package/lib/policyDefinition.d.ts +19 -0
  46. package/lib/policyDefinition.d.ts.map +1 -0
  47. package/lib/policyDefinition.js +226 -0
  48. package/lib/policyDefinition.js.map +1 -0
  49. package/lib/policyWatches.d.ts +17 -0
  50. package/lib/policyWatches.d.ts.map +1 -0
  51. package/lib/policyWatches.js +49 -0
  52. package/lib/policyWatches.js.map +1 -0
  53. package/lib/receiptPolicy.d.ts +12 -0
  54. package/lib/receiptPolicy.d.ts.map +1 -0
  55. package/lib/receiptPolicy.js +63 -0
  56. package/lib/receiptPolicy.js.map +1 -0
  57. package/lib/replicaBootstrap.d.ts +56 -0
  58. package/lib/replicaBootstrap.d.ts.map +1 -0
  59. package/lib/replicaBootstrap.js +60 -0
  60. package/lib/replicaBootstrap.js.map +1 -0
  61. package/lib/routing.d.ts +87 -0
  62. package/lib/routing.d.ts.map +1 -0
  63. package/lib/routing.js +344 -0
  64. package/lib/routing.js.map +1 -0
  65. package/lib/rpc.d.ts +4799 -0
  66. package/lib/rpc.d.ts.map +1 -0
  67. package/lib/rpc.js +575 -0
  68. package/lib/rpc.js.map +1 -0
  69. package/lib/rpcActivity.d.ts +6 -0
  70. package/lib/rpcActivity.d.ts.map +1 -0
  71. package/lib/rpcActivity.js +8 -0
  72. package/lib/rpcActivity.js.map +1 -0
  73. package/lib/rpcBackend.d.ts +8 -0
  74. package/lib/rpcBackend.d.ts.map +1 -0
  75. package/lib/rpcBackend.js +76 -0
  76. package/lib/rpcBackend.js.map +1 -0
  77. package/lib/rpcHttp.d.ts +24 -0
  78. package/lib/rpcHttp.d.ts.map +1 -0
  79. package/lib/rpcHttp.js +118 -0
  80. package/lib/rpcHttp.js.map +1 -0
  81. package/lib/rpcLocal.d.ts +13 -0
  82. package/lib/rpcLocal.d.ts.map +1 -0
  83. package/lib/rpcLocal.js +26 -0
  84. package/lib/rpcLocal.js.map +1 -0
  85. package/lib/rpcWatch.d.ts +9 -0
  86. package/lib/rpcWatch.d.ts.map +1 -0
  87. package/lib/rpcWatch.js +29 -0
  88. package/lib/rpcWatch.js.map +1 -0
  89. package/lib/rpcWorker.d.ts +38 -0
  90. package/lib/rpcWorker.d.ts.map +1 -0
  91. package/lib/rpcWorker.js +192 -0
  92. package/lib/rpcWorker.js.map +1 -0
  93. package/package.json +53 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.d.ts","names":["OntologyDescription"],"sources":["../src/rpc.ts"],"mappings":";;;;;;;;;;;;;;cAkEM,kBAAgB,OAAA;qBAsDT,cAAY,SAAA,SAAA,IAAA,cAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0ErC,UAAA,sCAAA,OAAA,OAAA,gBAAA,iWAAA,MAAA"}
package/lib/rpc.js ADDED
@@ -0,0 +1,575 @@
1
+ import { RpcActivity } from "./rpcActivity.js";
2
+ import { expectedBindingHeaders, withExpectedBinding } from "./bindingFence.js";
3
+ import { OntologyErrorProjection, errorProjectionLayer, projectActionFailure, projectStateFailures } from "./errorProjection.js";
4
+ import { OntologyOperationRpcs, makeOntologyOperationsClient, ontologyOperationHandlers } from "./operations.js";
5
+ import { makeRpcBackend } from "./rpcBackend.js";
6
+ import { BackendError, classifyBackendFailure } from "@party-stack/ontology-backend";
7
+ import { ClientStateCodec, ClientSubmissionCodec, ClientViewCodec, CompiledSubsetCodec, ObjectSelectionCodec } from "@party-stack/ontology-backend/protocol";
8
+ import { digestBytes } from "@party-stack/ontology-storage/blobs";
9
+ import { Cause, Context, Deferred, Effect, Exit, Layer, PubSub, Schema, Stream, SubscriptionRef } from "effect";
10
+ import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from "effect/rpc";
11
+ import { Table } from "@party-stack/ontology-storage/tables";
12
+ import { pinOntology } from "@party-stack/ontology-replica";
13
+ import { ontologyDefinitionContractSignature, ontologyDefinitionSignature } from "@party-stack/ontology-storage";
14
+ import { objectSubset } from "@party-stack/ontology-backend/subset";
15
+ import { ClientLeaseSchema, ClientSessionSchema, ClientTokenSchema } from "@party-stack/ontology-backend/clients";
16
+ import { DeliveryFrameCodec, DeliveryPositionSchema } from "@party-stack/ontology-backend/delivery";
17
+ import { OntologyDescriptionCodec } from "@party-stack/ontology-backend/description";
18
+ //#region src/rpc.ts
19
+ const Counter = Schema.Int.check(Schema.isBetween({
20
+ minimum: 0,
21
+ maximum: Number.MAX_SAFE_INTEGER
22
+ }));
23
+ const DeliveryStrategy = Schema.Literals([
24
+ "auto",
25
+ "snapshot",
26
+ "incremental"
27
+ ]);
28
+ const Description = OntologyDescriptionCodec;
29
+ const ReplicaRpcs = RpcGroup.make(Rpc.make("Describe", {
30
+ success: Description,
31
+ error: BackendError
32
+ }), Rpc.make("SubscribeSelection", {
33
+ payload: {
34
+ selection: ObjectSelectionCodec,
35
+ resume: Schema.optional(DeliveryPositionSchema)
36
+ },
37
+ success: DeliveryFrameCodec,
38
+ error: BackendError,
39
+ stream: true
40
+ }), Rpc.make("SubscribeState", {
41
+ payload: {
42
+ session: ClientSessionSchema,
43
+ view: ClientViewCodec,
44
+ resume: Schema.optional(DeliveryPositionSchema)
45
+ },
46
+ success: DeliveryFrameCodec,
47
+ error: BackendError,
48
+ stream: true
49
+ }), Rpc.make("AckDelivery", {
50
+ payload: {
51
+ kind: Schema.Literals(["committed", "speculative"]),
52
+ position: DeliveryPositionSchema
53
+ },
54
+ error: BackendError
55
+ }), Rpc.make("Accept", {
56
+ payload: ClientSubmissionCodec,
57
+ error: BackendError
58
+ }), Rpc.make("OpenClient", {
59
+ payload: { resume: Schema.optional(ClientTokenSchema) },
60
+ success: ClientLeaseSchema,
61
+ error: BackendError
62
+ }), Rpc.make("Read", {
63
+ payload: {
64
+ session: ClientSessionSchema,
65
+ view: Schema.optional(ClientViewCodec)
66
+ },
67
+ success: ClientStateCodec,
68
+ error: BackendError
69
+ }), Rpc.make("Submit", {
70
+ payload: ClientSubmissionCodec,
71
+ success: ClientStateCodec,
72
+ error: BackendError
73
+ }), Rpc.make("Acknowledge", {
74
+ payload: {
75
+ session: ClientSessionSchema,
76
+ revision: Counter,
77
+ through: Counter,
78
+ viewGeneration: Schema.optional(Counter)
79
+ },
80
+ error: BackendError
81
+ }), Rpc.make("Demand", {
82
+ payload: CompiledSubsetCodec,
83
+ success: Schema.Literal("ready"),
84
+ error: BackendError,
85
+ stream: true
86
+ }), Rpc.make("Changes", {
87
+ success: Schema.Literal("invalidate"),
88
+ error: BackendError,
89
+ stream: true
90
+ }));
91
+ const OntologyRpcs = ReplicaRpcs.merge(OntologyOperationRpcs).middleware(OntologyErrorProjection);
92
+ var SubscriptionTracing = class extends RpcMiddleware.Service()("@party-stack/ontology-server/SubscriptionTracing", { requiredForClient: true }) {};
93
+ const subscriptionTracingLayer = RpcMiddleware.layerClient(SubscriptionTracing, ({ rpc, request, next }) => RpcSchema.isStreamSchema(rpc.successSchema) ? Effect.annotateCurrentSpan("activity", Context.get(rpc.annotations, RpcActivity)).pipe(Effect.andThen(next(request))) : next(request));
94
+ const makeTracedRpcClient = (group) => RpcClient.make(group.middleware(SubscriptionTracing)).pipe(Effect.provide(subscriptionTracingLayer));
95
+ /** The in-process transport keeps the same subscription/transfer trace classification. */
96
+ const makeTracedRpcClientNoSerialization = (group, options) => RpcClient.makeNoSerialization(group.middleware(SubscriptionTracing), options).pipe(Effect.provide(subscriptionTracingLayer));
97
+ const makeOntologyRpcClient = makeTracedRpcClient(OntologyRpcs);
98
+ const clientSyncOperations = /* @__PURE__ */ new Set([
99
+ "WatchSubset",
100
+ "WatchChanges",
101
+ "PullChanges",
102
+ "SubscribeSelection",
103
+ "AckDelivery",
104
+ "SubscribeState",
105
+ "OpenClient",
106
+ "Read",
107
+ "Submit",
108
+ "Accept",
109
+ "Acknowledge",
110
+ "Demand",
111
+ "Changes"
112
+ ]);
113
+ const baseOntologyRpcHandlers = (options) => {
114
+ const clientSync = options.enableRealtime === true;
115
+ const bindingAuthorization = withExpectedBinding(options);
116
+ const authorize = Effect.fnUntraced(function* (request, headers) {
117
+ yield* bindingAuthorization(request, headers);
118
+ if (!clientSync && clientSyncOperations.has(request.operation)) return yield* new BackendError({
119
+ operation: request.operation,
120
+ kind: "NotImplemented",
121
+ message: "Client synchronization is disabled on this endpoint.",
122
+ retryable: false,
123
+ actionOutcome: "not-committed"
124
+ });
125
+ });
126
+ const snapshots = options.deliveryStrategy === "snapshot";
127
+ const operationOptions = snapshots ? {
128
+ ...options,
129
+ get replica() {
130
+ return options.replica;
131
+ },
132
+ get backend() {
133
+ const backend = options.backend;
134
+ if (!backend) return void 0;
135
+ const watch = backend.changes?.watch;
136
+ return {
137
+ ...backend,
138
+ changes: void 0,
139
+ watchSubset: backend.watchSubset ?? (watch ? () => watch : void 0)
140
+ };
141
+ }
142
+ } : options;
143
+ const unavailableSource = () => Effect.fail(new BackendError({
144
+ operation: "replication",
145
+ kind: "NotImplemented",
146
+ message: "This endpoint serves stateless operations only.",
147
+ retryable: false
148
+ }));
149
+ const unavailableDelivery = () => Effect.fail(new BackendError({
150
+ operation: "delivery",
151
+ kind: "NotImplemented",
152
+ message: "Selected incremental delivery is disabled or unavailable on this endpoint.",
153
+ retryable: false
154
+ }));
155
+ const source = options.source ?? {
156
+ sourceId: options.backend?.sourceId ?? "stateless",
157
+ supportsIdempotency: options.backend?.supportsIdempotency ?? false,
158
+ openClient: unavailableSource,
159
+ read: unavailableSource,
160
+ submit: unavailableSource,
161
+ acknowledge: unavailableSource,
162
+ demand: () => Stream.fromEffect(unavailableSource()),
163
+ subscribeChanges: unavailableSource()
164
+ };
165
+ return ReplicaRpcs.toLayer({
166
+ Describe: (_, context) => authorize({ operation: "Describe" }, context.headers).pipe(Effect.andThen(options.ready ?? Effect.void), Effect.andThen(Effect.gen(function* () {
167
+ const strategy = yield* Schema.decodeUnknownEffect(DeliveryStrategy)(options.deliveryStrategy ?? "auto").pipe(Effect.mapError(() => new BackendError({
168
+ operation: "describe",
169
+ kind: "InvalidConfiguration",
170
+ message: "Invalid delivery strategy.",
171
+ retryable: false
172
+ })));
173
+ const committedDelivery = clientSync && Boolean(options.backend?.subscribeSelection && options.backend.acknowledgeDelivery);
174
+ const speculativeDelivery = clientSync && Boolean(source.subscribe && source.acknowledgeDelivery && source.accept);
175
+ if (clientSync && strategy === "incremental" && !(options.source ? speculativeDelivery : committedDelivery)) return yield* new BackendError({
176
+ operation: "describe",
177
+ kind: "NotImplemented",
178
+ message: "This source does not support incremental selected delivery.",
179
+ retryable: false
180
+ });
181
+ const signature = options.ir ? yield* Effect.try({
182
+ try: () => ontologyDefinitionSignature(options.ir),
183
+ catch: (cause) => new BackendError({
184
+ operation: "describe",
185
+ kind: "InvalidConfiguration",
186
+ message: "Invalid ontology definition.",
187
+ retryable: false,
188
+ cause
189
+ })
190
+ }) : void 0;
191
+ const definitionHash = options.ir ? yield* digestBytes({
192
+ type: "application/json",
193
+ stream: Stream.make(new TextEncoder().encode(signature))
194
+ }).pipe(Effect.mapError((cause) => classifyBackendFailure("describe", cause))) : void 0;
195
+ return {
196
+ version: 1,
197
+ replication: clientSync && options.source ? "speculative" : "committed",
198
+ definitionHash,
199
+ sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? "stateless",
200
+ ir: options.ir,
201
+ context: options.context,
202
+ supportsIdempotency: options.source?.supportsIdempotency ?? options.backend?.supportsIdempotency ?? false,
203
+ delivery: !snapshots && committedDelivery,
204
+ stateDelivery: Boolean(options.source) && !snapshots && speculativeDelivery,
205
+ changes: clientSync && Boolean(operationOptions.backend?.changes),
206
+ watchChanges: clientSync && Boolean(operationOptions.backend?.changes?.watch),
207
+ watchSubset: clientSync && Boolean(operationOptions.backend?.watchSubset || options.ir?.objectTypes.some((type) => typeof operationOptions.backend?.refresh?.(objectSubset(type.name))?.pollIntervalMs === "number")),
208
+ actionParameterResolution: Boolean(options.backend?.resolveActionParameters || options.replica),
209
+ queries: Boolean(options.backend),
210
+ pins: Boolean(options.pins ?? options.replica),
211
+ attachments: options.backend ? options.backend.attachments && { stage: Boolean(options.backend.attachments.stage) } : options.replica ? { stage: true } : void 0,
212
+ encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica)
213
+ };
214
+ }))),
215
+ SubscribeSelection: (request, context) => Stream.unwrap(Effect.gen(function* () {
216
+ yield* authorize({
217
+ operation: "SubscribeSelection",
218
+ selection: request.selection
219
+ }, context.headers);
220
+ if (snapshots || !options.backend?.subscribeSelection) return yield* unavailableDelivery();
221
+ return (yield* options.backend.subscribeSelection(request.selection, options.delivery, request.resume)).frames.pipe(Stream.mapEffect((frame) => Effect.gen(function* () {
222
+ if (!frame.metadata) return frame;
223
+ if (frame.metadata.sourceId !== options.backend.sourceId) return yield* new BackendError({
224
+ operation: "delivery",
225
+ kind: "SourceMismatch",
226
+ message: "The committed delivery source changed.",
227
+ retryable: false
228
+ });
229
+ return {
230
+ ...frame,
231
+ metadata: {
232
+ ...frame.metadata,
233
+ sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? "stateless"
234
+ }
235
+ };
236
+ })));
237
+ })),
238
+ SubscribeState: (request, context) => Stream.unwrap(Effect.gen(function* () {
239
+ yield* authorize({
240
+ operation: "SubscribeState",
241
+ ...request
242
+ }, context.headers);
243
+ if (snapshots || !source.subscribe) return yield* unavailableDelivery();
244
+ return (yield* source.subscribe(request.session, request.view, options.delivery, request.resume)).frames.pipe(Stream.map((frame) => ({
245
+ ...frame,
246
+ changes: frame.changes.map((change) => change.kind === "put" && (change.record.kind === "pending" || change.record.kind === "completed") ? {
247
+ ...change,
248
+ record: {
249
+ ...change.record,
250
+ value: projectActionFailure(change.record.value, options)
251
+ }
252
+ } : change)
253
+ })));
254
+ })),
255
+ AckDelivery: (request, context) => authorize({
256
+ operation: "AckDelivery",
257
+ ...request
258
+ }, context.headers).pipe(Effect.andThen(() => {
259
+ if (snapshots) return unavailableDelivery();
260
+ const ack = request.kind === "committed" ? options.backend?.acknowledgeDelivery : source.acknowledgeDelivery;
261
+ return ack ? ack(request.position) : unavailableSource();
262
+ })),
263
+ Accept: (request, context) => authorize({
264
+ operation: "Accept",
265
+ submission: request
266
+ }, context.headers).pipe(Effect.andThen(() => source.accept ? source.accept(request) : unavailableSource())),
267
+ OpenClient: (request, context) => authorize({
268
+ operation: "OpenClient",
269
+ ...request
270
+ }, context.headers).pipe(Effect.andThen(() => source.openClient(request.resume))),
271
+ Read: (request, context) => authorize({
272
+ operation: "Read",
273
+ ...request
274
+ }, context.headers).pipe(Effect.andThen(() => source.read(request.session, request.view).pipe(Effect.map((result) => ({
275
+ ...result,
276
+ state: projectStateFailures(result.state, options)
277
+ }))))),
278
+ Submit: (request, context) => authorize({
279
+ operation: "Submit",
280
+ submission: request
281
+ }, context.headers).pipe(Effect.andThen(() => source.submit(request).pipe(Effect.map((result) => ({
282
+ ...result,
283
+ state: projectStateFailures(result.state, options)
284
+ }))))),
285
+ Acknowledge: (request, context) => authorize({
286
+ operation: "Acknowledge",
287
+ ...request
288
+ }, context.headers).pipe(Effect.andThen(() => source.acknowledge(request.session, request.revision, request.through, request.viewGeneration))),
289
+ Demand: (subset, context) => Stream.unwrap(Effect.gen(function* () {
290
+ yield* Effect.annotateCurrentSpan("activity", "subscription");
291
+ yield* authorize({
292
+ operation: "Demand",
293
+ subset
294
+ }, context.headers);
295
+ return source.demand(subset).pipe(Stream.as("ready"));
296
+ })),
297
+ Changes: (_, context) => Stream.unwrap(Effect.gen(function* () {
298
+ yield* Effect.annotateCurrentSpan("activity", "subscription");
299
+ yield* authorize({ operation: "Changes" }, context.headers);
300
+ const changes = options.source ? yield* source.subscribeChanges : void 0;
301
+ if (!changes) return yield* unavailableSource();
302
+ return Stream.concat(Stream.make("invalidate"), Stream.map(changes, () => "invalidate"));
303
+ }))
304
+ }).pipe(Layer.merge(ontologyOperationHandlers(operationOptions, authorize)), Layer.merge(errorProjectionLayer(options)));
305
+ };
306
+ const resourceHeader = "x-party-stack-resource";
307
+ /** Administrative resources use the same ontology RPCs and transport. Access is
308
+ * still gated by the parent endpoint before the resource is acquired. */
309
+ const ontologyRpcHandlers = (options) => Layer.unwrap(Effect.gen(function* () {
310
+ const scope = yield* Effect.scope;
311
+ const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);
312
+ const pins = yield* Effect.cached(Effect.gen(function* () {
313
+ if (!options.replica) return yield* new BackendError({
314
+ operation: "pins",
315
+ kind: "NotImplemented",
316
+ retryable: false,
317
+ message: "This endpoint does not own downloads."
318
+ });
319
+ const backend = yield* options.replica.demand.pins.backend;
320
+ return yield* Layer.buildWithScope(baseOntologyRpcHandlers({
321
+ backend,
322
+ ir: pinOntology,
323
+ context: options.context,
324
+ enableRealtime: options.enableRealtime,
325
+ errors: options.errors,
326
+ authorize: (_, headers) => options.authorize({ operation: "ReadPin" }, headers)
327
+ }), scope);
328
+ }));
329
+ const handlers = Object.fromEntries([...OntologyRpcs.requests].map(([tag, rpc]) => {
330
+ const invoke = (payload, request) => Effect.gen(function* () {
331
+ const resource = request.headers[resourceHeader];
332
+ if (resource !== void 0 && resource !== "pins") return yield* new BackendError({
333
+ operation: "ontology.resource",
334
+ kind: "NotFound",
335
+ retryable: false,
336
+ message: "Unknown ontology resource."
337
+ });
338
+ if (resource === "pins") yield* options.authorize({ operation: "ReadPin" }, request.headers);
339
+ const context = resource === "pins" ? yield* pins : ordinary;
340
+ return (yield* OntologyRpcs.accessHandler(tag).pipe(Effect.provideContext(context)))(payload, request);
341
+ });
342
+ return [tag, RpcSchema.isStreamSchema(rpc.successSchema) ? (payload, request) => Stream.unwrap(invoke(payload, request).pipe(Effect.map((result) => result))) : (payload, request) => Effect.flatten(invoke(payload, request).pipe(Effect.map((result) => result)))];
343
+ }));
344
+ return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));
345
+ }));
346
+ const selectPinResource = (client) => Object.fromEntries([...OntologyRpcs.requests.keys()].map((tag) => [tag, (payload, settings) => Reflect.apply(Reflect.get(client, tag), client, [payload, {
347
+ ...settings,
348
+ headers: {
349
+ ...settings?.headers,
350
+ [resourceHeader]: "pins"
351
+ }
352
+ }])]));
353
+ const unavailable = (cause) => classifyBackendFailure("remote.protocol", cause);
354
+ const copyDescription = (description) => Effect.try({
355
+ try: () => Schema.decodeUnknownSync(Description)(Schema.encodeSync(Description)(description)),
356
+ catch: (cause) => new BackendError({
357
+ operation: "remote.describe",
358
+ kind: "InvalidResponse",
359
+ retryable: false,
360
+ message: "Invalid ontology description.",
361
+ cause
362
+ })
363
+ });
364
+ const descriptionValue = Table.make({ name: "ontology-description-identity" });
365
+ const sameDescriptionValue = (left, right) => descriptionValue.encode(left) === descriptionValue.encode(right);
366
+ const protocolIdentity = (description) => ({
367
+ version: description.version,
368
+ replication: description.replication,
369
+ supportsIdempotency: description.supportsIdempotency,
370
+ delivery: Boolean(description.delivery),
371
+ stateDelivery: Boolean(description.stateDelivery),
372
+ changes: Boolean(description.changes),
373
+ watchChanges: Boolean(description.watchChanges),
374
+ watchSubset: Boolean(description.watchSubset),
375
+ actionParameterResolution: Boolean(description.actionParameterResolution),
376
+ queries: Boolean(description.queries),
377
+ pins: Boolean(description.pins),
378
+ attachments: Boolean(description.attachments),
379
+ stageAttachments: Boolean(description.attachments?.stage),
380
+ encrypted: Boolean(description.encrypted)
381
+ });
382
+ const checkBootstrapBinding = (accepted, fresh) => Effect.gen(function* () {
383
+ if (fresh.sourceId !== accepted.sourceId) return yield* new BackendError({
384
+ operation: "remote.validate",
385
+ kind: "SourceMismatch",
386
+ retryable: false,
387
+ message: "The ontology source changed."
388
+ });
389
+ if (!sameDescriptionValue(fresh.context ?? {}, accepted.context ?? {})) return yield* new BackendError({
390
+ operation: "remote.validate",
391
+ kind: "SourceMismatch",
392
+ retryable: false,
393
+ message: "The ontology context changed."
394
+ });
395
+ if (!sameDescriptionValue(protocolIdentity(fresh), protocolIdentity(accepted))) return yield* new BackendError({
396
+ operation: "remote.validate",
397
+ kind: "SchemaMismatch",
398
+ retryable: false,
399
+ message: "The ontology protocol capabilities changed."
400
+ });
401
+ });
402
+ const definitionFailure = Symbol("OntologyClient.definitionFailure");
403
+ /** HTTP byte operations use the same incompatibility notification as typed RPC. */
404
+ const observeOntologyClientFailure = (client, work) => work.pipe(Effect.tapError((error) => client.definition[definitionFailure]?.(error) ?? Effect.void));
405
+ const makeDefinitionClient = Effect.fnUntraced(function* (raw, description, options) {
406
+ const scope = yield* Effect.scope;
407
+ const state = yield* SubscriptionRef.make({
408
+ status: options?.description ? "retained" : "current",
409
+ refreshing: false
410
+ });
411
+ yield* Effect.addFinalizer(() => PubSub.shutdown(state.pubsub));
412
+ let attempt;
413
+ const incompatible = (error) => error.kind === "SchemaMismatch" || error.kind === "SourceMismatch";
414
+ const notify = (error) => options?.onIncompatible?.(error) ?? Effect.void;
415
+ const failed = Effect.fnUntraced(function* (error) {
416
+ const previous = yield* SubscriptionRef.get(state);
417
+ yield* SubscriptionRef.set(state, {
418
+ ...previous,
419
+ status: incompatible(error) ? "incompatible" : previous.status,
420
+ refreshing: false,
421
+ error: previous.status === "incompatible" && !incompatible(error) ? previous.error : error
422
+ });
423
+ if (incompatible(error) && (previous.status !== "incompatible" || previous.error?.kind !== error.kind)) yield* notify(error).pipe(Effect.catchCause((cause) => Effect.logError("Ontology incompatibility callback failed", cause)), Effect.forkIn(scope), Effect.asVoid);
424
+ });
425
+ const validate = options?.validate ?? ((fresh) => !fresh.ir && !description.ir || fresh.ir && description.ir && ontologyDefinitionContractSignature(fresh.ir) === ontologyDefinitionContractSignature(description.ir) ? Effect.void : Effect.fail(new BackendError({
426
+ operation: "remote.definition",
427
+ kind: "SchemaMismatch",
428
+ retryable: false,
429
+ message: "The ontology definition changed."
430
+ })));
431
+ const refresh = Effect.uninterruptibleMask((restore) => Effect.suspend(() => {
432
+ if (attempt) return restore(Deferred.await(attempt));
433
+ const pending = Deferred.makeUnsafe();
434
+ attempt = pending;
435
+ const check = SubscriptionRef.update(state, (current) => ({
436
+ ...current,
437
+ refreshing: true
438
+ })).pipe(Effect.andThen(raw.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(copyDescription))), Effect.tap((fresh) => checkBootstrapBinding(description, fresh)), Effect.tap(validate), Effect.tap(() => SubscriptionRef.set(state, {
439
+ status: "current",
440
+ refreshing: false
441
+ })), Effect.onExit((exit) => Effect.gen(function* () {
442
+ if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {
443
+ const error = Cause.findErrorOption(exit.cause);
444
+ yield* failed(error._tag === "Some" ? error.value : unavailable(Cause.squash(exit.cause)));
445
+ }
446
+ if (attempt === pending) attempt = void 0;
447
+ yield* Deferred.done(pending, exit);
448
+ })), Effect.catchCause(() => Effect.void));
449
+ return Effect.forkIn(check, scope, { startImmediately: true }).pipe(Effect.andThen(restore(Deferred.await(pending))));
450
+ }));
451
+ const report = Effect.fnUntraced(function* (error) {
452
+ if (!incompatible(error)) return;
453
+ yield* failed(error);
454
+ if (error.kind === "SourceMismatch") return;
455
+ yield* refresh.pipe(Effect.catchCause(() => Effect.void), Effect.forkIn(scope), Effect.asVoid);
456
+ });
457
+ const headers = expectedBindingHeaders(description);
458
+ const schemaHash = yield* Effect.cached(Effect.suspend(() => description.ir ? digestBytes({
459
+ type: "application/json",
460
+ stream: Stream.make(new TextEncoder().encode(ontologyDefinitionContractSignature(description.ir)))
461
+ }) : Effect.succeed(void 0)).pipe(Effect.mapError(unavailable)));
462
+ const checkFrame = Effect.fnUntraced(function* (frame) {
463
+ if (frame.metadata) {
464
+ if (frame.metadata.sourceId !== description.sourceId) return yield* new BackendError({
465
+ operation: "remote.definition",
466
+ kind: "SourceMismatch",
467
+ retryable: false,
468
+ message: "The delivered ontology source changed."
469
+ });
470
+ const expected = yield* schemaHash;
471
+ if (expected !== void 0 && frame.metadata.schemaHash !== expected) return yield* new BackendError({
472
+ operation: "remote.definition",
473
+ kind: "SchemaMismatch",
474
+ retryable: false,
475
+ message: "The delivered ontology definition changed."
476
+ });
477
+ }
478
+ return frame;
479
+ });
480
+ return {
481
+ client: Object.fromEntries([...OntologyRpcs.requests].map(([tag, rpc]) => [tag, (payload, options) => {
482
+ const invoke = () => Reflect.apply(Reflect.get(raw, tag), raw, [payload, tag === "Describe" ? options : {
483
+ ...options,
484
+ headers: {
485
+ ...options?.headers,
486
+ ...headers
487
+ }
488
+ }]);
489
+ if (RpcSchema.isStreamSchema(rpc.successSchema)) return (tag === "SubscribeSelection" || tag === "SubscribeState" ? invoke().pipe(Stream.mapEffect(checkFrame)) : invoke()).pipe(Stream.tapError(report));
490
+ return invoke().pipe(Effect.tapError(report));
491
+ }])),
492
+ definition: {
493
+ get: SubscriptionRef.get(state),
494
+ changes: SubscriptionRef.changes(state),
495
+ refresh,
496
+ [definitionFailure]: report
497
+ }
498
+ };
499
+ });
500
+ /** Use the same source contract with Effect RPC's worker, HTTP or socket transport. */
501
+ const makeOntologyProtocolClient = Effect.fn("RemoteOntology.protocol")(function* (client, options) {
502
+ const description = yield* options?.description ? copyDescription(options.description) : client.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(copyDescription));
503
+ if (options?.description && !description.ir) return yield* new BackendError({
504
+ operation: "remote.bootstrap",
505
+ kind: "InvalidConfiguration",
506
+ retryable: false,
507
+ message: "A retained ontology description must include its definition."
508
+ });
509
+ const described = yield* makeDefinitionClient(client, description, options);
510
+ const pinBackend = description.pins ? makeOntologyProtocolClient(selectPinResource(client)).pipe(Effect.map((resource) => resource.backend)) : void 0;
511
+ client = described.client;
512
+ const operations = yield* makeOntologyOperationsClient(client);
513
+ const common = {
514
+ description,
515
+ definition: described.definition,
516
+ operations,
517
+ pins: description.pins ? operations.pins : void 0,
518
+ pinBackend,
519
+ sourceId: description.sourceId,
520
+ definitionHash: description.definitionHash,
521
+ ir: description.ir,
522
+ context: description.context,
523
+ backend: makeRpcBackend(client, description, operations)
524
+ };
525
+ if (description.replication === "committed") return {
526
+ ...common,
527
+ replication: { kind: "committed" }
528
+ };
529
+ const source = {
530
+ sourceId: description.sourceId,
531
+ outbox: operations.outbox,
532
+ supportsIdempotency: description.supportsIdempotency,
533
+ openClient: (resume) => client.OpenClient({ resume }).pipe(Effect.mapError(unavailable)),
534
+ read: (session, view) => client.Read({
535
+ session,
536
+ view
537
+ }).pipe(Effect.mapError(unavailable)),
538
+ submit: (request) => client.Submit(request).pipe(Effect.mapError(unavailable)),
539
+ accept: description.stateDelivery ? (request) => client.Accept(request).pipe(Effect.mapError(unavailable)) : void 0,
540
+ subscribe: description.stateDelivery ? (session, view, _policy, resume) => Effect.succeed({
541
+ frames: client.SubscribeState({
542
+ session,
543
+ view,
544
+ resume
545
+ }).pipe(Stream.mapError(unavailable)),
546
+ acknowledge: (position) => client.AckDelivery({
547
+ kind: "speculative",
548
+ position
549
+ }).pipe(Effect.mapError(unavailable))
550
+ }) : void 0,
551
+ acknowledgeDelivery: description.stateDelivery ? (position) => client.AckDelivery({
552
+ kind: "speculative",
553
+ position
554
+ }).pipe(Effect.mapError(unavailable)) : void 0,
555
+ acknowledge: (session, revision, through, viewGeneration) => client.Acknowledge({
556
+ session,
557
+ revision,
558
+ through,
559
+ viewGeneration
560
+ }).pipe(Effect.mapError(unavailable)),
561
+ subscribeChanges: Effect.succeed(client.Changes().pipe(Stream.map(() => void 0), Stream.mapError(unavailable))),
562
+ demand: (subset) => client.Demand(subset).pipe(Stream.as(void 0), Stream.mapError(unavailable))
563
+ };
564
+ return {
565
+ ...common,
566
+ replication: {
567
+ kind: "speculative",
568
+ source
569
+ }
570
+ };
571
+ });
572
+ //#endregion
573
+ export { OntologyRpcs, errorProjectionLayer, makeOntologyProtocolClient, makeOntologyRpcClient, makeTracedRpcClient, makeTracedRpcClientNoSerialization, observeOntologyClientFailure, ontologyRpcHandlers };
574
+
575
+ //# sourceMappingURL=rpc.js.map