@stonecrop/stonecrop 0.4.28 → 0.4.29

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.
@@ -14,6 +14,8 @@ export function useStonecrop(registry) {
14
14
  if (!registry) {
15
15
  registry = inject('$registry');
16
16
  }
17
+ if (!registry || !registry.router)
18
+ return;
17
19
  let store;
18
20
  try {
19
21
  store = useDataStore();
@@ -21,10 +23,7 @@ export function useStonecrop(registry) {
21
23
  catch (e) {
22
24
  throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable');
23
25
  }
24
- // @ts-expect-error TODO: handle empty registry passed to Stonecrop
25
26
  stonecrop.value = new Stonecrop(registry, store);
26
- if (!registry || !registry.router)
27
- return;
28
27
  const route = registry.router.currentRoute.value;
29
28
  const doctypeSlug = route.params.records?.toString().toLowerCase();
30
29
  const recordId = route.params.record?.toString().toLowerCase();
@@ -45,7 +44,7 @@ export function useStonecrop(registry) {
45
44
  await stonecrop.value.getRecords(doctype);
46
45
  }
47
46
  }
48
- stonecrop.value.runAction(doctype, 'LOAD', recordId ? [recordId] : undefined);
47
+ stonecrop.value.runAction(doctype, 'load', recordId ? [recordId] : undefined);
49
48
  }
50
49
  });
51
50
  return { stonecrop };
package/dist/doctype.js CHANGED
@@ -43,8 +43,19 @@ export default class DoctypeMeta {
43
43
  this.component = component;
44
44
  }
45
45
  /**
46
- * Converts the registered doctype to a slug (kebab-case)
46
+ * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
47
+ * - It replaces camelCase and PascalCase with kebab-case strings
48
+ * - It replaces spaces and underscores with hyphens
49
+ * - It converts the string to lowercase
50
+ *
47
51
  * @returns The slugified doctype string
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const doctype = new DoctypeMeta('TaskItem', schema, workflow, actions
56
+ * console.log(doctype.slug) // 'task-item'
57
+ * ```
58
+ *
48
59
  * @public
49
60
  */
