doxum 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -14
- package/dist/{contract-I99DUMbN.d.ts → contract-CIcftgR3.d.ts} +101 -92
- package/dist/{contract-uYJTmT8o.d.cts → contract-b87yPRDp.d.cts} +101 -92
- package/dist/index.cjs +221 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +209 -327
- package/dist/index.js.map +1 -1
- package/dist/{integration-xupBIKjU.js → integration-B56u1l9V.js} +2 -2
- package/dist/integration-B56u1l9V.js.map +1 -0
- package/dist/{integration-Bs3pOk65.cjs → integration-CZwCwFBS.cjs} +2 -2
- package/dist/integration-CZwCwFBS.cjs.map +1 -0
- package/dist/integration.cjs +10 -2
- package/dist/integration.d.cts +3 -3
- package/dist/integration.d.ts +3 -3
- package/dist/integration.js +3 -3
- package/dist/local-sync.cjs +56 -17
- package/dist/local-sync.cjs.map +1 -1
- package/dist/local-sync.d.cts +2 -2
- package/dist/local-sync.d.ts +2 -2
- package/dist/local-sync.js +56 -17
- package/dist/local-sync.js.map +1 -1
- package/dist/react.cjs +27 -19
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +27 -19
- package/dist/react.js.map +1 -1
- package/dist/{runtime-CRijXjYp.cjs → runtime-0mOFbe_H.cjs} +899 -451
- package/dist/runtime-0mOFbe_H.cjs.map +1 -0
- package/dist/{runtime-C_vKHmhy.d.cts → runtime-BzxODO9Q.d.ts} +18 -20
- package/dist/{runtime-CUcvhFNP.d.ts → runtime-CRVMB9n1.d.cts} +18 -20
- package/dist/{runtime-BJRXF0gq.js → runtime-DF1q9Gje.js} +823 -429
- package/dist/runtime-DF1q9Gje.js.map +1 -0
- package/package.json +1 -1
- package/skills/doxum-runtime/SKILL.md +2 -1
- package/skills/doxum-runtime/references/guide.en.md +25 -18
- package/skills/doxum-runtime/references/guide.zh-CN.md +17 -17
- package/skills/doxum-runtime/references/invariants.en.md +1 -1
- package/skills/doxum-runtime/references/invariants.zh-CN.md +1 -1
- package/skills/doxum-runtime/references/patterns.en.md +9 -20
- package/skills/doxum-runtime/references/patterns.zh-CN.md +5 -18
- package/dist/integration-Bs3pOk65.cjs.map +0 -1
- package/dist/integration-xupBIKjU.js.map +0 -1
- package/dist/runtime-BJRXF0gq.js.map +0 -1
- package/dist/runtime-CRijXjYp.cjs.map +0 -1
|
@@ -40,19 +40,12 @@ type VariantNode<TTag extends string, TVariants extends VariantShape> = BaseNode
|
|
|
40
40
|
readonly tag: TTag;
|
|
41
41
|
readonly variants: TVariants;
|
|
42
42
|
};
|
|
43
|
-
type SingleNode<TValue extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = BaseNode<'single'> & {
|
|
44
|
-
readonly value: TValue;
|
|
45
|
-
};
|
|
46
43
|
type TableNode<TValue extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = BaseNode<'table'> & {
|
|
47
44
|
readonly value: TValue;
|
|
48
45
|
};
|
|
49
46
|
type MapNode<TValue extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = BaseNode<'map'> & {
|
|
50
47
|
readonly value: TValue;
|
|
51
48
|
};
|
|
52
|
-
type RecordNode<TId extends string, TValue> = BaseNode<'record'> & {
|
|
53
|
-
readonly __id?: TId;
|
|
54
|
-
readonly __value?: TValue;
|
|
55
|
-
};
|
|
56
49
|
type DictNode<TKey extends string, TValue> = BaseNode<'dict'> & {
|
|
57
50
|
readonly __key?: TKey;
|
|
58
51
|
readonly __value?: TValue;
|
|
@@ -64,18 +57,21 @@ type ListNode<TItem> = BaseNode<'list'> & {
|
|
|
64
57
|
type TreeNode<TValue> = BaseNode<'tree'> & {
|
|
65
58
|
readonly __value?: TValue;
|
|
66
59
|
};
|
|
67
|
-
type DocumentNode = FieldNode<unknown, false> | FieldNode<unknown, true> | ObjectNode<ObjectShape> | VariantNode<string, VariantShape> |
|
|
68
|
-
type
|
|
69
|
-
|
|
60
|
+
type DocumentNode = FieldNode<unknown, false> | FieldNode<unknown, true> | ObjectNode<ObjectShape> | VariantNode<string, VariantShape> | TableNode<ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> | MapNode<ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> | DictNode<string, unknown> | ListNode<unknown> | TreeNode<unknown>;
|
|
61
|
+
type SchemaObject<T> = { [K in keyof T]: T[K] } & {};
|
|
62
|
+
/** Infer a document or node value, including optional node presence. */
|
|
63
|
+
type Infer<T extends DocumentNode | DocumentSchema> = T extends DocumentSchema<infer S> ? ShapeValue<S> : T extends {
|
|
64
|
+
readonly optional: true;
|
|
65
|
+
} ? NodeValue<T> | undefined : NodeValue<T>;
|
|
66
|
+
type NodeValue<N> = N extends FieldNode<infer T, infer O> ? O extends true ? T | undefined : 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> ? {
|
|
70
67
|
readonly ids: readonly string[];
|
|
71
|
-
readonly byId: Readonly<Record<string,
|
|
72
|
-
} : N extends MapNode<infer V> ? Readonly<Record<string,
|
|
68
|
+
readonly byId: Readonly<Record<string, NodeValue<V>>>;
|
|
69
|
+
} : N extends MapNode<infer V> ? Readonly<Record<string, NodeValue<V>>> : N extends DictNode<infer K, infer T> ? Readonly<Partial<Record<K, T>>> : N extends ListNode<infer I> ? readonly I[] : N extends TreeNode<infer T> ? DocumentTreeValue<T> : never;
|
|
73
70
|
type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
|
|
74
71
|
readonly optional: true;
|
|
75
72
|
} ? K : never }[keyof S];
|
|
76
73
|
type RequiredKeys<S extends ObjectShape> = Exclude<keyof S, OptionalKeys<S>>;
|
|
77
|
-
type
|
|
78
|
-
type ReadonlyDocument<S extends DocumentSchema> = DocumentValueOfShape<S['shape']>;
|
|
74
|
+
type ShapeValue<S extends ObjectShape> = SchemaObject<{ readonly [K in RequiredKeys<S>]: NodeValue<S[K]> } & { readonly [K in OptionalKeys<S>]?: NodeValue<S[K]> }>;
|
|
79
75
|
type EntitySchemaNode = ObjectNode<ObjectShape> | VariantNode<string, VariantShape>;
|
|
80
76
|
type CollectionSelector<TId extends string = string, TNode extends EntitySchemaNode = EntitySchemaNode> = {
|
|
81
77
|
readonly kind: 'collection';
|
|
@@ -98,43 +94,32 @@ type ImpactTarget<T = unknown> = {
|
|
|
98
94
|
readonly at: DocumentAddress;
|
|
99
95
|
readonly id?: string;
|
|
100
96
|
} | CollectionSelector<string>;
|
|
97
|
+
declare const pathValue: unique symbol;
|
|
98
|
+
declare const collectionNode: unique symbol;
|
|
101
99
|
type PathMarker<TValue> = {
|
|
102
|
-
readonly
|
|
100
|
+
readonly [pathValue]: TValue;
|
|
103
101
|
};
|
|
104
|
-
type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } &
|
|
105
|
-
readonly item: (id: string) => SchemaPathFor<{}, unknown>;
|
|
106
|
-
} & PathMarker<TValue>;
|
|
102
|
+
type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } & PathMarker<TValue>;
|
|
107
103
|
type DocumentSchema<TShape extends ObjectShape = {}> = {
|
|
108
104
|
readonly kind: 'schema';
|
|
109
105
|
readonly shape: TShape;
|
|
110
|
-
collection<TPath extends
|
|
106
|
+
collection<TPath extends CollectionPath>(pick: (path: SchemaPath<TShape>) => TPath): CollectionSelector<CollectionId<TPath>, CollectionNode<TPath>>;
|
|
111
107
|
value<TPath extends PathMarker<unknown>>(pick: (path: SchemaPath<TShape>) => TPath): ValueSelector<PathValueResult<TPath>>;
|
|
112
108
|
};
|
|
113
|
-
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S,
|
|
109
|
+
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S, ShapeValue<S>>;
|
|
114
110
|
type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
|
|
115
111
|
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];
|
|
116
|
-
type VariantPath<V extends VariantShape> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K> } & {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
type PathNodeValue<N extends DocumentNode> = N extends {
|
|
120
|
-
readonly optional: true;
|
|
121
|
-
} ? DocumentValueOfNode<N> | undefined : DocumentValueOfNode<N>;
|
|
122
|
-
type EntityPath<N extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = N extends ObjectNode<infer S> ? SchemaPathFor<S, PathNodeValue<N>> : N extends VariantNode<string, infer V> ? VariantPath<V> : never;
|
|
123
|
-
type CollectionPath<N extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = Omit<EntityPath<N>, 'item'> & {
|
|
112
|
+
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>;
|
|
113
|
+
type EntityPath<N extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = N extends ObjectNode<infer S> ? SchemaPathFor<S, Infer<N>> : N extends VariantNode<infer T, infer V> ? VariantPath<T, V, Infer<N>> : never;
|
|
114
|
+
type CollectionPath<N extends EntitySchemaNode = EntitySchemaNode, TValue = unknown> = PathMarker<TValue> & {
|
|
124
115
|
readonly item: (id: string) => EntityPath<N>;
|
|
125
|
-
readonly
|
|
126
|
-
readonly id: string;
|
|
127
|
-
readonly node: N;
|
|
128
|
-
};
|
|
116
|
+
readonly [collectionNode]: N;
|
|
129
117
|
};
|
|
130
|
-
type PathValue<N extends DocumentNode> = N extends ObjectNode<infer S> ? SchemaPathFor<S,
|
|
118
|
+
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> | MapNode<infer V> ? CollectionPath<V, Infer<N>> : PathMarker<Infer<N>>;
|
|
131
119
|
type CollectionInfo<T> = T extends {
|
|
132
|
-
readonly
|
|
133
|
-
readonly id: infer TId;
|
|
134
|
-
readonly node: infer TNode extends EntitySchemaNode;
|
|
135
|
-
};
|
|
120
|
+
readonly [collectionNode]: infer TNode extends EntitySchemaNode;
|
|
136
121
|
} ? {
|
|
137
|
-
readonly id:
|
|
122
|
+
readonly id: string;
|
|
138
123
|
readonly node: TNode;
|
|
139
124
|
} : never;
|
|
140
125
|
type CollectionId<T> = CollectionInfo<T> extends {
|
|
@@ -145,13 +130,12 @@ type CollectionNode<T> = CollectionInfo<T> extends {
|
|
|
145
130
|
} ? TNode : EntitySchemaNode;
|
|
146
131
|
type PathValueResult<T> = T extends PathMarker<infer TValue> ? TValue : unknown;
|
|
147
132
|
declare const field: <T>() => FieldNode<T>;
|
|
148
|
-
|
|
133
|
+
type OptionalLeaf = FieldNode<unknown, boolean> | VariantNode<string, VariantShape> | DictNode<string, unknown> | ListNode<unknown> | TreeNode<unknown>;
|
|
134
|
+
declare const optional: <T extends OptionalLeaf>(value: T) => OptionalNode<T>;
|
|
149
135
|
declare const object: <S extends ObjectShape>(shape: S) => ObjectNode<S>;
|
|
150
136
|
declare const variant: <T extends string, V extends VariantShape>(tag: T, variants: V) => VariantNode<T, V>;
|
|
151
|
-
declare const single: <V extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>>(value: V) => SingleNode<V>;
|
|
152
137
|
declare const table: <V extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>>(value: V) => TableNode<V>;
|
|
153
138
|
declare const map: <V extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>>(value: V) => MapNode<V>;
|
|
154
|
-
declare const record: <TId extends string = string, TValue = unknown>() => RecordNode<TId, TValue>;
|
|
155
139
|
declare const dict: <TKey extends string = string, TValue = unknown>() => DictNode<TKey, TValue>;
|
|
156
140
|
declare const list: <TItem>(config: DocumentListConfig<TItem>) => ListNode<TItem>;
|
|
157
141
|
declare const tree: <TValue = unknown>() => TreeNode<TValue>;
|
|
@@ -168,34 +152,34 @@ type DocumentAnchor = {
|
|
|
168
152
|
type OperationBase = {
|
|
169
153
|
readonly at: DocumentAddress;
|
|
170
154
|
};
|
|
171
|
-
type FieldSetOperation
|
|
155
|
+
type FieldSetOperation = OperationBase & {
|
|
172
156
|
readonly type: 'field.set';
|
|
173
157
|
readonly value: unknown;
|
|
174
158
|
};
|
|
175
|
-
type FieldClearOperation
|
|
159
|
+
type FieldClearOperation = OperationBase & {
|
|
176
160
|
readonly type: 'field.clear';
|
|
177
161
|
};
|
|
178
|
-
type ValueClearOperation
|
|
162
|
+
type ValueClearOperation = OperationBase & {
|
|
179
163
|
readonly type: 'value.clear';
|
|
180
164
|
};
|
|
181
|
-
type VariantReplaceOperation
|
|
165
|
+
type VariantReplaceOperation = OperationBase & {
|
|
182
166
|
readonly type: 'variant.replace';
|
|
183
167
|
readonly value: unknown;
|
|
184
168
|
};
|
|
185
|
-
type DictSetOperation
|
|
169
|
+
type DictSetOperation = OperationBase & {
|
|
186
170
|
readonly type: 'dict.set';
|
|
187
171
|
readonly key: string;
|
|
188
172
|
readonly value: unknown;
|
|
189
173
|
};
|
|
190
|
-
type DictDeleteOperation
|
|
174
|
+
type DictDeleteOperation = OperationBase & {
|
|
191
175
|
readonly type: 'dict.delete';
|
|
192
176
|
readonly key: string;
|
|
193
177
|
};
|
|
194
|
-
type DictReplaceOperation
|
|
178
|
+
type DictReplaceOperation = OperationBase & {
|
|
195
179
|
readonly type: 'dict.replace';
|
|
196
180
|
readonly value: Readonly<Record<string, unknown>>;
|
|
197
181
|
};
|
|
198
|
-
type EntityCreateOperation
|
|
182
|
+
type EntityCreateOperation = OperationBase & {
|
|
199
183
|
readonly type: 'entity.create';
|
|
200
184
|
readonly entries: readonly EntityEntry[];
|
|
201
185
|
readonly anchor?: DocumentAnchor; /** Generated inverse metadata with strictly increasing final indices. Normal creates omit it. */
|
|
@@ -205,74 +189,81 @@ type EntityEntry = {
|
|
|
205
189
|
readonly id: string;
|
|
206
190
|
readonly value: unknown;
|
|
207
191
|
};
|
|
208
|
-
type EntityRemoveOperation
|
|
192
|
+
type EntityRemoveOperation = OperationBase & {
|
|
209
193
|
readonly type: 'entity.remove';
|
|
210
194
|
readonly ids: readonly string[];
|
|
211
195
|
};
|
|
212
|
-
type EntityMoveOperation
|
|
196
|
+
type EntityMoveOperation = OperationBase & {
|
|
213
197
|
readonly type: 'entity.move';
|
|
214
198
|
readonly id: string;
|
|
215
199
|
readonly anchor?: DocumentAnchor;
|
|
216
200
|
};
|
|
217
|
-
type ListInsertOperation
|
|
201
|
+
type ListInsertOperation = OperationBase & {
|
|
218
202
|
readonly type: 'list.insert';
|
|
219
203
|
readonly key: string;
|
|
220
204
|
readonly value: unknown;
|
|
221
205
|
readonly anchor?: DocumentAnchor;
|
|
222
206
|
};
|
|
223
|
-
type ListMoveOperation
|
|
207
|
+
type ListMoveOperation = OperationBase & {
|
|
224
208
|
readonly type: 'list.move';
|
|
225
209
|
readonly key: string;
|
|
226
210
|
readonly anchor?: DocumentAnchor;
|
|
227
211
|
};
|
|
228
|
-
type ListRemoveOperation
|
|
212
|
+
type ListRemoveOperation = OperationBase & {
|
|
229
213
|
readonly type: 'list.remove';
|
|
230
214
|
readonly key: string;
|
|
231
215
|
};
|
|
232
|
-
type ListReplaceOperation
|
|
216
|
+
type ListReplaceOperation = OperationBase & {
|
|
233
217
|
readonly type: 'list.replace';
|
|
234
218
|
readonly value: readonly unknown[];
|
|
235
219
|
readonly keys: readonly string[];
|
|
236
220
|
};
|
|
237
|
-
type TreeInsertOperation
|
|
221
|
+
type TreeInsertOperation = OperationBase & {
|
|
238
222
|
readonly type: 'tree.insert';
|
|
239
223
|
readonly treeNodeId: string;
|
|
240
224
|
readonly parentId?: string;
|
|
241
225
|
readonly index?: number;
|
|
242
226
|
readonly value?: unknown;
|
|
243
227
|
};
|
|
244
|
-
type TreeMoveOperation
|
|
228
|
+
type TreeMoveOperation = OperationBase & {
|
|
245
229
|
readonly type: 'tree.move';
|
|
246
230
|
readonly treeNodeId: string;
|
|
247
231
|
readonly parentId?: string;
|
|
248
232
|
readonly index?: number;
|
|
249
233
|
};
|
|
250
|
-
type TreeRemoveOperation
|
|
234
|
+
type TreeRemoveOperation = OperationBase & {
|
|
251
235
|
readonly type: 'tree.remove';
|
|
252
236
|
readonly treeNodeId: string;
|
|
253
237
|
};
|
|
254
|
-
type TreeSetOperation
|
|
238
|
+
type TreeSetOperation = OperationBase & {
|
|
255
239
|
readonly type: 'tree.set';
|
|
256
240
|
readonly treeNodeId: string;
|
|
257
241
|
readonly value: unknown;
|
|
258
242
|
};
|
|
259
|
-
type TreeReplaceOperation
|
|
243
|
+
type TreeReplaceOperation = OperationBase & {
|
|
260
244
|
readonly type: 'tree.replace';
|
|
261
245
|
readonly value: unknown;
|
|
262
246
|
};
|
|
263
|
-
type
|
|
264
|
-
type DocumentOperation<TSchema extends DocumentSchema = DocumentSchema> = DocumentOperationUnion<TSchema>;
|
|
247
|
+
type DocumentOperation = FieldSetOperation | FieldClearOperation | ValueClearOperation | VariantReplaceOperation | DictSetOperation | DictDeleteOperation | DictReplaceOperation | EntityCreateOperation | EntityRemoveOperation | EntityMoveOperation | ListInsertOperation | ListMoveOperation | ListRemoveOperation | ListReplaceOperation | TreeInsertOperation | TreeMoveOperation | TreeRemoveOperation | TreeSetOperation | TreeReplaceOperation;
|
|
265
248
|
//#endregion
|
|
266
249
|
//#region core/src/access/reader.d.ts
|
|
267
250
|
type FieldReader<T> = {
|
|
268
251
|
readonly get: () => T;
|
|
269
252
|
};
|
|
253
|
+
type DictionaryReader<K extends string, V> = {
|
|
254
|
+
get(key: K): V | undefined;
|
|
255
|
+
has(key: K): boolean;
|
|
256
|
+
keys(): readonly K[];
|
|
257
|
+
values(): Readonly<Partial<Record<K, V>>>;
|
|
258
|
+
};
|
|
270
259
|
type CollectionReader<TId, TNode extends EntitySchemaNode> = {
|
|
271
260
|
readonly ids: () => readonly TId[];
|
|
272
261
|
readonly has: (id: TId) => boolean;
|
|
273
262
|
readonly get: (id: TId) => ReaderOfNode<TNode> | undefined;
|
|
274
263
|
};
|
|
275
264
|
type ListReader<T> = {
|
|
265
|
+
readonly get: (key: string) => T | undefined;
|
|
266
|
+
readonly has: (key: string) => boolean;
|
|
276
267
|
readonly values: () => readonly T[];
|
|
277
268
|
readonly length: () => number;
|
|
278
269
|
readonly at: (index: number) => T | undefined;
|
|
@@ -286,7 +277,7 @@ type TreeReader<T> = {
|
|
|
286
277
|
};
|
|
287
278
|
type ReaderOfNode<TNode extends DocumentNode> = TNode extends {
|
|
288
279
|
kind: 'field';
|
|
289
|
-
} ? FieldReader<
|
|
280
|
+
} ? FieldReader<Infer<TNode>> : TNode extends ObjectNode<infer TShape> ? { readonly [K in keyof TShape]: ReaderOfNode<TShape[K]> } : TNode extends VariantNode<string, infer _TVariants> ? FieldReader<Infer<TNode>> : TNode extends TableNode<infer TValue> ? CollectionReader<string, TValue> : TNode extends MapNode<infer TValue> ? CollectionReader<string, TValue> : TNode extends DictNode<infer TKey, infer TValue> ? DictionaryReader<TKey, TValue> : TNode extends ListNode<infer TItem> ? ListReader<TItem> : TNode extends TreeNode<infer TValue> ? TreeReader<TValue> : FieldReader<Infer<TNode>>;
|
|
290
281
|
type DocumentReader<TSchema extends DocumentSchema> = ReaderOfNode<ObjectNode<TSchema['shape']>>;
|
|
291
282
|
//#endregion
|
|
292
283
|
//#region core/src/access/writer.d.ts
|
|
@@ -303,10 +294,10 @@ type DictionaryWriter<TKey extends string, TValue> = {
|
|
|
303
294
|
type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
304
295
|
readonly create: (entry: {
|
|
305
296
|
readonly id: TId;
|
|
306
|
-
readonly value:
|
|
297
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
307
298
|
} | readonly {
|
|
308
299
|
readonly id: TId;
|
|
309
|
-
readonly value:
|
|
300
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
310
301
|
}[], anchor?: DocumentAnchor) => void;
|
|
311
302
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
312
303
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -315,10 +306,10 @@ type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
|
315
306
|
type MapWriter<TId, TNode extends EntitySchemaNode> = {
|
|
316
307
|
readonly create: (entry: {
|
|
317
308
|
readonly id: TId;
|
|
318
|
-
readonly value:
|
|
309
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
319
310
|
} | readonly {
|
|
320
311
|
readonly id: TId;
|
|
321
|
-
readonly value:
|
|
312
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
322
313
|
}[]) => void;
|
|
323
314
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
324
315
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -330,8 +321,14 @@ type ListWriter<T> = {
|
|
|
330
321
|
readonly replace: (value: readonly T[]) => void;
|
|
331
322
|
};
|
|
332
323
|
type TreeWriter<T> = {
|
|
333
|
-
readonly insert: (id: string, value: T,
|
|
334
|
-
|
|
324
|
+
readonly insert: (id: string, value: T, position?: {
|
|
325
|
+
readonly parentId?: string;
|
|
326
|
+
readonly index?: number;
|
|
327
|
+
}) => void;
|
|
328
|
+
readonly move: (id: string, position?: {
|
|
329
|
+
readonly parentId?: string;
|
|
330
|
+
readonly index?: number;
|
|
331
|
+
}) => void;
|
|
335
332
|
readonly remove: (id: string) => void;
|
|
336
333
|
readonly set: (id: string, value: T) => void;
|
|
337
334
|
readonly replace: (value: DocumentTreeValue<T>) => void;
|
|
@@ -345,9 +342,9 @@ type WriterOfNode<TNode extends DocumentNode> = TNode extends {
|
|
|
345
342
|
kind: 'field';
|
|
346
343
|
} ? TNode extends {
|
|
347
344
|
readonly optional: true;
|
|
348
|
-
} ? FieldWriter<
|
|
349
|
-
readonly replace: (value:
|
|
350
|
-
}> : TNode extends
|
|
345
|
+
} ? FieldWriter<Infer<TNode>, true> : FieldWriter<Infer<TNode>> : TNode extends ObjectNode<infer TShape> ? { readonly [K in keyof TShape]: WriterOfNode<TShape[K]> } : TNode extends VariantNode<string, infer _TVariants> ? OptionalClear<TNode, {
|
|
346
|
+
readonly replace: (value: Exclude<Infer<TNode>, undefined>) => void;
|
|
347
|
+
}> : TNode extends TableNode<infer TValue> ? CollectionWriter<string, TValue> : TNode extends MapNode<infer TValue> ? MapWriter<string, TValue> : TNode extends DictNode<infer TKey, infer TValue> ? OptionalClear<TNode, DictionaryWriter<TKey, TValue>> : TNode extends ListNode<infer TItem> ? OptionalClear<TNode, ListWriter<TItem>> : TNode extends TreeNode<infer TValue> ? OptionalClear<TNode, TreeWriter<TValue>> : FieldWriter<Infer<TNode>>;
|
|
351
348
|
type DocumentWriter<TSchema extends DocumentSchema> = WriterOfNode<ObjectNode<TSchema['shape']>>;
|
|
352
349
|
//#endregion
|
|
353
350
|
//#region core/src/mutation/issue.d.ts
|
|
@@ -357,7 +354,7 @@ type MutationIssue = {
|
|
|
357
354
|
readonly code: MutationIssueCode;
|
|
358
355
|
readonly address: DocumentAddress;
|
|
359
356
|
readonly message: string;
|
|
360
|
-
readonly operation?:
|
|
357
|
+
readonly operation?: DocumentOperation['type'];
|
|
361
358
|
};
|
|
362
359
|
//#endregion
|
|
363
360
|
//#region core/src/impact.d.ts
|
|
@@ -374,7 +371,7 @@ type DocumentImpact<TSchema extends DocumentSchema> = {
|
|
|
374
371
|
readonly kind: 'incremental' | 'reset';
|
|
375
372
|
readonly affects: (target: ImpactTarget<unknown>) => boolean;
|
|
376
373
|
readonly collection: <TId extends string>(selector: CollectionSelector<TId>) => CollectionImpact<TId>;
|
|
377
|
-
readonly operations: readonly
|
|
374
|
+
readonly operations: readonly DocumentOperation[];
|
|
378
375
|
};
|
|
379
376
|
//#endregion
|
|
380
377
|
//#region core/src/address.d.ts
|
|
@@ -423,12 +420,20 @@ type CommandFootprintTarget = {
|
|
|
423
420
|
readonly id: string;
|
|
424
421
|
};
|
|
425
422
|
type CommandFootprint = readonly CommandFootprintTarget[];
|
|
426
|
-
declare const commandFootprint: (operations: readonly
|
|
423
|
+
declare const commandFootprint: (operations: readonly DocumentOperation[]) => CommandFootprint;
|
|
427
424
|
declare const footprintsOverlap: (left: CommandFootprint, right: CommandFootprint) => boolean;
|
|
428
425
|
declare const decodeCommandFootprint: (value: unknown) => CommandFootprint | undefined;
|
|
429
426
|
//#endregion
|
|
427
|
+
//#region core/src/projection/readable.d.ts
|
|
428
|
+
type Readable<TValue> = {
|
|
429
|
+
current(): TValue;
|
|
430
|
+
revision(): number;
|
|
431
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
430
434
|
//#region core/src/runtime/contract.d.ts
|
|
431
435
|
type Unsubscribe = () => void;
|
|
436
|
+
type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
|
|
432
437
|
type CommitSource = 'local' | 'system' | 'history' | 'remote';
|
|
433
438
|
declare class DocumentReentrancyError extends Error {
|
|
434
439
|
constructor();
|
|
@@ -440,16 +445,18 @@ type DocumentCommit<TSchema extends DocumentSchema> = {
|
|
|
440
445
|
readonly revision: number;
|
|
441
446
|
readonly kind: 'operations' | 'replace';
|
|
442
447
|
readonly source: CommitSource;
|
|
443
|
-
readonly operations: readonly
|
|
444
|
-
readonly inverse: readonly
|
|
448
|
+
readonly operations: readonly DocumentOperation[];
|
|
449
|
+
readonly inverse: readonly DocumentOperation[];
|
|
445
450
|
readonly impact: DocumentImpact<TSchema>;
|
|
446
451
|
};
|
|
447
|
-
type
|
|
448
|
-
readonly source: 'application';
|
|
452
|
+
type DiagnosticInput = {
|
|
449
453
|
readonly code: string;
|
|
450
454
|
readonly message: string;
|
|
451
455
|
readonly address?: DocumentAddress;
|
|
452
456
|
};
|
|
457
|
+
type DocumentDiagnostic = DiagnosticInput & {
|
|
458
|
+
readonly source: 'application';
|
|
459
|
+
};
|
|
453
460
|
type DocumentProblem = DocumentDiagnostic | MutationIssue;
|
|
454
461
|
type ObserverError = {
|
|
455
462
|
readonly phase: 'processor' | 'flush' | 'listener';
|
|
@@ -474,8 +481,8 @@ type TransactionResult<TValue, TCommit> = {
|
|
|
474
481
|
type PreparedUpdateResult<TValue, TSchema extends DocumentSchema> = {
|
|
475
482
|
readonly status: 'prepared';
|
|
476
483
|
readonly value: TValue;
|
|
477
|
-
readonly operations: readonly
|
|
478
|
-
readonly inverse: readonly
|
|
484
|
+
readonly operations: readonly DocumentOperation[];
|
|
485
|
+
readonly inverse: readonly DocumentOperation[];
|
|
479
486
|
readonly impact: DocumentImpact<TSchema>;
|
|
480
487
|
readonly footprint: CommandFootprint;
|
|
481
488
|
readonly reports: readonly DocumentDiagnostic[];
|
|
@@ -503,18 +510,20 @@ type HistoryState = {
|
|
|
503
510
|
readonly undoDepth: number;
|
|
504
511
|
readonly redoDepth: number;
|
|
505
512
|
};
|
|
506
|
-
type LocalHistory<TCommit> = {
|
|
507
|
-
current(): HistoryState;
|
|
508
|
-
subscribe(listener: () => void): Unsubscribe;
|
|
513
|
+
type LocalHistory<TCommit> = Readable<HistoryState> & {
|
|
509
514
|
undo(): OperationResult<TCommit>;
|
|
510
515
|
redo(): OperationResult<TCommit>;
|
|
511
516
|
clear(): void;
|
|
517
|
+
group(): {
|
|
518
|
+
end(): void;
|
|
519
|
+
cancel(): OperationResult<TCommit>;
|
|
520
|
+
};
|
|
512
521
|
};
|
|
513
522
|
type DocumentTransaction<TSchema extends DocumentSchema> = {
|
|
514
523
|
readonly read: DocumentReader<TSchema>;
|
|
515
524
|
readonly write: DocumentWriter<TSchema>;
|
|
516
|
-
readonly reject: (issue:
|
|
517
|
-
readonly report: (issue:
|
|
525
|
+
readonly reject: (issue: DiagnosticInput | readonly DiagnosticInput[]) => never;
|
|
526
|
+
readonly report: (issue: DiagnosticInput) => void;
|
|
518
527
|
};
|
|
519
528
|
type CommitListener<TSchema extends DocumentSchema> = (commit: DocumentCommit<TSchema>) => void;
|
|
520
529
|
type DocumentReadable<TSchema extends DocumentSchema> = {
|
|
@@ -531,22 +540,22 @@ type DocumentReadable<TSchema extends DocumentSchema> = {
|
|
|
531
540
|
};
|
|
532
541
|
type DocumentRuntime<TSchema extends DocumentSchema> = DocumentReadable<TSchema> & {
|
|
533
542
|
/** Schema configuration captured when this runtime was created. */readonly schema: TSchema;
|
|
534
|
-
update<TResult>(run: (transaction: DocumentTransaction<TSchema>) => TResult
|
|
543
|
+
update<TResult>(run: (transaction: DocumentTransaction<TSchema>) => Synchronous<TResult>, options?: {
|
|
535
544
|
readonly source?: Extract<CommitSource, 'local' | 'system'>;
|
|
536
545
|
readonly history?: boolean;
|
|
537
546
|
}): TransactionResult<TResult, DocumentCommit<TSchema>>;
|
|
538
|
-
prepare<TResult>(run: (transaction: DocumentTransaction<TSchema>) => TResult): PreparedUpdateResult<TResult, TSchema>;
|
|
547
|
+
prepare<TResult>(run: (transaction: DocumentTransaction<TSchema>) => Synchronous<TResult>): PreparedUpdateResult<TResult, TSchema>;
|
|
539
548
|
apply(operations: unknown, options?: {
|
|
540
549
|
readonly source?: Exclude<CommitSource, 'history'>;
|
|
541
550
|
readonly history?: boolean;
|
|
542
551
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
543
|
-
replace(document:
|
|
552
|
+
replace(document: Infer<TSchema>, options?: {
|
|
544
553
|
readonly source?: Extract<CommitSource, 'system' | 'remote'>;
|
|
545
554
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
546
|
-
snapshot():
|
|
555
|
+
snapshot(): Infer<TSchema>;
|
|
547
556
|
readonly history: LocalHistory<DocumentCommit<TSchema>>;
|
|
548
557
|
dispose(): void;
|
|
549
558
|
};
|
|
550
559
|
//#endregion
|
|
551
|
-
export {
|
|
552
|
-
//# sourceMappingURL=contract-
|
|
560
|
+
export { DocumentOperation as $, CollectionImpact as A, Infer as At, TreeWriter as B, VariantNode as Bt, footprintsOverlap as C, DocumentNode as Ct, overlaps as D, EntitySchemaNode as Dt, debugKey as E, DocumentTreeValue as Et, DictionaryWriter as F, OptionalNode as Ft, FieldReader as G, map as Gt, CollectionReader as H, dict as Ht, DocumentWriter as I, SchemaPath as It, TreeReader as J, schema as Jt, ListReader as K, object as Kt, FieldWriter as L, TableNode as Lt, MutationIssue as M, MapNode as Mt, MutationIssueCode as N, ObjectNode as Nt, read as O, FieldNode as Ot, CollectionWriter as P, ObjectShape as Pt, DocumentAnchor as Q, ListWriter as R, TreeNode as Rt, decodeCommandFootprint as S, DocumentListConfig as St, contains as T, DocumentTreeNode as Tt, DictionaryReader as U, field as Ut, WriterOfNode as V, VariantShape as Vt, DocumentReader as W, list as Wt, DictReplaceOperation as X, tree as Xt, DictDeleteOperation as Y, table as Yt, DictSetOperation as Z, variant as Zt, Unsubscribe as _, CollectionNode as _t, DocumentProblem as a, FieldSetOperation as at, CommandFootprintTarget as b, DictNode as bt, DocumentRuntime as c, ListRemoveOperation as ct, LocalHistory as d, TreeMoveOperation as dt, EntityCreateOperation as et, ObserverError as f, TreeRemoveOperation as ft, TransactionResult as g, VariantReplaceOperation as gt, Synchronous as h, ValueClearOperation as ht, DocumentDisposedError as i, FieldClearOperation as it, DocumentImpact as j, ListNode as jt, resolveAddress as k, ImpactTarget as kt, DocumentTransaction as l, ListReplaceOperation as lt, PreparedUpdateResult as m, TreeSetOperation as mt, DocumentCommit as n, EntityMoveOperation as nt, DocumentReadable as o, ListInsertOperation as ot, OperationResult as p, TreeReplaceOperation as pt, ReaderOfNode as q, optional as qt, DocumentDiagnostic as r, EntityRemoveOperation as rt, DocumentReentrancyError as s, ListMoveOperation as st, CommitSource as t, EntityEntry as tt, HistoryState as u, TreeInsertOperation as ut, Readable as v, CollectionPath as vt, AddressRef as w, DocumentSchema as wt, commandFootprint as x, DocumentAddress as xt, CommandFootprint as y, CollectionSelector as yt, MapWriter as z, ValueSelector as zt };
|
|
561
|
+
//# sourceMappingURL=contract-b87yPRDp.d.cts.map
|