@party-stack/ontology-backend 0.3.1 → 0.4.0
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/delivery.d.ts +0 -5
- package/lib/delivery.d.ts.map +1 -1
- package/lib/protocol.d.ts +3 -8
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +0 -1
- package/lib/protocol.js.map +1 -1
- package/package.json +3 -3
package/lib/delivery.d.ts
CHANGED
|
@@ -78,7 +78,6 @@ export declare const DeliveryRecordSchema: Schema.Union<readonly [Schema.Struct<
|
|
|
78
78
|
}>>>;
|
|
79
79
|
}>>;
|
|
80
80
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
81
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
82
81
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
83
82
|
readonly clientId: Schema.NonEmptyString;
|
|
84
83
|
readonly sequence: Schema.Int;
|
|
@@ -158,7 +157,6 @@ export declare const DeliveryChangeSchema: Schema.Union<readonly [Schema.Struct<
|
|
|
158
157
|
}>>>;
|
|
159
158
|
}>>;
|
|
160
159
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
161
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
162
160
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
163
161
|
readonly clientId: Schema.NonEmptyString;
|
|
164
162
|
readonly sequence: Schema.Int;
|
|
@@ -293,7 +291,6 @@ export declare const DeliveryFrameSchema: Schema.Struct<{
|
|
|
293
291
|
}>>>;
|
|
294
292
|
}>>;
|
|
295
293
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
296
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
297
294
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
298
295
|
readonly clientId: Schema.NonEmptyString;
|
|
299
296
|
readonly sequence: Schema.Int;
|
|
@@ -430,7 +427,6 @@ export declare const DeliveryFrameCodec: Schema.Codec<{
|
|
|
430
427
|
}[] | undefined;
|
|
431
428
|
} | undefined;
|
|
432
429
|
readonly failure?: "Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced" | undefined;
|
|
433
|
-
readonly touchedTypes: readonly string[];
|
|
434
430
|
readonly submission?: {
|
|
435
431
|
readonly clientId: string;
|
|
436
432
|
readonly sequence: number;
|
|
@@ -662,7 +658,6 @@ export declare const makeDeliveryReceiver: (options: {
|
|
|
662
658
|
}[] | undefined;
|
|
663
659
|
} | undefined;
|
|
664
660
|
readonly failure?: "Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced" | undefined;
|
|
665
|
-
readonly touchedTypes: readonly string[];
|
|
666
661
|
readonly submission?: {
|
|
667
662
|
readonly clientId: string;
|
|
668
663
|
readonly sequence: number;
|
package/lib/delivery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.d.ts","names":[],"sources":["../src/delivery.ts"],"mappings":";;;;;;qBAaa,mBAAiB,OAAA,gBAAA,OAAA;;;;;;;;qBAIjB,sBAAoB,OAAA,gBAAA,OAAA
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","names":[],"sources":["../src/delivery.ts"],"mappings":";;;;;;qBAaa,mBAAiB,OAAA,gBAAA,OAAA;;;;;;;;qBAIjB,sBAAoB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiBrB,cAAc,OAAO,OAAO,YAAY;YACxC,iBAAiB,OAAO,OAAO,YAAY;qBAC1C,sBAAoB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAIrB,iBAAiB,OAAO,OAAO,YAAY;qBAC1C,wBAAsB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBvB,mBAAmB,OAAO,OAAO,YAAY;qBAE5C,wBAAsB,OAAA;;;;YACvB,mBAAmB,OAAO,OAAO,YAAY;qBAC5C,qBAAmB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUpB,gBAAgB,OAAO,OAAO,YAAY;qBACzC,oBAAkB,OAA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AmB;WACX,QAAA;WACG;MA4nBtB,OAAA,OAAA,wBAAA,MAAA;UAQQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;;;;;;qBAUF,uBAAoB;EACrB,QAAA;EACG;EACE;EACF;;EAEG,eAAC,IAAI,aAAa,OAAO,qBAAqB,OAAO,aAAa;EACzE,QAAC,IAAI,aAAa,OAAO,qBAAqB,OAAO,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2RjC;MACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsB1C,iWAAA,MAAA"}
|
package/lib/protocol.d.ts
CHANGED
|
@@ -28,13 +28,13 @@ export interface PendingAction {
|
|
|
28
28
|
readonly failureRetryable?: boolean;
|
|
29
29
|
readonly receipt?: ActionReceipt;
|
|
30
30
|
readonly failure?: BackendError["kind"];
|
|
31
|
-
readonly touchedTypes: readonly string[];
|
|
32
31
|
readonly submission?: {
|
|
33
32
|
readonly clientId: string;
|
|
34
33
|
readonly sequence: number;
|
|
35
34
|
};
|
|
36
|
-
/** Whether the local prediction is reflected in visible state. `dropped` means
|
|
37
|
-
*
|
|
35
|
+
/** Whether the local prediction is reflected in visible state. `dropped` means it is
|
|
36
|
+
* not reflected locally: its last replay failed (`predictionFailure` says why), or
|
|
37
|
+
* the queue is stopped at a blocked action (this one or an earlier one).
|
|
38
38
|
* `none` means it was never predicted here (confirmed visibility or a source prediction).
|
|
39
39
|
* Absent on entries stored before this field existed; treat as `optimistic ? "applied" : "none"`. */
|
|
40
40
|
readonly prediction?: "applied" | "dropped" | "none";
|
|
@@ -182,7 +182,6 @@ export declare const PendingActionSchema: Schema.Struct<{
|
|
|
182
182
|
}>>>;
|
|
183
183
|
}>>;
|
|
184
184
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
185
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
186
185
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
187
186
|
readonly clientId: Schema.NonEmptyString;
|
|
188
187
|
readonly sequence: Schema.Int;
|
|
@@ -285,7 +284,6 @@ export declare const ReplicaStateSnapshotSchema: Schema.Struct<{
|
|
|
285
284
|
}>>>;
|
|
286
285
|
}>>;
|
|
287
286
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
288
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
289
287
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
290
288
|
readonly clientId: Schema.NonEmptyString;
|
|
291
289
|
readonly sequence: Schema.Int;
|
|
@@ -342,7 +340,6 @@ export declare const ReplicaStateSnapshotSchema: Schema.Struct<{
|
|
|
342
340
|
}>>>;
|
|
343
341
|
}>>;
|
|
344
342
|
readonly failure: Schema.optional<Schema.Literals<readonly ["Unauthenticated", "Forbidden", "NotFound", "ValidationFailed", "InvalidRequest", "InvalidResponse", "InvalidConfiguration", "Conflict", "NotImplemented", "RateLimited", "Unavailable", "Internal", "HistoryExpired", "SessionExpired", "SessionReplaced", "ViewReplaced", "ResultExpired", "SourceMismatch", "SchemaMismatch"]>>;
|
|
345
|
-
readonly touchedTypes: Schema.$Array<Schema.String>;
|
|
346
343
|
readonly submission: Schema.optional<Schema.Struct<{
|
|
347
344
|
readonly clientId: Schema.NonEmptyString;
|
|
348
345
|
readonly sequence: Schema.Int;
|
|
@@ -431,7 +428,6 @@ export declare const ClientStateCodec: Schema.Codec<{
|
|
|
431
428
|
}[] | undefined;
|
|
432
429
|
} | undefined;
|
|
433
430
|
readonly failure?: "Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced" | undefined;
|
|
434
|
-
readonly touchedTypes: readonly string[];
|
|
435
431
|
readonly submission?: {
|
|
436
432
|
readonly clientId: string;
|
|
437
433
|
readonly sequence: number;
|
|
@@ -490,7 +486,6 @@ export declare const ClientStateCodec: Schema.Codec<{
|
|
|
490
486
|
}[] | undefined;
|
|
491
487
|
} | undefined;
|
|
492
488
|
readonly failure?: "Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced" | undefined;
|
|
493
|
-
readonly touchedTypes: readonly string[];
|
|
494
489
|
readonly submission?: {
|
|
495
490
|
readonly clientId: string;
|
|
496
491
|
readonly sequence: number;
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","names":["_$__errors_js0.ValidationIssue","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription"],"sources":["../src/protocol.ts"],"mappings":";;;;;;;;;;iBAciB;WACJ,YAAY;WACZ;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA,yBAXYA;WAYZ;;WAEA;WACA;WACA;WACA,UAAU;WACV,UAAU;WACV;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","names":["_$__errors_js0.ValidationIssue","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription"],"sources":["../src/protocol.ts"],"mappings":";;;;;;;;;;iBAciB;WACJ,YAAY;WACZ;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA,yBAXYA;WAYZ;;WAEA;WACA;WACA;WACA,UAAU;WACV,UAAU;WACV;aAAwB;aAA2B;;;;;;;WAMnD;WACA,oBAAoB;WACpB;;;;;iBAMI;WACJ;WACA;WACA;WACA;aAAkB;;WAClB;aACI;aACA,eAAe,IAAI;aACnB,oBAAoB,IAAI,SAAS;;WAErC,kBAAkB;WAClB,oBAAoB;;;;;iBAMhB;WACJ,kBAAkB;WAClB;;;WAGA;;iBAEI;WACJ;WACA,WAAW;;iBAGP;WACJ;aACI,QAAQ;aACR;;aAEA;;WAEJ,OAAO;WACP,QAAQ;;iBAEJ;WACJ,SAAS;WACT;WACA,YAAY;WACZ;;WAEA;WACA,OAAO;;;;;;iBAOH;WACJ;WACA;aACI,SACL,YACA;eAAqB;UACpB,OAAO,aAAa;aAChB,QACL,YACA;eAAqB;UACpB,OAAO,aAAa;aAChB,OAAO,YAAY,SAAS,kBAAkB,OAAO,aAAa;;WAEtE;WACA,aAAa,SAAS,gBAAgB,OAAO,OAAO,aAAa;WACjE,OAAO,SAAS,eAAe,OAAO,eAAe,OAAO,OAAO,aAAa;WAChF,aACL,SAAS,eACT,MAAM,YACN,SADMC,gBAEN,SADiCC,qBAEhC,OAAO,OADyBC,sBAC4B,cAAc,MAAM;WAC5E,uBACL,UAFQD,qBAGP,OAAO,aAAa;;WAEhB,UAAU,SAAS,qBAAqB,OAAO,aAAa;;;;;WAK5D,SAAS,QAAQ,mBAAmB,OAAO,aAAa;WACxD,kBAAkB,OAAO,OAAO,OAAO,aAAa,eAAe,cAAc,MAAM;WACvF,SAAS,SAAS,qBAAqB,OAAO,OAAO,aAAa;WAClE,cACL,SAAS,eACT,kBACA,iBACA,4BACC,OAAO,aAAa;;;qBAIhB,gBAAa,UAAc;qBAwB3B,qBAAmB,OAAA;;;;;;;;;qBAMnB,qBAAmB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyBnB,sBAAoB,OAAA;;;;qBAIpB,sBAAoB,OAAA;;;;;;;;qBAKpB,kBAAgB,OAAA;;;;;;;;;;;qBAIhB,4BAA0B,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgD1B,qBAAsB,GAAC,QAAU,OAAO,MAAM,OAAK,OAAO,MAAM;qBAoBhE,kBAAgB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAChB,uBAAqB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBACrB,iBAAe,OAAA;;;;;;;;;;;qBACf,qBAAmB,OAAA;;;;qBAEnB,qBAAmB,OAAA;;;;;;;;qBAEnB,mBAAiB,OAAA,iDAAA;qBACjB,sBAAoB,OAAA"}
|
package/lib/protocol.js
CHANGED
|
@@ -62,7 +62,6 @@ const PendingActionSchema = Schema.Struct({
|
|
|
62
62
|
failureRetryable: Schema.optional(Schema.Boolean),
|
|
63
63
|
receipt: Schema.optional(ActionReceiptSchema),
|
|
64
64
|
failure: Schema.optional(BackendErrorKindSchema),
|
|
65
|
-
touchedTypes: Schema.Array(Schema.String),
|
|
66
65
|
submission: Schema.optional(Schema.Struct({
|
|
67
66
|
clientId: Schema.NonEmptyString,
|
|
68
67
|
sequence: PositiveCounter
|
package/lib/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","names":[],"sources":["../src/protocol.ts"],"sourcesContent":["import { QuerySchema } from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport { Effect, Schema, SchemaGetter, SchemaIssue } from \"effect\";\nimport { ClientLeaseSchema, ClientSessionSchema } from \"./clients.js\";\nimport { ObjectSubsetSchema, ObjectSelectionSchema } from \"./subset.js\";\nimport { ActionReceiptSchema, BackendErrorKindSchema, ValidationIssueSchema } from \"./index.js\";\nimport type { ClientLease, ClientSession, ClientToken } from \"./clients.js\";\nimport type { ActionRequest, ActionReceipt, BackendError } from \"./index.js\";\nimport type { CompiledSubset } from \"./subset.js\";\nimport type { Row } from \"@party-stack/ontology-storage\";\nimport type { Override } from \"@party-stack/ontology-storage/overlay\";\nimport type { Scope, Stream } from \"effect\";\n\n/** Logical action state shared by owned sources, intermediate replicas and clients. */\nexport interface PendingAction {\n readonly invocation: ActionRequest;\n readonly requestIdentity: string;\n readonly createdAt: number;\n readonly sequence: number;\n readonly state: \"queued\" | \"sending\" | \"acknowledged\" | \"blocked\";\n readonly optimistic: boolean;\n readonly attempts: number;\n /** Total attempts at the last explicit retry; automatic retry budgets start here. */\n readonly retryFromAttempt?: number;\n readonly nextAttemptAt?: number;\n readonly failureMessage?: string;\n readonly failureIssues?: readonly import(\"./errors.js\").ValidationIssue[];\n readonly completedAt?: number;\n /** The upstream cannot safely deduplicate another attempt; caller acknowledgment is required. */\n readonly retryRequiresAcknowledgement?: boolean;\n readonly failureOutcome?: \"not-committed\" | \"unknown\";\n readonly failureRetryable?: boolean;\n readonly receipt?: ActionReceipt;\n readonly failure?: BackendError[\"kind\"];\n readonly touchedTypes: readonly string[];\n readonly submission?: { readonly clientId: string; readonly sequence: number };\n /** Whether the local prediction is reflected in visible state. `dropped` means the\n * last replay failed: the action is still pending and sent, but not reflected locally.\n * `none` means it was never predicted here (confirmed visibility or a source prediction).\n * Absent on entries stored before this field existed; treat as `optimistic ? \"applied\" : \"none\"`. */\n readonly prediction?: \"applied\" | \"dropped\" | \"none\";\n readonly predictionFailure?: BackendError[\"kind\"];\n readonly predictionMessage?: string;\n}\n\n/** Consistent logical state. Selected views limit membership, while authorization\n * and property/action projection remain the server's responsibility.\n */\nexport interface ReplicaStateSnapshot {\n readonly sourceId: string;\n readonly revision: number;\n readonly definition: string;\n readonly view?: { readonly generation: number };\n readonly objects: readonly {\n readonly objectType: string;\n readonly base: readonly Row<Record<string, unknown>>[];\n readonly overrides: readonly Row<Override<Record<string, unknown>>>[];\n }[];\n readonly pending: readonly PendingAction[];\n readonly completed: readonly PendingAction[];\n}\n\n/** Membership is evaluated against the source's composed visible state. Action\n * inspection is privileged and must be authorized independently of row access.\n */\nexport interface StateSelection {\n readonly subsets: readonly CompiledSubset[];\n readonly actionIds: readonly string[];\n /** Include the pending queue. Outcomes are selected by actionIds, including\n * pending actions already observed by the child, not the parent's full history. */\n readonly inspectActions?: boolean;\n}\nexport interface ClientView {\n readonly generation: number;\n readonly selection: StateSelection;\n}\n\nexport interface ClientState {\n readonly coverage?: readonly {\n readonly subset: CompiledSubset;\n readonly complete: boolean;\n /** Previously confirmed resident coverage; it may need background refresh. */\n readonly cached?: boolean;\n }[];\n readonly state: ReplicaStateSnapshot;\n readonly client: ClientLease;\n}\nexport interface ClientSubmission {\n readonly session: ClientSession;\n readonly sequence: number;\n readonly invocation: ActionRequest;\n readonly optimistic: boolean;\n /** Newly staged child copies required before first acceptance; duplicates need no transfer. */\n readonly stagedAttachments?: readonly string[];\n readonly view?: ClientView;\n}\n\n/** A protocol source need not contain a Replica or an upstream outbox. Ordered\n * submission idempotency is scoped to a valid resumable client lease. A transport\n * must bind authorization and decode data before exposing this interface.\n */\nexport interface OntologySource {\n readonly sourceId: string;\n readonly outbox?: {\n readonly remove: (\n id: string,\n options?: { readonly allowUnknownOutcome?: boolean }\n ) => Effect.Effect<void, BackendError>;\n readonly retry: (\n id: string,\n options?: { readonly allowUnknownOutcome?: boolean }\n ) => Effect.Effect<void, BackendError>;\n readonly edit: (id: string, request: ActionRequest) => Effect.Effect<void, BackendError>;\n };\n readonly supportsIdempotency: boolean;\n readonly openClient: (resume?: ClientToken) => Effect.Effect<ClientLease, BackendError>;\n readonly read: (session: ClientSession, view?: ClientView) => Effect.Effect<ClientState, BackendError>;\n readonly subscribe?: (\n session: ClientSession,\n view: ClientView,\n policy?: import(\"./delivery.js\").DeliveryPolicy,\n resume?: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<import(\"./delivery.js\").DeliverySubscription, BackendError, Scope.Scope>;\n readonly acknowledgeDelivery?: (\n position: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<void, BackendError>;\n /** Acceptance only; selected delivery carries the resulting state. */\n readonly accept?: (request: ClientSubmission) => Effect.Effect<void, BackendError>;\n /** Snapshot-mode interest lease. The first element confirms acquisition;\n * failures/EOF remain observable, and closing the stream releases interest.\n * Replica supervision owns retries, not the transport.\n */\n readonly demand: (subset: CompiledSubset) => Stream.Stream<void, BackendError>;\n readonly subscribeChanges: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;\n readonly submit: (request: ClientSubmission) => Effect.Effect<ClientState, BackendError>;\n readonly acknowledge: (\n session: ClientSession,\n revision: number,\n through: number,\n viewGeneration?: number\n ) => Effect.Effect<void, BackendError>;\n}\n\n/** Row/action arrays represent keyed records, not their transport ordering. */\nexport const stateIdentity = (snapshot: ReplicaStateSnapshot): string => {\n const compare = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);\n const rows = <A>(values: readonly Row<A>[]) =>\n [...values].sort((a, b) => compare(JSON.stringify(a.key), JSON.stringify(b.key)));\n const actions = (values: readonly PendingAction[]) =>\n [...values].sort((a, b) => compare(a.invocation.id, b.invocation.id));\n return Table.make({ name: \"state-identity\" }).encode({\n ...snapshot,\n objects: [...snapshot.objects]\n .sort((a, b) => compare(a.objectType, b.objectType))\n .map((object) => ({\n ...object,\n base: rows(object.base),\n overrides: rows(object.overrides),\n })),\n pending: actions(snapshot.pending),\n completed: actions(snapshot.completed),\n });\n};\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst PositiveCounter = Counter.check(Schema.isGreaterThan(0));\nconst KeySchema = Schema.Union([Schema.String, Schema.Finite]);\nconst ValueSchema = Schema.Record(Schema.String, Schema.Unknown);\nexport const ActionRequestSchema = Schema.Struct({\n id: Schema.NonEmptyString,\n name: Schema.NonEmptyString,\n parameters: ValueSchema,\n replay: Schema.optional(Schema.Struct({ now: Schema.String, seed: Schema.NonEmptyString })),\n});\nexport const PendingActionSchema = Schema.Struct({\n invocation: ActionRequestSchema,\n requestIdentity: Schema.String,\n createdAt: Schema.Finite,\n sequence: PositiveCounter,\n state: Schema.Literals([\"queued\", \"sending\", \"acknowledged\", \"blocked\"]),\n optimistic: Schema.Boolean,\n attempts: Counter,\n retryFromAttempt: Schema.optional(Counter),\n nextAttemptAt: Schema.optional(Schema.Finite),\n failureMessage: Schema.optional(Schema.String),\n failureIssues: Schema.optional(Schema.Array(ValidationIssueSchema)),\n completedAt: Schema.optional(Schema.Finite),\n retryRequiresAcknowledgement: Schema.optional(Schema.Boolean),\n failureOutcome: Schema.optional(Schema.Literals([\"not-committed\", \"unknown\"])),\n failureRetryable: Schema.optional(Schema.Boolean),\n receipt: Schema.optional(ActionReceiptSchema),\n failure: Schema.optional(BackendErrorKindSchema),\n touchedTypes: Schema.Array(Schema.String),\n submission: Schema.optional(\n Schema.Struct({ clientId: Schema.NonEmptyString, sequence: PositiveCounter })\n ),\n prediction: Schema.optional(Schema.Literals([\"applied\", \"dropped\", \"none\"])),\n predictionFailure: Schema.optional(BackendErrorKindSchema),\n predictionMessage: Schema.optional(Schema.String),\n});\nexport const CompiledSubsetSchema = Schema.Struct({\n objectType: Schema.NonEmptyString,\n query: Schema.optional(QuerySchema),\n});\nexport const StateSelectionSchema = Schema.Struct({\n subsets: Schema.Array(CompiledSubsetSchema),\n actionIds: Schema.Array(Schema.NonEmptyString),\n inspectActions: Schema.optional(Schema.Boolean),\n});\nexport const ClientViewSchema = Schema.Struct({\n generation: PositiveCounter,\n selection: StateSelectionSchema,\n});\nexport const ReplicaStateSnapshotSchema = Schema.Struct({\n sourceId: Schema.NonEmptyString,\n revision: PositiveCounter,\n definition: Schema.NonEmptyString,\n view: Schema.optional(Schema.Struct({ generation: PositiveCounter })),\n objects: Schema.Array(\n Schema.Struct({\n objectType: Schema.NonEmptyString,\n base: Schema.Array(Schema.Struct({ key: KeySchema, value: ValueSchema })),\n overrides: Schema.Array(\n Schema.Struct({\n key: KeySchema,\n value: Schema.Union([\n Schema.Struct({ deleted: Schema.Literal(true) }),\n Schema.Struct({ deleted: Schema.Literal(false), value: ValueSchema }),\n ]),\n })\n ),\n })\n ),\n pending: Schema.Array(PendingActionSchema),\n completed: Schema.Array(PendingActionSchema),\n});\nconst ClientStateSchema = Schema.Struct({\n state: ReplicaStateSnapshotSchema,\n client: ClientLeaseSchema,\n coverage: Schema.optional(\n Schema.Array(\n Schema.Struct({\n subset: CompiledSubsetSchema,\n complete: Schema.Boolean,\n cached: Schema.optional(Schema.Boolean),\n })\n )\n ),\n});\nconst ClientSubmissionSchema = Schema.Struct({\n session: ClientSessionSchema,\n sequence: PositiveCounter,\n invocation: ActionRequestSchema,\n optimistic: Schema.Boolean,\n stagedAttachments: Schema.optional(Schema.Array(Schema.NonEmptyString)),\n view: Schema.optional(ClientViewSchema),\n});\n\n// Reuse the storage value codec for bigint/Temporal/nested values rather than\n// letting JSON or structured clone silently change the domain representation.\nconst values = Table.make<unknown>({ name: \"ontology-protocol-value\" });\nexport const protocolValueCodec = <A>(schema: Schema.Codec<A>): Schema.Codec<A, string> =>\n Schema.String.pipe(\n Schema.decodeTo(Schema.Unknown, {\n decode: SchemaGetter.transformEffect((input: string) =>\n Effect.try({\n try: () => values.decode(input),\n catch: () =>\n new SchemaIssue.InvalidValue({ message: \"Invalid ontology protocol encoding.\" }),\n })\n ),\n encode: SchemaGetter.transformEffect((input: unknown) =>\n Effect.try({\n try: () => values.encode(input),\n catch: () =>\n new SchemaIssue.InvalidValue({ message: \"Unsupported ontology protocol value.\" }),\n })\n ),\n }),\n Schema.decodeTo(Schema.toType(schema))\n );\nexport const ClientStateCodec = protocolValueCodec(ClientStateSchema);\nexport const ClientSubmissionCodec = protocolValueCodec(ClientSubmissionSchema);\nexport const ClientViewCodec = protocolValueCodec(ClientViewSchema);\nexport const CompiledSubsetCodec = protocolValueCodec(CompiledSubsetSchema);\n\nexport const StateSelectionCodec = protocolValueCodec(StateSelectionSchema);\n\nexport const ObjectSubsetCodec = protocolValueCodec(ObjectSubsetSchema);\nexport const ObjectSelectionCodec = protocolValueCodec(ObjectSelectionSchema);\n"],"mappings":";;;;;;;;;;AAgJA,MAAa,iBAAiB,aAA2C;CACrE,MAAM,WAAW,GAAW,MAAe,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;CACpE,MAAM,QAAW,WACb,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,QAAQ,KAAK,UAAU,EAAE,GAAG,GAAG,KAAK,UAAU,EAAE,GAAG,CAAC,CAAC;CACpF,MAAM,WAAW,WACb,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,QAAQ,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;CACxE,OAAO,MAAM,KAAK,EAAE,MAAM,iBAAiB,CAAC,CAAC,CAAC,OAAO;EACjD,GAAG;EACH,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,CACzB,MAAM,GAAG,MAAM,QAAQ,EAAE,YAAY,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;AACD,MAAM,oBAAoB,OAAO,OAAO;CACpC,OAAO;CACP,QAAQ;CACR,UAAU,OAAO,SACb,OAAO,MACH,OAAO,OAAO;EACV,QAAQ;EACR,UAAU,OAAO;EACjB,QAAQ,OAAO,SAAS,OAAO,OAAO;CAC1C,CAAC,CACL,CACJ;AACJ,CAAC;AACD,MAAM,yBAAyB,OAAO,OAAO;CACzC,SAAS;CACT,UAAU;CACV,YAAY;CACZ,YAAY,OAAO;CACnB,mBAAmB,OAAO,SAAS,OAAO,MAAM,OAAO,cAAc,CAAC;CACtE,MAAM,OAAO,SAAS,gBAAgB;AAC1C,CAAC;AAID,MAAM,SAAS,MAAM,KAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,MAAa,sBAAyB,WAClC,OAAO,OAAO,KACV,OAAO,SAAS,OAAO,SAAS;CAC5B,QAAQ,aAAa,iBAAiB,UAClC,OAAO,IAAI;EACP,WAAW,OAAO,OAAO,KAAK;EAC9B,aACI,IAAI,YAAY,aAAa,EAAE,SAAS,sCAAsC,CAAC;CACvF,CAAC,CACL;CACA,QAAQ,aAAa,iBAAiB,UAClC,OAAO,IAAI;EACP,WAAW,OAAO,OAAO,KAAK;EAC9B,aACI,IAAI,YAAY,aAAa,EAAE,SAAS,uCAAuC,CAAC;CACxF,CAAC,CACL;AACJ,CAAC,GACD,OAAO,SAAS,OAAO,OAAO,MAAM,CAAC,CACzC;AACJ,MAAa,mBAAmB,mBAAmB,iBAAiB;AACpE,MAAa,wBAAwB,mBAAmB,sBAAsB;AAC9E,MAAa,kBAAkB,mBAAmB,gBAAgB;AAClE,MAAa,sBAAsB,mBAAmB,oBAAoB;AAE1E,MAAa,sBAAsB,mBAAmB,oBAAoB;AAE1E,MAAa,oBAAoB,mBAAmB,kBAAkB;AACtE,MAAa,uBAAuB,mBAAmB,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"protocol.js","names":[],"sources":["../src/protocol.ts"],"sourcesContent":["import { QuerySchema } from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport { Effect, Schema, SchemaGetter, SchemaIssue } from \"effect\";\nimport { ClientLeaseSchema, ClientSessionSchema } from \"./clients.js\";\nimport { ObjectSubsetSchema, ObjectSelectionSchema } from \"./subset.js\";\nimport { ActionReceiptSchema, BackendErrorKindSchema, ValidationIssueSchema } from \"./index.js\";\nimport type { ClientLease, ClientSession, ClientToken } from \"./clients.js\";\nimport type { ActionRequest, ActionReceipt, BackendError } from \"./index.js\";\nimport type { CompiledSubset } from \"./subset.js\";\nimport type { Row } from \"@party-stack/ontology-storage\";\nimport type { Override } from \"@party-stack/ontology-storage/overlay\";\nimport type { Scope, Stream } from \"effect\";\n\n/** Logical action state shared by owned sources, intermediate replicas and clients. */\nexport interface PendingAction {\n readonly invocation: ActionRequest;\n readonly requestIdentity: string;\n readonly createdAt: number;\n readonly sequence: number;\n readonly state: \"queued\" | \"sending\" | \"acknowledged\" | \"blocked\";\n readonly optimistic: boolean;\n readonly attempts: number;\n /** Total attempts at the last explicit retry; automatic retry budgets start here. */\n readonly retryFromAttempt?: number;\n readonly nextAttemptAt?: number;\n readonly failureMessage?: string;\n readonly failureIssues?: readonly import(\"./errors.js\").ValidationIssue[];\n readonly completedAt?: number;\n /** The upstream cannot safely deduplicate another attempt; caller acknowledgment is required. */\n readonly retryRequiresAcknowledgement?: boolean;\n readonly failureOutcome?: \"not-committed\" | \"unknown\";\n readonly failureRetryable?: boolean;\n readonly receipt?: ActionReceipt;\n readonly failure?: BackendError[\"kind\"];\n readonly submission?: { readonly clientId: string; readonly sequence: number };\n /** Whether the local prediction is reflected in visible state. `dropped` means it is\n * not reflected locally: its last replay failed (`predictionFailure` says why), or\n * the queue is stopped at a blocked action (this one or an earlier one).\n * `none` means it was never predicted here (confirmed visibility or a source prediction).\n * Absent on entries stored before this field existed; treat as `optimistic ? \"applied\" : \"none\"`. */\n readonly prediction?: \"applied\" | \"dropped\" | \"none\";\n readonly predictionFailure?: BackendError[\"kind\"];\n readonly predictionMessage?: string;\n}\n\n/** Consistent logical state. Selected views limit membership, while authorization\n * and property/action projection remain the server's responsibility.\n */\nexport interface ReplicaStateSnapshot {\n readonly sourceId: string;\n readonly revision: number;\n readonly definition: string;\n readonly view?: { readonly generation: number };\n readonly objects: readonly {\n readonly objectType: string;\n readonly base: readonly Row<Record<string, unknown>>[];\n readonly overrides: readonly Row<Override<Record<string, unknown>>>[];\n }[];\n readonly pending: readonly PendingAction[];\n readonly completed: readonly PendingAction[];\n}\n\n/** Membership is evaluated against the source's composed visible state. Action\n * inspection is privileged and must be authorized independently of row access.\n */\nexport interface StateSelection {\n readonly subsets: readonly CompiledSubset[];\n readonly actionIds: readonly string[];\n /** Include the pending queue. Outcomes are selected by actionIds, including\n * pending actions already observed by the child, not the parent's full history. */\n readonly inspectActions?: boolean;\n}\nexport interface ClientView {\n readonly generation: number;\n readonly selection: StateSelection;\n}\n\nexport interface ClientState {\n readonly coverage?: readonly {\n readonly subset: CompiledSubset;\n readonly complete: boolean;\n /** Previously confirmed resident coverage; it may need background refresh. */\n readonly cached?: boolean;\n }[];\n readonly state: ReplicaStateSnapshot;\n readonly client: ClientLease;\n}\nexport interface ClientSubmission {\n readonly session: ClientSession;\n readonly sequence: number;\n readonly invocation: ActionRequest;\n readonly optimistic: boolean;\n /** Newly staged child copies required before first acceptance; duplicates need no transfer. */\n readonly stagedAttachments?: readonly string[];\n readonly view?: ClientView;\n}\n\n/** A protocol source need not contain a Replica or an upstream outbox. Ordered\n * submission idempotency is scoped to a valid resumable client lease. A transport\n * must bind authorization and decode data before exposing this interface.\n */\nexport interface OntologySource {\n readonly sourceId: string;\n readonly outbox?: {\n readonly remove: (\n id: string,\n options?: { readonly allowUnknownOutcome?: boolean }\n ) => Effect.Effect<void, BackendError>;\n readonly retry: (\n id: string,\n options?: { readonly allowUnknownOutcome?: boolean }\n ) => Effect.Effect<void, BackendError>;\n readonly edit: (id: string, request: ActionRequest) => Effect.Effect<void, BackendError>;\n };\n readonly supportsIdempotency: boolean;\n readonly openClient: (resume?: ClientToken) => Effect.Effect<ClientLease, BackendError>;\n readonly read: (session: ClientSession, view?: ClientView) => Effect.Effect<ClientState, BackendError>;\n readonly subscribe?: (\n session: ClientSession,\n view: ClientView,\n policy?: import(\"./delivery.js\").DeliveryPolicy,\n resume?: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<import(\"./delivery.js\").DeliverySubscription, BackendError, Scope.Scope>;\n readonly acknowledgeDelivery?: (\n position: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<void, BackendError>;\n /** Acceptance only; selected delivery carries the resulting state. */\n readonly accept?: (request: ClientSubmission) => Effect.Effect<void, BackendError>;\n /** Snapshot-mode interest lease. The first element confirms acquisition;\n * failures/EOF remain observable, and closing the stream releases interest.\n * Replica supervision owns retries, not the transport.\n */\n readonly demand: (subset: CompiledSubset) => Stream.Stream<void, BackendError>;\n readonly subscribeChanges: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;\n readonly submit: (request: ClientSubmission) => Effect.Effect<ClientState, BackendError>;\n readonly acknowledge: (\n session: ClientSession,\n revision: number,\n through: number,\n viewGeneration?: number\n ) => Effect.Effect<void, BackendError>;\n}\n\n/** Row/action arrays represent keyed records, not their transport ordering. */\nexport const stateIdentity = (snapshot: ReplicaStateSnapshot): string => {\n const compare = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);\n const rows = <A>(values: readonly Row<A>[]) =>\n [...values].sort((a, b) => compare(JSON.stringify(a.key), JSON.stringify(b.key)));\n const actions = (values: readonly PendingAction[]) =>\n [...values].sort((a, b) => compare(a.invocation.id, b.invocation.id));\n return Table.make({ name: \"state-identity\" }).encode({\n ...snapshot,\n objects: [...snapshot.objects]\n .sort((a, b) => compare(a.objectType, b.objectType))\n .map((object) => ({\n ...object,\n base: rows(object.base),\n overrides: rows(object.overrides),\n })),\n pending: actions(snapshot.pending),\n completed: actions(snapshot.completed),\n });\n};\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst PositiveCounter = Counter.check(Schema.isGreaterThan(0));\nconst KeySchema = Schema.Union([Schema.String, Schema.Finite]);\nconst ValueSchema = Schema.Record(Schema.String, Schema.Unknown);\nexport const ActionRequestSchema = Schema.Struct({\n id: Schema.NonEmptyString,\n name: Schema.NonEmptyString,\n parameters: ValueSchema,\n replay: Schema.optional(Schema.Struct({ now: Schema.String, seed: Schema.NonEmptyString })),\n});\nexport const PendingActionSchema = Schema.Struct({\n invocation: ActionRequestSchema,\n requestIdentity: Schema.String,\n createdAt: Schema.Finite,\n sequence: PositiveCounter,\n state: Schema.Literals([\"queued\", \"sending\", \"acknowledged\", \"blocked\"]),\n optimistic: Schema.Boolean,\n attempts: Counter,\n retryFromAttempt: Schema.optional(Counter),\n nextAttemptAt: Schema.optional(Schema.Finite),\n failureMessage: Schema.optional(Schema.String),\n failureIssues: Schema.optional(Schema.Array(ValidationIssueSchema)),\n completedAt: Schema.optional(Schema.Finite),\n retryRequiresAcknowledgement: Schema.optional(Schema.Boolean),\n failureOutcome: Schema.optional(Schema.Literals([\"not-committed\", \"unknown\"])),\n failureRetryable: Schema.optional(Schema.Boolean),\n receipt: Schema.optional(ActionReceiptSchema),\n failure: Schema.optional(BackendErrorKindSchema),\n submission: Schema.optional(\n Schema.Struct({ clientId: Schema.NonEmptyString, sequence: PositiveCounter })\n ),\n prediction: Schema.optional(Schema.Literals([\"applied\", \"dropped\", \"none\"])),\n predictionFailure: Schema.optional(BackendErrorKindSchema),\n predictionMessage: Schema.optional(Schema.String),\n});\nexport const CompiledSubsetSchema = Schema.Struct({\n objectType: Schema.NonEmptyString,\n query: Schema.optional(QuerySchema),\n});\nexport const StateSelectionSchema = Schema.Struct({\n subsets: Schema.Array(CompiledSubsetSchema),\n actionIds: Schema.Array(Schema.NonEmptyString),\n inspectActions: Schema.optional(Schema.Boolean),\n});\nexport const ClientViewSchema = Schema.Struct({\n generation: PositiveCounter,\n selection: StateSelectionSchema,\n});\nexport const ReplicaStateSnapshotSchema = Schema.Struct({\n sourceId: Schema.NonEmptyString,\n revision: PositiveCounter,\n definition: Schema.NonEmptyString,\n view: Schema.optional(Schema.Struct({ generation: PositiveCounter })),\n objects: Schema.Array(\n Schema.Struct({\n objectType: Schema.NonEmptyString,\n base: Schema.Array(Schema.Struct({ key: KeySchema, value: ValueSchema })),\n overrides: Schema.Array(\n Schema.Struct({\n key: KeySchema,\n value: Schema.Union([\n Schema.Struct({ deleted: Schema.Literal(true) }),\n Schema.Struct({ deleted: Schema.Literal(false), value: ValueSchema }),\n ]),\n })\n ),\n })\n ),\n pending: Schema.Array(PendingActionSchema),\n completed: Schema.Array(PendingActionSchema),\n});\nconst ClientStateSchema = Schema.Struct({\n state: ReplicaStateSnapshotSchema,\n client: ClientLeaseSchema,\n coverage: Schema.optional(\n Schema.Array(\n Schema.Struct({\n subset: CompiledSubsetSchema,\n complete: Schema.Boolean,\n cached: Schema.optional(Schema.Boolean),\n })\n )\n ),\n});\nconst ClientSubmissionSchema = Schema.Struct({\n session: ClientSessionSchema,\n sequence: PositiveCounter,\n invocation: ActionRequestSchema,\n optimistic: Schema.Boolean,\n stagedAttachments: Schema.optional(Schema.Array(Schema.NonEmptyString)),\n view: Schema.optional(ClientViewSchema),\n});\n\n// Reuse the storage value codec for bigint/Temporal/nested values rather than\n// letting JSON or structured clone silently change the domain representation.\nconst values = Table.make<unknown>({ name: \"ontology-protocol-value\" });\nexport const protocolValueCodec = <A>(schema: Schema.Codec<A>): Schema.Codec<A, string> =>\n Schema.String.pipe(\n Schema.decodeTo(Schema.Unknown, {\n decode: SchemaGetter.transformEffect((input: string) =>\n Effect.try({\n try: () => values.decode(input),\n catch: () =>\n new SchemaIssue.InvalidValue({ message: \"Invalid ontology protocol encoding.\" }),\n })\n ),\n encode: SchemaGetter.transformEffect((input: unknown) =>\n Effect.try({\n try: () => values.encode(input),\n catch: () =>\n new SchemaIssue.InvalidValue({ message: \"Unsupported ontology protocol value.\" }),\n })\n ),\n }),\n Schema.decodeTo(Schema.toType(schema))\n );\nexport const ClientStateCodec = protocolValueCodec(ClientStateSchema);\nexport const ClientSubmissionCodec = protocolValueCodec(ClientSubmissionSchema);\nexport const ClientViewCodec = protocolValueCodec(ClientViewSchema);\nexport const CompiledSubsetCodec = protocolValueCodec(CompiledSubsetSchema);\n\nexport const StateSelectionCodec = protocolValueCodec(StateSelectionSchema);\n\nexport const ObjectSubsetCodec = protocolValueCodec(ObjectSubsetSchema);\nexport const ObjectSelectionCodec = protocolValueCodec(ObjectSelectionSchema);\n"],"mappings":";;;;;;;;;;AAgJA,MAAa,iBAAiB,aAA2C;CACrE,MAAM,WAAW,GAAW,MAAe,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;CACpE,MAAM,QAAW,WACb,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,QAAQ,KAAK,UAAU,EAAE,GAAG,GAAG,KAAK,UAAU,EAAE,GAAG,CAAC,CAAC;CACpF,MAAM,WAAW,WACb,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,QAAQ,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;CACxE,OAAO,MAAM,KAAK,EAAE,MAAM,iBAAiB,CAAC,CAAC,CAAC,OAAO;EACjD,GAAG;EACH,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,CACzB,MAAM,GAAG,MAAM,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CACnD,KAAK,YAAY;GACd,GAAG;GACH,MAAM,KAAK,OAAO,IAAI;GACtB,WAAW,KAAK,OAAO,SAAS;EACpC,EAAE;EACN,SAAS,QAAQ,SAAS,OAAO;EACjC,WAAW,QAAQ,SAAS,SAAS;CACzC,CAAC;AACL;AAEA,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS,OAAO;AAAiB,CAAC,CAAC;AACnG,MAAM,kBAAkB,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AAO,SAAS,gBAAgB;AAC1C,CAAC;AAID,MAAM,SAAS,MAAM,KAAc,EAAE,MAAM,0BAA0B,CAAC;AACtE,MAAa,sBAAyB,WAClC,OAAO,OAAO,KACV,OAAO,SAAS,OAAO,SAAS;CAC5B,QAAQ,aAAa,iBAAiB,UAClC,OAAO,IAAI;EACP,WAAW,OAAO,OAAO,KAAK;EAC9B,aACI,IAAI,YAAY,aAAa,EAAE,SAAS,sCAAsC,CAAC;CACvF,CAAC,CACL;CACA,QAAQ,aAAa,iBAAiB,UAClC,OAAO,IAAI;EACP,WAAW,OAAO,OAAO,KAAK;EAC9B,aACI,IAAI,YAAY,aAAa,EAAE,SAAS,uCAAuC,CAAC;CACxF,CAAC,CACL;AACJ,CAAC,GACD,OAAO,SAAS,OAAO,OAAO,MAAM,CAAC,CACzC;AACJ,MAAa,mBAAmB,mBAAmB,iBAAiB;AACpE,MAAa,wBAAwB,mBAAmB,sBAAsB;AAC9E,MAAa,kBAAkB,mBAAmB,gBAAgB;AAClE,MAAa,sBAAsB,mBAAmB,oBAAoB;AAE1E,MAAa,sBAAsB,mBAAmB,oBAAoB;AAE1E,MAAa,oBAAoB,mBAAmB,kBAAkB;AACtE,MAAa,uBAAuB,mBAAmB,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/ontology-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"temporal-polyfill": "^0.3.0",
|
|
60
|
-
"@party-stack/ontology-spec": "0.
|
|
61
|
-
"@party-stack/ontology-storage": "0.3.
|
|
60
|
+
"@party-stack/ontology-spec": "0.4.0",
|
|
61
|
+
"@party-stack/ontology-storage": "0.3.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@effect/vitest": "^4.0.5",
|