quidproquo-xstate 0.1.0 → 0.1.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/lib/commonjs/actionProcessor/getStateMachineCreateActionProcessor.js +3 -1
- package/lib/commonjs/actionProcessor/getStateMachineGetActionProcessor.js +3 -1
- package/lib/commonjs/actionProcessor/getStateMachineGetStateActionProcessor.js +3 -1
- package/lib/commonjs/actionProcessor/getStateMachineSendEventActionProcessor.js +6 -2
- package/lib/commonjs/config/settings/stateMachine.js +1 -4
- package/lib/esm/actionProcessor/getStateMachineCreateActionProcessor.js +3 -1
- package/lib/esm/actionProcessor/getStateMachineGetActionProcessor.js +3 -1
- package/lib/esm/actionProcessor/getStateMachineGetStateActionProcessor.js +3 -1
- package/lib/esm/actionProcessor/getStateMachineSendEventActionProcessor.js +6 -2
- package/lib/esm/config/settings/stateMachine.js +2 -5
- package/package.json +3 -3
|
@@ -40,7 +40,9 @@ const getProcessStateMachineCreate = (qpqConfig) => {
|
|
|
40
40
|
const entity = Object.assign(Object.assign({}, payload.item), { id: payload.id });
|
|
41
41
|
entity[smConfig.stateField] = initialSnapshot;
|
|
42
42
|
// Persist to KVS
|
|
43
|
-
const upsertResult = yield resolveStory(function* () {
|
|
43
|
+
const upsertResult = yield resolveStory(function* () {
|
|
44
|
+
yield* (0, quidproquo_core_1.askKeyValueStoreUpsert)(smConfig.keyValueStoreName, entity);
|
|
45
|
+
}, []);
|
|
44
46
|
if (upsertResult.error) {
|
|
45
47
|
return (0, quidproquo_core_1.actionResultError)(upsertResult.error.errorType, upsertResult.error.errorText);
|
|
46
48
|
}
|
|
@@ -20,7 +20,9 @@ const getProcessStateMachineGet = (qpqConfig) => {
|
|
|
20
20
|
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `State machine not found: ${payload.stateMachineName}`);
|
|
21
21
|
}
|
|
22
22
|
const resolveStory = (0, quidproquo_core_1.createImplementationRuntime)(qpqConfig, ['StateMachine Get'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
23
|
-
const getResult = yield resolveStory(function* () {
|
|
23
|
+
const getResult = yield resolveStory(function* () {
|
|
24
|
+
return yield* (0, quidproquo_core_1.askKeyValueStoreGet)(smConfig.keyValueStoreName, payload.id);
|
|
25
|
+
}, []);
|
|
24
26
|
if (getResult.error) {
|
|
25
27
|
return (0, quidproquo_core_1.actionResultError)(getResult.error.errorType, getResult.error.errorText);
|
|
26
28
|
}
|
|
@@ -22,7 +22,9 @@ const getProcessStateMachineGetState = (qpqConfig) => {
|
|
|
22
22
|
}
|
|
23
23
|
const resolveStory = (0, quidproquo_core_1.createImplementationRuntime)(qpqConfig, ['StateMachine GetState'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
24
24
|
// Load entity from KVS
|
|
25
|
-
const getResult = yield resolveStory(function* () {
|
|
25
|
+
const getResult = yield resolveStory(function* () {
|
|
26
|
+
return yield* (0, quidproquo_core_1.askKeyValueStoreGet)(smConfig.keyValueStoreName, payload.id);
|
|
27
|
+
}, []);
|
|
26
28
|
if (getResult.error) {
|
|
27
29
|
return (0, quidproquo_core_1.actionResultError)(getResult.error.errorType, getResult.error.errorText);
|
|
28
30
|
}
|
|
@@ -23,7 +23,9 @@ const getProcessStateMachineSendEvent = (qpqConfig) => {
|
|
|
23
23
|
const resolveStory = (0, quidproquo_core_1.createImplementationRuntime)(qpqConfig, ['StateMachine SendEvent'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
24
24
|
// Load entity from KVS
|
|
25
25
|
let entity;
|
|
26
|
-
const getResult = yield resolveStory(function* () {
|
|
26
|
+
const getResult = yield resolveStory(function* () {
|
|
27
|
+
return yield* (0, quidproquo_core_1.askKeyValueStoreGet)(smConfig.keyValueStoreName, payload.id);
|
|
28
|
+
}, []);
|
|
27
29
|
if (getResult.error) {
|
|
28
30
|
return (0, quidproquo_core_1.actionResultError)(getResult.error.errorType, getResult.error.errorText);
|
|
29
31
|
}
|
|
@@ -74,7 +76,9 @@ const getProcessStateMachineSendEvent = (qpqConfig) => {
|
|
|
74
76
|
}
|
|
75
77
|
// Persist new snapshot
|
|
76
78
|
entity[smConfig.stateField] = newSnapshot;
|
|
77
|
-
const upsertResult = yield resolveStory(function* () {
|
|
79
|
+
const upsertResult = yield resolveStory(function* () {
|
|
80
|
+
yield* (0, quidproquo_core_1.askKeyValueStoreUpsert)(smConfig.keyValueStoreName, entity);
|
|
81
|
+
}, []);
|
|
78
82
|
if (upsertResult.error) {
|
|
79
83
|
return (0, quidproquo_core_1.actionResultError)(upsertResult.error.errorType, upsertResult.error.errorText);
|
|
80
84
|
}
|
|
@@ -19,9 +19,6 @@ const defineStateMachine = (stateMachineName, options) => {
|
|
|
19
19
|
stateField: (_c = options.stateField) !== null && _c !== void 0 ? _c : '__machineState',
|
|
20
20
|
owner: options.owner,
|
|
21
21
|
};
|
|
22
|
-
return [
|
|
23
|
-
(0, quidproquo_core_1.defineKeyValueStore)(keyValueStoreName, 'id'),
|
|
24
|
-
stateMachineConfig
|
|
25
|
-
];
|
|
22
|
+
return [(0, quidproquo_core_1.defineKeyValueStore)(keyValueStoreName, 'id'), stateMachineConfig];
|
|
26
23
|
};
|
|
27
24
|
exports.defineStateMachine = defineStateMachine;
|
|
@@ -28,7 +28,9 @@ const getProcessStateMachineCreate = (qpqConfig) => {
|
|
|
28
28
|
const entity = { ...payload.item, id: payload.id };
|
|
29
29
|
entity[smConfig.stateField] = initialSnapshot;
|
|
30
30
|
// Persist to KVS
|
|
31
|
-
const upsertResult = await resolveStory(function* () {
|
|
31
|
+
const upsertResult = await resolveStory(function* () {
|
|
32
|
+
yield* askKeyValueStoreUpsert(smConfig.keyValueStoreName, entity);
|
|
33
|
+
}, []);
|
|
32
34
|
if (upsertResult.error) {
|
|
33
35
|
return actionResultError(upsertResult.error.errorType, upsertResult.error.errorText);
|
|
34
36
|
}
|
|
@@ -8,7 +8,9 @@ const getProcessStateMachineGet = (qpqConfig) => {
|
|
|
8
8
|
return actionResultError(ErrorTypeEnum.NotFound, `State machine not found: ${payload.stateMachineName}`);
|
|
9
9
|
}
|
|
10
10
|
const resolveStory = createImplementationRuntime(qpqConfig, ['StateMachine Get'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
11
|
-
const getResult = await resolveStory(function* () {
|
|
11
|
+
const getResult = await resolveStory(function* () {
|
|
12
|
+
return yield* askKeyValueStoreGet(smConfig.keyValueStoreName, payload.id);
|
|
13
|
+
}, []);
|
|
12
14
|
if (getResult.error) {
|
|
13
15
|
return actionResultError(getResult.error.errorType, getResult.error.errorText);
|
|
14
16
|
}
|
|
@@ -10,7 +10,9 @@ const getProcessStateMachineGetState = (qpqConfig) => {
|
|
|
10
10
|
}
|
|
11
11
|
const resolveStory = createImplementationRuntime(qpqConfig, ['StateMachine GetState'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
12
12
|
// Load entity from KVS
|
|
13
|
-
const getResult = await resolveStory(function* () {
|
|
13
|
+
const getResult = await resolveStory(function* () {
|
|
14
|
+
return yield* askKeyValueStoreGet(smConfig.keyValueStoreName, payload.id);
|
|
15
|
+
}, []);
|
|
14
16
|
if (getResult.error) {
|
|
15
17
|
return actionResultError(getResult.error.errorType, getResult.error.errorText);
|
|
16
18
|
}
|
|
@@ -11,7 +11,9 @@ const getProcessStateMachineSendEvent = (qpqConfig) => {
|
|
|
11
11
|
const resolveStory = createImplementationRuntime(qpqConfig, ['StateMachine SendEvent'], () => new Date().toISOString(), () => `${Date.now()}-${Math.random().toString(36).slice(2)}`, session, actionProcessors, logger, dynamicModuleLoader, streamRegistry);
|
|
12
12
|
// Load entity from KVS
|
|
13
13
|
let entity;
|
|
14
|
-
const getResult = await resolveStory(function* () {
|
|
14
|
+
const getResult = await resolveStory(function* () {
|
|
15
|
+
return yield* askKeyValueStoreGet(smConfig.keyValueStoreName, payload.id);
|
|
16
|
+
}, []);
|
|
15
17
|
if (getResult.error) {
|
|
16
18
|
return actionResultError(getResult.error.errorType, getResult.error.errorText);
|
|
17
19
|
}
|
|
@@ -62,7 +64,9 @@ const getProcessStateMachineSendEvent = (qpqConfig) => {
|
|
|
62
64
|
}
|
|
63
65
|
// Persist new snapshot
|
|
64
66
|
entity[smConfig.stateField] = newSnapshot;
|
|
65
|
-
const upsertResult = await resolveStory(function* () {
|
|
67
|
+
const upsertResult = await resolveStory(function* () {
|
|
68
|
+
yield* askKeyValueStoreUpsert(smConfig.keyValueStoreName, entity);
|
|
69
|
+
}, []);
|
|
66
70
|
if (upsertResult.error) {
|
|
67
71
|
return actionResultError(upsertResult.error.errorType, upsertResult.error.errorText);
|
|
68
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineKeyValueStore
|
|
1
|
+
import { defineKeyValueStore } from 'quidproquo-core';
|
|
2
2
|
import { QPQXStateConfigSettingType } from '../QPQConfig';
|
|
3
3
|
export const getStateMachineStoreName = (stateMachineName) => `qpq-sm-${stateMachineName}`;
|
|
4
4
|
export const defineStateMachine = (stateMachineName, options) => {
|
|
@@ -14,8 +14,5 @@ export const defineStateMachine = (stateMachineName, options) => {
|
|
|
14
14
|
stateField: options.stateField ?? '__machineState',
|
|
15
15
|
owner: options.owner,
|
|
16
16
|
};
|
|
17
|
-
return [
|
|
18
|
-
defineKeyValueStore(keyValueStoreName, 'id'),
|
|
19
|
-
stateMachineConfig
|
|
20
|
-
];
|
|
17
|
+
return [defineKeyValueStore(keyValueStoreName, 'id'), stateMachineConfig];
|
|
21
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-xstate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"quidproquo-core": "0.1.
|
|
35
|
+
"quidproquo-core": "0.1.2",
|
|
36
36
|
"xstate": "^5.19.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"quidproquo-tsconfig": "0.1.
|
|
39
|
+
"quidproquo-tsconfig": "0.1.2",
|
|
40
40
|
"typescript": "^5.8.2"
|
|
41
41
|
}
|
|
42
42
|
}
|