50
61
  get slug() {
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ import { useStonecrop } from './composable';
2
2
  import DoctypeMeta from './doctype';
3
3
  import Registry from './registry';
4
4
  import Stonecrop from './plugins';
5
- export { DoctypeMeta, Registry, Stonecrop, useStonecrop };
5
+ import { Stonecrop as StonecropClass } from './stonecrop';
6
+ export { DoctypeMeta, Registry, Stonecrop, StonecropClass, useStonecrop };
package/dist/registry.js CHANGED
@@ -23,11 +23,6 @@ export default class Registry {
23
23
  * @see {@link https://router.vuejs.org/}
24
24
  */
25
25
  router;
26
- /**
27
- * The getMeta function fetches doctype metadata from an API
28
- * @see {@link DoctypeMeta}
29
- */
30
- getMeta;
31
26
  constructor(router, getMeta) {
32
27
  if (Registry._root) {
33
28
  return Registry._root;
@@ -38,6 +33,11 @@ export default class Registry {
38
33
  this.router = router;
39
34
  this.getMeta = getMeta;
40
35
  }
36
+ /**
37
+ * The getMeta function fetches doctype metadata from an API
38
+ * @see {@link DoctypeMeta}
39
+ */
40
+ getMeta;
41
41
  /**
42
42
  * Get doctype metadata
43
43
  * @param doctype - The doctype to fetch metadata for
@@ -1 +1 @@
1
- {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAO,MAAM,KAAK,CAAA;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CAgDjE"}
1
+ {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAO,MAAM,KAAK,CAAA;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CA8CjE"}
@@ -37,8 +37,19 @@ export default class DoctypeMeta {
37
37
  readonly component?: Component;
38
38
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
39
39
  /**
40
- * Converts the registered doctype to a slug (kebab-case)
40
+ * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
41
+ * - It replaces camelCase and PascalCase with kebab-case strings
42
+ * - It replaces spaces and underscores with hyphens
43
+ * - It converts the string to lowercase
44
+ *
41
45
  * @returns The slugified doctype string
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const doctype = new DoctypeMeta('TaskItem', schema, workflow, actions
50
+ * console.log(doctype.slug) // 'task-item'
51
+ * ```
52
+ *
42
53
  * @public
43
54
  */
44
55
  get slug(): string;
@@ -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,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,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op } from './composable';
4
4
  import DoctypeMeta from './doctype';
5
5
  import Registry from './registry';
6
6
  import Stonecrop from './plugins';
7
+ import { Stonecrop as StonecropClass } from './stonecrop';
7
8
  export type { ImmutableDoctype, MutableDoctype, Schema, InstallOptions } from './types';
8
- export { DoctypeMeta, Registry, Stonecrop, StonecropReturn, useStonecrop };
9
+ export { DoctypeMeta, Registry, Stonecrop, StonecropClass, StonecropReturn, useStonecrop };
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACxG,YAAY,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,GACR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,WAAW,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEvF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACxG,YAAY,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,GACR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,WAAW,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,aAAa,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEvF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,CAAA"}
@@ -14,23 +14,23 @@ export default class Registry {
14
14
  *
15
15
  * @defaultValue 'Registry'
16
16
  */
17
- name: string;
17
+ readonly name: string;
18
18
  /**
19
19
  * The registry property contains a collection of doctypes
20
20
  * @see {@link DoctypeMeta}
21
21
  */
22
- registry: Record<string, DoctypeMeta>;
22
+ readonly registry: Record<string, DoctypeMeta>;
23
23
  /**
24
24
  * The Vue router instance
25
25
  * @see {@link https://router.vuejs.org/}
26
26
  */
27
- router?: Router;
27
+ readonly router?: Router;
28
+ constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
28
29
  /**
29
30
  * The getMeta function fetches doctype metadata from an API
30
31
  * @see {@link DoctypeMeta}
31
32
  */
32
33
  getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>;
33
- constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
34
34
  /**
35
35
  * Get doctype metadata
36
36
  * @param doctype - The doctype to fetch metadata for
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YA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ACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAEjE;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW;CA0B/B"}
@@ -1,7 +1,6 @@
1
1
  import DoctypeMeta from './doctype';
2
2
  import Registry from './registry';
3
3
  import { useDataStore } from './stores/data';
4
- import type { ImmutableDoctype, Schema } from './types';
5
4
  /**
6
5
  * Stonecrop class
7
6
  * @public
@@ -42,39 +41,10 @@ export declare class Stonecrop {
42
41
  * The Pinia store that manages the mutable records
43
42
  */
44
43
  store: ReturnType<typeof useDataStore>;
45
- /**
46
- * schema - The Stonecrop schema; the schema is a subset of the registry
47
- * @example
48
- * ```ts
49
- * {
50
- * doctype: 'Task',
51
- * schema: {
52
- * title: 'string',
53
- * description: 'string',
54
- * ...
55
- * }
56
- * }
57
- * ```
58
- * @see {@link Registry}
59
- * @see {@link DoctypeMeta}
60
- * @see {@link DoctypeMeta.schema}
61
- */
62
- schema?: Schema;
63
- /**
64
- * The workflow is a subset of the registry
65
- */
66
- workflow?: ImmutableDoctype['workflow'];
67
- /**
68
- * The actions are a subset of the registry
69
- */
70
- actions?: ImmutableDoctype['actions'];
71
44
  /**
72
45
  * @param registry - The immutable registry
73
46
  * @param store - The mutable Pinia store
74
- * @param schema - The Stonecrop schema
75
- * @param workflow - The Stonecrop workflow
76
- * @param actions - The Stonecrop actions
77
- * @returns The Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
47
+ * @returns The Stonecrop instance with the given registry and store. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
78
48
  * @example
79
49
  * ```ts
80
50
  * const registry = new Registry()
@@ -82,7 +52,7 @@ export declare class Stonecrop {
82
52
  * const stonecrop = new Stonecrop(registry, store)
83
53
  * ```
84
54
  */
85
- constructor(registry: Registry, store: ReturnType<typeof useDataStore>, schema?: Schema, workflow?: ImmutableDoctype['workflow'], actions?: ImmutableDoctype['actions']);
55
+ constructor(registry: Registry, store: ReturnType<typeof useDataStore>);
86
56
  /**
87
57
  * Sets up the Stonecrop instance with the given doctype
88
58
  * @param doctype - The doctype to setup
@@ -97,7 +67,7 @@ export declare class Stonecrop {
97
67
  * Gets the meta for the given doctype
98
68
  * @param doctype - The doctype to get meta for
99
69
  * @returns The meta for the given doctype
100
- * @throws NotImplementedError
70
+ * @throws `NotImplementedError` if the `getMeta` function is not implemented for the doctype in the registry
101
71
  * @example
102
72
  * ```ts
103
73
  * const doctype = await registry.getMeta('Task')
@@ -105,27 +75,7 @@ export declare class Stonecrop {
105
75
  * ```
106
76
  * @see {@link DoctypeMeta}
107
77
  */
108
- getMeta(doctype: DoctypeMeta): DoctypeMeta | Promise<DoctypeMeta> | never;
109
- /**
110
- * Gets the workflow for the given doctype
111
- * @param doctype - The doctype to get workflow for
112
- * @example
113
- * ```ts
114
- * const doctype = await registry.getMeta('Task')
115
- * stonecrop.getWorkflow(doctype)
116
- * ```
117
- */
118
- getWorkflow(doctype: DoctypeMeta): void;
119
- /**
120
- * Gets the actions for the given doctype
121
- * @param doctype - The doctype to get actions for
122
- * @example
123
- * ```ts
124
- * const doctype = await registry.getMeta('Task')
125
- * stonecrop.getActions(doctype)
126
- * ```
127
- */
128
- getActions(doctype: DoctypeMeta): void;
78
+ getMeta(doctype: string): Promise<DoctypeMeta> | never;
129
79
  /**
130
80
  * Gets the records for the given doctype
131
81
  * @param doctype - The doctype to get records for
@@ -162,22 +112,22 @@ export declare class Stonecrop {
162
112
  * @example
163
113
  * ```ts
164
114
  * const doctype = await registry.getMeta('Task')
165
- * stonecrop.runAction(doctype, 'CREATE')
115
+ * stonecrop.runAction(doctype, 'create')
166
116
  * ```
167
117
  * @example
168
118
  * ```ts
169
119
  * const doctype = await registry.getMeta('Task')
170
- * stonecrop.runAction(doctype, 'UPDATE', ['TASK-00001'])
120
+ * stonecrop.runAction(doctype, 'update', ['TASK-00001'])
171
121
  * ```
172
122
  * @example
173
123
  * ```ts
174
124
  * const doctype = await registry.getMeta('Task')
175
- * stonecrop.runAction(doctype, 'DELETE', ['TASK-00001'])
125
+ * stonecrop.runAction(doctype, 'delete', ['TASK-00001'])
176
126
  * ```
177
127
  * @example
178
128
  * ```ts
179
129
  * const doctype = await registry.getMeta('Task')
180
- * stonecrop.runAction(doctype, 'TRANSITION', ['TASK-00001', 'TASK-00002'])
130
+ * stonecrop.runAction(doctype, 'merge', ['TASK-00001', 'TASK-00002'])
181
131
  * ```
182
132
  */
183
133
  runAction(doctype: DoctypeMeta, action: string, id?: string[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvD;;;GAGG;AACH,qBAAa,SAAS;IACrB;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,CAAA;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,eAAc;IAE3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;IAEtC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAEvC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAErC;;;;;;;;;;;;;OAaG;gBAEF,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,UA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;;;;OAkBG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;IAEtC;;;;;;;;;;OAUG;gBACS,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC;IAStE;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIjC;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK;IAO5D;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5E;;;;;;;;;OASG;IACG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;CAyBpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,KAAK,uBAAgB,CAAA;AAW3B,OAAO,EAAE,KAAK,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,KAAK,uBAAgB,CAAA;AAU3B,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -2,7 +2,7 @@ import type { SchemaTypes } from '@stonecrop/aform';
2
2
  import { List, Map } from 'immutable';
3
3
  import type { Component } from 'vue';
4
4
  import type { Router } from 'vue-router';
5
- import type { MachineConfig, StateMachine } from 'xstate';
5
+ import type { AnyStateNodeConfig, UnknownMachineConfig } from 'xstate';
6
6
  import DoctypeMeta from '../doctype';
7
7
  /**
8
8
  * Immutable Doctype type for Stonecrop instances
@@ -10,7 +10,7 @@ import DoctypeMeta from '../doctype';
10
10
  */
11
11
  export type ImmutableDoctype = {
12
12
  readonly schema?: List<SchemaTypes>;
13
- readonly workflow: StateMachine<unknown, any, any>;
13
+ readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig;
14
14
  readonly actions?: Map<string, string[]>;
15
15
  };
16
16
  /**
@@ -19,7 +19,7 @@ export type ImmutableDoctype = {
19
19
  */
20
20
  export type MutableDoctype = {
21
21
  schema?: SchemaTypes[];
22
- workflow: MachineConfig<unknown, any, any>;
22
+ workflow?: UnknownMachineConfig | AnyStateNodeConfig;
23
23
  actions?: Record<string, string[]>;
24
24
  };
25
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,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,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEzD,OAAO,WAAW,MAAM,YAAY,CAAA;AAEpC;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAE9B,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,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,GAAG,kBAAkB,CAAA;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACxC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAE5B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAClC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAClE,CAAA"}
@@ -1,13 +1,13 @@
1
+ import type { AnyStateNodeConfig } from 'xstate';
1
2
  import { Component } from 'vue';
2
3
  import { List } from 'immutable';
3
- import type { MachineConfig } from 'xstate';
4
4
  import { Map as Map_2 } from 'immutable';
5
5
  import { Plugin as Plugin_2 } from 'vue';
6
6
  import { Ref } from 'vue';
7
7
  import { Router } from 'vue-router';
8
8
  import type { ShallowRef } from 'vue';
9
- import type { StateMachine } from 'xstate';
10
9
  import { StoreDefinition } from 'pinia';
10
+ import type { UnknownMachineConfig } from 'xstate';
11
11
 
12
12
  /**
13
13
  * Basic field structure for AForm schemas
@@ -177,8 +177,19 @@ export declare class DoctypeMeta {
177
177
  readonly component?: Component;
178
178
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
179
179
  /**
180
- * Converts the registered doctype to a slug (kebab-case)
180
+ * Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
181
+ * - It replaces camelCase and PascalCase with kebab-case strings
182
+ * - It replaces spaces and underscores with hyphens
183
+ * - It converts the string to lowercase
184
+ *
181
185
  * @returns The slugified doctype string
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const doctype = new DoctypeMeta('TaskItem', schema, workflow, actions
190
+ * console.log(doctype.slug) // 'task-item'
191
+ * ```
192
+ *
182
193
  * @public
183
194
  */
184
195
  get slug(): string;
@@ -369,7 +380,7 @@ export declare interface GanttOptions {
369
380
  */
370
381
  export declare type ImmutableDoctype = {
371
382
  readonly schema?: List<SchemaTypes>;
372
- readonly workflow: StateMachine<unknown, any, any>;
383
+ readonly workflow?: UnknownMachineConfig | AnyStateNodeConfig;
373
384
  readonly actions?: Map_2<string, string[]>;
374
385
  };
375
386
 
@@ -389,7 +400,7 @@ export declare type InstallOptions = {
389
400
  */
390
401
  export declare type MutableDoctype = {
391
402
  schema?: SchemaTypes[];
392
- workflow: MachineConfig<unknown, any, any>;
403
+ workflow?: UnknownMachineConfig | AnyStateNodeConfig;
393
404
  actions?: Record<string, string[]>;
394
405
  };
395
406
 
@@ -407,23 +418,23 @@ export declare class Registry {
407
418
  *
408
419
  * @defaultValue 'Registry'
409
420
  */
410
- name: string;
421
+ readonly name: string;
411
422
  /**
412
423
  * The registry property contains a collection of doctypes
413
424
  * @see {@link DoctypeMeta}
414
425
  */
415
- registry: Record<string, DoctypeMeta>;
426
+ readonly registry: Record<string, DoctypeMeta>;
416
427
  /**
417
428
  * The Vue router instance
418
429
  * @see {@link https://router.vuejs.org/}
419
430
  */
420
- router?: Router;
431
+ readonly router?: Router;
432
+ constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
421
433
  /**
422
434
  * The getMeta function fetches doctype metadata from an API
423
435
  * @see {@link DoctypeMeta}
424
436
  */
425
437
  getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>;
426
- constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
427
438
  /**
428
439
  * Get doctype metadata
429
440
  * @param doctype - The doctype to fetch metadata for
@@ -482,11 +493,11 @@ export declare const Stonecrop: Plugin_2;
482
493
  * Stonecrop class
483
494
  * @public
484
495
  */
485
- declare class Stonecrop_2 {
496
+ export declare class StonecropClass {
486
497
  /**
487
498
  * The root Stonecrop instance
488
499
  */
489
- static _root: Stonecrop_2;
500
+ static _root: StonecropClass;
490
501
  /**
491
502
  * The name of the Stonecrop instance
492
503
  * @readonly
@@ -518,39 +529,10 @@ declare class Stonecrop_2 {
518
529
  * The Pinia store that manages the mutable records
519
530
  */
520
531
  store: ReturnType<typeof useDataStore>;
521
- /**
522
- * schema - The Stonecrop schema; the schema is a subset of the registry
523
- * @example
524
- * ```ts
525
- * {
526
- * doctype: 'Task',
527
- * schema: {
528
- * title: 'string',
529
- * description: 'string',
530
- * ...
531
- * }
532
- * }
533
- * ```
534
- * @see {@link Registry}
535
- * @see {@link DoctypeMeta}
536
- * @see {@link DoctypeMeta.schema}
537
- */
538
- schema?: Schema;
539
- /**
540
- * The workflow is a subset of the registry
541
- */
542
- workflow?: ImmutableDoctype['workflow'];
543
- /**
544
- * The actions are a subset of the registry
545
- */
546
- actions?: ImmutableDoctype['actions'];
547
532
  /**
548
533
  * @param registry - The immutable registry
549
534
  * @param store - The mutable Pinia store
550
- * @param schema - The Stonecrop schema
551
- * @param workflow - The Stonecrop workflow
552
- * @param actions - The Stonecrop actions
553
- * @returns The Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
535
+ * @returns The Stonecrop instance with the given registry and store. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
554
536
  * @example
555
537
  * ```ts
556
538
  * const registry = new Registry()
@@ -558,7 +540,7 @@ declare class Stonecrop_2 {
558
540
  * const stonecrop = new Stonecrop(registry, store)
559
541
  * ```
560
542
  */
561
- constructor(registry: Registry, store: ReturnType<typeof useDataStore>, schema?: Schema, workflow?: ImmutableDoctype['workflow'], actions?: ImmutableDoctype['actions']);
543
+ constructor(registry: Registry, store: ReturnType<typeof useDataStore>);
562
544
  /**
563
545
  * Sets up the Stonecrop instance with the given doctype
564
546
  * @param doctype - The doctype to setup
@@ -573,7 +555,7 @@ declare class Stonecrop_2 {
573
555
  * Gets the meta for the given doctype
574
556
  * @param doctype - The doctype to get meta for
575
557
  * @returns The meta for the given doctype
576
- * @throws NotImplementedError
558
+ * @throws `NotImplementedError` if the `getMeta` function is not implemented for the doctype in the registry
577
559
  * @example
578
560
  * ```ts
579
561
  * const doctype = await registry.getMeta('Task')
@@ -581,27 +563,7 @@ declare class Stonecrop_2 {
581
563
  * ```
582
564
  * @see {@link DoctypeMeta}
583
565
  */
584
- getMeta(doctype: DoctypeMeta): DoctypeMeta | Promise<DoctypeMeta> | never;
585
- /**
586
- * Gets the workflow for the given doctype
587
- * @param doctype - The doctype to get workflow for
588
- * @example
589
- * ```ts
590
- * const doctype = await registry.getMeta('Task')
591
- * stonecrop.getWorkflow(doctype)
592
- * ```
593
- */
594
- getWorkflow(doctype: DoctypeMeta): void;
595
- /**
596
- * Gets the actions for the given doctype
597
- * @param doctype - The doctype to get actions for
598
- * @example
599
- * ```ts
600
- * const doctype = await registry.getMeta('Task')
601
- * stonecrop.getActions(doctype)
602
- * ```
603
- */
604
- getActions(doctype: DoctypeMeta): void;
566
+ getMeta(doctype: string): Promise<DoctypeMeta> | never;
605
567
  /**
606
568
  * Gets the records for the given doctype
607
569
  * @param doctype - The doctype to get records for
@@ -638,22 +600,22 @@ declare class Stonecrop_2 {
638
600
  * @example
639
601
  * ```ts
640
602
  * const doctype = await registry.getMeta('Task')
641
- * stonecrop.runAction(doctype, 'CREATE')
603
+ * stonecrop.runAction(doctype, 'create')
642
604
  * ```
643
605
  * @example
644
606
  * ```ts
645
607
  * const doctype = await registry.getMeta('Task')
646
- * stonecrop.runAction(doctype, 'UPDATE', ['TASK-00001'])
608
+ * stonecrop.runAction(doctype, 'update', ['TASK-00001'])
647
609
  * ```
648
610
  * @example
649
611
  * ```ts
650
612
  * const doctype = await registry.getMeta('Task')
651
- * stonecrop.runAction(doctype, 'DELETE', ['TASK-00001'])
613
+ * stonecrop.runAction(doctype, 'delete', ['TASK-00001'])
652
614
  * ```
653
615
  * @example
654
616
  * ```ts
655
617
  * const doctype = await registry.getMeta('Task')
656
- * stonecrop.runAction(doctype, 'TRANSITION', ['TASK-00001', 'TASK-00002'])
618
+ * stonecrop.runAction(doctype, 'merge', ['TASK-00001', 'TASK-00002'])
657
619
  * ```
658
620
  */
659
621
  runAction(doctype: DoctypeMeta, action: string, id?: string[]): void;
@@ -664,7 +626,7 @@ declare class Stonecrop_2 {
664
626
  * @public
665
627
  */
666
628
  export declare type StonecropReturn = {
667
- stonecrop: Ref<Stonecrop_2 | undefined>;
629
+ stonecrop: Ref<StonecropClass | undefined>;
668
630
  };
669
631
 
670
632
  /**