doxum 0.1.21 → 0.1.23

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 (72) hide show
  1. package/README.md +35 -7
  2. package/dist/{advanced-FgdTwu5b.d.ts → advanced-CLJCWkHa.d.cts} +3 -3
  3. package/dist/{advanced-COFJtWMT.js → advanced-CRNHfJBu.js} +482 -446
  4. package/dist/advanced-CRNHfJBu.js.map +1 -0
  5. package/dist/{advanced-BRL5pN0y.cjs → advanced-Cle5g3B4.cjs} +615 -459
  6. package/dist/advanced-Cle5g3B4.cjs.map +1 -0
  7. package/dist/{advanced-DfKc7TZR.d.cts → advanced-d6J61er9.d.ts} +3 -3
  8. package/dist/advanced.cjs +1 -1
  9. package/dist/advanced.d.cts +1 -1
  10. package/dist/advanced.d.ts +1 -1
  11. package/dist/advanced.js +1 -1
  12. package/dist/context-BcLKGfq8.cjs +149 -0
  13. package/dist/context-BcLKGfq8.cjs.map +1 -0
  14. package/dist/context-DFEaDUv5.js +84 -0
  15. package/dist/context-DFEaDUv5.js.map +1 -0
  16. package/dist/{contract-CdmDHRUq.d.cts → contract-SYJFP0lM.d.cts} +62 -88
  17. package/dist/{contract-KG5XnQZt.d.ts → contract-ULPQmiEs.d.ts} +62 -88
  18. package/dist/driver-BD3DQOW6.cjs +382 -0
  19. package/dist/driver-BD3DQOW6.cjs.map +1 -0
  20. package/dist/{driver-CLYJOGDQ.js → driver-yFfvDMX5.js} +155 -26
  21. package/dist/driver-yFfvDMX5.js.map +1 -0
  22. package/dist/index.cjs +2370 -406
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +6 -5
  25. package/dist/index.d.ts +6 -5
  26. package/dist/index.js +2293 -330
  27. package/dist/index.js.map +1 -1
  28. package/dist/local-sync.cjs +5 -5
  29. package/dist/local-sync.cjs.map +1 -1
  30. package/dist/local-sync.d.cts +1 -1
  31. package/dist/local-sync.d.ts +1 -1
  32. package/dist/local-sync.js +2 -2
  33. package/dist/local-sync.js.map +1 -1
  34. package/dist/react.cjs +2 -69
  35. package/dist/react.cjs.map +1 -1
  36. package/dist/react.d.cts +0 -1
  37. package/dist/react.d.ts +1 -2
  38. package/dist/react.js +3 -70
  39. package/dist/react.js.map +1 -1
  40. package/package.json +1 -6
  41. package/skills/doxum-runtime/SKILL.md +7 -1
  42. package/skills/doxum-runtime/references/guide.en.md +17 -6
  43. package/skills/doxum-runtime/references/guide.zh-CN.md +15 -5
  44. package/skills/doxum-runtime/references/invariants.en.md +5 -3
  45. package/skills/doxum-runtime/references/invariants.zh-CN.md +4 -3
  46. package/skills/doxum-runtime/references/projections.en.md +5 -0
  47. package/skills/doxum-runtime/references/projections.zh-CN.md +5 -0
  48. package/dist/access-BeSV5ve-.js +0 -816
  49. package/dist/access-BeSV5ve-.js.map +0 -1
  50. package/dist/access-Bienf28h.cjs +0 -911
  51. package/dist/access-Bienf28h.cjs.map +0 -1
  52. package/dist/advanced-BRL5pN0y.cjs.map +0 -1
  53. package/dist/advanced-COFJtWMT.js.map +0 -1
  54. package/dist/driver-CLYJOGDQ.js.map +0 -1
  55. package/dist/driver-Djr3BVvo.cjs +0 -241
  56. package/dist/driver-Djr3BVvo.cjs.map +0 -1
  57. package/dist/integration-C4Isp8lJ.js +0 -26
  58. package/dist/integration-C4Isp8lJ.js.map +0 -1
  59. package/dist/integration-Z6MsfFI7.cjs +0 -31
  60. package/dist/integration-Z6MsfFI7.cjs.map +0 -1
  61. package/dist/integration.cjs +0 -12
  62. package/dist/integration.d.cts +0 -17
  63. package/dist/integration.d.ts +0 -17
  64. package/dist/integration.js +0 -4
  65. package/dist/issue-DjK1xp5K.cjs +0 -881
  66. package/dist/issue-DjK1xp5K.cjs.map +0 -1
  67. package/dist/issue-W0hT8u8D.js +0 -642
  68. package/dist/issue-W0hT8u8D.js.map +0 -1
  69. package/dist/notification-Bkjau6B6.js +0 -232
  70. package/dist/notification-Bkjau6B6.js.map +0 -1
  71. package/dist/notification-DJfouMEb.cjs +0 -309
  72. package/dist/notification-DJfouMEb.cjs.map +0 -1
@@ -1,4 +1,5 @@
1
- //#region core/src/schema-value.d.ts
1
+ //#region core/src/schema.d.ts
2
+ type DocumentAddress = readonly string[];
2
3
  /** Pure synchronous validation. Successful output is ignored; input is never transformed. */
