@revisium/schema-toolkit 0.20.2 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +216 -0
  2. package/dist/FormulaPathBuilder-BUJRR0Am.d.cts +48 -0
  3. package/dist/FormulaPathBuilder-QR0htn-e.d.ts +48 -0
  4. package/dist/{chunk-VGADCIBG.cjs → chunk-2PIMJSWJ.cjs} +12 -8
  5. package/dist/chunk-3MJP73IJ.js +1 -0
  6. package/dist/{chunk-LLHQWDAR.js → chunk-4U2RZHMX.js} +19 -21
  7. package/dist/{chunk-Q2UOTIMG.js → chunk-5DUMJHCA.js} +0 -2
  8. package/dist/{chunk-V6JTSET2.cjs → chunk-7JWCZZPJ.cjs} +49 -51
  9. package/dist/{chunk-YFWOURZL.js → chunk-7PEC6ZYY.js} +0 -2
  10. package/dist/chunk-AV5EZUMZ.cjs +2 -0
  11. package/dist/{chunk-3JZKQWQH.js → chunk-AWFMSOHM.js} +5 -7
  12. package/dist/{chunk-X2VRR7V7.cjs → chunk-ERW5XVED.cjs} +0 -2
  13. package/dist/{chunk-XNFSFT7T.cjs → chunk-EVD5ZI55.cjs} +0 -2
  14. package/dist/{chunk-ZRNFSUOV.cjs → chunk-FL6PWPVJ.cjs} +0 -2
  15. package/dist/{chunk-55AMH44G.js → chunk-FTBRJODD.js} +28 -30
  16. package/dist/{chunk-R3MS2N4A.js → chunk-GJM63Q4K.js} +0 -2
  17. package/dist/{chunk-U5YDA3LA.js → chunk-HFMZITNE.js} +238 -31
  18. package/dist/{chunk-EGC32GPY.cjs → chunk-ITYABUR5.cjs} +19 -21
  19. package/dist/{chunk-R4CFU33U.js → chunk-IZMBM36H.js} +10 -9
  20. package/dist/chunk-J4RVO37K.cjs +2 -0
  21. package/dist/{chunk-QEV4Q4TR.js → chunk-JLXX3SGF.js} +30 -32
  22. package/dist/{chunk-MPF6VCB5.js → chunk-NO655UI5.js} +0 -2
  23. package/dist/chunk-OAUVP6CU.js +1 -0
  24. package/dist/{chunk-B3T6YB2D.cjs → chunk-ONW2OVNQ.cjs} +28 -30
  25. package/dist/{chunk-32FZHFIO.cjs → chunk-QKA7DJDN.cjs} +0 -2
  26. package/dist/{chunk-46ME2TAU.cjs → chunk-RCCBUOGY.cjs} +5 -7
  27. package/dist/{chunk-IPL2CGVA.cjs → chunk-RQBW7ATZ.cjs} +0 -2
  28. package/dist/{chunk-FZ2MS4Q5.cjs → chunk-S5SRXND6.cjs} +307 -97
  29. package/dist/{chunk-WSPFHUHU.cjs → chunk-T3QQSHAC.cjs} +0 -2
  30. package/dist/{chunk-J6SCHJKG.cjs → chunk-VMELKZXD.cjs} +0 -2
  31. package/dist/{chunk-5VDDLW7U.js → chunk-WE4OLW5U.js} +0 -2
  32. package/dist/{chunk-JUOGJFTL.js → chunk-XKWWCXGB.js} +0 -2
  33. package/dist/{chunk-ZBPUTF3Q.js → chunk-ZPRBA4AQ.js} +0 -2
  34. package/dist/consts/index.cjs +4 -6
  35. package/dist/consts/index.js +2 -4
  36. package/dist/core/index.cjs +65 -69
  37. package/dist/core/index.d.cts +6 -4
  38. package/dist/core/index.d.ts +6 -4
  39. package/dist/core/index.js +4 -8
  40. package/dist/formula/index.cjs +7 -9
  41. package/dist/formula/index.d.cts +1 -1
  42. package/dist/formula/index.d.ts +1 -1
  43. package/dist/formula/index.js +1 -3
  44. package/dist/index.cjs +269 -248
  45. package/dist/index.d.cts +8 -7
  46. package/dist/index.d.ts +8 -7
  47. package/dist/index.js +15 -18
  48. package/dist/{json-patch.types-DY7k9hxy.d.ts → json-patch.types-BpVnp08Z.d.ts} +1 -1
  49. package/dist/{json-patch.types-Cu0Medki.d.cts → json-patch.types-eM6pYC2P.d.cts} +1 -1
  50. package/dist/{json-string.store-C58zbl31.d.ts → json-string.store-DfdLcgnM.d.ts} +11 -11
  51. package/dist/{json-string.store-DuI--IL2.d.cts → json-string.store-cAOADo23.d.cts} +11 -11
  52. package/dist/lib/index.cjs +51 -54
  53. package/dist/lib/index.d.cts +3 -3
  54. package/dist/lib/index.d.ts +3 -3
  55. package/dist/lib/index.js +7 -10
  56. package/dist/mocks/index.cjs +30 -21
  57. package/dist/mocks/index.d.cts +22 -8
  58. package/dist/mocks/index.d.ts +22 -8
  59. package/dist/mocks/index.js +2 -5
  60. package/dist/model/index.cjs +85 -78
  61. package/dist/model/index.d.cts +171 -346
  62. package/dist/model/index.d.ts +171 -346
  63. package/dist/model/index.js +4 -9
  64. package/dist/plugins/index.cjs +20 -23
  65. package/dist/plugins/index.d.cts +10 -10
  66. package/dist/plugins/index.d.ts +10 -10
  67. package/dist/plugins/index.js +2 -5
  68. package/dist/{schema.types-B5OgKLpV.d.cts → schema.types-On_VGw2m.d.cts} +7 -6
  69. package/dist/{schema.types-B5OgKLpV.d.ts → schema.types-On_VGw2m.d.ts} +7 -6
  70. package/dist/typed-BRZhUqGG.d.ts +502 -0
  71. package/dist/typed-Cri0IYAn.d.cts +502 -0
  72. package/dist/types/index.cjs +6 -9
  73. package/dist/types/index.d.cts +7 -5
  74. package/dist/types/index.d.ts +7 -5
  75. package/dist/types/index.js +2 -5
  76. package/dist/{FormulaPathBuilder-DwlKOvVB.d.ts → types-BIvIURgy.d.cts} +37 -82
  77. package/dist/{FormulaPathBuilder-D9LkBcSv.d.cts → types-C_pTFtSY.d.ts} +37 -82
  78. package/dist/validation-schemas/index.cjs +18 -20
  79. package/dist/validation-schemas/index.js +1 -3
  80. package/package.json +1 -1
  81. package/dist/chunk-32FZHFIO.cjs.map +0 -1
  82. package/dist/chunk-3FJZMVWA.js +0 -3
  83. package/dist/chunk-3FJZMVWA.js.map +0 -1
  84. package/dist/chunk-3IKI64T2.js +0 -3
  85. package/dist/chunk-3IKI64T2.js.map +0 -1
  86. package/dist/chunk-3JZKQWQH.js.map +0 -1
  87. package/dist/chunk-46ME2TAU.cjs.map +0 -1
  88. package/dist/chunk-55AMH44G.js.map +0 -1
  89. package/dist/chunk-5VDDLW7U.js.map +0 -1
  90. package/dist/chunk-B3T6YB2D.cjs.map +0 -1
  91. package/dist/chunk-EGC32GPY.cjs.map +0 -1
  92. package/dist/chunk-FZ2MS4Q5.cjs.map +0 -1
  93. package/dist/chunk-G6ZKEVVU.cjs +0 -4
  94. package/dist/chunk-G6ZKEVVU.cjs.map +0 -1
  95. package/dist/chunk-IPL2CGVA.cjs.map +0 -1
  96. package/dist/chunk-J6SCHJKG.cjs.map +0 -1
  97. package/dist/chunk-JUOGJFTL.js.map +0 -1
  98. package/dist/chunk-L6HE7QPU.cjs +0 -4
  99. package/dist/chunk-L6HE7QPU.cjs.map +0 -1
  100. package/dist/chunk-LLHQWDAR.js.map +0 -1
  101. package/dist/chunk-MPF6VCB5.js.map +0 -1
  102. package/dist/chunk-NY3H6C7K.js +0 -3
  103. package/dist/chunk-NY3H6C7K.js.map +0 -1
  104. package/dist/chunk-Q2UOTIMG.js.map +0 -1
  105. package/dist/chunk-QEV4Q4TR.js.map +0 -1
  106. package/dist/chunk-R3MS2N4A.js.map +0 -1
  107. package/dist/chunk-R4CFU33U.js.map +0 -1
  108. package/dist/chunk-TBFTADML.cjs +0 -4
  109. package/dist/chunk-TBFTADML.cjs.map +0 -1
  110. package/dist/chunk-U5YDA3LA.js.map +0 -1
  111. package/dist/chunk-V6JTSET2.cjs.map +0 -1
  112. package/dist/chunk-VGADCIBG.cjs.map +0 -1
  113. package/dist/chunk-WSPFHUHU.cjs.map +0 -1
  114. package/dist/chunk-X2VRR7V7.cjs.map +0 -1
  115. package/dist/chunk-XNFSFT7T.cjs.map +0 -1
  116. package/dist/chunk-YFWOURZL.js.map +0 -1
  117. package/dist/chunk-ZBPUTF3Q.js.map +0 -1
  118. package/dist/chunk-ZRNFSUOV.cjs.map +0 -1
  119. package/dist/consts/index.cjs.map +0 -1
  120. package/dist/consts/index.js.map +0 -1
  121. package/dist/core/index.cjs.map +0 -1
  122. package/dist/core/index.js.map +0 -1
  123. package/dist/formula/index.cjs.map +0 -1
  124. package/dist/formula/index.js.map +0 -1
  125. package/dist/index.cjs.map +0 -1
  126. package/dist/index.js.map +0 -1
  127. package/dist/json-value-patch.types-CgiEpchp.d.ts +0 -24
  128. package/dist/json-value-patch.types-LEJxcIWR.d.cts +0 -24
  129. package/dist/lib/index.cjs.map +0 -1
  130. package/dist/lib/index.js.map +0 -1
  131. package/dist/mocks/index.cjs.map +0 -1
  132. package/dist/mocks/index.js.map +0 -1
  133. package/dist/model/index.cjs.map +0 -1
  134. package/dist/model/index.js.map +0 -1
  135. package/dist/plugins/index.cjs.map +0 -1
  136. package/dist/plugins/index.js.map +0 -1
  137. package/dist/types/index.cjs.map +0 -1
  138. package/dist/types/index.js.map +0 -1
  139. package/dist/validation-schemas/index.cjs.map +0 -1
  140. package/dist/validation-schemas/index.js.map +0 -1
