@stonecrop/stonecrop 0.10.11 → 0.10.13
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/dist/composables/stonecrop.js +26 -110
- package/dist/field-triggers.js +5 -6
- package/dist/index.js +9 -6
- package/dist/plugins/index.js +4 -1
- package/dist/registry.js +62 -61
- package/dist/schema-validator.js +1 -13
- package/dist/src/composables/stonecrop.d.ts +2 -74
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +1 -27
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/field-triggers.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/registry.d.ts +13 -10
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/schema-validator.d.ts +1 -62
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +38 -17
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/operation-log.d.ts +1 -1
- package/dist/src/types/composable.d.ts +230 -0
- package/dist/src/types/composable.d.ts.map +1 -0
- package/dist/src/types/doctype.d.ts +57 -0
- package/dist/src/types/doctype.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +6 -67
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/plugin.d.ts +37 -0
- package/dist/src/types/plugin.d.ts.map +1 -0
- package/dist/src/types/schema-validator.d.ts +64 -0
- package/dist/src/types/schema-validator.d.ts.map +1 -0
- package/dist/src/types/stonecrop.d.ts +17 -0
- package/dist/src/types/stonecrop.d.ts.map +1 -0
- package/dist/stonecrop.css +1 -0
- package/dist/stonecrop.d.ts +206 -14
- package/dist/stonecrop.js +1751 -1631
- package/dist/stonecrop.js.map +1 -1
- package/dist/types/composable.js +0 -0
- package/dist/types/doctype.js +0 -0
- package/dist/types/index.js +7 -2
- package/dist/types/plugin.js +0 -0
- package/dist/types/schema-validator.js +13 -0
- package/dist/types/stonecrop.js +0 -0
- package/package.json +4 -4
- package/src/composables/stonecrop.ts +34 -218
- package/src/doctype.ts +2 -29
- package/src/field-triggers.ts +5 -6
- package/src/index.ts +12 -19
- package/src/plugins/index.ts +4 -1
- package/src/registry.ts +61 -66
- package/src/schema-validator.ts +3 -66
- package/src/stonecrop.ts +148 -17
- package/src/types/composable.ts +245 -0
- package/src/types/doctype.ts +60 -0
- package/src/types/index.ts +7 -74
- package/src/types/plugin.ts +38 -0
- package/src/types/schema-validator.ts +67 -0
- package/src/types/stonecrop.ts +17 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -2,20 +2,17 @@ export type * from '@stonecrop/aform/types';
|
|
|
2
2
|
export type * from '@stonecrop/atable/types';
|
|
3
3
|
import { useStonecrop } from './composables/stonecrop';
|
|
4
4
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
5
|
-
import Doctype
|
|
6
|
-
import { getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
|
|
5
|
+
import Doctype from './doctype';
|
|
6
|
+
import { FieldTriggerEngine, getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
|
|
7
7
|
import plugin from './plugins';
|
|
8
8
|
import Registry from './registry';
|
|
9
|
-
import {
|
|
9
|
+
import { Stonecrop, collectNestedData } from './stonecrop';
|
|
10
10
|
import { HST, createHST, type HSTNode } from './stores/hst';
|
|
11
11
|
import { useOperationLogStore } from './stores/operation-log';
|
|
12
12
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
13
|
+
import { ValidationSeverity } from './types/schema-validator';
|
|
13
14
|
export type * from './types';
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export type { FieldChangeContext, TransitionChangeContext, FieldTriggerExecutionResult, ActionExecutionResult, TransitionExecutionResult, FieldActionFunction, TransitionActionFunction, } from './types/field-triggers';
|
|
17
|
-
export type { ValidationIssue, ValidationResult, ValidatorOptions } from './schema-validator';
|
|
18
|
-
export { ValidationSeverity } from './schema-validator';
|
|
19
|
-
export { Doctype, DoctypeConfig, Registry, Stonecrop, StonecropOptions, useStonecrop, HST, createHST, HSTNode, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, };
|
|
15
|
+
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, collectNestedData, };
|
|
20
17
|
export default plugin;
|
|
21
18
|
//# 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,
|
|
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;AA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"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAY,MAAM,KAAK,CAAA;AA2BhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,QAAA,MAAM,MAAM,EAAE,MAqDb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/src/registry.d.ts
CHANGED
|
@@ -46,17 +46,18 @@ export default class Registry {
|
|
|
46
46
|
*/
|
|
47
47
|
addDoctype(doctype: Doctype): void;
|
|
48
48
|
/**
|
|
49
|
-
* Resolve nested Doctype
|
|
49
|
+
* Resolve nested Doctype fields in a schema by embedding child schemas inline.
|
|
50
50
|
*
|
|
51
51
|
* @remarks
|
|
52
52
|
* Walks the schema array and for each field with `fieldtype: 'Doctype'` and a string
|
|
53
|
-
* `options` value, looks up the referenced doctype in the registry and
|
|
54
|
-
* as the field's `schema` property. Recurses for deeply nested doctypes.
|
|
53
|
+
* `options` value, looks up the referenced doctype in the registry and:
|
|
55
54
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
55
|
+
* - If `cardinality: 'many'`: auto-derives `columns` from the child doctype's schema,
|
|
56
|
+
* sets `component: 'ATable'`, `config: { view: 'list' }`, and initializes `rows: []`.
|
|
57
|
+
* - Otherwise (default/`cardinality: 'one'`): embeds the child schema as the field's
|
|
58
|
+
* `schema` property for 1:1 nested forms.
|
|
59
|
+
*
|
|
60
|
+
* Recurses for deeply nested doctypes. Circular references are protected against.
|
|
60
61
|
*
|
|
61
62
|
* Returns a new array — does not mutate the original schema.
|
|
62
63
|
*
|
|
@@ -85,11 +86,13 @@ export default class Registry {
|
|
|
85
86
|
* - Data, Text → `''`
|
|
86
87
|
* - Check → `false`
|
|
87
88
|
* - Int, Float, Decimal, Currency, Quantity → `0`
|
|
88
|
-
* -
|
|
89
|
-
* -
|
|
89
|
+
* - JSON → `{}`
|
|
90
|
+
* - Doctype with `cardinality: 'many'` → `[]`
|
|
91
|
+
* - Doctype without `cardinality` or `cardinality: 'one'` → recursively initializes nested record
|
|
90
92
|
* - All others → `null`
|
|
91
93
|
*
|
|
92
|
-
* For Doctype fields with a resolved `schema` array, recursively
|
|
94
|
+
* For Doctype fields with a resolved `schema` array (cardinality: 'one'), recursively
|
|
95
|
+
* initializes the nested record.
|
|
93
96
|
*
|
|
94
97
|
* @param schema - The schema array to derive defaults from
|
|
95
98
|
* @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,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,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;IAErB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE1C;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAExB;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAWjG;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEpE;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO;IAsB3B
|
|
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,OAAO,GAAG,SAAS;CAgB7C"}
|
|
@@ -7,68 +7,7 @@ import type { SchemaTypes } from '@stonecrop/aform';
|
|
|
7
7
|
import type { List, Map as ImmutableMap } from 'immutable';
|
|
8
8
|
import type { AnyStateNodeConfig } from 'xstate';
|
|
9
9
|
import type Registry from './registry';
|
|
10
|
-
|
|
11
|
-
* Validation severity levels
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare enum ValidationSeverity {
|
|
15
|
-
/** Blocking error that prevents save */
|
|
16
|
-
ERROR = "error",
|
|
17
|
-
/** Advisory warning that allows save */
|
|
18
|
-
WARNING = "warning",
|
|
19
|
-
/** Informational message */
|
|
20
|
-
INFO = "info"
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Validation issue
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export interface ValidationIssue {
|
|
27
|
-
/** Severity level */
|
|
28
|
-
severity: ValidationSeverity;
|
|
29
|
-
/** Validation rule that failed */
|
|
30
|
-
rule: string;
|
|
31
|
-
/** Human-readable message */
|
|
32
|
-
message: string;
|
|
33
|
-
/** Doctype name */
|
|
34
|
-
doctype?: string;
|
|
35
|
-
/** Field name if applicable */
|
|
36
|
-
fieldname?: string;
|
|
37
|
-
/** Additional context */
|
|
38
|
-
context?: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validation result
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export interface ValidationResult {
|
|
45
|
-
/** Whether validation passed (no blocking errors) */
|
|
46
|
-
valid: boolean;
|
|
47
|
-
/** List of validation issues */
|
|
48
|
-
issues: ValidationIssue[];
|
|
49
|
-
/** Count of errors */
|
|
50
|
-
errorCount: number;
|
|
51
|
-
/** Count of warnings */
|
|
52
|
-
warningCount: number;
|
|
53
|
-
/** Count of info messages */
|
|
54
|
-
infoCount: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Schema validator options
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
export interface ValidatorOptions {
|
|
61
|
-
/** Registry instance for doctype lookups */
|
|
62
|
-
registry?: Registry;
|
|
63
|
-
/** Whether to validate Link field targets */
|
|
64
|
-
validateLinkTargets?: boolean;
|
|
65
|
-
/** Whether to validate workflow reachability */
|
|
66
|
-
validateWorkflows?: boolean;
|
|
67
|
-
/** Whether to validate action registration */
|
|
68
|
-
validateActions?: boolean;
|
|
69
|
-
/** Whether to validate required schema properties */
|
|
70
|
-
validateRequiredProperties?: boolean;
|
|
71
|
-
}
|
|
10
|
+
import type { ValidationResult, ValidatorOptions } from './types/schema-validator';
|
|
72
11
|
/**
|
|
73
12
|
* Schema validator class
|
|
74
13
|
* @public
|
|
@@ -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,EAAE,MAAM,QAAQ,CAAA;
|
|
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,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;IAU1C;;;;;;;OAOG;IACH,QAAQ,CACP,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,WAAW,EAAE,GAAG,SAAS,EACrD,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;IAyCnB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAwClC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA4D1B;;;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,29 +1,23 @@
|
|
|
1
|
+
import { type SchemaTypes } from '@stonecrop/aform';
|
|
1
2
|
import type { DataClient } from '@stonecrop/schema';
|
|
2
3
|
import Doctype from './doctype';
|
|
3
4
|
import Registry from './registry';
|
|
4
5
|
import { type HSTNode } from './stores/hst';
|
|
5
6
|
import type { OperationLogConfig } from './types/operation-log';
|
|
6
7
|
import type { RouteContext } from './types/registry';
|
|
7
|
-
|
|
8
|
-
* Options for constructing a Stonecrop instance directly.
|
|
9
|
-
* When using the Vue plugin, pass these via `InstallOptions` instead.
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export interface StonecropOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Data client for fetching doctype metadata and records.
|
|
15
|
-
* Use \@stonecrop/graphql-client's StonecropClient for GraphQL backends,
|
|
16
|
-
* or implement DataClient for custom data sources.
|
|
17
|
-
*
|
|
18
|
-
* Can be set later via `setClient()` for deferred configuration.
|
|
19
|
-
*/
|
|
20
|
-
client?: DataClient;
|
|
21
|
-
}
|
|
8
|
+
import type { StonecropOptions } from './types/stonecrop';
|
|
22
9
|
/**
|
|
23
10
|
* Main Stonecrop class with HST integration and built-in Operation Log
|
|
24
11
|
* @public
|
|
25
12
|
*/
|
|
26
13
|
export declare class Stonecrop {
|
|
14
|
+
/**
|
|
15
|
+
* Singleton instance of Stonecrop. Only one Stonecrop instance can exist
|
|
16
|
+
* per application, ensuring consistent HST state and registry access.
|
|
17
|
+
* Subsequent constructor calls return this instance instead of creating new ones.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
static _root: Stonecrop;
|
|
27
21
|
private hstStore;
|
|
28
22
|
private _operationLogStore?;
|
|
29
23
|
private _operationLogConfig?;
|
|
@@ -31,7 +25,7 @@ export declare class Stonecrop {
|
|
|
31
25
|
/** The registry instance containing all doctype definitions */
|
|
32
26
|
readonly registry: Registry;
|
|
33
27
|
/**
|
|
34
|
-
* Creates a new Stonecrop instance with HST integration
|
|
28
|
+
* Creates a new Stonecrop instance with HST integration (singleton pattern)
|
|
35
29
|
* @param registry - The Registry instance containing doctype definitions
|
|
36
30
|
* @param operationLogConfig - Optional configuration for the operation log
|
|
37
31
|
* @param options - Options including the data client (can be set later via setClient)
|
|
@@ -146,7 +140,7 @@ export declare class Stonecrop {
|
|
|
146
140
|
getSnapshot: () => import("./types").OperationLogSnapshot;
|
|
147
141
|
markIrreversible: (operationId: string, reason: string) => void;
|
|
148
142
|
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
|
|
149
|
-
}, "operations" | "
|
|
143
|
+
}, "operations" | "clientId" | "currentIndex" | "config">, Pick<{
|
|
150
144
|
operations: import("vue").Ref<{
|
|
151
145
|
id: string;
|
|
152
146
|
type: import("./types").HSTOperationType;
|
|
@@ -435,5 +429,32 @@ export declare class Stonecrop {
|
|
|
435
429
|
* @public
|
|
436
430
|
*/
|
|
437
431
|
getRecordState(doctype: string | Doctype, recordId: string): string;
|
|
432
|
+
/**
|
|
433
|
+
* Collect a record payload with all nested doctype fields from HST
|
|
434
|
+
* @param doctype - The doctype metadata
|
|
435
|
+
* @param recordId - The record ID to collect
|
|
436
|
+
* @returns The complete record payload ready for API submission
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
collectRecordPayload(doctype: Doctype, recordId: string): Record<string, any>;
|
|
440
|
+
/**
|
|
441
|
+
* Load nested data from HST or initialize with defaults
|
|
442
|
+
* @param parentPath - The HST path to check for existing data
|
|
443
|
+
* @param childDoctype - The child doctype metadata
|
|
444
|
+
* @param _recordId - Optional record ID to load
|
|
445
|
+
* @returns The loaded or initialized data
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
loadNestedData(parentPath: string, childDoctype: Doctype, _recordId?: string): Record<string, any>;
|
|
438
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Recursively collect nested data from HST using pre-resolved schemas
|
|
452
|
+
* @param resolvedSchema - The already-resolved schema (with nested schemas embedded)
|
|
453
|
+
* @param basePath - The base path in HST (e.g., "customer.123.address")
|
|
454
|
+
* @param hstStore - The HST store instance
|
|
455
|
+
* @returns The collected data object
|
|
456
|
+
* @public
|
|
457
|
+
*/
|
|
458
|
+
declare function collectNestedData(resolvedSchema: SchemaTypes[], basePath: string, hstStore: HSTNode): Record<string, any>;
|
|
459
|
+
export { collectNestedData };
|
|
439
460
|
//# sourceMappingURL=stonecrop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,WAAW,EAEhB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD;;;GAGG;AACH,qBAAa,SAAS;IACrB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,CAAA;IAEvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,kBAAkB,CAAC,CAAyC;IACpE,OAAO,CAAC,mBAAmB,CAAC,CAA6B;IACzD,OAAO,CAAC,OAAO,CAAC,CAAY;IAE5B,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B;;;;;OAKG;gBACS,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAmB5G;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI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are const useOperationLogStore: import("pinia").StoreDefinition<"hst-
|
|
|
92
92
|
getSnapshot: () => OperationLogSnapshot;
|
|
93
93
|
markIrreversible: (operationId: string, reason: string) => void;
|
|
94
94
|
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
|
|
95
|
-
}, "operations" | "
|
|
95
|
+
}, "operations" | "clientId" | "currentIndex" | "config">, Pick<{
|
|
96
96
|
operations: import("vue").Ref<{
|
|
97
97
|
id: string;
|
|
98
98
|
type: import("..").HSTOperationType;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
+
import type { Ref, ComputedRef } from 'vue';
|
|
3
|
+
import type Doctype from '../doctype';
|
|
4
|
+
import type { HSTNode } from '../stores/hst';
|
|
5
|
+
import type { HSTOperation, OperationLogConfig, OperationLogSnapshot } from './operation-log';
|
|
6
|
+
/**
|
|
7
|
+
* Operation Log API - nested object containing all operation log functionality
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type OperationLogAPI = {
|
|
11
|
+
/**
|
|
12
|
+
* List of all recorded operations in the log.
|
|
13
|
+
* Each operation represents a state change that can be undone/redone.
|
|
14
|
+
*/
|
|
15
|
+
operations: Ref<HSTOperation[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Current position in the operation log.
|
|
18
|
+
* -1 means no operations, 0 means at first operation, etc.
|
|
19
|
+
*/
|
|
20
|
+
currentIndex: Ref<number>;
|
|
21
|
+
/**
|
|
22
|
+
* Computed snapshot of undo/redo state.
|
|
23
|
+
* Use this for UI indicators (buttons, menu state).
|
|
24
|
+
*/
|
|
25
|
+
undoRedoState: ComputedRef<{
|
|
26
|
+
canUndo: boolean;
|
|
27
|
+
canRedo: boolean;
|
|
28
|
+
undoCount: number;
|
|
29
|
+
redoCount: number;
|
|
30
|
+
currentIndex: number;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether undo is currently available.
|
|
34
|
+
* True when there are operations that can be undone.
|
|
35
|
+
*/
|
|
36
|
+
canUndo: ComputedRef<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether redo is currently available.
|
|
39
|
+
* True when there are undone operations that can be redone.
|
|
40
|
+
*/
|
|
41
|
+
canRedo: ComputedRef<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Number of operations available to undo.
|
|
44
|
+
*/
|
|
45
|
+
undoCount: ComputedRef<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Number of operations available to redo.
|
|
48
|
+
*/
|
|
49
|
+
redoCount: ComputedRef<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Undo the last operation.
|
|
52
|
+
* @param hstStore - The HST node to apply the inverse operation to
|
|
53
|
+
* @returns True if undo succeeded, false if nothing to undo
|
|
54
|
+
*/
|
|
55
|
+
undo: (hstStore: HSTNode) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Redo the last undone operation.
|
|
58
|
+
* @param hstStore - The HST node to apply the operation to
|
|
59
|
+
* @returns True if redo succeeded, false if nothing to redo
|
|
60
|
+
*/
|
|
61
|
+
redo: (hstStore: HSTNode) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Start batching multiple operations together.
|
|
64
|
+
* Call before a series of changes that should be undone/redone as a unit.
|
|
65
|
+
*/
|
|
66
|
+
startBatch: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Commit the current batch of operations.
|
|
69
|
+
* @param description - Optional description for the batch
|
|
70
|
+
* @returns The batch operation ID, or null if no batch in progress
|
|
71
|
+
*/
|
|
72
|
+
commitBatch: (description?: string) => string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Cancel the current batch without committing.
|
|
75
|
+
* Discards all operations added since startBatch().
|
|
76
|
+
*/
|
|
77
|
+
cancelBatch: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all operations from the log.
|
|
80
|
+
* Resets the log to its initial empty state.
|
|
81
|
+
*/
|
|
82
|
+
clear: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Get all operations for a specific doctype.
|
|
85
|
+
* @param doctype - The doctype name to filter by
|
|
86
|
+
* @param recordId - Optional record ID to further filter
|
|
87
|
+
* @returns Array of matching operations
|
|
88
|
+
*/
|
|
89
|
+
getOperationsFor: (doctype: string, recordId?: string) => HSTOperation[];
|
|
90
|
+
/**
|
|
91
|
+
* Get a serializable snapshot of the operation log.
|
|
92
|
+
* Use for debugging, logging, or state persistence.
|
|
93
|
+
* @returns Snapshot containing operations and current index
|
|
94
|
+
*/
|
|
95
|
+
getSnapshot: () => OperationLogSnapshot;
|
|
96
|
+
/**
|
|
97
|
+
* Mark an operation as irreversible.
|
|
98
|
+
* Irreversible operations cannot be undone.
|
|
99
|
+
* @param operationId - The operation ID to mark
|
|
100
|
+
* @param reason - Human-readable reason why it cannot be undone
|
|
101
|
+
*/
|
|
102
|
+
markIrreversible: (operationId: string, reason: string) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Log a custom action (non-HST operation).
|
|
105
|
+
* Use for tracking server calls, external side effects, etc.
|
|
106
|
+
* @param doctype - The doctype this action relates to
|
|
107
|
+
* @param actionName - Name of the action (e.g., 'save', 'submit')
|
|
108
|
+
* @param recordIds - Optional array of affected record IDs
|
|
109
|
+
* @param result - Optional result status
|
|
110
|
+
* @param error - Optional error message if result is 'failure'
|
|
111
|
+
* @returns The logged operation ID
|
|
112
|
+
*/
|
|
113
|
+
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: 'success' | 'failure' | 'pending', error?: string) => string;
|
|
114
|
+
/**
|
|
115
|
+
* Configure operation log options.
|
|
116
|
+
* @param options - Partial configuration to merge with existing settings
|
|
117
|
+
*/
|
|
118
|
+
configure: (options: Partial<OperationLogConfig>) => void;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Base Stonecrop composable return type - includes operation log functionality
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export type BaseStonecropReturn = {
|
|
125
|
+
/**
|
|
126
|
+
* Reactive reference to the Stonecrop singleton instance.
|
|
127
|
+
* Use this to access class methods like `getRecord()`, `addRecord()`, `runAction()`.
|
|
128
|
+
*/
|
|
129
|
+
stonecrop: Ref<Stonecrop | undefined>;
|
|
130
|
+
/**
|
|
131
|
+
* Operation log API for undo/redo functionality.
|
|
132
|
+
* Use `operationLog.undo()` and `operationLog.redo()` for user-triggered operations.
|
|
133
|
+
* Use `operationLog.startBatch()` / `operationLog.commitBatch()` for grouping operations.
|
|
134
|
+
*/
|
|
135
|
+
operationLog: OperationLogAPI;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* HST-enabled Stonecrop composable return type
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export type HSTStonecropReturn = BaseStonecropReturn & {
|
|
142
|
+
/**
|
|
143
|
+
* Generates a fully-qualified HST path for a field.
|
|
144
|
+
* Use this in nested components to create paths like "customer.123.address".
|
|
145
|
+
* @param fieldname - The field name to append to the path
|
|
146
|
+
* @param recordId - Optional record ID (defaults to current record)
|
|
147
|
+
* @returns The full HST path string
|
|
148
|
+
*/
|
|
149
|
+
provideHSTPath: (fieldname: string, recordId?: string) => string;
|
|
150
|
+
/**
|
|
151
|
+
* Handles a field value change and updates HST.
|
|
152
|
+
* Call this from form input handlers to persist changes to the store.
|
|
153
|
+
* @param changeData - Object containing path, value, fieldname, and optional recordId
|
|
154
|
+
*/
|
|
155
|
+
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Reactive reference to the HST node for this doctype/record.
|
|
158
|
+
* Use this to read current form state or subscribe to changes.
|
|
159
|
+
*/
|
|
160
|
+
hstStore: Ref<HSTNode | undefined>;
|
|
161
|
+
/**
|
|
162
|
+
* Reactive form data bound to HST.
|
|
163
|
+
* Use this as the v-model target for form inputs. Changes sync to hstStore.
|
|
164
|
+
*/
|
|
165
|
+
formData: Ref<Record<string, any>>;
|
|
166
|
+
/**
|
|
167
|
+
* Resolved schema with nested Doctype fields expanded.
|
|
168
|
+
* Use this to iterate over fields for rendering, excluding nested doctypes handled separately.
|
|
169
|
+
*/
|
|
170
|
+
resolvedSchema: Ref<SchemaTypes[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Loads or initializes nested doctype data.
|
|
173
|
+
* Use this when rendering a nested form component. Checks HST first, then initializes defaults.
|
|
174
|
+
* @param parentPath - The HST path to check for existing data
|
|
175
|
+
* @param childDoctype - The nested doctype metadata
|
|
176
|
+
* @param recordId - Optional record ID (reserved for future API fetch)
|
|
177
|
+
* @returns The loaded or initialized data object
|
|
178
|
+
*/
|
|
179
|
+
loadNestedData: (parentPath: string, childDoctype: Doctype, recordId?: string) => Record<string, any>;
|
|
180
|
+
/**
|
|
181
|
+
* Collects a complete record payload with all nested data from HST.
|
|
182
|
+
* Use this before submitting to an API. Recursively includes 1:1 and 1:many nested records.
|
|
183
|
+
* @param doctype - The doctype metadata
|
|
184
|
+
* @param recordId - The record ID to collect
|
|
185
|
+
* @returns The complete record payload ready for API submission
|
|
186
|
+
*/
|
|
187
|
+
collectRecordPayload: (doctype: Doctype, recordId: string) => Record<string, any>;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a nested context for a child doctype component.
|
|
190
|
+
* Use this in parent components to pass scoped handlers to child components.
|
|
191
|
+
* @param basePath - The parent HST path prefix
|
|
192
|
+
* @param childDoctype - The child doctype metadata
|
|
193
|
+
* @returns Scoped provideHSTPath and handleHSTChange functions
|
|
194
|
+
*/
|
|
195
|
+
createNestedContext: (basePath: string, childDoctype: Doctype) => {
|
|
196
|
+
provideHSTPath: (fieldname: string) => string;
|
|
197
|
+
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Loading state for async doctype resolution.
|
|
201
|
+
* True while fetching doctype by slug string from registry.
|
|
202
|
+
*/
|
|
203
|
+
isLoading: Ref<boolean>;
|
|
204
|
+
/**
|
|
205
|
+
* Error state for doctype resolution failures.
|
|
206
|
+
* Set when doctype slug lookup fails.
|
|
207
|
+
*/
|
|
208
|
+
error: Ref<Error | null>;
|
|
209
|
+
/**
|
|
210
|
+
* Resolved doctype instance.
|
|
211
|
+
* Available immediately if Doctype instance passed, after async resolution if slug string passed.
|
|
212
|
+
*/
|
|
213
|
+
resolvedDoctype: Ref<Doctype | undefined>;
|
|
214
|
+
};
|
|
215
|
+
import type { Stonecrop } from '../stonecrop';
|
|
216
|
+
/**
|
|
217
|
+
* HST Change data structure
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
export type HSTChangeData = {
|
|
221
|
+
/** Full HST path to the changed field */
|
|
222
|
+
path: string;
|
|
223
|
+
/** New value for the field */
|
|
224
|
+
value: any;
|
|
225
|
+
/** Field name that changed */
|
|
226
|
+
fieldname: string;
|
|
227
|
+
/** Optional record ID */
|
|
228
|
+
recordId?: string;
|
|
229
|
+
};
|
|
230
|
+
//# sourceMappingURL=composable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../../src/types/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAE3C,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE7F;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B;;;OAGG;IACH,UAAU,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAA;IAC/B;;;OAGG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACzB;;;OAGG;IACH,aAAa,EAAE,WAAW,CAAC;QAC1B,OAAO,EA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EAAE,MAAM,KAAK,MAAM,CAAA;QAC7C,eAAe,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAA;KACpD,CAAA;IACD;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACvB;;;OAGG;IACH,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACxB;;;OAGG;IACH,eAAe,EAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;CACzC,CAAA;AAGD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,8BAA8B;IAC9B,KAAK,EAAE,GAAG,CAAA;IACV,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
+
import type { WorkflowMeta } from '@stonecrop/schema';
|
|
3
|
+
import { List, Map } from 'immutable';
|
|
4
|
+
import type { AnyStateNodeConfig, UnknownMachineConfig } from 'xstate';
|
|
5
|
+
/**
|
|
6
|
+
* Immutable Doctype type for Stonecrop instances
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type ImmutableDoctype = {
|
|
10
|
+
readonly schema?: List<SchemaTypes>;
|
|
11
|
+
readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
12
|
+
readonly actions?: Map<string, string[]>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Mutable Doctype type for Stonecrop instances
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type MutableDoctype = {
|
|
19
|
+
doctype?: string;
|
|
20
|
+
schema?: SchemaTypes[];
|
|
21
|
+
workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
22
|
+
actions?: Record<string, string[]>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Schema type for Stonecrop instances
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export type Schema = {
|
|
29
|
+
doctype: string;
|
|
30
|
+
schema: List<SchemaTypes>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Plain object representation of doctype configuration for serialization/API responses.
|
|
34
|
+
* Compatible with the DoctypeMeta type from \@stonecrop/schema.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export type DoctypeConfig = {
|
|
38
|
+
/** Display name of the doctype */
|
|
39
|
+
name: string;
|
|
40
|
+
/** URL-friendly slug (kebab-case) */
|
|
41
|
+
slug?: string;
|
|
42
|
+
/** Database table name */
|
|
43
|
+
tableName?: string;
|
|
44
|
+
/** Field definitions */
|
|
45
|
+
fields?: SchemaTypes[];
|
|
46
|
+
/** Workflow configuration (XState format or simple WorkflowMeta) */
|
|
47
|
+
workflow?: UnknownMachineConfig | WorkflowMeta;
|
|
48
|
+
/** Actions and their field triggers */
|
|
49
|
+
actions?: Record<string, string[]>;
|
|
50
|
+
/** Parent doctype for inheritance */
|
|
51
|
+
inherits?: string;
|
|
52
|
+
/** Doctype to use for list views */
|
|
53
|
+
listDoctype?: string;
|
|
54
|
+
/** Parent doctype for child tables */
|
|
55
|
+
parentDoctype?: string;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=doctype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../../src/types/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE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