@party-stack/ontology-backend 0.0.0-stage → 0.2.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -2
  3. package/lib/actions.d.ts +47 -0
  4. package/lib/actions.d.ts.map +1 -0
  5. package/lib/actions.js +306 -0
  6. package/lib/actions.js.map +1 -0
  7. package/lib/clients.d.ts +236 -0
  8. package/lib/clients.d.ts.map +1 -0
  9. package/lib/clients.js +211 -0
  10. package/lib/clients.js.map +1 -0
  11. package/lib/delivery.d.ts +746 -0
  12. package/lib/delivery.d.ts.map +1 -0
  13. package/lib/delivery.js +863 -0
  14. package/lib/delivery.js.map +1 -0
  15. package/lib/description.d.ts +29 -0
  16. package/lib/description.d.ts.map +1 -0
  17. package/lib/description.js +28 -0
  18. package/lib/description.js.map +1 -0
  19. package/lib/encrypted.d.ts +41 -0
  20. package/lib/encrypted.d.ts.map +1 -0
  21. package/lib/encrypted.js +111 -0
  22. package/lib/encrypted.js.map +1 -0
  23. package/lib/errors.d.ts +106 -0
  24. package/lib/errors.d.ts.map +1 -0
  25. package/lib/errors.js +275 -0
  26. package/lib/errors.js.map +1 -0
  27. package/lib/fulfillment.d.ts +25 -0
  28. package/lib/fulfillment.d.ts.map +1 -0
  29. package/lib/fulfillment.js +99 -0
  30. package/lib/fulfillment.js.map +1 -0
  31. package/lib/index.d.ts +297 -0
  32. package/lib/index.d.ts.map +1 -0
  33. package/lib/index.js +91 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/maintenance.d.ts +11 -0
  36. package/lib/maintenance.d.ts.map +1 -0
  37. package/lib/maintenance.js +24 -0
  38. package/lib/maintenance.js.map +1 -0
  39. package/lib/meta.d.ts +26 -0
  40. package/lib/meta.d.ts.map +1 -0
  41. package/lib/meta.js +213 -0
  42. package/lib/meta.js.map +1 -0
  43. package/lib/owned.d.ts +74 -0
  44. package/lib/owned.d.ts.map +1 -0
  45. package/lib/owned.js +593 -0
  46. package/lib/owned.js.map +1 -0
  47. package/lib/policy/indexes.d.ts +12 -0
  48. package/lib/policy/indexes.d.ts.map +1 -0
  49. package/lib/policy/indexes.js +113 -0
  50. package/lib/policy/indexes.js.map +1 -0
  51. package/lib/policy/planner.d.ts +10 -0
  52. package/lib/policy/planner.d.ts.map +1 -0
  53. package/lib/policy/planner.js +118 -0
  54. package/lib/policy/planner.js.map +1 -0
  55. package/lib/policy/view.d.ts +31 -0
  56. package/lib/policy/view.d.ts.map +1 -0
  57. package/lib/policy/view.js +173 -0
  58. package/lib/policy/view.js.map +1 -0
  59. package/lib/policy.d.ts +47 -0
  60. package/lib/policy.d.ts.map +1 -0
  61. package/lib/policy.js +100 -0
  62. package/lib/policy.js.map +1 -0
  63. package/lib/protocol.d.ts +570 -0
  64. package/lib/protocol.d.ts.map +1 -0
  65. package/lib/protocol.js +144 -0
  66. package/lib/protocol.js.map +1 -0
  67. package/lib/query.d.ts +33 -0
  68. package/lib/query.d.ts.map +1 -0
  69. package/lib/query.js +51 -0
  70. package/lib/query.js.map +1 -0
  71. package/lib/references.d.ts +8 -0
  72. package/lib/references.d.ts.map +1 -0
  73. package/lib/references.js +41 -0
  74. package/lib/references.js.map +1 -0
  75. package/lib/storage.d.ts +55 -0
  76. package/lib/storage.d.ts.map +1 -0
  77. package/lib/storage.js +168 -0
  78. package/lib/storage.js.map +1 -0
  79. package/lib/subset.d.ts +19 -0
  80. package/lib/subset.d.ts.map +1 -0
  81. package/lib/subset.js +150 -0
  82. package/lib/subset.js.map +1 -0
  83. package/lib/subsetSchema.d.ts +10 -0
  84. package/lib/subsetSchema.d.ts.map +1 -0
  85. package/lib/subsetSchema.js +20 -0
  86. package/lib/subsetSchema.js.map +1 -0
  87. package/package.json +72 -3
