@revisium/schema-toolkit 0.14.3 → 0.16.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 +1 -1
- package/dist/FormulaValidator-CKE2kT4C.d.cts +10 -0
- package/dist/FormulaValidator-DGGmwqDQ.d.ts +10 -0
- package/dist/{chunk-DJ4JPKI4.js → chunk-2NRQPOQY.js} +126 -218
- package/dist/chunk-2NRQPOQY.js.map +1 -0
- package/dist/chunk-3IKI64T2.js +3 -0
- package/dist/{chunk-H7W4QNMA.js.map → chunk-3IKI64T2.js.map} +1 -1
- package/dist/{chunk-L5MLJEC7.js → chunk-CYTPQYVM.js} +2 -2
- package/dist/chunk-CYTPQYVM.js.map +1 -0
- package/dist/{chunk-B22UU3JK.cjs → chunk-GAPLSVZN.cjs} +2 -2
- package/dist/chunk-GAPLSVZN.cjs.map +1 -0
- package/dist/chunk-IWRV6QAD.cjs +2621 -0
- package/dist/chunk-IWRV6QAD.cjs.map +1 -0
- package/dist/chunk-LF6CGXRQ.js +2289 -0
- package/dist/chunk-LF6CGXRQ.js.map +1 -0
- package/dist/chunk-OR2I3XOQ.cjs +2320 -0
- package/dist/chunk-OR2I3XOQ.cjs.map +1 -0
- package/dist/chunk-S7GEDTSL.js +2569 -0
- package/dist/chunk-S7GEDTSL.js.map +1 -0
- package/dist/chunk-TBFTADML.cjs +4 -0
- package/dist/{chunk-ODCH3PP2.cjs.map → chunk-TBFTADML.cjs.map} +1 -1
- package/dist/chunk-WSPFHUHU.cjs +130 -0
- package/dist/chunk-WSPFHUHU.cjs.map +1 -0
- package/dist/{chunk-VX5C5YMF.cjs → chunk-XS47N22X.cjs} +125 -218
- package/dist/chunk-XS47N22X.cjs.map +1 -0
- package/dist/chunk-YFWOURZL.js +128 -0
- package/dist/chunk-YFWOURZL.js.map +1 -0
- package/dist/{chunk-KJCURW4D.js → chunk-ZBPUTF3Q.js} +3 -3
- package/dist/chunk-ZBPUTF3Q.js.map +1 -0
- package/dist/{chunk-GF3XXYOS.cjs → chunk-ZRNFSUOV.cjs} +3 -3
- package/dist/chunk-ZRNFSUOV.cjs.map +1 -0
- package/dist/computeValueDiff-CDwbNw8F.d.ts +5 -0
- package/dist/computeValueDiff-CNT84rwK.d.cts +5 -0
- package/dist/core/index.cjs +231 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +314 -0
- package/dist/core/index.d.ts +314 -0
- package/dist/core/index.js +29 -0
- package/dist/core/index.js.map +1 -0
- package/dist/formula/index.d.cts +1 -1
- package/dist/formula/index.d.ts +1 -1
- package/dist/index.cjs +182 -44
- package/dist/index.d.cts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +7 -5
- package/dist/{json-patch.types-CYt9TCu3.d.ts → json-patch.types-DTUHS9SV.d.ts} +1 -1
- package/dist/{json-patch.types-DUcWbQRY.d.cts → json-patch.types-eltVqnWC.d.cts} +1 -1
- package/dist/{json-string.store-CcZ197KO.d.cts → json-string.store-DKlkc1u_.d.cts} +1 -1
- package/dist/{json-string.store-DckDcMVN.d.ts → json-string.store-DMrHPJ3v.d.ts} +1 -1
- package/dist/json-value-patch.types-CjBpq5VF.d.cts +24 -0
- package/dist/json-value-patch.types-U2y_ugm1.d.ts +24 -0
- package/dist/lib/index.cjs +40 -39
- package/dist/lib/index.d.cts +6 -7
- package/dist/lib/index.d.ts +6 -7
- package/dist/lib/index.js +4 -3
- package/dist/mocks/index.cjs +1 -1
- package/dist/mocks/index.d.cts +2 -2
- package/dist/mocks/index.d.ts +2 -2
- package/dist/mocks/index.js +1 -1
- package/dist/model/index.cjs +125 -2
- package/dist/model/index.d.cts +596 -4
- package/dist/model/index.d.ts +596 -4
- package/dist/model/index.js +5 -2
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +25 -1
- package/dist/plugins/index.d.ts +25 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{schema.types-CLHMJmkJ.d.cts → schema.types-ZX5fUW1X.d.cts} +6 -0
- package/dist/{schema.types-CLHMJmkJ.d.ts → schema.types-ZX5fUW1X.d.ts} +6 -0
- package/dist/types/index.cjs +5 -5
- package/dist/types/index.d.cts +8 -29
- package/dist/types/index.d.ts +8 -29
- package/dist/types/index.js +3 -3
- package/dist/{value-diff.types-BRoI_kGE.d.cts → types-C_GxaUve.d.cts} +4 -4
- package/dist/{value-diff.types-BRoI_kGE.d.ts → types-C_GxaUve.d.ts} +4 -4
- package/dist/types-Cnfj5nLO.d.ts +198 -0
- package/dist/types-DMzUCve0.d.cts +198 -0
- package/package.json +14 -1
- package/dist/chunk-B22UU3JK.cjs.map +0 -1
- package/dist/chunk-DJ4JPKI4.js.map +0 -1
- package/dist/chunk-GF3XXYOS.cjs.map +0 -1
- package/dist/chunk-H7W4QNMA.js +0 -3
- package/dist/chunk-KJCURW4D.js.map +0 -1
- package/dist/chunk-L5MLJEC7.js.map +0 -1
- package/dist/chunk-ODCH3PP2.cjs +0 -4
- package/dist/chunk-SBJFTOWW.js +0 -3
- package/dist/chunk-SBJFTOWW.js.map +0 -1
- package/dist/chunk-VX5C5YMF.cjs.map +0 -1
- package/dist/chunk-XAFOMEOK.cjs +0 -4
- package/dist/chunk-XAFOMEOK.cjs.map +0 -1
package/dist/model/index.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { h as JsonSchemaStore } from '../json-string.store-
|
|
2
|
-
export { A as AddedPropertyEvent, C as ChangeNameEvent, f as JsonArrayStore, m as JsonArrayValueStore, b as JsonBooleanStore, k as JsonBooleanValueStore, a as JsonNumberStore, j as JsonNumberValueStore, c as JsonObjectStore, l as JsonObjectValueStore, g as JsonSchemaStorePrimitives, J as JsonStringStore, i as JsonStringValueStore, p as JsonValueStore, o as JsonValueStoreParent, n as JsonValueStorePrimitives, d as MigrateItemsEvent, M as MigratePropertyEvent, R as RemovedPropertyEvent, e as ReplaceItemsEvent } from '../json-string.store-
|
|
1
|
+
import { h as JsonSchemaStore } from '../json-string.store-DKlkc1u_.cjs';
|
|
2
|
+
export { A as AddedPropertyEvent, C as ChangeNameEvent, f as JsonArrayStore, m as JsonArrayValueStore, b as JsonBooleanStore, k as JsonBooleanValueStore, a as JsonNumberStore, j as JsonNumberValueStore, c as JsonObjectStore, l as JsonObjectValueStore, g as JsonSchemaStorePrimitives, J as JsonStringStore, i as JsonStringValueStore, p as JsonValueStore, o as JsonValueStoreParent, n as JsonValueStorePrimitives, d as MigrateItemsEvent, M as MigratePropertyEvent, R as RemovedPropertyEvent, e as ReplaceItemsEvent } from '../json-string.store-DKlkc1u_.cjs';
|
|
3
|
+
import { b as SchemaNode, P as Path, N as NodeMetadata, S as SchemaValidationError, F as FormulaValidationError, f as SchemaPatch, J as JsonPatch, R as ReactivityAdapter, c as SchemaTree, D as Diagnostic } from '../types-DMzUCve0.cjs';
|
|
4
|
+
import { f as JsonObjectSchema, i as JsonSchema } from '../schema.types-ZX5fUW1X.cjs';
|
|
5
|
+
import { d as JsonValuePatch } from '../json-value-patch.types-CjBpq5VF.cjs';
|
|
3
6
|
import 'node:events';
|
|
4
|
-
import '../schema.types-CLHMJmkJ.cjs';
|
|
5
7
|
import '../json.types-46Cq-WxU.cjs';
|
|
8
|
+
import '@revisium/formula';
|
|
6
9
|
|
|
7
10
|
declare const equal: (value: unknown) => unknown;
|
|
8
11
|
declare const fromNumberToString: (value: number, defaultValue?: string) => string;
|
|
@@ -20,4 +23,593 @@ declare const fromArrayToObject: (_value: unknown, defaultValue: unknown) => unk
|
|
|
20
23
|
declare const getTransformation: (from: JsonSchemaStore, to: JsonSchemaStore) => Transformation | undefined;
|
|
21
24
|
type Transformation = (value: unknown, defaultValue?: unknown) => unknown;
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
interface ReactivityOptions {
|
|
27
|
+
reactivity?: ReactivityAdapter;
|
|
28
|
+
}
|
|
29
|
+
type FieldType = 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
30
|
+
interface ReplaceResult {
|
|
31
|
+
replacedNodeId: string;
|
|
32
|
+
newNodeId: string;
|
|
33
|
+
}
|
|
34
|
+
interface SchemaModel {
|
|
35
|
+
root(): SchemaNode;
|
|
36
|
+
nodeById(id: string): SchemaNode;
|
|
37
|
+
pathOf(id: string): Path;
|
|
38
|
+
addField(parentId: string, name: string, type: FieldType): SchemaNode;
|
|
39
|
+
removeField(nodeId: string): boolean;
|
|
40
|
+
renameField(nodeId: string, newName: string): void;
|
|
41
|
+
changeFieldType(nodeId: string, newType: FieldType): SchemaNode;
|
|
42
|
+
updateMetadata(nodeId: string, meta: Partial<NodeMetadata>): void;
|
|
43
|
+
updateFormula(nodeId: string, expression: string | undefined): void;
|
|
44
|
+
updateForeignKey(nodeId: string, foreignKey: string | undefined): void;
|
|
45
|
+
updateDefaultValue(nodeId: string, value: unknown): void;
|
|
46
|
+
wrapInArray(nodeId: string): ReplaceResult | null;
|
|
47
|
+
wrapRootInArray(): ReplaceResult | null;
|
|
48
|
+
replaceRoot(newType: FieldType): ReplaceResult | null;
|
|
49
|
+
canMoveNode(nodeId: string, targetParentId: string): boolean;
|
|
50
|
+
hasValidDropTarget(nodeId: string): boolean;
|
|
51
|
+
getFormulaDependents(nodeId: string): readonly string[];
|
|
52
|
+
hasFormulaDependents(nodeId: string): boolean;
|
|
53
|
+
getValidationErrors(): SchemaValidationError[];
|
|
54
|
+
getFormulaErrors(): FormulaValidationError[];
|
|
55
|
+
isDirty(): boolean;
|
|
56
|
+
isValid(): boolean;
|
|
57
|
+
getPatches(): SchemaPatch[];
|
|
58
|
+
getJsonPatches(): JsonPatch[];
|
|
59
|
+
markAsSaved(): void;
|
|
60
|
+
revert(): void;
|
|
61
|
+
getPlainSchema(): JsonObjectSchema;
|
|
62
|
+
generateDefaultValue(options?: {
|
|
63
|
+
arrayItemCount?: number;
|
|
64
|
+
}): unknown;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare function createSchemaModel(schema: JsonObjectSchema, options?: ReactivityOptions): SchemaModel;
|
|
68
|
+
|
|
69
|
+
declare class SchemaParser {
|
|
70
|
+
private pendingFormulas;
|
|
71
|
+
parse(schema: JsonObjectSchema): SchemaNode;
|
|
72
|
+
parseFormulas(tree: SchemaTree): void;
|
|
73
|
+
private parseNode;
|
|
74
|
+
private parseObject;
|
|
75
|
+
private parseArray;
|
|
76
|
+
private parseString;
|
|
77
|
+
private parseNumber;
|
|
78
|
+
private parseBoolean;
|
|
79
|
+
private extractMetadata;
|
|
80
|
+
private collectFormula;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class NodeFactory$1 {
|
|
84
|
+
createNode(name: string, type: FieldType): SchemaNode;
|
|
85
|
+
private createArrayNode;
|
|
86
|
+
createArrayNodeWithItems(name: string, items: SchemaNode): SchemaNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface RowData {
|
|
90
|
+
rowId: string;
|
|
91
|
+
data: unknown;
|
|
92
|
+
}
|
|
93
|
+
interface TableModelOptions {
|
|
94
|
+
tableId: string;
|
|
95
|
+
schema: JsonObjectSchema;
|
|
96
|
+
rows?: RowData[];
|
|
97
|
+
fkResolver?: ForeignKeyResolver;
|
|
98
|
+
}
|
|
99
|
+
interface TableModel {
|
|
100
|
+
readonly fk: ForeignKeyResolver | undefined;
|
|
101
|
+
readonly tableId: string;
|
|
102
|
+
readonly baseTableId: string;
|
|
103
|
+
readonly isRenamed: boolean;
|
|
104
|
+
rename(newTableId: string): void;
|
|
105
|
+
readonly schema: SchemaModel;
|
|
106
|
+
readonly rows: readonly RowModel[];
|
|
107
|
+
readonly rowCount: number;
|
|
108
|
+
addRow(rowId: string, data?: unknown): RowModel;
|
|
109
|
+
removeRow(rowId: string): void;
|
|
110
|
+
getRow(rowId: string): RowModel | undefined;
|
|
111
|
+
getRowIndex(rowId: string): number;
|
|
112
|
+
getRowAt(index: number): RowModel | undefined;
|
|
113
|
+
readonly isDirty: boolean;
|
|
114
|
+
commit(): void;
|
|
115
|
+
revert(): void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface ForeignKeyLoaderResult {
|
|
119
|
+
schema: JsonObjectSchema;
|
|
120
|
+
rows: RowData[];
|
|
121
|
+
}
|
|
122
|
+
interface ForeignKeyRowLoaderResult {
|
|
123
|
+
schema: JsonObjectSchema;
|
|
124
|
+
row: RowData;
|
|
125
|
+
}
|
|
126
|
+
interface ForeignKeyLoader {
|
|
127
|
+
loadSchema(tableId: string): Promise<JsonObjectSchema>;
|
|
128
|
+
loadTable(tableId: string): Promise<ForeignKeyLoaderResult>;
|
|
129
|
+
loadRow(tableId: string, rowId: string): Promise<ForeignKeyRowLoaderResult>;
|
|
130
|
+
}
|
|
131
|
+
interface ForeignKeyResolverOptions {
|
|
132
|
+
reactivity?: ReactivityAdapter;
|
|
133
|
+
loader?: ForeignKeyLoader;
|
|
134
|
+
prefetch?: boolean;
|
|
135
|
+
prefetchDepth?: 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface ForeignKeyResolver {
|
|
139
|
+
addSchema(tableId: string, schema: JsonObjectSchema): void;
|
|
140
|
+
addTable(tableId: string, schema: JsonObjectSchema, rows: RowData[]): void;
|
|
141
|
+
addRow(tableId: string, rowId: string, data: unknown): void;
|
|
142
|
+
renameTable(oldTableId: string, newTableId: string): void;
|
|
143
|
+
getSchema(tableId: string): Promise<JsonObjectSchema>;
|
|
144
|
+
getRowData(tableId: string, rowId: string): Promise<RowData>;
|
|
145
|
+
isLoading(tableId: string): boolean;
|
|
146
|
+
isLoadingRow(tableId: string, rowId: string): boolean;
|
|
147
|
+
hasSchema(tableId: string): boolean;
|
|
148
|
+
hasTable(tableId: string): boolean;
|
|
149
|
+
hasRow(tableId: string, rowId: string): boolean;
|
|
150
|
+
setPrefetch(enabled: boolean): void;
|
|
151
|
+
readonly isPrefetchEnabled: boolean;
|
|
152
|
+
dispose(): void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
type NodeFactoryFn = (name: string, schema: JsonSchema, value: unknown, id?: string) => ValueNode;
|
|
156
|
+
declare class NodeFactoryRegistry {
|
|
157
|
+
private readonly factories;
|
|
158
|
+
register(schemaType: string, factory: NodeFactoryFn): this;
|
|
159
|
+
get(schemaType: string): NodeFactoryFn | undefined;
|
|
160
|
+
has(schemaType: string): boolean;
|
|
161
|
+
}
|
|
162
|
+
type RefSchemas = Record<string, JsonSchema>;
|
|
163
|
+
interface NodeFactoryOptions {
|
|
164
|
+
refSchemas?: RefSchemas;
|
|
165
|
+
reactivity?: ReactivityAdapter;
|
|
166
|
+
fkResolver?: ForeignKeyResolver;
|
|
167
|
+
}
|
|
168
|
+
declare class NodeFactory {
|
|
169
|
+
private readonly registry;
|
|
170
|
+
private readonly refSchemas;
|
|
171
|
+
constructor(registry: NodeFactoryRegistry, options?: NodeFactoryOptions);
|
|
172
|
+
create(name: string, schema: JsonSchema, value: unknown, id?: string): ValueNode;
|
|
173
|
+
createTree(schema: JsonSchema, value: unknown): ValueNode;
|
|
174
|
+
private getSchemaType;
|
|
175
|
+
private resolveSchema;
|
|
176
|
+
}
|
|
177
|
+
declare function createDefaultRegistry(reactivity?: ReactivityAdapter, fkResolver?: ForeignKeyResolver): NodeFactoryRegistry;
|
|
178
|
+
declare function createNodeFactory(options?: NodeFactoryOptions): NodeFactory;
|
|
179
|
+
|
|
180
|
+
declare enum ValueType {
|
|
181
|
+
String = "string",
|
|
182
|
+
Number = "number",
|
|
183
|
+
Boolean = "boolean",
|
|
184
|
+
Object = "object",
|
|
185
|
+
Array = "array"
|
|
186
|
+
}
|
|
187
|
+
interface FormulaDefinition {
|
|
188
|
+
readonly expression: string;
|
|
189
|
+
readonly version: number;
|
|
190
|
+
}
|
|
191
|
+
interface FormulaWarning {
|
|
192
|
+
readonly type: 'nan' | 'infinity' | 'type-coercion' | 'division-by-zero' | 'null-reference' | 'runtime-error';
|
|
193
|
+
readonly message: string;
|
|
194
|
+
readonly expression: string;
|
|
195
|
+
readonly computedValue: unknown;
|
|
196
|
+
}
|
|
197
|
+
interface ValueNode {
|
|
198
|
+
readonly id: string;
|
|
199
|
+
readonly type: ValueType;
|
|
200
|
+
readonly schema: JsonSchema;
|
|
201
|
+
parent: ValueNode | null;
|
|
202
|
+
readonly name: string;
|
|
203
|
+
readonly value: unknown;
|
|
204
|
+
getPlainValue(): unknown;
|
|
205
|
+
isObject(): this is ObjectValueNode$1;
|
|
206
|
+
isArray(): this is ArrayValueNode$1;
|
|
207
|
+
isPrimitive(): this is PrimitiveValueNode;
|
|
208
|
+
readonly errors: readonly Diagnostic[];
|
|
209
|
+
readonly warnings: readonly Diagnostic[];
|
|
210
|
+
readonly isValid: boolean;
|
|
211
|
+
readonly hasWarnings: boolean;
|
|
212
|
+
}
|
|
213
|
+
interface DirtyTrackable {
|
|
214
|
+
readonly isDirty: boolean;
|
|
215
|
+
commit(): void;
|
|
216
|
+
revert(): void;
|
|
217
|
+
}
|
|
218
|
+
interface PrimitiveValueNode extends ValueNode, DirtyTrackable {
|
|
219
|
+
value: string | number | boolean;
|
|
220
|
+
readonly baseValue: string | number | boolean;
|
|
221
|
+
readonly defaultValue: unknown;
|
|
222
|
+
readonly formula: FormulaDefinition | undefined;
|
|
223
|
+
readonly formulaWarning: FormulaWarning | null;
|
|
224
|
+
readonly isReadOnly: boolean;
|
|
225
|
+
setValue(value: unknown, options?: {
|
|
226
|
+
internal?: boolean;
|
|
227
|
+
}): void;
|
|
228
|
+
setFormulaWarning(warning: FormulaWarning | null): void;
|
|
229
|
+
}
|
|
230
|
+
interface ObjectValueNode$1 extends ValueNode, DirtyTrackable {
|
|
231
|
+
readonly value: Record<string, ValueNode>;
|
|
232
|
+
readonly children: readonly ValueNode[];
|
|
233
|
+
child(name: string): ValueNode | undefined;
|
|
234
|
+
addChild(node: ValueNode): void;
|
|
235
|
+
removeChild(name: string): void;
|
|
236
|
+
hasChild(name: string): boolean;
|
|
237
|
+
}
|
|
238
|
+
interface ArrayValueNode$1 extends ValueNode, DirtyTrackable {
|
|
239
|
+
readonly value: readonly ValueNode[];
|
|
240
|
+
readonly length: number;
|
|
241
|
+
at(index: number): ValueNode | undefined;
|
|
242
|
+
push(node: ValueNode): void;
|
|
243
|
+
insertAt(index: number, node: ValueNode): void;
|
|
244
|
+
removeAt(index: number): void;
|
|
245
|
+
move(fromIndex: number, toIndex: number): void;
|
|
246
|
+
replaceAt(index: number, node: ValueNode): void;
|
|
247
|
+
clear(): void;
|
|
248
|
+
setNodeFactory(factory: NodeFactory): void;
|
|
249
|
+
pushValue(value?: unknown): void;
|
|
250
|
+
insertValueAt(index: number, value?: unknown): void;
|
|
251
|
+
}
|
|
252
|
+
interface ValueNodeOptions {
|
|
253
|
+
readonly id?: string;
|
|
254
|
+
readonly name: string;
|
|
255
|
+
readonly schema: JsonSchema;
|
|
256
|
+
readonly parent?: ValueNode | null;
|
|
257
|
+
}
|
|
258
|
+
interface PrimitiveNodeOptions extends ValueNodeOptions {
|
|
259
|
+
readonly value?: unknown;
|
|
260
|
+
}
|
|
261
|
+
interface ObjectNodeOptions extends ValueNodeOptions {
|
|
262
|
+
readonly children?: ValueNode[];
|
|
263
|
+
}
|
|
264
|
+
interface ArrayNodeOptions extends ValueNodeOptions {
|
|
265
|
+
readonly items?: ValueNode[];
|
|
266
|
+
}
|
|
267
|
+
declare function extractFormulaDefinition(schema: JsonSchema): FormulaDefinition | undefined;
|
|
268
|
+
|
|
269
|
+
interface ValueTreeLike {
|
|
270
|
+
readonly root: ValueNode;
|
|
271
|
+
get(path: string): ValueNode | undefined;
|
|
272
|
+
getValue(path: string): unknown;
|
|
273
|
+
setValue(path: string, value: unknown): void;
|
|
274
|
+
getPlainValue(): unknown;
|
|
275
|
+
readonly isDirty: boolean;
|
|
276
|
+
readonly isValid: boolean;
|
|
277
|
+
readonly errors: readonly Diagnostic[];
|
|
278
|
+
getPatches(): readonly JsonValuePatch[];
|
|
279
|
+
commit(): void;
|
|
280
|
+
revert(): void;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface TableModelLike {
|
|
284
|
+
getRowIndex(rowId: string): number;
|
|
285
|
+
getRowAt(index: number): RowModel | undefined;
|
|
286
|
+
readonly rowCount: number;
|
|
287
|
+
}
|
|
288
|
+
interface RowModel {
|
|
289
|
+
readonly rowId: string;
|
|
290
|
+
readonly tableModel: TableModelLike | null;
|
|
291
|
+
readonly tree: ValueTreeLike;
|
|
292
|
+
readonly index: number;
|
|
293
|
+
readonly prev: RowModel | null;
|
|
294
|
+
readonly next: RowModel | null;
|
|
295
|
+
get(path: string): ValueNode | undefined;
|
|
296
|
+
getValue(path: string): unknown;
|
|
297
|
+
setValue(path: string, value: unknown): void;
|
|
298
|
+
getPlainValue(): unknown;
|
|
299
|
+
readonly isDirty: boolean;
|
|
300
|
+
readonly isValid: boolean;
|
|
301
|
+
readonly errors: readonly Diagnostic[];
|
|
302
|
+
getPatches(): readonly JsonValuePatch[];
|
|
303
|
+
commit(): void;
|
|
304
|
+
revert(): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare class RowModelImpl implements RowModel {
|
|
308
|
+
private readonly _rowId;
|
|
309
|
+
private readonly _tree;
|
|
310
|
+
private readonly _reactivity?;
|
|
311
|
+
private _tableModel;
|
|
312
|
+
constructor(_rowId: string, _tree: ValueTreeLike, _reactivity?: ReactivityAdapter | undefined);
|
|
313
|
+
private initObservable;
|
|
314
|
+
get rowId(): string;
|
|
315
|
+
get tableModel(): TableModelLike | null;
|
|
316
|
+
get tree(): ValueTreeLike;
|
|
317
|
+
get index(): number;
|
|
318
|
+
get prev(): RowModel | null;
|
|
319
|
+
get next(): RowModel | null;
|
|
320
|
+
get(path: string): ValueNode | undefined;
|
|
321
|
+
getValue(path: string): unknown;
|
|
322
|
+
setValue(path: string, value: unknown): void;
|
|
323
|
+
getPlainValue(): unknown;
|
|
324
|
+
get isDirty(): boolean;
|
|
325
|
+
get isValid(): boolean;
|
|
326
|
+
get errors(): readonly Diagnostic[];
|
|
327
|
+
getPatches(): readonly JsonValuePatch[];
|
|
328
|
+
commit(): void;
|
|
329
|
+
revert(): void;
|
|
330
|
+
setTableModel(tableModel: TableModelLike | null): void;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare class TableModelImpl implements TableModel {
|
|
334
|
+
private _tableId;
|
|
335
|
+
private _baseTableId;
|
|
336
|
+
private readonly _schema;
|
|
337
|
+
private readonly _rows;
|
|
338
|
+
private readonly _jsonSchema;
|
|
339
|
+
private readonly _reactivity;
|
|
340
|
+
private readonly _fkResolver;
|
|
341
|
+
constructor(options: TableModelOptions, reactivity?: ReactivityAdapter);
|
|
342
|
+
private initObservable;
|
|
343
|
+
get tableId(): string;
|
|
344
|
+
get baseTableId(): string;
|
|
345
|
+
get isRenamed(): boolean;
|
|
346
|
+
get fk(): ForeignKeyResolver | undefined;
|
|
347
|
+
get schema(): SchemaModel;
|
|
348
|
+
get rows(): readonly RowModel[];
|
|
349
|
+
get rowCount(): number;
|
|
350
|
+
rename(newTableId: string): void;
|
|
351
|
+
addRow(rowId: string, data?: unknown): RowModel;
|
|
352
|
+
removeRow(rowId: string): void;
|
|
353
|
+
getRow(rowId: string): RowModel | undefined;
|
|
354
|
+
getRowIndex(rowId: string): number;
|
|
355
|
+
getRowAt(index: number): RowModel | undefined;
|
|
356
|
+
get isDirty(): boolean;
|
|
357
|
+
commit(): void;
|
|
358
|
+
revert(): void;
|
|
359
|
+
private createRowModel;
|
|
360
|
+
}
|
|
361
|
+
declare function createTableModel(options: TableModelOptions, reactivity?: ReactivityAdapter): TableModel;
|
|
362
|
+
|
|
363
|
+
interface GenerateDefaultValueOptions {
|
|
364
|
+
arrayItemCount?: number;
|
|
365
|
+
refSchemas?: Record<string, JsonSchema>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
declare function generateDefaultValue(schema: JsonSchema | null | undefined, options?: GenerateDefaultValueOptions): unknown;
|
|
369
|
+
|
|
370
|
+
declare class ForeignKeyResolverImpl implements ForeignKeyResolver {
|
|
371
|
+
private readonly _schemaCache;
|
|
372
|
+
private readonly _tableCache;
|
|
373
|
+
private readonly _loadingTables;
|
|
374
|
+
private readonly _loadingRows;
|
|
375
|
+
private readonly _pendingTableLoads;
|
|
376
|
+
private readonly _pendingRowLoads;
|
|
377
|
+
private _prefetchEnabled;
|
|
378
|
+
private _disposed;
|
|
379
|
+
private readonly loader;
|
|
380
|
+
private readonly reactivity;
|
|
381
|
+
constructor(options?: ForeignKeyResolverOptions);
|
|
382
|
+
private initObservable;
|
|
383
|
+
get isPrefetchEnabled(): boolean;
|
|
384
|
+
setPrefetch(enabled: boolean): void;
|
|
385
|
+
hasSchema(tableId: string): boolean;
|
|
386
|
+
hasTable(tableId: string): boolean;
|
|
387
|
+
hasRow(tableId: string, rowId: string): boolean;
|
|
388
|
+
isLoading(tableId: string): boolean;
|
|
389
|
+
isLoadingRow(tableId: string, rowId: string): boolean;
|
|
390
|
+
addSchema(tableId: string, schema: JsonObjectSchema): void;
|
|
391
|
+
addTable(tableId: string, schema: JsonObjectSchema, rows: RowData[]): void;
|
|
392
|
+
addRow(tableId: string, rowId: string, data: unknown): void;
|
|
393
|
+
renameTable(oldTableId: string, newTableId: string): void;
|
|
394
|
+
getSchema(tableId: string): Promise<JsonObjectSchema>;
|
|
395
|
+
getRowData(tableId: string, rowId: string): Promise<RowData>;
|
|
396
|
+
dispose(): void;
|
|
397
|
+
private loadSchemaInternal;
|
|
398
|
+
private loadRowInternal;
|
|
399
|
+
private ensureTableCache;
|
|
400
|
+
private markRowAsLoading;
|
|
401
|
+
private clearRowLoading;
|
|
402
|
+
private setPendingRowLoad;
|
|
403
|
+
private clearPendingRowLoad;
|
|
404
|
+
private prefetchForeignKeysFromTable;
|
|
405
|
+
private prefetchForeignKeysFromRow;
|
|
406
|
+
private prefetchRow;
|
|
407
|
+
private extractForeignKeys;
|
|
408
|
+
private getForeignKeyFromSchema;
|
|
409
|
+
}
|
|
410
|
+
declare function createForeignKeyResolver(options?: ForeignKeyResolverOptions): ForeignKeyResolver;
|
|
411
|
+
|
|
412
|
+
declare class ForeignKeyNotFoundError extends Error {
|
|
413
|
+
readonly tableId: string;
|
|
414
|
+
readonly rowId?: string | undefined;
|
|
415
|
+
constructor(tableId: string, rowId?: string | undefined);
|
|
416
|
+
}
|
|
417
|
+
declare class ForeignKeyResolverNotConfiguredError extends Error {
|
|
418
|
+
constructor();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
interface DataModel {
|
|
422
|
+
readonly fk: ForeignKeyResolver;
|
|
423
|
+
addTable(tableId: string, schema: JsonObjectSchema, rows?: RowData[]): TableModel;
|
|
424
|
+
getTable(tableId: string): TableModel | undefined;
|
|
425
|
+
removeTable(tableId: string): void;
|
|
426
|
+
renameTable(oldTableId: string, newTableId: string): void;
|
|
427
|
+
hasTable(tableId: string): boolean;
|
|
428
|
+
readonly tables: readonly TableModel[];
|
|
429
|
+
readonly tableIds: readonly string[];
|
|
430
|
+
readonly isDirty: boolean;
|
|
431
|
+
commit(): void;
|
|
432
|
+
revert(): void;
|
|
433
|
+
dispose(): void;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
interface DataModelOptions {
|
|
437
|
+
reactivity?: ReactivityAdapter;
|
|
438
|
+
fkResolver?: ForeignKeyResolver;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
declare class DataModelImpl implements DataModel {
|
|
442
|
+
private readonly _tables;
|
|
443
|
+
private readonly _fk;
|
|
444
|
+
private readonly _ownsFkResolver;
|
|
445
|
+
private readonly _reactivity;
|
|
446
|
+
constructor(options?: DataModelOptions);
|
|
447
|
+
private initObservable;
|
|
448
|
+
get fk(): ForeignKeyResolver;
|
|
449
|
+
get tables(): readonly TableModel[];
|
|
450
|
+
get tableIds(): readonly string[];
|
|
451
|
+
get isDirty(): boolean;
|
|
452
|
+
hasTable(tableId: string): boolean;
|
|
453
|
+
getTable(tableId: string): TableModel | undefined;
|
|
454
|
+
addTable(tableId: string, schema: JsonObjectSchema, rows?: RowData[]): TableModel;
|
|
455
|
+
removeTable(tableId: string): void;
|
|
456
|
+
renameTable(oldTableId: string, newTableId: string): void;
|
|
457
|
+
commit(): void;
|
|
458
|
+
revert(): void;
|
|
459
|
+
dispose(): void;
|
|
460
|
+
}
|
|
461
|
+
declare function createDataModel(options?: DataModelOptions): DataModel;
|
|
462
|
+
|
|
463
|
+
declare function generateNodeId(): string;
|
|
464
|
+
declare function resetNodeIdCounter(): void;
|
|
465
|
+
declare abstract class BaseValueNode implements ValueNode {
|
|
466
|
+
readonly id: string;
|
|
467
|
+
abstract readonly type: ValueType;
|
|
468
|
+
readonly schema: JsonSchema;
|
|
469
|
+
private _parent;
|
|
470
|
+
private readonly _name;
|
|
471
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema);
|
|
472
|
+
get parent(): ValueNode | null;
|
|
473
|
+
set parent(value: ValueNode | null);
|
|
474
|
+
get name(): string;
|
|
475
|
+
abstract get value(): unknown;
|
|
476
|
+
abstract getPlainValue(): unknown;
|
|
477
|
+
isObject(): this is ObjectValueNode$1;
|
|
478
|
+
isArray(): this is ArrayValueNode$1;
|
|
479
|
+
isPrimitive(): this is PrimitiveValueNode;
|
|
480
|
+
get errors(): readonly Diagnostic[];
|
|
481
|
+
get warnings(): readonly Diagnostic[];
|
|
482
|
+
get isValid(): boolean;
|
|
483
|
+
get hasWarnings(): boolean;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
declare abstract class BasePrimitiveValueNode<T extends string | number | boolean> extends BaseValueNode implements PrimitiveValueNode {
|
|
487
|
+
protected readonly reactivity?: ReactivityAdapter | undefined;
|
|
488
|
+
protected _value: T;
|
|
489
|
+
protected _baseValue: T;
|
|
490
|
+
protected _formulaWarning: FormulaWarning | null;
|
|
491
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, value: T | undefined, defaultValue: T, reactivity?: ReactivityAdapter | undefined);
|
|
492
|
+
protected initObservable(): void;
|
|
493
|
+
get value(): T;
|
|
494
|
+
set value(newValue: T);
|
|
495
|
+
get baseValue(): T;
|
|
496
|
+
get isDirty(): boolean;
|
|
497
|
+
abstract get defaultValue(): T;
|
|
498
|
+
get formula(): FormulaDefinition | undefined;
|
|
499
|
+
get formulaWarning(): FormulaWarning | null;
|
|
500
|
+
get isReadOnly(): boolean;
|
|
501
|
+
getPlainValue(): T;
|
|
502
|
+
setValue(value: unknown, options?: {
|
|
503
|
+
internal?: boolean;
|
|
504
|
+
}): void;
|
|
505
|
+
protected abstract coerceValue(value: unknown): T;
|
|
506
|
+
setFormulaWarning(warning: FormulaWarning | null): void;
|
|
507
|
+
commit(): void;
|
|
508
|
+
revert(): void;
|
|
509
|
+
isPrimitive(): this is PrimitiveValueNode;
|
|
510
|
+
get errors(): readonly Diagnostic[];
|
|
511
|
+
protected computeErrors(): readonly Diagnostic[];
|
|
512
|
+
get warnings(): readonly Diagnostic[];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
declare class StringValueNode extends BasePrimitiveValueNode<string> {
|
|
516
|
+
readonly type = ValueType.String;
|
|
517
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, value?: string, reactivity?: ReactivityAdapter);
|
|
518
|
+
get defaultValue(): string;
|
|
519
|
+
protected coerceValue(value: unknown): string;
|
|
520
|
+
protected computeErrors(): readonly Diagnostic[];
|
|
521
|
+
private validateRequired;
|
|
522
|
+
private validateForeignKey;
|
|
523
|
+
private validateMinLength;
|
|
524
|
+
private validateMaxLength;
|
|
525
|
+
private validatePattern;
|
|
526
|
+
private validateEnum;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
declare class NumberValueNode extends BasePrimitiveValueNode<number> {
|
|
530
|
+
readonly type = ValueType.Number;
|
|
531
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, value?: number, reactivity?: ReactivityAdapter);
|
|
532
|
+
get defaultValue(): number;
|
|
533
|
+
protected coerceValue(value: unknown): number;
|
|
534
|
+
protected computeErrors(): readonly Diagnostic[];
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
declare class BooleanValueNode extends BasePrimitiveValueNode<boolean> {
|
|
538
|
+
readonly type = ValueType.Boolean;
|
|
539
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, value?: boolean, reactivity?: ReactivityAdapter);
|
|
540
|
+
get defaultValue(): boolean;
|
|
541
|
+
protected coerceValue(value: unknown): boolean;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
declare class ObjectValueNode extends BaseValueNode implements ObjectValueNode$1 {
|
|
545
|
+
private readonly reactivity?;
|
|
546
|
+
readonly type = ValueType.Object;
|
|
547
|
+
private _children;
|
|
548
|
+
private _baseChildren;
|
|
549
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, children?: ValueNode[], reactivity?: ReactivityAdapter | undefined);
|
|
550
|
+
private initObservable;
|
|
551
|
+
get value(): Record<string, ValueNode>;
|
|
552
|
+
get children(): readonly ValueNode[];
|
|
553
|
+
getPlainValue(): Record<string, unknown>;
|
|
554
|
+
child(name: string): ValueNode | undefined;
|
|
555
|
+
hasChild(name: string): boolean;
|
|
556
|
+
addChild(node: ValueNode): void;
|
|
557
|
+
removeChild(name: string): void;
|
|
558
|
+
get isDirty(): boolean;
|
|
559
|
+
commit(): void;
|
|
560
|
+
revert(): void;
|
|
561
|
+
isObject(): this is ObjectValueNode$1;
|
|
562
|
+
get errors(): readonly Diagnostic[];
|
|
563
|
+
get warnings(): readonly Diagnostic[];
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
declare class ArrayValueNode extends BaseValueNode implements ArrayValueNode$1 {
|
|
567
|
+
private readonly reactivity?;
|
|
568
|
+
readonly type = ValueType.Array;
|
|
569
|
+
private _items;
|
|
570
|
+
private _baseItems;
|
|
571
|
+
private _nodeFactory;
|
|
572
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, items?: ValueNode[], reactivity?: ReactivityAdapter | undefined);
|
|
573
|
+
private initObservable;
|
|
574
|
+
get value(): readonly ValueNode[];
|
|
575
|
+
get length(): number;
|
|
576
|
+
getPlainValue(): unknown[];
|
|
577
|
+
at(index: number): ValueNode | undefined;
|
|
578
|
+
push(node: ValueNode): void;
|
|
579
|
+
insertAt(index: number, node: ValueNode): void;
|
|
580
|
+
removeAt(index: number): void;
|
|
581
|
+
move(fromIndex: number, toIndex: number): void;
|
|
582
|
+
replaceAt(index: number, node: ValueNode): void;
|
|
583
|
+
clear(): void;
|
|
584
|
+
setNodeFactory(factory: NodeFactory): void;
|
|
585
|
+
pushValue(value?: unknown): void;
|
|
586
|
+
insertValueAt(index: number, value?: unknown): void;
|
|
587
|
+
private createItemNode;
|
|
588
|
+
private propagateFactory;
|
|
589
|
+
get isDirty(): boolean;
|
|
590
|
+
commit(): void;
|
|
591
|
+
revert(): void;
|
|
592
|
+
isArray(): this is ArrayValueNode$1;
|
|
593
|
+
get errors(): readonly Diagnostic[];
|
|
594
|
+
get warnings(): readonly Diagnostic[];
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
interface ForeignKeyValueNode extends ValueNode {
|
|
598
|
+
readonly value: string;
|
|
599
|
+
readonly foreignKey: string;
|
|
600
|
+
getRow(): Promise<RowData>;
|
|
601
|
+
getSchema(): Promise<JsonObjectSchema>;
|
|
602
|
+
readonly isLoading: boolean;
|
|
603
|
+
}
|
|
604
|
+
declare function isForeignKeyValueNode(node: ValueNode): node is ForeignKeyValueNode;
|
|
605
|
+
declare class ForeignKeyValueNodeImpl extends StringValueNode implements ForeignKeyValueNode {
|
|
606
|
+
private readonly fkResolver?;
|
|
607
|
+
private readonly _foreignKey;
|
|
608
|
+
constructor(id: string | undefined, name: string, schema: JsonSchema, value?: string, reactivity?: ReactivityAdapter, fkResolver?: ForeignKeyResolver | undefined);
|
|
609
|
+
get foreignKey(): string;
|
|
610
|
+
get isLoading(): boolean;
|
|
611
|
+
getRow(): Promise<RowData>;
|
|
612
|
+
getSchema(): Promise<JsonObjectSchema>;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export { type ArrayNodeOptions, ArrayValueNode, type ArrayValueNode$1 as ArrayValueNodeInterface, BasePrimitiveValueNode, BaseValueNode, BooleanValueNode, type DataModel, DataModelImpl, type DataModelOptions, type DirtyTrackable, type FieldType, type ForeignKeyLoader, type ForeignKeyLoaderResult, ForeignKeyNotFoundError, type ForeignKeyResolver, ForeignKeyResolverImpl, ForeignKeyResolverNotConfiguredError, type ForeignKeyResolverOptions, type ForeignKeyRowLoaderResult, type ForeignKeyValueNode, ForeignKeyValueNodeImpl, type FormulaDefinition, type FormulaWarning, type GenerateDefaultValueOptions, JsonSchemaStore, NodeFactory$1 as NodeFactory, type NodeFactoryFn, type NodeFactoryOptions, NodeFactoryRegistry, NumberValueNode, type ObjectNodeOptions, ObjectValueNode, type ObjectValueNode$1 as ObjectValueNodeInterface, type PrimitiveNodeOptions, type PrimitiveValueNode, type ReactivityOptions, type RefSchemas, type ReplaceResult, type RowData, type RowModel, RowModelImpl, type SchemaModel, SchemaParser, StringValueNode, type TableModel, TableModelImpl, type TableModelLike, type TableModelOptions, type ValueNode, NodeFactory as ValueNodeFactory, type ValueNodeOptions, type ValueTreeLike, ValueType, createDataModel, createDefaultRegistry, createForeignKeyResolver, createNodeFactory, createSchemaModel, createTableModel, equal, extractFormulaDefinition, fromArrayToObject, fromArrayTransformation, fromBooleanToNumber, fromBooleanToString, fromNumberToBoolean, fromNumberToString, fromObjectToArray, fromObjectToPrimitive, fromPrimitiveToObject, fromStringToBoolean, fromStringToNumber, generateDefaultValue, generateNodeId, getTransformation, isForeignKeyValueNode, resetNodeIdCounter, toArrayTransformation };
|