doxum 0.1.7 → 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 +29 -1
- package/dist/{contract-DNZ4D53r.d.ts → contract-CIcftgR3.d.ts} +25 -27
- package/dist/{contract-j3SLGAwh.d.cts → contract-b87yPRDp.d.cts} +25 -27
- 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.map +1 -1
- package/dist/integration.d.cts +2 -2
- package/dist/integration.d.ts +2 -2
- package/dist/local-sync.cjs.map +1 -1
- package/dist/local-sync.d.cts +1 -1
- package/dist/local-sync.d.ts +1 -1
- package/dist/local-sync.js.map +1 -1
- package/dist/runtime-0mOFbe_H.cjs.map +1 -1
- package/dist/{runtime-BFmhzPpZ.d.ts → runtime-BzxODO9Q.d.ts} +2 -2
- package/dist/{runtime-B22tuj9A.d.cts → runtime-CRVMB9n1.d.cts} +2 -2
- package/dist/runtime-DF1q9Gje.js.map +1 -1
- package/package.json +1 -1
- package/skills/doxum-runtime/references/guide.en.md +7 -0
- package/skills/doxum-runtime/references/guide.zh-CN.md +5 -0
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Define the document shape once. Doxum infers the immutable document value and
|
|
|
61
61
|
the reader and writer APIs from that schema.
|
|
62
62
|
|
|
63
63
|
```ts
|
|
64
|
-
import { createDocument, field, object, schema, table } from 'doxum';
|
|
64
|
+
import { createDocument, field, object, schema, table, type Infer } from 'doxum';
|
|
65
65
|
|
|
66
66
|
const task = object({
|
|
67
67
|
title: field<string>(),
|
|
@@ -73,6 +73,9 @@ const taskSchema = schema({
|
|
|
73
73
|
tasks: table(task),
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
type Task = Infer<typeof task>;
|
|
77
|
+
type TaskDocument = Infer<typeof taskSchema>;
|
|
78
|
+
|
|
76
79
|
const runtime = createDocument({
|
|
77
80
|
schema: taskSchema,
|
|
78
81
|
initial: {
|
|
@@ -103,6 +106,31 @@ application validation, use `tx.report` or `tx.reject` with a
|
|
|
103
106
|
diagnostic `{ code, message, address? }`; Doxum adds `source: 'application'`.
|
|
104
107
|
Published diagnostic arrays and addresses are copied and frozen.
|
|
105
108
|
|
|
109
|
+
## Infer Value Types
|
|
110
|
+
|
|
111
|
+
Use `Infer<typeof node>` or `Infer<typeof documentSchema>` for value types.
|
|
112
|
+
Schema-generated objects are flattened, with readonly properties and optional
|
|
113
|
+
presence preserved. Variants produce a discriminated union of flat branches:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { field, object, variant, type Infer } from 'doxum';
|
|
117
|
+
|
|
118
|
+
const outcome = variant('kind', {
|
|
119
|
+
victory: object({ reason: field<'sealed' | 'destroyed'>() }),
|
|
120
|
+
defeat: object({ reason: field<'deadline' | 'collapse'>() }),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
type Outcome = Infer<typeof outcome>;
|
|
124
|
+
// { readonly kind: 'victory'; readonly reason: 'sealed' | 'destroyed' }
|
|
125
|
+
// | { readonly kind: 'defeat'; readonly reason: 'deadline' | 'collapse' }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`Infer` includes `undefined` for an optional node; in a containing object its
|
|
129
|
+
property is optional. User-supplied types in `field<T>`, dict, list and tree
|
|
130
|
+
values retain their original type structure. Flattening does not recursively
|
|
131
|
+
rewrite those types or apply deep readonly to them. TypeScript controls the
|
|
132
|
+
exact alias presentation in editor hovers.
|
|
133
|
+
|
|
106
134
|
## Read And Subscribe
|
|
107
135
|
|
|
108
136
|
Use `select` for a one-off typed read. Use schema selectors and `subscribe`
|
|
@@ -58,17 +58,20 @@ type TreeNode<TValue> = BaseNode<'tree'> & {
|
|
|
58
58
|
readonly __value?: TValue;
|
|
59
59
|
};
|
|
60
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
|
|
62
|
-
|
|
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> ? {
|
|
63
67
|
readonly ids: readonly string[];
|
|
64
|
-
readonly byId: Readonly<Record<string,
|
|
65
|
-
} : 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;
|
|
66
70
|
type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
|
|
67
71
|
readonly optional: true;
|
|
68
72
|
} ? K : never }[keyof S];
|
|
69
73
|
type RequiredKeys<S extends ObjectShape> = Exclude<keyof S, OptionalKeys<S>>;
|
|
70
|
-
type
|
|
71
|
-
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]> }>;
|
|
72
75
|
type EntitySchemaNode = ObjectNode<ObjectShape> | VariantNode<string, VariantShape>;
|
|
73
76
|
type CollectionSelector<TId extends string = string, TNode extends EntitySchemaNode = EntitySchemaNode> = {
|
|
74
77
|
readonly kind: 'collection';
|
|
@@ -103,19 +106,16 @@ type DocumentSchema<TShape extends ObjectShape = {}> = {
|
|
|
103
106
|
collection<TPath extends CollectionPath>(pick: (path: SchemaPath<TShape>) => TPath): CollectionSelector<CollectionId<TPath>, CollectionNode<TPath>>;
|
|
104
107
|
value<TPath extends PathMarker<unknown>>(pick: (path: SchemaPath<TShape>) => TPath): ValueSelector<PathValueResult<TPath>>;
|
|
105
108
|
};
|
|
106
|
-
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S,
|
|
109
|
+
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S, ShapeValue<S>>;
|
|
107
110
|
type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
|
|
108
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];
|
|
109
|
-
type VariantPath<T extends string, V extends VariantShape> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K> } & { readonly [K in T]: PathMarker<keyof V & string> } & PathMarker<
|
|
110
|
-
type
|
|
111
|
-
readonly optional: true;
|
|
112
|
-
} ? DocumentValueOfNode<N> | undefined : DocumentValueOfNode<N>;
|
|
113
|
-
type EntityPath<N extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = N extends ObjectNode<infer S> ? SchemaPathFor<S, PathNodeValue<N>> : N extends VariantNode<infer T, infer V> ? VariantPath<T, V> : never;
|
|
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
114
|
type CollectionPath<N extends EntitySchemaNode = EntitySchemaNode, TValue = unknown> = PathMarker<TValue> & {
|
|
115
115
|
readonly item: (id: string) => EntityPath<N>;
|
|
116
116
|
readonly [collectionNode]: N;
|
|
117
117
|
};
|
|
118
|
-
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>>;
|
|
119
119
|
type CollectionInfo<T> = T extends {
|
|
120
120
|
readonly [collectionNode]: infer TNode extends EntitySchemaNode;
|
|
121
121
|
} ? {
|
|
@@ -277,9 +277,7 @@ type TreeReader<T> = {
|
|
|
277
277
|
};
|
|
278
278
|
type ReaderOfNode<TNode extends DocumentNode> = TNode extends {
|
|
279
279
|
kind: 'field';
|
|
280
|
-
} ? FieldReader<
|
|
281
|
-
readonly optional: true;
|
|
282
|
-
} ? undefined : never)> : 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<DocumentValueOfNode<TNode>>;
|
|
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>>;
|
|
283
281
|
type DocumentReader<TSchema extends DocumentSchema> = ReaderOfNode<ObjectNode<TSchema['shape']>>;
|
|
284
282
|
//#endregion
|
|
285
283
|
//#region core/src/access/writer.d.ts
|
|
@@ -296,10 +294,10 @@ type DictionaryWriter<TKey extends string, TValue> = {
|
|
|
296
294
|
type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
297
295
|
readonly create: (entry: {
|
|
298
296
|
readonly id: TId;
|
|
299
|
-
readonly value:
|
|
297
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
300
298
|
} | readonly {
|
|
301
299
|
readonly id: TId;
|
|
302
|
-
readonly value:
|
|
300
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
303
301
|
}[], anchor?: DocumentAnchor) => void;
|
|
304
302
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
305
303
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -308,10 +306,10 @@ type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
|
308
306
|
type MapWriter<TId, TNode extends EntitySchemaNode> = {
|
|
309
307
|
readonly create: (entry: {
|
|
310
308
|
readonly id: TId;
|
|
311
|
-
readonly value:
|
|
309
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
312
310
|
} | readonly {
|
|
313
311
|
readonly id: TId;
|
|
314
|
-
readonly value:
|
|
312
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
315
313
|
}[]) => void;
|
|
316
314
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
317
315
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -344,9 +342,9 @@ type WriterOfNode<TNode extends DocumentNode> = TNode extends {
|
|
|
344
342
|
kind: 'field';
|
|
345
343
|
} ? TNode extends {
|
|
346
344
|
readonly optional: true;
|
|
347
|
-
} ? FieldWriter<
|
|
348
|
-
readonly replace: (value:
|
|
349
|
-
}> : 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<
|
|
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>>;
|
|
350
348
|
type DocumentWriter<TSchema extends DocumentSchema> = WriterOfNode<ObjectNode<TSchema['shape']>>;
|
|
351
349
|
//#endregion
|
|
352
350
|
//#region core/src/mutation/issue.d.ts
|
|
@@ -551,13 +549,13 @@ type DocumentRuntime<TSchema extends DocumentSchema> = DocumentReadable<TSchema>
|
|
|
551
549
|
readonly source?: Exclude<CommitSource, 'history'>;
|
|
552
550
|
readonly history?: boolean;
|
|
553
551
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
554
|
-
replace(document:
|
|
552
|
+
replace(document: Infer<TSchema>, options?: {
|
|
555
553
|
readonly source?: Extract<CommitSource, 'system' | 'remote'>;
|
|
556
554
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
557
|
-
snapshot():
|
|
555
|
+
snapshot(): Infer<TSchema>;
|
|
558
556
|
readonly history: LocalHistory<DocumentCommit<TSchema>>;
|
|
559
557
|
dispose(): void;
|
|
560
558
|
};
|
|
561
559
|
//#endregion
|
|
562
|
-
export { DocumentOperation as $,
|
|
563
|
-
//# 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-CIcftgR3.d.ts.map
|
|
@@ -58,17 +58,20 @@ type TreeNode<TValue> = BaseNode<'tree'> & {
|
|
|
58
58
|
readonly __value?: TValue;
|
|
59
59
|
};
|
|
60
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
|
|
62
|
-
|
|
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> ? {
|
|
63
67
|
readonly ids: readonly string[];
|
|
64
|
-
readonly byId: Readonly<Record<string,
|
|
65
|
-
} : 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;
|
|
66
70
|
type OptionalKeys<S extends ObjectShape> = { [K in keyof S]: S[K] extends {
|
|
67
71
|
readonly optional: true;
|
|
68
72
|
} ? K : never }[keyof S];
|
|
69
73
|
type RequiredKeys<S extends ObjectShape> = Exclude<keyof S, OptionalKeys<S>>;
|
|
70
|
-
type
|
|
71
|
-
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]> }>;
|
|
72
75
|
type EntitySchemaNode = ObjectNode<ObjectShape> | VariantNode<string, VariantShape>;
|
|
73
76
|
type CollectionSelector<TId extends string = string, TNode extends EntitySchemaNode = EntitySchemaNode> = {
|
|
74
77
|
readonly kind: 'collection';
|
|
@@ -103,19 +106,16 @@ type DocumentSchema<TShape extends ObjectShape = {}> = {
|
|
|
103
106
|
collection<TPath extends CollectionPath>(pick: (path: SchemaPath<TShape>) => TPath): CollectionSelector<CollectionId<TPath>, CollectionNode<TPath>>;
|
|
104
107
|
value<TPath extends PathMarker<unknown>>(pick: (path: SchemaPath<TShape>) => TPath): ValueSelector<PathValueResult<TPath>>;
|
|
105
108
|
};
|
|
106
|
-
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S,
|
|
109
|
+
type SchemaPath<S extends ObjectShape = {}> = SchemaPathFor<S, ShapeValue<S>>;
|
|
107
110
|
type VariantKeys<V extends VariantShape> = { [K in keyof V & string]: keyof (V[K] extends ObjectNode<infer S> ? S : {}) }[keyof V & string] & string;
|
|
108
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];
|
|
109
|
-
type VariantPath<T extends string, V extends VariantShape> = { readonly [K in VariantKeys<V>]: VariantFieldPath<V, K> } & { readonly [K in T]: PathMarker<keyof V & string> } & PathMarker<
|
|
110
|
-
type
|
|
111
|
-
readonly optional: true;
|
|
112
|
-
} ? DocumentValueOfNode<N> | undefined : DocumentValueOfNode<N>;
|
|
113
|
-
type EntityPath<N extends ObjectNode<ObjectShape> | VariantNode<string, VariantShape>> = N extends ObjectNode<infer S> ? SchemaPathFor<S, PathNodeValue<N>> : N extends VariantNode<infer T, infer V> ? VariantPath<T, V> : never;
|
|
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
114
|
type CollectionPath<N extends EntitySchemaNode = EntitySchemaNode, TValue = unknown> = PathMarker<TValue> & {
|
|
115
115
|
readonly item: (id: string) => EntityPath<N>;
|
|
116
116
|
readonly [collectionNode]: N;
|
|
117
117
|
};
|
|
118
|
-
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>>;
|
|
119
119
|
type CollectionInfo<T> = T extends {
|
|
120
120
|
readonly [collectionNode]: infer TNode extends EntitySchemaNode;
|
|
121
121
|
} ? {
|
|
@@ -277,9 +277,7 @@ type TreeReader<T> = {
|
|
|
277
277
|
};
|
|
278
278
|
type ReaderOfNode<TNode extends DocumentNode> = TNode extends {
|
|
279
279
|
kind: 'field';
|
|
280
|
-
} ? FieldReader<
|
|
281
|
-
readonly optional: true;
|
|
282
|
-
} ? undefined : never)> : 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<DocumentValueOfNode<TNode>>;
|
|
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>>;
|
|
283
281
|
type DocumentReader<TSchema extends DocumentSchema> = ReaderOfNode<ObjectNode<TSchema['shape']>>;
|
|
284
282
|
//#endregion
|
|
285
283
|
//#region core/src/access/writer.d.ts
|
|
@@ -296,10 +294,10 @@ type DictionaryWriter<TKey extends string, TValue> = {
|
|
|
296
294
|
type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
297
295
|
readonly create: (entry: {
|
|
298
296
|
readonly id: TId;
|
|
299
|
-
readonly value:
|
|
297
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
300
298
|
} | readonly {
|
|
301
299
|
readonly id: TId;
|
|
302
|
-
readonly value:
|
|
300
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
303
301
|
}[], anchor?: DocumentAnchor) => void;
|
|
304
302
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
305
303
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -308,10 +306,10 @@ type CollectionWriter<TId, TNode extends EntitySchemaNode> = {
|
|
|
308
306
|
type MapWriter<TId, TNode extends EntitySchemaNode> = {
|
|
309
307
|
readonly create: (entry: {
|
|
310
308
|
readonly id: TId;
|
|
311
|
-
readonly value:
|
|
309
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
312
310
|
} | readonly {
|
|
313
311
|
readonly id: TId;
|
|
314
|
-
readonly value:
|
|
312
|
+
readonly value: Exclude<Infer<TNode>, undefined>;
|
|
315
313
|
}[]) => void;
|
|
316
314
|
readonly item: (id: TId) => WriterOfNode<TNode>;
|
|
317
315
|
readonly remove: (id: TId | readonly TId[]) => void;
|
|
@@ -344,9 +342,9 @@ type WriterOfNode<TNode extends DocumentNode> = TNode extends {
|
|
|
344
342
|
kind: 'field';
|
|
345
343
|
} ? TNode extends {
|
|
346
344
|
readonly optional: true;
|
|
347
|
-
} ? FieldWriter<
|
|
348
|
-
readonly replace: (value:
|
|
349
|
-
}> : 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<
|
|
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>>;
|
|
350
348
|
type DocumentWriter<TSchema extends DocumentSchema> = WriterOfNode<ObjectNode<TSchema['shape']>>;
|
|
351
349
|
//#endregion
|
|
352
350
|
//#region core/src/mutation/issue.d.ts
|
|
@@ -551,13 +549,13 @@ type DocumentRuntime<TSchema extends DocumentSchema> = DocumentReadable<TSchema>
|
|
|
551
549
|
readonly source?: Exclude<CommitSource, 'history'>;
|
|
552
550
|
readonly history?: boolean;
|
|
553
551
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
554
|
-
replace(document:
|
|
552
|
+
replace(document: Infer<TSchema>, options?: {
|
|
555
553
|
readonly source?: Extract<CommitSource, 'system' | 'remote'>;
|
|
556
554
|
}): OperationResult<DocumentCommit<TSchema>>;
|
|
557
|
-
snapshot():
|
|
555
|
+
snapshot(): Infer<TSchema>;
|
|
558
556
|
readonly history: LocalHistory<DocumentCommit<TSchema>>;
|
|
559
557
|
dispose(): void;
|
|
560
558
|
};
|
|
561
559
|
//#endregion
|
|
562
|
-
export { DocumentOperation as $,
|
|
563
|
-
//# 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
|