@genesislcap/foundation-state-machine 14.70.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/README.md +26 -0
- package/dist/dts/core/actions.d.ts +61 -0
- package/dist/dts/core/actions.d.ts.map +1 -0
- package/dist/dts/core/binding.d.ts +37 -0
- package/dist/dts/core/binding.d.ts.map +1 -0
- package/dist/dts/core/errors.d.ts +41 -0
- package/dist/dts/core/errors.d.ts.map +1 -0
- package/dist/dts/core/guards.d.ts +67 -0
- package/dist/dts/core/guards.d.ts.map +1 -0
- package/dist/dts/core/index.d.ts +8 -0
- package/dist/dts/core/index.d.ts.map +1 -0
- package/dist/dts/core/inputs.d.ts +19 -0
- package/dist/dts/core/inputs.d.ts.map +1 -0
- package/dist/dts/core/machine.d.ts +338 -0
- package/dist/dts/core/machine.d.ts.map +1 -0
- package/dist/dts/core/state.d.ts +11 -0
- package/dist/dts/core/state.d.ts.map +1 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/index.federated.d.ts +1 -0
- package/dist/dts/index.federated.d.ts.map +1 -0
- package/dist/dts/machines/fetch/errors.d.ts +39 -0
- package/dist/dts/machines/fetch/errors.d.ts.map +1 -0
- package/dist/dts/machines/fetch/index.d.ts +5 -0
- package/dist/dts/machines/fetch/index.d.ts.map +1 -0
- package/dist/dts/machines/fetch/machine.d.ts +57 -0
- package/dist/dts/machines/fetch/machine.d.ts.map +1 -0
- package/dist/dts/machines/fetch/policies.d.ts +25 -0
- package/dist/dts/machines/fetch/policies.d.ts.map +1 -0
- package/dist/dts/machines/fetch/types.d.ts +118 -0
- package/dist/dts/machines/fetch/types.d.ts.map +1 -0
- package/dist/dts/machines/index.d.ts +2 -0
- package/dist/dts/machines/index.d.ts.map +1 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/dts/utils/index.d.ts +2 -0
- package/dist/dts/utils/index.d.ts.map +1 -0
- package/dist/dts/utils/logger.d.ts +5 -0
- package/dist/dts/utils/logger.d.ts.map +1 -0
- package/dist/esm/core/actions.js +46 -0
- package/dist/esm/core/binding.js +16 -0
- package/dist/esm/core/errors.js +70 -0
- package/dist/esm/core/guards.js +73 -0
- package/dist/esm/core/index.js +7 -0
- package/dist/esm/core/inputs.js +10 -0
- package/dist/esm/core/machine.js +180 -0
- package/dist/esm/core/state.js +26 -0
- package/dist/esm/index.federated.js +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/machines/fetch/errors.js +46 -0
- package/dist/esm/machines/fetch/index.js +4 -0
- package/dist/esm/machines/fetch/machine.js +216 -0
- package/dist/esm/machines/fetch/policies.js +48 -0
- package/dist/esm/machines/fetch/types.js +48 -0
- package/dist/esm/machines/index.js +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/logger.js +5 -0
- package/dist/foundation-state-machine.api.json +5594 -0
- package/dist/foundation-state-machine.d.ts +884 -0
- package/docs/.gitattributes +2 -0
- package/docs/api/foundation-state-machine.abstractmachine.actor.md +18 -0
- package/docs/api/foundation-state-machine.abstractmachine.binding.md +27 -0
- package/docs/api/foundation-state-machine.abstractmachine.complete.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.context.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.error.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.errors.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.getfromcontainer.md +23 -0
- package/docs/api/foundation-state-machine.abstractmachine.hastag.md +28 -0
- package/docs/api/foundation-state-machine.abstractmachine.machine.md +18 -0
- package/docs/api/foundation-state-machine.abstractmachine.matches.md +28 -0
- package/docs/api/foundation-state-machine.abstractmachine.md +44 -0
- package/docs/api/foundation-state-machine.abstractmachine.onsendevent.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.output.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.provide.md +24 -0
- package/docs/api/foundation-state-machine.abstractmachine.send.md +24 -0
- package/docs/api/foundation-state-machine.abstractmachine.start.md +28 -0
- package/docs/api/foundation-state-machine.abstractmachine.startingcontext.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.startingstate.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.state.md +13 -0
- package/docs/api/foundation-state-machine.abstractmachine.stop.md +17 -0
- package/docs/api/foundation-state-machine.apierror._constructor_.md +22 -0
- package/docs/api/foundation-state-machine.apierror.data.md +11 -0
- package/docs/api/foundation-state-machine.apierror.md +32 -0
- package/docs/api/foundation-state-machine.apierror.status.md +11 -0
- package/docs/api/foundation-state-machine.assertevent.md +27 -0
- package/docs/api/foundation-state-machine.createerrorstatenode.md +13 -0
- package/docs/api/foundation-state-machine.createfetchpolicy.md +18 -0
- package/docs/api/foundation-state-machine.createresponsedataextractorwithdeserializer.md +13 -0
- package/docs/api/foundation-state-machine.defaultfetchconfig.md +13 -0
- package/docs/api/foundation-state-machine.defaultfetchmachine._constructor_.md +20 -0
- package/docs/api/foundation-state-machine.defaultfetchmachine.getfromcontainer.md +23 -0
- package/docs/api/foundation-state-machine.defaultfetchmachine.md +30 -0
- package/docs/api/foundation-state-machine.defaultfetchmachine.start.md +28 -0
- package/docs/api/foundation-state-machine.defaultfetchmachinecontext.md +13 -0
- package/docs/api/foundation-state-machine.defaultfetchpolicy.md +13 -0
- package/docs/api/foundation-state-machine.defaultresponsedataextractor.md +18 -0
- package/docs/api/foundation-state-machine.defaultresponseokchecker.md +13 -0
- package/docs/api/foundation-state-machine.defaultretrystatscodes.md +13 -0
- package/docs/api/foundation-state-machine.errorworkflowinput.md +15 -0
- package/docs/api/foundation-state-machine.escalateerror.md +42 -0
- package/docs/api/foundation-state-machine.fetchconfig.fetcher.md +13 -0
- package/docs/api/foundation-state-machine.fetchconfig.fetchpolicy.md +13 -0
- package/docs/api/foundation-state-machine.fetchconfig.md +23 -0
- package/docs/api/foundation-state-machine.fetchconfig.responsedataextractor.md +13 -0
- package/docs/api/foundation-state-machine.fetchconfig.responseokchecker.md +13 -0
- package/docs/api/foundation-state-machine.fetchmachine.md +15 -0
- package/docs/api/foundation-state-machine.fetchmachinecontext.controller.md +13 -0
- package/docs/api/foundation-state-machine.fetchmachinecontext.data.md +13 -0
- package/docs/api/foundation-state-machine.fetchmachinecontext.md +28 -0
- package/docs/api/foundation-state-machine.fetchmachinecontext.params.md +17 -0
- package/docs/api/foundation-state-machine.fetchmachinecontext.response.md +13 -0
- package/docs/api/foundation-state-machine.fetchmachineevent.md +24 -0
- package/docs/api/foundation-state-machine.fetchmachineeventmap.md +21 -0
- package/docs/api/foundation-state-machine.fetchmachineoutput.md +21 -0
- package/docs/api/foundation-state-machine.genesisservererror._constructor_.md +22 -0
- package/docs/api/foundation-state-machine.genesisservererror.getdetailserror.md +15 -0
- package/docs/api/foundation-state-machine.genesisservererror.getmessageerror.md +15 -0
- package/docs/api/foundation-state-machine.genesisservererror.haserrorcode.md +22 -0
- package/docs/api/foundation-state-machine.genesisservererror.isignorableerror.md +17 -0
- package/docs/api/foundation-state-machine.genesisservererror.md +41 -0
- package/docs/api/foundation-state-machine.genesisservererror.received.md +11 -0
- package/docs/api/foundation-state-machine.genesisservererror.sent.md +11 -0
- package/docs/api/foundation-state-machine.isaborterror.md +15 -0
- package/docs/api/foundation-state-machine.isactorerrorevent.md +13 -0
- package/docs/api/foundation-state-machine.isapierror.md +11 -0
- package/docs/api/foundation-state-machine.isdoneinvokeevent.md +13 -0
- package/docs/api/foundation-state-machine.iserrorcustomevent.md +18 -0
- package/docs/api/foundation-state-machine.iserrorevent.md +13 -0
- package/docs/api/foundation-state-machine.iserrortype.md +13 -0
- package/docs/api/foundation-state-machine.isgenesisservererror.md +11 -0
- package/docs/api/foundation-state-machine.ismappingerror.md +11 -0
- package/docs/api/foundation-state-machine.isnetworkerror.md +11 -0
- package/docs/api/foundation-state-machine.isnotfounderror.md +13 -0
- package/docs/api/foundation-state-machine.issyntaxerror.md +15 -0
- package/docs/api/foundation-state-machine.istypeerror.md +15 -0
- package/docs/api/foundation-state-machine.logger.md +12 -0
- package/docs/api/foundation-state-machine.machine.actor.md +18 -0
- package/docs/api/foundation-state-machine.machine.binding.md +47 -0
- package/docs/api/foundation-state-machine.machine.complete.md +13 -0
- package/docs/api/foundation-state-machine.machine.context.md +13 -0
- package/docs/api/foundation-state-machine.machine.error.md +13 -0
- package/docs/api/foundation-state-machine.machine.errors.md +13 -0
- package/docs/api/foundation-state-machine.machine.getfromcontainer.md +35 -0
- package/docs/api/foundation-state-machine.machine.hastag.md +35 -0
- package/docs/api/foundation-state-machine.machine.machine.md +18 -0
- package/docs/api/foundation-state-machine.machine.matches.md +35 -0
- package/docs/api/foundation-state-machine.machine.md +101 -0
- package/docs/api/foundation-state-machine.machine.onsendevent.md +24 -0
- package/docs/api/foundation-state-machine.machine.output.md +13 -0
- package/docs/api/foundation-state-machine.machine.provide.md +44 -0
- package/docs/api/foundation-state-machine.machine.send.md +24 -0
- package/docs/api/foundation-state-machine.machine.start.md +28 -0
- package/docs/api/foundation-state-machine.machine.startingcontext.md +13 -0
- package/docs/api/foundation-state-machine.machine.startingstate.md +13 -0
- package/docs/api/foundation-state-machine.machine.state.md +13 -0
- package/docs/api/foundation-state-machine.machine.stop.md +17 -0
- package/docs/api/foundation-state-machine.machinecontext.error.md +13 -0
- package/docs/api/foundation-state-machine.machinecontext.errors.md +13 -0
- package/docs/api/foundation-state-machine.machinecontext.md +36 -0
- package/docs/api/foundation-state-machine.mappingerror._constructor_.md +21 -0
- package/docs/api/foundation-state-machine.mappingerror.dto.md +11 -0
- package/docs/api/foundation-state-machine.mappingerror.md +27 -0
- package/docs/api/foundation-state-machine.md +81 -0
- package/docs/api/foundation-state-machine.networkerror._constructor_.md +21 -0
- package/docs/api/foundation-state-machine.networkerror.md +31 -0
- package/docs/api/foundation-state-machine.networkerror.url.md +11 -0
- package/docs/api/foundation-state-machine.responsedataextractor.md +18 -0
- package/docs/api/foundation-state-machine.responseokchecker.md +13 -0
- package/docs/api/foundation-state-machine.seterror.md +25 -0
- package/docs/api/foundation-state-machine.seterrorbykey.md +25 -0
- package/docs/api/index.md +12 -0
- package/docs/api-report.md +393 -0
- package/license.txt +46 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Foundation State Machine
|
|
2
|
+
|
|
3
|
+
[](https://lerna.js.org/)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
|
|
6
|
+
State machines in `foundation-ui` are built upon the [xState](https://github.com/statelyai/xstate) v5+ library and provide bindable properties and other hooks. `foundation-state-machine` provides a collection of pre-built state machines and utilities to build your own machines.
|
|
7
|
+
|
|
8
|
+
For details on how machines work see the API Docs and the v5+ version of the [xstate docs](https://stately.ai/docs/xstate-v5).
|
|
9
|
+
|
|
10
|
+
### [API Docs](./docs/api/index.md)
|
|
11
|
+
|
|
12
|
+
### Pre-built state machines
|
|
13
|
+
|
|
14
|
+
Overtime this package will provide a number of pre-built machines that offer common functionality. Visit their README files and API Docs for more information.
|
|
15
|
+
|
|
16
|
+
* [FetchMachine](./src/machines/fetch/README.md)
|
|
17
|
+
* ...
|
|
18
|
+
|
|
19
|
+
Domain focused machines like `AuthMachine` will live in different packages.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
Note: this project provides front end dependencies and uses licensed components listed in the next section, thus licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
|
|
24
|
+
|
|
25
|
+
### Licensed components
|
|
26
|
+
Genesis low-code platform
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set error action.
|
|
3
|
+
* @remarks
|
|
4
|
+
* Used to set a top level error on the machine. This may equal to {@link @genesislcap/foundation-utils#ErrorMap} `lastError` in the `errors` property.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const setError: {
|
|
8
|
+
(_: import("xstate").ActionArgs<import("xstate").MachineContext, import("xstate").EventObject, import("xstate").ParameterizedObject>): void;
|
|
9
|
+
type: string;
|
|
10
|
+
assignment: import("xstate").Assigner<import("xstate").MachineContext, import("xstate").EventObject> | import("xstate").PropertyAssigner<import("xstate").MachineContext, import("xstate").EventObject>;
|
|
11
|
+
resolve: (actorContext: import("xstate").AnyActorContext, state: import("xstate").AnyState, actionArgs: import("xstate").ActionArgs<any, any, import("xstate").ParameterizedObject>, { assignment }: {
|
|
12
|
+
assignment: import("xstate").Assigner<any, any> | import("xstate").PropertyAssigner<any, any>;
|
|
13
|
+
}) => import("xstate").AnyState[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Set error by key action.
|
|
17
|
+
* @remarks
|
|
18
|
+
* Used to set an error in the {@link @genesislcap/foundation-utils#ErrorMap} by key.
|
|
19
|
+
* @param key - The error key.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const setErrorByKey: (key: string) => {
|
|
23
|
+
(_: import("xstate").ActionArgs<import("xstate").MachineContext, import("xstate").EventObject, import("xstate").ParameterizedObject>): void;
|
|
24
|
+
type: string;
|
|
25
|
+
assignment: import("xstate").Assigner<import("xstate").MachineContext, import("xstate").EventObject> | import("xstate").PropertyAssigner<import("xstate").MachineContext, import("xstate").EventObject>;
|
|
26
|
+
resolve: (actorContext: import("xstate").AnyActorContext, state: import("xstate").AnyState, actionArgs: import("xstate").ActionArgs<any, any, import("xstate").ParameterizedObject>, { assignment }: {
|
|
27
|
+
assignment: import("xstate").Assigner<any, any> | import("xstate").PropertyAssigner<any, any>;
|
|
28
|
+
}) => import("xstate").AnyState[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Escalate error action.
|
|
32
|
+
* @remarks
|
|
33
|
+
* Guard this call with a parent check to avoid warnings when there's no parent.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare const escalateError: {
|
|
37
|
+
(_: import("xstate").ActionArgs<import("xstate").MachineContext, import("xstate").EventObject, import("xstate").ParameterizedObject>): void;
|
|
38
|
+
type: string;
|
|
39
|
+
to: string | import("xstate").AnyActorRef | ((args: import("xstate").UnifiedArg<import("xstate").MachineContext, import("xstate").EventObject>) => string | import("xstate").AnyActorRef);
|
|
40
|
+
event: any;
|
|
41
|
+
id: string;
|
|
42
|
+
delay: string | number | import("xstate").DelayExpr<import("xstate").MachineContext, import("xstate").EventObject>;
|
|
43
|
+
resolve: (actorContext: import("xstate").AnyActorContext, state: import("xstate").AnyState, args: import("xstate").ActionArgs<any, any, import("xstate").ParameterizedObject>, { to, event: eventOrExpr, id, delay }: {
|
|
44
|
+
to: string | import("xstate").AnyActorRef | ((args: import("xstate").UnifiedArg<import("xstate").MachineContext, import("xstate").EventObject>) => string | import("xstate").AnyActorRef);
|
|
45
|
+
event: import("xstate").EventObject | import("xstate").SendExpr<import("xstate").MachineContext, import("xstate").EventObject, import("xstate").EventObject>;
|
|
46
|
+
id: string;
|
|
47
|
+
delay: string | number | import("xstate").DelayExpr<import("xstate").MachineContext, import("xstate").EventObject>;
|
|
48
|
+
}) => (import("xstate").AnyState | {
|
|
49
|
+
to: import("xstate").AnyActorRef;
|
|
50
|
+
event: import("xstate").EventObject;
|
|
51
|
+
id: string;
|
|
52
|
+
delay: number;
|
|
53
|
+
})[];
|
|
54
|
+
execute: (actorContext: import("xstate").AnyActorContext, params: {
|
|
55
|
+
to: import("xstate").AnyActorRef;
|
|
56
|
+
event: import("xstate").EventObject;
|
|
57
|
+
id: string;
|
|
58
|
+
delay: number;
|
|
59
|
+
}) => void;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/core/actions.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAOnB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM;;;;;;;CASrC,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;CAGvB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BindingObserver, ExecutionContext } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* @typeParam TReturn - The return type.
|
|
4
|
+
* @param value - The bound value.
|
|
5
|
+
* @param args - A binding observer.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export type SubscriberChangeCallback<TReturn = any> = (value: TReturn, args: BindingObserver) => void;
|
|
9
|
+
/**
|
|
10
|
+
* @typeParam TTarget - The target interface.
|
|
11
|
+
* @typeParam TReturn - The return type.
|
|
12
|
+
* @param binding - A binding.
|
|
13
|
+
* @param args - A binding observer.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export type SubscriberChangeHandler<TTarget = any, TReturn = any> = (binding: (x?: TTarget, context?: ExecutionContext) => TReturn, args: BindingObserver) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @typeParam TTarget - The target interface.
|
|
19
|
+
* @typeParam TReturn - The return type.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export interface TargetSubscriber<TTarget = any, TReturn = any> {
|
|
23
|
+
handleChange: SubscriberChangeHandler<TTarget, TReturn>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @typeParam TTarget - The target interface.
|
|
27
|
+
* @param target - The target.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export type TargetBinding<TTarget = any> = (target: TTarget) => any;
|
|
31
|
+
/**
|
|
32
|
+
* @typeParam TTarget - The target interface.
|
|
33
|
+
* @param args - Binding args.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare const getBindArgs: <TTarget = any>(...args: unknown[]) => TargetBinding<TTarget>;
|
|
37
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../src/core/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,CAAC,OAAO,GAAG,GAAG,IAAI,CACpD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;AAEV;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,CAClE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,EAC7D,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;AAEV;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG;IAC5D,YAAY,EAAE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,GAAG,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,WAAW,2BAA4B,OAAO,EAAE,2BAS5D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Message } from '@genesislcap/foundation-comms';
|
|
2
|
+
/**
|
|
3
|
+
* GenesisServerError.
|
|
4
|
+
* @remarks
|
|
5
|
+
* Represents an error received from a Genesis Server.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class GenesisServerError extends Error {
|
|
9
|
+
sent?: Message;
|
|
10
|
+
received?: Message;
|
|
11
|
+
constructor(sent?: Message, received?: Message, message?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Capture known edge cases.
|
|
14
|
+
* @privateRemarks
|
|
15
|
+
* This is ugly, lets figure out if this is still an issue and remove if not.
|
|
16
|
+
*/
|
|
17
|
+
isIgnorableError(): boolean;
|
|
18
|
+
getMessageError(): string;
|
|
19
|
+
getDetailsError(): string;
|
|
20
|
+
hasErrorCode(code: string): boolean;
|
|
21
|
+
private errorDetailFormatter;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param error - An error.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const isGenesisServerError: (error: unknown) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* MappingError.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare class MappingError extends Error {
|
|
33
|
+
dto?: unknown;
|
|
34
|
+
constructor(dto?: unknown, message?: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param error - An error.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare const isMappingError: (error: unknown) => boolean;
|
|
41
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAElC,IAAI,CAAC,EAAE,OAAO;IACd,QAAQ,CAAC,EAAE,OAAO;gBADlB,IAAI,CAAC,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,OAAO,EACzB,OAAO,GAAE,MAAwC;IAOnD;;;;OAIG;IACH,gBAAgB;IAUhB,eAAe;IAMf,eAAe,IAAI,MAAM;IAMzB,YAAY,CAAC,IAAI,EAAE,MAAM;IAMzB,OAAO,CAAC,oBAAoB;CAG7B;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAW,OAAO,YAAwC,CAAC;AAE5F;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAE5B,GAAG,CAAC,EAAE,OAAO;gBAAb,GAAG,CAAC,EAAE,OAAO,EACpB,OAAO,GAAE,MAAiC;CAM7C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,YAAkC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DoneInvokeEvent, ErrorEvent, EventObject } from 'xstate';
|
|
2
|
+
/**
|
|
3
|
+
* assertEvent.
|
|
4
|
+
* @privateRemarks
|
|
5
|
+
* Note `asserts` need to be functions to work.
|
|
6
|
+
* @param event - An event.
|
|
7
|
+
* @param type - An event type.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertEvent<TEvent extends EventObject = EventObject>(event: TEvent, type: TEvent['type']): asserts event is Extract<TEvent, {
|
|
11
|
+
type: TEvent['type'];
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* isDoneInvokeEvent.
|
|
15
|
+
* @param event - An event.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const isDoneInvokeEvent: <TData = any>(event: EventObject | DoneInvokeEvent<TData>) => event is DoneInvokeEvent<TData>;
|
|
19
|
+
/**
|
|
20
|
+
* isErrorEvent.
|
|
21
|
+
* @param event - An event.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const isErrorEvent: <TData = any>(event: EventObject | ErrorEvent<TData>) => event is ErrorEvent<TData>;
|
|
25
|
+
/**
|
|
26
|
+
* isErrorCustomEvent.
|
|
27
|
+
* @remarks
|
|
28
|
+
* What `escalate` from a child is typed as.
|
|
29
|
+
* @param event - An event.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare const isErrorCustomEvent: <TData = any>(event: EventObject | ErrorEvent<TData>) => event is ErrorEvent<TData>;
|
|
33
|
+
/**
|
|
34
|
+
* isActorErrorEvent.
|
|
35
|
+
* @param actorId - An actor id.
|
|
36
|
+
* @param event - An event.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const isActorErrorEvent: <TData = any>(actorId: string, event: EventObject | ErrorEvent<TData>) => event is ErrorEvent<TData>;
|
|
40
|
+
/**
|
|
41
|
+
* isErrorType.
|
|
42
|
+
* @param type - An event type.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare const isErrorType: <TType extends ErrorConstructor>(type: TType) => (event: any) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* isTypeError.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare const isTypeError: ({ event }: {
|
|
51
|
+
event: any;
|
|
52
|
+
}) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* isSyntaxError.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare const isSyntaxError: ({ event }: {
|
|
58
|
+
event: any;
|
|
59
|
+
}) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* isAbortError.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export declare const isAbortError: ({ event }: {
|
|
65
|
+
event: any;
|
|
66
|
+
}) => boolean;
|
|
67
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../../src/core/guards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAElE;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,WAAW,GAAG,WAAW,EAClE,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,GACnB,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAI5D;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,+FAEuC,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,YAAY,qFAE0C,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,qFAEkC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,yBACnB,MAAM,uEAE8E,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,WAAW,0EAOrB,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW;;aAA+C,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,aAAa;;aAAiD,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,YAAY;;aAQxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ErrorDetailMap, ErrorMap } from '@genesislcap/foundation-utils';
|
|
2
|
+
/**
|
|
3
|
+
* ErrorWorkflowInput type.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type ErrorWorkflowInput = {
|
|
7
|
+
errorKey: string;
|
|
8
|
+
errorValue: any;
|
|
9
|
+
errorMap: ErrorMap<ErrorDetailMap>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Error workflow input.
|
|
13
|
+
* @param key - An error key.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare const errorWorkflowInput: (key: string) => ({ context }: {
|
|
17
|
+
context: any;
|
|
18
|
+
}) => ErrorWorkflowInput;
|
|
19
|
+
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/core/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QACvB,MAAM;;MACG,kBAIb,CAAC"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { ErrorDetailMap, ErrorMap } from '@genesislcap/foundation-utils';
|
|
2
|
+
import { BindingObserver, ExecutionContext } from '@microsoft/fast-element';
|
|
3
|
+
import { Container } from '@microsoft/fast-foundation';
|
|
4
|
+
import type { AnyEventObject, EventObject, InternalMachineImplementations, InterpreterFrom, InterpreterOptions, MachineContext as XMachineContext, NoInfer, ParameterizedObject, ProvidedActor, ResolveTypegenMeta, StateMachine, StateValue, StateValueFrom, TypegenDisabled } from 'xstate';
|
|
5
|
+
import { SubscriberChangeCallback } from './binding';
|
|
6
|
+
/**
|
|
7
|
+
* MachineContext interface.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The interface of our xstate based machine contexts that include `error` and `errors` properties. Should be extended.
|
|
11
|
+
*
|
|
12
|
+
* @example Creating a machine context.
|
|
13
|
+
* ```ts
|
|
14
|
+
* export interface MyMachineContext extends MachineContext {
|
|
15
|
+
* ...
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface MachineContext extends XMachineContext {
|
|
22
|
+
/**
|
|
23
|
+
* A `ErrorMap` of errors that may have occurred during the machine's workflows.
|
|
24
|
+
*/
|
|
25
|
+
readonly errors: ErrorMap<ErrorDetailMap>;
|
|
26
|
+
/**
|
|
27
|
+
* A general machine error. Maybe equal to `errors.lastError`.
|
|
28
|
+
*/
|
|
29
|
+
readonly error: any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Machine interface.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* The interface of our xstate based machines or logic workflows. These contain bindable properties for convenience.
|
|
36
|
+
* Should be extended.
|
|
37
|
+
*
|
|
38
|
+
* @example Creating a machine in the DI.
|
|
39
|
+
* ```ts
|
|
40
|
+
* export interface MyMachine extends Machine<MyMachineContext, MyMachineEvent> {
|
|
41
|
+
* readonly service: MyService;
|
|
42
|
+
* ...
|
|
43
|
+
* }
|
|
44
|
+
* export class DefaultMyMachine
|
|
45
|
+
* extends AbstractMachine<MyMachineContext, MyMachineEvent>
|
|
46
|
+
* implements MyMachine
|
|
47
|
+
* {
|
|
48
|
+
* constructor(@MyService readonly service: MyService) {
|
|
49
|
+
* super();
|
|
50
|
+
* this.machine = createMachine<MyMachineContext, MyMachineEvent>(...);
|
|
51
|
+
* this.start(); // < Call now or later to ready the machine.
|
|
52
|
+
* }
|
|
53
|
+
* start(
|
|
54
|
+
* options: InterpreterOptions<typeof this.machine> = {
|
|
55
|
+
* input: myDefaultContext,
|
|
56
|
+
* },
|
|
57
|
+
* ) {
|
|
58
|
+
* super.start(options);
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* // Whether the machine should be `transient` or a `singleton` probably depends on the use case and if it contains a `final` state.
|
|
62
|
+
* export const MyMachine = DI.createInterface<MyMachine>((x) => x.transient(DefaultMyMachine));
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Machines are bindable from templates and other logic.
|
|
66
|
+
*
|
|
67
|
+
* @example Surface errors in a template.
|
|
68
|
+
* ```ts
|
|
69
|
+
* ${when(
|
|
70
|
+
* (x) => !!x.myMachine.errors.size,
|
|
71
|
+
* html<MyComponent>`
|
|
72
|
+
* <span>${(x) => x.myMachine.errors.messages}</span>
|
|
73
|
+
* `,
|
|
74
|
+
* )}
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example Use context data in a class.
|
|
78
|
+
* ```ts
|
|
79
|
+
* this.myMachine.binding((x) => x.context.data, (value) => {
|
|
80
|
+
* // use data
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export interface Machine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TAction extends ParameterizedObject = ParameterizedObject, TActor extends ProvidedActor = ProvidedActor, TInput = any, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActor>> {
|
|
87
|
+
/**
|
|
88
|
+
* Mandatory machine property.
|
|
89
|
+
* @remarks
|
|
90
|
+
* The logic / config that goes into a machine is not accessible from the outside, and is owned by the implementing
|
|
91
|
+
* class. However, consumers of that may provide custom `implementations` in the xstate sense via the `provide()` api.
|
|
92
|
+
*/
|
|
93
|
+
readonly machine: StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>;
|
|
94
|
+
/**
|
|
95
|
+
* Optional actor
|
|
96
|
+
* @remarks
|
|
97
|
+
* Callers can decide to reuse/reference if set or create their own.
|
|
98
|
+
*/
|
|
99
|
+
readonly actor?: InterpreterFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>;
|
|
100
|
+
/**
|
|
101
|
+
* The current `state` of the machine itself. This is not to be confused with state in the data or store sense.
|
|
102
|
+
*/
|
|
103
|
+
readonly state: StateValue;
|
|
104
|
+
/**
|
|
105
|
+
* The `state` of the machine when started. Allows consumers to start a machine from a persisted state.
|
|
106
|
+
*/
|
|
107
|
+
readonly startingState: StateValue;
|
|
108
|
+
/**
|
|
109
|
+
* The current `context` of the machine. The data points in context may be considered transient in nature.
|
|
110
|
+
*
|
|
111
|
+
* @privateRemarks
|
|
112
|
+
* Review the possibility of using an object with `@observable` properties as `context`, such as a store fragment or class.
|
|
113
|
+
*/
|
|
114
|
+
readonly context: Partial<TContext>;
|
|
115
|
+
/**
|
|
116
|
+
* The `context` of the machine when started.
|
|
117
|
+
*/
|
|
118
|
+
readonly startingContext: Partial<TContext>;
|
|
119
|
+
/**
|
|
120
|
+
* Indicates if the machine has completed the happy path.
|
|
121
|
+
*/
|
|
122
|
+
readonly complete: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Holds successful machine output if any.
|
|
125
|
+
*/
|
|
126
|
+
readonly output: any;
|
|
127
|
+
/**
|
|
128
|
+
* An {@link @genesislcap/foundation-utils#ErrorMap | ErrorMap} of errors that may have occurred during the machine's workflows.
|
|
129
|
+
*/
|
|
130
|
+
readonly errors: ErrorMap<ErrorDetailMap>;
|
|
131
|
+
/**
|
|
132
|
+
* A general machine error. Likely equal to `errors.lastError`.
|
|
133
|
+
*/
|
|
134
|
+
readonly error: any;
|
|
135
|
+
/**
|
|
136
|
+
* Start the machine.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* Called to ready the machine and create the internal actor (interpreter). This is called internally after
|
|
140
|
+
* `createMachine` by convention, however it should also be called after calling {@link Machine.provide | provide}
|
|
141
|
+
* when overriding logic. Calling `start` on an injected machine allows you to restart/reuse it if needed. This is okay
|
|
142
|
+
* for machines registered as `transient` in the DI, but care should be taken when creating a machine registered as a
|
|
143
|
+
* `singleton`. You may need to check the status of the machine and block re-starts.
|
|
144
|
+
*
|
|
145
|
+
* @param options - Optional InterpreterOptions. Can be used to restore to a previously persisted state.
|
|
146
|
+
*/
|
|
147
|
+
start(options?: InterpreterOptions<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>): any;
|
|
148
|
+
/**
|
|
149
|
+
* Stop the machine.
|
|
150
|
+
*/
|
|
151
|
+
stop(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Recreate the internal machine with the provided implementations.
|
|
154
|
+
*
|
|
155
|
+
* @example Using an existing machine with a custom implementation.
|
|
156
|
+
* ```ts
|
|
157
|
+
* @MyMachine readonly machine: MyMachine;
|
|
158
|
+
* ...
|
|
159
|
+
* this.machine.provide({
|
|
160
|
+
* actors: {
|
|
161
|
+
* serviceCallX: fromPromise(async ({ input }) => Promise.resolve(new Error('Overridden serviceCallX'))),
|
|
162
|
+
* onSuccess: (context) => successHandlerInHost(context.data)
|
|
163
|
+
* },
|
|
164
|
+
* guards: {
|
|
165
|
+
* isAssured: ({ context }) => true,
|
|
166
|
+
* },
|
|
167
|
+
* });
|
|
168
|
+
* // When you change the machine it will stop if running, so you'll have to call {@link Machine.start | start} again.
|
|
169
|
+
* this.machine.start();
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @param implementations - `actions`, `guards`, `actors`... to merge with existing options.
|
|
173
|
+
*/
|
|
174
|
+
provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): void;
|
|
175
|
+
/**
|
|
176
|
+
* Check `state` matches provided value.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* Can be useful if you need to conditionally run logic or render markup.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* if (machine.matches('inactive')) { ... }
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @param value - A state value.
|
|
187
|
+
*/
|
|
188
|
+
matches(value: StateValueFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Check `tags` contain provided tag.
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* This differs from `matches`, as multiple states may use common tags such as `pending` to indicate some async work
|
|
194
|
+
* is occurring. As with `matches`, `hasTag` can be useful if you need to conditionally run logic or render markup.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* if (machine.hasTag('pending')) { ... }
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @param tag - A tag.
|
|
202
|
+
*/
|
|
203
|
+
hasTag(tag: string): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* An api to send events to the machine.
|
|
206
|
+
*
|
|
207
|
+
* @param event - An event.
|
|
208
|
+
*/
|
|
209
|
+
send(event: TEvent): void;
|
|
210
|
+
/**
|
|
211
|
+
* A custom event handler to send events to the machine.
|
|
212
|
+
*
|
|
213
|
+
* @param event - A custom event.
|
|
214
|
+
*/
|
|
215
|
+
onSendEvent(event: CustomEvent<TEvent>): void;
|
|
216
|
+
/**
|
|
217
|
+
* An api to allow the observation of values and arbitrary bindings outside the template engine.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* TS attains the value type information from the machine's interface.
|
|
221
|
+
* ```ts
|
|
222
|
+
* this.myMachine.binding(x => x.context.data, value => {...}); // value is typeof data
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* You can also use the underlying BindingObserver api should you prefer.
|
|
227
|
+
* ```ts
|
|
228
|
+
* this.myMachine.binding(x => x.error).subscribe({
|
|
229
|
+
* handleChange(binding, args) {
|
|
230
|
+
* ...
|
|
231
|
+
* }
|
|
232
|
+
* })
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @param token - A target lookup token which can take various forms.
|
|
236
|
+
* @param subscriberChangeCallback - {@link SubscriberChangeCallback}.
|
|
237
|
+
* @param isVolatileBinding - Indicates the binding is volatile.
|
|
238
|
+
* @param context - {@link @microsoft/fast-element#ExecutionContext}.
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
binding<TReturn = any, TParent = any>(token: ((target: this) => TReturn) | keyof this, subscriberChangeCallback?: SubscriberChangeCallback<TReturn> | undefined, isVolatileBinding?: boolean, context?: ExecutionContext): BindingObserver<this, TReturn, TParent>;
|
|
243
|
+
/**
|
|
244
|
+
* Gets the machine from the container.
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* Calling `getFromContainer` on an injected machine will return a new instance providing it was registered with the
|
|
248
|
+
* DI as `transient`. This is simply a convenience method, and may be useful as some machines contain 'final' states,
|
|
249
|
+
* meaning once they complete they can no longer receive events. However, if you want to continue to work with your
|
|
250
|
+
* injected machine reference, re-calling {@link Machine.start | start} may also be a viable option.
|
|
251
|
+
*
|
|
252
|
+
* Please note that machines are injected into other machines to form parts of complex workflows. In such cases,
|
|
253
|
+
* the parent machine will `invoke` or `spawn` the injected machine's `logic` directly to always create a new actor.
|
|
254
|
+
*
|
|
255
|
+
* @example Invoke an injected machine's `logic` from a parent machine
|
|
256
|
+
* ```ts
|
|
257
|
+
* invoke: {
|
|
258
|
+
* id: 'dataFetcher',
|
|
259
|
+
* src: fetchMachine.machine, // < Or `src: 'fetcher'`, and create that actor to interact with the injected machine.
|
|
260
|
+
* ...
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
getFromContainer(): this;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* AbstractMachine base class.
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
export declare 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> {
|
|
271
|
+
/**
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
protected container: Container;
|
|
275
|
+
/** {@inheritDoc Machine.machine} */
|
|
276
|
+
machine: StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>;
|
|
277
|
+
/** {@inheritDoc Machine.actor} */
|
|
278
|
+
actor: InterpreterFrom<StateMachine<TContext, TEvent, TAction, TActor, TInput, TResolvedTypesMeta>>;
|
|
279
|
+
/** {@inheritDoc Machine.state} */
|
|
280
|
+
state: StateValue;
|
|
281
|
+
/** {@inheritDoc Machine.startingState} */
|
|
282
|
+
startingState: StateValue;
|
|
283
|
+
/** {@inheritDoc Machine.context} */
|
|
284
|
+
context: Partial<TContext>;
|
|
285
|
+
/** {@inheritDoc Machine.startingContext} */
|
|
286
|
+
startingContext: Partial<TContext>;
|
|
287
|
+
/** {@inheritDoc Machine.complete} */
|
|
288
|
+
complete: boolean;
|
|
289
|
+
/** {@inheritDoc Machine.output} */
|
|
290
|
+
output: any;
|
|
291
|
+
/** {@inheritDoc Machine.errors} */
|
|
292
|
+
errors: ErrorMap<ErrorDetailMap>;
|
|
293
|
+
/** {@inheritDoc Machine.error} */
|
|
294
|
+
error: any;
|
|
295
|
+
/**
|
|
296
|
+
* @internal
|
|
297
|
+
*/
|
|
298
|
+
private subscription;
|
|
299
|
+
/** {@inheritDoc Machine.start} */
|
|
300
|
+
start(options?: InterpreterOptions<typeof this.machine>): void;
|
|
301
|
+
/** {@inheritDoc Machine.stop} */
|
|
302
|
+
stop(): void;
|
|
303
|
+
/**
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
protected interpret(options?: InterpreterOptions<typeof this.machine>): void;
|
|
307
|
+
/**
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
protected subscribe(): void;
|
|
311
|
+
/**
|
|
312
|
+
* @internal
|
|
313
|
+
*/
|
|
314
|
+
protected unsubscribe(): void;
|
|
315
|
+
/**
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
protected startActor(): void;
|
|
319
|
+
/**
|
|
320
|
+
* @internal
|
|
321
|
+
*/
|
|
322
|
+
protected stopActor(): void;
|
|
323
|
+
/** {@inheritDoc Machine.provide} */
|
|
324
|
+
provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): void;
|
|
325
|
+
/** {@inheritDoc Machine.matches} */
|
|
326
|
+
matches(value: StateValueFrom<typeof this.machine>): boolean;
|
|
327
|
+
/** {@inheritDoc Machine.hasTag} */
|
|
328
|
+
hasTag(tag: string): boolean;
|
|
329
|
+
/** {@inheritDoc Machine.send} */
|
|
330
|
+
send(event: TEvent): void;
|
|
331
|
+
/** {@inheritDoc Machine.onSendEvent} */
|
|
332
|
+
onSendEvent: (event: CustomEvent<TEvent>) => void;
|
|
333
|
+
/** {@inheritDoc Machine.binding} */
|
|
334
|
+
binding<TReturn = any, TParent = any>(token: ((target: this) => TReturn) | keyof this, subscriberChangeCallback?: SubscriberChangeCallback<TReturn> | undefined, isVolatileBinding?: boolean, context?: ExecutionContext): BindingObserver<this, TReturn, TParent>;
|
|
335
|
+
/** {@inheritDoc Machine.getFromContainer} */
|
|
336
|
+
abstract getFromContainer(): this;
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/core/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EACL,eAAe,EAEf,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,8BAA8B,EAC9B,eAAe,EACf,kBAAkB,EAClB,cAAc,IAAI,eAAe,EACjC,OAAO,EACP,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,cAAc,EAEd,eAAe,EAChB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAe,wBAAwB,EAAoB,MAAM,WAAW,CAAC;AAEpF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC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
|
+
* Creates an error state node.
|
|
4
|
+
*
|
|
5
|
+
* @param key - An error state key.
|
|
6
|
+
* @param metaContent - An optional meta content value.
|
|
7
|
+
* @param final - An optional flag which adds final with output functionality.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const createErrorStateNode: (key: string, metaContent?: string, final?: boolean) => StateNodeConfig<any, any, any, any>;
|
|
11
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +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;AAG9C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,QAC1B,MAAM,gBACG,MAAM,UACb,OAAO,KACb,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAgBpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|