@stonecrop/stonecrop 0.13.12 → 0.14.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 +6 -3
- package/dist/probe.tsbuildinfo +1 -0
- package/dist/src/client-handler.d.ts +43 -0
- package/dist/src/client-handler.d.ts.map +1 -0
- package/dist/src/client-handler.js +42 -0
- package/dist/src/doctype.d.ts +42 -7
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +77 -18
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/registry.d.ts +1 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +46 -38
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/schema-validator.js +44 -47
- package/dist/src/stonecrop.d.ts +0 -6
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/index.d.ts +2 -0
- package/dist/src/stores/index.d.ts.map +1 -1
- package/dist/src/stores/index.js +1 -0
- package/dist/src/stores/operation-log.d.ts +0 -6
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/src/stores/operation-log.js +0 -1
- package/dist/src/stores/validation.d.ts +83 -0
- package/dist/src/stores/validation.d.ts.map +1 -0
- package/dist/src/stores/validation.js +104 -0
- package/dist/src/types/doctype.d.ts +1 -1
- package/dist/src/types/doctype.d.ts.map +1 -1
- package/dist/src/types/operation-log.d.ts +0 -2
- package/dist/src/types/operation-log.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +166 -22
- package/dist/stonecrop.js +5241 -1958
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/client-handler.ts +55 -0
- package/src/doctype.ts +83 -22
- package/src/index.ts +12 -0
- package/src/registry.ts +45 -40
- package/src/schema-validator.ts +52 -48
- package/src/stores/index.ts +2 -0
- package/src/stores/operation-log.ts +7 -10
- package/src/stores/validation.ts +138 -0
- package/src/types/doctype.ts +1 -1
- package/src/types/operation-log.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAgB,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAgB,MAAM,mBAAmB,CAAA;AAGvG,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEtE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAE/C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAEhD;;;;;;;;OAQG;gBAEF,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,EACtC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS,EACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAUxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAajD;;;;;;;;;;;;;;OAcG;IACH,cAAc,IAAI,YAAY,EAAE;IAKhC;;;;;;;OAOG;IACH,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAK5C;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAqC3F;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAAoB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAcpE;;;;;;;;;;;;;;OAcG;IACH,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAS5D;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAC7B;QACA,KAAK,EAAE,MAAM,CAAA;QACb,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;QACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;KACvB,GACD,SAAS;IAWZ;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
|
package/dist/src/doctype.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isActionAllowedInState, normalizeFieldKind } from '@stonecrop/schema';
|
|
1
2
|
import { List, Map } from 'immutable';
|
|
2
3
|
/**
|
|
3
4
|
* Doctype runtime class with Immutable.js collections for HST change tracking.
|
|
@@ -90,8 +91,8 @@ export default class Doctype {
|
|
|
90
91
|
* const planDoctype = Doctype.fromObject({
|
|
91
92
|
* name: 'Plan',
|
|
92
93
|
* fields: [
|
|
93
|
-
* { fieldname: 'title', label: 'Title',
|
|
94
|
-
* { fieldname: 'status', label: 'Status',
|
|
94
|
+
* { fieldname: 'title', label: 'Title', component: 'ATextInput' },
|
|
95
|
+
* { fieldname: 'status', label: 'Status', component: 'ATextInput' },
|
|
95
96
|
* ],
|
|
96
97
|
* workflow: {
|
|
97
98
|
* id: 'plan',
|
|
@@ -104,7 +105,13 @@ export default class Doctype {
|
|
|
104
105
|
* @public
|
|
105
106
|
*/
|
|
106
107
|
static fromObject(config) {
|
|
107
|
-
|
|
108
|
+
// Authored JSON may omit the `kind` discriminant; the Zod schema injects it via a
|
|
109
|
+
// preprocess, but this path bypasses Zod. Normalize here so the registry's
|
|
110
|
+
// `resolveFields` (which gates link/fieldset handling on `field.kind`) sees the same
|
|
111
|
+
// shape a parsed doctype would — otherwise links silently fail to expand.
|
|
112
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- normalizeFieldKind only injects the `kind` discriminant; the field shape is otherwise preserved
|
|
113
|
+
const fields = config.fields?.map(normalizeFieldKind);
|
|
114
|
+
const schema = fields ? List(fields) : List();
|
|
108
115
|
const actions = config.actions ? Map(config.actions) : Map();
|
|
109
116
|
return new Doctype(config.name, schema, config.workflow, actions, undefined, config.links);
|
|
110
117
|
}
|
|
@@ -170,19 +177,14 @@ export default class Doctype {
|
|
|
170
177
|
const actions = workflow.actions;
|
|
171
178
|
if (!actions)
|
|
172
179
|
return [];
|
|
173
|
-
return Object.entries(actions)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return true;
|
|
179
|
-
return allowedStates.includes(currentState);
|
|
180
|
-
})
|
|
181
|
-
.map(([name]) => ({
|
|
180
|
+
return (Object.entries(actions)
|
|
181
|
+
// Exclude stateless Commands — they change no state and are surfaced separately
|
|
182
|
+
// via getAvailableCommands(). Genuine transitions carry a nextState.
|
|
183
|
+
.filter(([, actionDef]) => !actionDef.stateless && isActionAllowedInState(actionDef, currentState))
|
|
184
|
+
.map(([name, actionDef]) => ({
|
|
182
185
|
name,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}));
|
|
186
|
+
targetState: actionDef.nextState ?? currentState,
|
|
187
|
+
})));
|
|
186
188
|
}
|
|
187
189
|
// XState format: use the on property of the state
|
|
188
190
|
const states = workflow.states;
|
|
@@ -196,6 +198,61 @@ export default class Doctype {
|
|
|
196
198
|
targetState: typeof target === 'string' ? target : 'unknown',
|
|
197
199
|
}));
|
|
198
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Returns the stateless **Commands** available in a given workflow state — side-effect
|
|
203
|
+
* actions (save/print/email…) that do not change workflow state. Unlike transitions,
|
|
204
|
+
* Commands may exist on a workflow that declares no `states` (a commands-only doctype),
|
|
205
|
+
* and a Command with no `allowedStates` is available in every state.
|
|
206
|
+
*
|
|
207
|
+
* Only meaningful for WorkflowMeta format; XState workflows have no Commands.
|
|
208
|
+
*
|
|
209
|
+
* @param currentState - The record's current state, used to honor a Command's `allowedStates`
|
|
210
|
+
* @returns Array of command descriptors with `name`
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const commands = doctype.getAvailableCommands('Draft')
|
|
215
|
+
* // [{ name: 'Print' }]
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
getAvailableCommands(currentState) {
|
|
221
|
+
const workflow = this.workflow;
|
|
222
|
+
if (!workflow)
|
|
223
|
+
return [];
|
|
224
|
+
// Only WorkflowMeta carries an `actions` map; XState workflows have no Commands.
|
|
225
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- probing the workflow union for the optional WorkflowMeta actions map
|
|
226
|
+
const actions = workflow.actions;
|
|
227
|
+
if (!actions)
|
|
228
|
+
return [];
|
|
229
|
+
return Object.entries(actions)
|
|
230
|
+
.filter(([, actionDef]) => actionDef.stateless === true && isActionAllowedInState(actionDef, currentState ?? ''))
|
|
231
|
+
.map(([name]) => ({ name }));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Returns the field-validation **triggers** declared on this doctype's workflow (advisory,
|
|
235
|
+
* client-side). Keyed by trigger name. Returns undefined when the workflow is absent, is an
|
|
236
|
+
* XState machine (no triggers), or simply declares none.
|
|
237
|
+
*
|
|
238
|
+
* @returns The `workflow.triggers` map, or undefined
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const triggers = doctype.getTriggers()
|
|
243
|
+
* // { dateOrder: { on: ['start_date', 'end_date'], clientHandler: '…' } }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
getTriggers() {
|
|
249
|
+
const workflow = this.workflow;
|
|
250
|
+
if (!workflow)
|
|
251
|
+
return undefined;
|
|
252
|
+
// Only WorkflowMeta carries a `triggers` map; XState workflows have none.
|
|
253
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- probing the workflow union for the optional WorkflowMeta triggers map
|
|
254
|
+
return workflow.triggers;
|
|
255
|
+
}
|
|
199
256
|
/**
|
|
200
257
|
* Returns metadata for a specific action, if available.
|
|
201
258
|
* Only works with WorkflowMeta format; returns undefined for XState format.
|
|
@@ -206,16 +263,18 @@ export default class Doctype {
|
|
|
206
263
|
* @example
|
|
207
264
|
* ```ts
|
|
208
265
|
* const actionMeta = doctype.getActionMeta('submit')
|
|
209
|
-
* // { label: 'Submit',
|
|
266
|
+
* // { label: 'Submit', allowedStates: ['draft'] }
|
|
210
267
|
* ```
|
|
211
268
|
*
|
|
212
269
|
* @public
|
|
213
270
|
*/
|
|
214
271
|
getActionMeta(actionName) {
|
|
215
272
|
const workflow = this.workflow;
|
|
216
|
-
if (!workflow
|
|
273
|
+
if (!workflow)
|
|
217
274
|
return undefined;
|
|
218
|
-
//
|
|
275
|
+
// Only WorkflowMeta carries an `actions` map (with labels); XState workflows have none.
|
|
276
|
+
// Don't require a `states` array — a commands-only doctype has labeled actions but no states.
|
|
277
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- probing the workflow union for the optional WorkflowMeta actions map
|
|
219
278
|
const actions = workflow.actions;
|
|
220
279
|
return actions?.[actionName];
|
|
221
280
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type * from '@stonecrop/aform/types';
|
|
2
2
|
export type * from '@stonecrop/atable/types';
|
|
3
|
+
import { executeClientHandler } from './client-handler';
|
|
3
4
|
import { useLazyLink } from './composables/lazy-link';
|
|
4
5
|
import { useStonecrop } from './composables/stonecrop';
|
|
5
6
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
@@ -10,10 +11,13 @@ import Registry from './registry';
|
|
|
10
11
|
import { Stonecrop, getStonecrop } from './stonecrop';
|
|
11
12
|
import { HST, createHST, type HSTNode } from './stores/hst';
|
|
12
13
|
import { useOperationLogStore } from './stores/operation-log';
|
|
14
|
+
import { useValidationStore } from './stores/validation';
|
|
13
15
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
14
16
|
import { ValidationSeverity } from './types/schema-validator';
|
|
15
17
|
export type * from './types';
|
|
18
|
+
export type { ClientHandlerApi } from './client-handler';
|
|
19
|
+
export type { ValidationError } from './stores/validation';
|
|
16
20
|
export { ValidationSeverity };
|
|
17
|
-
export { Doctype, Registry, Stonecrop, useLazyLink, useStonecrop, HST, createHST, HSTNode, FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, getStonecrop, };
|
|
21
|
+
export { Doctype, Registry, Stonecrop, useLazyLink, useStonecrop, executeClientHandler, HST, createHST, HSTNode, FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, useValidationStore, getStonecrop, };
|
|
18
22
|
export default plugin;
|
|
19
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,yBAAyB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC9F,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAG7D,mBAAmB,SAAS,CAAA;AAG5B,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,OAAO,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cAAc,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAG7D,mBAAmB,SAAS,CAAA;AAG5B,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,OAAO,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EAEZ,oBAAoB,EAEpB,GAAG,EACH,SAAS,EACT,OAAO,EAEP,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EAEzB,eAAe,EACf,eAAe,EACf,cAAc,EAEd,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EAET,kBAAkB,EAElB,YAAY,GACZ,CAAA;AAGD,eAAe,MAAM,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { executeClientHandler } from './client-handler';
|
|
1
2
|
import { useLazyLink } from './composables/lazy-link';
|
|
2
3
|
import { useStonecrop } from './composables/stonecrop';
|
|
3
4
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
@@ -8,11 +9,14 @@ import Registry from './registry';
|
|
|
8
9
|
import { Stonecrop, getStonecrop } from './stonecrop';
|
|
9
10
|
import { HST, createHST } from './stores/hst';
|
|
10
11
|
import { useOperationLogStore } from './stores/operation-log';
|
|
12
|
+
import { useValidationStore } from './stores/validation';
|
|
11
13
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
12
14
|
import { ValidationSeverity } from './types/schema-validator';
|
|
13
15
|
// Export enum as value (enums need runtime export, not just type)
|
|
14
16
|
export { ValidationSeverity };
|
|
15
17
|
export { Doctype, Registry, Stonecrop, useLazyLink, useStonecrop,
|
|
18
|
+
// clientHandler executor
|
|
19
|
+
executeClientHandler,
|
|
16
20
|
// HST exports for advanced usage
|
|
17
21
|
HST, createHST,
|
|
18
22
|
// Field trigger system exports
|
|
@@ -21,6 +25,8 @@ FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransi
|
|
|
21
25
|
SchemaValidator, createValidator, validateSchema,
|
|
22
26
|
// Operation log exports
|
|
23
27
|
useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch,
|
|
28
|
+
// Field-validation store
|
|
29
|
+
useValidationStore,
|
|
24
30
|
// Utility functions
|
|
25
31
|
getStonecrop, };
|
|
26
32
|
// Default export is the Vue plugin
|
package/dist/src/registry.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export default class Registry {
|
|
|
102
102
|
*
|
|
103
103
|
* - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
|
|
104
104
|
* - `kind: 'fieldset'` → recursively initializes children as `{}`
|
|
105
|
-
* - `kind: 'field'` → derives default from
|
|
105
|
+
* - `kind: 'field'` → derives the default from the component's category; falls back to `null`
|
|
106
106
|
*
|
|
107
107
|
* @param schema - The resolved schema array to derive defaults from
|
|
108
108
|
* @returns A plain object with default values for each field
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiE,MAAM,kBAAkB,CAAA;AACpH,OAAO,KAAK,EAA8B,eAAe,EAA+B,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiE,MAAM,kBAAkB,CAAA;AACpH,OAAO,KAAK,EAA8B,eAAe,EAA+B,MAAM,mBAAmB,CAAA;AAEjH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,OAAO,MAAM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BAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,eAAe,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAWvF;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,eAAe,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAwBtG;;;OAGG;IACH,OAAO,CAAC,oBAAoB;CAgC5B"}
|
package/dist/src/registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { componentCategory, componentLinkExpansion, resolveLinkRenderMode } from '@stonecrop/schema';
|
|
1
2
|
import { getGlobalTriggerEngine } from './field-triggers';
|
|
2
3
|
/**
|
|
3
4
|
* Stonecrop Registry class
|
|
@@ -137,21 +138,21 @@ export default class Registry {
|
|
|
137
138
|
resolveFields(fields, links, visited) {
|
|
138
139
|
const resolved = [];
|
|
139
140
|
for (const field of fields) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
// A field is a link when it carries `doctype` (the marker) or has a LinkDeclaration.
|
|
142
|
+
const linkDecl = field.kind === 'field' ? links.get(field.fieldname) : undefined;
|
|
143
|
+
if (field.kind === 'field' && (linkDecl || field.doctype)) {
|
|
144
|
+
const link = linkDecl;
|
|
145
|
+
// The declaration's target wins over the field's own `doctype`.
|
|
146
|
+
const linkTarget = link?.target ?? field.doctype;
|
|
147
|
+
// An undeclared link, or a declared one whose component renders an inline picker,
|
|
148
|
+
// stays a scalar: the target is not expanded, it only needs the slug for async
|
|
149
|
+
// display-text resolution and navigation.
|
|
150
|
+
if (!link || resolveLinkRenderMode(link, field.component) === 'inline') {
|
|
150
151
|
const { cardinality: _c, ...rest } = field;
|
|
151
152
|
resolved.push({
|
|
152
153
|
...rest,
|
|
153
154
|
component: rest.component || 'AFormLink',
|
|
154
|
-
...(
|
|
155
|
+
...(linkTarget !== undefined ? { doctype: linkTarget } : {}),
|
|
155
156
|
});
|
|
156
157
|
continue;
|
|
157
158
|
}
|
|
@@ -163,8 +164,8 @@ export default class Registry {
|
|
|
163
164
|
continue;
|
|
164
165
|
}
|
|
165
166
|
const childSchema = this.resolveSchema(targetDoctype, new Set(visited));
|
|
166
|
-
const {
|
|
167
|
-
if (link
|
|
167
|
+
const { options: _opt, cardinality: _card, kind: _kind, ...fieldRest } = field;
|
|
168
|
+
if (resolveLinkRenderMode(link, field.component) === 'table') {
|
|
168
169
|
resolved.push(this.buildTableConfig(field, childSchema, link.component));
|
|
169
170
|
}
|
|
170
171
|
else {
|
|
@@ -200,7 +201,16 @@ export default class Registry {
|
|
|
200
201
|
resolved.push(tableEntry);
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
|
-
// Scalar field (kind: 'field', not a
|
|
204
|
+
// Scalar field (kind: 'field', not a link) — strip cardinality.
|
|
205
|
+
// A link-rendering component with nothing to point at renders an empty picker (or an
|
|
206
|
+
// empty embedded form), which is indistinguishable from "the record has no value".
|
|
207
|
+
// Link-ness comes from `doctype`/`links`, so this is a field that named a link
|
|
208
|
+
// component and forgot the target.
|
|
209
|
+
if (field.kind === 'field' && componentLinkExpansion(field.component)) {
|
|
210
|
+
console.warn(`[Stonecrop] Field "${field.fieldname}" renders with "${field.component}", which is a link component, ` +
|
|
211
|
+
`but the field is not a link: it has no \`doctype\` and no \`links\` declaration. It will render ` +
|
|
212
|
+
`as a plain field. Add \`"doctype": "<doctype-slug>"\` to the field definition.`);
|
|
213
|
+
}
|
|
204
214
|
const { cardinality: _c, ...rest } = field;
|
|
205
215
|
resolved.push({ ...rest });
|
|
206
216
|
}
|
|
@@ -218,7 +228,7 @@ export default class Registry {
|
|
|
218
228
|
.filter((f) => f.kind === 'field')
|
|
219
229
|
.map(({ kind: _k, ...col }) => col);
|
|
220
230
|
const config = field.config ?? { view: 'list' };
|
|
221
|
-
const {
|
|
231
|
+
const { options: _opt, cardinality: _card, ...fieldRest } = field;
|
|
222
232
|
return {
|
|
223
233
|
...fieldRest,
|
|
224
234
|
kind: 'table',
|
|
@@ -234,7 +244,7 @@ export default class Registry {
|
|
|
234
244
|
*
|
|
235
245
|
* - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
|
|
236
246
|
* - `kind: 'fieldset'` → recursively initializes children as `{}`
|
|
237
|
-
* - `kind: 'field'` → derives default from
|
|
247
|
+
* - `kind: 'field'` → derives the default from the component's category; falls back to `null`
|
|
238
248
|
*
|
|
239
249
|
* @param schema - The resolved schema array to derive defaults from
|
|
240
250
|
* @returns A plain object with default values for each field
|
|
@@ -253,33 +263,31 @@ export default class Registry {
|
|
|
253
263
|
record[field.fieldname] = this.initializeRecord(field.schema);
|
|
254
264
|
}
|
|
255
265
|
else {
|
|
256
|
-
// kind: 'field' —
|
|
266
|
+
// kind: 'field' — the empty default comes from the component's category.
|
|
257
267
|
const fieldDefault = field.default;
|
|
258
268
|
if (fieldDefault !== undefined) {
|
|
259
269
|
record[field.fieldname] = fieldDefault;
|
|
260
270
|
}
|
|
261
271
|
else {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
default:
|
|
282
|
-
record[field.fieldname] = null;
|
|
272
|
+
const category = componentCategory(field.component);
|
|
273
|
+
if (category === 'text') {
|
|
274
|
+
record[field.fieldname] = '';
|
|
275
|
+
}
|
|
276
|
+
else if (category === 'number') {
|
|
277
|
+
record[field.fieldname] = 0;
|
|
278
|
+
}
|
|
279
|
+
else if (category === 'boolean') {
|
|
280
|
+
record[field.fieldname] = false;
|
|
281
|
+
}
|
|
282
|
+
else if (category === 'code' && field.language) {
|
|
283
|
+
// A JSON editor starts from an empty object; any other language from empty source.
|
|
284
|
+
record[field.fieldname] = field.language === 'json' ? {} : '';
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// date / datetime / select / link / attach — plus two cases with no better answer
|
|
288
|
+
// than "no value": an unknown (custom) component, and a code field whose missing
|
|
289
|
+
// `language` doesn't say which kind of empty it wants.
|
|
290
|
+
record[field.fieldname] = null;
|
|
283
291
|
}
|
|
284
292
|
}
|
|
285
293
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAGhD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EAAmB,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEnG;;;GAGG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,OAAO,CAA4B;IAE3C;;;OAGG;gBACS,OAAO,GAAE,gBAAqB;IAW1C;;;;;;;;OAQG;IACH,QAAQ,CACP,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,EACvD,QAAQ,CAAC,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAChE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACrC,gBAAgB;IA+CnB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IA8DlC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAmC1B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAkGhC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAoFxB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;CAwClC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,eAAe,CAKxG;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,EACvD,QAAQ,EAAE,QAAQ,EAClB,QAAQ,CAAC,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAC9D,gBAAgB,CAGlB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Validates Stonecrop schemas for integrity and consistency
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
+
import { componentLinkExpansion } from '@stonecrop/schema';
|
|
6
7
|
import { getGlobalTriggerEngine } from './field-triggers';
|
|
7
8
|
import { ValidationSeverity } from './types/schema-validator';
|
|
8
9
|
/**
|
|
@@ -40,7 +41,7 @@ export class SchemaValidator {
|
|
|
40
41
|
const schemaArray = schema ? (Array.isArray(schema) ? schema : schema.toArray()) : [];
|
|
41
42
|
// Validate required properties
|
|
42
43
|
if (this.options.validateRequiredProperties) {
|
|
43
|
-
issues.push(...this.validateRequiredProperties(doctype, schemaArray));
|
|
44
|
+
issues.push(...this.validateRequiredProperties(doctype, schemaArray, links));
|
|
44
45
|
}
|
|
45
46
|
// Validate Link field targets
|
|
46
47
|
if (this.options.validateLinkTargets && this.options.registry) {
|
|
@@ -76,7 +77,7 @@ export class SchemaValidator {
|
|
|
76
77
|
* Validates that required schema properties are present
|
|
77
78
|
* @internal
|
|
78
79
|
*/
|
|
79
|
-
validateRequiredProperties(doctype, schema) {
|
|
80
|
+
validateRequiredProperties(doctype, schema, links) {
|
|
80
81
|
const issues = [];
|
|
81
82
|
for (const field of schema) {
|
|
82
83
|
// Check for fieldname
|
|
@@ -90,19 +91,37 @@ export class SchemaValidator {
|
|
|
90
91
|
});
|
|
91
92
|
continue;
|
|
92
93
|
}
|
|
93
|
-
//
|
|
94
|
-
|
|
94
|
+
// A value field renders through its component and has no other rendering axis;
|
|
95
|
+
// fieldset/table have their own structural requirements.
|
|
96
|
+
if (field.kind === 'field' && !field.component) {
|
|
95
97
|
issues.push({
|
|
96
98
|
severity: ValidationSeverity.ERROR,
|
|
97
|
-
rule: 'required-component
|
|
98
|
-
message: `Field "${field.fieldname}" must have
|
|
99
|
+
rule: 'required-component',
|
|
100
|
+
message: `Field "${field.fieldname}" must have a component property`,
|
|
101
|
+
doctype,
|
|
102
|
+
fieldname: field.fieldname,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// A link component with nothing to point at renders an empty picker, which looks exactly
|
|
106
|
+
// like a record that has no value — so this fails silently at runtime rather than loudly.
|
|
107
|
+
// Link-ness comes from `doctype` or a `links` declaration, so this is a field that named
|
|
108
|
+
// a link component and gave it neither.
|
|
109
|
+
if (field.kind === 'field' &&
|
|
110
|
+
componentLinkExpansion(field.component) &&
|
|
111
|
+
!field.doctype &&
|
|
112
|
+
!links?.[field.fieldname]) {
|
|
113
|
+
issues.push({
|
|
114
|
+
severity: ValidationSeverity.ERROR,
|
|
115
|
+
rule: 'link-component-without-doctype',
|
|
116
|
+
message: `Field "${field.fieldname}" renders with "${field.component}", which is a link component, ` +
|
|
117
|
+
`but has no \`doctype\` to name its target`,
|
|
99
118
|
doctype,
|
|
100
119
|
fieldname: field.fieldname,
|
|
101
120
|
});
|
|
102
121
|
}
|
|
103
122
|
// Validate nested schemas recursively (fieldset only; table columns are ColumnSchema not DoctypeField)
|
|
104
123
|
if (field.kind === 'fieldset') {
|
|
105
|
-
issues.push(...this.validateRequiredProperties(doctype, field.schema));
|
|
124
|
+
issues.push(...this.validateRequiredProperties(doctype, field.schema, links));
|
|
106
125
|
}
|
|
107
126
|
}
|
|
108
127
|
return issues;
|
|
@@ -114,29 +133,14 @@ export class SchemaValidator {
|
|
|
114
133
|
validateLinkFields(doctype, schema, registry) {
|
|
115
134
|
const issues = [];
|
|
116
135
|
for (const field of schema) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
fieldname: field.fieldname,
|
|
126
|
-
});
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const targetDoctype = typeof options === 'string' ? options : '';
|
|
130
|
-
if (!targetDoctype) {
|
|
131
|
-
issues.push({
|
|
132
|
-
severity: ValidationSeverity.ERROR,
|
|
133
|
-
rule: 'link-invalid-options',
|
|
134
|
-
message: `Link field "${field.fieldname}" has invalid options format (expected string doctype name)`,
|
|
135
|
-
doctype,
|
|
136
|
-
fieldname: field.fieldname,
|
|
137
|
-
});
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
136
|
+
// `doctype` is both the link marker and its target, and the schema types it as a
|
|
137
|
+
// non-empty string — so there is no "missing target" or "malformed target" state left
|
|
138
|
+
// to check here. The rules that did (`link-missing-options`, `link-invalid-options`)
|
|
139
|
+
// were removed with the `options`-as-link-target convention; the case they actually
|
|
140
|
+
// guarded — a link component with no target — is now `link-component-without-doctype`,
|
|
141
|
+
// which fires in validateRequiredProperties whether or not a registry is configured.
|
|
142
|
+
if (field.kind === 'field' && field.doctype) {
|
|
143
|
+
const targetDoctype = field.doctype;
|
|
140
144
|
const targetMeta = registry.registry[targetDoctype] || registry.registry[targetDoctype.toLowerCase()];
|
|
141
145
|
if (!targetMeta) {
|
|
142
146
|
issues.push({
|
|
@@ -162,10 +166,10 @@ export class SchemaValidator {
|
|
|
162
166
|
*/
|
|
163
167
|
validateLinkDeclarations(doctype, links, schema, registry) {
|
|
164
168
|
const issues = [];
|
|
165
|
-
// Build a map of
|
|
169
|
+
// Build a map of link fields by fieldname for quick lookup
|
|
166
170
|
const linkFieldsByFieldname = new Map();
|
|
167
171
|
for (const field of schema) {
|
|
168
|
-
if (field.kind === 'field' && field.
|
|
172
|
+
if (field.kind === 'field' && field.doctype) {
|
|
169
173
|
linkFieldsByFieldname.set(field.fieldname, field);
|
|
170
174
|
}
|
|
171
175
|
}
|
|
@@ -223,7 +227,8 @@ export class SchemaValidator {
|
|
|
223
227
|
if (link.fieldname) {
|
|
224
228
|
const linkField = linkFieldsByFieldname.get(link.fieldname);
|
|
225
229
|
if (linkField && linkField.kind === 'field') {
|
|
226
|
-
|
|
230
|
+
// Map membership implies `doctype` is set — that is the map's build condition.
|
|
231
|
+
const linkFieldTarget = linkField.doctype;
|
|
227
232
|
if (linkFieldTarget && linkFieldTarget !== link.target) {
|
|
228
233
|
issues.push({
|
|
229
234
|
severity: ValidationSeverity.ERROR,
|
|
@@ -237,20 +242,12 @@ export class SchemaValidator {
|
|
|
237
242
|
}
|
|
238
243
|
}
|
|
239
244
|
}
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
severity: ValidationSeverity.ERROR,
|
|
247
|
-
rule: 'link-field-without-declaration',
|
|
248
|
-
message: `Link field "${fieldname}" has no corresponding link declaration`,
|
|
249
|
-
doctype,
|
|
250
|
-
fieldname,
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}
|
|
245
|
+
// NOTE: there is deliberately no "every link field needs a declaration" rule. A plain foreign
|
|
246
|
+
// key is a link with no `links` entry — the map is additive, carrying expansion metadata
|
|
247
|
+
// (backlink/fetch/cardinality), and is not required. Such a rule would contradict
|
|
248
|
+
// `Registry.resolveFields`, which resolves undeclared links to inline pickers, and would flag
|
|
249
|
+
// every doctype that mixes an expanded relation with a plain FK (e.g. `country`: a `links`
|
|
250
|
+
// map for states/languages/subdivisions plus a plain `continent` picker).
|
|
254
251
|
return issues;
|
|
255
252
|
}
|
|
256
253
|
/**
|
package/dist/src/stonecrop.d.ts
CHANGED
|
@@ -108,7 +108,6 @@ export declare class Stonecrop {
|
|
|
108
108
|
config: import("vue").Ref<{
|
|
109
109
|
maxOperations?: number | undefined;
|
|
110
110
|
enableCrossTabSync?: boolean | undefined;
|
|
111
|
-
autoSyncInterval?: number | undefined;
|
|
112
111
|
enablePersistence?: boolean | undefined;
|
|
113
112
|
persistenceKeyPrefix?: string | undefined;
|
|
114
113
|
userId?: string | undefined;
|
|
@@ -116,7 +115,6 @@ export declare class Stonecrop {
|
|
|
116
115
|
}, OperationLogConfig | {
|
|
117
116
|
maxOperations?: number | undefined;
|
|
118
117
|
enableCrossTabSync?: boolean | undefined;
|
|
119
|
-
autoSyncInterval?: number | undefined;
|
|
120
118
|
enablePersistence?: boolean | undefined;
|
|
121
119
|
persistenceKeyPrefix?: string | undefined;
|
|
122
120
|
userId?: string | undefined;
|
|
@@ -194,7 +192,6 @@ export declare class Stonecrop {
|
|
|
194
192
|
config: import("vue").Ref<{
|
|
195
193
|
maxOperations?: number | undefined;
|
|
196
194
|
enableCrossTabSync?: boolean | undefined;
|
|
197
|
-
autoSyncInterval?: number | undefined;
|
|
198
195
|
enablePersistence?: boolean | undefined;
|
|
199
196
|
persistenceKeyPrefix?: string | undefined;
|
|
200
197
|
userId?: string | undefined;
|
|
@@ -202,7 +199,6 @@ export declare class Stonecrop {
|
|
|
202
199
|
}, OperationLogConfig | {
|
|
203
200
|
maxOperations?: number | undefined;
|
|
204
201
|
enableCrossTabSync?: boolean | undefined;
|
|
205
|
-
autoSyncInterval?: number | undefined;
|
|
206
202
|
enablePersistence?: boolean | undefined;
|
|
207
203
|
persistenceKeyPrefix?: string | undefined;
|
|
208
204
|
userId?: string | undefined;
|
|
@@ -280,7 +276,6 @@ export declare class Stonecrop {
|
|
|
280
276
|
config: import("vue").Ref<{
|
|
281
277
|
maxOperations?: number | undefined;
|
|
282
278
|
enableCrossTabSync?: boolean | undefined;
|
|
283
|
-
autoSyncInterval?: number | undefined;
|
|
284
279
|
enablePersistence?: boolean | undefined;
|
|
285
280
|
persistenceKeyPrefix?: string | undefined;
|
|
286
281
|
userId?: string | undefined;
|
|
@@ -288,7 +283,6 @@ export declare class Stonecrop {
|
|
|
288
283
|
}, OperationLogConfig | {
|
|
289
284
|
maxOperations?: number | undefined;
|
|
290
285
|
enableCrossTabSync?: boolean | undefined;
|
|
291
|
-
autoSyncInterval?: number | undefined;
|
|
292
286
|
enablePersistence?: boolean | undefined;
|
|
293
287
|
persistenceKeyPrefix?: string | undefined;
|
|
294
288
|
userId?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,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OAAO;IAInB;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IA6BnE;;;;;;OAMG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA+B7E;;;;;;;;;OASG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAoB1D;;;;;;;;;;;;;OAaG;IACG,eAAe,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;KAAE,GAC9C,OAAO,CAAC,IAAI,CAAC;IAgChB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CA2BzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,SAAS,CAEpD"}
|
|
@@ -3,5 +3,7 @@ declare const hst: HST;
|
|
|
3
3
|
declare const pinia: import("pinia").Pinia;
|
|
4
4
|
export { hst, pinia };
|
|
5
5
|
export { useOperationLogStore } from './operation-log';
|
|
6
|
+
export { useValidationStore } from './validation';
|
|
7
|
+
export type { ValidationError } from './validation';
|
|
6
8
|
export type { HSTNode } from './hst';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,QAAA,MAAM,GAAG,KAAoB,CAAA;AAC7B,QAAA,MAAM,KAAK,uBAAgB,CAAA;AAU3B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,QAAA,MAAM,GAAG,KAAoB,CAAA;AAC7B,QAAA,MAAM,KAAK,uBAAgB,CAAA;AAU3B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,YAAY,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA"}
|
package/dist/src/stores/index.js
CHANGED