@stonecrop/stonecrop 0.3.7 → 0.3.9
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/dist/composable.js +15 -10
- package/dist/registry.js +1 -1
- package/dist/src/composable.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +7 -7
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/xstate.d.ts +22 -1
- package/dist/src/stores/xstate.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -6
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +11 -11
- package/dist/stonecrop.js +129 -124
- package/dist/stonecrop.js.map +1 -1
- package/dist/stonecrop.umd.cjs +2 -2
- package/dist/stonecrop.umd.cjs.map +1 -1
- package/dist/stores/xstate.js +1 -1
- package/package.json +4 -4
- package/src/composable.ts +15 -9
- package/src/registry.ts +1 -1
- package/src/stonecrop.ts +22 -19
- package/src/stores/xstate.ts +1 -1
- package/src/types/index.ts +6 -6
package/dist/composable.js
CHANGED
|
@@ -19,9 +19,12 @@ export function useStonecrop(registry) {
|
|
|
19
19
|
catch (e) {
|
|
20
20
|
throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable');
|
|
21
21
|
}
|
|
22
|
+
// @ts-expect-error TODO: handle empty registry passed to Stonecrop
|
|
22
23
|
const stonecrop = ref(new Stonecrop(registry, store));
|
|
23
24
|
const isReady = ref(false);
|
|
24
25
|
onBeforeMount(async () => {
|
|
26
|
+
if (!registry)
|
|
27
|
+
return;
|
|
25
28
|
const route = registry.router.currentRoute.value;
|
|
26
29
|
const doctypeSlug = route.params.records?.toString().toLowerCase();
|
|
27
30
|
const recordId = route.params.record?.toString().toLowerCase();
|
|
@@ -30,18 +33,20 @@ export function useStonecrop(registry) {
|
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
35
|
// setup doctype via registry
|
|
33
|
-
const doctype = await registry.getMeta(doctypeSlug);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const doctype = await registry.getMeta?.(doctypeSlug);
|
|
37
|
+
if (doctype) {
|
|
38
|
+
registry.addDoctype(doctype);
|
|
39
|
+
stonecrop.value.setup(doctype);
|
|
40
|
+
if (doctypeSlug) {
|
|
41
|
+
if (recordId) {
|
|
42
|
+
await stonecrop.value.getRecord(doctype, recordId);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
await stonecrop.value.getRecords(doctype);
|
|
46
|
+
}
|
|
42
47
|
}
|
|
48
|
+
stonecrop.value.runAction(doctype, 'LOAD', recordId ? [recordId] : undefined);
|
|
43
49
|
}
|
|
44
|
-
stonecrop.value.runAction(doctype, 'LOAD', recordId ? [recordId] : undefined);
|
|
45
50
|
isReady.value = true;
|
|
46
51
|
});
|
|
47
52
|
// @ts-expect-error TODO: fix the type mismatch
|
package/dist/registry.js
CHANGED
|
@@ -48,7 +48,7 @@ export default class Registry {
|
|
|
48
48
|
if (!(doctype.doctype in Object.keys(this.registry))) {
|
|
49
49
|
this.registry[doctype.slug] = doctype;
|
|
50
50
|
}
|
|
51
|
-
if (!this.router.hasRoute(doctype.doctype)) {
|
|
51
|
+
if (!this.router.hasRoute(doctype.doctype) && doctype.component) {
|
|
52
52
|
this.router.addRoute({
|
|
53
53
|
path: `/${doctype.slug}`,
|
|
54
54
|
name: doctype.slug,
|
|
@@ -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;;;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,
|
|
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,CAkDjE"}
|
package/dist/src/stonecrop.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export declare class Stonecrop {
|
|
|
38
38
|
* @see {@link DoctypeMeta}
|
|
39
39
|
*/
|
|
40
40
|
readonly registry: Registry;
|
|
41
|
+
/**
|
|
42
|
+
* The Pinia store that manages the mutable records
|
|
43
|
+
*/
|
|
44
|
+
store: ReturnType<typeof useDataStore>;
|
|
41
45
|
/**
|
|
42
46
|
* schema - The Stonecrop schema; the schema is a subset of the registry
|
|
43
47
|
* @example
|
|
@@ -55,19 +59,15 @@ export declare class Stonecrop {
|
|
|
55
59
|
* @see {@link DoctypeMeta}
|
|
56
60
|
* @see {@link DoctypeMeta.schema}
|
|
57
61
|
*/
|
|
58
|
-
schema
|
|
62
|
+
schema?: Schema;
|
|
59
63
|
/**
|
|
60
64
|
* The workflow is a subset of the registry
|
|
61
65
|
*/
|
|
62
|
-
workflow
|
|
66
|
+
workflow?: ImmutableDoctype['workflow'];
|
|
63
67
|
/**
|
|
64
68
|
* The actions are a subset of the registry
|
|
65
69
|
*/
|
|
66
|
-
actions
|
|
67
|
-
/**
|
|
68
|
-
* The Pinia store that manages the mutable records
|
|
69
|
-
*/
|
|
70
|
-
store: ReturnType<typeof useDataStore>;
|
|
70
|
+
actions?: ImmutableDoctype['actions'];
|
|
71
71
|
/**
|
|
72
72
|
* @param registry - The immutable registry
|
|
73
73
|
* @param store - The mutable Pinia store
|
|
@@ -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
|
|
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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I;CAoBpE"}
|
|
@@ -6,5 +6,26 @@ export declare const counterMachine: import("xstate").StateMachine<{
|
|
|
6
6
|
count: number;
|
|
7
7
|
};
|
|
8
8
|
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("xstate").AnyEventObject, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
|
|
9
|
-
export declare const useCounterStore: import("pinia").StoreDefinition<string, {
|
|
9
|
+
export declare const useCounterStore: import("pinia").StoreDefinition<string, Pick<import("pinia-xstate").Store<import("xstate").StateMachine<{
|
|
10
|
+
count: number;
|
|
11
|
+
}, any, import("xstate").AnyEventObject, {
|
|
12
|
+
value: any;
|
|
13
|
+
context: {
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("xstate").AnyEventObject, import("xstate").BaseActionObject, import("xstate").ServiceMap>>>, "state" | "actor">, Pick<import("pinia-xstate").Store<import("xstate").StateMachine<{
|
|
17
|
+
count: number;
|
|
18
|
+
}, any, import("xstate").AnyEventObject, {
|
|
19
|
+
value: any;
|
|
20
|
+
context: {
|
|
21
|
+
count: number;
|
|
22
|
+
};
|
|
23
|
+
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("xstate").AnyEventObject, import("xstate").BaseActionObject, import("xstate").ServiceMap>>>, "state">, Pick<import("pinia-xstate").Store<import("xstate").StateMachine<{
|
|
24
|
+
count: number;
|
|
25
|
+
}, any, import("xstate").AnyEventObject, {
|
|
26
|
+
value: any;
|
|
27
|
+
context: {
|
|
28
|
+
count: number;
|
|
29
|
+
};
|
|
30
|
+
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("xstate").AnyEventObject, import("xstate").BaseActionObject, import("xstate").ServiceMap>>>, "state" | "send">>;
|
|
10
31
|
//# sourceMappingURL=xstate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xstate.d.ts","sourceRoot":"","sources":["../../../src/stores/xstate.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;0OA0B1B,CAAA;AAGD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"xstate.d.ts","sourceRoot":"","sources":["../../../src/stores/xstate.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;0OA0B1B,CAAA;AAGD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;+PAAyD,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SchemaTypes } from '@stonecrop/aform';
|
|
1
|
+
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
2
|
import { List, Map } from 'immutable';
|
|
3
|
-
import { Component } from 'vue';
|
|
4
|
-
import { Router } from 'vue-router';
|
|
5
|
-
import { MachineConfig, StateMachine } from 'xstate';
|
|
3
|
+
import type { Component } from 'vue';
|
|
4
|
+
import type { Router } from 'vue-router';
|
|
5
|
+
import type { MachineConfig, StateMachine } 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,
|
|
13
|
+
readonly workflow: StateMachine<unknown, any, any>;
|
|
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,
|
|
22
|
+
workflow: MachineConfig<unknown, any, any>;
|
|
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,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
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,EAAE,CAAC,CAAA;CACxC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAE5B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC1C,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"}
|
package/dist/stonecrop.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { List } from 'immutable';
|
|
3
|
-
import { MachineConfig } from 'xstate';
|
|
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
|
-
import { StateMachine } from 'xstate';
|
|
8
|
+
import type { StateMachine } from 'xstate';
|
|
9
9
|
import { StoreDefinition } from 'pinia';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -172,7 +172,7 @@ export declare type FormSchema = BaseSchema & {
|
|
|
172
172
|
*/
|
|
173
173
|
export declare type ImmutableDoctype = {
|
|
174
174
|
readonly schema?: List<SchemaTypes>;
|
|
175
|
-
readonly workflow: StateMachine<unknown,
|
|
175
|
+
readonly workflow: StateMachine<unknown, any, any>;
|
|
176
176
|
readonly actions?: Map_2<string, string[]>;
|
|
177
177
|
};
|
|
178
178
|
|
|
@@ -192,7 +192,7 @@ export declare type InstallOptions = {
|
|
|
192
192
|
*/
|
|
193
193
|
export declare type MutableDoctype = {
|
|
194
194
|
schema?: SchemaTypes[];
|
|
195
|
-
workflow: MachineConfig<unknown,
|
|
195
|
+
workflow: MachineConfig<unknown, any, any>;
|
|
196
196
|
actions?: Record<string, string[]>;
|
|
197
197
|
};
|
|
198
198
|
|
|
@@ -317,6 +317,10 @@ declare class Stonecrop_2 {
|
|
|
317
317
|
* @see {@link DoctypeMeta}
|
|
318
318
|
*/
|
|
319
319
|
readonly registry: Registry;
|
|
320
|
+
/**
|
|
321
|
+
* The Pinia store that manages the mutable records
|
|
322
|
+
*/
|
|
323
|
+
store: ReturnType<typeof useDataStore>;
|
|
320
324
|
/**
|
|
321
325
|
* schema - The Stonecrop schema; the schema is a subset of the registry
|
|
322
326
|
* @example
|
|
@@ -334,19 +338,15 @@ declare class Stonecrop_2 {
|
|
|
334
338
|
* @see {@link DoctypeMeta}
|
|
335
339
|
* @see {@link DoctypeMeta.schema}
|
|
336
340
|
*/
|
|
337
|
-
schema
|
|
341
|
+
schema?: Schema;
|
|
338
342
|
/**
|
|
339
343
|
* The workflow is a subset of the registry
|
|
340
344
|
*/
|
|
341
|
-
workflow
|
|
345
|
+
workflow?: ImmutableDoctype['workflow'];
|
|
342
346
|
/**
|
|
343
347
|
* The actions are a subset of the registry
|
|
344
348
|
*/
|
|
345
|
-
actions
|
|
346
|
-
/**
|
|
347
|
-
* The Pinia store that manages the mutable records
|
|
348
|
-
*/
|
|
349
|
-
store: ReturnType<typeof useDataStore>;
|
|
349
|
+
actions?: ImmutableDoctype['actions'];
|
|
350
350
|
/**
|
|
351
351
|
* @param registry - The immutable registry
|
|
352
352
|
* @param store - The mutable Pinia store
|