@stonecrop/stonecrop 0.10.0 → 0.10.2

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
@@ -19,37 +19,35 @@ import Stonecrop from '@stonecrop/stonecrop'
19
19
 
20
20
  const app = createApp(App)
21
21
 
22
- // Install the Stonecrop plugin
23
- app.use(Stonecrop, {
24
- router,
25
- components: {
26
- // Register custom components
27
- },
28
- getMeta: async (doctype: string) => {
29
- // Fetch doctype metadata from your API
30
- return await fetchDoctypeMeta(doctype)
31
- }
22
+ // Build your Registry before installing the plugin
23
+ const registry = new Registry(router, async ({ path, segments }) => {
24
+ return await fetchDoctypeMeta(segments[0])
32
25
  })
33
26
 
27
+ // Install the Stonecrop plugin
28
+ app.use(Stonecrop, { registry })
29
+
34
30
  app.mount('#app')
35
31
  ```
36
32
 
37
33
  ### Available Imports
38
34
 
39
35
  ```typescript
40
- // Default export - Vue plugin
41
- import Stonecrop from '@stonecrop/stonecrop'
36
+ // Default export - Vue plugin (install with app.use)
37
+ import StonecropPlugin from '@stonecrop/stonecrop'
42
38
 
43
39
  // Named exports - utilities and classes
44
40
  import {
45
- Stonecrop as StonecropClass, // Core class
46
- Registry, // Doctype registry
47
- useStonecrop, // Vue composable
48
- HST, // Hierarchical State Tree
49
- createHST, // HST factory
50
- DoctypeMeta // Doctype metadata class
41
+ Stonecrop, // Core orchestration class
42
+ Registry, // Doctype registry (singleton)
43
+ DoctypeMeta, // Doctype definition class
44
+ useStonecrop, // Vue composable — primary integration point
45
+ HST, // HST store class
46
+ createHST, // HST factory function
51
47
  } from '@stonecrop/stonecrop'
52
- ```### Using the Composable
48
+ ```
49
+
50
+ ### Using the Composable
53
51
 
54
52
  ```typescript
55
53
  import { useStonecrop } from '@stonecrop/stonecrop'
@@ -71,65 +69,22 @@ export default {
71
69
  ```
72
70
 
73
71
  ## Design
74
- A context will define schema, workflow and actions.
75
- - Schema describes the data model and layout of the document.
76
- - Workflows are the events that are registered on it and will specific to the context. An application might have 'login', 'onAppLoad', 'beforeRouteChange' and 'logout' events. A form/document context might define CRUD events. A table component, nested inside the form component might define its own events. I think we want Events to be FSM
77
- - Actions are an ordered set of functions, called by Workflow
78
- - [Router integration](https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-external-properties). Stonecrop setup should expect a router or provide a default implementation
72
+ A Doctype defines schema, workflow, and actions.
73
+ - **Schema** describes the data model and field layout used by AForm for rendering.
74
+ - **Workflow** is an XState machine config expressing the states and transitions a record can go through.
75
+ - **Actions** are an ordered map of named functions, triggered by field changes (lowercase keys) or FSM transitions (UPPERCASE keys).
76
+ - **Registry** is the singleton catalog — all doctypes live here. Optional Vue Router integration allows automatic route creation per doctype.
77
+ - **Stem/`useStonecrop()`** is the Vue composable that wires components to HST and provides `formData`, `provideHSTPath`, `handleHSTChange`, and the operation log API.
79
78
 
80
- The context will be tree-shaped with a single root. Adding more nodes at the root level isn't a problem, but multiple roots would be disallowed.
79
+ The data model is **two operations**: get data and run actions. There is no CRUD. Records change state through FSM transitions; those transitions have side effects (persistence, notifications, etc.) defined in action handlers registered by the application. The framework provides the pipeline; applications define what actions exist and what they do.
81
80
 
82
- Example APIs and paths
81
+ HST path structure:
83
82
 
84
83
  ```
85
- app.schema <Record> // immutable
86
- app.workflow <FSM> // immutable
87
- app.actions <OrderedSet> // immutable
88
- app.value <Store> // mutable
89
- app.user // "tyler@agritheory.com"
90
- app.name // "My First Application"
91
- app.doctype.schema <Record> // `app.doctype` lazy loaded by Event in router?
92
- app.doctype.workflow <FSM>
93
- app.doctype.actions <OrderedSet>
94
- app.doctype.actions.value <Store>
95
- app.doctype.schema.field.workflow <FSM>
96
- app.doctype.schema.field.actions <OrderedSet>
97
- app.doctype.schema.field.value <Store>
98
- app.doctype.schema.field.value.field.value <Store> // a "sub-form"
99
- app.doctype.schema.field.value.field['a:1'].value <Store> // also a "sub-form", representing a table
84
+ doctype.recordId.fieldname // e.g. plan.abc-123.title
85
+ doctype.recordId.nested.field // deep nesting supported
100
86
  ```
101
87
 
102
- ## Base Classes
103
- The Doctype aligns with a row, record or object in a database. It is required to specify its schema, a Finite State Machine that informs its workflow and a set of functions that are triggered by that FSM's state transitions.
104
-
105
- Registry is a map of all Doctypes, lazy loaded and is responsible for routing within the application
106
-
107
- Stem is a composable singleton that wraps Registry and provides application level state management
108
-
109
-
110
- ## Story / Network diagram
111
- #### **Doctype | Record Story**
112
-
113
- - User is redirected after successful login
114
- - Base URL is configured at app level to serve a navigation page
115
- - User navigates to list view of `doctype`
116
- - Table component loads existing records of `doctype` from schema; record-level schema is added to registry with web worker
117
- - User navigates to specific record of `doctype`: schema is loaded from registry, data is loaded from server
118
- - User mutates data, changes are persisted to server / DB per FSM
119
-
120
- #### **App Level**
121
- - User is redirected after successful login
122
- - Base URL is configured at app level to serve a navigation page
123
- - User opens command palette from lower-right-docked tab interface
124
- - User can search for `doctype` by name or other server-enabled capabilities
125
-
126
- #### **Low Code**
127
- - User can define `doctype` and schema from UI
128
- - Fields are shown as rows in a table
129
- - FSM is shown as an editable diagram that validates itself
130
-
131
- ___
132
-
133
88
  # Hierarchical State Tree (HST) Interface Requirements
134
89
 
135
90
  ## Core Requirements
@@ -1,6 +1,6 @@
1
1
  import { useMagicKeys, whenever } from '@vueuse/core';
2
2
  import { storeToRefs } from 'pinia';
3
- import { inject } from 'vue';
3
+ import { getCurrentInstance, inject } from 'vue';
4
4
  import { useOperationLogStore } from '../stores/operation-log';
5
5
  /**
6
6
  * Composable for operation log management
@@ -28,9 +28,12 @@ import { useOperationLogStore } from '../stores/operation-log';
28
28
  * @public
29
29
  */
30
30
  export function useOperationLog(config) {
31
- // Try to use the injected store from the Stonecrop plugin first
32
- // This ensures we use the same Pinia instance as the app
33
- const injectedStore = inject('$operationLogStore', undefined);
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;
34
37
  const store = injectedStore || useOperationLogStore();
35
38
  // Apply configuration if provided
36
39
  if (config) {
package/dist/doctype.js CHANGED
@@ -48,6 +48,33 @@ export default class DoctypeMeta {
48
48
  this.actions = actions;
49
49
  this.component = component;
50
50
  }
51
+ /**
52
+ * Returns the transitions available from a given workflow state, derived from the
53
+ * doctype's XState workflow configuration.
54
+ *
55
+ * @param currentState - The state name to read transitions from
56
+ * @returns Array of transition descriptors with `name` and `targetState`
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const transitions = doctype.getAvailableTransitions('draft')
61
+ * // [{ name: 'SUBMIT', targetState: 'submitted' }]
62
+ * ```
63
+ *
64
+ * @public
65
+ */
66
+ getAvailableTransitions(currentState) {
67
+ const states = this.workflow?.states;
68
+ if (!states)
69
+ return [];
70
+ const stateConfig = states[currentState];
71
+ if (!stateConfig?.on)
72
+ return [];
73
+ return Object.entries(stateConfig.on).map(([name, target]) => ({
74
+ name,
75
+ targetState: typeof target === 'string' ? target : 'unknown',
76
+ }));
77
+ }
51
78
  /**
52
79
  * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
53
80
  * - It replaces camelCase and PascalCase with kebab-case strings
package/dist/registry.js CHANGED
@@ -235,4 +235,13 @@ export default class Registry {
235
235
  });
236
236
  return record;
237
237
  }
238
+ /**
239
+ * Get a registered doctype by slug
240
+ * @param slug - The doctype slug to look up
241
+ * @returns The DoctypeMeta instance if found, or undefined
242
+ * @public
243
+ */
244
+ getDoctype(slug) {
245
+ return this.registry[slug];
246
+ }
238
247
  }
@@ -1 +1 @@
1
- {"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/composables/operation-log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;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M,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"}
@@ -44,6 +44,25 @@ export default class DoctypeMeta {
44
44
  * @param component - Optional Vue component for rendering the doctype
45
45
  */
46
46
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
47
+ /**
48
+ * Returns the transitions available from a given workflow state, derived from the
49
+ * doctype's XState workflow configuration.
50
+ *
51
+ * @param currentState - The state name to read transitions from
52
+ * @returns Array of transition descriptors with `name` and `targetState`
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const transitions = doctype.getAvailableTransitions('draft')
57
+ * // [{ name: 'SUBMIT', targetState: 'submitted' }]
58
+ * ```
59
+ *
60
+ * @public
61
+ */
62
+ getAvailableTransitions(currentState: string): Array<{
63
+ name: string;
64
+ targetState: string;
65
+ }>;
47
66
  /**
48
67
  * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
49
68
  * - 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":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,KAA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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,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAW3F;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
@@ -103,5 +103,12 @@ export default class Registry {
103
103
  * @public
104
104
  */
105
105
  initializeRecord(schema: SchemaTypes[]): Record<string, any>;
106
+ /**
107
+ * Get a registered doctype by slug
108
+ * @param slug - The doctype slug to look up
109
+ * @returns The DoctypeMeta instance if found, or undefined
110
+ * @public
111
+ */
112
+ getDoctype(slug: string): DoctypeMeta | undefined;
106
113
  }
107
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;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,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,CAAC,GAAG,WAAW,EAAE;IAwF1E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA4C5D;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;CAgBjD"}
@@ -367,5 +367,19 @@ export declare class Stonecrop {
367
367
  * @returns Root HST node
368
368
  */
369
369
  getStore(): HSTNode;
370
+ /**
371
+ * Determine the current workflow state for a record.
372
+ *
373
+ * Reads the record's `status` field from the HST store. If the field is absent or
374
+ * empty the doctype's declared `workflow.initial` state is used as the fallback,
375
+ * giving callers a reliable state name without having to duplicate that logic.
376
+ *
377
+ * @param doctype - The doctype slug or DoctypeMeta instance
378
+ * @param recordId - The record identifier
379
+ * @returns The current state name, or an empty string if the doctype has no workflow
380
+ *
381
+ * @public
382
+ */
383
+ getRecordState(doctype: string | DoctypeMeta, recordId: string): string;
370
384
  }
371
385
  //# sourceMappingURL=stonecrop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stonecrop.d.ts","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AC;8BAkBtB,iBAAiB,WAAU,eAAe;;gCAwDxC,MAAM,KAAG,MAAM,GAAG,IAAI;;kBA+DpC,OAAO,KAAG,OAAO;kBAmDjB,OAAO,KAAG,OAAO;;gCA2FH,MAAM,aAAa,MAAM,KAAG,YAAY,EAAE;uBA1BrD,oBAAoB;oCAmCL,MAAM,UAAU,MAAM;yBAmBnD,MAAM,cACH,MAAM,cACN,MAAM,EAAE,WACZ,SAAS,GAAG,SAAS,GAAG,SAAS,UACjC,MAAM,KACZ,MAAM;oLA0MR,CAAA"}
@@ -158,6 +158,25 @@ export declare class DoctypeMeta {
158
158
  * @param component - Optional Vue component for rendering the doctype
159
159
  */
160
160
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
161
+ /**
162
+ * Returns the transitions available from a given workflow state, derived from the
163
+ * doctype's XState workflow configuration.
164
+ *
165
+ * @param currentState - The state name to read transitions from
166
+ * @returns Array of transition descriptors with `name` and `targetState`
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const transitions = doctype.getAvailableTransitions('draft')
171
+ * // [{ name: 'SUBMIT', targetState: 'submitted' }]
172
+ * ```
173
+ *
174
+ * @public
175
+ */
176
+ getAvailableTransitions(currentState: string): Array<{
177
+ name: string;
178
+ targetState: string;
179
+ }>;
161
180
  /**
162
181
  * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
163
182
  * - It replaces camelCase and PascalCase with kebab-case strings
@@ -888,6 +907,13 @@ export declare class Registry {
888
907
  * @public
889
908
  */
890
909
  initializeRecord(schema: SchemaTypes[]): Record<string, any>;
910
+ /**
911
+ * Get a registered doctype by slug
912
+ * @param slug - The doctype slug to look up
913
+ * @returns The DoctypeMeta instance if found, or undefined
914
+ * @public
915
+ */
916
+ getDoctype(slug: string): DoctypeMeta | undefined;
891
917
  }
892
918
 
893
919
  /**
@@ -1325,6 +1351,20 @@ export declare class Stonecrop {
1325
1351
  * @returns Root HST node
1326
1352
  */
1327
1353
  getStore(): HSTNode;
1354
+ /**
1355
+ * Determine the current workflow state for a record.
1356
+ *
1357
+ * Reads the record's `status` field from the HST store. If the field is absent or
1358
+ * empty the doctype's declared `workflow.initial` state is used as the fallback,
1359
+ * giving callers a reliable state name without having to duplicate that logic.
1360
+ *
1361
+ * @param doctype - The doctype slug or DoctypeMeta instance
1362
+ * @param recordId - The record identifier
1363
+ * @returns The current state name, or an empty string if the doctype has no workflow
1364
+ *
1365
+ * @public
1366
+ */
1367
+ getRecordState(doctype: string | DoctypeMeta, recordId: string): string;
1328
1368
  }
1329
1369
 
1330
1370
  /**