@revisium/schema-toolkit 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -0
- package/dist/FormulaPathBuilder-BUJRR0Am.d.cts +48 -0
- package/dist/FormulaPathBuilder-QR0htn-e.d.ts +48 -0
- package/dist/chunk-2NARA22J.js +3 -0
- package/dist/{chunk-NY3H6C7K.js.map → chunk-2NARA22J.js.map} +1 -1
- package/dist/{chunk-EGC32GPY.cjs → chunk-3DDUT57J.cjs} +21 -21
- package/dist/chunk-3DDUT57J.cjs.map +1 -0
- package/dist/{chunk-LLHQWDAR.js → chunk-62A5JJJ3.js} +21 -21
- package/dist/chunk-62A5JJJ3.js.map +1 -0
- package/dist/{chunk-R4CFU33U.js → chunk-BIBFHULN.js} +12 -9
- package/dist/chunk-BIBFHULN.js.map +1 -0
- package/dist/chunk-BZWL424W.cjs +4 -0
- package/dist/{chunk-G6ZKEVVU.cjs.map → chunk-BZWL424W.cjs.map} +1 -1
- package/dist/{chunk-J6SCHJKG.cjs → chunk-CGVYS7EK.cjs} +2 -2
- package/dist/chunk-CGVYS7EK.cjs.map +1 -0
- package/dist/{chunk-MPF6VCB5.js → chunk-DRPNJ4YP.js} +2 -2
- package/dist/chunk-DRPNJ4YP.js.map +1 -0
- package/dist/{chunk-FZ2MS4Q5.cjs → chunk-F4POD7AE.cjs} +149 -90
- package/dist/chunk-F4POD7AE.cjs.map +1 -0
- package/dist/{chunk-B3T6YB2D.cjs → chunk-HH2LDPVV.cjs} +30 -30
- package/dist/chunk-HH2LDPVV.cjs.map +1 -0
- package/dist/{chunk-46ME2TAU.cjs → chunk-JWYYVKRT.cjs} +7 -7
- package/dist/{chunk-46ME2TAU.cjs.map → chunk-JWYYVKRT.cjs.map} +1 -1
- package/dist/{chunk-U5YDA3LA.js → chunk-MK3IKVZO.js} +80 -24
- package/dist/chunk-MK3IKVZO.js.map +1 -0
- package/dist/{chunk-VGADCIBG.cjs → chunk-SBO2UMI3.cjs} +14 -8
- package/dist/chunk-SBO2UMI3.cjs.map +1 -0
- package/dist/{chunk-55AMH44G.js → chunk-TKMR6CQW.js} +30 -30
- package/dist/chunk-TKMR6CQW.js.map +1 -0
- package/dist/{chunk-3JZKQWQH.js → chunk-TMCRV6V5.js} +7 -7
- package/dist/{chunk-3JZKQWQH.js.map → chunk-TMCRV6V5.js.map} +1 -1
- package/dist/{chunk-QEV4Q4TR.js → chunk-UTSL45Q4.js} +32 -32
- package/dist/chunk-UTSL45Q4.js.map +1 -0
- package/dist/{chunk-V6JTSET2.cjs → chunk-Z7M4ZGC6.cjs} +51 -51
- package/dist/chunk-Z7M4ZGC6.cjs.map +1 -0
- package/dist/core/index.cjs +60 -62
- package/dist/core/index.d.cts +6 -4
- package/dist/core/index.d.ts +6 -4
- package/dist/core/index.js +1 -3
- package/dist/formula/index.d.cts +1 -1
- package/dist/formula/index.d.ts +1 -1
- package/dist/index.cjs +237 -214
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +9 -10
- package/dist/{json-patch.types-DY7k9hxy.d.ts → json-patch.types-BpVnp08Z.d.ts} +1 -1
- package/dist/{json-patch.types-Cu0Medki.d.cts → json-patch.types-eM6pYC2P.d.cts} +1 -1
- package/dist/{json-string.store-C58zbl31.d.ts → json-string.store-DfdLcgnM.d.ts} +11 -11
- package/dist/{json-string.store-DuI--IL2.d.cts → json-string.store-cAOADo23.d.cts} +11 -11
- package/dist/lib/index.cjs +41 -42
- package/dist/lib/index.d.cts +3 -3
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +4 -5
- package/dist/mocks/index.cjs +30 -19
- package/dist/mocks/index.d.cts +22 -8
- package/dist/mocks/index.d.ts +22 -8
- package/dist/mocks/index.js +2 -3
- package/dist/model/index.cjs +85 -76
- package/dist/model/index.d.cts +158 -346
- package/dist/model/index.d.ts +158 -346
- package/dist/model/index.js +4 -7
- package/dist/plugins/index.cjs +19 -20
- package/dist/plugins/index.d.cts +10 -10
- package/dist/plugins/index.d.ts +10 -10
- package/dist/plugins/index.js +1 -2
- package/dist/{schema.types-B5OgKLpV.d.cts → schema.types-On_VGw2m.d.cts} +7 -6
- package/dist/{schema.types-B5OgKLpV.d.ts → schema.types-On_VGw2m.d.ts} +7 -6
- package/dist/typed-BinPIf3R.d.ts +455 -0
- package/dist/typed-LSaUJayS.d.cts +455 -0
- package/dist/types/index.cjs +5 -6
- package/dist/types/index.d.cts +7 -5
- package/dist/types/index.d.ts +7 -5
- package/dist/types/index.js +1 -2
- package/dist/{FormulaPathBuilder-DwlKOvVB.d.ts → types-BIvIURgy.d.cts} +37 -82
- package/dist/{FormulaPathBuilder-D9LkBcSv.d.cts → types-C_pTFtSY.d.ts} +37 -82
- package/package.json +1 -1
- package/dist/chunk-3IKI64T2.js +0 -3
- package/dist/chunk-3IKI64T2.js.map +0 -1
- package/dist/chunk-55AMH44G.js.map +0 -1
- package/dist/chunk-B3T6YB2D.cjs.map +0 -1
- package/dist/chunk-EGC32GPY.cjs.map +0 -1
- package/dist/chunk-FZ2MS4Q5.cjs.map +0 -1
- package/dist/chunk-G6ZKEVVU.cjs +0 -4
- package/dist/chunk-J6SCHJKG.cjs.map +0 -1
- package/dist/chunk-LLHQWDAR.js.map +0 -1
- package/dist/chunk-MPF6VCB5.js.map +0 -1
- package/dist/chunk-NY3H6C7K.js +0 -3
- package/dist/chunk-QEV4Q4TR.js.map +0 -1
- package/dist/chunk-R4CFU33U.js.map +0 -1
- package/dist/chunk-TBFTADML.cjs +0 -4
- package/dist/chunk-TBFTADML.cjs.map +0 -1
- package/dist/chunk-U5YDA3LA.js.map +0 -1
- package/dist/chunk-V6JTSET2.cjs.map +0 -1
- package/dist/chunk-VGADCIBG.cjs.map +0 -1
- package/dist/json-value-patch.types-CgiEpchp.d.ts +0 -24
- package/dist/json-value-patch.types-LEJxcIWR.d.cts +0 -24
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { j as SchemaNode, P as Path, h as NodeMetadata, f as SchemaValidationError, T as TreeFormulaValidationError, k as SchemaPatch, B as BasePath, p as BasePathSegment, D as Diagnostic } from './types-C_pTFtSY.js';
|
|
2
|
+
import { g as JsonObjectSchema, j as JsonSchema } from './schema.types-On_VGw2m.js';
|
|
3
|
+
import { h as JsonPatch } from './json-patch.types-BpVnp08Z.js';
|
|
4
|
+
import { c as JsonValue } from './json.types-PrMmLhba.js';
|
|
5
|
+
|
|
6
|
+
type JsonValuePatchMove = {
|
|
7
|
+
op: 'move';
|
|
8
|
+
from: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
type JsonValuePatchReplace = {
|
|
12
|
+
op: 'replace';
|
|
13
|
+
path: string;
|
|
14
|
+
value: JsonValue;
|
|
15
|
+
};
|
|
16
|
+
type JsonValuePatchRemove = {
|
|
17
|
+
op: 'remove';
|
|
18
|
+
path: string;
|
|
19
|
+
};
|
|
20
|
+
type JsonValuePatchAdd = {
|
|
21
|
+
op: 'add';
|
|
22
|
+
path: string;
|
|
23
|
+
value: JsonValue;
|
|
24
|
+
};
|
|
25
|
+
type JsonValuePatch = JsonValuePatchMove | JsonValuePatchReplace | JsonValuePatchRemove | JsonValuePatchAdd;
|
|
26
|
+
|
|
27
|
+
type PrimitiveTypeName = 'string' | 'number' | 'boolean';
|
|
28
|
+
type CompositeTypeName = 'object' | 'array';
|
|
29
|
+
type SimpleFieldType = PrimitiveTypeName | CompositeTypeName;
|
|
30
|
+
interface FieldSchemaSpec {
|
|
31
|
+
type?: SimpleFieldType;
|
|
32
|
+
$ref?: string;
|
|
33
|
+
default?: unknown;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
deprecated?: boolean;
|
|
37
|
+
foreignKey?: string;
|
|
38
|
+
'x-formula'?: {
|
|
39
|
+
expression: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
type FieldTypeSpec = SimpleFieldType | FieldSchemaSpec;
|
|
43
|
+
interface TransformContext {
|
|
44
|
+
sourceNode: SchemaNode;
|
|
45
|
+
targetSpec: FieldSchemaSpec;
|
|
46
|
+
refSchemas?: RefSchemas$1;
|
|
47
|
+
}
|
|
48
|
+
interface TransformResult {
|
|
49
|
+
node: SchemaNode;
|
|
50
|
+
}
|
|
51
|
+
interface TypeTransformer {
|
|
52
|
+
canTransform(ctx: TransformContext): boolean;
|
|
53
|
+
transform(ctx: TransformContext): TransformResult;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type RefSchemas$1 = Record<string, JsonSchema>;
|
|
57
|
+
interface SchemaModelOptions {
|
|
58
|
+
refSchemas?: RefSchemas$1;
|
|
59
|
+
customTransformers?: TypeTransformer[];
|
|
60
|
+
}
|
|
61
|
+
type FieldType = 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
62
|
+
|
|
63
|
+
interface ReplaceResult {
|
|
64
|
+
replacedNodeId: string;
|
|
65
|
+
newNodeId: string;
|
|
66
|
+
}
|
|
67
|
+
interface SchemaModel {
|
|
68
|
+
readonly root: SchemaNode;
|
|
69
|
+
nodeById(id: string): SchemaNode;
|
|
70
|
+
pathOf(id: string): Path;
|
|
71
|
+
addField(parentId: string, name: string, type: FieldType): SchemaNode;
|
|
72
|
+
insertFieldAt(parentId: string, index: number, name: string, type: FieldType): SchemaNode;
|
|
73
|
+
removeField(nodeId: string): boolean;
|
|
74
|
+
renameField(nodeId: string, newName: string): void;
|
|
75
|
+
changeFieldType(nodeId: string, newType: FieldTypeSpec): SchemaNode;
|
|
76
|
+
updateMetadata(nodeId: string, meta: Partial<NodeMetadata>): void;
|
|
77
|
+
updateFormula(nodeId: string, expression: string | undefined): void;
|
|
78
|
+
updateForeignKey(nodeId: string, foreignKey: string | undefined): void;
|
|
79
|
+
updateDefaultValue(nodeId: string, value: unknown): void;
|
|
80
|
+
wrapInArray(nodeId: string): ReplaceResult | null;
|
|
81
|
+
wrapRootInArray(): ReplaceResult | null;
|
|
82
|
+
replaceRoot(newType: FieldType): ReplaceResult | null;
|
|
83
|
+
canMoveNode(nodeId: string, targetParentId: string): boolean;
|
|
84
|
+
hasValidDropTarget(nodeId: string): boolean;
|
|
85
|
+
moveNode(nodeId: string, targetParentId: string): void;
|
|
86
|
+
getFormulaDependents(nodeId: string): readonly string[];
|
|
87
|
+
hasFormulaDependents(nodeId: string): boolean;
|
|
88
|
+
serializeFormula(nodeId: string): string;
|
|
89
|
+
readonly validationErrors: SchemaValidationError[];
|
|
90
|
+
readonly formulaErrors: TreeFormulaValidationError[];
|
|
91
|
+
readonly isDirty: boolean;
|
|
92
|
+
readonly isValid: boolean;
|
|
93
|
+
readonly patches: SchemaPatch[];
|
|
94
|
+
readonly jsonPatches: JsonPatch[];
|
|
95
|
+
markAsSaved(): void;
|
|
96
|
+
revert(): void;
|
|
97
|
+
readonly plainSchema: JsonObjectSchema;
|
|
98
|
+
readonly nodeCount: number;
|
|
99
|
+
readonly refSchemas: RefSchemas$1 | undefined;
|
|
100
|
+
generateDefaultValue(options?: {
|
|
101
|
+
arrayItemCount?: number;
|
|
102
|
+
}): unknown;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface ValuePathSegment extends BasePathSegment {
|
|
106
|
+
isProperty(): boolean;
|
|
107
|
+
isIndex(): boolean;
|
|
108
|
+
propertyName(): string;
|
|
109
|
+
indexValue(): number;
|
|
110
|
+
equals(other: ValuePathSegment): boolean;
|
|
111
|
+
}
|
|
112
|
+
interface ValuePath extends BasePath<ValuePathSegment, ValuePath> {
|
|
113
|
+
asString(): string;
|
|
114
|
+
asJsonPointer(): string;
|
|
115
|
+
child(name: string): ValuePath;
|
|
116
|
+
childIndex(index: number): ValuePath;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface BaseChange {
|
|
120
|
+
readonly path: ValuePath;
|
|
121
|
+
}
|
|
122
|
+
interface SetValueChange extends BaseChange {
|
|
123
|
+
readonly type: 'setValue';
|
|
124
|
+
readonly value: JsonValue;
|
|
125
|
+
readonly oldValue: JsonValue;
|
|
126
|
+
}
|
|
127
|
+
interface AddPropertyChange extends BaseChange {
|
|
128
|
+
readonly type: 'addProperty';
|
|
129
|
+
readonly value: JsonValue;
|
|
130
|
+
}
|
|
131
|
+
interface RemovePropertyChange extends BaseChange {
|
|
132
|
+
readonly type: 'removeProperty';
|
|
133
|
+
}
|
|
134
|
+
interface ArrayPushChange extends BaseChange {
|
|
135
|
+
readonly type: 'arrayPush';
|
|
136
|
+
readonly value: JsonValue;
|
|
137
|
+
}
|
|
138
|
+
interface ArrayInsertChange extends BaseChange {
|
|
139
|
+
readonly type: 'arrayInsert';
|
|
140
|
+
readonly index: number;
|
|
141
|
+
readonly value: JsonValue;
|
|
142
|
+
}
|
|
143
|
+
interface ArrayRemoveChange extends BaseChange {
|
|
144
|
+
readonly type: 'arrayRemove';
|
|
145
|
+
readonly index: number;
|
|
146
|
+
}
|
|
147
|
+
interface ArrayMoveChange extends BaseChange {
|
|
148
|
+
readonly type: 'arrayMove';
|
|
149
|
+
readonly fromIndex: number;
|
|
150
|
+
readonly toIndex: number;
|
|
151
|
+
}
|
|
152
|
+
interface ArrayReplaceChange extends BaseChange {
|
|
153
|
+
readonly type: 'arrayReplace';
|
|
154
|
+
readonly index: number;
|
|
155
|
+
readonly value: JsonValue;
|
|
156
|
+
}
|
|
157
|
+
interface ArrayClearChange extends BaseChange {
|
|
158
|
+
readonly type: 'arrayClear';
|
|
159
|
+
}
|
|
160
|
+
type Change = SetValueChange | AddPropertyChange | RemovePropertyChange | ArrayPushChange | ArrayInsertChange | ArrayRemoveChange | ArrayMoveChange | ArrayReplaceChange | ArrayClearChange;
|
|
161
|
+
interface ValueTreeLike {
|
|
162
|
+
readonly root: ValueNode;
|
|
163
|
+
get(path: string): ValueNode | undefined;
|
|
164
|
+
getValue(path: string): unknown;
|
|
165
|
+
setValue(path: string, value: unknown, options?: {
|
|
166
|
+
internal?: boolean;
|
|
167
|
+
}): void;
|
|
168
|
+
getPlainValue(): unknown;
|
|
169
|
+
readonly isDirty: boolean;
|
|
170
|
+
readonly isValid: boolean;
|
|
171
|
+
readonly errors: readonly Diagnostic[];
|
|
172
|
+
getPatches(): readonly JsonValuePatch[];
|
|
173
|
+
commit(): void;
|
|
174
|
+
revert(): void;
|
|
175
|
+
nodeById(id: string): ValueNode | undefined;
|
|
176
|
+
pathOf(nodeOrId: ValueNode | string): ValuePath;
|
|
177
|
+
dispose(): void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface RowModelOptions {
|
|
181
|
+
rowId: string;
|
|
182
|
+
schema: JsonSchema;
|
|
183
|
+
data?: unknown;
|
|
184
|
+
fkResolver?: ForeignKeyResolver;
|
|
185
|
+
refSchemas?: RefSchemas;
|
|
186
|
+
}
|
|
187
|
+
interface TableModelLike {
|
|
188
|
+
getRowIndex(rowId: string): number;
|
|
189
|
+
getRowAt(index: number): RowModel | undefined;
|
|
190
|
+
readonly rowCount: number;
|
|
191
|
+
}
|
|
192
|
+
interface RowModel {
|
|
193
|
+
readonly rowId: string;
|
|
194
|
+
readonly tableModel: TableModelLike | null;
|
|
195
|
+
readonly tree: ValueTreeLike;
|
|
196
|
+
readonly index: number;
|
|
197
|
+
readonly prev: RowModel | null;
|
|
198
|
+
readonly next: RowModel | null;
|
|
199
|
+
get(path: string): ValueNode | undefined;
|
|
200
|
+
getValue(path: string): unknown;
|
|
201
|
+
setValue(path: string, value: unknown): void;
|
|
202
|
+
getPlainValue(): unknown;
|
|
203
|
+
nodeById(id: string): ValueNode | undefined;
|
|
204
|
+
readonly isDirty: boolean;
|
|
205
|
+
readonly isValid: boolean;
|
|
206
|
+
readonly errors: readonly Diagnostic[];
|
|
207
|
+
getPatches(): readonly JsonValuePatch[];
|
|
208
|
+
commit(): void;
|
|
209
|
+
revert(): void;
|
|
210
|
+
dispose(): void;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface RowData {
|
|
214
|
+
rowId: string;
|
|
215
|
+
data: unknown;
|
|
216
|
+
}
|
|
217
|
+
interface TableModelOptions {
|
|
218
|
+
tableId: string;
|
|
219
|
+
schema: JsonObjectSchema;
|
|
220
|
+
rows?: RowData[];
|
|
221
|
+
fkResolver?: ForeignKeyResolver;
|
|
222
|
+
refSchemas?: RefSchemas;
|
|
223
|
+
}
|
|
224
|
+
interface TableModel {
|
|
225
|
+
readonly fk: ForeignKeyResolver | undefined;
|
|
226
|
+
readonly refSchemas: RefSchemas | undefined;
|
|
227
|
+
readonly tableId: string;
|
|
228
|
+
readonly baseTableId: string;
|
|
229
|
+
readonly isRenamed: boolean;
|
|
230
|
+
rename(newTableId: string): void;
|
|
231
|
+
readonly schema: SchemaModel;
|
|
232
|
+
readonly rows: readonly RowModel[];
|
|
233
|
+
readonly rowCount: number;
|
|
234
|
+
addRow(rowId: string, data?: unknown): RowModel;
|
|
235
|
+
removeRow(rowId: string): void;
|
|
236
|
+
getRow(rowId: string): RowModel | undefined;
|
|
237
|
+
getRowIndex(rowId: string): number;
|
|
238
|
+
getRowAt(index: number): RowModel | undefined;
|
|
239
|
+
readonly isDirty: boolean;
|
|
240
|
+
commit(): void;
|
|
241
|
+
revert(): void;
|
|
242
|
+
dispose(): void;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface ForeignKeyResolver {
|
|
246
|
+
addSchema(tableId: string, schema: JsonObjectSchema): void;
|
|
247
|
+
addTable(tableId: string, schema: JsonObjectSchema, rows: RowData[]): void;
|
|
248
|
+
addRow(tableId: string, rowId: string, data: unknown): void;
|
|
249
|
+
renameTable(oldTableId: string, newTableId: string): void;
|
|
250
|
+
getSchema(tableId: string): Promise<JsonObjectSchema>;
|
|
251
|
+
getRowData(tableId: string, rowId: string): Promise<RowData>;
|
|
252
|
+
isLoading(tableId: string): boolean;
|
|
253
|
+
isLoadingRow(tableId: string, rowId: string): boolean;
|
|
254
|
+
hasSchema(tableId: string): boolean;
|
|
255
|
+
hasTable(tableId: string): boolean;
|
|
256
|
+
hasRow(tableId: string, rowId: string): boolean;
|
|
257
|
+
setPrefetch(enabled: boolean): void;
|
|
258
|
+
readonly isPrefetchEnabled: boolean;
|
|
259
|
+
dispose(): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type NodeFactoryFn = (name: string, schema: JsonSchema, value: unknown, id?: string) => ValueNode;
|
|
263
|
+
declare class NodeFactoryRegistry {
|
|
264
|
+
private readonly factories;
|
|
265
|
+
register(schemaType: string, factory: NodeFactoryFn): this;
|
|
266
|
+
get(schemaType: string): NodeFactoryFn | undefined;
|
|
267
|
+
has(schemaType: string): boolean;
|
|
268
|
+
}
|
|
269
|
+
type RefSchemas = Record<string, JsonSchema>;
|
|
270
|
+
interface NodeFactoryOptions {
|
|
271
|
+
refSchemas?: RefSchemas;
|
|
272
|
+
fkResolver?: ForeignKeyResolver;
|
|
273
|
+
}
|
|
274
|
+
declare class NodeFactory {
|
|
275
|
+
private readonly registry;
|
|
276
|
+
private readonly refSchemas;
|
|
277
|
+
constructor(registry: NodeFactoryRegistry, options?: NodeFactoryOptions);
|
|
278
|
+
create(name: string, schema: JsonSchema, value: unknown, id?: string): ValueNode;
|
|
279
|
+
createTree(schema: JsonSchema, value: unknown): ValueNode;
|
|
280
|
+
private getSchemaType;
|
|
281
|
+
private resolveSchema;
|
|
282
|
+
}
|
|
283
|
+
declare function createDefaultRegistry(fkResolver?: ForeignKeyResolver): NodeFactoryRegistry;
|
|
284
|
+
declare function createNodeFactory(options?: NodeFactoryOptions): NodeFactory;
|
|
285
|
+
|
|
286
|
+
declare enum ValueType {
|
|
287
|
+
String = "string",
|
|
288
|
+
Number = "number",
|
|
289
|
+
Boolean = "boolean",
|
|
290
|
+
Object = "object",
|
|
291
|
+
Array = "array"
|
|
292
|
+
}
|
|
293
|
+
interface FormulaDefinition {
|
|
294
|
+
readonly expression: string;
|
|
295
|
+
readonly version: number;
|
|
296
|
+
}
|
|
297
|
+
interface FormulaWarning {
|
|
298
|
+
readonly type: 'nan' | 'infinity' | 'type-coercion' | 'division-by-zero' | 'null-reference' | 'runtime-error';
|
|
299
|
+
readonly message: string;
|
|
300
|
+
readonly expression: string;
|
|
301
|
+
readonly computedValue: unknown;
|
|
302
|
+
}
|
|
303
|
+
interface ValueNode {
|
|
304
|
+
readonly id: string;
|
|
305
|
+
readonly type: ValueType;
|
|
306
|
+
readonly schema: JsonSchema;
|
|
307
|
+
parent: ValueNode | null;
|
|
308
|
+
readonly name: string;
|
|
309
|
+
readonly value: unknown;
|
|
310
|
+
getPlainValue(): unknown;
|
|
311
|
+
isObject(): this is ObjectValueNode;
|
|
312
|
+
isArray(): this is ArrayValueNode;
|
|
313
|
+
isPrimitive(): this is PrimitiveValueNode;
|
|
314
|
+
readonly errors: readonly Diagnostic[];
|
|
315
|
+
readonly warnings: readonly Diagnostic[];
|
|
316
|
+
readonly isValid: boolean;
|
|
317
|
+
readonly hasWarnings: boolean;
|
|
318
|
+
}
|
|
319
|
+
interface DirtyTrackable {
|
|
320
|
+
readonly isDirty: boolean;
|
|
321
|
+
commit(): void;
|
|
322
|
+
revert(): void;
|
|
323
|
+
}
|
|
324
|
+
interface PrimitiveValueNode extends ValueNode, DirtyTrackable {
|
|
325
|
+
value: string | number | boolean;
|
|
326
|
+
readonly baseValue: string | number | boolean;
|
|
327
|
+
readonly defaultValue: unknown;
|
|
328
|
+
readonly formula: FormulaDefinition | undefined;
|
|
329
|
+
readonly formulaWarning: FormulaWarning | null;
|
|
330
|
+
readonly isReadOnly: boolean;
|
|
331
|
+
setValue(value: unknown, options?: {
|
|
332
|
+
internal?: boolean;
|
|
333
|
+
}): void;
|
|
334
|
+
setFormulaWarning(warning: FormulaWarning | null): void;
|
|
335
|
+
}
|
|
336
|
+
interface ObjectValueNode extends ValueNode, DirtyTrackable {
|
|
337
|
+
readonly value: Record<string, ValueNode>;
|
|
338
|
+
readonly children: readonly ValueNode[];
|
|
339
|
+
child(name: string): ValueNode | undefined;
|
|
340
|
+
addChild(node: ValueNode): void;
|
|
341
|
+
removeChild(name: string): void;
|
|
342
|
+
hasChild(name: string): boolean;
|
|
343
|
+
setValue(value: Record<string, unknown>, options?: {
|
|
344
|
+
internal?: boolean;
|
|
345
|
+
}): void;
|
|
346
|
+
}
|
|
347
|
+
interface ArrayValueNode extends ValueNode, DirtyTrackable {
|
|
348
|
+
readonly value: readonly ValueNode[];
|
|
349
|
+
readonly length: number;
|
|
350
|
+
at(index: number): ValueNode | undefined;
|
|
351
|
+
push(node: ValueNode): void;
|
|
352
|
+
insertAt(index: number, node: ValueNode): void;
|
|
353
|
+
removeAt(index: number): void;
|
|
354
|
+
move(fromIndex: number, toIndex: number): void;
|
|
355
|
+
replaceAt(index: number, node: ValueNode): void;
|
|
356
|
+
clear(): void;
|
|
357
|
+
setNodeFactory(factory: NodeFactory): void;
|
|
358
|
+
pushValue(value?: unknown): void;
|
|
359
|
+
insertValueAt(index: number, value?: unknown): void;
|
|
360
|
+
setValue(value: unknown[], options?: {
|
|
361
|
+
internal?: boolean;
|
|
362
|
+
}): void;
|
|
363
|
+
}
|
|
364
|
+
interface ValueNodeOptions {
|
|
365
|
+
readonly id?: string;
|
|
366
|
+
readonly name: string;
|
|
367
|
+
readonly schema: JsonSchema;
|
|
368
|
+
readonly parent?: ValueNode | null;
|
|
369
|
+
}
|
|
370
|
+
interface PrimitiveNodeOptions extends ValueNodeOptions {
|
|
371
|
+
readonly value?: unknown;
|
|
372
|
+
}
|
|
373
|
+
interface ObjectNodeOptions extends ValueNodeOptions {
|
|
374
|
+
readonly children?: ValueNode[];
|
|
375
|
+
}
|
|
376
|
+
interface ArrayNodeOptions extends ValueNodeOptions {
|
|
377
|
+
readonly items?: ValueNode[];
|
|
378
|
+
}
|
|
379
|
+
declare function extractFormulaDefinition(schema: JsonSchema): FormulaDefinition | undefined;
|
|
380
|
+
|
|
381
|
+
type SchemaType<S> = S extends {
|
|
382
|
+
readonly type: infer T;
|
|
383
|
+
} ? T : S extends {
|
|
384
|
+
type: infer T;
|
|
385
|
+
} ? T : never;
|
|
386
|
+
type SchemaProperties<S> = S extends {
|
|
387
|
+
readonly properties: infer P;
|
|
388
|
+
} ? P : S extends {
|
|
389
|
+
properties: infer P;
|
|
390
|
+
} ? P : never;
|
|
391
|
+
type SchemaItems<S> = S extends {
|
|
392
|
+
readonly items: infer I;
|
|
393
|
+
} ? I : S extends {
|
|
394
|
+
items: infer I;
|
|
395
|
+
} ? I : never;
|
|
396
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
397
|
+
type IsPrimitive<S> = IsNever<SchemaType<S>> extends true ? false : SchemaType<S> extends 'string' | 'number' | 'boolean' ? true : false;
|
|
398
|
+
type PrimitiveValue<T> = T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : never;
|
|
399
|
+
type InferValue<S> = IsNever<SchemaType<S>> extends true ? unknown : IsPrimitive<S> extends true ? PrimitiveValue<SchemaType<S>> : SchemaType<S> extends 'object' ? {
|
|
400
|
+
[K in keyof SchemaProperties<S>]: InferValue<SchemaProperties<S>[K]>;
|
|
401
|
+
} : SchemaType<S> extends 'array' ? InferValue<SchemaItems<S>>[] : unknown;
|
|
402
|
+
interface TypedPrimitiveValueNode<T extends string | number | boolean> extends PrimitiveValueNode {
|
|
403
|
+
readonly value: T;
|
|
404
|
+
readonly baseValue: T;
|
|
405
|
+
getPlainValue(): T;
|
|
406
|
+
setValue(value: T, options?: {
|
|
407
|
+
internal?: boolean;
|
|
408
|
+
}): void;
|
|
409
|
+
}
|
|
410
|
+
interface TypedObjectValueNode<P> extends ObjectValueNode {
|
|
411
|
+
child<K extends keyof P & string>(name: K): InferNode<P[K]>;
|
|
412
|
+
getPlainValue(): {
|
|
413
|
+
[K in keyof P]: InferValue<P[K]>;
|
|
414
|
+
};
|
|
415
|
+
setValue(value: Partial<{
|
|
416
|
+
[K in keyof P]: InferValue<P[K]>;
|
|
417
|
+
}>, options?: {
|
|
418
|
+
internal?: boolean;
|
|
419
|
+
}): void;
|
|
420
|
+
}
|
|
421
|
+
interface TypedArrayValueNode<I> extends ArrayValueNode {
|
|
422
|
+
at(index: number): InferNode<I> | undefined;
|
|
423
|
+
getPlainValue(): InferValue<I>[];
|
|
424
|
+
setValue(value: InferValue<I>[], options?: {
|
|
425
|
+
internal?: boolean;
|
|
426
|
+
}): void;
|
|
427
|
+
}
|
|
428
|
+
type PrimitiveNode<T> = T extends 'string' ? TypedPrimitiveValueNode<string> : T extends 'number' ? TypedPrimitiveValueNode<number> : T extends 'boolean' ? TypedPrimitiveValueNode<boolean> : never;
|
|
429
|
+
type InferNode<S> = IsNever<SchemaType<S>> extends true ? ValueNode : IsPrimitive<S> extends true ? PrimitiveNode<SchemaType<S>> : SchemaType<S> extends 'object' ? TypedObjectValueNode<SchemaProperties<S>> : SchemaType<S> extends 'array' ? TypedArrayValueNode<SchemaItems<S>> : ValueNode;
|
|
430
|
+
type SchemaPaths<S, Prefix extends string = ''> = IsPrimitive<S> extends true ? never : SchemaType<S> extends 'object' ? {
|
|
431
|
+
[K in keyof SchemaProperties<S> & string]: `${Prefix}${K}` | SchemaPaths<SchemaProperties<S>[K], `${Prefix}${K}.`>;
|
|
432
|
+
}[keyof SchemaProperties<S> & string] : SchemaType<S> extends 'array' ? `${Prefix}[${number}]` | SchemaPaths<SchemaItems<S>, `${Prefix}[${number}].`> : never;
|
|
433
|
+
type SchemaAtPath<S, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends `[${string}]` ? SchemaAtPath<SchemaItems<S>, Rest> : SchemaAtPath<Key extends keyof SchemaProperties<S> ? SchemaProperties<S>[Key] : never, Rest> : Path extends `[${string}]` ? SchemaItems<S> : Path extends keyof SchemaProperties<S> ? SchemaProperties<S>[Path] : never;
|
|
434
|
+
type NodeAtPath<S, Path extends string> = InferNode<SchemaAtPath<S, Path>>;
|
|
435
|
+
type ValueAtPath<S, Path extends string> = InferValue<SchemaAtPath<S, Path>>;
|
|
436
|
+
type SchemaFromPrimitive<T> = T extends string ? {
|
|
437
|
+
type: 'string';
|
|
438
|
+
} : T extends number ? {
|
|
439
|
+
type: 'number';
|
|
440
|
+
} : T extends boolean ? {
|
|
441
|
+
type: 'boolean';
|
|
442
|
+
} : never;
|
|
443
|
+
type SchemaFromValue<T> = T extends string | number | boolean ? SchemaFromPrimitive<T> : T extends (infer E)[] ? {
|
|
444
|
+
type: 'array';
|
|
445
|
+
items: SchemaFromValue<E>;
|
|
446
|
+
} : T extends Record<string, unknown> ? {
|
|
447
|
+
type: 'object';
|
|
448
|
+
properties: {
|
|
449
|
+
[K in keyof T]: SchemaFromValue<T[K]>;
|
|
450
|
+
};
|
|
451
|
+
} : never;
|
|
452
|
+
type NodeFromValue<T> = InferNode<SchemaFromValue<T>>;
|
|
453
|
+
type ValuePaths<T> = SchemaPaths<SchemaFromValue<T>>;
|
|
454
|
+
|
|
455
|
+
export { type FieldSchemaSpec as $, type ArrayValueNode as A, type SchemaModel as B, type FieldType as C, type DirtyTrackable as D, type FieldTypeSpec as E, type FormulaDefinition as F, type ReplaceResult as G, type SchemaModelOptions as H, type InferValue as I, type JsonValuePatchMove as J, type TableModel as K, type TableModelOptions as L, type RowData as M, type NodeAtPath as N, type ObjectValueNode as O, type PrimitiveValueNode as P, type RowModel as Q, type RefSchemas as R, type SchemaPaths as S, type TypedPrimitiveValueNode as T, type RowModelOptions as U, type ValueAtPath as V, type TableModelLike as W, type ForeignKeyResolver as X, type TypeTransformer as Y, type TransformContext as Z, type TransformResult as _, type JsonValuePatchReplace as a, type SimpleFieldType as a0, type PrimitiveTypeName as a1, type CompositeTypeName as a2, type RefSchemas$1 as a3, type ValuePath as a4, type Change as a5, type JsonValuePatchRemove as b, type JsonValuePatchAdd as c, type JsonValuePatch as d, type TypedObjectValueNode as e, type TypedArrayValueNode as f, type InferNode as g, type SchemaAtPath as h, type SchemaFromValue as i, type NodeFromValue as j, type ValuePaths as k, ValueType as l, extractFormulaDefinition as m, NodeFactoryRegistry as n, createNodeFactory as o, createDefaultRegistry as p, type ValueNode as q, type FormulaWarning as r, type ValueNodeOptions as s, type PrimitiveNodeOptions as t, type ObjectNodeOptions as u, type ArrayNodeOptions as v, type NodeFactoryFn as w, type NodeFactoryOptions as x, NodeFactory as y, type ValueTreeLike as z };
|