package/README.md CHANGED
@@ -17,8 +17,211 @@ Framework-agnostic TypeScript types, system schemas, runtime stores, and utiliti
17
17
  npm install @revisium/schema-toolkit
18
18
  ```
19
19
 
20
+ ## Quick Start
21
+
22
+ ### Schema helpers
23
+
24
+ ```typescript
25
+ import { obj, str, num, bool, arr } from '@revisium/schema-toolkit';
26
+
27
+ const schema = obj({
28
+ name: str(),
29
+ age: num(),
30
+ active: bool(),
31
+ tags: arr(str()),
32
+ });
33
+ ```
34
+
35
+ ### RowModel
36
+
37
+ ```typescript
38
+ import { obj, str, num, createRowModel } from '@revisium/schema-toolkit';
39
+
40
+ const schema = obj({ name: str(), price: num() });
41
+
42
+ const row = createRowModel({
43
+ rowId: 'row-1',
44
+ schema,
45
+ data: { name: 'Widget', price: 9.99 },
46
+ });
47
+
48
+ row.getValue('name'); // string (typed!)
49
+ row.setValue('price', 19.99); // OK
50
+ row.setValue('price', 'wrong'); // TS Error!
51
+ row.getPlainValue(); // { name: string, price: number }
52
+ row.getPatches(); // JSON Patch operations
53
+ ```
54
+
55
+ ### TableModel
56
+
57
+ ```typescript
58
+ import { obj, str, num, bool, createTableModel } from '@revisium/schema-toolkit';
59
+
60
+ const schema = obj({ title: str(), price: num(), inStock: bool() });
61
+
62
+ const table = createTableModel({
63
+ tableId: 'products',
64
+ schema,
65
+ rows: [
66
+ { rowId: 'p1', data: { title: 'Laptop', price: 999, inStock: true } },
67
+ ],
68
+ });
69
+
70
+ const row = table.getRow('p1');
71
+ row?.getValue('title'); // string (typed!)
72
+ row?.getPlainValue(); // { title: string, price: number, inStock: boolean }
73
+
74
+ const newRow = table.addRow('p2', { title: 'Mouse', price: 29, inStock: true });
75
+ newRow.setValue('price', 39); // OK
76
+ newRow.setValue('price', 'x'); // TS Error!
77
+ ```
78
+
79
+ ### Typed API without helpers
80
+
81
+ When the schema is typed (via helpers or `as const`), `createRowModel` / `createTableModel` return typed models automatically. With plain `JsonSchema` they return the untyped API as before:
82
+
83
+ ```typescript
84
+ import { createRowModel } from '@revisium/schema-toolkit';
85
+ import type { JsonObjectSchema } from '@revisium/schema-toolkit';
86
+
87
+ // Untyped — returns plain RowModel with unknown types
88
+ const schema: JsonObjectSchema = getSchemaFromApi();
89
+ const row = createRowModel({ rowId: 'row-1', schema, data });
90
+ row.getValue('name'); // unknown
91
+ ```
92
+
93
+ See [Typed API documentation](src/types/TYPED-API.md) for all approaches: `as const`, explicit type declarations, `SchemaFromValue<T>`, and more.
94
+
95
+ ## Reactivity (MobX)
96
+
97
+ By default all models use a noop reactivity provider, which works for backend and plain scripts. To enable MobX reactivity (e.g. in a React app), configure the provider once at startup:
98
+
99
+ ```typescript
100
+ import * as mobx from 'mobx';
101
+ import { setReactivityProvider, createMobxProvider } from '@revisium/schema-toolkit/core';
102
+
103
+ setReactivityProvider(createMobxProvider(mobx));
104
+ ```
105
+
106
+ After this call every model created via `createRowModel`, `createTableModel`, or `createDataModel` becomes fully observable.
107
+
108
+ See [Reactivity Module docs](src/core/reactivity/README.md) for the full API, noop behaviour table, and test-setup examples.
109
+
110
+ ## Formulas (Computed Fields)
111
+
112
+ Fields with `x-formula` are automatically computed from other fields. Use `readOnly: true` and the `formula` option in helpers:
113
+
114
+ ```typescript
115
+ import { obj, num, numFormula, createRowModel } from '@revisium/schema-toolkit';
116
+
117
+ const schema = obj({
118
+ price: num(),
119
+ quantity: num(),
120
+ subtotal: numFormula('price * quantity'),
121
+ tax: numFormula('subtotal * 0.1'),
122
+ total: numFormula('subtotal + tax'),
123
+ });
124
+
125
+ const row = createRowModel({
126
+ rowId: 'order-1',
127
+ schema,
128
+ data: { price: 100, quantity: 5, subtotal: 0, tax: 0, total: 0 },
129
+ });
130
+
131
+ row.getPlainValue();
132
+ // { price: 100, quantity: 5, subtotal: 500, tax: 50, total: 550 }
133
+ ```
134
+
135
+ Formulas are evaluated in dependency order. With the MobX reactivity provider configured, changing a dependency triggers automatic re-evaluation of all affected formulas.
136
+
137
+ ### Expression Syntax
138
+
139
+ | Syntax | Example |
140
+ |--------|---------|
141
+ | Field reference | `price`, `item.quantity` |
142
+ | Arithmetic | `price * quantity`, `a + b - c` |
143
+ | Comparison & logic | `a > b && c < d`, `x ? y : z` |
144
+ | Absolute path | `/rootField` |
145
+ | Relative path | `../siblingField` |
146
+ | Array access | `items[0].price`, `items[*].price` |
147
+ | Array context | `#index`, `#length`, `@prev`, `@next` |
148
+ | Functions | `sum(items[*].price)`, `avg(values)`, `count(array)` |
149
+
150
+ ### Schema-Level Integration
151
+
152
+ When fields are renamed or moved, formula expressions are automatically updated in the generated patches:
153
+
154
+ ```typescript
155
+ // rename price → cost
156
+ // formula 'price * quantity' → 'cost * quantity' (auto-updated)
157
+ ```
158
+
159
+ ### Warnings
160
+
161
+ The evaluator tracks problematic results (`nan`, `infinity`, `runtime-error`) on the node's `formulaWarning` property.
162
+
163
+ See [value-formula docs](src/model/value-formula/README.md) for the runtime engine API and [schema-formula docs](src/model/schema-formula/README.md) for parsing, dependency tracking, and serialization.
164
+
165
+ ## Foreign Key Resolution
166
+
167
+ Schemas with `foreignKey` fields (string fields referencing another table) can be resolved automatically via `ForeignKeyResolver`:
168
+
169
+ ```typescript
170
+ import { createForeignKeyResolver, createTableModel, obj, str } from '@revisium/schema-toolkit';
171
+
172
+ const resolver = createForeignKeyResolver({
173
+ loader: {
174
+ loadSchema: async (tableId) => api.getTableSchema(tableId),
175
+ loadRow: async (tableId, rowId) => api.getRow(tableId, rowId),
176
+ },
177
+ prefetch: true,
178
+ });
179
+
180
+ const table = createTableModel({
181
+ tableId: 'products',
182
+ schema: obj({ name: str(), categoryId: str({ foreignKey: 'categories' }) }),
183
+ rows: [{ rowId: 'p1', data: { name: 'Laptop', categoryId: 'cat-1' } }],
184
+ fkResolver: resolver,
185
+ });
186
+
187
+ // Referenced data is prefetched in the background and available from cache
188
+ const category = await resolver.getRowData('categories', 'cat-1');
189
+ ```
190
+
191
+ The same `fkResolver` option is accepted by `createRowModel`. When using `createDataModel`, pass the resolver once and all tables will share it.
192
+
193
+ See [ForeignKeyResolver docs](src/model/foreign-key-resolver/README.md) for cache-only mode, prefetch control, loading state, and error handling.
194
+
20
195
  ## API
