doxum 0.1.22 → 0.1.25

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 (84) hide show
  1. package/README.md +210 -105
  2. package/dist/advanced.cjs +237 -2
  3. package/dist/advanced.cjs.map +1 -0
  4. package/dist/advanced.d.cts +98 -2
  5. package/dist/advanced.d.ts +98 -2
  6. package/dist/advanced.js +236 -1
  7. package/dist/advanced.js.map +1 -0
  8. package/dist/{contract-CRrZ-3sF.d.cts → contract-DB8XvNt0.d.cts} +102 -99
  9. package/dist/{contract-CxiNcqMn.d.ts → contract-Dawq6LKS.d.ts} +102 -99
  10. package/dist/definition-CHVS-RDY.d.cts +110 -0
  11. package/dist/definition-DT1NpMul.d.ts +110 -0
  12. package/dist/driver-B5vdPohL.js +385 -0
  13. package/dist/driver-B5vdPohL.js.map +1 -0
  14. package/dist/driver-BL91gn7_.cjs +480 -0
  15. package/dist/driver-BL91gn7_.cjs.map +1 -0
  16. package/dist/index.cjs +3489 -954
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +66 -32
  19. package/dist/index.d.ts +66 -32
  20. package/dist/index.js +4114 -1579
  21. package/dist/index.js.map +1 -1
  22. package/dist/local-sync.cjs +69 -103
  23. package/dist/local-sync.cjs.map +1 -1
  24. package/dist/local-sync.d.cts +14 -26
  25. package/dist/local-sync.d.ts +14 -26
  26. package/dist/local-sync.js +68 -96
  27. package/dist/local-sync.js.map +1 -1
  28. package/dist/react.cjs +6 -75
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +6 -9
  31. package/dist/react.d.ts +6 -9
  32. package/dist/react.js +7 -76
  33. package/dist/react.js.map +1 -1
  34. package/dist/record-B2yRhYsc.js +28 -0
  35. package/dist/record-B2yRhYsc.js.map +1 -0
  36. package/dist/record-ChYUi8PP.cjs +45 -0
  37. package/dist/record-ChYUi8PP.cjs.map +1 -0
  38. package/dist/scheduler--137L3j-.js +500 -0
  39. package/dist/scheduler--137L3j-.js.map +1 -0
  40. package/dist/scheduler-D4VthaaK.cjs +589 -0
  41. package/dist/scheduler-D4VthaaK.cjs.map +1 -0
  42. package/package.json +5 -8
  43. package/skills/doxum-runtime/SKILL.md +28 -8
  44. package/skills/doxum-runtime/agents/openai.yaml +1 -1
  45. package/skills/doxum-runtime/references/api.en.md +243 -0
  46. package/skills/doxum-runtime/references/api.zh-CN.md +236 -0
  47. package/skills/doxum-runtime/references/guide.en.md +26 -14
  48. package/skills/doxum-runtime/references/guide.zh-CN.md +21 -11
  49. package/skills/doxum-runtime/references/invariants.en.md +32 -6
  50. package/skills/doxum-runtime/references/invariants.zh-CN.md +26 -7
  51. package/skills/doxum-runtime/references/patterns.en.md +78 -18
  52. package/skills/doxum-runtime/references/patterns.zh-CN.md +76 -18
  53. package/skills/doxum-runtime/references/projections.en.md +206 -119
  54. package/skills/doxum-runtime/references/projections.zh-CN.md +197 -101
  55. package/dist/access-CZXv_DIF.js +0 -958
  56. package/dist/access-CZXv_DIF.js.map +0 -1
  57. package/dist/access-D64MFRSm.cjs +0 -1101
  58. package/dist/access-D64MFRSm.cjs.map +0 -1
  59. package/dist/advanced-BTStm2cW.js +0 -1192
  60. package/dist/advanced-BTStm2cW.js.map +0 -1
  61. package/dist/advanced-CqrR_4dh.d.ts +0 -176
  62. package/dist/advanced-CyR5o3Xr.d.cts +0 -176
  63. package/dist/advanced-GKZ-CZ6a.cjs +0 -1365
  64. package/dist/advanced-GKZ-CZ6a.cjs.map +0 -1
  65. package/dist/driver-BC06FEMF.cjs +0 -241
  66. package/dist/driver-BC06FEMF.cjs.map +0 -1
  67. package/dist/driver-BqRjwFmU.js +0 -200
  68. package/dist/driver-BqRjwFmU.js.map +0 -1
  69. package/dist/integration-BqDw7e2w.cjs +0 -30
  70. package/dist/integration-BqDw7e2w.cjs.map +0 -1
  71. package/dist/integration-CSXaF8HP.js +0 -25
  72. package/dist/integration-CSXaF8HP.js.map +0 -1
  73. package/dist/integration.cjs +0 -13
  74. package/dist/integration.d.cts +0 -17
  75. package/dist/integration.d.ts +0 -17
  76. package/dist/integration.js +0 -5
  77. package/dist/issue-9U6YLYz3.js +0 -647
  78. package/dist/issue-9U6YLYz3.js.map +0 -1
  79. package/dist/issue-Bo0FIO3b.cjs +0 -886
  80. package/dist/issue-Bo0FIO3b.cjs.map +0 -1
  81. package/dist/notification-CrZHVx3a.js +0 -176
  82. package/dist/notification-CrZHVx3a.js.map +0 -1
  83. package/dist/notification-DFoA9bQY.cjs +0 -235
  84. package/dist/notification-DFoA9bQY.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
