@genesislcap/foundation-state-machine 15.24.0-FUI-2603.10 → 15.24.0
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/dts/core/actions.d.ts +2 -7
- package/dist/dts/core/actions.d.ts.map +1 -1
- package/dist/dts/core/state.d.ts +0 -4
- package/dist/dts/core/state.d.ts.map +1 -1
- package/dist/dts/machines/fetch/machine.d.ts.map +1 -1
- package/dist/esm/core/actions.js +9 -16
- package/dist/esm/core/state.js +17 -7
- package/dist/esm/machines/fetch/machine.js +0 -6
- package/dist/foundation-state-machine.api.json +2 -2
- package/dist/foundation-state-machine.d.ts +2 -11
- package/package.json +11 -11
|
@@ -18,14 +18,9 @@ export declare const setError: {
|
|
|
18
18
|
* Set error by key action.
|
|
19
19
|
* @remarks
|
|
20
20
|
* Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.
|
|
21
|
-
* Prefers an existing `context.error` over the current event. Callers that start a new
|
|
22
|
-
* operation must clear the previous error first (e.g. `clearErrors` / `resetContext`);
|
|
23
|
-
* otherwise a stale `context.error` is re-keyed under this key and a later done-output
|
|
24
|
-
* Error is ignored. When `setError` matches no branch it returns `undefined` and leaves
|
|
25
|
-
* the prior `context.error` in place — which is what makes clearing mandatory.
|
|
26
21
|
* @privateRemarks
|
|
27
|
-
* Contains done event handling to deal with 200 Nacks.
|
|
28
|
-
*
|
|
22
|
+
* Contains done event handling to deal with 200 Nacks. If done output is an error use it, or fallback to `context.error`
|
|
23
|
+
* and set that under the provided key.
|
|
29
24
|
* @param key - The error key.
|
|
30
25
|
* @public
|
|
31
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/core/actions.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAYnB,CAAC;AAEH
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/core/actions.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAYnB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM;;;;;;;CAgBrC,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;CAA2C,CAAC"}
|
package/dist/dts/core/state.d.ts
CHANGED
|
@@ -2,10 +2,6 @@ import type { StateNodeConfig } from 'xstate';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates an error state node.
|
|
4
4
|
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Entry runs {@link setErrorByKey}, which prefers an existing `context.error`. Ensure
|
|
7
|
-
* the prior error was cleared before entering a new operation that may land here.
|
|
8
|
-
*
|
|
9
5
|
* @param key - An error state key.
|
|
10
6
|
* @param metaContent - An optional meta content value.
|
|
11
7
|
* @param final - An optional flag which adds final with output functionality.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/core/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/core/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI9C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,MAAM,EACX,cAAc,MAAM,EACpB,QAAO,OAAc,KACpB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CA4BpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../../src/machines/fetch/machine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE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H,OAAO,EAAE,OAAO,KAAK,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,mEAAoC,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,OAAO,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;CAAG;AAExF;;;GAGG;AACH,qBAAa,mBACX,SAAQ,eAAe,CAAC,mBAAmB,EAAE,iBAAiB,CAC9D,YAAW,YAAY;IAEY,OAAO,CAAC,MAAM;gBAAN,MAAM,cAAqB;IAkLtE,kCAAkC;IAClC,KAAK,CACH,OAAO,GAAE,kBAAkB,CAAC,OAAO,IAAI,CAAC,OAAO,CAE9C;IAKH,6CAA6C;IAC7C,gBAAgB,IAAI,IAAI;CAGzB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,oEAExB,CAAC"}
|
package/dist/esm/core/actions.js
CHANGED
|
@@ -28,28 +28,21 @@ export const setError = assign(({ event }) => {
|
|
|
28
28
|
* Set error by key action.
|
|
29
29
|
* @remarks
|
|
30
30
|
* Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.
|
|
31
|
-
* Prefers an existing `context.error` over the current event. Callers that start a new
|
|
32
|
-
* operation must clear the previous error first (e.g. `clearErrors` / `resetContext`);
|
|
33
|
-
* otherwise a stale `context.error` is re-keyed under this key and a later done-output
|
|
34
|
-
* Error is ignored. When `setError` matches no branch it returns `undefined` and leaves
|
|
35
|
-
* the prior `context.error` in place — which is what makes clearing mandatory.
|
|
36
31
|
* @privateRemarks
|
|
37
|
-
* Contains done event handling to deal with 200 Nacks.
|
|
38
|
-
*
|
|
32
|
+
* Contains done event handling to deal with 200 Nacks. If done output is an error use it, or fallback to `context.error`
|
|
33
|
+
* and set that under the provided key.
|
|
39
34
|
* @param key - The error key.
|
|
40
35
|
* @public
|
|
41
36
|
*/
|
|
42
37
|
export const setErrorByKey = (key) => assign(({ context, event }) => {
|
|
43
38
|
var _a;
|
|
44
|
-
let error
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
error = event.output instanceof Error ? event.output : undefined;
|
|
52
|
-
}
|
|
39
|
+
let error;
|
|
40
|
+
if (isErrorEvent(event)) {
|
|
41
|
+
error = event.data;
|
|
42
|
+
}
|
|
43
|
+
else if (isDoneInvokeEvent(event)) {
|
|
44
|
+
logger.debug(`setErrorByKey action called with non error event type.`, event);
|
|
45
|
+
error = event.output instanceof Error ? event.output : context.error;
|
|
53
46
|
}
|
|
54
47
|
if (error) {
|
|
55
48
|
const errors = (_a = context.errors) !== null && _a !== void 0 ? _a : createErrorMap(logger.error);
|
package/dist/esm/core/state.js
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import { setErrorByKey } from './actions';
|
|
1
|
+
import { escalateError, setErrorByKey } from './actions';
|
|
2
2
|
/**
|
|
3
3
|
* Creates an error state node.
|
|
4
4
|
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Entry runs {@link setErrorByKey}, which prefers an existing `context.error`. Ensure
|
|
7
|
-
* the prior error was cleared before entering a new operation that may land here.
|
|
8
|
-
*
|
|
9
5
|
* @param key - An error state key.
|
|
10
6
|
* @param metaContent - An optional meta content value.
|
|
11
7
|
* @param final - An optional flag which adds final with output functionality.
|
|
12
8
|
* @public
|
|
13
9
|
*/
|
|
14
10
|
export const createErrorStateNode = (key, metaContent, final = true) => {
|
|
11
|
+
/**
|
|
12
|
+
* Raised question on reuse and dynamic parent detection, regarding error escalation.
|
|
13
|
+
* https://github.com/statelyai/xstate/discussions/4268
|
|
14
|
+
*/
|
|
15
|
+
let hasParentMachine = false;
|
|
16
|
+
let sentToParentMachine = false;
|
|
15
17
|
return {
|
|
16
18
|
tags: ['error', key],
|
|
17
19
|
meta: {
|
|
18
20
|
content: metaContent ? metaContent : `${key} error.`,
|
|
19
21
|
},
|
|
20
|
-
entry: [
|
|
22
|
+
entry: [
|
|
23
|
+
setErrorByKey(`${key}-error`),
|
|
24
|
+
(args) => (hasParentMachine = args.self._parent !== undefined),
|
|
25
|
+
],
|
|
26
|
+
always: [
|
|
27
|
+
{
|
|
28
|
+
guard: () => hasParentMachine && !sentToParentMachine,
|
|
29
|
+
actions: [escalateError, () => (sentToParentMachine = true)],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
21
32
|
/**
|
|
22
33
|
* Provide final output to parent machines.
|
|
23
|
-
* Notification of invoked parents is via this output / top-level `failed`, not escalate closures.
|
|
24
34
|
*/
|
|
25
35
|
type: final ? 'final' : 'atomic',
|
|
26
36
|
output: ({ context }) => context.error,
|
|
@@ -92,12 +92,6 @@ let DefaultFetchMachine = class DefaultFetchMachine extends AbstractMachine {
|
|
|
92
92
|
abort: createErrorStateNode('abort', 'Abort error.'),
|
|
93
93
|
syntax: createErrorStateNode('syntax', 'Syntax error.'),
|
|
94
94
|
},
|
|
95
|
-
onDone: 'failed',
|
|
96
|
-
},
|
|
97
|
-
failed: {
|
|
98
|
-
tags: ['error'],
|
|
99
|
-
type: 'final',
|
|
100
|
-
output: ({ context }) => context.error,
|
|
101
95
|
},
|
|
102
96
|
},
|
|
103
97
|
on: {
|
|
@@ -1715,7 +1715,7 @@
|
|
|
1715
1715
|
{
|
|
1716
1716
|
"kind": "Function",
|
|
1717
1717
|
"canonicalReference": "@genesislcap/foundation-state-machine!createErrorStateNode:function(1)",
|
|
1718
|
-
"docComment": "/**\n * Creates an error state node.\n *\n * @
|
|
1718
|
+
"docComment": "/**\n * Creates an error state node.\n *\n * @param key - An error state key.\n *\n * @param metaContent - An optional meta content value.\n *\n * @param final - An optional flag which adds final with output functionality.\n *\n * @public\n */\n",
|
|
1719
1719
|
"excerptTokens": [
|
|
1720
1720
|
{
|
|
1721
1721
|
"kind": "Content",
|
|
@@ -6424,7 +6424,7 @@
|
|
|
6424
6424
|
{
|
|
6425
6425
|
"kind": "Function",
|
|
6426
6426
|
"canonicalReference": "@genesislcap/foundation-state-machine!setErrorByKey:function(1)",
|
|
6427
|
-
"docComment": "/**\n * Set error by key action.\n *\n * @remarks\n *\n * Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key
|
|
6427
|
+
"docComment": "/**\n * Set error by key action.\n *\n * @remarks\n *\n * Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.\n *\n * @param key - The error key.\n *\n * @public\n */\n",
|
|
6428
6428
|
"excerptTokens": [
|
|
6429
6429
|
{
|
|
6430
6430
|
"kind": "Content",
|
|
@@ -166,10 +166,6 @@ export { assign }
|
|
|
166
166
|
/**
|
|
167
167
|
* Creates an error state node.
|
|
168
168
|
*
|
|
169
|
-
* @remarks
|
|
170
|
-
* Entry runs {@link setErrorByKey}, which prefers an existing `context.error`. Ensure
|
|
171
|
-
* the prior error was cleared before entering a new operation that may land here.
|
|
172
|
-
*
|
|
173
169
|
* @param key - An error state key.
|
|
174
170
|
* @param metaContent - An optional meta content value.
|
|
175
171
|
* @param final - An optional flag which adds final with output functionality.
|
|
@@ -918,14 +914,9 @@ export declare const setError: {
|
|
|
918
914
|
* Set error by key action.
|
|
919
915
|
* @remarks
|
|
920
916
|
* Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.
|
|
921
|
-
* Prefers an existing `context.error` over the current event. Callers that start a new
|
|
922
|
-
* operation must clear the previous error first (e.g. `clearErrors` / `resetContext`);
|
|
923
|
-
* otherwise a stale `context.error` is re-keyed under this key and a later done-output
|
|
924
|
-
* Error is ignored. When `setError` matches no branch it returns `undefined` and leaves
|
|
925
|
-
* the prior `context.error` in place — which is what makes clearing mandatory.
|
|
926
917
|
* @privateRemarks
|
|
927
|
-
* Contains done event handling to deal with 200 Nacks.
|
|
928
|
-
*
|
|
918
|
+
* Contains done event handling to deal with 200 Nacks. If done output is an error use it, or fallback to `context.error`
|
|
919
|
+
* and set that under the provided key.
|
|
929
920
|
* @param key - The error key.
|
|
930
921
|
* @public
|
|
931
922
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-state-machine",
|
|
3
3
|
"description": "Genesis Foundation State Machine",
|
|
4
|
-
"version": "15.24.0
|
|
4
|
+
"version": "15.24.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@genesislcap/foundation-testing": "15.24.0
|
|
58
|
-
"@genesislcap/genx": "15.24.0
|
|
59
|
-
"@genesislcap/rollup-builder": "15.24.0
|
|
60
|
-
"@genesislcap/ts-builder": "15.24.0
|
|
61
|
-
"@genesislcap/uvu-playwright-builder": "15.24.0
|
|
62
|
-
"@genesislcap/vite-builder": "15.24.0
|
|
63
|
-
"@genesislcap/webpack-builder": "15.24.0
|
|
57
|
+
"@genesislcap/foundation-testing": "15.24.0",
|
|
58
|
+
"@genesislcap/genx": "15.24.0",
|
|
59
|
+
"@genesislcap/rollup-builder": "15.24.0",
|
|
60
|
+
"@genesislcap/ts-builder": "15.24.0",
|
|
61
|
+
"@genesislcap/uvu-playwright-builder": "15.24.0",
|
|
62
|
+
"@genesislcap/vite-builder": "15.24.0",
|
|
63
|
+
"@genesislcap/webpack-builder": "15.24.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@genesislcap/foundation-comms": "15.24.0
|
|
67
|
-
"@genesislcap/foundation-logger": "15.24.0
|
|
68
|
-
"@genesislcap/foundation-utils": "15.24.0
|
|
66
|
+
"@genesislcap/foundation-comms": "15.24.0",
|
|
67
|
+
"@genesislcap/foundation-logger": "15.24.0",
|
|
68
|
+
"@genesislcap/foundation-utils": "15.24.0",
|
|
69
69
|
"@microsoft/fast-element": "1.14.0",
|
|
70
70
|
"@microsoft/fast-foundation": "2.50.0",
|
|
71
71
|
"cockatiel": "^3.1.1",
|