21
196
 
197
+ ### Schema Helpers
198
+
199
+ | Function | Description |
200
+ |----------|-------------|
201
+ | `str()` | Create string schema |
202
+ | `num()` | Create number schema |
203
+ | `bool()` | Create boolean schema |
204
+ | `strFormula(expr)` | Create computed string field (`readOnly: true` + `x-formula`) |
205
+ | `numFormula(expr)` | Create computed number field (`readOnly: true` + `x-formula`) |
206
+ | `boolFormula(expr)` | Create computed boolean field (`readOnly: true` + `x-formula`) |
207
+ | `obj(properties)` | Create object schema (generic — preserves property types) |
208
+ | `arr(items)` | Create array schema (generic — preserves items type) |
209
+ | `ref(tableName)` | Create $ref schema |
210
+
211
+ ### Table & Row
212
+
213
+ | Function | Description |
214
+ |----------|-------------|
215
+ | `createRowModel(options)` | Create a row model (typed overload when schema is typed) |
216
+ | `createTableModel(options)` | Create a table model (typed overload when schema is typed) |
217
+
218
+ ### Value Tree
219
+
220
+ | Function | Description |
221
+ |----------|-------------|
222
+ | `createTypedTree(schema, data)` | Create a typed value tree with path-based access |
223
+ | `typedNode(node)` | Cast an untyped `ValueNode` to a typed node |
224
+
22
225
  ### Schema
