@stonecrop/stonecrop 0.10.16 → 0.11.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.
- package/README.md +72 -29
- package/dist/composables/lazy-link.js +125 -0
- package/dist/composables/stonecrop.js +123 -68
- package/dist/doctype.js +10 -2
- package/dist/field-triggers.js +15 -3
- package/dist/index.js +4 -3
- package/dist/registry.js +261 -101
- package/dist/schema-validator.js +105 -1
- package/dist/src/composables/lazy-link.d.ts +25 -0
- package/dist/src/composables/lazy-link.d.ts.map +1 -0
- package/dist/src/composables/operation-log.d.ts +5 -5
- package/dist/src/composables/operation-log.d.ts.map +1 -1
- package/dist/src/composables/stonecrop.d.ts +11 -1
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +9 -1
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/field-triggers.d.ts +6 -0
- package/dist/src/field-triggers.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/registry.d.ts +102 -23
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/schema-validator.d.ts +8 -1
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +73 -28
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/hst.d.ts +5 -75
- package/dist/src/stores/hst.d.ts.map +1 -1
- package/dist/src/stores/operation-log.d.ts +14 -14
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/src/types/composable.d.ts +50 -12
- package/dist/src/types/composable.d.ts.map +1 -1
- package/dist/src/types/doctype.d.ts +6 -7
- package/dist/src/types/doctype.d.ts.map +1 -1
- package/dist/src/types/field-triggers.d.ts +1 -1
- package/dist/src/types/field-triggers.d.ts.map +1 -1
- package/dist/src/types/hst.d.ts +70 -0
- package/dist/src/types/hst.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/operation-log.d.ts +4 -4
- package/dist/src/types/operation-log.d.ts.map +1 -1
- package/dist/src/types/schema-validator.d.ts +2 -0
- package/dist/src/types/schema-validator.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +317 -99
- package/dist/stonecrop.js +2191 -1897
- package/dist/stonecrop.js.map +1 -1
- package/dist/stores/hst.js +27 -25
- package/dist/stores/operation-log.js +59 -47
- package/dist/types/hst.js +0 -0
- package/dist/types/index.js +1 -0
- package/package.json +5 -5
- package/src/composables/lazy-link.ts +146 -0
- package/src/composables/operation-log.ts +1 -1
- package/src/composables/stonecrop.ts +142 -73
- package/src/doctype.ts +13 -4
- package/src/field-triggers.ts +18 -4
- package/src/index.ts +4 -2
- package/src/registry.ts +289 -111
- package/src/schema-validator.ts +120 -1
- package/src/stonecrop.ts +230 -106
- package/src/stores/hst.ts +29 -104
- package/src/stores/operation-log.ts +64 -50
- package/src/types/composable.ts +55 -12
- package/src/types/doctype.ts +6 -7
- package/src/types/field-triggers.ts +1 -1
- package/src/types/hst.ts +77 -0
- package/src/types/index.ts +1 -0
- package/src/types/operation-log.ts +4 -4
- package/src/types/schema-validator.ts +2 -0
- package/dist/stonecrop.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HSTNode } from '../
|
|
1
|
+
import type { HSTNode } from '../types/hst';
|
|
2
2
|
import type { OperationLogConfig } from '../types/operation-log';
|
|
3
3
|
/**
|
|
4
4
|
* Composable for operation log management
|
|
@@ -48,8 +48,8 @@ export declare function useOperationLog(config?: Partial<OperationLogConfig>): {
|
|
|
48
48
|
actionError?: string | undefined;
|
|
49
49
|
userId?: string | undefined;
|
|
50
50
|
metadata?: Record<string, any> | undefined;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
ancestorOperationId?: string | undefined;
|
|
52
|
+
descendantOperationIds?: string[] | undefined;
|
|
53
53
|
}[], import("..").HSTOperation[] | {
|
|
54
54
|
id: string;
|
|
55
55
|
type: import("..").HSTOperationType;
|
|
@@ -72,8 +72,8 @@ export declare function useOperationLog(config?: Partial<OperationLogConfig>): {
|
|
|
72
72
|
actionError?: string | undefined;
|
|
73
73
|
userId?: string | undefined;
|
|
74
74
|
metadata?: Record<string, any> | undefined;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
ancestorOperationId?: string | undefined;
|
|
76
|
+
descendantOperationIds?: string[] | undefined;
|
|
77
77
|
}[]>;
|
|
78
78
|
currentIndex: import("vue").Ref<number, number>;
|
|
79
79
|
undoRedoState: import("vue").ComputedRef<import("..").UndoRedoState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/composables/operation-log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/composables/operation-log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoB3C,OAAO,KAAG,OAAO;qBAOjB,OAAO,KAAG,OAAO;;gCAcN,MAAM,KAAG,MAAM,GAAG,IAAI;;;gCAqBtB,MAAM,aAAa,MAAM;;oCAgBrB,MAAM,UAAU,MAAM;yBAcnD,MAAM,cACH,MAAM,cACN,MAAM,EAAE,WACZ,SAAS,GAAG,SAAS,GAAG,SAAS,UACjC,MAAM,KACZ,MAAM;yBAQmB,OAAO,CAAC,kBAAkB,CAAC;EA2BvD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,UAAO,QAqCrE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYzG"}
|
|
@@ -10,7 +10,17 @@ import type { BaseStonecropReturn, HSTStonecropReturn } from '../types/composabl
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function useStonecrop(): BaseStonecropReturn | HSTStonecropReturn;
|
|
12
12
|
/**
|
|
13
|
-
* Unified Stonecrop composable with HST integration for a specific doctype and record
|
|
13
|
+
* Unified Stonecrop composable with HST integration for a specific doctype and record.
|
|
14
|
+
*
|
|
15
|
+
* When a `Doctype` instance is passed, all synchronous initialisation (`hstStore`,
|
|
16
|
+
* `resolvedSchema`, `formData`, `handleHSTChange`, operation-log wiring) is performed
|
|
17
|
+
* during `setup()` — before the first render and without awaiting any lifecycle hook.
|
|
18
|
+
* Callers can read `hstStore.value`, `resolvedSchema.value`, and `formData.value`
|
|
19
|
+
* immediately after calling this composable; no `nextTick`, `flushPromises`, or
|
|
20
|
+
* `setTimeout` is required.
|
|
21
|
+
*
|
|
22
|
+
* The only remaining async work in `onMounted` is fetching an existing record from the
|
|
23
|
+
* server when `recordId` is not `'new'`, and lazy-loading a doctype by slug string.
|
|
14
24
|
*
|
|
15
25
|
* @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
|
|
16
26
|
* @returns Stonecrop instance with full HST integration utilities
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAkC,MAAM,qBAAqB,CAAA;AAIlH;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,mBAAmB,GAAG,kBAAkB,CAAA;AACxE
|
|
1
|
+
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAkC,MAAM,qBAAqB,CAAA;AAIlH;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,mBAAmB,GAAG,kBAAkB,CAAA;AACxE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACrC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,EAAE,OAAO,GAAG,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,kBAAkB,CAAA"}
|
package/dist/src/doctype.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
+
import type { LinkDeclaration } from '@stonecrop/schema';
|
|
2
3
|
import { Component } from 'vue';
|
|
3
4
|
import type { ImmutableDoctype } from './types';
|
|
4
5
|
import type { DoctypeConfig } from './types/doctype';
|
|
@@ -43,6 +44,12 @@ export default class Doctype {
|
|
|
43
44
|
* @readonly
|
|
44
45
|
*/
|
|
45
46
|
readonly component?: Component;
|
|
47
|
+
/**
|
|
48
|
+
* Relationship links to other doctypes
|
|
49
|
+
* @public
|
|
50
|
+
* @readonly
|
|
51
|
+
*/
|
|
52
|
+
readonly links?: Record<string, LinkDeclaration>;
|
|
46
53
|
/**
|
|
47
54
|
* Creates a new Doctype instance
|
|
48
55
|
* @param doctype - The doctype name
|
|
@@ -50,8 +57,9 @@ export default class Doctype {
|
|
|
50
57
|
* @param workflow - The doctype workflow configuration (XState machine)
|
|
51
58
|
* @param actions - The doctype actions and field triggers
|
|
52
59
|
* @param component - Optional Vue component for rendering the doctype
|
|
60
|
+
* @param links - Optional relationship links to other doctypes
|
|
53
61
|
*/
|
|
54
|
-
constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
|
|
62
|
+
constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component, links?: Record<string, LinkDeclaration>);
|
|
55
63
|
/**
|
|
56
64
|
* Creates a Doctype instance from a plain configuration object.
|
|
57
65
|
* Handles conversion of arrays to Immutable.js collections internally.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,mBAAmB,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD;;;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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CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC7B,GACD,SAAS;IAQZ;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
|
|
@@ -27,6 +27,12 @@ export declare class FieldTriggerEngine {
|
|
|
27
27
|
* @param fn - The action function
|
|
28
28
|
*/
|
|
29
29
|
registerAction(name: string, fn: FieldActionFunction): void;
|
|
30
|
+
/**
|
|
31
|
+
* Look up a registered action function by name.
|
|
32
|
+
* Returns `undefined` if the action has not been registered.
|
|
33
|
+
* @param name - The action name
|
|
34
|
+
*/
|
|
35
|
+
getAction(name: string): FieldActionFunction | undefined;
|
|
30
36
|
/**
|
|
31
37
|
* Register a global XState transition action function
|
|
32
38
|
* @param name - The name of the transition action
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-triggers.d.ts","sourceRoot":"","sources":["../../src/field-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAEpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"field-triggers.d.ts","sourceRoot":"","sources":["../../src/field-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAEpD,OAAO,KAAK,EAEX,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EAEnB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,MAAM,wBAAwB,CAAA;AAE/B;;;;GAIG;AACH,qBAAa,kBAAkB;IAC9B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAA;IAEhC,OAAO,CAAC,OAAO,CAA4F;IAC3G,OAAO,CAAC,cAAc,CAA2C;IACjE,OAAO,CAAC,kBAAkB,CAA2C;IACrE,OAAO,CAAC,mBAAmB,CAA0C;IACrE,OAAO,C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,18 +1,19 @@
|
|
|
1
1
|
export type * from '@stonecrop/aform/types';
|
|
2
2
|
export type * from '@stonecrop/atable/types';
|
|
3
|
+
import { useLazyLink } from './composables/lazy-link';
|
|
3
4
|
import { useStonecrop } from './composables/stonecrop';
|
|
4
5
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
5
6
|
import Doctype from './doctype';
|
|
6
7
|
import { FieldTriggerEngine, getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
|
|
7
8
|
import plugin from './plugins';
|
|
8
9
|
import Registry from './registry';
|
|
9
|
-
import { Stonecrop,
|
|
10
|
+
import { Stonecrop, getStonecrop } from './stonecrop';
|
|
10
11
|
import { HST, createHST, type HSTNode } from './stores/hst';
|
|
11
12
|
import { useOperationLogStore } from './stores/operation-log';
|
|
12
13
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
13
14
|
import { ValidationSeverity } from './types/schema-validator';
|
|
14
15
|
export type * from './types';
|
|
15
16
|
export { ValidationSeverity };
|
|
16
|
-
export { Doctype, Registry, Stonecrop, useStonecrop, HST, createHST, HSTNode, FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch,
|
|
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, };
|
|
17
18
|
export default plugin;
|
|
18
19
|
//# 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,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,
|
|
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,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EAEZ,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,YAAY,GACZ,CAAA;AAGD,eAAe,MAAM,CAAA"}
|
package/dist/src/registry.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
+
import type { DoctypeMeta, LinkDeclaration } from '@stonecrop/schema';
|
|
2
3
|
import { Router } from 'vue-router';
|
|
3
4
|
import Doctype from './doctype';
|
|
4
5
|
import { RouteContext } from './types/registry';
|
|
@@ -19,9 +20,27 @@ export default class Registry {
|
|
|
19
20
|
readonly name: string;
|
|
20
21
|
/**
|
|
21
22
|
* The registry property contains a collection of doctypes
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `{}`
|
|
22
25
|
* @see {@link Doctype}
|
|
23
26
|
*/
|
|
24
27
|
readonly registry: Record<string, Doctype>;
|
|
28
|
+
/**
|
|
29
|
+
* Reverse index: backlink fieldname → list of \{ doctype slug, link fieldname \}.
|
|
30
|
+
* Multiple doctypes can declare a link with the same backlink name, so each key
|
|
31
|
+
* maps to an array. Built at schema load time for O(1) ancestor lookups.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue `new Map()`
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
private _ancestorIndex;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the ancestor index needs rebuilding
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue `true`
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
private _ancestorIndexDirty;
|
|
25
44
|
/**
|
|
26
45
|
* The Vue router instance
|
|
27
46
|
* @see {@link https://router.vuejs.org/}
|
|
@@ -48,35 +67,32 @@ export default class Registry {
|
|
|
48
67
|
/**
|
|
49
68
|
* Resolve nested Doctype fields in a schema by embedding child schemas inline.
|
|
50
69
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
70
|
+
* Accepts a Doctype and extracts `fields` and `links` internally.
|
|
71
|
+
* Fields array contains both scalar fields and link fields (with fieldtype: 'Link').
|
|
72
|
+
* Render order is determined by the order of fields in the fields array.
|
|
54
73
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* -
|
|
58
|
-
* `
|
|
74
|
+
* For each link field:
|
|
75
|
+
* - Looks up the corresponding link declaration in `links` by fieldname
|
|
76
|
+
* - `cardinality: 'noneOrMany'` or `'atLeastOne'`: auto-derives `columns` from the target's schema,
|
|
77
|
+
* sets `component` to `link.component ?? 'ATable'`, `config: { view: 'list' }`, `rows: []`.
|
|
78
|
+
* - `cardinality: 'one'` or `'atMostOne'`: embeds the target schema as the entry's
|
|
79
|
+
* `schema` property, sets `component` to `link.component ?? 'AForm'`.
|
|
59
80
|
*
|
|
60
81
|
* Recurses for deeply nested doctypes. Circular references are protected against.
|
|
82
|
+
* Returns a new array — does not mutate the original.
|
|
61
83
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
* @returns A new schema array with nested Doctype fields resolved
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts
|
|
69
|
-
* registry.addDoctype(addressDoctype)
|
|
70
|
-
* registry.addDoctype(customerDoctype)
|
|
71
|
-
*
|
|
72
|
-
* // Before: customer schema has { fieldname: 'address', fieldtype: 'Doctype', options: 'address' }
|
|
73
|
-
* const resolved = registry.resolveSchema(customerSchema)
|
|
74
|
-
* // After: address field now has schema: [...address fields...]
|
|
75
|
-
* ```
|
|
84
|
+
* @param doctype - The doctype to resolve
|
|
85
|
+
* @param visited - Internal — set of already-visited doctype slugs for cycle detection
|
|
86
|
+
* @returns A new schema array with nested links resolved
|
|
76
87
|
*
|
|
77
88
|
* @public
|
|
78
89
|
*/
|
|
79
|
-
resolveSchema(
|
|
90
|
+
resolveSchema(doctype: Doctype, visited?: Set<string>): SchemaTypes[];
|
|
91
|
+
/**
|
|
92
|
+
* Build an ATable configuration from a field and child schema
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
private buildTableConfig;
|
|
80
96
|
/**
|
|
81
97
|
* Initialize a new record with default values based on a schema.
|
|
82
98
|
*
|
|
@@ -87,7 +103,7 @@ export default class Registry {
|
|
|
87
103
|
* - Check → `false`
|
|
88
104
|
* - Int, Float, Decimal, Currency, Quantity → `0`
|
|
89
105
|
* - JSON → `{}`
|
|
90
|
-
* - Doctype with `cardinality: '
|
|
106
|
+
* - Doctype with `cardinality: 'noneOrMany'` or `'atLeastOne'` → `[]`
|
|
91
107
|
* - Doctype without `cardinality` or `cardinality: 'one'` → recursively initializes nested record
|
|
92
108
|
* - All others → `null`
|
|
93
109
|
*
|
|
@@ -113,5 +129,68 @@ export default class Registry {
|
|
|
113
129
|
* @public
|
|
114
130
|
*/
|
|
115
131
|
getDoctype(slug: string): Doctype | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Get all links declared on a doctype.
|
|
134
|
+
*
|
|
135
|
+
* @param doctypeSlug - The doctype slug to get links for
|
|
136
|
+
* @returns Array of link declarations with fieldname, or empty array if none
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* const links = registry.getDescendantLinks('recipe')
|
|
141
|
+
* // [{ fieldname: 'tasks', target: 'recipe-task', cardinality: 'noneOrMany', backlink: 'recipe' }]
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
getDescendantLinks(doctypeSlug: string): Array<LinkDeclaration & {
|
|
147
|
+
fieldname: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Get links on other doctypes that target the given doctype.
|
|
151
|
+
*
|
|
152
|
+
* @param doctypeSlug - The doctype slug to find ancestor links for
|
|
153
|
+
* @returns Array of link declarations with fieldname and declaring doctype slug, or empty array
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* const ancestors = registry.getAncestorLinks('recipe-task')
|
|
158
|
+
* // [{ fieldname: 'tasks', target: 'recipe-task', cardinality: 'noneOrMany', backlink: 'recipe', doctype: 'recipe' }]
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
getAncestorLinks(doctypeSlug: string): Array<LinkDeclaration & {
|
|
164
|
+
fieldname: string;
|
|
165
|
+
doctype: string;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Ensure the ancestor index is up to date
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
private _ensureAncestorIndex;
|
|
172
|
+
/**
|
|
173
|
+
* Convert the registry to a Map of DoctypeMeta objects for use with StonecropClient.
|
|
174
|
+
*
|
|
175
|
+
* This allows passing a Registry instance to StonecropClient by deriving the
|
|
176
|
+
* Map\<string, DoctypeMeta\> that StonecropClient needs for building nested GraphQL queries.
|
|
177
|
+
*
|
|
178
|
+
* @returns Map of doctype metadata keyed by doctype name
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const registry = new Registry()
|
|
183
|
+
* registry.addDoctype(Doctype.fromObject(customerSchema))
|
|
184
|
+
* registry.addDoctype(Doctype.fromObject(orderSchema))
|
|
185
|
+
*
|
|
186
|
+
* const client = new StonecropClient({
|
|
187
|
+
* endpoint: '/graphql',
|
|
188
|
+
* registry: registry.toMetaMap(), // Convert once, use with client
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
toMetaMap(): Map<string, DoctypeMeta>;
|
|
116
195
|
}
|
|
117
196
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAA;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAa;IAElC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAK;IAE/C;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc,CAAqE;IAE3F;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CAAgB;IAE3C;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAExB;;;;OAIG;gBACS,MAAM,CAAC,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LinkDeclaration } from '@stonecrop/schema';
|
|
7
8
|
import type { List, Map as ImmutableMap } from 'immutable';
|
|
8
9
|
import type { AnyStateNodeConfig } from 'xstate';
|
|
9
10
|
import type Registry from './registry';
|
|
@@ -25,9 +26,10 @@ export declare class SchemaValidator {
|
|
|
25
26
|
* @param schema - Schema fields (List or Array)
|
|
26
27
|
* @param workflow - Optional workflow configuration
|
|
27
28
|
* @param actions - Optional actions map
|
|
29
|
+
* @param links - Optional links object
|
|
28
30
|
* @returns Validation result
|
|
29
31
|
*/
|
|
30
|
-
validate(doctype: string, schema: List<SchemaTypes> | SchemaTypes[] | undefined, workflow?: AnyStateNodeConfig, actions?: ImmutableMap<string, string[]> | Map<string, string[]>): ValidationResult;
|
|
32
|
+
validate(doctype: string, schema: List<SchemaTypes> | SchemaTypes[] | undefined, workflow?: AnyStateNodeConfig, actions?: ImmutableMap<string, string[]> | Map<string, string[]>, links?: Record<string, LinkDeclaration>): ValidationResult;
|
|
31
33
|
/**
|
|
32
34
|
* Validates that required schema properties are present
|
|
33
35
|
* @internal
|
|
@@ -38,6 +40,11 @@ export declare class SchemaValidator {
|
|
|
38
40
|
* @internal
|
|
39
41
|
*/
|
|
40
42
|
private validateLinkFields;
|
|
43
|
+
/**
|
|
44
|
+
* Validates link declarations: target resolution, backlink consistency, Link field correspondence
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
private validateLinkDeclarations;
|
|
41
48
|
/**
|
|
42
49
|
* Validates workflow state machine configuration
|
|
43
50
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB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C;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA4D1B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IA0GhC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAmFxB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;CAuClC;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,WAAW,CAAC,GAAG,WAAW,EAAE,GAAG,SAAS,EACrD,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"}
|
package/dist/src/stonecrop.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type SchemaTypes } from '@stonecrop/aform';
|
|
2
1
|
import type { DataClient } from '@stonecrop/schema';
|
|
3
2
|
import Doctype from './doctype';
|
|
4
3
|
import Registry from './registry';
|
|
@@ -18,6 +17,7 @@ export declare class Stonecrop {
|
|
|
18
17
|
* @internal
|
|
19
18
|
*/
|
|
20
19
|
static _root: Stonecrop;
|
|
20
|
+
/** The HST store instance for reactive state management */
|
|
21
21
|
private hstStore;
|
|
22
22
|
private _operationLogStore?;
|
|
23
23
|
private _operationLogConfig?;
|
|
@@ -77,8 +77,8 @@ export declare class Stonecrop {
|
|
|
77
77
|
actionError?: string | undefined;
|
|
78
78
|
userId?: string | undefined;
|
|
79
79
|
metadata?: Record<string, any> | undefined;
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
ancestorOperationId?: string | undefined;
|
|
81
|
+
descendantOperationIds?: string[] | undefined;
|
|
82
82
|
}[], import("./types").HSTOperation[] | {
|
|
83
83
|
id: string;
|
|
84
84
|
type: import("./types").HSTOperationType;
|
|
@@ -101,8 +101,8 @@ export declare class Stonecrop {
|
|
|
101
101
|
actionError?: string | undefined;
|
|
102
102
|
userId?: string | undefined;
|
|
103
103
|
metadata?: Record<string, any> | undefined;
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
ancestorOperationId?: string | undefined;
|
|
105
|
+
descendantOperationIds?: string[] | undefined;
|
|
106
106
|
}[]>;
|
|
107
107
|
currentIndex: import("vue").Ref<number, number>;
|
|
108
108
|
config: import("vue").Ref<{
|
|
@@ -140,7 +140,7 @@ export declare class Stonecrop {
|
|
|
140
140
|
getSnapshot: () => import("./types").OperationLogSnapshot;
|
|
141
141
|
markIrreversible: (operationId: string, reason: string) => void;
|
|
142
142
|
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
|
|
143
|
-
}, "operations" | "
|
|
143
|
+
}, "operations" | "currentIndex" | "config" | "clientId">, Pick<{
|
|
144
144
|
operations: import("vue").Ref<{
|
|
145
145
|
id: string;
|
|
146
146
|
type: import("./types").HSTOperationType;
|
|
@@ -163,8 +163,8 @@ export declare class Stonecrop {
|
|
|
163
163
|
actionError?: string | undefined;
|
|
164
164
|
userId?: string | undefined;
|
|
165
165
|
metadata?: Record<string, any> | undefined;
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
ancestorOperationId?: string | undefined;
|
|
167
|
+
descendantOperationIds?: string[] | undefined;
|
|
168
168
|
}[], import("./types").HSTOperation[] | {
|
|
169
169
|
id: string;
|
|
170
170
|
type: import("./types").HSTOperationType;
|
|
@@ -187,8 +187,8 @@ export declare class Stonecrop {
|
|
|
187
187
|
actionError?: string | undefined;
|
|
188
188
|
userId?: string | undefined;
|
|
189
189
|
metadata?: Record<string, any> | undefined;
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
ancestorOperationId?: string | undefined;
|
|
191
|
+
descendantOperationIds?: string[] | undefined;
|
|
192
192
|
}[]>;
|
|
193
193
|
currentIndex: import("vue").Ref<number, number>;
|
|
194
194
|
config: import("vue").Ref<{
|
|
@@ -249,8 +249,8 @@ export declare class Stonecrop {
|
|
|
249
249
|
actionError?: string | undefined;
|
|
250
250
|
userId?: string | undefined;
|
|
251
251
|
metadata?: Record<string, any> | undefined;
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
ancestorOperationId?: string | undefined;
|
|
253
|
+
descendantOperationIds?: string[] | undefined;
|
|
254
254
|
}[], import("./types").HSTOperation[] | {
|
|
255
255
|
id: string;
|
|
256
256
|
type: import("./types").HSTOperationType;
|
|
@@ -273,8 +273,8 @@ export declare class Stonecrop {
|
|
|
273
273
|
actionError?: string | undefined;
|
|
274
274
|
userId?: string | undefined;
|
|
275
275
|
metadata?: Record<string, any> | undefined;
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
ancestorOperationId?: string | undefined;
|
|
277
|
+
descendantOperationIds?: string[] | undefined;
|
|
278
278
|
}[]>;
|
|
279
279
|
currentIndex: import("vue").Ref<number, number>;
|
|
280
280
|
config: import("vue").Ref<{
|
|
@@ -370,7 +370,25 @@ export declare class Stonecrop {
|
|
|
370
370
|
* @param action - The action to run
|
|
371
371
|
* @param args - Action arguments (typically record IDs)
|
|
372
372
|
*/
|
|
373
|
-
runAction(doctype: Doctype, action: string, args?:
|
|
373
|
+
runAction(doctype: Doctype, action: string, args?: string[]): void;
|
|
374
|
+
/**
|
|
375
|
+
* Get the effective blockWorkflows value for a link.
|
|
376
|
+
* Returns true if blockWorkflows is explicitly true, or if it's absent and fetch method is 'sync'.
|
|
377
|
+
* @param link - The link declaration
|
|
378
|
+
* @returns Whether workflows should be blocked until this link is loaded
|
|
379
|
+
*/
|
|
380
|
+
private getEffectiveBlockWorkflows;
|
|
381
|
+
/**
|
|
382
|
+
* Check if workflow actions are ready to run (all required link data is loaded).
|
|
383
|
+
* A link's data is considered loaded if it exists in HST at `slug.recordId.linkname`.
|
|
384
|
+
* @param doctype - The doctype to check
|
|
385
|
+
* @param recordId - The record ID
|
|
386
|
+
* @returns Object with `ready: true` if all blocked links are loaded, or `ready: false` with `blockedLinks` array
|
|
387
|
+
*/
|
|
388
|
+
isWorkflowReady(doctype: Doctype, recordId: string): {
|
|
389
|
+
ready: boolean;
|
|
390
|
+
blockedLinks?: string[];
|
|
391
|
+
};
|
|
374
392
|
/**
|
|
375
393
|
* Get records from server using the configured data client.
|
|
376
394
|
* @param doctype - The doctype
|
|
@@ -438,23 +456,50 @@ export declare class Stonecrop {
|
|
|
438
456
|
*/
|
|
439
457
|
collectRecordPayload(doctype: Doctype, recordId: string): Record<string, any>;
|
|
440
458
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
459
|
+
* Scaffold empty descendant records from defaults for all descendant links.
|
|
460
|
+
*
|
|
461
|
+
* Initializes all scalar and link fields at their HST paths with default values.
|
|
462
|
+
* For new records, call this after setting up the doctype to ensure all paths exist.
|
|
463
|
+
*
|
|
464
|
+
* @param path - HST path (e.g., "customer.new")
|
|
465
|
+
* @param doctype - The doctype to initialize
|
|
466
|
+
* @public
|
|
467
|
+
*/
|
|
468
|
+
initializeNestedData(path: string, doctype: Doctype): void;
|
|
469
|
+
/**
|
|
470
|
+
* Fetch a record and its nested data from the server.
|
|
471
|
+
*
|
|
472
|
+
* Calls `_client.getRecord()` with nested sub-selections and stores each scalar field at its own HST path
|
|
473
|
+
* (`slug.recordId.fieldname`), descendants at the link-level path (`slug.recordId.linkname`).
|
|
474
|
+
*
|
|
475
|
+
* @param path - HST path (e.g., "recipe.r1")
|
|
476
|
+
* @param doctype - The doctype to fetch
|
|
477
|
+
* @param recordId - Record ID to fetch
|
|
478
|
+
* @param options - Query options (includeNested to control which links are fetched)
|
|
479
|
+
* @throws Error with code `"CLIENT_REQUIRED"` if no data client is configured
|
|
480
|
+
* @throws Error with code `"RECORD_NOT_FOUND"` if the server returns null
|
|
446
481
|
* @public
|
|
447
482
|
*/
|
|
448
|
-
|
|
483
|
+
fetchNestedData(path: string, doctype: Doctype, recordId: string, options?: {
|
|
484
|
+
includeNested?: boolean | string[];
|
|
485
|
+
}): Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* Recursively collect nested data from HST
|
|
488
|
+
* @param basePath - The base path in HST (e.g., "customer.123.address")
|
|
489
|
+
* @param doctype - The doctype whose links drive the recursive traversal
|
|
490
|
+
* @returns The collected data object
|
|
491
|
+
*/
|
|
492
|
+
private collectNestedData;
|
|
449
493
|
}
|
|
450
494
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
495
|
+
* Returns the global Stonecrop singleton instance, or `undefined` if no
|
|
496
|
+
* instance has been created yet.
|
|
497
|
+
*
|
|
498
|
+
* Use this when you need the Stonecrop instance outside a Vue component
|
|
499
|
+
* context (e.g., in workflow action handlers, plugin setup code, or
|
|
500
|
+
* non-component utilities). Inside a component, prefer `useStonecrop()`.
|
|
501
|
+
*
|
|
456
502
|
* @public
|
|
457
503
|
*/
|
|
458
|
-
declare function
|
|
459
|
-
export { collectNestedData };
|
|
504
|
+
export declare function getStonecrop(): Stonecrop | undefined;
|
|
460
505
|
//# sourceMappingURL=stonecrop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,CA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