- //#region core/src/schema-value.d.ts
1
+ //#region core/src/schema/model.d.ts
2
+ type DocumentAddress = readonly string[];
2
3
  /** Pure synchronous validation. Successful output is ignored; input is never transformed. */
3
- type Validator<T> = ((value: unknown) => T) | {
4
+ type Validator<T> = ((value: unknown) => value is T) | ((value: unknown) => asserts value is T) | {
4
5
  readonly '~standard': {
5
6
  readonly version: 1;
6
7
  readonly vendor: string;
@@ -21,19 +22,6 @@ type Validator<T> = ((value: unknown) => T) | {
21
22
  } | PromiseLike<unknown>;
22
23
  };
23
24
  };
24
- type ParseIssue = {
25
- readonly address: DocumentAddress;
26
- readonly code: 'invalid-value' | 'invalid-key' | 'missing-validator' | 'invalid-tree';
27
- readonly message: string;
28
- };
29
- declare class ParseError extends TypeError {
30
- readonly issues: readonly ParseIssue[];
31
- constructor(issue: ParseIssue);
32
- }
33
- declare const parse: <N extends DocumentNode>(node: N, input: unknown) => Infer<N>;
34
- //#endregion
35
- //#region core/src/schema.d.ts
36
- type DocumentAddress = readonly string[];
37
25
  /** Shared payloads are immutable through every alias, including builtin methods. */
38
26
  type ReadonlyValue<T> = T extends ((...args: never[]) => unknown) ? T : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<ReadonlyValue<K>, ReadonlyValue<V>> : T extends ReadonlySet<infer V> ? ReadonlySet<ReadonlyValue<V>> : T extends Date ? Omit<Date, `set${string}`> : T extends object ? { readonly [K in keyof T]: ReadonlyValue<T[K]> } : T;
39
27
  type DocumentListConfig<TItem> = {
@@ -96,11 +84,24 @@ type TreeNode<TValue, ValueOptional extends boolean = false> = BaseNode<'tree'>
96
84
  readonly value: FieldNode<TValue, ValueOptional>;
97
85
  };
98
86
  type DocumentNode = FieldNode<unknown, false> | FieldNode<unknown, true> | ObjectNode<ObjectShape> | VariantNode<string, VariantShape> | TableNode<ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown, false> | TreeNode<unknown, true>;
87
+ declare const schemaType: unique symbol;
88
+ declare const schemaNode: unique symbol;
89
+ declare const objectSchema: unique symbol;
90
+ type Schema<T = unknown> = {
91
+ readonly [schemaType]: T;
92
+ };
93
+ type ObjectSchema<T extends object = object> = Schema<T> & {
94
+ readonly [objectSchema]: true;
95
+ };
96
+ type SchemaNodeOf<S extends Schema<unknown>> = S extends {
97
+ readonly [schemaNode]: infer N extends DocumentNode;
98
+ } ? N : S extends ObjectSchema<object> ? ObjectNode : DocumentNode;
99
99
  type SchemaObject<T> = { [K in keyof T]: T[K] } & {};
100
100
  /** Infer a document or node value, including optional node presence. */
101
- type Infer<T extends DocumentNode> = T extends {
101
+ type InferNode<T extends DocumentNode> = T extends {
102
102
  readonly optional: true;
103
103
  } ? NodeValue<T> | undefined : NodeValue<T>;
104
+ type Infer<T extends Schema<unknown> | DocumentNode> = T extends Schema<infer TValue> ? TValue : T extends DocumentNode ? InferNode<T> : never;
104
105
  type NodeValue<N> = N extends FieldNode<infer T, infer O> ? O extends true ? ReadonlyValue<T> | undefined : ReadonlyValue<T> : N extends ObjectNode<infer S> ? ShapeValue<S> : N extends VariantNode<infer T, infer V> ? { [K in keyof V & string]: SchemaObject<{ readonly [P in T]: K } & NodeValue<V[K]>> }[keyof V & string] : N extends TableNode<infer V, infer K> ? {
105
106
  readonly ids: readonly K[];
106
107
  readonly byId: Readonly<Record<K, NodeValue<V>>>;
@@ -110,6 +111,7 @@ type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
110
111
  } ? K : never }[keyof S];
111
112
  type RequiredKeys<S extends ObjectShape> = Exclude<keyof S, OptionalKeys<S>>;
112
113
  type ShapeValue<S extends ObjectShape> = SchemaObject<{ readonly [K in RequiredKeys<S>]: NodeValue<S[K]> } & { readonly [K in OptionalKeys<S>]?: NodeValue<S[K]> }>;
114
+ type RootNodeOf<S extends ObjectSchema<object>> = Extract<SchemaNodeOf<S>, ObjectNode>;
113
115
  type EntitySchemaNode = ObjectNode<ObjectShape> | VariantNode<string, VariantShape>;
114
116
  type ValueSchemaNode = EntitySchemaNode | FieldNode<unknown, boolean>;
115
117
  type DocumentAnchor<K extends string = string> = {
@@ -119,43 +121,58 @@ type DocumentAnchor<K extends string = string> = {
119
121
  } | {
120
122
  readonly after: K;
121
123
  };
122
- type TreeTarget = {
123
- readonly kind: 'root';
124
- } | {
125
- readonly kind: 'nodes';
126
- } | {
127
- readonly kind: 'node';
128
- readonly id: string;
129
- };
130
- type TreeValueTarget = Exclude<TreeTarget, {
131
- readonly kind: 'nodes';
132
- }>;
133
- type TreeCollectionTarget = Extract<TreeTarget, {
134
- readonly kind: 'nodes';
135
- }>;
136
- type CollectionSelector<TId extends string = string> = {
137
- readonly kind: 'collection';
138
- readonly schema: ObjectNode;
139
- readonly address: DocumentAddress;
140
- readonly tree?: TreeCollectionTarget;
141
- readonly __id?: TId;
124
+ type SchemaHandle<N extends DocumentNode> = Schema<InferNode<N>> & {
125
+ readonly [schemaNode]: N;
142
126
  };
143
- type ValueSelector<TResult = unknown> = {
144
- readonly kind: 'value';
145
- readonly schema: ObjectNode;
146
- readonly address: DocumentAddress;
147
- readonly tree?: TreeValueTarget;
148
- readonly __value?: TResult;
127
+ type PublicSchemaShape = {
128
+ readonly [key: string]: Schema<unknown>;
149
129
  };
150
- type ImpactTarget<T = unknown> = {
151
- readonly kind: 'value';
152
- readonly at: DocumentAddress;
153
- readonly tree?: TreeValueTarget;
154
- } | ValueSelector<T> | {
155
- readonly kind: 'collection';
156
- readonly at: DocumentAddress;
157
- readonly id?: string;
158
- } | CollectionSelector<string>;
130
+ type NodeShapeOf<S extends PublicSchemaShape> = { readonly [K in keyof S]: SchemaNodeOf<S[K]> };
131
+ type PublicOptionalKeys<S extends PublicSchemaShape> = { [K in keyof S]: SchemaNodeOf<S[K]> extends {
132
+ readonly optional: true;
133
+ } ? K : never }[keyof S];
134
+ type PublicRequiredKeys<S extends PublicSchemaShape> = Exclude<keyof S, PublicOptionalKeys<S>>;
135
+ type PublicShapeValue<S extends PublicSchemaShape> = SchemaObject<{ readonly [K in PublicRequiredKeys<S>]: Infer<S[K]> } & { readonly [K in PublicOptionalKeys<S>]?: Infer<S[K]> }>;
136
+ type ObjectSchemaHandle<S extends PublicSchemaShape> = ObjectSchema<PublicShapeValue<S>> & {
137
+ readonly [schemaNode]: ObjectNode<NodeShapeOf<S>>;
138
+ };
139
+ type FieldSchemaHandle<T> = SchemaHandle<FieldNode<T, false>>;
140
+ type OptionalFieldSchemaHandle<T> = SchemaHandle<FieldNode<T, true>>;
141
+ type OptionalSchemaHandle = Schema<unknown> & {
142
+ readonly [schemaNode]: OptionalLeaf;
143
+ };
144
+ type EntitySchemaHandle = Schema<unknown> & {
145
+ readonly [schemaNode]: EntitySchemaNode;
146
+ };
147
+ type ValueSchemaHandle = Schema<unknown> & {
148
+ readonly [schemaNode]: ValueSchemaNode;
149
+ };
150
+ type PublicVariantShape = {
151
+ readonly [key: string]: ObjectSchema<object>;
152
+ };
153
+ type VariantNodeShapeOf<V extends PublicVariantShape> = { readonly [K in keyof V]: Extract<SchemaNodeOf<V[K]>, ObjectNode> };
154
+ type VariantSchemaHandle<T extends string, V extends PublicVariantShape> = Schema<{ [K in keyof V & string]: SchemaObject<{ readonly [P in T]: K } & Infer<V[K]>> }[keyof V & string]> & {
155
+ readonly [schemaNode]: VariantNode<T, VariantNodeShapeOf<V>>;
156
+ };
157
+ type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown, false> | TreeNode<unknown, true>;
158
+ type OptionalResult<T extends OptionalSchemaHandle> = SchemaHandle<OptionalNode<Extract<SchemaNodeOf<T>, OptionalLeaf>>>;
159
+ type EntityNodeOf<V extends EntitySchemaHandle> = Extract<SchemaNodeOf<V>, EntitySchemaNode>;
160
+ type ValueNodeOf<V extends ValueSchemaHandle> = Extract<SchemaNodeOf<V>, ValueSchemaNode>;
161
+ declare const field: <T>(validator?: Validator<T>) => FieldSchemaHandle<T>;
162
+ declare const optional: <T extends OptionalSchemaHandle>(value: T) => OptionalResult<T>;
163
+ declare const object: <S extends PublicSchemaShape>(shape: S) => ObjectSchemaHandle<S>;
164
+ declare const variant: <T extends string, V extends PublicVariantShape>(tag: T, variants: V) => VariantSchemaHandle<T, V>;
165
+ declare const table: <V extends EntitySchemaHandle, K extends string = string>(value: V, options?: {
166
+ readonly key: Validator<K>;
167
+ }) => SchemaHandle<TableNode<EntityNodeOf<V>, K>>;
168
+ declare const map: <V extends ValueSchemaHandle, K extends string = string>(value: V, options?: {
169
+ readonly key: Validator<K>;
170
+ }) => SchemaHandle<MapNode<ValueNodeOf<V>, K>>;
171
+ declare const list: <TItem>(value: FieldSchemaHandle<TItem>, config: DocumentListConfig<TItem>) => SchemaHandle<ListNode<TItem>>;
172
+ declare function tree<TValue>(value: FieldSchemaHandle<TValue>): SchemaHandle<TreeNode<TValue, false>>;
173
+ declare function tree<TValue>(value: OptionalFieldSchemaHandle<TValue>): SchemaHandle<TreeNode<TValue, true>>;
174
+ //#endregion
175
+ //#region core/src/schema/path.d.ts
159
176
  declare const pathValue: unique symbol;
160
177
  declare const collectionEntry: unique symbol;
161
178
  declare const collectionKey: unique symbol;
@@ -171,8 +188,8 @@ type NodeAbsent<N extends DocumentNode, ParentAbsent extends boolean> = Or<Paren
171
188
  } ? true : false>;
172
189
  type PathResult<N extends DocumentNode, ParentAbsent extends boolean> = Infer<N> | (ParentAbsent extends true ? undefined : never);
173
190
  type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown, Absent extends boolean = false> = { readonly [K in keyof S]: PathValue<S[K], Absent> } & PathMarker<TValue | (Absent extends true ? undefined : never)>;
174
- type SchemaPath<S extends ObjectShape = ObjectShape> = SchemaPathFor<S, ShapeValue<S>>;
175
- type PathPick<S extends ObjectNode = ObjectNode> = (path: SchemaPath<S['shape']>) => PathMarker<unknown>;
191
+ type SchemaPath<S extends ObjectSchema<object> = ObjectSchema<object>> = RootNodeOf<S> extends ObjectNode<infer Shape> ? SchemaPathFor<Shape, Infer<S>> : never;
192
+ type PathPick<S extends ObjectSchema<object> = ObjectSchema<object>> = (path: SchemaPath<S>) => PathMarker<unknown>;
176
193
  type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
177
194
  type VariantFieldMissing<V extends VariantShape, K extends string> = { [P in keyof V & string]: V[P] extends ObjectNode<infer S> ? (K extends keyof S ? never : P) : P }[keyof V & string] extends never ? false : true;
178
195
  type VariantFieldPath<V extends VariantShape, K extends string, Absent extends boolean> = { [P in keyof V & string]: V[P] extends ObjectNode<infer S> ? K extends keyof S ? PathValue<S[K], Or<Absent, VariantFieldMissing<V, K>>> : never : never }[keyof V & string];
@@ -201,19 +218,18 @@ type CollectionId<T> = CollectionInfo<T> extends {
201
218
  type CollectionEntry<T> = CollectionInfo<T> extends {
202
219
  readonly entry: infer TEntry;
203
220
  } ? TEntry : unknown;
204
- declare const field: <T>(validator?: Validator<T>) => FieldNode<T>;
205
- type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown, false> | TreeNode<unknown, true>;
206
- declare const optional: <T extends OptionalLeaf>(value: T) => OptionalNode<T>;
207
- declare const object: <S extends ObjectShape>(shape: S) => ObjectNode<S>;
208
- declare const variant: <T extends string, V extends VariantShape>(tag: T, variants: V) => VariantNode<T, V>;
209
- declare const table: <V extends EntitySchemaNode, K extends string = string>(value: V, options?: {
210
- readonly key: Validator<K>;
211
- }) => TableNode<V, K>;
212
- declare const map: <V extends ValueSchemaNode, K extends string = string>(value: V, options?: {
213
- readonly key: Validator<K>;
214
- }) => MapNode<V, K>;
215
- declare const list: <TItem>(value: FieldNode<TItem, false>, config: DocumentListConfig<TItem>) => ListNode<TItem>;
216
- declare const tree: <TValue, ValueOptional extends boolean>(value: FieldNode<TValue, ValueOptional>) => TreeNode<TValue, ValueOptional>;
221
+ //#endregion
222
+ //#region core/src/schema/value.d.ts
223
+ type ParseIssue = {
224
+ readonly address: DocumentAddress;
225
+ readonly code: 'invalid-value' | 'invalid-key' | 'missing-validator' | 'invalid-tree';
226
+ readonly message: string;
227
+ };
228
+ declare class ParseError extends TypeError {
229
+ readonly issues: readonly ParseIssue[];
230
+ constructor(issue: ParseIssue);
231
+ }
232
+ declare const parse: <S extends Schema<unknown>>(schema: S, input: unknown) => Infer<S>;
217
233
  //#endregion
218
234
  //#region core/src/changes.d.ts
219
235
  type ValueTransition<T = unknown> = {
@@ -256,24 +272,12 @@ type ChangeSet = {
256
272
  readonly changes: readonly Change[];
257
273
  };
258
274
  //#endregion
259
- //#region core/src/mutation/tree.d.ts
275
+ //#region core/src/tree/topology.d.ts
260
276
  type TreePosition = {
261
277
  readonly parentId?: string;
262
278
  readonly index?: number;
263
279
  };
264
280
  //#endregion
265
- //#region core/src/address.d.ts
266
- /** The only resolved address representation used inside the runtime. */
267
- type AddressRef = {
268
- readonly path: number;
269
- readonly address: DocumentAddress;
270
- };
271
- declare const resolveAddress: (schema: ObjectNode, address: DocumentAddress, document?: unknown) => AddressRef | undefined;
272
- declare const read: (root: unknown, address: DocumentAddress, schema: DocumentNode) => unknown;
273
- declare const contains: (parent: DocumentAddress, child: DocumentAddress) => boolean;
274
- declare const overlaps: (a: DocumentAddress, b: DocumentAddress) => boolean;
275
- declare const debugKey: (address: DocumentAddress) => string;
276
- //#endregion
277
281
  //#region core/src/access/scope.d.ts
278
282
  declare const scopeValue: unique symbol;
279
283
  type Scoped<N extends DocumentNode, W extends boolean, V = Infer<N>> = {
@@ -337,8 +341,9 @@ type NodeAccess<N extends DocumentNode, W extends boolean> = N extends FieldNode
337
341
  type Access<N extends DocumentNode, W extends boolean> = N extends {
338
342
  readonly optional: true;
339
343
  } ? NodeAccess<N, W> | undefined : NodeAccess<N, W>;
340
- type Read<N extends DocumentNode> = Access<N, false>;
341
- type Draft<N extends DocumentNode> = Access<N, true>;
344
+ type AccessNode<S extends Schema<unknown> | DocumentNode> = S extends Schema<unknown> ? SchemaNodeOf<S> : Extract<S, DocumentNode>;
345
+ type Read<S extends Schema<unknown> | DocumentNode> = Access<AccessNode<S>, false>;
346
+ type Draft<S extends Schema<unknown> | DocumentNode> = Access<AccessNode<S>, true>;
342
347
  type Snapshot<T> = T extends {
343
348
  readonly [scopeValue]?: readonly [DocumentNode, boolean, infer V];
344
349
  } ? V : ReadonlyValue<T>;
@@ -361,10 +366,10 @@ type CollectionImpact<K> = {
361
366
  readonly updated: ReadonlySet<K>;
362
367
  readonly orderChanged: boolean;
363
368
  };
364
- type DocumentImpact<S extends ObjectNode> = {
369
+ type DocumentImpact<S extends ObjectSchema<object>> = {
365
370
  readonly kind: 'incremental' | 'reset';
366
371
  affects(pick: PathPick<S>): boolean;
367
- collection<P extends CollectionPath>(pick: (path: SchemaPath<S['shape']>) => P): CollectionImpact<CollectionId<P>>;
372
+ collection<P extends CollectionPath>(pick: (path: SchemaPath<S>) => P): CollectionImpact<CollectionId<P>>;
368
373
  };
369
374
  //#endregion
370
375
  //#region core/src/mutation/issue.d.ts
@@ -376,7 +381,8 @@ type MutationIssue = {
376
381
  readonly message: string;
377
382
  };
378
383
  //#endregion
379
- //#region core/src/projection/readable.d.ts
384
+ //#region core/src/readable.d.ts
385
+ type Unsubscribe = () => void;
380
386
  type Readable<TValue> = {
381
387
  current(): TValue;
382
388
  revision(): number;
@@ -384,7 +390,6 @@ type Readable<TValue> = {
384
390
  };
385
391
  //#endregion
386
392
  //#region core/src/runtime/contract.d.ts
387
- type Unsubscribe = () => void;
388
393
  type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
389
394
  type CommitSource = 'local' | 'system' | 'history' | 'remote';
390
395
  declare class DocumentReentrancyError extends Error {
@@ -406,7 +411,7 @@ declare class TransactionRejected extends Error {
406
411
  readonly issues: readonly DocumentDiagnostic[];
407
412
  constructor(input: DiagnosticInput | readonly DiagnosticInput[]);
408
413
  }
409
- type DocumentCommit<S extends ObjectNode> = {
414
+ type DocumentCommit<S extends ObjectSchema<object>> = {
410
415
  readonly revision: number;
411
416
  readonly source: CommitSource;
412
417
  readonly changes: ChangeSet;
@@ -455,29 +460,27 @@ type LocalHistory<C> = Readable<HistoryState> & {
455
460
  cancel(): OperationResult<C>;
456
461
  };
457
462
  };
458
- type CommitListener<S extends ObjectNode> = (commit: DocumentCommit<S>) => void;
459
- type DocumentReadable<S extends ObjectNode> = {
460
- readonly address: {
461
- resolve(address: DocumentAddress): AddressRef | undefined;
462
- read(address: DocumentAddress): unknown;
463
- contains(parent: DocumentAddress, child: DocumentAddress): boolean;
464
- overlaps(left: DocumentAddress, right: DocumentAddress): boolean;
465
- debugKey(address: DocumentAddress): string;
466
- };
463
+ type CommitListener<S extends ObjectSchema<object>> = (commit: DocumentCommit<S>) => void;
464
+ type ReadonlyDocument<S extends ObjectSchema<object>> = {
467
465
  revision(): number;
468
466
  subscribe(listener: CommitListener<S>): Unsubscribe;
469
467
  subscribe(pick: PathPick<S> | readonly [PathPick<S>, ...PathPick<S>[]], listener: CommitListener<S>): Unsubscribe;
470
468
  };
471
- type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
469
+ type DocumentRuntime<S extends ObjectSchema<object>> = ReadonlyDocument<S> & {
472
470
  readonly schema: S;
471
+ readonly(): ReadonlyDocument<S>;
473
472
  update<V>(run: (draft: Draft<S>) => Synchronous<V>, options?: {
474
473
  readonly source?: Extract<CommitSource, 'local' | 'system'>;
475
474
  readonly history?: boolean;
476
475
  }): TransactionResult<V, DocumentCommit<S>>;
477
476
  apply(changes: unknown, options: {
478
477
  readonly expectedRevision: number;
479
- readonly source?: Exclude<CommitSource, 'history'>;
478
+ readonly source?: Extract<CommitSource, 'local' | 'system'>;
480
479
  readonly history?: boolean;
480
+ } | {
481
+ readonly expectedRevision: number;
482
+ readonly source: 'remote';
483
+ readonly history?: never;
481
484
  }): OperationResult<DocumentCommit<S>>;
482
485
  replace(value: Infer<S>, options?: {
483
486
  readonly source?: Extract<CommitSource, 'system' | 'remote'>;
@@ -487,5 +490,5 @@ type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
487
490
  dispose(): void;
488
491
  };
489
492
  //#endregion
490
- export { OptionalNode as $, overlaps as A, DocumentAddress as B, Draft as C, AddressRef as D, snapshot as E, MemberChange as F, DocumentTreeValue as G, DocumentListConfig as H, ValueTransition as I, Infer as J, FieldNode as K, CollectionEntry as L, resolveAddress as M, Change as N, contains as O, ChangeSet as P, ObjectShape as Q, CollectionId as R, DocumentImpact as S, replace as T, DocumentNode as U, DocumentAnchor as V, DocumentTreeNode as W, MapNode as X, ListNode as Y, ObjectNode as Z, Unsubscribe as _, Validator as _t, DocumentDisposedError as a, VariantNode as at, MutationIssueCode as b, DocumentReentrancyError as c, list as ct, LocalHistory as d, optional as dt, PathValueOf as et, ObserverError as f, table as ft, TransactionResult as g, ParseIssue as gt, TransactionRejected as h, ParseError as ht, DocumentDiagnostic as i, TreeNode as it, read as j, debugKey as k, DocumentRuntime as l, map as lt, Synchronous as m, variant as mt, CommitSource as n, SchemaPath as nt, DocumentProblem as o, VariantShape as ot, OperationResult as p, tree as pt, ImpactTarget as q, DocumentCommit as r, TableNode as rt, DocumentReadable as s, field as st, CommitListener as t, ReadonlyValue as tt, HistoryState as u, object as ut, Readable as v, parse as vt, Read as w, CollectionImpact as x, MutationIssue as y, CollectionPath as z };
491
- //# sourceMappingURL=contract-CxiNcqMn.d.ts.map
493
+ export { table as $, ParseError as A, DocumentListConfig as B, Read as C, ChangeSet as D, Change as E, CollectionPath as F, ReadonlyValue as G, DocumentTreeValue as H, PathValueOf as I, field as J, Schema as K, SchemaPath as L, parse as M, CollectionEntry as N, MemberChange as O, CollectionId as P, optional as Q, DocumentAddress as R, Draft as S, snapshot as T, Infer as U, DocumentTreeNode as V, ObjectSchema as W, map as X, list as Y, object as Z, Unsubscribe as _, DocumentProblem as a, CollectionImpact as b, HistoryState as c, OperationResult as d, tree as et, ReadonlyDocument as f, Readable as g, TransactionResult as h, DocumentDisposedError as i, ParseIssue as j, ValueTransition as k, LocalHistory as l, TransactionRejected as m, DocumentCommit as n, DocumentReentrancyError as o, Synchronous as p, Validator as q, DocumentDiagnostic as r, DocumentRuntime as s, CommitSource as t, variant as tt, ObserverError as u, MutationIssue as v, replace as w, DocumentImpact as x, MutationIssueCode as y, DocumentAnchor as z };
494
+ //# sourceMappingURL=contract-Dawq6LKS.d.ts.map
@@ -0,0 +1,110 @@
1
+ import { _ as Unsubscribe, b as CollectionImpact } from "./contract-DB8XvNt0.cjs";
2
+
3
+ //#region core/src/projection/contract.d.ts
4
+ /** The one processor-facing collection transition protocol. */
5
+ type CollectionChange<K extends string, V> = {
6
+ readonly kind: 'reset';
7
+ } | {
8
+ readonly kind: 'incremental';
9
+ readonly added: readonly {
10
+ readonly key: K;
11
+ readonly after: V;
12
+ }[];
13
+ readonly updated: readonly {
14
+ readonly key: K;
15
+ readonly before: V;
16
+ readonly after: V;
17
+ }[];
18
+ readonly removed: readonly {
19
+ readonly key: K;
20
+ readonly before: V;
21
+ }[];
22
+ readonly order?: {
23
+ readonly before: readonly K[];
24
+ readonly after: readonly K[];
25
+ };
26
+ };
27
+ type CollectionRead<K extends string, V> = {
28
+ get(key: K): V | undefined;
29
+ has(key: K): boolean;
30
+ ids(): readonly K[];
31
+ };
32
+ type ExternalCollectionRead<K extends string, V> = {
33
+ readonly get: (key: K) => V | undefined;
34
+ readonly has: (key: K) => boolean;
35
+ readonly ids: () => readonly K[];
36
+ };
37
+ type ExternalValueSource<T> = {
38
+ readonly kind: 'value';
39
+ current(): T;
40
+ revision(): number;
41
+ subscribe(listener: (event: ExternalValueEvent<T>) => void): Unsubscribe;
42
+ };
43
+ type ExternalCollectionSource<K extends string, V> = {
44
+ readonly kind: 'collection';
45
+ current(): ExternalCollectionRead<K, V>;
46
+ revision(): number;
47
+ subscribe(listener: (event: ExternalCollectionEvent<K, V>) => void): Unsubscribe;
48
+ };
49
+ type ExternalValueEvent<T> = {
50
+ readonly value: T;
51
+ readonly revision: number;
52
+ readonly reset?: boolean;
53
+ readonly cause?: unknown;
54
+ };
55
+ type ExternalCollectionEvent<K extends string, V> = {
56
+ /** Stable read from the source before this event or external batch. */readonly previous: ExternalCollectionRead<K, V>;
57
+ readonly revision: number; /** Optional document-style hint; the adapter resolves the canonical change. */
58
+ readonly impact?: CollectionImpact<K>;
59
+ readonly cause?: unknown;
60
+ };
61
+ type CollectionDraft<K extends string, V> = {
62
+ set(key: K, value: V): void;
63
+ remove(key: K): void;
64
+ order(ids: readonly K[]): void;
65
+ };
66
+ declare class ProjectionError extends Error {
67
+ readonly phase: 'processor' | 'listener' | 'source' | 'blocked';
68
+ readonly cause: unknown;
69
+ constructor(phase: 'processor' | 'listener' | 'source' | 'blocked', cause: unknown);
70
+ }
71
+ declare class ProjectionDisposedError extends Error {
72
+ constructor();
73
+ }
74
+ //#endregion
75
+ //#region core/src/projection/definition.d.ts
76
+ declare const projectionDefinition: unique symbol;
77
+ declare const projectionChanges: unique symbol;
78
+ declare const writableInput: unique symbol;
79
+ declare const writableCollectionInput: unique symbol;
80
+ /** A lazy output reference with no materialized Runtime state. */
81
+ type Projection<T> = {
82
+ readonly [projectionDefinition]: T;
83
+ };
84
+ /** A writable source projection. */
85
+ type Input<T> = Projection<T> & {
86
+ readonly [writableInput]: true;
87
+ };
88
+ /** A writable keyed collection source projection. */
89
+ type CollectionInput<K extends string, V> = Projection<ReadonlyMap<K, V>> & {
90
+ readonly [writableCollectionInput]: {
91
+ readonly key: K;
92
+ readonly value: V;
93
+ };
94
+ readonly [projectionChanges]: CollectionChange<K, V>;
95
+ };
96
+ type CollectionInputDraft<K extends string, V> = {
97
+ get(key: K): V | undefined;
98
+ has(key: K): boolean;
99
+ set(key: K, value: V): void;
100
+ remove(key: K): void;
101
+ };
102
+ type ProjectionWithChange<T, C> = Projection<T> & {
103
+ readonly [projectionChanges]: C;
104
+ };
105
+ type ProjectionChange<P> = P extends {
106
+ readonly [projectionChanges]: infer C;
107
+ } ? C : undefined;
108
+ //#endregion
109
+ export { ProjectionChange as a, CollectionDraft as c, ExternalCollectionRead as d, ExternalCollectionSource as f, ProjectionError as g, ProjectionDisposedError as h, Projection as i, CollectionRead as l, ExternalValueSource as m, CollectionInputDraft as n, ProjectionWithChange as o, ExternalValueEvent as p, Input as r, CollectionChange as s, CollectionInput as t, ExternalCollectionEvent as u };
110
+ //# sourceMappingURL=definition-CHVS-RDY.d.cts.map
@@ -0,0 +1,110 @@
1
+ import { _ as Unsubscribe, b as CollectionImpact } from "./contract-Dawq6LKS.js";
2
+
3
+ //#region core/src/projection/contract.d.ts
4
+ /** The one processor-facing collection transition protocol. */
5
+ type CollectionChange<K extends string, V> = {
6
+ readonly kind: 'reset';
7
+ } | {
8
+ readonly kind: 'incremental';
9
+ readonly added: readonly {
10
+ readonly key: K;
11
+ readonly after: V;
12
+ }[];
13
+ readonly updated: readonly {
14
+ readonly key: K;
15
+ readonly before: V;
16
+ readonly after: V;
17
+ }[];
18
+ readonly removed: readonly {
19
+ readonly key: K;
20
+ readonly before: V;
21
+ }[];
22
+ readonly order?: {
23
+ readonly before: readonly K[];
24
+ readonly after: readonly K[];
25
+ };
26
+ };
27
+ type CollectionRead<K extends string, V> = {
28
+ get(key: K): V | undefined;
29
+ has(key: K): boolean;
30
+ ids(): readonly K[];
31
+ };
32
+ type ExternalCollectionRead<K extends string, V> = {
33
+ readonly get: (key: K) => V | undefined;
34
+ readonly has: (key: K) => boolean;
35
+ readonly ids: () => readonly K[];
36
+ };
37
+ type ExternalValueSource<T> = {
38
+ readonly kind: 'value';
39
+ current(): T;
40
+ revision(): number;
41
+ subscribe(listener: (event: ExternalValueEvent<T>) => void): Unsubscribe;
42
+ };
43
+ type ExternalCollectionSource<K extends string, V> = {
44
+ readonly kind: 'collection';
45
+ current(): ExternalCollectionRead<K, V>;
46
+ revision(): number;
47
+ subscribe(listener: (event: ExternalCollectionEvent<K, V>) => void): Unsubscribe;
48
+ };
49
+ type ExternalValueEvent<T> = {
50
+ readonly value: T;
51
+ readonly revision: number;
52
+ readonly reset?: boolean;
53
+ readonly cause?: unknown;
54
+ };
55
+ type ExternalCollectionEvent<K extends string, V> = {
56
+ /** Stable read from the source before this event or external batch. */readonly previous: ExternalCollectionRead<K, V>;
57
+ readonly revision: number; /** Optional document-style hint; the adapter resolves the canonical change. */
58
+ readonly impact?: CollectionImpact<K>;
59
+ readonly cause?: unknown;
60
+ };
61
+ type CollectionDraft<K extends string, V> = {
62
+ set(key: K, value: V): void;
63
+ remove(key: K): void;
64
+ order(ids: readonly K[]): void;
65
+ };
66
+ declare class ProjectionError extends Error {
67
+ readonly phase: 'processor' | 'listener' | 'source' | 'blocked';
68
+ readonly cause: unknown;
69
+ constructor(phase: 'processor' | 'listener' | 'source' | 'blocked', cause: unknown);
70
+ }
71
+ declare class ProjectionDisposedError extends Error {
72
+ constructor();
73
+ }
74
+ //#endregion
75
+ //#region core/src/projection/definition.d.ts
76
+ declare const projectionDefinition: unique symbol;
77
+ declare const projectionChanges: unique symbol;
78
+ declare const writableInput: unique symbol;
79
+ declare const writableCollectionInput: unique symbol;
80
+ /** A lazy output reference with no materialized Runtime state. */
81
+ type Projection<T> = {
82
+ readonly [projectionDefinition]: T;
83
+ };
84
+ /** A writable source projection. */
85
+ type Input<T> = Projection<T> & {
86
+ readonly [writableInput]: true;
87
+ };
88
+ /** A writable keyed collection source projection. */
89
+ type CollectionInput<K extends string, V> = Projection<ReadonlyMap<K, V>> & {
90
+ readonly [writableCollectionInput]: {
91
+ readonly key: K;
92
+ readonly value: V;
93
+ };
94
+ readonly [projectionChanges]: CollectionChange<K, V>;
95
+ };
96
+ type CollectionInputDraft<K extends string, V> = {
97
+ get(key: K): V | undefined;
98
+ has(key: K): boolean;
99
+ set(key: K, value: V): void;
100
+ remove(key: K): void;
101
+ };
102
+ type ProjectionWithChange<T, C> = Projection<T> & {
103
+ readonly [projectionChanges]: C;
104
+ };
105
+ type ProjectionChange<P> = P extends {
106
+ readonly [projectionChanges]: infer C;
107
+ } ? C : undefined;
108
+ //#endregion
109
+ export { ProjectionChange as a, CollectionDraft as c, ExternalCollectionRead as d, ExternalCollectionSource as f, ProjectionError as g, ProjectionDisposedError as h, Projection as i, CollectionRead as l, ExternalValueSource as m, CollectionInputDraft as n, ProjectionWithChange as o, ExternalValueEvent as p, Input as r, CollectionChange as s, CollectionInput as t, ExternalCollectionEvent as u };
110
+ //# sourceMappingURL=definition-DT1NpMul.d.ts.map