cogfy-data-exchange 1.0.12 → 1.0.14
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/create-flow.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ type Handlers<F extends FlowJson> = {
|
|
|
8
8
|
* @param handlers An object mapping trigger strings to their corresponding handler functions. Each handler receives the payload for its trigger and returns a promise that resolves to the next result, which includes the next screen and its data.
|
|
9
9
|
* @returns An object with a `dispatch` method to trigger handlers and the original flow definition.
|
|
10
10
|
*/
|
|
11
|
+
type DispatchPayloads<F extends FlowJson> = {
|
|
12
|
+
[K in AllTriggers<F>]: PayloadByTrigger<F, K, ExtractScreen<K, F>>;
|
|
13
|
+
};
|
|
14
|
+
export type AllPayloads<F extends FlowJson> = DispatchPayloads<F>[AllTriggers<F>];
|
|
11
15
|
export declare function createFlow<F extends FlowJson>(flow: F, handlers: Handlers<F>): {
|
|
12
16
|
dispatch<T extends AllTriggers<F>>(trigger: T, payload: PayloadByTrigger<F, T, ExtractScreen<T, F>>): Promise<NextResult<F, ExtractScreen<T, F>>>;
|
|
13
17
|
flow: F;
|
package/dist/create-flow.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFlow = createFlow;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a flow engine based on the provided flow definition and handlers.
|
|
6
|
-
* @param flow The flow definition, which includes the routing model and screen definitions.
|
|
7
|
-
* @param handlers An object mapping trigger strings to their corresponding handler functions. Each handler receives the payload for its trigger and returns a promise that resolves to the next result, which includes the next screen and its data.
|
|
8
|
-
* @returns An object with a `dispatch` method to trigger handlers and the original flow definition.
|
|
9
|
-
*/
|
|
10
4
|
function createFlow(flow, handlers) {
|
|
11
5
|
return {
|
|
12
6
|
dispatch(trigger, payload) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export type FlowJsonDataValue = {
|
|
2
2
|
type: 'string';
|
|
3
|
-
__example__
|
|
3
|
+
__example__?: string;
|
|
4
4
|
} | {
|
|
5
5
|
type: 'number';
|
|
6
|
-
__example__
|
|
6
|
+
__example__?: number;
|
|
7
7
|
} | {
|
|
8
8
|
type: 'boolean';
|
|
9
|
-
__example__
|
|
9
|
+
__example__?: boolean;
|
|
10
10
|
} | {
|
|
11
11
|
type: 'object';
|
|
12
|
-
properties
|
|
12
|
+
properties: Record<string, FlowJsonDataValue>;
|
|
13
13
|
__example__?: Record<string, unknown>;
|
|
14
14
|
} | {
|
|
15
15
|
type: 'array';
|
package/package.json
CHANGED
package/src/create-flow.ts
CHANGED
|
@@ -12,6 +12,12 @@ type Handlers<F extends FlowJson> = {
|
|
|
12
12
|
* @param handlers An object mapping trigger strings to their corresponding handler functions. Each handler receives the payload for its trigger and returns a promise that resolves to the next result, which includes the next screen and its data.
|
|
13
13
|
* @returns An object with a `dispatch` method to trigger handlers and the original flow definition.
|
|
14
14
|
*/
|
|
15
|
+
type DispatchPayloads<F extends FlowJson> = {
|
|
16
|
+
[K in AllTriggers<F>]: PayloadByTrigger<F, K, ExtractScreen<K, F>>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type AllPayloads<F extends FlowJson> = DispatchPayloads<F>[AllTriggers<F>]
|
|
20
|
+
|
|
15
21
|
export function createFlow<F extends FlowJson>(flow: F, handlers: Handlers<F>) {
|
|
16
22
|
return {
|
|
17
23
|
dispatch<T extends AllTriggers<F>>(
|
package/src/types/flow-json.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type FlowJsonDataValue =
|
|
2
|
-
| { type: 'string'; __example__
|
|
3
|
-
| { type: 'number'; __example__
|
|
4
|
-
| { type: 'boolean'; __example__
|
|
5
|
-
| { type: 'object'; properties
|
|
2
|
+
| { type: 'string'; __example__?: string }
|
|
3
|
+
| { type: 'number'; __example__?: number }
|
|
4
|
+
| { type: 'boolean'; __example__?: boolean }
|
|
5
|
+
| { type: 'object'; properties: Record<string, FlowJsonDataValue>; __example__?: Record<string, unknown> }
|
|
6
6
|
| { type: 'array'; items: FlowJsonDataValue; __example__?: unknown[] }
|
|
7
7
|
|
|
8
8
|
export type FlowJsonData = Record<string, FlowJsonDataValue>
|