@stonecrop/stonecrop 0.10.6 → 0.10.8
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 +30 -1
- package/dist/composables/stonecrop.js +69 -12
- package/dist/doctype.js +51 -2
- package/dist/src/composables/stonecrop.d.ts +5 -2
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +28 -4
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +34 -7
- package/dist/stonecrop.js +1611 -1551
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/composables/stonecrop.ts +86 -18
- package/src/doctype.ts +67 -6
- package/src/stonecrop.ts +15 -5
- package/src/types/index.ts +3 -3
package/README.md
CHANGED
|
@@ -84,12 +84,19 @@ export default {
|
|
|
84
84
|
// Base mode — operation log only, no HST record loading
|
|
85
85
|
const { stonecrop, operationLog } = useStonecrop()
|
|
86
86
|
|
|
87
|
-
// HST mode — pass
|
|
87
|
+
// HST mode — pass Doctype instance and optional recordId
|
|
88
88
|
const { stonecrop, formData, provideHSTPath, handleHSTChange } = useStonecrop({
|
|
89
89
|
doctype: myDoctype,
|
|
90
90
|
recordId: 'record-123', // omit or pass undefined for new records
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
+
// HST mode with lazy-loading — pass string doctype slug
|
|
94
|
+
// Automatically loads doctype via registry.getMeta if not in registry
|
|
95
|
+
const { isLoading, error, resolvedDoctype, formData } = useStonecrop({
|
|
96
|
+
doctype: 'plan',
|
|
97
|
+
recordId: 'record-123',
|
|
98
|
+
})
|
|
99
|
+
|
|
93
100
|
// Access HST store
|
|
94
101
|
const store = stonecrop.value?.getStore()
|
|
95
102
|
|
|
@@ -101,6 +108,28 @@ export default {
|
|
|
101
108
|
}
|
|
102
109
|
```
|
|
103
110
|
|
|
111
|
+
### String Doctype Lazy-Loading
|
|
112
|
+
|
|
113
|
+
When you pass a string doctype slug instead of a `Doctype` instance, `useStonecrop` will:
|
|
114
|
+
|
|
115
|
+
1. Check if the doctype is already in the Registry
|
|
116
|
+
2. If not, call `registry.getMeta` to lazy-load it
|
|
117
|
+
3. Return `isLoading`, `error`, and `resolvedDoctype` refs for handling the async state
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const { isLoading, error, resolvedDoctype, formData } = useStonecrop({
|
|
121
|
+
doctype: 'plan', // string slug - triggers lazy-loading
|
|
122
|
+
recordId: '123',
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
// In your template:
|
|
126
|
+
// <div v-if="isLoading">Loading doctype...</div>
|
|
127
|
+
// <div v-else-if="error">Error: {{ error.message }}</div>
|
|
128
|
+
// <AForm v-else :schema="resolvedDoctype.schema" v-model:data="formData" />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This pattern eliminates the timing mismatch when loading doctypes asynchronously in Nuxt plugins.
|
|
132
|
+
|
|
104
133
|
## Design
|
|
105
134
|
A Doctype defines schema, workflow, and actions.
|
|
106
135
|
- **Schema** describes the data model and field layout — used by AForm for rendering.
|
|
@@ -17,14 +17,13 @@ export function useStonecrop(options) {
|
|
|
17
17
|
const routerRecordId = ref();
|
|
18
18
|
// Resolved schema with nested Doctype fields expanded
|
|
19
19
|
const resolvedSchema = ref([]);
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
resolvedSchema.value = registry.resolveSchema(schemaArray);
|
|
20
|
+
// Loading state for lazy-loaded doctypes
|
|
21
|
+
const isLoading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const resolvedDoctype = ref();
|
|
24
|
+
// If doctype is a Doctype instance (not string), set resolved immediately
|
|
25
|
+
if (options?.doctype && typeof options.doctype !== 'string') {
|
|
26
|
+
resolvedDoctype.value = options.doctype;
|
|
28
27
|
}
|
|
29
28
|
// Operation log state and methods - will be populated after stonecrop instance is created
|
|
30
29
|
const operations = ref([]);
|
|
@@ -166,8 +165,56 @@ export function useStonecrop(options) {
|
|
|
166
165
|
// Handle HST integration if doctype is provided explicitly
|
|
167
166
|
if (options.doctype) {
|
|
168
167
|
hstStore.value = stonecrop.value.getStore();
|
|
169
|
-
const doctype = options.doctype;
|
|
170
168
|
const recordId = options.recordId;
|
|
169
|
+
// Resolve doctype - handle string (lazy-load) or Doctype instance
|
|
170
|
+
let doctype;
|
|
171
|
+
if (typeof options.doctype === 'string') {
|
|
172
|
+
// String doctype - check registry first, then lazy-load
|
|
173
|
+
const doctypeSlug = options.doctype;
|
|
174
|
+
isLoading.value = true;
|
|
175
|
+
error.value = null;
|
|
176
|
+
try {
|
|
177
|
+
// Check if already in registry
|
|
178
|
+
doctype = registry.getDoctype(doctypeSlug);
|
|
179
|
+
if (!doctype && registry.getMeta) {
|
|
180
|
+
// Lazy-load via getMeta
|
|
181
|
+
const routeContext = {
|
|
182
|
+
path: `/${doctypeSlug}`,
|
|
183
|
+
segments: [doctypeSlug],
|
|
184
|
+
};
|
|
185
|
+
doctype = await registry.getMeta(routeContext);
|
|
186
|
+
if (doctype) {
|
|
187
|
+
registry.addDoctype(doctype);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!doctype) {
|
|
191
|
+
error.value = new Error(`Doctype '${doctypeSlug}' not found in registry and getMeta returned no result`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
error.value = e instanceof Error ? e : new Error(String(e));
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
isLoading.value = false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
// Doctype instance provided directly
|
|
203
|
+
doctype = options.doctype;
|
|
204
|
+
}
|
|
205
|
+
// Set resolved doctype for consumers
|
|
206
|
+
resolvedDoctype.value = doctype;
|
|
207
|
+
if (!doctype) {
|
|
208
|
+
// Error already set above, just return
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
// Resolve schema for the doctype
|
|
212
|
+
const schemaArray = doctype.schema
|
|
213
|
+
? Array.isArray(doctype.schema)
|
|
214
|
+
? doctype.schema
|
|
215
|
+
: Array.from(doctype.schema)
|
|
216
|
+
: [];
|
|
217
|
+
resolvedSchema.value = registry.resolveSchema(schemaArray);
|
|
171
218
|
if (recordId && recordId !== 'new') {
|
|
172
219
|
const existingRecord = stonecrop.value.getRecordById(doctype, recordId);
|
|
173
220
|
if (existingRecord) {
|
|
@@ -196,14 +243,14 @@ export function useStonecrop(options) {
|
|
|
196
243
|
});
|
|
197
244
|
// HST integration functions - always created but only populated when HST is available
|
|
198
245
|
const provideHSTPath = (fieldname, customRecordId) => {
|
|
199
|
-
const doctype =
|
|
246
|
+
const doctype = resolvedDoctype.value || routerDoctype.value;
|
|
200
247
|
if (!doctype)
|
|
201
248
|
return '';
|
|
202
249
|
const actualRecordId = customRecordId || options.recordId || routerRecordId.value || 'new';
|
|
203
250
|
return `${doctype.slug}.${actualRecordId}.${fieldname}`;
|
|
204
251
|
};
|
|
205
252
|
const handleHSTChange = (changeData) => {
|
|
206
|
-
const doctype =
|
|
253
|
+
const doctype = resolvedDoctype.value || routerDoctype.value;
|
|
207
254
|
if (!hstStore.value || !stonecrop.value || !doctype) {
|
|
208
255
|
return;
|
|
209
256
|
}
|
|
@@ -294,7 +341,11 @@ export function useStonecrop(options) {
|
|
|
294
341
|
// Build the save payload using resolved schema
|
|
295
342
|
const payload = { ...recordData };
|
|
296
343
|
// Use resolveSchema to get the full resolved tree, then walk Doctype fields
|
|
297
|
-
const schemaArray =
|
|
344
|
+
const schemaArray = doctype.schema
|
|
345
|
+
? Array.isArray(doctype.schema)
|
|
346
|
+
? doctype.schema
|
|
347
|
+
: Array.from(doctype.schema)
|
|
348
|
+
: [];
|
|
298
349
|
const resolved = registry ? registry.resolveSchema(schemaArray) : schemaArray;
|
|
299
350
|
const doctypeFields = resolved.filter(field => 'fieldtype' in field && field.fieldtype === 'Doctype' && 'schema' in field && Array.isArray(field.schema));
|
|
300
351
|
// Recursively collect nested data from HST using resolved schemas
|
|
@@ -364,6 +415,9 @@ export function useStonecrop(options) {
|
|
|
364
415
|
loadNestedData,
|
|
365
416
|
saveRecursive,
|
|
366
417
|
createNestedContext,
|
|
418
|
+
isLoading,
|
|
419
|
+
error,
|
|
420
|
+
resolvedDoctype,
|
|
367
421
|
};
|
|
368
422
|
}
|
|
369
423
|
else if (!options.doctype && registry?.router) {
|
|
@@ -379,6 +433,9 @@ export function useStonecrop(options) {
|
|
|
379
433
|
loadNestedData,
|
|
380
434
|
saveRecursive,
|
|
381
435
|
createNestedContext,
|
|
436
|
+
isLoading,
|
|
437
|
+
error,
|
|
438
|
+
resolvedDoctype,
|
|
382
439
|
};
|
|
383
440
|
}
|
|
384
441
|
// No doctype and no router - basic mode
|
package/dist/doctype.js
CHANGED
|
@@ -135,7 +135,7 @@ export default class Doctype {
|
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Returns the transitions available from a given workflow state, derived from the
|
|
138
|
-
* doctype's
|
|
138
|
+
* doctype's workflow configuration. Supports both XState format and WorkflowMeta format.
|
|
139
139
|
*
|
|
140
140
|
* @param currentState - The state name to read transitions from
|
|
141
141
|
* @returns Array of transition descriptors with `name` and `targetState`
|
|
@@ -149,7 +149,34 @@ export default class Doctype {
|
|
|
149
149
|
* @public
|
|
150
150
|
*/
|
|
151
151
|
getAvailableTransitions(currentState) {
|
|
152
|
-
const
|
|
152
|
+
const workflow = this.workflow;
|
|
153
|
+
if (!workflow)
|
|
154
|
+
return [];
|
|
155
|
+
// Check if this is WorkflowMeta format (states is an array) or XState format (states is an object)
|
|
156
|
+
if (Array.isArray(workflow.states)) {
|
|
157
|
+
// WorkflowMeta format: validate state exists and filter actions by allowedStates
|
|
158
|
+
const states = workflow.states;
|
|
159
|
+
if (!states.includes(currentState))
|
|
160
|
+
return [];
|
|
161
|
+
const actions = workflow.actions;
|
|
162
|
+
if (!actions)
|
|
163
|
+
return [];
|
|
164
|
+
return Object.entries(actions)
|
|
165
|
+
.filter(([, actionDef]) => {
|
|
166
|
+
const allowedStates = actionDef.allowedStates;
|
|
167
|
+
// If no allowedStates specified, action is available in all valid states
|
|
168
|
+
if (!allowedStates || allowedStates.length === 0)
|
|
169
|
+
return true;
|
|
170
|
+
return allowedStates.includes(currentState);
|
|
171
|
+
})
|
|
172
|
+
.map(([name]) => ({
|
|
173
|
+
name,
|
|
174
|
+
// WorkflowMeta doesn't define target states - transitions are handled server-side
|
|
175
|
+
targetState: currentState,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
// XState format: use the on property of the state
|
|
179
|
+
const states = workflow.states;
|
|
153
180
|
if (!states)
|
|
154
181
|
return [];
|
|
155
182
|
const stateConfig = states[currentState];
|
|
@@ -160,6 +187,28 @@ export default class Doctype {
|
|
|
160
187
|
targetState: typeof target === 'string' ? target : 'unknown',
|
|
161
188
|
}));
|
|
162
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Returns metadata for a specific action, if available.
|
|
192
|
+
* Only works with WorkflowMeta format; returns undefined for XState format.
|
|
193
|
+
*
|
|
194
|
+
* @param actionName - The action name to get metadata for
|
|
195
|
+
* @returns Action metadata or undefined
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const actionMeta = doctype.getActionMeta('submit')
|
|
200
|
+
* // { label: 'Submit', handler: 'plan:submit', allowedStates: ['draft'] }
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
getActionMeta(actionName) {
|
|
206
|
+
const workflow = this.workflow;
|
|
207
|
+
if (!workflow || !Array.isArray(workflow.states))
|
|
208
|
+
return undefined;
|
|
209
|
+
const actions = workflow.actions;
|
|
210
|
+
return actions?.[actionName];
|
|
211
|
+
}
|
|
163
212
|
/**
|
|
164
213
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
165
214
|
* - It replaces camelCase and PascalCase with kebab-case strings
|
|
@@ -59,6 +59,9 @@ export type HSTStonecropReturn = BaseStonecropReturn & {
|
|
|
59
59
|
provideHSTPath: (fieldname: string) => string;
|
|
60
60
|
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
61
61
|
};
|
|
62
|
+
isLoading: Ref<boolean>;
|
|
63
|
+
error: Ref<Error | null>;
|
|
64
|
+
resolvedDoctype: Ref<Doctype | undefined>;
|
|
62
65
|
};
|
|
63
66
|
/**
|
|
64
67
|
* HST Change data structure
|
|
@@ -81,13 +84,13 @@ export declare function useStonecrop(): BaseStonecropReturn | HSTStonecropReturn
|
|
|
81
84
|
/**
|
|
82
85
|
* Unified Stonecrop composable with HST integration for a specific doctype and record
|
|
83
86
|
*
|
|
84
|
-
* @param options - Configuration with doctype and optional recordId
|
|
87
|
+
* @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
|
|
85
88
|
* @returns Stonecrop instance with full HST integration utilities
|
|
86
89
|
* @public
|
|
87
90
|
*/
|
|
88
91
|
export declare function useStonecrop(options: {
|
|
89
92
|
registry?: Registry;
|
|
90
|
-
doctype: Doctype;
|
|
93
|
+
doctype: Doctype | string;
|
|
91
94
|
recordId?: string;
|
|
92
95
|
}): HSTStonecropReturn;
|
|
93
96
|
//# sourceMappingURL=stonecrop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAiC,WAAW,EAAE,MAAM,KAAK,CAAA;AAExF,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,KAAK,EA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
1
|
-
import { Component } from 'vue';
|
|
2
1
|
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
+
import type { WorkflowMeta } from '@stonecrop/schema';
|
|
3
|
+
import { Component } from 'vue';
|
|
3
4
|
import type { UnknownMachineConfig } from 'xstate';
|
|
4
5
|
import type { ImmutableDoctype } from './types';
|
|
5
6
|
/**
|
|
@@ -16,8 +17,8 @@ export type DoctypeConfig = {
|
|
|
16
17
|
tableName?: string;
|
|
17
18
|
/** Field definitions */
|
|
18
19
|
fields?: SchemaTypes[];
|
|
19
|
-
/** Workflow configuration */
|
|
20
|
-
workflow?: UnknownMachineConfig;
|
|
20
|
+
/** Workflow configuration (XState format or simple WorkflowMeta) */
|
|
21
|
+
workflow?: UnknownMachineConfig | WorkflowMeta;
|
|
21
22
|
/** Actions and their field triggers */
|
|
22
23
|
actions?: Record<string, string[]>;
|
|
23
24
|
/** Parent doctype for inheritance */
|
|
@@ -143,7 +144,7 @@ export default class Doctype {
|
|
|
143
144
|
getActionsObject(): Record<string, string[]>;
|
|
144
145
|
/**
|
|
145
146
|
* Returns the transitions available from a given workflow state, derived from the
|
|
146
|
-
* doctype's
|
|
147
|
+
* doctype's workflow configuration. Supports both XState format and WorkflowMeta format.
|
|
147
148
|
*
|
|
148
149
|
* @param currentState - The state name to read transitions from
|
|
149
150
|
* @returns Array of transition descriptors with `name` and `targetState`
|
|
@@ -160,6 +161,29 @@ export default class Doctype {
|
|
|
160
161
|
name: string;
|
|
161
162
|
targetState: string;
|
|
162
163
|
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Returns metadata for a specific action, if available.
|
|
166
|
+
* Only works with WorkflowMeta format; returns undefined for XState format.
|
|
167
|
+
*
|
|
168
|
+
* @param actionName - The action name to get metadata for
|
|
169
|
+
* @returns Action metadata or undefined
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const actionMeta = doctype.getActionMeta('submit')
|
|
174
|
+
* // { label: 'Submit', handler: 'plan:submit', allowedStates: ['draft'] }
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
getActionMeta(actionName: string): {
|
|
180
|
+
label: string;
|
|
181
|
+
handler: string;
|
|
182
|
+
requiredFields?: string[];
|
|
183
|
+
allowedStates?: string[];
|
|
184
|
+
confirm?: boolean;
|
|
185
|
+
args?: Record<string, unknown>;
|
|
186
|
+
} | undefined;
|
|
163
187
|
/**
|
|
164
188
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
165
189
|
* - It replaces camelCase and PascalCase with kebab-case strings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"
|
|
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,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wBAAwB;IACxB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,oBAAoB,GAAG,YAAY,CAAA;IAC9C,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAA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,EAAE,MAAM,CAAA;KAAE,CAAC;IAsC3F;;;;;;;;;;;;;;OAcG;IACH,aAAa,CACZ,UAAU,EAAE,MAAM,GAEhB;QACA,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAA;QACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;QACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QACxB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC7B,GACD,SAAS;IAQZ;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
|
|
@@ -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,KAAK,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAA;AAGjE,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;AAEpD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;CACnB;AAED;;;GAGG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,kBAAkB,CAAC,CAAyC;IACpE,OAAO,CAAC,mBAAmB,CAAC,CAA6B;IACzD,OAAO,CAAC,OAAO,CAAC,CAAY;IAE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AYjD;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAW7C;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAK7B;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI;IAkC/D;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjD;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelE;;;;;;;;;OASG;IACG,cAAc,CACnB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,EAAE,GACd,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAWrE;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAOlD;;;OAGG;IACH,QAAQ,IAAI,OAAO;IAInB;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAyBnE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataClient } from '@stonecrop/schema';
|
|
1
|
+
import type { DataClient, WorkflowMeta } from '@stonecrop/schema';
|
|
2
2
|
import type { SchemaTypes } from '@stonecrop/aform';
|
|
3
3
|
import { List, Map } from 'immutable';
|
|
4
4
|
import type { Component } from 'vue';
|
|
@@ -14,7 +14,7 @@ import type { RouteContext } from './registry';
|
|
|
14
14
|
*/
|
|
15
15
|
export type ImmutableDoctype = {
|
|
16
16
|
readonly schema?: List<SchemaTypes>;
|
|
17
|
-
readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig;
|
|
17
|
+
readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
18
18
|
readonly actions?: Map<string, string[]>;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
@@ -24,7 +24,7 @@ export type ImmutableDoctype = {
|
|
|
24
24
|
export type MutableDoctype = {
|
|
25
25
|
doctype?: string;
|
|
26
26
|
schema?: SchemaTypes[];
|
|
27
|
-
workflow?: UnknownMachineConfig | AnyStateNodeConfig;
|
|
27
|
+
workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
28
28
|
actions?: Record<string, string[]>;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,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AE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxF,CAAA;AAGD,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
|
package/dist/stonecrop.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { SchemaTypes } from '@stonecrop/aform';
|
|
|
11
11
|
import { Store } from 'pinia';
|
|
12
12
|
import { StoreDefinition } from 'pinia';
|
|
13
13
|
import type { UnknownMachineConfig } from 'xstate';
|
|
14
|
+
import type { WorkflowMeta } from '@stonecrop/schema';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Result of executing a field action
|
|
@@ -231,7 +232,7 @@ export declare class Doctype {
|
|
|
231
232
|
getActionsObject(): Record<string, string[]>;
|
|
232
233
|
/**
|
|
233
234
|
* Returns the transitions available from a given workflow state, derived from the
|
|
234
|
-
* doctype's
|
|
235
|
+
* doctype's workflow configuration. Supports both XState format and WorkflowMeta format.
|
|
235
236
|
*
|
|
236
237
|
* @param currentState - The state name to read transitions from
|
|
237
238
|
* @returns Array of transition descriptors with `name` and `targetState`
|
|
@@ -248,6 +249,29 @@ export declare class Doctype {
|
|
|
248
249
|
name: string;
|
|
249
250
|
targetState: string;
|
|
250
251
|
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Returns metadata for a specific action, if available.
|
|
254
|
+
* Only works with WorkflowMeta format; returns undefined for XState format.
|
|
255
|
+
*
|
|
256
|
+
* @param actionName - The action name to get metadata for
|
|
257
|
+
* @returns Action metadata or undefined
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const actionMeta = doctype.getActionMeta('submit')
|
|
262
|
+
* // { label: 'Submit', handler: 'plan:submit', allowedStates: ['draft'] }
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
getActionMeta(actionName: string): {
|
|
268
|
+
label: string;
|
|
269
|
+
handler: string;
|
|
270
|
+
requiredFields?: string[];
|
|
271
|
+
allowedStates?: string[];
|
|
272
|
+
confirm?: boolean;
|
|
273
|
+
args?: Record<string, unknown>;
|
|
274
|
+
} | undefined;
|
|
251
275
|
/**
|
|
252
276
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
253
277
|
* - It replaces camelCase and PascalCase with kebab-case strings
|
|
@@ -281,8 +305,8 @@ export declare type DoctypeConfig = {
|
|
|
281
305
|
tableName?: string;
|
|
282
306
|
/** Field definitions */
|
|
283
307
|
fields?: SchemaTypes[];
|
|
284
|
-
/** Workflow configuration */
|
|
285
|
-
workflow?: UnknownMachineConfig;
|
|
308
|
+
/** Workflow configuration (XState format or simple WorkflowMeta) */
|
|
309
|
+
workflow?: UnknownMachineConfig | WorkflowMeta;
|
|
286
310
|
/** Actions and their field triggers */
|
|
287
311
|
actions?: Record<string, string[]>;
|
|
288
312
|
/** Parent doctype for inheritance */
|
|
@@ -722,6 +746,9 @@ export declare type HSTStonecropReturn = BaseStonecropReturn & {
|
|
|
722
746
|
provideHSTPath: (fieldname: string) => string;
|
|
723
747
|
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
724
748
|
};
|
|
749
|
+
isLoading: Ref<boolean>;
|
|
750
|
+
error: Ref<Error | null>;
|
|
751
|
+
resolvedDoctype: Ref<Doctype | undefined>;
|
|
725
752
|
};
|
|
726
753
|
|
|
727
754
|
/**
|
|
@@ -730,7 +757,7 @@ export declare type HSTStonecropReturn = BaseStonecropReturn & {
|
|
|
730
757
|
*/
|
|
731
758
|
export declare type ImmutableDoctype = {
|
|
732
759
|
readonly schema?: List<SchemaTypes>;
|
|
733
|
-
readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig;
|
|
760
|
+
readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
734
761
|
readonly actions?: Map_2<string, string[]>;
|
|
735
762
|
};
|
|
736
763
|
|
|
@@ -780,7 +807,7 @@ export declare function markOperationIrreversible(operationId: string | undefine
|
|
|
780
807
|
export declare type MutableDoctype = {
|
|
781
808
|
doctype?: string;
|
|
782
809
|
schema?: SchemaTypes[];
|
|
783
|
-
workflow?: UnknownMachineConfig | AnyStateNodeConfig;
|
|
810
|
+
workflow?: UnknownMachineConfig | AnyStateNodeConfig | WorkflowMeta;
|
|
784
811
|
actions?: Record<string, string[]>;
|
|
785
812
|
};
|
|
786
813
|
|
|
@@ -1991,13 +2018,13 @@ export declare function useStonecrop(): BaseStonecropReturn | HSTStonecropReturn
|
|
|
1991
2018
|
/**
|
|
1992
2019
|
* Unified Stonecrop composable with HST integration for a specific doctype and record
|
|
1993
2020
|
*
|
|
1994
|
-
* @param options - Configuration with doctype and optional recordId
|
|
2021
|
+
* @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
|
|
1995
2022
|
* @returns Stonecrop instance with full HST integration utilities
|
|
1996
2023
|
* @public
|
|
1997
2024
|
*/
|
|
1998
2025
|
export declare function useStonecrop(options: {
|
|
1999
2026
|
registry?: Registry;
|
|
2000
|
-
doctype: Doctype;
|
|
2027
|
+
doctype: Doctype | string;
|
|
2001
2028
|
recordId?: string;
|
|
2002
2029
|
}): HSTStonecropReturn;
|
|
2003
2030
|
|