@stonecrop/stonecrop 0.3.4 → 0.3.6

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.
@@ -1,11 +1,24 @@
1
1
  import { inject, onBeforeMount, ref } from 'vue';
2
2
  import { Stonecrop } from './stonecrop';
3
3
  import { useDataStore } from './stores/data';
4
+ /**
5
+ * Stonecrop composable
6
+ * @param registry - An existing Stonecrop Registry instance
7
+ * @returns The Stonecrop instance and a boolean indicating if Stonecrop is setup and ready
8
+ * @throws Error if the Stonecrop plugin is not enabled before using the composable
9
+ * @public
10
+ */
4
11
  export function useStonecrop(registry) {
5
12
  if (!registry) {
6
13
  registry = inject('$registry');
7
14
  }
8
- const store = useDataStore();
15
+ let store;
16
+ try {
17
+ store = useDataStore();
18
+ }
19
+ catch (e) {
20
+ throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable');
21
+ }
9
22
  const stonecrop = ref(new Stonecrop(registry, store));
10
23
  const isReady = ref(false);
11
24
  onBeforeMount(async () => {
package/dist/doctype.js CHANGED
@@ -1,11 +1,40 @@
1
+ /**
2
+ * Doctype Meta class
3
+ * @public
4
+ */
1
5
  export default class DoctypeMeta {
6
+ /**
7
+ * The doctype name
8
+ * @public
9
+ * @readonly
10
+ */
2
11
  doctype;
12
+ /**
13
+ * The doctype schema
14
+ * @public
15
+ * @readonly
16
+ */
3
17
  schema;
18
+ /**
19
+ * The doctype workflow
20
+ * @public
21
+ * @readonly
22
+ */
4
23
  workflow;
24
+ /**
25
+ * The doctype actions
26
+ * @public
27
+ * @readonly
28
+ */
5
29
  actions;
30
+ /**
31
+ * The doctype component
32
+ * @public
33
+ * @readonly
34
+ */
35
+ component;
6
36
  // TODO: allow different components for different views; probably
7
37
  // should be defined in the schema instead?
8
- component;
9
38
  constructor(doctype, schema, workflow, actions, component) {
10
39
  this.doctype = doctype;
11
40
  this.schema = schema;
@@ -13,14 +42,15 @@ export default class DoctypeMeta {
13
42
  this.actions = actions;
14
43
  this.component = component;
15
44
  }
45
+ /**
46
+ * Converts the registered doctype to a slug (kebab-case)
47
+ * @returns The slugified doctype string
48
+ * @public
49
+ */
16
50
  get slug() {
17
- // kebab case
18
51
  return this.doctype
19
52
  .replace(/([a-z])([A-Z])/g, '$1-$2')
20
53
  .replace(/[\s_]+/g, '-')
21
54
  .toLowerCase();
22
55
  }
23
- get __typename() {
24
- return this.doctype;
25
- }
26
56
  }
@@ -1,6 +1,34 @@
1
1
  import Registry from '../registry';
2
2
  import router from '../router';
3
3
  import { pinia } from '../stores';
4
+ /**
5
+ * Stonecrop Vue plugin
6
+ * @param app - The Vue app instance
7
+ * @param options - The plugin options
8
+ * @example
9
+ * ```ts
10
+ *
11
+ * import { createApp } from 'vue'
12
+ * import Stonecrop from 'stonecrop'
13
+ *
14
+ * import App from './App.vue'
15
+ *
16
+ * const app = createApp(App)
17
+ * app.use(Stonecrop, {
18
+ * router,
19
+ * components: {
20
+ * // register custom components
21
+ * },
22
+ * getMeta: async (doctype: string) => {
23
+ * // fetch doctype meta from API
24
+ * },
25
+ * })
26
+ *
27
+ * app.mount('#app')
28
+ * ```
29
+ *
30
+ * @public
31
+ */
4
32
  const plugin = {
5
33
  install: (app, options) => {
6
34
  const appRouter = options?.router || router;
package/dist/registry.js CHANGED
@@ -1,8 +1,32 @@
1
+ /**
2
+ * Stonecrop Registry class
3
+ * @public
4
+ */
1
5
  export default class Registry {
6
+ /**
7
+ * The root Registry instance
8
+ */
2
9
  static _root;
10
+ /**
11
+ * The name of the Registry instance
12
+ *
13
+ * @defaultValue 'Registry'
14
+ */
3
15
  name;
16
+ /**
17
+ * The Vue router instance
18
+ * @see {@link https://router.vuejs.org/}
19
+ */
4
20
  router;
21
+ /**
22
+ * The registry property contains a collection of doctypes
23
+ * @see {@link DoctypeMeta}
24
+ */
5
25
  registry;
26
+ /**
27
+ * The getMeta function fetches doctype metadata from an API
28
+ * @see {@link DoctypeMeta}
29
+ */
6
30
  getMeta;
7
31
  constructor(router, getMeta) {
8
32
  if (Registry._root) {
@@ -14,6 +38,12 @@ export default class Registry {
14
38
  this.registry = {};
15
39
  this.getMeta = getMeta;
16
40
  }
41
+ /**
42
+ * Get doctype metadata
43
+ * @param doctype - The doctype to fetch metadata for
44
+ * @returns The doctype metadata
45
+ * @see {@link DoctypeMeta}
46
+ */
17
47
  addDoctype(doctype) {
18
48
  if (!(doctype.doctype in Object.keys(this.registry))) {
19
49
  this.registry[doctype.slug] = doctype;
@@ -1,10 +1,20 @@
1
1
  import { Ref } from 'vue';
2
2
  import Registry from './registry';
3
3
  import { Stonecrop } from './stonecrop';
4
- type StonecropReturn = {
4
+ /**
5
+ * Stonecrop composable return type
6
+ * @public
7
+ */
8
+ export type StonecropReturn = {
5
9
  stonecrop: Ref<Stonecrop>;
6
10
  isReady: Ref<boolean>;
7
11
  };
12
+ /**
13
+ * Stonecrop composable
14
+ * @param registry - An existing Stonecrop Registry instance
15
+ * @returns The Stonecrop instance and a boolean indicating if Stonecrop is setup and ready
16
+ * @throws Error if the Stonecrop plugin is not enabled before using the composable
17
+ * @public
18
+ */
8
19
  export declare function useStonecrop(registry?: Registry): StonecropReturn;
9
- export {};
10
20
  //# sourceMappingURL=composable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,GAAG,EAAO,MAAM,KAAK,CAAA;AAErD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,KAAK,eAAe,GAAG;IACtB,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACzB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CAsCjE"}
1
+ {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,GAAG,EAAO,MAAM,KAAK,CAAA;AAErD,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,CAAC,CAAA;IACzB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CA4CjE"}
@@ -1,13 +1,46 @@
1
1
  import { Component } from 'vue';
2
2
  import type { ImmutableDoctype } from './types';
3
+ /**
4
+ * Doctype Meta class
5
+ * @public
6
+ */
3
7
  export default class DoctypeMeta {
8
+ /**
9
+ * The doctype name
10
+ * @public
11
+ * @readonly
12
+ */
4
13
  readonly doctype: string;
14
+ /**
15
+ * The doctype schema
16
+ * @public
17
+ * @readonly
18
+ */
5
19
  readonly schema: ImmutableDoctype['schema'];
20
+ /**
21
+ * The doctype workflow
22
+ * @public
23
+ * @readonly
24
+ */
6
25
  readonly workflow: ImmutableDoctype['workflow'];
26
+ /**
27
+ * The doctype actions
28
+ * @public
29
+ * @readonly
30
+ */
7
31
  readonly actions: ImmutableDoctype['actions'];
32
+ /**
33
+ * The doctype component
34
+ * @public
35
+ * @readonly
36
+ */
8
37
  readonly component?: Component;
9
38
  constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
39
+ /**
40
+ * Converts the registered doctype to a slug (kebab-case)
41
+ * @returns The slugified doctype string
42
+ * @public
43
+ */
10
44
  get slug(): string;
11
- get __typename(): string;
12
45
  }
13
46
  //# sourceMappingURL=doctype.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],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H,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;gBAK7B,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;;;;OAIG;IACH,IAAI,IAAI,WAKP;CACD"}
@@ -1,7 +1,9 @@
1
- import { useStonecrop } from './composable';
1
+ export type { BaseSchema, FieldsetSchema, FormSchema, SchemaTypes, TableSchema } from '@stonecrop/aform';
2
+ export type { CellContext, TableColumn, TableConfig, TableRow } from '@stonecrop/atable';
3
+ import { type StonecropReturn, useStonecrop } from './composable';
2
4
  import DoctypeMeta from './doctype';
3
5
  import Registry from './registry';
4
6
  import Stonecrop from './plugins';
5
7
  export type { ImmutableDoctype, MutableDoctype, Schema, InstallOptions } from './types';
6
- export { DoctypeMeta, Registry, Stonecrop, useStonecrop };
8
+ export { DoctypeMeta, Registry, Stonecrop, StonecropReturn, useStonecrop };
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,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,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,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAExF,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,4 +1,32 @@
1
1
  import { type Plugin } from 'vue';
2
+ /**
3
+ * Stonecrop Vue plugin
4
+ * @param app - The Vue app instance
5
+ * @param options - The plugin options
6
+ * @example
7
+ * ```ts
8
+ *
9
+ * import { createApp } from 'vue'
10
+ * import Stonecrop from 'stonecrop'
11
+ *
12
+ * import App from './App.vue'
13
+ *
14
+ * const app = createApp(App)
15
+ * app.use(Stonecrop, {
16
+ * router,
17
+ * components: {
18
+ * // register custom components
19
+ * },
20
+ * getMeta: async (doctype: string) => {
21
+ * // fetch doctype meta from API
22
+ * },
23
+ * })
24
+ *
25
+ * app.mount('#app')
26
+ * ```
27
+ *
28
+ * @public
29
+ */
2
30
  declare const plugin: Plugin;
3
31
  export default plugin;
4
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,KAAK,CAAA;AAOtC,QAAA,MAAM,MAAM,EAAE,MAeb,CAAA;AAED,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,KAAK,CAAA;AAOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,MAAM,EAAE,MAeb,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,12 +1,42 @@
1
1
  import { Router } from 'vue-router';
2
2
  import DoctypeMeta from './doctype';
3
+ /**
4
+ * Stonecrop Registry class
5
+ * @public
6
+ */
3
7
  export default class Registry {
8
+ /**
9
+ * The root Registry instance
10
+ */
4
11
  static _root: Registry;
12
+ /**
13
+ * The name of the Registry instance
14
+ *
15
+ * @defaultValue 'Registry'
16
+ */
5
17
  name: string;
18
+ /**
19
+ * The Vue router instance
20
+ * @see {@link https://router.vuejs.org/}
21
+ */
6
22
  router: Router;
23
+ /**
24
+ * The registry property contains a collection of doctypes
25
+ * @see {@link DoctypeMeta}
26
+ */
7
27
  registry: Record<string, DoctypeMeta>;
28
+ /**
29
+ * The getMeta function fetches doctype metadata from an API
30
+ * @see {@link DoctypeMeta}
31
+ */
8
32
  getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>;
9
33
  constructor(router: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
34
+ /**
35
+ * Get doctype metadata
36
+ * @param doctype - The doctype to fetch metadata for
37
+ * @returns The doctype metadata
38
+ * @see {@link DoctypeMeta}
39
+ */
10
40
  addDoctype(doctype: DoctypeMeta): void;
11
41
  }
12
42
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACrC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;gBAErD,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAW7F,UAAU,CAAC,OAAO,EAAE,WAAW;CAY/B"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAA;IAEtB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAErC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;gBAErD,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAW7F;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW;CAY/B"}
@@ -2,23 +2,26 @@ import DoctypeMeta from './doctype';
2
2
  import Registry from './registry';
3
3
  import { useDataStore } from './stores/data';
4
4
  import type { ImmutableDoctype, Schema } from './types';
5
+ /**
6
+ * Stonecrop class
7
+ * @public
8
+ */
5
9
  export declare class Stonecrop {
6
10
  /**
7
- * @property {Stonecrop} _root
8
- * @description The root Stonecrop instance
11
+ * The root Stonecrop instance
9
12
  */
10
13
  static _root: Stonecrop;
11
14
  /**
12
- * @property {string} name
13
- * @description The name of the Stonecrop instance
14
- * @example
15
- * 'Stonecrop'
15
+ * The name of the Stonecrop instance
16
+ * @readonly
17
+ *
18
+ * @defaultValue 'Stonecrop'
16
19
  */
17
20
  readonly name = "Stonecrop";
18
21
  /**
19
- * @property {Registry} registry
20
- * @description The registry is an immutable collection of doctypes
22
+ * The registry is an immutable collection of doctypes
21
23
  * @example
24
+ * ```ts
22
25
  * {
23
26
  * 'task': {
24
27
  * doctype: 'Task',
@@ -30,14 +33,15 @@ export declare class Stonecrop {
30
33
  * },
31
34
  * ...
32
35
  * }
36
+ * ```
33
37
  * @see {@link Registry}
34
38
  * @see {@link DoctypeMeta}
35
39
  */
36
40
  readonly registry: Registry;
37
41
  /**
38
- * @property {Schema} schema - The Stonecrop schema
39
- * @description The schema is a subset of the registry
42
+ * schema - The Stonecrop schema; the schema is a subset of the registry
40
43
  * @example
44
+ * ```ts
41
45
  * {
42
46
  * doctype: 'Task',
43
47
  * schema: {
@@ -46,128 +50,135 @@ export declare class Stonecrop {
46
50
  * ...
47
51
  * }
48
52
  * }
53
+ * ```
49
54
  * @see {@link Registry}
50
55
  * @see {@link DoctypeMeta}
51
56
  * @see {@link DoctypeMeta.schema}
52
57
  */
53
58
  schema: Schema;
54
59
  /**
55
- * @property {ImmutableDoctype['workflow']} workflow
56
- * @description The workflow is a subset of the registry
60
+ * The workflow is a subset of the registry
57
61
  */
58
62
  workflow: ImmutableDoctype['workflow'];
59
63
  /**
60
- * @property {ImmutableDoctype['actions']} actions
61
- * @description The actions are a subset of the registry
64
+ * The actions are a subset of the registry
62
65
  */
63
66
  actions: ImmutableDoctype['actions'];
64
67
  /**
65
- * @property {ReturnType<typeof useDataStore>} store
66
- * @description The Pinia store that manages the mutable records
68
+ * The Pinia store that manages the mutable records
67
69
  */
68
70
  store: ReturnType<typeof useDataStore>;
69
71
  /**
70
- * @constructor
71
- * @param {Registry} registry - The immutable registry
72
- * @param {ReturnType<typeof useDataStore>} store - The mutable Pinia store
73
- * @param {Schema} [schema] - (optional) The Stonecrop schema
74
- * @param {ImmutableDoctype['workflow']} [workflow] - (optional) The Stonecrop workflow
75
- * @param {ImmutableDoctype['actions']} [actions] - (optional) The Stonecrop actions
76
- * @returns {Stonecrop} The Stonecrop instance
77
- * @description The Stonecrop constructor initializes a new 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.
72
+ * @param registry - The immutable registry
73
+ * @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.
78
78
  * @example
79
+ * ```ts
79
80
  * const registry = new Registry()
80
81
  * const store = useDataStore()
81
- * const stonecrop = new Stonecrop(registry, store, schema, workflow, actions)
82
+ * const stonecrop = new Stonecrop(registry, store)
83
+ * ```
82
84
  */
83
85
  constructor(registry: Registry, store: ReturnType<typeof useDataStore>, schema?: Schema, workflow?: ImmutableDoctype['workflow'], actions?: ImmutableDoctype['actions']);
84
86
  /**
85
- * @method setup
86
- * @param {DoctypeMeta} doctype - The doctype to setup
87
- * @returns {void}
88
- * @description Sets up the Stonecrop instance with the given doctype
87
+ * Sets up the Stonecrop instance with the given doctype
88
+ * @param doctype - The doctype to setup
89
89
  * @example
90
+ * ```ts
90
91
  * const doctype = await registry.getMeta('Task')
91
92
  * stonecrop.setup(doctype)
93
+ * ```
92
94
  */
93
95
  setup(doctype: DoctypeMeta): void;
94
96
  /**
95
- * @method getMeta
96
- * @param {DoctypeMeta} doctype - The doctype to get meta for
97
- * @returns {DoctypeMeta}
98
- * @see {@link DoctypeMeta}
97
+ * Gets the meta for the given doctype
98
+ * @param doctype - The doctype to get meta for
99
+ * @returns The meta for the given doctype
99
100
  * @throws NotImplementedError
100
- * @description Gets the meta for the given doctype
101
101
  * @example
102
+ * ```ts
102
103
  * const doctype = await registry.getMeta('Task')
103
104
  * const meta = stonecrop.getMeta(doctype)
105
+ * ```
106
+ * @see {@link DoctypeMeta}
104
107
  */
105
108
  getMeta(doctype: DoctypeMeta): DoctypeMeta | Promise<DoctypeMeta> | never;
106
109
  /**
107
- * @method getWorkflow
108
- * @param {DoctypeMeta} doctype - The doctype to get workflow for
109
- * @returns {void}
110
- * @description Gets the workflow for the given doctype
110
+ * Gets the workflow for the given doctype
111
+ * @param doctype - The doctype to get workflow for
111
112
  * @example
113
+ * ```ts
112
114
  * const doctype = await registry.getMeta('Task')
113
115
  * stonecrop.getWorkflow(doctype)
116
+ * ```
114
117
  */
115
118
  getWorkflow(doctype: DoctypeMeta): void;
116
119
  /**
117
- * @method getActions
118
- * @param {DoctypeMeta} doctype - The doctype to get actions for
119
- * @returns {void}
120
- * @description Gets the actions for the given doctype
120
+ * Gets the actions for the given doctype
121
+ * @param doctype - The doctype to get actions for
121
122
  * @example
123
+ * ```ts
122
124
  * const doctype = await registry.getMeta('Task')
123
125
  * stonecrop.getActions(doctype)
126
+ * ```
124
127
  */
125
128
  getActions(doctype: DoctypeMeta): void;
126
129
  /**
127
- * @method getRecords
128
- * @param {DoctypeMeta} doctype - The doctype to get records for
129
- * @param {RequestInit} [filters] - The filters to apply to the records
130
- * @returns {Promise<void>}
131
- * @description Gets the records for the given doctype
130
+ * Gets the records for the given doctype
131
+ * @param doctype - The doctype to get records for
132
+ * @param filters - The filters to apply to the records
132
133
  * @example
134
+ * ```ts
133
135
  * const doctype = await registry.getMeta('Task')
134
136
  * await stonecrop.getRecords(doctype)
137
+ * ```
135
138
  * @example
139
+ * ```ts
136
140
  * const doctype = await registry.getMeta('Task')
137
141
  * const filters = JSON.stringify({ status: 'Open' })
138
142
  * await stonecrop.getRecords(doctype, { body: filters })
143
+ * ```
139
144
  */
140
145
  getRecords(doctype: DoctypeMeta, filters?: RequestInit): Promise<void>;
141
146
  /**
142
- * @method getRecord
143
- * @param {DoctypeMeta} doctype - The doctype to get record for
144
- * @param {string} id - The id of the record to get
145
- * @returns {Promise<void>}
146
- * @description Gets the record for the given doctype and id
147
+ * Gets the record for the given doctype and id
148
+ * @param doctype - The doctype to get record for
149
+ * @param id - The id of the record to get
147
150
  * @example
151
+ * ```ts
148
152
  * const doctype = await registry.getMeta('Task')
149
153
  * await stonecrop.getRecord(doctype, 'TASK-00001')
154
+ * ```
150
155
  */
151
156
  getRecord(doctype: DoctypeMeta, id: string): Promise<void>;
152
157
  /**
153
- * @method runAction
154
- * @param {DoctypeMeta} doctype - The doctype to run action for
155
- * @param {string} action - The action to run
156
- * @param {string[]} [id] - The id(s) of the record(s) to run action on
157
- * @returns {void}
158
- * @description Runs the action for the given doctype and id
158
+ * Runs the action for the given doctype and id
159
+ * @param doctype - The doctype to run action for
160
+ * @param action - The action to run
161
+ * @param id - The id(s) of the record(s) to run action on
159
162
  * @example
163
+ * ```ts
160
164
  * const doctype = await registry.getMeta('Task')
161
165
  * stonecrop.runAction(doctype, 'CREATE')
166
+ * ```
162
167
  * @example
168
+ * ```ts
163
169
  * const doctype = await registry.getMeta('Task')
164
170
  * stonecrop.runAction(doctype, 'UPDATE', ['TASK-00001'])
171
+ * ```
165
172
  * @example
173
+ * ```ts
166
174
  * const doctype = await registry.getMeta('Task')
167
175
  * stonecrop.runAction(doctype, 'DELETE', ['TASK-00001'])
176
+ * ```
168
177
  * @example
178
+ * ```ts
169
179
  * const doctype = await registry.getMeta('Task')
170
180
  * stonecrop.runAction(doctype, 'TRANSITION', ['TASK-00001', 'TASK-00002'])
181
+ * ```
171
182
  */
172
183
  runAction(doctype: DoctypeMeta, action: string, id?: string[]): void;
173
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts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AAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,EACvC,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAatC;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAMjC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK;IAIzE;;;;;;;;OAQG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAKvC;;;;;;;;OAQG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAKtC;;;;;;;;;;;;;;;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;CAiBpE"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.48.0"
9
+ }
10
+ ]
11
+ }
@@ -4,20 +4,36 @@ import { Component } from 'vue';
4
4
  import { Router } from 'vue-router';
5
5
  import { MachineConfig, StateMachine } from 'xstate';
6
6
  import DoctypeMeta from '../doctype';
7
+ /**
8
+ * Immutable Doctype type for Stonecrop instances
9
+ * @public
10
+ */
7
11
  export type ImmutableDoctype = {
8
12
  readonly schema?: List<SchemaTypes>;
9
13
  readonly workflow: StateMachine<unknown, unknown, any>;
10
14
  readonly actions?: Map<string, string[]>;
11
15
  };
16
+ /**
17
+ * Mutable Doctype type for Stonecrop instances
18
+ * @public
19
+ */
12
20
  export type MutableDoctype = {
13
21
  schema?: SchemaTypes[];
14
22
  workflow: MachineConfig<unknown, unknown, any>;
15
23
  actions?: Record<string, string[]>;
16
24
  };
25
+ /**
26
+ * Schema type for Stonecrop instances
27
+ * @public
28
+ */
17
29
  export type Schema = {
18
30
  doctype: string;
19
31
  schema: List<SchemaTypes>;
20
32
  };
33
+ /**
34
+ * Install options for Stonecrop Vue plugin
35
+ * @public
36
+ */
21
37
  export type InstallOptions = {
22
38
  router?: Router;
23
39
  components?: Record<string, Component>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEpD,OAAO,WAAW,MAAM,YAAY,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAE9B,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAE5B,MAAM,CAAC,EAAE,WA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