@stonecrop/stonecrop 0.30.0 → 0.32.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.
Files changed (121) hide show
  1. package/dist/stonecrop.js +3548 -2740
  2. package/dist/stonecrop.js.map +1 -1
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/package.json +33 -27
  5. package/dist/src/client-action.d.ts +0 -31
  6. package/dist/src/client-action.d.ts.map +0 -1
  7. package/dist/src/client-action.js +0 -169
  8. package/dist/src/client-handler.d.ts +0 -43
  9. package/dist/src/client-handler.d.ts.map +0 -1
  10. package/dist/src/client-handler.js +0 -42
  11. package/dist/src/composables/lazy-link.d.ts +0 -25
  12. package/dist/src/composables/lazy-link.d.ts.map +0 -1
  13. package/dist/src/composables/lazy-link.js +0 -124
  14. package/dist/src/composables/operation-log.d.ts +0 -136
  15. package/dist/src/composables/operation-log.d.ts.map +0 -1
  16. package/dist/src/composables/operation-log.js +0 -224
  17. package/dist/src/composables/stonecrop.d.ts +0 -37
  18. package/dist/src/composables/stonecrop.d.ts.map +0 -1
  19. package/dist/src/composables/stonecrop.js +0 -433
  20. package/dist/src/doctype.d.ts +0 -243
  21. package/dist/src/doctype.d.ts.map +0 -1
  22. package/dist/src/doctype.js +0 -325
  23. package/dist/src/draft.d.ts +0 -35
  24. package/dist/src/draft.d.ts.map +0 -1
  25. package/dist/src/draft.js +0 -36
  26. package/dist/src/exceptions.d.ts +0 -14
  27. package/dist/src/exceptions.d.ts.map +0 -1
  28. package/dist/src/exceptions.js +0 -16
  29. package/dist/src/field-triggers.d.ts +0 -184
  30. package/dist/src/field-triggers.d.ts.map +0 -1
  31. package/dist/src/field-triggers.js +0 -577
  32. package/dist/src/index.d.ts +0 -25
  33. package/dist/src/index.d.ts.map +0 -1
  34. package/dist/src/index.js +0 -39
  35. package/dist/src/plugins/index.d.ts +0 -35
  36. package/dist/src/plugins/index.d.ts.map +0 -1
  37. package/dist/src/plugins/index.js +0 -98
  38. package/dist/src/registry.d.ts +0 -161
  39. package/dist/src/registry.d.ts.map +0 -1
  40. package/dist/src/registry.js +0 -384
  41. package/dist/src/schema-validator.d.ts +0 -78
  42. package/dist/src/schema-validator.d.ts.map +0 -1
  43. package/dist/src/schema-validator.js +0 -398
  44. package/dist/src/stonecrop.d.ts +0 -539
  45. package/dist/src/stonecrop.d.ts.map +0 -1
  46. package/dist/src/stonecrop.js +0 -610
  47. package/dist/src/stores/hst.d.ts +0 -92
  48. package/dist/src/stores/hst.d.ts.map +0 -1
  49. package/dist/src/stores/hst.js +0 -487
  50. package/dist/src/stores/index.d.ts +0 -9
  51. package/dist/src/stores/index.d.ts.map +0 -1
  52. package/dist/src/stores/index.js +0 -13
  53. package/dist/src/stores/operation-log.d.ts +0 -262
  54. package/dist/src/stores/operation-log.d.ts.map +0 -1
  55. package/dist/src/stores/operation-log.js +0 -571
  56. package/dist/src/stores/validation.d.ts +0 -83
  57. package/dist/src/stores/validation.d.ts.map +0 -1
  58. package/dist/src/stores/validation.js +0 -104
  59. package/dist/src/types/client-action.d.ts +0 -121
  60. package/dist/src/types/client-action.d.ts.map +0 -1
  61. package/dist/src/types/client-action.js +0 -0
  62. package/dist/src/types/composable.d.ts +0 -268
  63. package/dist/src/types/composable.d.ts.map +0 -1
  64. package/dist/src/types/composable.js +0 -0
  65. package/dist/src/types/doctype.d.ts +0 -34
  66. package/dist/src/types/doctype.d.ts.map +0 -1
  67. package/dist/src/types/doctype.js +0 -0
  68. package/dist/src/types/field-triggers.d.ts +0 -186
  69. package/dist/src/types/field-triggers.d.ts.map +0 -1
  70. package/dist/src/types/field-triggers.js +0 -4
  71. package/dist/src/types/hst.d.ts +0 -70
  72. package/dist/src/types/hst.d.ts.map +0 -1
  73. package/dist/src/types/hst.js +0 -0
  74. package/dist/src/types/index.d.ts +0 -11
  75. package/dist/src/types/index.d.ts.map +0 -1
  76. package/dist/src/types/index.js +0 -11
  77. package/dist/src/types/operation-log.d.ts +0 -163
  78. package/dist/src/types/operation-log.d.ts.map +0 -1
  79. package/dist/src/types/operation-log.js +0 -0
  80. package/dist/src/types/plugin.d.ts +0 -37
  81. package/dist/src/types/plugin.d.ts.map +0 -1
  82. package/dist/src/types/plugin.js +0 -0
  83. package/dist/src/types/registry.d.ts +0 -11
  84. package/dist/src/types/registry.d.ts.map +0 -1
  85. package/dist/src/types/registry.js +0 -0
  86. package/dist/src/types/schema-validator.d.ts +0 -66
  87. package/dist/src/types/schema-validator.d.ts.map +0 -1
  88. package/dist/src/types/schema-validator.js +0 -13
  89. package/dist/src/types/stonecrop.d.ts +0 -32
  90. package/dist/src/types/stonecrop.d.ts.map +0 -1
  91. package/dist/src/types/stonecrop.js +0 -0
  92. package/dist/stonecrop.tsbuildinfo +0 -1
  93. package/src/client-action.ts +0 -207
  94. package/src/client-handler.ts +0 -55
  95. package/src/composables/lazy-link.ts +0 -145
  96. package/src/composables/operation-log.ts +0 -257
  97. package/src/composables/stonecrop.ts +0 -556
  98. package/src/doctype.ts +0 -360
  99. package/src/draft.ts +0 -38
  100. package/src/exceptions.ts +0 -16
  101. package/src/field-triggers.ts +0 -686
  102. package/src/index.ts +0 -81
  103. package/src/plugins/index.ts +0 -113
  104. package/src/registry.ts +0 -433
  105. package/src/schema-validator.ts +0 -476
  106. package/src/stonecrop.ts +0 -721
  107. package/src/stores/hst.ts +0 -626
  108. package/src/stores/index.ts +0 -21
  109. package/src/stores/operation-log.ts +0 -675
  110. package/src/stores/validation.ts +0 -138
  111. package/src/types/client-action.ts +0 -121
  112. package/src/types/composable.ts +0 -288
  113. package/src/types/doctype.ts +0 -35
  114. package/src/types/field-triggers.ts +0 -201
  115. package/src/types/hst.ts +0 -77
  116. package/src/types/index.ts +0 -11
  117. package/src/types/operation-log.ts +0 -202
  118. package/src/types/plugin.ts +0 -38
  119. package/src/types/registry.ts +0 -10
  120. package/src/types/schema-validator.ts +0 -69
  121. package/src/types/stonecrop.ts +0 -33