3
4
  type Validator<T> = ((value: unknown) => T) | {
4
5
  readonly '~standard': {
@@ -21,32 +22,22 @@ 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> = {
40
28
  readonly keyOf: (item: ReadonlyValue<TItem>) => string;
41
29
  };
42
- type DocumentTreeNode<TValue> = {
30
+ type DocumentTreeNode<TValue, ValueOptional extends boolean = false> = {
43
31
  readonly parentId?: string;
44
32
  readonly children: readonly string[];
33
+ } & (ValueOptional extends true ? {
45
34
  readonly value?: ReadonlyValue<TValue>;
46
- };
47
- type DocumentTreeValue<TValue> = {
35
+ } : {
36
+ readonly value: ReadonlyValue<TValue>;
37
+ });
38
+ type DocumentTreeValue<TValue, ValueOptional extends boolean = false> = {
48
39
  readonly rootId?: string;
49
- readonly nodes: Readonly<Record<string, DocumentTreeNode<TValue>>>;
40
+ readonly nodes: Readonly<Record<string, DocumentTreeNode<TValue, ValueOptional>>>;
50
41
  };
51
42
  type BaseNode<K extends string> = {
52
43
  readonly kind: K;
@@ -89,10 +80,10 @@ type ListNode<TItem> = BaseNode<'list'> & {
89
80
  readonly value: FieldNode<TItem, false>;
90
81
  keyOf(item: ReadonlyValue<TItem>): string;
91
82
  };
92
- type TreeNode<TValue> = BaseNode<'tree'> & {
93
- readonly value: FieldNode<TValue, boolean>;
83
+ type TreeNode<TValue, ValueOptional extends boolean = false> = BaseNode<'tree'> & {
84
+ readonly value: FieldNode<TValue, ValueOptional>;
94
85
  };
95
- 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>;
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>;
96
87
  type SchemaObject<T> = { [K in keyof T]: T[K] } & {};
97
88
  /** Infer a document or node value, including optional node presence. */
98
89
  type Infer<T extends DocumentNode> = T extends {
@@ -101,7 +92,7 @@ type Infer<T extends DocumentNode> = T extends {
101
92
  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> ? {
102
93
  readonly ids: readonly K[];
103
94
  readonly byId: Readonly<Record<K, NodeValue<V>>>;
104
- } : N extends MapNode<infer V, infer K> ? Readonly<Record<K, NodeValue<V>>> : N extends ListNode<infer I> ? readonly ReadonlyValue<I>[] : N extends TreeNode<infer T> ? DocumentTreeValue<T> : never;
95
+ } : N extends MapNode<infer V, infer K> ? Readonly<Record<K, NodeValue<V>>> : N extends ListNode<infer I> ? readonly ReadonlyValue<I>[] : N extends TreeNode<infer T, infer O> ? DocumentTreeValue<T, O> : never;
105
96
  type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
106
97
  readonly optional: true;
107
98
  } ? K : never }[keyof S];
@@ -116,29 +107,8 @@ type DocumentAnchor<K extends string = string> = {
116
107
  } | {
117
108
  readonly after: K;
118
109
  };
119
- type CollectionSelector<TId extends string = string, TNode extends ValueSchemaNode = ValueSchemaNode> = {
120
- readonly kind: 'collection';
121
- readonly schema: ObjectNode;
122
- readonly address: DocumentAddress;
123
- readonly __id?: TId; /** Compile-time entry schema carried by schema selectors. */
124
- readonly __node?: TNode;
125
- };
126
- type ValueSelector<TResult = unknown> = {
127
- readonly kind: 'value';
128
- readonly schema: ObjectNode;
129
- readonly address: DocumentAddress;
130
- readonly __value?: TResult;
131
- };
132
- type ImpactTarget<T = unknown> = {
133
- readonly kind: 'value';
134
- readonly at: DocumentAddress;
135
- } | ValueSelector<T> | {
136
- readonly kind: 'collection';
137
- readonly at: DocumentAddress;
138
- readonly id?: string;
139
- } | CollectionSelector<string>;
140
110
  declare const pathValue: unique symbol;
141
- declare const collectionNode: unique symbol;
111
+ declare const collectionEntry: unique symbol;
142
112
  declare const collectionKey: unique symbol;
143
113
  type PathMarker<TValue> = {
144
114
  readonly [pathValue]: TValue;
@@ -146,33 +116,44 @@ type PathMarker<TValue> = {
146
116
  type PathValueOf<T> = T extends {
147
117
  readonly [pathValue]: infer TValue;
148
118
  } ? TValue : never;
149
- type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } & PathMarker<TValue>;
119
+ type Or<A extends boolean, B extends boolean> = A extends true ? true : B;
120
+ type NodeAbsent<N extends DocumentNode, ParentAbsent extends boolean> = Or<ParentAbsent, N extends {
121
+ readonly optional: true;
122
+ } ? true : false>;
123
+ type PathResult<N extends DocumentNode, ParentAbsent extends boolean> = Infer<N> | (ParentAbsent extends true ? undefined : never);
124
+ 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)>;
150
125
  type SchemaPath<S extends ObjectShape = ObjectShape> = SchemaPathFor<S, ShapeValue<S>>;
151
126
  type PathPick<S extends ObjectNode = ObjectNode> = (path: SchemaPath<S['shape']>) => PathMarker<unknown>;
152
127
  type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
153
- type VariantFieldPath<V extends VariantShape, K extends string> = { [P in keyof V & string]: V[P] extends ObjectNode<infer S> ? K extends keyof S ? PathValue<S[K]> : never : never }[keyof V & string];
154
- type VariantPath<T extends string, V extends VariantShape, TValue> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K> } & { readonly [K in T]: PathMarker<keyof V & string> } & PathMarker<TValue>;
155
- type CollectionPath<N extends ValueSchemaNode = ValueSchemaNode, TValue = unknown, K extends string = string> = PathMarker<TValue> & {
156
- item(id: K): PathValue<N>;
157
- readonly [collectionNode]: N;
128
+ 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;
129
+ 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];
130
+ type VariantPath<T extends string, V extends VariantShape, TValue, Absent extends boolean> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K, Absent> } & { readonly [K in T]: PathMarker<(keyof V & string) | (Absent extends true ? undefined : never)> } & PathMarker<TValue>;
131
+ type CollectionPath<K extends string = string, TValue = unknown, TEntry = unknown, TItem = PathMarker<TEntry | undefined>> = PathMarker<TValue> & {
132
+ item(id: K): TItem;
133
+ readonly [collectionEntry]: TEntry;
158
134
  readonly [collectionKey]: K;
159
135
  };
160
- type PathValue<N extends DocumentNode> = N extends ObjectNode<infer S> ? SchemaPathFor<S, Infer<N>> : N extends VariantNode<infer TTag, infer V> ? VariantPath<TTag, V, Infer<N>> : N extends TableNode<infer V, infer K> ? CollectionPath<V, Infer<N>, K> : N extends MapNode<infer V, infer K> ? CollectionPath<V, Infer<N>, K> : N extends ListNode<infer I> ? CollectionPath<FieldNode<I, false>, Infer<N>, string> : PathMarker<Infer<N>>;
136
+ type TreeNodesPath<TValue, ValueOptional extends boolean> = CollectionPath<string, Readonly<Record<string, DocumentTreeNode<TValue, ValueOptional>>>, DocumentTreeNode<TValue, ValueOptional>, PathMarker<DocumentTreeNode<TValue, ValueOptional> | undefined>>;
137
+ type TreePath<TValue, ValueOptional extends boolean, TValueResult> = PathMarker<TValueResult> & {
138
+ readonly rootId: PathMarker<string | undefined>;
139
+ readonly nodes: TreeNodesPath<TValue, ValueOptional>;
140
+ };
141
+ type PathValue<N extends DocumentNode, ParentAbsent extends boolean = false> = N extends ObjectNode<infer S> ? SchemaPathFor<S, PathResult<N, ParentAbsent>, NodeAbsent<N, ParentAbsent>> : N extends VariantNode<infer TTag, infer V> ? VariantPath<TTag, V, PathResult<N, ParentAbsent>, NodeAbsent<N, ParentAbsent>> : N extends TableNode<infer V, infer K> ? CollectionPath<K, PathResult<N, ParentAbsent>, Infer<V>, PathValue<V, true>> : N extends MapNode<infer V, infer K> ? CollectionPath<K, PathResult<N, ParentAbsent>, Infer<V>, PathValue<V, true>> : N extends ListNode<infer I> ? CollectionPath<string, PathResult<N, ParentAbsent>, ReadonlyValue<I>, PathMarker<ReadonlyValue<I> | undefined>> : N extends TreeNode<infer T, infer O> ? TreePath<T, O, PathResult<N, ParentAbsent>> : PathMarker<PathResult<N, ParentAbsent>>;
161
142
  type CollectionInfo<T> = T extends {
162
- readonly [collectionNode]: infer TNode extends ValueSchemaNode;
143
+ readonly [collectionEntry]: infer TEntry;
163
144
  readonly [collectionKey]: infer K extends string;
164
145
  } ? {
165
146
  readonly id: K;
166
- readonly node: TNode;
147
+ readonly entry: TEntry;
167
148
  } : never;
168
149
  type CollectionId<T> = CollectionInfo<T> extends {
169
150
  readonly id: infer TId extends string;
170
151
  } ? TId : string;
171
- type CollectionNode<T> = CollectionInfo<T> extends {
172
- readonly node: infer TNode extends ValueSchemaNode;
173
- } ? TNode : ValueSchemaNode;
152
+ type CollectionEntry<T> = CollectionInfo<T> extends {
153
+ readonly entry: infer TEntry;
154
+ } ? TEntry : unknown;
174
155
  declare const field: <T>(validator?: Validator<T>) => FieldNode<T>;
175
- type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown>;
156
+ type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown, false> | TreeNode<unknown, true>;
176
157
  declare const optional: <T extends OptionalLeaf>(value: T) => OptionalNode<T>;
177
158
  declare const object: <S extends ObjectShape>(shape: S) => ObjectNode<S>;
178
159
  declare const variant: <T extends string, V extends VariantShape>(tag: T, variants: V) => VariantNode<T, V>;
@@ -183,7 +164,19 @@ declare const map: <V extends ValueSchemaNode, K extends string = string>(value:
183
164
  readonly key: Validator<K>;
184
165
  }) => MapNode<V, K>;
185
166
  declare const list: <TItem>(value: FieldNode<TItem, false>, config: DocumentListConfig<TItem>) => ListNode<TItem>;
186
- declare const tree: <TValue>(value: FieldNode<TValue, boolean>) => TreeNode<TValue>;
167
+ declare const tree: <TValue, ValueOptional extends boolean>(value: FieldNode<TValue, ValueOptional>) => TreeNode<TValue, ValueOptional>;
168
+ //#endregion
169
+ //#region core/src/schema/value.d.ts
170
+ type ParseIssue = {
171
+ readonly address: DocumentAddress;
172
+ readonly code: 'invalid-value' | 'invalid-key' | 'missing-validator' | 'invalid-tree';
173
+ readonly message: string;
174
+ };
175
+ declare class ParseError extends TypeError {
176
+ readonly issues: readonly ParseIssue[];
177
+ constructor(issue: ParseIssue);
178
+ }
179
+ declare const parse: <N extends DocumentNode>(node: N, input: unknown) => Infer<N>;
187
180
  //#endregion
188
181
  //#region core/src/changes.d.ts
189
182
  type ValueTransition<T = unknown> = {
@@ -213,7 +206,7 @@ type Change = {
213
206
  readonly at: DocumentAddress;
214
207
  readonly before: string | null;
215
208
  readonly after: string | null;
216
- readonly nodes: readonly (ValueTransition<DocumentTreeNode<unknown>> & {
209
+ readonly nodes: readonly (ValueTransition<DocumentTreeNode<unknown, false> | DocumentTreeNode<unknown, true>> & {
217
210
  readonly id: string;
218
211
  })[];
219
212
  } | {
@@ -226,24 +219,12 @@ type ChangeSet = {
226
219
  readonly changes: readonly Change[];
227
220
  };
228
221
  //#endregion
229
- //#region core/src/mutation/tree.d.ts
222
+ //#region core/src/tree/topology.d.ts
230
223
  type TreePosition = {
231
224
  readonly parentId?: string;
232
225
  readonly index?: number;
233
226
  };
234
227
  //#endregion
235
- //#region core/src/address.d.ts
236
- /** The only resolved address representation used inside the runtime. */
237
- type AddressRef = {
238
- readonly path: number;
239
- readonly address: DocumentAddress;
240
- };
241
- declare const resolveAddress: (schema: ObjectNode, address: DocumentAddress, document?: unknown) => AddressRef | undefined;
242
- declare const read: (root: unknown, address: DocumentAddress, schema: DocumentNode) => unknown;
243
- declare const contains: (parent: DocumentAddress, child: DocumentAddress) => boolean;
244
- declare const overlaps: (a: DocumentAddress, b: DocumentAddress) => boolean;
245
- declare const debugKey: (address: DocumentAddress) => string;
246
- //#endregion
247
228
  //#region core/src/access/scope.d.ts
248
229
  declare const scopeValue: unique symbol;
249
230
  type Scoped<N extends DocumentNode, W extends boolean, V = Infer<N>> = {
@@ -290,20 +271,20 @@ type ListAccess<T, W extends boolean> = {
290
271
  replace(value: readonly ReadonlyValue<T>[]): void;
291
272
  replace(key: string, value: ReadonlyValue<T>): void;
292
273
  } : {});
293
- type TreeAccess<T, W extends boolean> = {
274
+ type TreeAccess<T, O extends boolean, W extends boolean> = {
294
275
  rootId(): string | undefined;
295
276
  get(id: string): ReadonlyValue<T> | undefined;
296
277
  has(id: string): boolean;
297
278
  parent(id: string): string | undefined;
298
279
  children(id: string): readonly string[] | undefined;
299
280
  } & (W extends true ? {
300
- insert(id: string, value: ReadonlyValue<T>, position?: TreePosition): void;
281
+ insert(id: string, value: O extends true ? ReadonlyValue<T> | undefined : ReadonlyValue<T>, position?: TreePosition): void;
301
282
  move(id: string, position?: TreePosition): void;
302
283
  remove(id: string): void;
303
- replace(value: DocumentTreeValue<T>): void;
304
- replace(id: string, value: ReadonlyValue<T>): void;
284
+ replace(value: DocumentTreeValue<T, O>): void;
285
+ replace(id: string, value: O extends true ? ReadonlyValue<T> | undefined : ReadonlyValue<T>): void;
305
286
  } : {});
306
- type NodeAccess<N extends DocumentNode, W extends boolean> = N extends FieldNode<infer T, boolean> ? ReadonlyValue<T> : N extends ObjectNode<infer S> ? ShapeAccess<S, W> & Scoped<N, W> : N extends VariantNode<infer Tag, infer V> ? { [K in keyof V & string]: ShapeAccess<V[K]['shape'], W> & { readonly [P in Tag]: K } & Scoped<N, W, Extract<Infer<N>, Record<Tag, K>>> }[keyof V & string] : N extends MapNode<infer V, infer K> ? MapAccess<K, V, W> & Scoped<N, W> : N extends TableNode<infer V, infer K> ? TableAccess<K, V, W> & Scoped<N, W> : N extends ListNode<infer T> ? ListAccess<T, W> & Scoped<N, W> : N extends TreeNode<infer T> ? TreeAccess<T, W> & Scoped<N, W> : never;
287
+ type NodeAccess<N extends DocumentNode, W extends boolean> = N extends FieldNode<infer T, boolean> ? ReadonlyValue<T> : N extends ObjectNode<infer S> ? ShapeAccess<S, W> & Scoped<N, W> : N extends VariantNode<infer Tag, infer V> ? { [K in keyof V & string]: ShapeAccess<V[K]['shape'], W> & { readonly [P in Tag]: K } & Scoped<N, W, Extract<Infer<N>, Record<Tag, K>>> }[keyof V & string] : N extends MapNode<infer V, infer K> ? MapAccess<K, V, W> & Scoped<N, W> : N extends TableNode<infer V, infer K> ? TableAccess<K, V, W> & Scoped<N, W> : N extends ListNode<infer T> ? ListAccess<T, W> & Scoped<N, W> : N extends TreeNode<infer T, infer O> ? TreeAccess<T, O, W> & Scoped<N, W> : never;
307
288
  type Access<N extends DocumentNode, W extends boolean> = N extends {
308
289
  readonly optional: true;
309
290
  } ? NodeAccess<N, W> | undefined : NodeAccess<N, W>;
@@ -346,7 +327,8 @@ type MutationIssue = {
346
327
  readonly message: string;
347
328
  };
348
329
  //#endregion
349
- //#region core/src/projection/readable.d.ts
330
+ //#region core/src/readable.d.ts
331
+ type Unsubscribe = () => void;
350
332
  type Readable<TValue> = {
351
333
  current(): TValue;
352
334
  revision(): number;
@@ -354,7 +336,6 @@ type Readable<TValue> = {
354
336
  };
355
337
  //#endregion
356
338
  //#region core/src/runtime/contract.d.ts
357
- type Unsubscribe = () => void;
358
339
  type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
359
340
  type CommitSource = 'local' | 'system' | 'history' | 'remote';
360
341
  declare class DocumentReentrancyError extends Error {
@@ -427,13 +408,6 @@ type LocalHistory<C> = Readable<HistoryState> & {
427
408
  };
428
409
  type CommitListener<S extends ObjectNode> = (commit: DocumentCommit<S>) => void;
429
410
  type DocumentReadable<S extends ObjectNode> = {
430
- readonly address: {
431
- resolve(address: DocumentAddress): AddressRef | undefined;
432
- read(address: DocumentAddress): unknown;
433
- contains(parent: DocumentAddress, child: DocumentAddress): boolean;
434
- overlaps(left: DocumentAddress, right: DocumentAddress): boolean;
435
- debugKey(address: DocumentAddress): string;
436
- };
437
411
  revision(): number;
438
412
  subscribe(listener: CommitListener<S>): Unsubscribe;
439
413
  subscribe(pick: PathPick<S> | readonly [PathPick<S>, ...PathPick<S>[]], listener: CommitListener<S>): Unsubscribe;
@@ -457,5 +431,5 @@ type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
457
431
  dispose(): void;
458
432
  };
459
433
  //#endregion
460
- 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, CollectionId as L, resolveAddress as M, Change as N, contains as O, ChangeSet as P, ObjectShape as Q, CollectionNode 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 };
461
- //# sourceMappingURL=contract-CdmDHRUq.d.cts.map
434
+ export { TreeNode as $, ParseError as A, DocumentTreeNode as B, Read as C, ChangeSet as D, Change as E, CollectionPath as F, MapNode as G, FieldNode as H, DocumentAddress as I, OptionalNode as J, ObjectNode as K, DocumentAnchor as L, parse as M, CollectionEntry as N, MemberChange as O, CollectionId as P, TableNode as Q, DocumentListConfig as R, Draft as S, snapshot as T, Infer as U, DocumentTreeValue as V, ListNode as W, ReadonlyValue as X, PathValueOf as Y, SchemaPath as Z, Unsubscribe as _, DocumentProblem as a, map as at, CollectionImpact as b, DocumentRuntime as c, table as ct, ObserverError as d, Validator as et, OperationResult as f, Readable as g, TransactionResult as h, DocumentDisposedError as i, list as it, ParseIssue as j, ValueTransition as k, HistoryState as l, tree as lt, TransactionRejected as m, DocumentCommit as n, VariantShape as nt, DocumentReadable as o, object as ot, Synchronous as p, ObjectShape as q, DocumentDiagnostic as r, field as rt, DocumentReentrancyError as s, optional as st, CommitSource as t, VariantNode as tt, LocalHistory as u, variant as ut, MutationIssue as v, replace as w, DocumentImpact as x, MutationIssueCode as y, DocumentNode as z };
435
+ //# sourceMappingURL=contract-SYJFP0lM.d.cts.map
@@ -1,4 +1,5 @@
1
- //#region core/src/schema-value.d.ts
1
+ //#region core/src/schema.d.ts
2
+ type DocumentAddress = readonly string[];
2
3
  /** Pure synchronous validation. Successful output is ignored; input is never transformed. */
3
4
  type Validator<T> = ((value: unknown) => T) | {
4
5
  readonly '~standard': {
@@ -21,32 +22,22 @@ 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> = {
40
28
  readonly keyOf: (item: ReadonlyValue<TItem>) => string;
41
29
  };
42
- type DocumentTreeNode<TValue> = {
30
+ type DocumentTreeNode<TValue, ValueOptional extends boolean = false> = {
43
31
  readonly parentId?: string;
44
32
  readonly children: readonly string[];
33
+ } & (ValueOptional extends true ? {
45
34
  readonly value?: ReadonlyValue<TValue>;
46
- };
47
- type DocumentTreeValue<TValue> = {
35
+ } : {
36
+ readonly value: ReadonlyValue<TValue>;
37
+ });
38
+ type DocumentTreeValue<TValue, ValueOptional extends boolean = false> = {
48
39
  readonly rootId?: string;
49
- readonly nodes: Readonly<Record<string, DocumentTreeNode<TValue>>>;
40
+ readonly nodes: Readonly<Record<string, DocumentTreeNode<TValue, ValueOptional>>>;
50
41
  };
51
42
  type BaseNode<K extends string> = {
52
43
  readonly kind: K;
@@ -89,10 +80,10 @@ type ListNode<TItem> = BaseNode<'list'> & {
89
80
  readonly value: FieldNode<TItem, false>;
90
81
  keyOf(item: ReadonlyValue<TItem>): string;
91
82
  };
92
- type TreeNode<TValue> = BaseNode<'tree'> & {
93
- readonly value: FieldNode<TValue, boolean>;
83
+ type TreeNode<TValue, ValueOptional extends boolean = false> = BaseNode<'tree'> & {
84
+ readonly value: FieldNode<TValue, ValueOptional>;
94
85
  };
95
- 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>;
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>;
96
87
  type SchemaObject<T> = { [K in keyof T]: T[K] } & {};
97
88
  /** Infer a document or node value, including optional node presence. */
98
89
  type Infer<T extends DocumentNode> = T extends {
@@ -101,7 +92,7 @@ type Infer<T extends DocumentNode> = T extends {
101
92
  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> ? {
102
93
  readonly ids: readonly K[];
103
94
  readonly byId: Readonly<Record<K, NodeValue<V>>>;
104
- } : N extends MapNode<infer V, infer K> ? Readonly<Record<K, NodeValue<V>>> : N extends ListNode<infer I> ? readonly ReadonlyValue<I>[] : N extends TreeNode<infer T> ? DocumentTreeValue<T> : never;
95
+ } : N extends MapNode<infer V, infer K> ? Readonly<Record<K, NodeValue<V>>> : N extends ListNode<infer I> ? readonly ReadonlyValue<I>[] : N extends TreeNode<infer T, infer O> ? DocumentTreeValue<T, O> : never;
105
96
  type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
106
97
  readonly optional: true;
107
98
  } ? K : never }[keyof S];
@@ -116,29 +107,8 @@ type DocumentAnchor<K extends string = string> = {
116
107
  } | {
117
108
  readonly after: K;
118
109
  };
119
- type CollectionSelector<TId extends string = string, TNode extends ValueSchemaNode = ValueSchemaNode> = {
120
- readonly kind: 'collection';
121
- readonly schema: ObjectNode;
122
- readonly address: DocumentAddress;
123
- readonly __id?: TId; /** Compile-time entry schema carried by schema selectors. */
124
- readonly __node?: TNode;
125
- };
126
- type ValueSelector<TResult = unknown> = {
127
- readonly kind: 'value';
128
- readonly schema: ObjectNode;
129
- readonly address: DocumentAddress;
130
- readonly __value?: TResult;
131
- };
132
- type ImpactTarget<T = unknown> = {
133
- readonly kind: 'value';
134
- readonly at: DocumentAddress;
135
- } | ValueSelector<T> | {
136
- readonly kind: 'collection';
137
- readonly at: DocumentAddress;
138
- readonly id?: string;
139
- } | CollectionSelector<string>;
140
110
  declare const pathValue: unique symbol;
141
- declare const collectionNode: unique symbol;
111
+ declare const collectionEntry: unique symbol;
142
112
  declare const collectionKey: unique symbol;
143
113
  type PathMarker<TValue> = {
144
114
  readonly [pathValue]: TValue;
@@ -146,33 +116,44 @@ type PathMarker<TValue> = {
146
116
  type PathValueOf<T> = T extends {
147
117
  readonly [pathValue]: infer TValue;
148
118
  } ? TValue : never;
149
- type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } & PathMarker<TValue>;
119
+ type Or<A extends boolean, B extends boolean> = A extends true ? true : B;
120
+ type NodeAbsent<N extends DocumentNode, ParentAbsent extends boolean> = Or<ParentAbsent, N extends {
121
+ readonly optional: true;
122
+ } ? true : false>;
123
+ type PathResult<N extends DocumentNode, ParentAbsent extends boolean> = Infer<N> | (ParentAbsent extends true ? undefined : never);
124
+ 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)>;
150
125
  type SchemaPath<S extends ObjectShape = ObjectShape> = SchemaPathFor<S, ShapeValue<S>>;
151
126
  type PathPick<S extends ObjectNode = ObjectNode> = (path: SchemaPath<S['shape']>) => PathMarker<unknown>;
152
127
  type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
153
- type VariantFieldPath<V extends VariantShape, K extends string> = { [P in keyof V & string]: V[P] extends ObjectNode<infer S> ? K extends keyof S ? PathValue<S[K]> : never : never }[keyof V & string];
154
- type VariantPath<T extends string, V extends VariantShape, TValue> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K> } & { readonly [K in T]: PathMarker<keyof V & string> } & PathMarker<TValue>;
155
- type CollectionPath<N extends ValueSchemaNode = ValueSchemaNode, TValue = unknown, K extends string = string> = PathMarker<TValue> & {
156
- item(id: K): PathValue<N>;
157
- readonly [collectionNode]: N;
128
+ 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;
129
+ 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];
130
+ type VariantPath<T extends string, V extends VariantShape, TValue, Absent extends boolean> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K, Absent> } & { readonly [K in T]: PathMarker<(keyof V & string) | (Absent extends true ? undefined : never)> } & PathMarker<TValue>;
131
+ type CollectionPath<K extends string = string, TValue = unknown, TEntry = unknown, TItem = PathMarker<TEntry | undefined>> = PathMarker<TValue> & {
132
+ item(id: K): TItem;
133
+ readonly [collectionEntry]: TEntry;
158
134
  readonly [collectionKey]: K;
159
135
  };
160
- type PathValue<N extends DocumentNode> = N extends ObjectNode<infer S> ? SchemaPathFor<S, Infer<N>> : N extends VariantNode<infer TTag, infer V> ? VariantPath<TTag, V, Infer<N>> : N extends TableNode<infer V, infer K> ? CollectionPath<V, Infer<N>, K> : N extends MapNode<infer V, infer K> ? CollectionPath<V, Infer<N>, K> : N extends ListNode<infer I> ? CollectionPath<FieldNode<I, false>, Infer<N>, string> : PathMarker<Infer<N>>;
136
+ type TreeNodesPath<TValue, ValueOptional extends boolean> = CollectionPath<string, Readonly<Record<string, DocumentTreeNode<TValue, ValueOptional>>>, DocumentTreeNode<TValue, ValueOptional>, PathMarker<DocumentTreeNode<TValue, ValueOptional> | undefined>>;
137
+ type TreePath<TValue, ValueOptional extends boolean, TValueResult> = PathMarker<TValueResult> & {
138
+ readonly rootId: PathMarker<string | undefined>;
139
+ readonly nodes: TreeNodesPath<TValue, ValueOptional>;
140
+ };
141
+ type PathValue<N extends DocumentNode, ParentAbsent extends boolean = false> = N extends ObjectNode<infer S> ? SchemaPathFor<S, PathResult<N, ParentAbsent>, NodeAbsent<N, ParentAbsent>> : N extends VariantNode<infer TTag, infer V> ? VariantPath<TTag, V, PathResult<N, ParentAbsent>, NodeAbsent<N, ParentAbsent>> : N extends TableNode<infer V, infer K> ? CollectionPath<K, PathResult<N, ParentAbsent>, Infer<V>, PathValue<V, true>> : N extends MapNode<infer V, infer K> ? CollectionPath<K, PathResult<N, ParentAbsent>, Infer<V>, PathValue<V, true>> : N extends ListNode<infer I> ? CollectionPath<string, PathResult<N, ParentAbsent>, ReadonlyValue<I>, PathMarker<ReadonlyValue<I> | undefined>> : N extends TreeNode<infer T, infer O> ? TreePath<T, O, PathResult<N, ParentAbsent>> : PathMarker<PathResult<N, ParentAbsent>>;
161
142
  type CollectionInfo<T> = T extends {
162
- readonly [collectionNode]: infer TNode extends ValueSchemaNode;
143
+ readonly [collectionEntry]: infer TEntry;
163
144
  readonly [collectionKey]: infer K extends string;
164
145
  } ? {
165
146
  readonly id: K;
166
- readonly node: TNode;
147
+ readonly entry: TEntry;
167
148
  } : never;
168
149
  type CollectionId<T> = CollectionInfo<T> extends {
169
150
  readonly id: infer TId extends string;
170
151
  } ? TId : string;
171
- type CollectionNode<T> = CollectionInfo<T> extends {
172
- readonly node: infer TNode extends ValueSchemaNode;
173
- } ? TNode : ValueSchemaNode;
152
+ type CollectionEntry<T> = CollectionInfo<T> extends {
153
+ readonly entry: infer TEntry;
154
+ } ? TEntry : unknown;
174
155
  declare const field: <T>(validator?: Validator<T>) => FieldNode<T>;
175
- type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown>;
156
+ type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | MapNode<ValueSchemaNode> | ListNode<unknown> | TreeNode<unknown, false> | TreeNode<unknown, true>;
176
157
  declare const optional: <T extends OptionalLeaf>(value: T) => OptionalNode<T>;
177
158
  declare const object: <S extends ObjectShape>(shape: S) => ObjectNode<S>;
178
159
  declare const variant: <T extends string, V extends VariantShape>(tag: T, variants: V) => VariantNode<T, V>;
@@ -183,7 +164,19 @@ declare const map: <V extends ValueSchemaNode, K extends string = string>(value:
183
164
  readonly key: Validator<K>;
184
165
  }) => MapNode<V, K>;
185
166
  declare const list: <TItem>(value: FieldNode<TItem, false>, config: DocumentListConfig<TItem>) => ListNode<TItem>;
186
- declare const tree: <TValue>(value: FieldNode<TValue, boolean>) => TreeNode<TValue>;
167
+ declare const tree: <TValue, ValueOptional extends boolean>(value: FieldNode<TValue, ValueOptional>) => TreeNode<TValue, ValueOptional>;
168
+ //#endregion
169
+ //#region core/src/schema/value.d.ts
170
+ type ParseIssue = {
171
+ readonly address: DocumentAddress;
172
+ readonly code: 'invalid-value' | 'invalid-key' | 'missing-validator' | 'invalid-tree';
173
+ readonly message: string;
174
+ };
175
+ declare class ParseError extends TypeError {
176
+ readonly issues: readonly ParseIssue[];
177
+ constructor(issue: ParseIssue);
178
+ }
179
+ declare const parse: <N extends DocumentNode>(node: N, input: unknown) => Infer<N>;
187
180
  //#endregion
188
181
  //#region core/src/changes.d.ts
189
182
  type ValueTransition<T = unknown> = {
@@ -213,7 +206,7 @@ type Change = {
213
206
  readonly at: DocumentAddress;
214
207
  readonly before: string | null;
215
208
  readonly after: string | null;
216
- readonly nodes: readonly (ValueTransition<DocumentTreeNode<unknown>> & {
209
+ readonly nodes: readonly (ValueTransition<DocumentTreeNode<unknown, false> | DocumentTreeNode<unknown, true>> & {
217
210
  readonly id: string;
218
211
  })[];
219
212
  } | {
@@ -226,24 +219,12 @@ type ChangeSet = {
226
219
  readonly changes: readonly Change[];
227
220
  };
228
221
  //#endregion
229
- //#region core/src/mutation/tree.d.ts
222
+ //#region core/src/tree/topology.d.ts
230
223
  type TreePosition = {
231
224
  readonly parentId?: string;
232
225
  readonly index?: number;
233
226
  };
234
227
  //#endregion
235
- //#region core/src/address.d.ts
236
- /** The only resolved address representation used inside the runtime. */
237
- type AddressRef = {
238
- readonly path: number;
239
- readonly address: DocumentAddress;
240
- };
241
- declare const resolveAddress: (schema: ObjectNode, address: DocumentAddress, document?: unknown) => AddressRef | undefined;
242
- declare const read: (root: unknown, address: DocumentAddress, schema: DocumentNode) => unknown;
243
- declare const contains: (parent: DocumentAddress, child: DocumentAddress) => boolean;
244
- declare const overlaps: (a: DocumentAddress, b: DocumentAddress) => boolean;
245
- declare const debugKey: (address: DocumentAddress) => string;
246
- //#endregion
247
228
  //#region core/src/access/scope.d.ts
248
229
  declare const scopeValue: unique symbol;
249
230
  type Scoped<N extends DocumentNode, W extends boolean, V = Infer<N>> = {
@@ -290,20 +271,20 @@ type ListAccess<T, W extends boolean> = {
290
271
  replace(value: readonly ReadonlyValue<T>[]): void;
291
272
  replace(key: string, value: ReadonlyValue<T>): void;
292
273
  } : {});
293
- type TreeAccess<T, W extends boolean> = {
274
+ type TreeAccess<T, O extends boolean, W extends boolean> = {
294
275
  rootId(): string | undefined;
295
276
  get(id: string): ReadonlyValue<T> | undefined;
296
277
  has(id: string): boolean;
297
278
  parent(id: string): string | undefined;
298
279
  children(id: string): readonly string[] | undefined;
299
280
  } & (W extends true ? {
300
- insert(id: string, value: ReadonlyValue<T>, position?: TreePosition): void;
281
+ insert(id: string, value: O extends true ? ReadonlyValue<T> | undefined : ReadonlyValue<T>, position?: TreePosition): void;
301
282
  move(id: string, position?: TreePosition): void;
302
283
  remove(id: string): void;
303
- replace(value: DocumentTreeValue<T>): void;
304
- replace(id: string, value: ReadonlyValue<T>): void;
284
+ replace(value: DocumentTreeValue<T, O>): void;
285
+ replace(id: string, value: O extends true ? ReadonlyValue<T> | undefined : ReadonlyValue<T>): void;
305
286
  } : {});
306
- type NodeAccess<N extends DocumentNode, W extends boolean> = N extends FieldNode<infer T, boolean> ? ReadonlyValue<T> : N extends ObjectNode<infer S> ? ShapeAccess<S, W> & Scoped<N, W> : N extends VariantNode<infer Tag, infer V> ? { [K in keyof V & string]: ShapeAccess<V[K]['shape'], W> & { readonly [P in Tag]: K } & Scoped<N, W, Extract<Infer<N>, Record<Tag, K>>> }[keyof V & string] : N extends MapNode<infer V, infer K> ? MapAccess<K, V, W> & Scoped<N, W> : N extends TableNode<infer V, infer K> ? TableAccess<K, V, W> & Scoped<N, W> : N extends ListNode<infer T> ? ListAccess<T, W> & Scoped<N, W> : N extends TreeNode<infer T> ? TreeAccess<T, W> & Scoped<N, W> : never;
287
+ type NodeAccess<N extends DocumentNode, W extends boolean> = N extends FieldNode<infer T, boolean> ? ReadonlyValue<T> : N extends ObjectNode<infer S> ? ShapeAccess<S, W> & Scoped<N, W> : N extends VariantNode<infer Tag, infer V> ? { [K in keyof V & string]: ShapeAccess<V[K]['shape'], W> & { readonly [P in Tag]: K } & Scoped<N, W, Extract<Infer<N>, Record<Tag, K>>> }[keyof V & string] : N extends MapNode<infer V, infer K> ? MapAccess<K, V, W> & Scoped<N, W> : N extends TableNode<infer V, infer K> ? TableAccess<K, V, W> & Scoped<N, W> : N extends ListNode<infer T> ? ListAccess<T, W> & Scoped<N, W> : N extends TreeNode<infer T, infer O> ? TreeAccess<T, O, W> & Scoped<N, W> : never;
307
288
  type Access<N extends DocumentNode, W extends boolean> = N extends {
308
289
  readonly optional: true;
309
290
  } ? NodeAccess<N, W> | undefined : NodeAccess<N, W>;
@@ -346,7 +327,8 @@ type MutationIssue = {
346
327
  readonly message: string;
347
328
  };
348
329
  //#endregion
349
- //#region core/src/projection/readable.d.ts
330
+ //#region core/src/readable.d.ts
331
+ type Unsubscribe = () => void;
350
332
  type Readable<TValue> = {
351
333
  current(): TValue;
352
334
  revision(): number;
@@ -354,7 +336,6 @@ type Readable<TValue> = {
354
336
  };
355
337
  //#endregion
356
338
  //#region core/src/runtime/contract.d.ts
357
- type Unsubscribe = () => void;
358
339
  type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
359
340
  type CommitSource = 'local' | 'system' | 'history' | 'remote';
360
341
  declare class DocumentReentrancyError extends Error {
@@ -427,13 +408,6 @@ type LocalHistory<C> = Readable<HistoryState> & {
427
408
  };
428
409
  type CommitListener<S extends ObjectNode> = (commit: DocumentCommit<S>) => void;
429
410
  type DocumentReadable<S extends ObjectNode> = {
430
- readonly address: {
431
- resolve(address: DocumentAddress): AddressRef | undefined;
432
- read(address: DocumentAddress): unknown;
433
- contains(parent: DocumentAddress, child: DocumentAddress): boolean;
434
- overlaps(left: DocumentAddress, right: DocumentAddress): boolean;
435
- debugKey(address: DocumentAddress): string;
436
- };
437
411
  revision(): number;
438
412
  subscribe(listener: CommitListener<S>): Unsubscribe;
439
413
  subscribe(pick: PathPick<S> | readonly [PathPick<S>, ...PathPick<S>[]], listener: CommitListener<S>): Unsubscribe;
@@ -457,5 +431,5 @@ type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
457
431
  dispose(): void;
458
432
  };
459
433
  //#endregion
460
- 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, CollectionId as L, resolveAddress as M, Change as N, contains as O, ChangeSet as P, ObjectShape as Q, CollectionNode 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 };
461
- //# sourceMappingURL=contract-KG5XnQZt.d.ts.map
434
+ export { TreeNode as $, ParseError as A, DocumentTreeNode as B, Read as C, ChangeSet as D, Change as E, CollectionPath as F, MapNode as G, FieldNode as H, DocumentAddress as I, OptionalNode as J, ObjectNode as K, DocumentAnchor as L, parse as M, CollectionEntry as N, MemberChange as O, CollectionId as P, TableNode as Q, DocumentListConfig as R, Draft as S, snapshot as T, Infer as U, DocumentTreeValue as V, ListNode as W, ReadonlyValue as X, PathValueOf as Y, SchemaPath as Z, Unsubscribe as _, DocumentProblem as a, map as at, CollectionImpact as b, DocumentRuntime as c, table as ct, ObserverError as d, Validator as et, OperationResult as f, Readable as g, TransactionResult as h, DocumentDisposedError as i, list as it, ParseIssue as j, ValueTransition as k, HistoryState as l, tree as lt, TransactionRejected as m, DocumentCommit as n, VariantShape as nt, DocumentReadable as o, object as ot, Synchronous as p, ObjectShape as q, DocumentDiagnostic as r, field as rt, DocumentReentrancyError as s, optional as st, CommitSource as t, VariantNode as tt, LocalHistory as u, variant as ut, MutationIssue as v, replace as w, DocumentImpact as x, MutationIssueCode as y, DocumentNode as z };
435
+ //# sourceMappingURL=contract-ULPQmiEs.d.ts.map