package/lib/index.d.ts ADDED
@@ -0,0 +1,297 @@
1
+ import { ApplyActionError, BackendError, BackendErrorKind, BackendErrorKindSchema, ErrorProjection, ErrorProjectionContext, LoadSubsetError, ReplicationError, ReplicationErrorKind, UnauthenticatedError, ValidateActionError, ValidationIssue, ValidationIssueSchema, ValidationReport, ValidationReportSchema, backendErrorStatus, classifyBackendFailure, isUnauthenticatedError, isUnknownActionOutcome, projectBackendError, projectValidationIssue, schemaValidationIssues, unauthenticated } from "./errors.js";
2
+ import { DecryptedValue, DecryptedValueSchema, EncryptedValueSchema, encryptedPropertyCodec, makePropertyDecryption } from "./encrypted.js";
3
+ import { DeliveryPolicy, DeliveryPosition, DeliverySubscription } from "./delivery.js";
4
+ import { makeOntologyBackend } from "./query.js";
5
+ import { ObjectSubset } from "@party-stack/ontology-spec/query";
6
+ import { Key, Row } from "@party-stack/ontology-storage";
7
+ import { Context, Effect, Schema, Scope, Stream } from "effect";
8
+ import { ByteInput } from "@party-stack/ontology-storage/blobs";
9
+ import { AttachmentTypeDef, QueryDocument } from "@party-stack/ontology-spec";
10
+ import { Encrypted, attachment } from "@party-stack/ontology-spec/values";
11
+ //#region src/index.d.ts
12
+ export interface ObjectSelection {
13
+ readonly subsets: readonly ObjectSubset[];
14
+ }
15
+ export interface BackendSnapshot {
16
+ /** Region represented by these rows, including any window already applied.
17
+ * Omitted means the requested subset. A broader unwindowed region lets the
18
+ * engine finish filtering/ordering/windowing and optionally cache extra objects.
19
+ * Rows may include residual candidates outside this region; consumers discard
20
+ * them before installing its objects or recording complete coverage.
21
+ */
22
+ readonly fulfilledSubset?: ObjectSubset;
23
+ readonly rows: readonly Row<Record<string, unknown>>[];
24
+ /** Complete for fulfilledSubset (or the request when omitted), including its window. */
25
+ readonly complete: boolean;
26
+ /** Rows fetched from the provider, before adapter-side filtering/windowing.
27
+ * Diagnostic only; omitted when the adapter cannot report it. Not a DB scan count.
28
+ */
29
+ readonly fetchedRows?: number;
30
+ /** Diagnostic provider filter, not a query-capability or coverage contract. */
31
+ readonly pushdown?: SourceQueryPlan;
32
+ /** Position coordinated with this snapshot, when the backend exposes a durable change stream. */
33
+ readonly cursor?: string;
34
+ }
35
+ export declare const SourceQueryPlanSchema: Schema.Struct<{
36
+ readonly source: Schema.String;
37
+ /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */
38
+ readonly predicates: Schema.$Array<Schema.Struct<{
39
+ readonly path: Schema.$Array<Schema.Int>;
40
+ readonly execution: Schema.Literals<readonly ["source", "candidate", "adapter", "engine"]>;
41
+ }>>;
42
+ readonly sorting: Schema.Literals<readonly ["source", "adapter", "engine", "none"]>;
43
+ readonly pagination: Schema.Literals<readonly ["source", "adapter", "engine", "none"]>;
44
+ readonly rechecksFilter: Schema.Boolean;
45
+ /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */
46
+ readonly native: Schema.optional<Schema.Struct<{
47
+ readonly language: Schema.String;
48
+ readonly text: Schema.String;
49
+ }>>;
50
+ }>;
51
+ export type SourceQueryPlan = Schema.Schema.Type<typeof SourceQueryPlanSchema>;
52
+ export type ObjectChange = {
53
+ readonly kind: "put";
54
+ readonly objectType: string;
55
+ readonly key: Key;
56
+ readonly value: Record<string, unknown>;
57
+ } | {
58
+ readonly kind: "delete";
59
+ readonly objectType: string;
60
+ readonly key: Key;
61
+ };
62
+ export interface BackendCommit {
63
+ readonly cursor: string;
64
+ readonly changes: readonly ObjectChange[];
65
+ readonly operationId?: string;
66
+ }
67
+ export interface BackendChangePage {
68
+ readonly commits: readonly BackendCommit[];
69
+ readonly cursor: string;
70
+ readonly hasMore: boolean;
71
+ }
72
+ export interface AttachmentUpload {
73
+ readonly attachment: attachment;
74
+ readonly blob: ByteInput;
75
+ readonly target?: AttachmentTypeDef;
76
+ }
77
+ export interface ActionRequest {
78
+ /** Stable across retries. The source must separately guarantee keyed idempotency. */
79
+ readonly id: string;
80
+ readonly name: string;
81
+ readonly parameters: Record<string, unknown>;
82
+ readonly attachmentUploads?: readonly AttachmentUpload[];
83
+ /** Portable replay inputs, preserved across rebases, forwarding and authoritative execution. */
84
+ readonly replay?: {
85
+ readonly now: string;
86
+ readonly seed: string;
87
+ };
88
+ }
89
+ export interface ActionReceipt {
90
+ /** The submitted ActionRequest.id, also supplied as the application's idempotencyKey. */
91
+ readonly operationId: string;
92
+ /** Provider commitment is recorded before local read-back/reconciliation. Parent acceptance is separate. */
93
+ readonly outcome: "committed";
94
+ /** Encoded authoritative return value, interpreted using the action returnType. Never a journal payload. */
95
+ readonly result?: unknown;
96
+ readonly cursor?: string;
97
+ /** Optional upstream execution ID. Never substitutes for our stable retry identity. */
98
+ readonly providerOperationId?: string;
99
+ /** Read-back targets for a committed non-journal action. Missing keys
100
+ * means the whole type; an empty list means no modeled object changes.
101
+ * Omission conservatively refreshes every modeled type.
102
+ * Targets are complete unless affectedComplete is explicitly false.
103
+ */
104
+ readonly affected?: readonly {
105
+ readonly objectType: string;
106
+ readonly keys?: readonly Key[];
107
+ }[];
108
+ /** False when these are known targets but automation may have changed other
109
+ * modeled records. Confirmation must not use them as an exhaustive edit list.
110
+ */
111
+ readonly affectedComplete?: boolean;
112
+ readonly attachmentIdMappings?: readonly {
113
+ readonly localId: string;
114
+ readonly remoteId: string;
115
+ }[];
116
+ }
117
+ export declare const ObjectChangeSchema: Schema.Union<readonly [Schema.Struct<{
118
+ readonly kind: Schema.Literal<"put">;
119
+ readonly objectType: Schema.String;
120
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
121
+ readonly value: Schema.$Record<Schema.String, Schema.Unknown>;
122
+ }>, Schema.Struct<{
123
+ readonly kind: Schema.Literal<"delete">;
124
+ readonly objectType: Schema.String;
125
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
126
+ }>]>;
127
+ export declare const ActionReceiptSchema: Schema.Struct<{
128
+ readonly operationId: Schema.String;
129
+ readonly outcome: Schema.Literal<"committed">;
130
+ readonly result: Schema.optional<Schema.Unknown>;
131
+ readonly cursor: Schema.optional<Schema.String>;
132
+ readonly providerOperationId: Schema.optional<Schema.String>;
133
+ readonly affected: Schema.optional<Schema.$Array<Schema.Struct<{
134
+ readonly objectType: Schema.String;
135
+ readonly keys: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
136
+ }>>>;
137
+ readonly affectedComplete: Schema.optional<Schema.Boolean>;
138
+ readonly attachmentIdMappings: Schema.optional<Schema.$Array<Schema.Struct<{
139
+ readonly localId: Schema.String;
140
+ readonly remoteId: Schema.String;
141
+ }>>>;
142
+ }>;
143
+ export declare const BackendCommitSchema: Schema.Struct<{
144
+ readonly cursor: Schema.String;
145
+ readonly changes: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
146
+ readonly kind: Schema.Literal<"put">;
147
+ readonly objectType: Schema.String;
148
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
149
+ readonly value: Schema.$Record<Schema.String, Schema.Unknown>;
150
+ }>, Schema.Struct<{
151
+ readonly kind: Schema.Literal<"delete">;
152
+ readonly objectType: Schema.String;
153
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
154
+ }>]>>;
155
+ readonly operationId: Schema.optional<Schema.String>;
156
+ }>;
157
+ export declare const BackendSnapshotSchema: Schema.Struct<{
158
+ readonly fulfilledSubset: Schema.optional<Schema.declare<ObjectSubset, ObjectSubset>>;
159
+ readonly fetchedRows: Schema.optional<Schema.Number>;
160
+ readonly pushdown: Schema.optional<Schema.Struct<{
161
+ readonly source: Schema.String;
162
+ /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */
163
+ readonly predicates: Schema.$Array<Schema.Struct<{
164
+ readonly path: Schema.$Array<Schema.Int>;
165
+ readonly execution: Schema.Literals<readonly ["source", "candidate", "adapter", "engine"]>;
166
+ }>>;
167
+ readonly sorting: Schema.Literals<readonly ["source", "adapter", "engine", "none"]>;
168
+ readonly pagination: Schema.Literals<readonly ["source", "adapter", "engine", "none"]>;
169
+ readonly rechecksFilter: Schema.Boolean;
170
+ /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */
171
+ readonly native: Schema.optional<Schema.Struct<{
172
+ readonly language: Schema.String;
173
+ readonly text: Schema.String;
174
+ }>>;
175
+ }>>;
176
+ readonly rows: Schema.$Array<Schema.Struct<{
177
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
178
+ readonly value: Schema.$Record<Schema.String, Schema.Unknown>;
179
+ }>>;
180
+ readonly complete: Schema.Boolean;
181
+ readonly cursor: Schema.optional<Schema.String>;
182
+ }>;
183
+ export declare const BackendChangePageSchema: Schema.Struct<{
184
+ readonly commits: Schema.$Array<Schema.Struct<{
185
+ readonly cursor: Schema.String;
186
+ readonly changes: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
187
+ readonly kind: Schema.Literal<"put">;
188
+ readonly objectType: Schema.String;
189
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
190
+ readonly value: Schema.$Record<Schema.String, Schema.Unknown>;
191
+ }>, Schema.Struct<{
192
+ readonly kind: Schema.Literal<"delete">;
193
+ readonly objectType: Schema.String;
194
+ readonly key: Schema.Union<readonly [Schema.String, Schema.Finite]>;
195
+ }>]>>;
196
+ readonly operationId: Schema.optional<Schema.String>;
197
+ }>>;
198
+ readonly cursor: Schema.String;
199
+ readonly hasMore: Schema.Boolean;
200
+ }>;
201
+ export interface BackendAttachments {
202
+ /** Optional authoritative staging before a subsequent action references the handle. */
203
+ readonly stage?: (value: attachment, bytes: ByteInput, options?: {
204
+ readonly target?: AttachmentTypeDef;
205
+ }) => Effect.Effect<attachment, BackendError>;
206
+ /** Keep the caller Scope open through consumption; closing it cancels an unconsumed download too. */
207
+ readonly read: (value: attachment, options?: {
208
+ readonly offset?: number;
209
+ readonly length?: number;
210
+ }) => Effect.Effect<ByteInput, BackendError, Scope.Scope>;
211
+ readonly metadata: (value: attachment, options?: {
212
+ readonly select?: readonly ("size" | "type" | "name" | "dimensions")[];
213
+ }) => Effect.Effect<{
214
+ readonly size?: number;
215
+ readonly type?: string;
216
+ readonly name?: string;
217
+ readonly dimensions?: {
218
+ readonly width: number;
219
+ readonly height: number;
220
+ };
221
+ }, BackendError>;
222
+ }
223
+ export interface BackendEncryptedValues {
224
+ /** Explicit operation. Ordinary record loads return handles and never decrypt them. */
225
+ readonly decrypt: (value: Encrypted<unknown>) => Effect.Effect<DecryptedValue, BackendError>;
226
+ }
227
+ /** A reset requests repair after starting/restarting a watch; it does not
228
+ * assert that data changed. Ordinary void hints always invalidate coverage.
229
+ */
230
+ export type SubsetWatchEvent = void | "reset";
231
+ export interface OntologyBackendService {
232
+ readonly name: string;
233
+ /** Stable identity for the source whose cursors and receipts this binding returns. */
234
+ readonly sourceId: string;
235
+ /** Durable keyed idempotency within the configured receipt-retention window:
236
+ * repeated IDs return the recorded result, with
237
+ * conflicting payloads rejected. The guarantee must survive source restart.
238
+ * Merely receiving an ID, or an action being naturally idempotent, is insufficient.
239
+ */
240
+ readonly supportsIdempotency: boolean;
241
+ /** Indexed bounded local maintenance; the backend owner schedules it. */
242
+ readonly maintenance?: Effect.Effect<void, BackendError>;
243
+ /** Return the request or explicitly describe the region actually fulfilled.
244
+ * Consumers use the shared subset normalizer before applying requested windows.
245
+ */
246
+ readonly loadSubset: (subset: ObjectSubset) => Effect.Effect<BackendSnapshot, BackendError>;
247
+ /** Finite Query IR execution using this binding's trusted context and read path.
248
+ * Provider adapters may evaluate through subset loads; owned storage uses one
249
+ * read transaction. Callers supply query inputs, never authentication context.
250
+ */
251
+ readonly query: (document: QueryDocument, options?: {
252
+ readonly inputs?: Record<string, unknown>;
253
+ }) => Effect.Effect<Record<string, unknown>, BackendError>;
254
+ /** Optional selected committed rows. Closing the Scope releases demand; delivery state expires by policy. */
255
+ readonly subscribeSelection?: (selection: ObjectSelection, policy?: DeliveryPolicy, resume?: DeliveryPosition) => Effect.Effect<DeliverySubscription, BackendError, Scope.Scope>;
256
+ readonly acknowledgeDelivery?: (position: DeliveryPosition) => Effect.Effect<void, BackendError>;
257
+ /** Read-only defaults and edit prefills; never invokes the action. */
258
+ readonly resolveActionParameters?: (name: string, parameters: Record<string, unknown>) => Effect.Effect<Record<string, unknown>, BackendError>;
259
+ /** Acquire a demand-scoped watch before reading its snapshot. Completion proves
260
+ * registration and buffering are active, even before the returned stream is pulled.
261
+ * The acquiring Scope owns registration and release. Undefined means polling.
262
+ * Reconnect within the same stream must fail or emit reset/invalidation;
263
+ * reacquisition establishes a new readiness boundary for a fresh read.
264
+ * Must cover every change relevant to the requested subset; broader watches
265
+ * may emit extra hints. It does not maintain broader fulfilledSubset coverage.
266
+ */
267
+ readonly watchSubset?: (subset: ObjectSubset) => Effect.Effect<Stream.Stream<SubsetWatchEvent, BackendError>, BackendError, Scope.Scope> | undefined;
268
+ /** Recommended demand refresh defaults. Caller configuration wins; healthy
269
+ * watches/journals keep coverage current independently of snapshot age. */
270
+ readonly refresh?: (subset: ObjectSubset) => {
271
+ readonly pollIntervalMs?: number | false;
272
+ readonly maxCoverageAgeMs?: number;
273
+ } | undefined;
274
+ readonly validateAction?: (name: string, parameters: Record<string, unknown>, options?: {
275
+ readonly knownParameters?: readonly string[];
276
+ }) => Effect.Effect<ValidationReport, BackendError>;
277
+ readonly applyAction: (invocation: ActionRequest) => Effect.Effect<ActionReceipt, BackendError>;
278
+ readonly queryFunction: (name: string, parameters: Record<string, unknown>) => Effect.Effect<unknown, BackendError>;
279
+ readonly changes?: {
280
+ readonly pull: (options: {
281
+ readonly cursor?: string;
282
+ readonly limit?: number;
283
+ }) => Effect.Effect<BackendChangePage, BackendError>;
284
+ /** Acquire registered, buffered wake-up hints in the caller's Scope before
285
+ * pulling durable changes. Stream consumption does not initiate registration.
286
+ * Call pull to recover changes after reconnect or restart. */
287
+ readonly watch?: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;
288
+ };
289
+ readonly attachments?: BackendAttachments;
290
+ readonly encrypted?: BackendEncryptedValues;
291
+ }
292
+ declare const OntologyBackend_base: Context.ServiceClass<OntologyBackend, "@party-stack/ontology-backend/OntologyBackend", OntologyBackendService>;
293
+ /** Backend protocol independent of TanStack collections and client lifecycle management. */
294
+ export declare class OntologyBackend extends OntologyBackend_base {}
295
+ //#endregion
296
+ export { type ApplyActionError, BackendError, type BackendErrorKind, BackendErrorKindSchema, type DecryptedValue, DecryptedValueSchema, EncryptedValueSchema, type ErrorProjection, type ErrorProjectionContext, type LoadSubsetError, type ReplicationError, type ReplicationErrorKind, type UnauthenticatedError, type ValidateActionError, type ValidationIssue, ValidationIssueSchema, type ValidationReport, ValidationReportSchema, backendErrorStatus, classifyBackendFailure, encryptedPropertyCodec, isUnauthenticatedError, isUnknownActionOutcome, makeOntologyBackend, makePropertyDecryption, projectBackendError, projectValidationIssue, schemaValidationIssues, unauthenticated };
297
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["_$__encrypted_js0.DecryptedValue","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription","_$__errors_js0.ValidationReport"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;iBAuCiB;WACJ,kBAAkB;;iBAEd;;;;;;;WAOJ,kBAAkB;WAClB,eAAe,IAAI;;WAEnB;;;;WAIA;;WAEA,WAAW;;WAEX;;qBAEA,uBAAqB,OAAA;;;;;;;;;;;;;;;;YAetB,kBAAkB,OAAO,OAAO,YAAY;YAC5C;WAEO;WACA;WACA,KAAK;WACL,OAAO;;WAET;WAAyB;WAA6B,KAAK;;iBAC3D;WACJ;WACA,kBAAkB;WAClB;;iBAEI;WACJ,kBAAkB;WAClB;WACA;;iBAEI;WACJ,YAAY;WACZ,MAAM;WACN,SAAS;;iBAEL;;WAEJ;WACA;WACA,YAAY;WACZ,6BAA6B;;WAE7B;aAAoB;aAAsB;;;iBAEtC;;WAEJ;;WAEA;;WAEA;WACA;;WAEA;;;;;;WAMA;aACI;aACA,gBAAgB;;;;;WAKpB;WACA;aAA2C;aAA0B;;;qBAGrE,oBAAkB,OAAA,gBAAA,OAAA;;;;;;;;;;qBASlB,qBAAmB,OAAA;;;;;;;;;;;;;;;;qBAgBnB,qBAAmB,OAAA;;;;;;;;;;;;;;qBAKnB,uBAAqB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAUrB,yBAAuB,OAAA;;;;;;;;;;;;;;;;;;iBAMnB;;WAEJ,SACL,OAAO,YACP,OAAO,WACP;aAAqB,SAAS;QAC7B,OAAO,OAAO,YAAY;;WAEtB,OACL,OAAO,YACP;aAAqB;aAA0B;QAC9C,OAAO,OAAO,WAAW,cAAc,MAAM;WACzC,WACL,OAAO,YACP;aAAqB;QACpB,OAAO;aAEK;aACA;aACA;aACA;eAAwB;eAAwB;;KAE7D;;iBAWS;;WAEJ,UACL,OAAO,uBACN,OAAO,OADDA,gBACiD;;;;;YAKpD;iBAEK;WACJ;;WAEA;;;;;;WAMA;;WAEA,cAAc,OAAO,aAAa;;;;WAIlC,aAAa,QAAQ,iBAAiB,OAAO,OAAO,iBAAiB;;;;;WAKrE,QACL,UAAU,eACV;aAAqB,SAAS;QAC7B,OAAO,OAAO,yBAAyB;;WAEnC,sBACL,WAAW,iBACX,SADWC,gBAEX,SADiCC,qBAEhC,OAAO,OADyBC,sBAC4B,cAAc,MAAM;WAC5E,uBACL,UAFQD,qBAGP,OAAO,aAAa;;WAEhB,2BACL,cACA,YAAY,4BACX,OAAO,OAAO,yBAAyB;;;;;;;;;WASnC,eACL,QAAQ,iBACP,OAAO,OAAO,OAAO,OAAO,kBAAkB,eAAe,cAAc,MAAM;;;WAG7E,WAAW,QAAQ;aAET;aACA;;WAGV,kBACL,cACA,YAAY,yBACZ;aAAqB;QACpB,OAAO,OAFIE,kBAE2C;WAClD,cAAc,YAAY,kBAAkB,OAAO,OAAO,eAAe;WACzE,gBACL,cACA,YAAY,4BACX,OAAO,gBAAgB;WACnB;aACI,OAAO;eACH;eACA;UACP,OAAO,OAAO,mBAAmB;;;;aAI9B,QAAQ,OAAO,OAAO,OAAO,aAAa,eAAe,cAAc,MAAM;;WAEjF,cAAc;WACd,YAAY;;;;qBAIZ,wBAAwB"}
package/lib/index.js ADDED
@@ -0,0 +1,91 @@
1
+ import { BackendError, BackendErrorKindSchema, ValidationIssueSchema, ValidationReportSchema, backendErrorStatus, classifyBackendFailure, isUnauthenticatedError, isUnknownActionOutcome, projectBackendError, projectValidationIssue, schemaValidationIssues, unauthenticated } from "./errors.js";
2
+ import { ObjectSubsetSchema } from "./subsetSchema.js";
3
+ import { DecryptedValueSchema, EncryptedValueSchema, encryptedPropertyCodec, makePropertyDecryption } from "./encrypted.js";
4
+ import { makeOntologyBackend } from "./query.js";
5
+ import { Context, Schema } from "effect";
6
+ //#region src/index.ts
7
+ const SourceQueryPlanSchema = Schema.Struct({
8
+ source: Schema.String,
9
+ /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */
10
+ predicates: Schema.Array(Schema.Struct({
11
+ path: Schema.Array(Schema.Int),
12
+ execution: Schema.Literals([
13
+ "source",
14
+ "candidate",
15
+ "adapter",
16
+ "engine"
17
+ ])
18
+ })),
19
+ sorting: Schema.Literals([
20
+ "source",
21
+ "adapter",
22
+ "engine",
23
+ "none"
24
+ ]),
25
+ pagination: Schema.Literals([
26
+ "source",
27
+ "adapter",
28
+ "engine",
29
+ "none"
30
+ ]),
31
+ rechecksFilter: Schema.Boolean,
32
+ /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */
33
+ native: Schema.optional(Schema.Struct({
34
+ language: Schema.String,
35
+ text: Schema.String
36
+ }))
37
+ });
38
+ const KeySchema = Schema.Union([Schema.String, Schema.Finite]);
39
+ const ObjectChangeSchema = Schema.Union([Schema.Struct({
40
+ kind: Schema.Literal("put"),
41
+ objectType: Schema.String,
42
+ key: KeySchema,
43
+ value: Schema.Record(Schema.String, Schema.Unknown)
44
+ }), Schema.Struct({
45
+ kind: Schema.Literal("delete"),
46
+ objectType: Schema.String,
47
+ key: KeySchema
48
+ })]);
49
+ const ActionReceiptSchema = Schema.Struct({
50
+ operationId: Schema.String,
51
+ outcome: Schema.Literal("committed"),
52
+ result: Schema.optional(Schema.Unknown),
53
+ cursor: Schema.optional(Schema.String),
54
+ providerOperationId: Schema.optional(Schema.String),
55
+ affected: Schema.optional(Schema.Array(Schema.Struct({
56
+ objectType: Schema.String,
57
+ keys: Schema.optional(Schema.Array(KeySchema))
58
+ }))),
59
+ affectedComplete: Schema.optional(Schema.Boolean),
60
+ attachmentIdMappings: Schema.optional(Schema.Array(Schema.Struct({
61
+ localId: Schema.String,
62
+ remoteId: Schema.String
63
+ })))
64
+ });
65
+ const BackendCommitSchema = Schema.Struct({
66
+ cursor: Schema.String,
67
+ changes: Schema.Array(ObjectChangeSchema),
68
+ operationId: Schema.optional(Schema.String)
69
+ });
70
+ const BackendSnapshotSchema = Schema.Struct({
71
+ fulfilledSubset: Schema.optional(ObjectSubsetSchema),
72
+ fetchedRows: Schema.optional(Schema.Number),
73
+ pushdown: Schema.optional(SourceQueryPlanSchema),
74
+ rows: Schema.Array(Schema.Struct({
75
+ key: KeySchema,
76
+ value: Schema.Record(Schema.String, Schema.Unknown)
77
+ })),
78
+ complete: Schema.Boolean,
79
+ cursor: Schema.optional(Schema.String)
80
+ });
81
+ const BackendChangePageSchema = Schema.Struct({
82
+ commits: Schema.Array(BackendCommitSchema),
83
+ cursor: Schema.String,
84
+ hasMore: Schema.Boolean
85
+ });
86
+ /** Backend protocol independent of TanStack collections and client lifecycle management. */
87
+ var OntologyBackend = class extends Context.Service()("@party-stack/ontology-backend/OntologyBackend") {};
88
+ //#endregion
89
+ export { ActionReceiptSchema, BackendChangePageSchema, BackendCommitSchema, BackendError, BackendErrorKindSchema, BackendSnapshotSchema, DecryptedValueSchema, EncryptedValueSchema, ObjectChangeSchema, OntologyBackend, SourceQueryPlanSchema, ValidationIssueSchema, ValidationReportSchema, backendErrorStatus, classifyBackendFailure, encryptedPropertyCodec, isUnauthenticatedError, isUnknownActionOutcome, makeOntologyBackend, makePropertyDecryption, projectBackendError, projectValidationIssue, schemaValidationIssues, unauthenticated };
90
+
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ObjectSubsetSchema } from \"./subsetSchema.js\";\nimport type { AttachmentTypeDef, QueryDocument } from \"@party-stack/ontology-spec\";\nimport type { ObjectSubset } from \"@party-stack/ontology-spec/query\";\nimport type { attachment, Encrypted } from \"@party-stack/ontology-spec/values\";\nimport type { Key, Row } from \"@party-stack/ontology-storage\";\nimport type { ByteInput } from \"@party-stack/ontology-storage/blobs\";\nimport type { Scope, Effect, Stream } from \"effect\";\n\nexport {\n schemaValidationIssues,\n BackendError,\n BackendErrorKindSchema,\n backendErrorStatus,\n ValidationIssueSchema,\n ValidationReportSchema,\n unauthenticated,\n isUnauthenticatedError,\n classifyBackendFailure,\n projectBackendError,\n projectValidationIssue,\n isUnknownActionOutcome,\n} from \"./errors.js\";\nexport type {\n BackendErrorKind,\n ReplicationErrorKind,\n ReplicationError,\n ErrorProjection,\n ErrorProjectionContext,\n ValidationReport,\n ValidationIssue,\n UnauthenticatedError,\n ApplyActionError,\n ValidateActionError,\n LoadSubsetError,\n} from \"./errors.js\";\nimport { BackendError } from \"./errors.js\";\nexport { makeOntologyBackend } from \"./query.js\";\n\nexport interface ObjectSelection {\n readonly subsets: readonly ObjectSubset[];\n}\nexport interface BackendSnapshot {\n /** Region represented by these rows, including any window already applied.\n * Omitted means the requested subset. A broader unwindowed region lets the\n * engine finish filtering/ordering/windowing and optionally cache extra objects.\n * Rows may include residual candidates outside this region; consumers discard\n * them before installing its objects or recording complete coverage.\n */\n readonly fulfilledSubset?: ObjectSubset;\n readonly rows: readonly Row<Record<string, unknown>>[];\n /** Complete for fulfilledSubset (or the request when omitted), including its window. */\n readonly complete: boolean;\n /** Rows fetched from the provider, before adapter-side filtering/windowing.\n * Diagnostic only; omitted when the adapter cannot report it. Not a DB scan count.\n */\n readonly fetchedRows?: number;\n /** Diagnostic provider filter, not a query-capability or coverage contract. */\n readonly pushdown?: SourceQueryPlan;\n /** Position coordinated with this snapshot, when the backend exposes a durable change stream. */\n readonly cursor?: string;\n}\nexport const SourceQueryPlanSchema = Schema.Struct({\n source: Schema.String,\n /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */\n predicates: Schema.Array(\n Schema.Struct({\n path: Schema.Array(Schema.Int),\n execution: Schema.Literals([\"source\", \"candidate\", \"adapter\", \"engine\"]),\n })\n ),\n sorting: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n pagination: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n rechecksFilter: Schema.Boolean,\n /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */\n native: Schema.optional(Schema.Struct({ language: Schema.String, text: Schema.String })),\n});\nexport type SourceQueryPlan = Schema.Schema.Type<typeof SourceQueryPlanSchema>;\nexport type ObjectChange =\n | {\n readonly kind: \"put\";\n readonly objectType: string;\n readonly key: Key;\n readonly value: Record<string, unknown>;\n }\n | { readonly kind: \"delete\"; readonly objectType: string; readonly key: Key };\nexport interface BackendCommit {\n readonly cursor: string;\n readonly changes: readonly ObjectChange[];\n readonly operationId?: string;\n}\nexport interface BackendChangePage {\n readonly commits: readonly BackendCommit[];\n readonly cursor: string;\n readonly hasMore: boolean;\n}\nexport interface AttachmentUpload {\n readonly attachment: attachment;\n readonly blob: ByteInput;\n readonly target?: AttachmentTypeDef;\n}\nexport interface ActionRequest {\n /** Stable across retries. The source must separately guarantee keyed idempotency. */\n readonly id: string;\n readonly name: string;\n readonly parameters: Record<string, unknown>;\n readonly attachmentUploads?: readonly AttachmentUpload[];\n /** Portable replay inputs, preserved across rebases, forwarding and authoritative execution. */\n readonly replay?: { readonly now: string; readonly seed: string };\n}\nexport interface ActionReceipt {\n /** The submitted ActionRequest.id, also supplied as the application's idempotencyKey. */\n readonly operationId: string;\n /** Provider commitment is recorded before local read-back/reconciliation. Parent acceptance is separate. */\n readonly outcome: \"committed\";\n /** Encoded authoritative return value, interpreted using the action returnType. Never a journal payload. */\n readonly result?: unknown;\n readonly cursor?: string;\n /** Optional upstream execution ID. Never substitutes for our stable retry identity. */\n readonly providerOperationId?: string;\n /** Read-back targets for a committed non-journal action. Missing keys\n * means the whole type; an empty list means no modeled object changes.\n * Omission conservatively refreshes every modeled type.\n * Targets are complete unless affectedComplete is explicitly false.\n */\n readonly affected?: readonly {\n readonly objectType: string;\n readonly keys?: readonly Key[];\n }[];\n /** False when these are known targets but automation may have changed other\n * modeled records. Confirmation must not use them as an exhaustive edit list.\n */\n readonly affectedComplete?: boolean;\n readonly attachmentIdMappings?: readonly { readonly localId: string; readonly remoteId: string }[];\n}\nconst KeySchema = Schema.Union([Schema.String, Schema.Finite]);\nexport const ObjectChangeSchema = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"put\"),\n objectType: Schema.String,\n key: KeySchema,\n value: Schema.Record(Schema.String, Schema.Unknown),\n }),\n Schema.Struct({ kind: Schema.Literal(\"delete\"), objectType: Schema.String, key: KeySchema }),\n]);\nexport const ActionReceiptSchema = Schema.Struct({\n operationId: Schema.String,\n outcome: Schema.Literal(\"committed\"),\n result: Schema.optional(Schema.Unknown),\n cursor: Schema.optional(Schema.String),\n providerOperationId: Schema.optional(Schema.String),\n affected: Schema.optional(\n Schema.Array(\n Schema.Struct({ objectType: Schema.String, keys: Schema.optional(Schema.Array(KeySchema)) })\n )\n ),\n affectedComplete: Schema.optional(Schema.Boolean),\n attachmentIdMappings: Schema.optional(\n Schema.Array(Schema.Struct({ localId: Schema.String, remoteId: Schema.String }))\n ),\n});\nexport const BackendCommitSchema = Schema.Struct({\n cursor: Schema.String,\n changes: Schema.Array(ObjectChangeSchema),\n operationId: Schema.optional(Schema.String),\n});\nexport const BackendSnapshotSchema = Schema.Struct({\n fulfilledSubset: Schema.optional(ObjectSubsetSchema),\n fetchedRows: Schema.optional(Schema.Number),\n pushdown: Schema.optional(SourceQueryPlanSchema),\n rows: Schema.Array(\n Schema.Struct({ key: KeySchema, value: Schema.Record(Schema.String, Schema.Unknown) })\n ),\n complete: Schema.Boolean,\n cursor: Schema.optional(Schema.String),\n});\nexport const BackendChangePageSchema = Schema.Struct({\n commits: Schema.Array(BackendCommitSchema),\n cursor: Schema.String,\n hasMore: Schema.Boolean,\n});\n\nexport interface BackendAttachments {\n /** Optional authoritative staging before a subsequent action references the handle. */\n readonly stage?: (\n value: attachment,\n bytes: ByteInput,\n options?: { readonly target?: AttachmentTypeDef }\n ) => Effect.Effect<attachment, BackendError>;\n /** Keep the caller Scope open through consumption; closing it cancels an unconsumed download too. */\n readonly read: (\n value: attachment,\n options?: { readonly offset?: number; readonly length?: number }\n ) => Effect.Effect<ByteInput, BackendError, Scope.Scope>;\n readonly metadata: (\n value: attachment,\n options?: { readonly select?: readonly (\"size\" | \"type\" | \"name\" | \"dimensions\")[] }\n ) => Effect.Effect<\n {\n readonly size?: number;\n readonly type?: string;\n readonly name?: string;\n readonly dimensions?: { readonly width: number; readonly height: number };\n },\n BackendError\n >;\n}\nexport {\n EncryptedValueSchema,\n DecryptedValueSchema,\n encryptedPropertyCodec,\n makePropertyDecryption,\n} from \"./encrypted.js\";\nexport type { DecryptedValue } from \"./encrypted.js\";\n\nexport interface BackendEncryptedValues {\n /** Explicit operation. Ordinary record loads return handles and never decrypt them. */\n readonly decrypt: (\n value: Encrypted<unknown>\n ) => Effect.Effect<import(\"./encrypted.js\").DecryptedValue, BackendError>;\n}\n/** A reset requests repair after starting/restarting a watch; it does not\n * assert that data changed. Ordinary void hints always invalidate coverage.\n */\nexport type SubsetWatchEvent = void | \"reset\";\n\nexport interface OntologyBackendService {\n readonly name: string;\n /** Stable identity for the source whose cursors and receipts this binding returns. */\n readonly sourceId: string;\n /** Durable keyed idempotency within the configured receipt-retention window:\n * repeated IDs return the recorded result, with\n * conflicting payloads rejected. The guarantee must survive source restart.\n * Merely receiving an ID, or an action being naturally idempotent, is insufficient.\n */\n readonly supportsIdempotency: boolean;\n /** Indexed bounded local maintenance; the backend owner schedules it. */\n readonly maintenance?: Effect.Effect<void, BackendError>;\n /** Return the request or explicitly describe the region actually fulfilled.\n * Consumers use the shared subset normalizer before applying requested windows.\n */\n readonly loadSubset: (subset: ObjectSubset) => Effect.Effect<BackendSnapshot, BackendError>;\n /** Finite Query IR execution using this binding's trusted context and read path.\n * Provider adapters may evaluate through subset loads; owned storage uses one\n * read transaction. Callers supply query inputs, never authentication context.\n */\n readonly query: (\n document: QueryDocument,\n options?: { readonly inputs?: Record<string, unknown> }\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Optional selected committed rows. Closing the Scope releases demand; delivery state expires by policy. */\n readonly subscribeSelection?: (\n selection: ObjectSelection,\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 /** Read-only defaults and edit prefills; never invokes the action. */\n readonly resolveActionParameters?: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Acquire a demand-scoped watch before reading its snapshot. Completion proves\n * registration and buffering are active, even before the returned stream is pulled.\n * The acquiring Scope owns registration and release. Undefined means polling.\n * Reconnect within the same stream must fail or emit reset/invalidation;\n * reacquisition establishes a new readiness boundary for a fresh read.\n * Must cover every change relevant to the requested subset; broader watches\n * may emit extra hints. It does not maintain broader fulfilledSubset coverage.\n */\n readonly watchSubset?: (\n subset: ObjectSubset\n ) => Effect.Effect<Stream.Stream<SubsetWatchEvent, BackendError>, BackendError, Scope.Scope> | undefined;\n /** Recommended demand refresh defaults. Caller configuration wins; healthy\n * watches/journals keep coverage current independently of snapshot age. */\n readonly refresh?: (subset: ObjectSubset) =>\n | {\n readonly pollIntervalMs?: number | false;\n readonly maxCoverageAgeMs?: number;\n }\n | undefined;\n readonly validateAction?: (\n name: string,\n parameters: Record<string, unknown>,\n options?: { readonly knownParameters?: readonly string[] }\n ) => Effect.Effect<import(\"./errors.js\").ValidationReport, BackendError>;\n readonly applyAction: (invocation: ActionRequest) => Effect.Effect<ActionReceipt, BackendError>;\n readonly queryFunction: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<unknown, BackendError>;\n readonly changes?: {\n readonly pull: (options: {\n readonly cursor?: string;\n readonly limit?: number;\n }) => Effect.Effect<BackendChangePage, BackendError>;\n /** Acquire registered, buffered wake-up hints in the caller's Scope before\n * pulling durable changes. Stream consumption does not initiate registration.\n * Call pull to recover changes after reconnect or restart. */\n readonly watch?: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;\n };\n readonly attachments?: BackendAttachments;\n readonly encrypted?: BackendEncryptedValues;\n}\n\n/** Backend protocol independent of TanStack collections and client lifecycle management. */\nexport class OntologyBackend extends Context.Service<OntologyBackend, OntologyBackendService>()(\n \"@party-stack/ontology-backend/OntologyBackend\"\n) {}\n"],"mappings":";;;;;;AA8DA,MAAa,wBAAwB,OAAO,OAAO;CAC/C,QAAQ,OAAO;;CAEf,YAAY,OAAO,MACf,OAAO,OAAO;EACV,MAAM,OAAO,MAAM,OAAO,GAAG;EAC7B,WAAW,OAAO,SAAS;GAAC;GAAU;GAAa;GAAW;EAAQ,CAAC;CAC3E,CAAC,CACL;CACA,SAAS,OAAO,SAAS;EAAC;EAAU;EAAW;EAAU;CAAM,CAAC;CAChE,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAU;CAAM,CAAC;CACnE,gBAAgB,OAAO;;CAEvB,QAAQ,OAAO,SAAS,OAAO,OAAO;EAAE,UAAU,OAAO;EAAQ,MAAM,OAAO;CAAO,CAAC,CAAC;AAC3F,CAAC;AA2DD,MAAM,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAC7D,MAAa,qBAAqB,OAAO,MAAM,CAC3C,OAAO,OAAO;CACV,MAAM,OAAO,QAAQ,KAAK;CAC1B,YAAY,OAAO;CACnB,KAAK;CACL,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;AACtD,CAAC,GACD,OAAO,OAAO;CAAE,MAAM,OAAO,QAAQ,QAAQ;CAAG,YAAY,OAAO;CAAQ,KAAK;AAAU,CAAC,CAC/F,CAAC;AACD,MAAa,sBAAsB,OAAO,OAAO;CAC7C,aAAa,OAAO;CACpB,SAAS,OAAO,QAAQ,WAAW;CACnC,QAAQ,OAAO,SAAS,OAAO,OAAO;CACtC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,qBAAqB,OAAO,SAAS,OAAO,MAAM;CAClD,UAAU,OAAO,SACb,OAAO,MACH,OAAO,OAAO;EAAE,YAAY,OAAO;EAAQ,MAAM,OAAO,SAAS,OAAO,MAAM,SAAS,CAAC;CAAE,CAAC,CAC/F,CACJ;CACA,kBAAkB,OAAO,SAAS,OAAO,OAAO;CAChD,sBAAsB,OAAO,SACzB,OAAO,MAAM,OAAO,OAAO;EAAE,SAAS,OAAO;EAAQ,UAAU,OAAO;CAAO,CAAC,CAAC,CACnF;AACJ,CAAC;AACD,MAAa,sBAAsB,OAAO,OAAO;CAC7C,QAAQ,OAAO;CACf,SAAS,OAAO,MAAM,kBAAkB;CACxC,aAAa,OAAO,SAAS,OAAO,MAAM;AAC9C,CAAC;AACD,MAAa,wBAAwB,OAAO,OAAO;CAC/C,iBAAiB,OAAO,SAAS,kBAAkB;CACnD,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,UAAU,OAAO,SAAS,qBAAqB;CAC/C,MAAM,OAAO,MACT,OAAO,OAAO;EAAE,KAAK;EAAW,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;CAAE,CAAC,CACzF;CACA,UAAU,OAAO;CACjB,QAAQ,OAAO,SAAS,OAAO,MAAM;AACzC,CAAC;AACD,MAAa,0BAA0B,OAAO,OAAO;CACjD,SAAS,OAAO,MAAM,mBAAmB;CACzC,QAAQ,OAAO;CACf,SAAS,OAAO;AACpB,CAAC;;AAgID,IAAa,kBAAb,cAAqC,QAAQ,QAAiD,CAAC,CAC3F,+CACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { BackendError } from "./errors.js";
2
+ import "./index.js";
3
+ import { Effect } from "effect";
4
+ //#region src/maintenance.d.ts
5
+ export declare const maintenanceInterval: (policy: false | {
6
+ readonly intervalMs?: number;
7
+ } | undefined) => Effect.Effect<number | false, BackendError<"InvalidConfiguration">, never>;
8
+ /** One scheduler in the acquisition scope, shared by low-level and storage-backed owners. */
9
+ export declare const scheduleMaintenance: (maintenance: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, never>, interval: number | false) => Effect.Effect<void, never, import("effect/Scope").Scope>;
10
+ //#endregion
11
+ //# sourceMappingURL=maintenance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maintenance.d.ts","names":[],"sources":["../src/maintenance.ts"],"mappings":";;;;qBAGa,sBAAmB;WACY;kBAY1C,OAAA,uBAAA;;qBAGW,sBAAmB,aAAA,OAAA,aAAA,yWAAA,6BAAA,OAAA,2CAAA"}
@@ -0,0 +1,24 @@
1
+ import { BackendError } from "./errors.js";
2
+ import "./index.js";
3
+ import { Effect } from "effect";
4
+ //#region src/maintenance.ts
5
+ const maintenanceInterval = Effect.fnUntraced(function* (policy) {
6
+ if (policy === false) return false;
7
+ const interval = policy?.intervalMs ?? 6e4;
8
+ if (!Number.isSafeInteger(interval) || interval < 1) return yield* new BackendError({
9
+ operation: "maintenance",
10
+ kind: "InvalidConfiguration",
11
+ retryable: false,
12
+ message: "Maintenance interval must be a positive integer."
13
+ });
14
+ return interval;
15
+ });
16
+ /** One scheduler in the acquisition scope, shared by low-level and storage-backed owners. */
17
+ const scheduleMaintenance = Effect.fnUntraced(function* (maintenance, interval) {
18
+ if (interval === false) return;
19
+ yield* Effect.forkScoped(Effect.forever(Effect.sleep(interval).pipe(Effect.andThen(maintenance), Effect.catch((error) => Effect.logWarning("Ontology maintenance failed", { kind: error.kind })))));
20
+ });
21
+ //#endregion
22
+ export { maintenanceInterval, scheduleMaintenance };
23
+
24
+ //# sourceMappingURL=maintenance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maintenance.js","names":[],"sources":["../src/maintenance.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { BackendError } from \"./index.js\";\n\nexport const maintenanceInterval = Effect.fnUntraced(function* (\n policy: false | { readonly intervalMs?: number } | undefined\n) {\n if (policy === false) return false as const;\n const interval = policy?.intervalMs ?? 60_000;\n if (!Number.isSafeInteger(interval) || interval < 1)\n return yield* new BackendError({\n operation: \"maintenance\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"Maintenance interval must be a positive integer.\",\n });\n return interval;\n});\n\n/** One scheduler in the acquisition scope, shared by low-level and storage-backed owners. */\nexport const scheduleMaintenance = Effect.fnUntraced(function* (\n maintenance: Effect.Effect<void, BackendError>,\n interval: number | false\n) {\n if (interval === false) return;\n yield* Effect.forkScoped(\n Effect.forever(\n Effect.sleep(interval).pipe(\n Effect.andThen(maintenance),\n Effect.catch((error) =>\n Effect.logWarning(\"Ontology maintenance failed\", { kind: error.kind })\n )\n )\n )\n );\n});\n"],"mappings":";;;;AAGA,MAAa,sBAAsB,OAAO,WAAW,WACjD,QACF;CACE,IAAI,WAAW,OAAO,OAAO;CAC7B,MAAM,WAAW,QAAQ,cAAc;CACvC,IAAI,CAAC,OAAO,cAAc,QAAQ,KAAK,WAAW,GAC9C,OAAO,OAAO,IAAI,aAAa;EAC3B,WAAW;EACX,MAAM;EACN,WAAW;EACX,SAAS;CACb,CAAC;CACL,OAAO;AACX,CAAC;;AAGD,MAAa,sBAAsB,OAAO,WAAW,WACjD,aACA,UACF;CACE,IAAI,aAAa,OAAO;CACxB,OAAO,OAAO,WACV,OAAO,QACH,OAAO,MAAM,QAAQ,CAAC,CAAC,KACnB,OAAO,QAAQ,WAAW,GAC1B,OAAO,OAAO,UACV,OAAO,WAAW,+BAA+B,EAAE,MAAM,MAAM,KAAK,CAAC,CACzE,CACJ,CACJ,CACJ;AACJ,CAAC"}
package/lib/meta.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { BackendError } from "./errors.js";
2
+ import { OntologyBackendService } from "./index.js";
3
+ import { Effect, Scope } from "effect";
4
+ import { OntologyIR } from "@party-stack/ontology-spec";
5
+ //#region src/meta.d.ts
6
+ export interface PullOptions {
7
+ /** Omitted selects all definitions of this kind; an empty array selects none. */
8
+ objectTypeNames?: string[];
9
+ actionTypeNames?: string[];
10
+ queryFunctionTypeNames?: string[];
11
+ /** App-specific definition edits, applied before the final IR validation. */
12
+ transformPulledOntology?: (ontology: OntologyIR) => OntologyIR | Promise<OntologyIR>;
13
+ }
14
+ /** Pull selected definitions directly from a metadata backend, without a replica or UI collections. */
15
+ export declare const pull: (backend: Pick<OntologyBackendService, "query">, options?: PullOptions | undefined) => Effect.Effect<OntologyIR, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, never>;
16
+ /** Assemble a runtime definition through ordinary metadata queries. Completeness
17
+ * is the adapter's query contract; this does not invent an atomic provider revision.
18
+ */
19
+ export declare const loadDefinition: (backend: Pick<OntologyBackendService, "query">) => Effect.Effect<OntologyIR, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, never>;
20
+ export declare function makeMetadataBackend(ir: OntologyIR): OntologyBackendService;
21
+ export interface OntologyPullConfig<R = never> extends Omit<PullOptions, "queryFunctionTypeNames"> {
22
+ readonly queryFunctionTypeNames?: string[];
23
+ readonly backend: Effect.Effect<OntologyBackendService, BackendError, R | Scope.Scope>;
24
+ }
25
+ //#endregion
26
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","names":[],"sources":["../src/meta.ts"],"mappings":";;;;;iBA4DiB;;EAEb;EACA;EACA;;EAEA,2BAA2B,UAAU,eAAe,aAAa,QAAQ;;;qBAIhE,OAAI,SAAA,KAAA,kCAAA,UAAA,4BAAA,OAAA,OAAA,YAAA;;;;qBA2IJ,iBAAc,SAAa,KAAK,qCAAgC,OAAA,OAAA,YAAA;wBAM7D,oBAAoB,IAAI,aAAa;iBAkFpC,mBAAmB,mBAAmB,KAAK;WAC/C;WACA,SAAS,OAAO,OAAO,wBAAwB,cAAc,IAAI,MAAM"}