@genesislcap/foundation-state-machine 14.94.2 → 14.96.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 +6 -1
- package/dist/dts/core/actions.d.ts.map +1 -1
- package/dist/dts/core/errors.d.ts +2 -2
- package/dist/dts/core/errors.d.ts.map +1 -1
- package/dist/dts/core/guards.d.ts +7 -1
- package/dist/dts/core/guards.d.ts.map +1 -1
- package/dist/dts/core/machine.d.ts +28 -1
- package/dist/dts/core/machine.d.ts.map +1 -1
- package/dist/dts/core/state.d.ts.map +1 -1
- package/dist/dts/machines/fetch/errors.d.ts +14 -3
- package/dist/dts/machines/fetch/errors.d.ts.map +1 -1
- package/dist/esm/core/actions.js +23 -8
- package/dist/esm/core/guards.js +6 -0
- package/dist/esm/core/machine.js +39 -12
- package/dist/esm/core/state.js +18 -6
- package/dist/esm/machines/fetch/errors.js +11 -0
- package/dist/esm/machines/fetch/policies.js +5 -5
- package/dist/foundation-state-machine.api.json +464 -11
- package/dist/foundation-state-machine.d.ts +59 -7
- package/docs/api/foundation-state-machine.abstractmachine.getmetavaluesbykey.md +28 -0
- package/docs/api/foundation-state-machine.abstractmachine.md +3 -0
- package/docs/api/foundation-state-machine.abstractmachine.meta.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.snapshot.md +13 -0
- package/docs/api/foundation-state-machine.apierror.isunauthorized.md +16 -0
- package/docs/api/foundation-state-machine.apierror.md +6 -0
- package/docs/api/foundation-state-machine.escalateerror.md +1 -1
- package/docs/api/foundation-state-machine.isapierror.md +1 -1
- package/docs/api/foundation-state-machine.iseventwithparams.md +13 -0
- package/docs/api/foundation-state-machine.isgenesisservererror.md +1 -1
- package/docs/api/foundation-state-machine.ismappingerror.md +1 -1
- package/docs/api/foundation-state-machine.isnetworkerror.md +1 -1
- package/docs/api/foundation-state-machine.isnotfounderror.md +1 -1
- package/docs/api/foundation-state-machine.isunauthorizederror.md +13 -0
- package/docs/api/foundation-state-machine.machine.getmetavaluesbykey.md +28 -0
- package/docs/api/foundation-state-machine.machine.md +3 -0
- package/docs/api/foundation-state-machine.machine.meta.md +13 -0
- package/docs/api/foundation-state-machine.machine.snapshot.md +13 -0
- package/docs/api/foundation-state-machine.md +3 -1
- package/docs/api-report.md +25 -6
- package/package.json +7 -7
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ActionArgs } from 'xstate';
|
|
4
4
|
import { AnyActorContext } from 'xstate';
|
|
5
5
|
import { AnyActorRef } from 'xstate';
|
|
6
|
-
import
|
|
6
|
+
import { AnyEventObject } from 'xstate';
|
|
7
7
|
import { AnyState } from 'xstate';
|
|
8
8
|
import { Assigner } from 'xstate';
|
|
9
9
|
import { BindingObserver } from '@microsoft/fast-element';
|
|
@@ -34,6 +34,7 @@ import type { ProvidedActor } from 'xstate';
|
|
|
34
34
|
import type { ResolveTypegenMeta } from 'xstate';
|
|
35
35
|
import { RetryPolicy } from 'cockatiel';
|
|
36
36
|
import { SendExpr } from 'xstate';
|
|
37
|
+
import type { State } from 'xstate';
|
|
37
38
|
import type { StateMachine } from 'xstate';
|
|
38
39
|
import type { StateNodeConfig } from 'xstate';
|
|
39
40
|
import type { StateValue } from 'xstate';
|
|
@@ -56,6 +57,8 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
56
57
|
machine: StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>;
|
|
57
58
|
/** {@inheritDoc Machine.actor} */
|
|
58
59
|
actor: InterpreterFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>;
|
|
60
|
+
/** {@inheritDoc Machine.snapshot} */
|
|
61
|
+
snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
59
62
|
/** {@inheritDoc Machine.state} */
|
|
60
63
|
state: StateValue;
|
|
61
64
|
/** {@inheritDoc Machine.startingState} */
|
|
@@ -64,6 +67,8 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
64
67
|
context: Partial<TContext>;
|
|
65
68
|
/** {@inheritDoc Machine.startingContext} */
|
|
66
69
|
startingContext: Partial<TContext>;
|
|
70
|
+
/** {@inheritDoc Machine.meta} */
|
|
71
|
+
meta: Record<string, any>;
|
|
67
72
|
/** {@inheritDoc Machine.complete} */
|
|
68
73
|
complete: boolean;
|
|
69
74
|
/** {@inheritDoc Machine.output} */
|
|
@@ -88,6 +93,10 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
88
93
|
* @internal
|
|
89
94
|
*/
|
|
90
95
|
protected subscribe(): void;
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
protected applySnapshot(snapshot?: typeof AbstractMachine.snapshot): void;
|
|
91
100
|
/**
|
|
92
101
|
* @internal
|
|
93
102
|
*/
|
|
@@ -106,6 +115,8 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
106
115
|
matches(value: StateValueFrom<typeof AbstractMachine.machine>): boolean;
|
|
107
116
|
/** {@inheritDoc Machine.hasTag} */
|
|
108
117
|
hasTag(tag: string): boolean;
|
|
118
|
+
/** {@inheritDoc Machine.getMetaValuesByKey} */
|
|
119
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
109
120
|
/** {@inheritDoc Machine.send} */
|
|
110
121
|
send(event: TEvent): void;
|
|
111
122
|
/** {@inheritDoc Machine.onSendEvent} */
|
|
@@ -126,6 +137,10 @@ export declare class APIError extends Error {
|
|
|
126
137
|
status: number;
|
|
127
138
|
data?: unknown;
|
|
128
139
|
constructor(status: number, data?: unknown, message?: string);
|
|
140
|
+
/**
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
isUnauthorized(): boolean;
|
|
129
144
|
}
|
|
130
145
|
|
|
131
146
|
/**
|
|
@@ -240,7 +255,7 @@ export declare const errorWorkflowInput: (key: string) => ({ context }: {
|
|
|
240
255
|
}) => ErrorWorkflowInput;
|
|
241
256
|
|
|
242
257
|
/**
|
|
243
|
-
* Escalate error action.
|
|
258
|
+
* Escalate context error action.
|
|
244
259
|
* @remarks
|
|
245
260
|
* Guard this call with a parent check to avoid warnings when there's no parent.
|
|
246
261
|
* @public
|
|
@@ -432,7 +447,7 @@ export declare const isActorErrorEvent: <TData = any>(actorId: string, event: Ev
|
|
|
432
447
|
* @param error - An error.
|
|
433
448
|
* @public
|
|
434
449
|
*/
|
|
435
|
-
export declare const isAPIError: (error: unknown) =>
|
|
450
|
+
export declare const isAPIError: (error: unknown) => error is APIError;
|
|
436
451
|
|
|
437
452
|
/**
|
|
438
453
|
* isDoneInvokeEvent.
|
|
@@ -464,23 +479,30 @@ export declare const isErrorEvent: <TData = any>(event: EventObject | ErrorEvent
|
|
|
464
479
|
*/
|
|
465
480
|
export declare const isErrorType: <TType extends ErrorConstructor>(type: TType) => (event: any) => boolean;
|
|
466
481
|
|
|
482
|
+
/**
|
|
483
|
+
* isEventWithParams.
|
|
484
|
+
* @param event - An event.
|
|
485
|
+
* @public
|
|
486
|
+
*/
|
|
487
|
+
export declare const isEventWithParams: (event: AnyEventObject) => event is ParameterizedObject;
|
|
488
|
+
|
|
467
489
|
/**
|
|
468
490
|
* @param error - An error.
|
|
469
491
|
* @public
|
|
470
492
|
*/
|
|
471
|
-
export declare const isGenesisServerError: (error: unknown) =>
|
|
493
|
+
export declare const isGenesisServerError: (error: unknown) => error is GenesisServerError;
|
|
472
494
|
|
|
473
495
|
/**
|
|
474
496
|
* @param error - An error.
|
|
475
497
|
* @public
|
|
476
498
|
*/
|
|
477
|
-
export declare const isMappingError: (error: unknown) =>
|
|
499
|
+
export declare const isMappingError: (error: unknown) => error is MappingError;
|
|
478
500
|
|
|
479
501
|
/**
|
|
480
502
|
* @param error - An error.
|
|
481
503
|
* @public
|
|
482
504
|
*/
|
|
483
|
-
export declare const isNetworkError: (error: unknown) =>
|
|
505
|
+
export declare const isNetworkError: (error: unknown) => error is NetworkError;
|
|
484
506
|
|
|
485
507
|
/**
|
|
486
508
|
* @param error - An error.
|
|
@@ -488,7 +510,7 @@ export declare const isNetworkError: (error: unknown) => boolean;
|
|
|
488
510
|
*/
|
|
489
511
|
export declare const isNotFoundError: (error: {
|
|
490
512
|
status?: number;
|
|
491
|
-
}) =>
|
|
513
|
+
}) => error is APIError;
|
|
492
514
|
|
|
493
515
|
/**
|
|
494
516
|
* isSyntaxError.
|
|
@@ -506,6 +528,14 @@ export declare const isTypeError: ({ event }: {
|
|
|
506
528
|
event: any;
|
|
507
529
|
}) => boolean;
|
|
508
530
|
|
|
531
|
+
/**
|
|
532
|
+
* @param error - An error.
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
export declare const isUnauthorizedError: (error: {
|
|
536
|
+
status?: number;
|
|
537
|
+
}) => error is APIError;
|
|
538
|
+
|
|
509
539
|
/**
|
|
510
540
|
* @public
|
|
511
541
|
*/
|
|
@@ -580,6 +610,10 @@ export declare interface Machine<TContext extends MachineContext, TEvent extends
|
|
|
580
610
|
* Callers can decide to reuse/reference if set or create their own.
|
|
581
611
|
*/
|
|
582
612
|
readonly actor?: InterpreterFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>;
|
|
613
|
+
/**
|
|
614
|
+
* The last `snapshot` from the actor.
|
|
615
|
+
*/
|
|
616
|
+
readonly snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
583
617
|
/**
|
|
584
618
|
* The current `state` of the machine itself. This is not to be confused with state in the data or store sense.
|
|
585
619
|
*/
|
|
@@ -599,6 +633,10 @@ export declare interface Machine<TContext extends MachineContext, TEvent extends
|
|
|
599
633
|
* The `context` of the machine when started.
|
|
600
634
|
*/
|
|
601
635
|
readonly startingContext: Partial<TContext>;
|
|
636
|
+
/**
|
|
637
|
+
* The `meta` from the current `state`.
|
|
638
|
+
*/
|
|
639
|
+
readonly meta: Record<string, any>;
|
|
602
640
|
/**
|
|
603
641
|
* Indicates if the machine has completed the happy path.
|
|
604
642
|
*/
|
|
@@ -684,6 +722,15 @@ export declare interface Machine<TContext extends MachineContext, TEvent extends
|
|
|
684
722
|
* @param tag - A tag.
|
|
685
723
|
*/
|
|
686
724
|
hasTag(tag: string): boolean;
|
|
725
|
+
/**
|
|
726
|
+
* Get `meta` values by key.
|
|
727
|
+
*
|
|
728
|
+
* @remarks
|
|
729
|
+
* Meta is cumulative across all state nodes represented by the state value.
|
|
730
|
+
*
|
|
731
|
+
* @param key - A key within the `meta` object. Defaults to `content`.
|
|
732
|
+
*/
|
|
733
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
687
734
|
/**
|
|
688
735
|
* An api to send events to the machine.
|
|
689
736
|
*
|
|
@@ -821,6 +868,8 @@ export declare type ResponseOkChecker = (response: Response) => boolean;
|
|
|
821
868
|
* Set error action.
|
|
822
869
|
* @remarks
|
|
823
870
|
* Used to set a top level error on the machine. This may equal to {@link @genesislcap/foundation-utils#ErrorMap} `lastError` in the `errors` property.
|
|
871
|
+
* @privateRemarks
|
|
872
|
+
* Contains done event handling to deal with 200 Nacks.
|
|
824
873
|
* @public
|
|
825
874
|
*/
|
|
826
875
|
export declare const setError: {
|
|
@@ -836,6 +885,9 @@ export declare const setError: {
|
|
|
836
885
|
* Set error by key action.
|
|
837
886
|
* @remarks
|
|
838
887
|
* Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.
|
|
888
|
+
* @privateRemarks
|
|
889
|
+
* Contains done event handling to deal with 200 Nacks. If done output is an error use it, or fallback to `context.error`
|
|
890
|
+
* and set that under the provided key.
|
|
839
891
|
* @param key - The error key.
|
|
840
892
|
* @public
|
|
841
893
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [AbstractMachine](./foundation-state-machine.abstractmachine.md) > [getMetaValuesByKey](./foundation-state-machine.abstractmachine.getmetavaluesbykey.md)
|
|
4
|
+
|
|
5
|
+
## AbstractMachine.getMetaValuesByKey() method
|
|
6
|
+
|
|
7
|
+
Get `meta` values by key.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| key | string | _(Optional)_ A key within the <code>meta</code> object. Defaults to <code>content</code>. |
|
|
20
|
+
|
|
21
|
+
**Returns:**
|
|
22
|
+
|
|
23
|
+
T\[\]
|
|
24
|
+
|
|
25
|
+
## Remarks
|
|
26
|
+
|
|
27
|
+
Meta is cumulative across all state nodes represented by the state value.
|
|
28
|
+
|
|
@@ -23,8 +23,10 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
23
23
|
| [error](./foundation-state-machine.abstractmachine.error.md) | | any | A general machine error. Likely equal to <code>errors.lastError</code>. |
|
|
24
24
|
| [errors](./foundation-state-machine.abstractmachine.errors.md) | | ErrorMap<ErrorDetailMap> | An of errors that may have occurred during the machine's workflows. |
|
|
25
25
|
| [machine](./foundation-state-machine.abstractmachine.machine.md) | | StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta> | Mandatory machine property. |
|
|
26
|
+
| [meta](./foundation-state-machine.abstractmachine.meta.md) | | Record<string, any> | The <code>meta</code> from the current <code>state</code>. |
|
|
26
27
|
| [onSendEvent](./foundation-state-machine.abstractmachine.onsendevent.md) | | (event: CustomEvent<TEvent>) => void | A custom event handler to send events to the machine. |
|
|
27
28
|
| [output](./foundation-state-machine.abstractmachine.output.md) | | any | Holds successful machine output if any. |
|
|
29
|
+
| [snapshot](./foundation-state-machine.abstractmachine.snapshot.md) | | State<TContext, TEvent, TActor, TResolvedTypesMeta> | The last <code>snapshot</code> from the actor. |
|
|
28
30
|
| [startingContext](./foundation-state-machine.abstractmachine.startingcontext.md) | | Partial<TContext> | The <code>context</code> of the machine when started. |
|
|
29
31
|
| [startingState](./foundation-state-machine.abstractmachine.startingstate.md) | | StateValue | The <code>state</code> of the machine when started. Allows consumers to start a machine from a persisted state. |
|
|
30
32
|
| [state](./foundation-state-machine.abstractmachine.state.md) | | StateValue | The current <code>state</code> of the machine itself. This is not to be confused with state in the data or store sense. |
|
|
@@ -35,6 +37,7 @@ export declare abstract class AbstractMachine<TContext extends MachineContext, T
|
|
|
35
37
|
| --- | --- | --- |
|
|
36
38
|
| [binding(token, subscriberChangeCallback, isVolatileBinding, context)](./foundation-state-machine.abstractmachine.binding.md) | | An api to allow the observation of values and arbitrary bindings outside the template engine. |
|
|
37
39
|
| [getFromContainer()](./foundation-state-machine.abstractmachine.getfromcontainer.md) | <code>abstract</code> | Gets the machine from the container. |
|
|
40
|
+
| [getMetaValuesByKey(key)](./foundation-state-machine.abstractmachine.getmetavaluesbykey.md) | | Get <code>meta</code> values by key. |
|
|
38
41
|
| [hasTag(tag)](./foundation-state-machine.abstractmachine.hastag.md) | | Check <code>tags</code> contain provided tag. |
|
|
39
42
|
| [matches(value)](./foundation-state-machine.abstractmachine.matches.md) | | Check <code>state</code> matches provided value. |
|
|
40
43
|
| [provide(implementations)](./foundation-state-machine.abstractmachine.provide.md) | | Recreate the internal machine with the provided implementations. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [AbstractMachine](./foundation-state-machine.abstractmachine.md) > [meta](./foundation-state-machine.abstractmachine.meta.md)
|
|
4
|
+
|
|
5
|
+
## AbstractMachine.meta property
|
|
6
|
+
|
|
7
|
+
The `meta` from the current `state`<!-- -->.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
meta: Record<string, any>;
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [AbstractMachine](./foundation-state-machine.abstractmachine.md) > [snapshot](./foundation-state-machine.abstractmachine.snapshot.md)
|
|
4
|
+
|
|
5
|
+
## AbstractMachine.snapshot property
|
|
6
|
+
|
|
7
|
+
The last `snapshot` from the actor.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
13
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [APIError](./foundation-state-machine.apierror.md) > [isUnauthorized](./foundation-state-machine.apierror.isunauthorized.md)
|
|
4
|
+
|
|
5
|
+
## APIError.isUnauthorized() method
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
**Signature:**
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
isUnauthorized(): boolean;
|
|
12
|
+
```
|
|
13
|
+
**Returns:**
|
|
14
|
+
|
|
15
|
+
boolean
|
|
16
|
+
|
|
@@ -30,3 +30,9 @@ Bad server `Response`<!-- -->.
|
|
|
30
30
|
| [data?](./foundation-state-machine.apierror.data.md) | | unknown | _(Optional)_ |
|
|
31
31
|
| [status](./foundation-state-machine.apierror.status.md) | | number | |
|
|
32
32
|
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
| Method | Modifiers | Description |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| [isUnauthorized()](./foundation-state-machine.apierror.isunauthorized.md) | | |
|
|
38
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [isEventWithParams](./foundation-state-machine.iseventwithparams.md)
|
|
4
|
+
|
|
5
|
+
## isEventWithParams variable
|
|
6
|
+
|
|
7
|
+
isEventWithParams.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
isEventWithParams: (event: AnyEventObject) => event is ParameterizedObject
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [isUnauthorizedError](./foundation-state-machine.isunauthorizederror.md)
|
|
4
|
+
|
|
5
|
+
## isUnauthorizedError variable
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
isUnauthorizedError: (error: {
|
|
11
|
+
status?: number;
|
|
12
|
+
}) => error is APIError
|
|
13
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [Machine](./foundation-state-machine.machine.md) > [getMetaValuesByKey](./foundation-state-machine.machine.getmetavaluesbykey.md)
|
|
4
|
+
|
|
5
|
+
## Machine.getMetaValuesByKey() method
|
|
6
|
+
|
|
7
|
+
Get `meta` values by key.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| key | string | _(Optional)_ A key within the <code>meta</code> object. Defaults to <code>content</code>. |
|
|
20
|
+
|
|
21
|
+
**Returns:**
|
|
22
|
+
|
|
23
|
+
T\[\]
|
|
24
|
+
|
|
25
|
+
## Remarks
|
|
26
|
+
|
|
27
|
+
Meta is cumulative across all state nodes represented by the state value.
|
|
28
|
+
|
|
@@ -80,7 +80,9 @@ this.myMachine.binding((x) => x.context.data, (value) => {
|
|
|
80
80
|
| [error](./foundation-state-machine.machine.error.md) | <code>readonly</code> | any | A general machine error. Likely equal to <code>errors.lastError</code>. |
|
|
81
81
|
| [errors](./foundation-state-machine.machine.errors.md) | <code>readonly</code> | ErrorMap<ErrorDetailMap> | An of errors that may have occurred during the machine's workflows. |
|
|
82
82
|
| [machine](./foundation-state-machine.machine.machine.md) | <code>readonly</code> | StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta> | Mandatory machine property. |
|
|
83
|
+
| [meta](./foundation-state-machine.machine.meta.md) | <code>readonly</code> | Record<string, any> | The <code>meta</code> from the current <code>state</code>. |
|
|
83
84
|
| [output](./foundation-state-machine.machine.output.md) | <code>readonly</code> | any | Holds successful machine output if any. |
|
|
85
|
+
| [snapshot](./foundation-state-machine.machine.snapshot.md) | <code>readonly</code> | State<TContext, TEvent, TActor, TResolvedTypesMeta> | The last <code>snapshot</code> from the actor. |
|
|
84
86
|
| [startingContext](./foundation-state-machine.machine.startingcontext.md) | <code>readonly</code> | Partial<TContext> | The <code>context</code> of the machine when started. |
|
|
85
87
|
| [startingState](./foundation-state-machine.machine.startingstate.md) | <code>readonly</code> | StateValue | The <code>state</code> of the machine when started. Allows consumers to start a machine from a persisted state. |
|
|
86
88
|
| [state](./foundation-state-machine.machine.state.md) | <code>readonly</code> | StateValue | The current <code>state</code> of the machine itself. This is not to be confused with state in the data or store sense. |
|
|
@@ -91,6 +93,7 @@ this.myMachine.binding((x) => x.context.data, (value) => {
|
|
|
91
93
|
| --- | --- |
|
|
92
94
|
| [binding(token, subscriberChangeCallback, isVolatileBinding, context)](./foundation-state-machine.machine.binding.md) | An api to allow the observation of values and arbitrary bindings outside the template engine. |
|
|
93
95
|
| [getFromContainer()](./foundation-state-machine.machine.getfromcontainer.md) | Gets the machine from the container. |
|
|
96
|
+
| [getMetaValuesByKey(key)](./foundation-state-machine.machine.getmetavaluesbykey.md) | Get <code>meta</code> values by key. |
|
|
94
97
|
| [hasTag(tag)](./foundation-state-machine.machine.hastag.md) | Check <code>tags</code> contain provided tag. |
|
|
95
98
|
| [matches(value)](./foundation-state-machine.machine.matches.md) | Check <code>state</code> matches provided value. |
|
|
96
99
|
| [onSendEvent(event)](./foundation-state-machine.machine.onsendevent.md) | A custom event handler to send events to the machine. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [Machine](./foundation-state-machine.machine.md) > [meta](./foundation-state-machine.machine.meta.md)
|
|
4
|
+
|
|
5
|
+
## Machine.meta property
|
|
6
|
+
|
|
7
|
+
The `meta` from the current `state`<!-- -->.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
readonly meta: Record<string, any>;
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-state-machine](./foundation-state-machine.md) > [Machine](./foundation-state-machine.machine.md) > [snapshot](./foundation-state-machine.machine.snapshot.md)
|
|
4
|
+
|
|
5
|
+
## Machine.snapshot property
|
|
6
|
+
|
|
7
|
+
The last `snapshot` from the actor.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
readonly snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
13
|
+
```
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
| [defaultResponseOkChecker](./foundation-state-machine.defaultresponseokchecker.md) | ResponseOkChecker type. |
|
|
51
51
|
| [defaultRetryStatsCodes](./foundation-state-machine.defaultretrystatscodes.md) | Default retry stats codes. |
|
|
52
52
|
| [errorWorkflowInput](./foundation-state-machine.errorworkflowinput.md) | Error workflow input. |
|
|
53
|
-
| [escalateError](./foundation-state-machine.escalateerror.md) | Escalate error action. |
|
|
53
|
+
| [escalateError](./foundation-state-machine.escalateerror.md) | Escalate context error action. |
|
|
54
54
|
| [isAbortError](./foundation-state-machine.isaborterror.md) | isAbortError. |
|
|
55
55
|
| [isActorErrorEvent](./foundation-state-machine.isactorerrorevent.md) | isActorErrorEvent. |
|
|
56
56
|
| [isAPIError](./foundation-state-machine.isapierror.md) | |
|
|
@@ -58,12 +58,14 @@
|
|
|
58
58
|
| [isErrorCustomEvent](./foundation-state-machine.iserrorcustomevent.md) | isErrorCustomEvent. |
|
|
59
59
|
| [isErrorEvent](./foundation-state-machine.iserrorevent.md) | isErrorEvent. |
|
|
60
60
|
| [isErrorType](./foundation-state-machine.iserrortype.md) | isErrorType. |
|
|
61
|
+
| [isEventWithParams](./foundation-state-machine.iseventwithparams.md) | isEventWithParams. |
|
|
61
62
|
| [isGenesisServerError](./foundation-state-machine.isgenesisservererror.md) | |
|
|
62
63
|
| [isMappingError](./foundation-state-machine.ismappingerror.md) | |
|
|
63
64
|
| [isNetworkError](./foundation-state-machine.isnetworkerror.md) | |
|
|
64
65
|
| [isNotFoundError](./foundation-state-machine.isnotfounderror.md) | |
|
|
65
66
|
| [isSyntaxError](./foundation-state-machine.issyntaxerror.md) | isSyntaxError. |
|
|
66
67
|
| [isTypeError](./foundation-state-machine.istypeerror.md) | isTypeError. |
|
|
68
|
+
| [isUnauthorizedError](./foundation-state-machine.isunauthorizederror.md) | |
|
|
67
69
|
| [logger](./foundation-state-machine.logger.md) | |
|
|
68
70
|
| [setError](./foundation-state-machine.seterror.md) | Set error action. |
|
|
69
71
|
| [setErrorByKey](./foundation-state-machine.seterrorbykey.md) | Set error by key action. |
|
package/docs/api-report.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { ActionArgs } from 'xstate';
|
|
10
10
|
import { AnyActorContext } from 'xstate';
|
|
11
11
|
import { AnyActorRef } from 'xstate';
|
|
12
|
-
import
|
|
12
|
+
import { AnyEventObject } from 'xstate';
|
|
13
13
|
import { AnyState } from 'xstate';
|
|
14
14
|
import { Assigner } from 'xstate';
|
|
15
15
|
import { BindingObserver } from '@microsoft/fast-element';
|
|
@@ -40,6 +40,7 @@ import type { ProvidedActor } from 'xstate';
|
|
|
40
40
|
import type { ResolveTypegenMeta } from 'xstate';
|
|
41
41
|
import { RetryPolicy } from 'cockatiel';
|
|
42
42
|
import { SendExpr } from 'xstate';
|
|
43
|
+
import type { State } from 'xstate';
|
|
43
44
|
import type { StateMachine } from 'xstate';
|
|
44
45
|
import type { StateNodeConfig } from 'xstate';
|
|
45
46
|
import type { StateValue } from 'xstate';
|
|
@@ -52,6 +53,8 @@ import { UnifiedArg } from 'xstate';
|
|
|
52
53
|
// @public
|
|
53
54
|
export abstract class AbstractMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TAction extends ParameterizedObject = ParameterizedObject, TActor extends ProvidedActor = ProvidedActor, TInput = any, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActor>> implements Machine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta> {
|
|
54
55
|
actor: InterpreterFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>;
|
|
56
|
+
// @internal (undocumented)
|
|
57
|
+
protected applySnapshot(snapshot?: typeof AbstractMachine.snapshot): void;
|
|
55
58
|
// Warning: (ae-incompatible-release-tags) The symbol "binding" is marked as @public, but its signature references "SubscriberChangeCallback" which is marked as @internal
|
|
56
59
|
binding<TReturn = any, TParent = any>(token: ((target: this) => TReturn) | keyof this, subscriberChangeCallback?: SubscriberChangeCallback<TReturn> | undefined, isVolatileBinding?: boolean, context?: ExecutionContext): BindingObserver<this, TReturn, TParent>;
|
|
57
60
|
complete: boolean;
|
|
@@ -61,15 +64,18 @@ export abstract class AbstractMachine<TContext extends MachineContext, TEvent ex
|
|
|
61
64
|
error: any;
|
|
62
65
|
errors: ErrorMap<ErrorDetailMap>;
|
|
63
66
|
abstract getFromContainer(): this;
|
|
67
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
64
68
|
hasTag(tag: string): boolean;
|
|
65
69
|
// @internal (undocumented)
|
|
66
70
|
protected interpret(options?: InterpreterOptions<typeof AbstractMachine.machine>): void;
|
|
67
71
|
machine: StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>;
|
|
68
72
|
matches(value: StateValueFrom<typeof AbstractMachine.machine>): boolean;
|
|
73
|
+
meta: Record<string, any>;
|
|
69
74
|
onSendEvent: (event: CustomEvent<TEvent>) => void;
|
|
70
75
|
output: any;
|
|
71
76
|
provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): void;
|
|
72
77
|
send(event: TEvent): void;
|
|
78
|
+
snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
73
79
|
start(options?: InterpreterOptions<typeof AbstractMachine.machine>): void;
|
|
74
80
|
// @internal (undocumented)
|
|
75
81
|
protected startActor(): void;
|
|
@@ -91,6 +97,8 @@ export class APIError extends Error {
|
|
|
91
97
|
// (undocumented)
|
|
92
98
|
data?: unknown;
|
|
93
99
|
// (undocumented)
|
|
100
|
+
isUnauthorized(): boolean;
|
|
101
|
+
// (undocumented)
|
|
94
102
|
status: number;
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -254,7 +262,7 @@ export const isAbortError: ({ event }: {
|
|
|
254
262
|
export const isActorErrorEvent: <TData = any>(actorId: string, event: EventObject | ErrorEvent_2<TData>) => event is ErrorEvent_2<TData>;
|
|
255
263
|
|
|
256
264
|
// @public (undocumented)
|
|
257
|
-
export const isAPIError: (error: unknown) =>
|
|
265
|
+
export const isAPIError: (error: unknown) => error is APIError;
|
|
258
266
|
|
|
259
267
|
// @public
|
|
260
268
|
export const isDoneInvokeEvent: <TData = any>(event: EventObject | DoneInvokeEvent<TData>) => event is DoneInvokeEvent<TData>;
|
|
@@ -268,19 +276,22 @@ export const isErrorEvent: <TData = any>(event: EventObject | ErrorEvent_2<TData
|
|
|
268
276
|
// @public
|
|
269
277
|
export const isErrorType: <TType extends ErrorConstructor>(type: TType) => (event: any) => boolean;
|
|
270
278
|
|
|
279
|
+
// @public
|
|
280
|
+
export const isEventWithParams: (event: AnyEventObject) => event is ParameterizedObject;
|
|
281
|
+
|
|
271
282
|
// @public (undocumented)
|
|
272
|
-
export const isGenesisServerError: (error: unknown) =>
|
|
283
|
+
export const isGenesisServerError: (error: unknown) => error is GenesisServerError;
|
|
273
284
|
|
|
274
285
|
// @public (undocumented)
|
|
275
|
-
export const isMappingError: (error: unknown) =>
|
|
286
|
+
export const isMappingError: (error: unknown) => error is MappingError;
|
|
276
287
|
|
|
277
288
|
// @public (undocumented)
|
|
278
|
-
export const isNetworkError: (error: unknown) =>
|
|
289
|
+
export const isNetworkError: (error: unknown) => error is NetworkError;
|
|
279
290
|
|
|
280
291
|
// @public (undocumented)
|
|
281
292
|
export const isNotFoundError: (error: {
|
|
282
293
|
status?: number;
|
|
283
|
-
}) =>
|
|
294
|
+
}) => error is APIError;
|
|
284
295
|
|
|
285
296
|
// @public
|
|
286
297
|
export const isSyntaxError: ({ event }: {
|
|
@@ -292,6 +303,11 @@ export const isTypeError: ({ event }: {
|
|
|
292
303
|
event: any;
|
|
293
304
|
}) => boolean;
|
|
294
305
|
|
|
306
|
+
// @public (undocumented)
|
|
307
|
+
export const isUnauthorizedError: (error: {
|
|
308
|
+
status?: number;
|
|
309
|
+
}) => error is APIError;
|
|
310
|
+
|
|
295
311
|
// @public (undocumented)
|
|
296
312
|
export const logger: Logger;
|
|
297
313
|
|
|
@@ -305,13 +321,16 @@ export interface Machine<TContext extends MachineContext, TEvent extends EventOb
|
|
|
305
321
|
readonly error: any;
|
|
306
322
|
readonly errors: ErrorMap<ErrorDetailMap>;
|
|
307
323
|
getFromContainer(): this;
|
|
324
|
+
getMetaValuesByKey<T = string>(key?: string): T[];
|
|
308
325
|
hasTag(tag: string): boolean;
|
|
309
326
|
readonly machine: StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>;
|
|
310
327
|
matches(value: StateValueFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>): boolean;
|
|
328
|
+
readonly meta: Record<string, any>;
|
|
311
329
|
onSendEvent(event: CustomEvent<TEvent>): void;
|
|
312
330
|
readonly output: any;
|
|
313
331
|
provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): void;
|
|
314
332
|
send(event: TEvent): void;
|
|
333
|
+
readonly snapshot: State<TContext, TEvent, TActor, TResolvedTypesMeta>;
|
|
315
334
|
start(options?: InterpreterOptions<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>): any;
|
|
316
335
|
readonly startingContext: Partial<TContext>;
|
|
317
336
|
readonly startingState: StateValue;
|
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": "14.
|
|
4
|
+
"version": "14.96.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"test": "genx test"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@genesislcap/foundation-testing": "14.
|
|
38
|
-
"@genesislcap/genx": "14.
|
|
37
|
+
"@genesislcap/foundation-testing": "14.96.0",
|
|
38
|
+
"@genesislcap/genx": "14.96.0",
|
|
39
39
|
"rimraf": "^3.0.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@genesislcap/foundation-comms": "14.
|
|
43
|
-
"@genesislcap/foundation-logger": "14.
|
|
44
|
-
"@genesislcap/foundation-utils": "14.
|
|
42
|
+
"@genesislcap/foundation-comms": "14.96.0",
|
|
43
|
+
"@genesislcap/foundation-logger": "14.96.0",
|
|
44
|
+
"@genesislcap/foundation-utils": "14.96.0",
|
|
45
45
|
"@microsoft/fast-element": "^1.7.0",
|
|
46
46
|
"@microsoft/fast-foundation": "^2.33.2",
|
|
47
47
|
"cockatiel": "^3.1.1",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "65b7a0ee750748ce8a8a5ac374e56fd50623118e"
|
|
61
61
|
}
|