@@ -1,136 +0,0 @@
1
- import type { HSTNode } from '../types/hst';
2
- import type { OperationLogConfig } from '../types/operation-log';
3
- /**
4
- * Composable for operation log management
5
- * Provides easy access to undo/redo functionality and operation history
6
- *
7
- * @param config - Optional configuration for the operation log
8
- * @returns Operation log interface
9
- *
10
- * @example
11
- * ```typescript
12
- * const { undo, redo, canUndo, canRedo, operations, configure } = useOperationLog()
13
- *
14
- * // Configure the log
15
- * configure({
16
- * maxOperations: 50,
17
- * enableCrossTabSync: true,
18
- * enablePersistence: true
19
- * })
20
- *
21
- * // Undo/redo
22
- * await undo(hstStore)
23
- * await redo(hstStore)
24
- * ```
25
- *
26
- * @public
27
- */
28
- export declare function useOperationLog(config?: Partial<OperationLogConfig>): {
29
- operations: import("vue").Ref<{
30
- id: string;
31
- type: import("..").HSTOperationType;
32
- path: string;
33
- fieldname: string;
34
- beforeValue: any;
35
- afterValue: any;
36
- doctype: string;
37
- recordId?: string | undefined;
38
- timestamp: Date;
39
- source?: import("..").OperationSource | undefined;
40
- reversible: boolean;
41
- irreversibleReason?: string | undefined;
42
- transition?: string | undefined;
43
- currentState?: string | undefined;
44
- targetState?: string | undefined;
45
- actionName?: string | undefined;
46
- actionRecordIds?: string[] | undefined;
47
- actionResult?: "success" | "failure" | "pending" | undefined;
48
- actionError?: string | undefined;
49
- userId?: string | undefined;
50
- metadata?: Record<string, any> | undefined;
51
- ancestorOperationId?: string | undefined;
52
- descendantOperationIds?: string[] | undefined;
53
- }[], import("..").HSTOperation[] | {
54
- id: string;
55
- type: import("..").HSTOperationType;
56
- path: string;
57
- fieldname: string;
58
- beforeValue: any;
59
- afterValue: any;
60
- doctype: string;
61
- recordId?: string | undefined;
62
- timestamp: Date;
63
- source?: import("..").OperationSource | undefined;
64
- reversible: boolean;
65
- irreversibleReason?: string | undefined;
66
- transition?: string | undefined;
67
- currentState?: string | undefined;
68
- targetState?: string | undefined;
69
- actionName?: string | undefined;
70
- actionRecordIds?: string[] | undefined;
71
- actionResult?: "success" | "failure" | "pending" | undefined;
72
- actionError?: string | undefined;
73
- userId?: string | undefined;
74
- metadata?: Record<string, any> | undefined;
75
- ancestorOperationId?: string | undefined;
76
- descendantOperationIds?: string[] | undefined;
77
- }[]>;
78
- currentIndex: import("vue").Ref<number, number>;
79
- undoRedoState: import("vue").ComputedRef<import("..").UndoRedoState>;
80
- canUndo: import("vue").ComputedRef<boolean>;
81
- canRedo: import("vue").ComputedRef<boolean>;
82
- undoCount: import("vue").ComputedRef<number>;
83
- redoCount: import("vue").ComputedRef<number>;
84
- undo: (hstStore: HSTNode) => boolean;
85
- redo: (hstStore: HSTNode) => boolean;
86
- startBatch: () => void;
87
- commitBatch: (description?: string) => string | null;
88
- cancelBatch: () => void;
89
- clear: () => void;
90
- getOperationsFor: (doctype: string, recordId?: string) => import("..").HSTOperation[];
91
- getSnapshot: () => import("..").OperationLogSnapshot;
92
- markIrreversible: (operationId: string, reason: string) => void;
93
- logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
94
- configure: (options: Partial<OperationLogConfig>) => void;
95
- };
96
- /**
97
- * Keyboard shortcut handler for undo/redo
98
- * Automatically binds Ctrl+Z (undo) and Ctrl+Shift+Z/Ctrl+Y (redo) using VueUse
99
- *
100
- * @param hstStore - The HST store to operate on
101
- * @param enabled - Whether shortcuts are enabled (default: true)
102
- *
103
- * @example
104
- * ```typescript
105
- * import { onMounted } from 'vue'
106
- *
107
- * const stonecrop = useStonecrop({ doctype, recordId })
108
- * useUndoRedoShortcuts(stonecrop.hstStore)
109
- * ```
110
- *
111
- * @public
112
- */
113
- export declare function useUndoRedoShortcuts(hstStore: HSTNode, enabled?: boolean): void;
114
- /**
115
- * Batch operation helper
116
- * Wraps a function execution in a batch operation
117
- *
118
- * @param fn - The function to execute within a batch
119
- * @param description - Optional description for the batch
120
- * @returns The batch operation ID
121
- *
122
- * @example
123
- * ```typescript
124
- * const { withBatch } = useOperationLog()
125
- *
126
- * const batchId = await withBatch(() => {
127
- * hstStore.set('task.123.title', 'New Title')
128
- * hstStore.set('task.123.status', 'active')
129
- * hstStore.set('task.123.priority', 'high')
130
- * }, 'Update task details')
131
- * ```
132
- *
133
- * @public
134
- */
135
- export declare function withBatch<T>(fn: () => T | Promise<T>, description?: string): Promise<string | null>;
136
- //# sourceMappingURL=operation-log.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,224 +0,0 @@
1
- import { useMagicKeys, whenever } from '@vueuse/core';
2
- import { storeToRefs } from 'pinia';
3
- import { getCurrentInstance, inject } from 'vue';
4
- import { useOperationLogStore } from '../stores/operation-log';
5
- /**
6
- * Composable for operation log management
7
- * Provides easy access to undo/redo functionality and operation history
8
- *
9
- * @param config - Optional configuration for the operation log
10
- * @returns Operation log interface
11
- *
12
- * @example
13
- * ```typescript
14
- * const { undo, redo, canUndo, canRedo, operations, configure } = useOperationLog()
15
- *
16
- * // Configure the log
17
- * configure({
18
- * maxOperations: 50,
19
- * enableCrossTabSync: true,
20
- * enablePersistence: true
21
- * })
22
- *
23
- * // Undo/redo
24
- * await undo(hstStore)
25
- * await redo(hstStore)
26
- * ```
27
- *
28
- * @public
29
- */
30
- export function useOperationLog(config) {
31
- // inject() is only valid inside a component setup() context. When this
32
- // composable is called outside one (e.g. directly in test bodies or plain
33
- // scripts) skip the injection entirely and fall back to the Pinia store.
34
- const injectedStore = getCurrentInstance()
35
- ? inject('$operationLogStore', undefined)
36
- : undefined;
37
- const store = injectedStore || useOperationLogStore();
38
- // Apply configuration if provided
39
- if (config) {
40
- store.configure(config);
41
- }
42
- // Extract reactive state
43
- const { operations, currentIndex, undoRedoState, canUndo, canRedo, undoCount, redoCount } = storeToRefs(store);
44
- /**
45
- * Undo the last operation
46
- */
47
- function undo(hstStore) {
48
- return store.undo(hstStore);
49
- }
50
- /**
51
- * Redo the next operation
52
- */
53
- function redo(hstStore) {
54
- return store.redo(hstStore);
55
- }
56
- /**
57
- * Start a batch operation
58
- */
59
- function startBatch() {
60
- store.startBatch();
61
- }
62
- /**
63
- * Commit the current batch
64
- */
65
- function commitBatch(description) {
66
- return store.commitBatch(description);
67
- }
68
- /**
69
- * Cancel the current batch
70
- */
71
- function cancelBatch() {
72
- store.cancelBatch();
73
- }
74
- /**
75
- * Clear all operations
76
- */
77
- function clear() {
78
- store.clear();
79
- }
80
- /**
81
- * Get operations for a specific doctype/record
82
- */
83
- function getOperationsFor(doctype, recordId) {
84
- return store.getOperationsFor(doctype, recordId);
85
- }
86
- /**
87
- * Get a snapshot of the operation log
88
- */
89
- function getSnapshot() {
90
- return store.getSnapshot();
91
- }
92
- /**
93
- * Mark an operation as irreversible
94
- * @param operationId - The ID of the operation to mark
95
- * @param reason - The reason why the operation is irreversible
96
- */
97
- function markIrreversible(operationId, reason) {
98
- store.markIrreversible(operationId, reason);
99
- }
100
- /**
101
- * Log an action execution (stateless actions like print, email, etc.)
102
- * @param doctype - The doctype the action was executed on
103
- * @param actionName - The name of the action that was executed
104
- * @param recordIds - Optional array of record IDs the action was executed on
105
- * @param result - The result of the action execution
106
- * @param error - Optional error message if action failed
107
- * @returns The operation ID
108
- */
109
- function logAction(doctype, actionName, recordIds, result = 'success', error) {
110
- return store.logAction(doctype, actionName, recordIds, result, error);
111
- }
112
- /**
113
- * Update configuration
114
- * @param options - Configuration options to update
115
- */
116
- function configure(options) {
117
- store.configure(options);
118
- }
119
- return {
120
- // State
121
- operations,
122
- currentIndex,
123
- undoRedoState,
124
- canUndo,
125
- canRedo,
126
- undoCount,
127
- redoCount,
128
- // Methods
129
- undo,
130
- redo,
131
- startBatch,
132
- commitBatch,
133
- cancelBatch,
134
- clear,
135
- getOperationsFor,
136
- getSnapshot,
137
- markIrreversible,
138
- logAction,
139
- configure,
140
- };
141
- }
142
- /**
143
- * Keyboard shortcut handler for undo/redo
144
- * Automatically binds Ctrl+Z (undo) and Ctrl+Shift+Z/Ctrl+Y (redo) using VueUse
145
- *
146
- * @param hstStore - The HST store to operate on
147
- * @param enabled - Whether shortcuts are enabled (default: true)
148
- *
149
- * @example
150
- * ```typescript
151
- * import { onMounted } from 'vue'
152
- *
153
- * const stonecrop = useStonecrop({ doctype, recordId })
154
- * useUndoRedoShortcuts(stonecrop.hstStore)
155
- * ```
156
- *
157
- * @public
158
- */
159
- export function useUndoRedoShortcuts(hstStore, enabled = true) {
160
- if (!enabled)
161
- return;
162
- const { undo, redo, canUndo, canRedo } = useOperationLog();
163
- const keys = useMagicKeys();
164
- // Undo shortcuts: Ctrl+Z or Cmd+Z (Mac)
165
- whenever(keys['Ctrl+Z'], () => {
166
- if (canUndo.value) {
167
- undo(hstStore);
168
- }
169
- });
170
- whenever(keys['Meta+Z'], () => {
171
- if (canUndo.value) {
172
- undo(hstStore);
173
- }
174
- });
175
- // Redo shortcuts: Ctrl+Shift+Z, Cmd+Shift+Z (Mac), or Ctrl+Y
176
- whenever(keys['Ctrl+Shift+Z'], () => {
177
- if (canRedo.value) {
178
- redo(hstStore);
179
- }
180
- });
181
- whenever(keys['Meta+Shift+Z'], () => {
182
- if (canRedo.value) {
183
- redo(hstStore);
184
- }
185
- });
186
- whenever(keys['Ctrl+Y'], () => {
187
- if (canRedo.value) {
188
- redo(hstStore);
189
- }
190
- });
191
- }
192
- /**
193
- * Batch operation helper
194
- * Wraps a function execution in a batch operation
195
- *
196
- * @param fn - The function to execute within a batch
197
- * @param description - Optional description for the batch
198
- * @returns The batch operation ID
199
- *
200
- * @example
201
- * ```typescript
202
- * const { withBatch } = useOperationLog()
203
- *
204
- * const batchId = await withBatch(() => {
205
- * hstStore.set('task.123.title', 'New Title')
206
- * hstStore.set('task.123.status', 'active')
207
- * hstStore.set('task.123.priority', 'high')
208
- * }, 'Update task details')
209
- * ```
210
- *
211
- * @public
212
- */
213
- export async function withBatch(fn, description) {
214
- const { startBatch, commitBatch, cancelBatch } = useOperationLog();
215
- startBatch();
216
- try {
217
- await fn();
218
- return commitBatch(description);
219
- }
220
- catch (error) {
221
- cancelBatch();
222
- throw error;
223
- }
224
- }
@@ -1,37 +0,0 @@
1
- import Doctype from '../doctype';
2
- import Registry from '../registry';
3
- import type { BaseStonecropReturn, HSTStonecropReturn } from '../types/composable';
4
- /**
5
- * Unified Stonecrop composable - handles both general operations and HST reactive integration.
6
- *
7
- * Called with no doctype, it returns the Stonecrop instance and the operation log, and touches
8
- * the network not at all. Name a doctype to get the HST surface.
9
- *
10
- * @returns The Stonecrop instance and the operation log
11
- * @public
12
- */
13
- export declare function useStonecrop(): BaseStonecropReturn;
14
- /**
15
- * Unified Stonecrop composable with HST integration for a specific doctype and record.
16
- *
17
- * When a `Doctype` instance is passed, all synchronous initialisation (`hstStore`,
18
- * `resolvedSchema`, `formData`, `handleHSTChange`, operation-log wiring) is performed
19
- * during `setup()` — before the first render and without awaiting any lifecycle hook.
20
- * Callers can read `hstStore.value`, `resolvedSchema.value`, and `formData.value`
21
- * immediately after calling this composable; no `nextTick`, `flushPromises`, or
22
- * `setTimeout` is required.
23
- *
24
- * The only async work in `onMounted` is fetching an existing record from the server when
25
- * `recordId` is not a draft, and lazy-loading a doctype by slug string. Both need a doctype
26
- * named here — nothing is inferred from the route.
27
- *
28
- * @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
29
- * @returns Stonecrop instance with full HST integration utilities
30
- * @public
31
- */
32
- export declare function useStonecrop(options: {
33
- registry?: Registry;
34
- doctype: Doctype | string;
35
- recordId?: string;
36
- }): HSTStonecropReturn;
37
- //# sourceMappingURL=stonecrop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAkC,MAAM,qBAAqB,CAAA;AAIlH;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,mBAAmB,CAAA;AACnD;;;;;;;;;;;;;;;;;GAiBG;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"}