23
226
 
24
227
  | Function | Description |
@@ -57,6 +260,19 @@ npm install @revisium/schema-toolkit
57
260
  | `getPathByStore` | Get path from store |
58
261
  | `deepEqual` | Deep equality comparison |
59
262
 
263
+ ### Type Utilities
264
+
265
+ | Type | Description |
266
+ |------|-------------|
267
+ | `InferValue<S>` | Schema → plain TypeScript value type |
268
+ | `InferNode<S>` | Schema → typed ValueNode interface |
269
+ | `SchemaFromValue<T>` | Plain TS type → virtual schema shape |
270
+ | `SchemaPaths<S>` | Union of all valid dot-separated paths |
271
+ | `TypedRowModel<S>` | RowModel with typed `getValue`, `setValue`, `getPlainValue` |
272
+ | `TypedTableModel<S>` | TableModel with typed rows, `addRow`, `getRow` |
273
+
274
+ See [Typed API documentation](src/types/TYPED-API.md) for the full reference.
275
+
60
276
  ## License
61
277
 
62
278
  MIT
@@ -0,0 +1,48 @@
1
+ import { j as SchemaNode, P as Path, o as Formula } from './types-BIvIURgy.cjs';
2
+ import { X as XFormula } from './schema.types-On_VGw2m.cjs';
3
+
4
+ interface SchemaTree {
5
+ root(): SchemaNode;
6
+ nodeById(id: string): SchemaNode;
7
+ nodeAt(path: Path): SchemaNode;
8
+ pathOf(id: string): Path;
9
+ nodeIds(): IterableIterator<string>;
10
+ countNodes(): number;
11
+ clone(): SchemaTree;
12
+ trackReplacement(oldNodeId: string, newNodeId: string): void;
13
+ replacements(): IterableIterator<[string, string]>;
14
+ clearReplacements(): void;
15
+ addChildTo(parentId: string, node: SchemaNode): void;
16
+ insertChildAt(parentId: string, index: number, node: SchemaNode): void;
17
+ removeNodeAt(path: Path): boolean;
18
+ renameNode(nodeId: string, newName: string): void;
19
+ moveNode(nodeId: string, newParentId: string): void;
20
+ setNodeAt(path: Path, node: SchemaNode): void;
21
+ replaceRoot(newRoot: SchemaNode): void;
22
+ }
23
+
24
+ interface SerializeOptions {
25
+ readonly strict?: boolean;
26
+ }
27
+ declare class FormulaSerializer {
28
+ private readonly tree;
29
+ private readonly formulaNodeId;
30
+ private readonly formula;
31
+ private readonly pathBuilder;
32
+ constructor(tree: SchemaTree, formulaNodeId: string, formula: Formula);
33
+ static toXFormula(tree: SchemaTree, formulaNodeId: string, formula: Formula): XFormula;
34
+ static serializeExpression(tree: SchemaTree, formulaNodeId: string, formula: Formula, options?: SerializeOptions): string;
35
+ serialize(options?: SerializeOptions): string;
36
+ private buildPathReplacements;
37
+ private needsReplacement;
38
+ private normalizeArrayNotation;
39
+ }
40
+
41
+ declare class FormulaPathBuilder {
42
+ buildWithArrayNotation(fromPath: Path, toPath: Path): string;
43
+ private findCommonPrefixLength;
44
+ private buildPartsWithArrayNotation;
45
+ private formatPartsWithArrayNotation;
46
+ }
47
+
48
+ export { FormulaSerializer as F, type SchemaTree as S, FormulaPathBuilder as a };
@@ -0,0 +1,48 @@
1
+ import { j as SchemaNode, P as Path, o as Formula } from './types-C_pTFtSY.js';
2
+ import { X as XFormula } from './schema.types-On_VGw2m.js';
3
+
4
+ interface SchemaTree {
5
+ root(): SchemaNode;
6
+ nodeById(id: string): SchemaNode;
7
+ nodeAt(path: Path): SchemaNode;
8
+ pathOf(id: string): Path;
9
+ nodeIds(): IterableIterator<string>;
10
+ countNodes(): number;
11
+ clone(): SchemaTree;
12
+ trackReplacement(oldNodeId: string, newNodeId: string): void;
13
+ replacements(): IterableIterator<[string, string]>;
14
+ clearReplacements(): void;
15
+ addChildTo(parentId: string, node: SchemaNode): void;
16
+ insertChildAt(parentId: string, index: number, node: SchemaNode): void;
17
+ removeNodeAt(path: Path): boolean;
18
+ renameNode(nodeId: string, newName: string): void;
19
+ moveNode(nodeId: string, newParentId: string): void;
20
+ setNodeAt(path: Path, node: SchemaNode): void;
21
+ replaceRoot(newRoot: SchemaNode): void;
22
+ }
23
+
24
+ interface SerializeOptions {
25
+ readonly strict?: boolean;
26
+ }
27
+ declare class FormulaSerializer {
28
+ private readonly tree;
29
+ private readonly formulaNodeId;
30
+ private readonly formula;
31
+ private readonly pathBuilder;
32
+ constructor(tree: SchemaTree, formulaNodeId: string, formula: Formula);
33
+ static toXFormula(tree: SchemaTree, formulaNodeId: string, formula: Formula): XFormula;
34
+ static serializeExpression(tree: SchemaTree, formulaNodeId: string, formula: Formula, options?: SerializeOptions): string;
35
+ serialize(options?: SerializeOptions): string;
36
+ private buildPathReplacements;
37
+ private needsReplacement;
38
+ private normalizeArrayNotation;
39
+ }
40
+
41
+ declare class FormulaPathBuilder {
42
+ buildWithArrayNotation(fromPath: Path, toPath: Path): string;
43
+ private findCommonPrefixLength;
44
+ private buildPartsWithArrayNotation;
45
+ private formatPartsWithArrayNotation;
46
+ }
47
+
48
+ export { FormulaSerializer as F, type SchemaTree as S, FormulaPathBuilder as a };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // src/mocks/schema.mocks.ts
3
+ // src/lib/schema-helpers.ts
4
4
  var getReplacePatch = ({
5
5
  path,
6
6
  value
@@ -38,7 +38,7 @@ var buildFormula = (expression) => ({
38
38
  var getStringSchema = (params = {}) => {
39
39
  const { formula, ...rest } = params;
40
40
  return {
41
- type: "string" /* String */,
41
+ type: "string",
42
42
  ...rest,
43
43
  default: rest.default ?? "",
44
44
  ...formula && { "x-formula": buildFormula(formula) }
@@ -47,7 +47,7 @@ var getStringSchema = (params = {}) => {
47
47
  var getNumberSchema = (params = {}) => {
48
48
  const { formula, ...rest } = params;
49
49
  return {
50
- type: "number" /* Number */,
50
+ type: "number",
51
51
  ...rest,
52
52
  default: rest.default ?? 0,
53
53
  ...formula && { "x-formula": buildFormula(formula) }
@@ -56,21 +56,21 @@ var getNumberSchema = (params = {}) => {
56
56
  var getBooleanSchema = (params = {}) => {
57
57
  const { formula, ...rest } = params;
58
58
  return {
59
- type: "boolean" /* Boolean */,
59
+ type: "boolean",
60
60
  ...rest,
61
61
  default: rest.default ?? false,
62
62
  ...formula && { "x-formula": buildFormula(formula) }
63
63
  };
64
64
  };
65
65
  var getObjectSchema = (properties, options = {}) => ({
66
- type: "object" /* Object */,
66
+ type: "object",
67
67
  additionalProperties: false,
68
68
  required: Object.keys(properties).sort((a, b) => a.localeCompare(b)),
69
69
  properties,
70
70
  ...options
71
71
  });
72
72
  var getArraySchema = (items, options = {}) => ({
73
- type: "array" /* Array */,
73
+ type: "array",
74
74
  items,
75
75
  ...options
76
76
  });
@@ -81,12 +81,16 @@ var getRefSchema = ($ref, options = {}) => ({
81
81
  var str = (params = {}) => getStringSchema(params);
82
82
  var num = (params = {}) => getNumberSchema(params);
83
83
  var bool = (params = {}) => getBooleanSchema(params);
84
+ var strFormula = (formula, params = {}) => getStringSchema({ ...params, formula, readOnly: true });
85
+ var numFormula = (formula, params = {}) => getNumberSchema({ ...params, formula, readOnly: true });
86
+ var boolFormula = (formula, params = {}) => getBooleanSchema({ ...params, formula, readOnly: true });
84
87
  var obj = (properties, options) => getObjectSchema(properties, options);
85
88
  var arr = (items, options) => getArraySchema(items, options);
86
89
  var ref = ($ref, options) => getRefSchema($ref, options);
87
90
 
88
91
  exports.arr = arr;
89
92
  exports.bool = bool;
93
+ exports.boolFormula = boolFormula;
90
94
  exports.getAddPatch = getAddPatch;
91
95
  exports.getArraySchema = getArraySchema;
92
96
  exports.getBooleanSchema = getBooleanSchema;
@@ -98,8 +102,8 @@ exports.getRemovePatch = getRemovePatch;
98
102
  exports.getReplacePatch = getReplacePatch;
99
103
  exports.getStringSchema = getStringSchema;
100
104
  exports.num = num;
105
+ exports.numFormula = numFormula;
101
106
  exports.obj = obj;
102
107
  exports.ref = ref;
103
108
  exports.str = str;
104
- //# sourceMappingURL=chunk-VGADCIBG.cjs.map
105
- //# sourceMappingURL=chunk-VGADCIBG.cjs.map
109
+ exports.strFormula = strFormula;
@@ -0,0 +1 @@
1
+
@@ -1,6 +1,6 @@
1
1
  // src/plugins/row-id.schema.ts
2
2
  var rowIdSchema = {
3
- type: "string" /* String */,
3
+ type: "string",
4
4
  default: "",
5
5
  readOnly: true
6
6
  };
@@ -11,7 +11,7 @@ var ajvRowIdSchema = {
11
11
 
12
12
  // src/plugins/row-version-id.schema.ts
13
13
  var rowVersionIdSchema = {
14
- type: "string" /* String */,
14
+ type: "string",
15
15
  default: "",
16
16
  readOnly: true
17
17
  };
@@ -22,7 +22,7 @@ var ajvRowVersionIdSchema = {
22
22
 
23
23
  // src/plugins/row-created-id.schema.ts
24
24
  var rowCreatedIdSchema = {
25
- type: "string" /* String */,
25
+ type: "string",
26
26
  default: "",
27
27
  readOnly: true
28
28
  };
@@ -33,7 +33,7 @@ var ajvRowCreatedIdSchema = {
33
33
 
34
34
  // src/plugins/row-created-at.schema.ts
35
35
  var rowCreatedAtSchema = {
36
- type: "string" /* String */,
36
+ type: "string",
37
37
  default: "",
38
38
  readOnly: true
39
39
  };
@@ -44,7 +44,7 @@ var ajvRowCreatedAtSchema = {
44
44
 
45
45
  // src/plugins/row-published-at.schema.ts
46
46
  var rowPublishedAtSchema = {
47
- type: "string" /* String */,
47
+ type: "string",
48
48
  default: ""
49
49
  };
50
50
  var ajvRowPublishedAtSchema = {
@@ -54,7 +54,7 @@ var ajvRowPublishedAtSchema = {
54
54
 
55
55
  // src/plugins/row-updated-at.schema.ts
56
56
  var rowUpdatedAtSchema = {
57
- type: "string" /* String */,
57
+ type: "string",
58
58
  default: "",
59
59
  readOnly: true
60
60
  };
@@ -65,7 +65,7 @@ var ajvRowUpdatedAtSchema = {
65
65
 
66
66
  // src/plugins/row-hash.schema.ts
67
67
  var rowHashSchema = {
68
- type: "string" /* String */,
68
+ type: "string",
69
69
  default: "",
70
70
  readOnly: true
71
71
  };
@@ -76,7 +76,7 @@ var ajvRowHashSchema = {
76
76
 
77
77
  // src/plugins/row-schema-hash.schema.ts
78
78
  var rowSchemaHashSchema = {
79
- type: "string" /* String */,
79
+ type: "string",
80
80
  default: "",
81
81
  readOnly: true
82
82
  };
@@ -87,39 +87,39 @@ var ajvRowSchemaHashSchema = {
87
87
 
88
88
  // src/plugins/file-schema.ts
89
89
  var fileSchema = {
90
- type: "object" /* Object */,
90
+ type: "object",
91
91
  properties: {
92
- status: { type: "string" /* String */, default: "", readOnly: true },
93
- fileId: { type: "string" /* String */, default: "", readOnly: true },
94
- url: { type: "string" /* String */, default: "", readOnly: true },
95
- fileName: { type: "string" /* String */, default: "" },
92
+ status: { type: "string", default: "", readOnly: true },
93
+ fileId: { type: "string", default: "", readOnly: true },
94
+ url: { type: "string", default: "", readOnly: true },
95
+ fileName: { type: "string", default: "" },
96
96
  hash: {
97
- type: "string" /* String */,
97
+ type: "string",
98
98
  default: "",
99
99
  readOnly: true
100
100
  },
101
101
  extension: {
102
- type: "string" /* String */,
102
+ type: "string",
103
103
  default: "",
104
104
  readOnly: true
105
105
  },
106
106
  mimeType: {
107
- type: "string" /* String */,
107
+ type: "string",
108
108
  default: "",
109
109
  readOnly: true
110
110
  },
111
111
  size: {
112
- type: "number" /* Number */,
112
+ type: "number",
113
113
  default: 0,
114
114
  readOnly: true
115
115
  },
116
116
  width: {
117
- type: "number" /* Number */,
117
+ type: "number",
118
118
  default: 0,
119
119
  readOnly: true
120
120
  },
121
121
  height: {
122
- type: "number" /* Number */,
122
+ type: "number",
123
123
  default: 0,
124
124
  readOnly: true
125
125
  }
@@ -144,5 +144,3 @@ var ajvFileSchema = {
144
144
  };
145
145
 
146
146
  export { ajvFileSchema, ajvRowCreatedAtSchema, ajvRowCreatedIdSchema, ajvRowHashSchema, ajvRowIdSchema, ajvRowPublishedAtSchema, ajvRowSchemaHashSchema, ajvRowUpdatedAtSchema, ajvRowVersionIdSchema, fileSchema, rowCreatedAtSchema, rowCreatedIdSchema, rowHashSchema, rowIdSchema, rowPublishedAtSchema, rowSchemaHashSchema, rowUpdatedAtSchema, rowVersionIdSchema };
147
- //# sourceMappingURL=chunk-LLHQWDAR.js.map
148
- //# sourceMappingURL=chunk-LLHQWDAR.js.map
@@ -13,5 +13,3 @@ var SystemSchemaIds = /* @__PURE__ */ ((SystemSchemaIds2) => {
13
13
  })(SystemSchemaIds || {});
14
14
 
15
15
  export { SystemSchemaIds };
16
- //# sourceMappingURL=chunk-Q2UOTIMG.js.map
17
- //# sourceMappingURL=chunk-Q2UOTIMG.js.map