@stonecrop/stonecrop 0.10.5 → 0.10.7

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 CHANGED
@@ -50,7 +50,7 @@ app.mount('#app')
50
50
  | Option | Type | Description |
51
51
  |--------|------|-------------|
52
52
  | `router` | `Router` | Vue Router instance. Required for route-based doctype resolution. |
53
- | `getMeta` | `(ctx: RouteContext) => DoctypeMeta \| Promise<DoctypeMeta>` | Lazy-loads doctype metadata for the current route. `ctx` has `path` and `segments`. |
53
+ | `getMeta` | `(ctx: RouteContext) => Doctype \| Promise<Doctype>` | Lazy-loads doctype metadata for the current route. `ctx` has `path` and `segments`. |
54
54
  | `fetchRecord` | `(doctype, id) => Promise<Record \| null>` | Injectable replacement for `Stonecrop.getRecord()`'s default REST fetch. Use this to plug in GraphQL or any other transport. |
55
55
  | `fetchRecords` | `(doctype) => Promise<Record[]>` | Injectable replacement for `Stonecrop.getRecords()`'s default REST fetch. |
56
56
  | `components` | `Record<string, Component>` | Additional Vue components to register globally. |
@@ -67,7 +67,7 @@ import StonecropPlugin from '@stonecrop/stonecrop'
67
67
  import {
68
68
  Stonecrop, // Core orchestration class
69
69
  Registry, // Doctype registry (singleton)
70
- DoctypeMeta, // Doctype definition class
70
+ Doctype, // Doctype definition class
71
71
  useStonecrop, // Vue composable — primary integration point
72
72
  HST, // HST store class
73
73
  createHST, // HST factory function
@@ -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 doctype and optional recordId for full integration
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
- // Auto-resolve schema when doctype is available
21
- if (options.doctype && registry) {
22
- const schemaArray = options.doctype.schema
23
- ? Array.isArray(options.doctype.schema)
24
- ? options.doctype.schema
25
- : Array.from(options.doctype.schema)
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 = options.doctype || routerDoctype.value;
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 = options.doctype || routerDoctype.value;
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 = (doctype.schema ? (Array.isArray(doctype.schema) ? doctype.schema : Array.from(doctype.schema)) : []);
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
@@ -1,8 +1,9 @@
1
+ import { List, Map } from 'immutable';
1
2
  /**
2
- * Doctype Meta class
3
+ * Doctype runtime class with Immutable.js collections for HST change tracking.
3
4
  * @public
4
5
  */
5
- export default class DoctypeMeta {
6
+ export default class Doctype {
6
7
  /**
7
8
  * The doctype name
8
9
  * @public
@@ -42,7 +43,7 @@ export default class DoctypeMeta {
42
43
  */
43
44
  component;
44
45
  /**
45
- * Creates a new DoctypeMeta instance
46
+ * Creates a new Doctype instance
46
47
  * @param doctype - The doctype name
47
48
  * @param schema - The doctype schema definition
48
49
  * @param workflow - The doctype workflow configuration (XState machine)
@@ -56,6 +57,82 @@ export default class DoctypeMeta {
56
57
  this.actions = actions;
57
58
  this.component = component;
58
59
  }
60
+ /**
61
+ * Creates a Doctype instance from a plain configuration object.
62
+ * Handles conversion of arrays to Immutable.js collections internally.
63
+ *
64
+ * This is the recommended way to create a Doctype from API responses
65
+ * or configuration files, as it encapsulates the Immutable.js construction
66
+ * that the framework uses internally.
67
+ *
68
+ * @param config - Plain object with doctype configuration (typically from API response)
69
+ * @returns A new Doctype instance with Immutable.js collections
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // From an API response
74
+ * const response = await client.getMeta({ doctype: 'plan' })
75
+ * const doctype = Doctype.fromObject(response)
76
+ * registry.addDoctype(doctype)
77
+ * ```
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * // From a configuration object
82
+ * const planDoctype = Doctype.fromObject({
83
+ * name: 'Plan',
84
+ * fields: [
85
+ * { fieldname: 'title', label: 'Title', fieldtype: 'Data' },
86
+ * { fieldname: 'status', label: 'Status', fieldtype: 'Data' },
87
+ * ],
88
+ * workflow: {
89
+ * id: 'plan',
90
+ * initial: 'draft',
91
+ * states: { draft: {}, submitted: {} }
92
+ * }
93
+ * })
94
+ * ```
95
+ *
96
+ * @public
97
+ */
98
+ static fromObject(config) {
99
+ const schema = config.fields ? List(config.fields) : List();
100
+ const actions = config.actions ? Map(config.actions) : Map();
101
+ return new Doctype(config.name, schema, config.workflow, actions);
102
+ }
103
+ /**
104
+ * Returns the schema as a plain array for use with components that expect
105
+ * plain JavaScript arrays (e.g., AForm, ATable).
106
+ *
107
+ * @returns Array of schema fields
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const schemaArray = doctype.getSchemaArray()
112
+ * // Use with AForm
113
+ * <AForm :schema="schemaArray" v-model:data="formData" />
114
+ * ```
115
+ *
116
+ * @public
117
+ */
118
+ getSchemaArray() {
119
+ if (!this.schema)
120
+ return [];
121
+ return this.schema.toArray();
122
+ }
123
+ /**
124
+ * Returns the actions as a plain object for use with components that expect
125
+ * plain JavaScript objects.
126
+ *
127
+ * @returns Object mapping action names to field trigger arrays
128
+ *
129
+ * @public
130
+ */
131
+ getActionsObject() {
132
+ if (!this.actions)
133
+ return {};
134
+ return this.actions.toObject();
135
+ }
59
136
  /**
60
137
  * Returns the transitions available from a given workflow state, derived from the
61
138
  * doctype's XState workflow configuration.
@@ -93,7 +170,7 @@ export default class DoctypeMeta {
93
170
  *
94
171
  * @example
95
172
  * ```ts
96
- * const doctype = new DoctypeMeta('TaskItem', schema, workflow, actions
173
+ * const doctype = new Doctype('TaskItem', schema, workflow, actions)
97
174
  * console.log(doctype.slug) // 'task-item'
98
175
  * ```
99
176
  *
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useStonecrop } from './composables/stonecrop';
2
2
  import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
3
- import DoctypeMeta from './doctype';
3
+ import Doctype from './doctype';
4
4
  import { getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, } from './field-triggers';
5
5
  import plugin from './plugins';
6
6
  import Registry from './registry';
@@ -10,7 +10,7 @@ import { useOperationLogStore } from './stores/operation-log';
10
10
  // Export schema validator
11
11
  import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
12
12
  export { ValidationSeverity } from './schema-validator';
13
- export { DoctypeMeta, Registry, Stonecrop, useStonecrop,
13
+ export { Doctype, Registry, Stonecrop, useStonecrop,
14
14
  // HST exports for advanced usage
15
15
  HST, createHST,
16
16
  // Field trigger system exports
package/dist/registry.js CHANGED
@@ -16,7 +16,7 @@ export default class Registry {
16
16
  name;
17
17
  /**
18
18
  * The registry property contains a collection of doctypes
19
- * @see {@link DoctypeMeta}
19
+ * @see {@link Doctype}
20
20
  */
21
21
  registry;
22
22
  /**
@@ -41,14 +41,14 @@ export default class Registry {
41
41
  }
42
42
  /**
43
43
  * The getMeta function fetches doctype metadata from an API based on route context
44
- * @see {@link DoctypeMeta}
44
+ * @see {@link Doctype}
45
45
  */
46
46
  getMeta;
47
47
  /**
48
48
  * Get doctype metadata
49
49
  * @param doctype - The doctype to fetch metadata for
50
50
  * @returns The doctype metadata
51
- * @see {@link DoctypeMeta}
51
+ * @see {@link Doctype}
52
52
  */
53
53
  addDoctype(doctype) {
54
54
  if (!(doctype.slug in this.registry)) {
@@ -238,7 +238,7 @@ export default class Registry {
238
238
  /**
239
239
  * Get a registered doctype by slug
240
240
  * @param slug - The doctype slug to look up
241
- * @returns The DoctypeMeta instance if found, or undefined
241
+ * @returns The Doctype instance if found, or undefined
242
242
  * @public
243
243
  */
244
244
  getDoctype(slug) {
@@ -1,7 +1,7 @@
1
1
  import { Ref, ComputedRef } from 'vue';
2
2
  import Registry from '../registry';
3
3
  import { Stonecrop } from '../stonecrop';
4
- import DoctypeMeta from '../doctype';
4
+ import Doctype from '../doctype';
5
5
  import type { HSTNode } from '../stores/hst';
6
6
  import type { HSTOperation, OperationLogConfig, OperationLogSnapshot } from '../types/operation-log';
7
7
  import { SchemaTypes } from '@stonecrop/aform';
@@ -53,12 +53,15 @@ export type HSTStonecropReturn = BaseStonecropReturn & {
53
53
  hstStore: Ref<HSTNode | undefined>;
54
54
  formData: Ref<Record<string, any>>;
55
55
  resolvedSchema: Ref<SchemaTypes[]>;
56
- loadNestedData: (parentPath: string, childDoctype: DoctypeMeta, recordId?: string) => Record<string, any>;
57
- saveRecursive: (doctype: DoctypeMeta, recordId: string) => Promise<Record<string, any>>;
58
- createNestedContext: (basePath: string, childDoctype: DoctypeMeta) => {
56
+ loadNestedData: (parentPath: string, childDoctype: Doctype, recordId?: string) => Record<string, any>;
57
+ saveRecursive: (doctype: Doctype, recordId: string) => Promise<Record<string, any>>;
58
+ createNestedContext: (basePath: string, childDoctype: Doctype) => {
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: DoctypeMeta;
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,WAAW,MAAM,YAAY,CAAA;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG5C,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACpG,OAAO,EAAE,WAAW,EAAiB,MAAM,kBAAkB,CAA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G,kBAAkB,CAAA;AACxE;;;;;;GAMG;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"}
@@ -1,10 +1,37 @@
1
1
  import { Component } from 'vue';
2
+ import type { SchemaTypes } from '@stonecrop/aform';
3
+ import type { UnknownMachineConfig } from 'xstate';
2
4
  import type { ImmutableDoctype } from './types';
3
5
  /**
4
- * Doctype Meta class
6
+ * Plain object representation of doctype configuration for serialization/API responses.
7
+ * Compatible with the DoctypeMeta type from \@stonecrop/schema.
5
8
  * @public
6
9
  */
7
- export default class DoctypeMeta {
10
+ export type DoctypeConfig = {
11
+ /** Display name of the doctype */
12
+ name: string;
13
+ /** URL-friendly slug (kebab-case) */
14
+ slug?: string;
15
+ /** Database table name */
16
+ tableName?: string;
17
+ /** Field definitions */
18
+ fields?: SchemaTypes[];
19
+ /** Workflow configuration */
20
+ workflow?: UnknownMachineConfig;
21
+ /** Actions and their field triggers */
22
+ actions?: Record<string, string[]>;
23
+ /** Parent doctype for inheritance */
24
+ inherits?: string;
25
+ /** Doctype to use for list views */
26
+ listDoctype?: string;
27
+ /** Parent doctype for child tables */
28
+ parentDoctype?: string;
29
+ };
30
+ /**
31
+ * Doctype runtime class with Immutable.js collections for HST change tracking.
32
+ * @public
33
+ */
34
+ export default class Doctype {
8
35
  /**
9
36
  * The doctype name
10
37
  * @public
@@ -42,7 +69,7 @@ export default class DoctypeMeta {
42
69
  */
43
70
  readonly component?: Component;
44
71
  /**
45
- * Creates a new DoctypeMeta instance
72
+ * Creates a new Doctype instance
46
73
  * @param doctype - The doctype name
47
74
  * @param schema - The doctype schema definition
48
75
  * @param workflow - The doctype workflow configuration (XState machine)
@@ -50,6 +77,70 @@ export default class DoctypeMeta {
50
77
  * @param component - Optional Vue component for rendering the doctype
51
78
  */
52
79
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
80
+ /**
81
+ * Creates a Doctype instance from a plain configuration object.
82
+ * Handles conversion of arrays to Immutable.js collections internally.
83
+ *
84
+ * This is the recommended way to create a Doctype from API responses
85
+ * or configuration files, as it encapsulates the Immutable.js construction
86
+ * that the framework uses internally.
87
+ *
88
+ * @param config - Plain object with doctype configuration (typically from API response)
89
+ * @returns A new Doctype instance with Immutable.js collections
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * // From an API response
94
+ * const response = await client.getMeta({ doctype: 'plan' })
95
+ * const doctype = Doctype.fromObject(response)
96
+ * registry.addDoctype(doctype)
97
+ * ```
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // From a configuration object
102
+ * const planDoctype = Doctype.fromObject({
103
+ * name: 'Plan',
104
+ * fields: [
105
+ * { fieldname: 'title', label: 'Title', fieldtype: 'Data' },
106
+ * { fieldname: 'status', label: 'Status', fieldtype: 'Data' },
107
+ * ],
108
+ * workflow: {
109
+ * id: 'plan',
110
+ * initial: 'draft',
111
+ * states: { draft: {}, submitted: {} }
112
+ * }
113
+ * })
114
+ * ```
115
+ *
116
+ * @public
117
+ */
118
+ static fromObject(config: DoctypeConfig): Doctype;
119
+ /**
120
+ * Returns the schema as a plain array for use with components that expect
121
+ * plain JavaScript arrays (e.g., AForm, ATable).
122
+ *
123
+ * @returns Array of schema fields
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const schemaArray = doctype.getSchemaArray()
128
+ * // Use with AForm
129
+ * <AForm :schema="schemaArray" v-model:data="formData" />
130
+ * ```
131
+ *
132
+ * @public
133
+ */
134
+ getSchemaArray(): SchemaTypes[];
135
+ /**
136
+ * Returns the actions as a plain object for use with components that expect
137
+ * plain JavaScript objects.
138
+ *
139
+ * @returns Object mapping action names to field trigger arrays
140
+ *
141
+ * @public
142
+ */
143
+ getActionsObject(): Record<string, string[]>;
53
144
  /**
54
145
  * Returns the transitions available from a given workflow state, derived from the
55
146
  * doctype's XState workflow configuration.
@@ -79,7 +170,7 @@ export default class DoctypeMeta {
79
170
  *
80
171
  * @example
81
172
  * ```ts
82
- * const doctype = new DoctypeMeta('TaskItem', schema, workflow, actions
173
+ * const doctype = new Doctype('TaskItem', schema, workflow, actions)
83
174
  * console.log(doctype.slug) // 'task-item'
84
175
  * ```
85
176
  *
@@ -1 +1 @@
1
- {"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAE/C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;IAE9B;;;;;;;OAOG;gBAEF,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,EACtC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS;IAStB;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAA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AQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAE/C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;IAE9B;;;;;;;OAOG;gBAEF,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,EACtC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,SAAS,CAAC,EAAE,SAAS;IAStB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAOjD;;;;;;;;;;;;;;OAcG;IACH,cAAc,IAAI,WAAW,EAAE;IAK/B;;;;;;;OAOG;IACH,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAK5C;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAW3F;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
@@ -2,7 +2,7 @@ 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 DoctypeMeta from './doctype';
5
+ import Doctype, { type DoctypeConfig } from './doctype';
6
6
  import { getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
7
7
  import plugin from './plugins';
8
8
  import Registry from './registry';
@@ -16,6 +16,6 @@ export type { FieldTriggerEngine } from './field-triggers';
16
16
  export type { FieldChangeContext, TransitionChangeContext, FieldTriggerExecutionResult, ActionExecutionResult, TransitionExecutionResult, FieldActionFunction, TransitionActionFunction, } from './types/field-triggers';
17
17
  export type { ValidationIssue, ValidationResult, ValidatorOptions } from './schema-validator';
18
18
  export { ValidationSeverity } from './schema-validator';
19
- export { DoctypeMeta, Registry, Stonecrop, StonecropOptions, useStonecrop, HST, createHST, HSTNode, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, };
19
+ export { Doctype, DoctypeConfig, Registry, Stonecrop, StonecropOptions, useStonecrop, HST, createHST, HSTNode, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, };
20
20
  export default plugin;
21
21
  //# sourceMappingURL=index.d.ts.map
@@ -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,WAAW,MAAM,WAAW,CAAA;AACnC,OAAO,EACN,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,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9D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,EACf,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,GACT,CAAA;AAGD,eAAe,MAAM,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { SchemaTypes } from '@stonecrop/aform';
2
2
  import { Router } from 'vue-router';
3
- import DoctypeMeta from './doctype';
3
+ import Doctype from './doctype';
4
4
  import { RouteContext } from './types/registry';
5
5
  /**
6
6
  * Stonecrop Registry class
@@ -19,9 +19,9 @@ export default class Registry {
19
19
  readonly name: string;
20
20
  /**
21
21
  * The registry property contains a collection of doctypes
22
- * @see {@link DoctypeMeta}
22
+ * @see {@link Doctype}
23
23
  */
24
- readonly registry: Record<string, DoctypeMeta>;
24
+ readonly registry: Record<string, Doctype>;
25
25
  /**
26
26
  * The Vue router instance
27
27
  * @see {@link https://router.vuejs.org/}
@@ -32,19 +32,19 @@ export default class Registry {
32
32
  * @param router - Optional Vue router instance for route management
33
33
  * @param getMeta - Optional function to fetch doctype metadata from an API
34
34
  */
35
- constructor(router?: Router, getMeta?: (routeContext: RouteContext) => DoctypeMeta | Promise<DoctypeMeta>);
35
+ constructor(router?: Router, getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>);
36
36
  /**
37
37
  * The getMeta function fetches doctype metadata from an API based on route context
38
- * @see {@link DoctypeMeta}
38
+ * @see {@link Doctype}
39
39
  */
40
- getMeta?: (routeContext: RouteContext) => DoctypeMeta | Promise<DoctypeMeta>;
40
+ getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
41
41
  /**
42
42
  * Get doctype metadata
43
43
  * @param doctype - The doctype to fetch metadata for
44
44
  * @returns The doctype metadata
45
- * @see {@link DoctypeMeta}
45
+ * @see {@link Doctype}
46
46
  */
47
- addDoctype(doctype: DoctypeMeta): void;
47
+ addDoctype(doctype: Doctype): void;
48
48
  /**
49
49
  * Resolve nested Doctype and Table fields in a schema by embedding child schemas inline.
50
50
  *
@@ -106,9 +106,9 @@ export default class Registry {
106
106
  /**
107
107
  * Get a registered doctype by slug
108
108
  * @param slug - The doctype slug to look up
109
- * @returns The DoctypeMeta instance if found, or undefined
109
+ * @returns The Doctype instance if found, or undefined
110
110
  * @public
111
111
  */
112
- getDoctype(slug: string): DoctypeMeta | undefined;
112
+ getDoctype(slug: string): Doctype | undefined;
113
113
  }
114
114
  //# 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,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC,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,WAAW,CAAC,CAAA;IAE9C;;;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,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAWzG;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAE5E;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW;IAsB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CA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