@useparagon/core 0.0.1-canary.1
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/package.json +63 -0
- package/src/event/event.interface.ts +18 -0
- package/src/event/index.ts +1 -0
- package/src/execution/context.constants.ts +9 -0
- package/src/execution/context.interface.ts +39 -0
- package/src/execution/context.ts +72 -0
- package/src/execution/context.utils.ts +53 -0
- package/src/execution/index.ts +2 -0
- package/src/index.ts +6 -0
- package/src/integration/custom-integration.interface.ts +20 -0
- package/src/integration/index.ts +2 -0
- package/src/integration/integration-config.interface.ts +19 -0
- package/src/integration/integration.interface.ts +16 -0
- package/src/operator/index.ts +2 -0
- package/src/operator/operator.interface.ts +6 -0
- package/src/operator/operators/BooleanTrue.ts +20 -0
- package/src/operator/operators/StringContains.ts +27 -0
- package/src/resolvers/index.ts +2 -0
- package/src/resolvers/resolver.utils.ts +157 -0
- package/src/resolvers/resolvers.interface.ts +369 -0
- package/src/secret/index.ts +1 -0
- package/src/secret/secret.interface.ts +4 -0
- package/src/stateMachine/index.ts +2 -0
- package/src/stateMachine/stateMachine.constants.ts +12 -0
- package/src/stateMachine/stateMachine.interface.ts +145 -0
- package/src/stateMachine/stateMachine.utils.ts +733 -0
- package/src/steps/index.ts +3 -0
- package/src/steps/library/action/action.interface.ts +69 -0
- package/src/steps/library/action/action.step.ts +70 -0
- package/src/steps/library/action/index.ts +2 -0
- package/src/steps/library/conditional/conditional.interface.ts +82 -0
- package/src/steps/library/conditional/conditional.step.ts +96 -0
- package/src/steps/library/conditional/conditional.utils.ts +110 -0
- package/src/steps/library/conditional/index.ts +2 -0
- package/src/steps/library/delay/delay.interface.ts +71 -0
- package/src/steps/library/delay/delay.step.ts +51 -0
- package/src/steps/library/delay/index.ts +2 -0
- package/src/steps/library/fanout/fanout.interface.ts +46 -0
- package/src/steps/library/fanout/fanout.step.ts +68 -0
- package/src/steps/library/fanout/index.ts +2 -0
- package/src/steps/library/function/function.interface.ts +69 -0
- package/src/steps/library/function/function.step.ts +55 -0
- package/src/steps/library/function/index.ts +2 -0
- package/src/steps/library/index.ts +7 -0
- package/src/steps/library/integrationRequest/index.ts +2 -0
- package/src/steps/library/integrationRequest/integrationRequest.interface.ts +79 -0
- package/src/steps/library/integrationRequest/integrationRequest.step.ts +100 -0
- package/src/steps/library/request/index.ts +2 -0
- package/src/steps/library/request/request.interface.ts +159 -0
- package/src/steps/library/request/request.step.ts +117 -0
- package/src/steps/library/response/index.ts +2 -0
- package/src/steps/library/response/response.interface.ts +50 -0
- package/src/steps/library/response/response.step.ts +68 -0
- package/src/steps/step.constants.ts +4 -0
- package/src/steps/step.interface-base.ts +81 -0
- package/src/steps/step.interface.ts +31 -0
- package/src/steps/step.ts +136 -0
- package/src/steps/step.utils.ts +103 -0
- package/src/triggers/cron/cron.interface.ts +94 -0
- package/src/triggers/cron/cron.step.ts +52 -0
- package/src/triggers/cron/cron.utils.ts +117 -0
- package/src/triggers/cron/index.ts +3 -0
- package/src/triggers/endpoint/endpoint.interface.ts +66 -0
- package/src/triggers/endpoint/endpoint.step.ts +61 -0
- package/src/triggers/endpoint/index.ts +2 -0
- package/src/triggers/event/event.interface.ts +43 -0
- package/src/triggers/event/event.step.ts +41 -0
- package/src/triggers/event/index.ts +2 -0
- package/src/triggers/index.ts +4 -0
- package/src/triggers/integrationEnabled/index.ts +2 -0
- package/src/triggers/integrationEnabled/integrationEnabled.interface.ts +29 -0
- package/src/triggers/integrationEnabled/integrationEnabled.step.ts +33 -0
- package/src/triggers/trigger.interface.ts +28 -0
- package/src/triggers/trigger.ts +25 -0
- package/src/user/index.ts +2 -0
- package/src/user/user.interface.ts +4 -0
- package/src/user/user.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +10 -0
- package/src/workflow/index.ts +2 -0
- package/src/workflow/workflow.interface.ts +50 -0
- package/src/workflow/workflow.ts +132 -0
- package/tsconfig.json +9 -0
- package/tsconfig.release.json +8 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { KeyedSource } from '../../../resolvers/resolvers.interface';
|
|
2
|
+
import {
|
|
3
|
+
IBaseStep,
|
|
4
|
+
IBaseStepParameters,
|
|
5
|
+
StepType,
|
|
6
|
+
} from '../../step.interface-base';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* parameters for initializing an ActionStep
|
|
10
|
+
*/
|
|
11
|
+
export interface IActionStepInit<I extends Record<string, unknown>, _O = any>
|
|
12
|
+
extends IBaseStepParameters {
|
|
13
|
+
parameters: I;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* the name of the intent for the action
|
|
17
|
+
*/
|
|
18
|
+
intent: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* the name of the integration that the action belongs to
|
|
22
|
+
*/
|
|
23
|
+
actionType: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* parameters used for initializing an ActionStep
|
|
28
|
+
*/
|
|
29
|
+
export interface IActionStepParameters extends IBaseStepParameters {
|
|
30
|
+
/**
|
|
31
|
+
* the name of the intent for the action
|
|
32
|
+
*/
|
|
33
|
+
intent: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* parameters for the intent
|
|
37
|
+
*/
|
|
38
|
+
actionParameters: KeyedSource[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* the name of the integration that the action belongs to
|
|
42
|
+
*/
|
|
43
|
+
actionType: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* whether or not to retry when the step fails
|
|
47
|
+
*/
|
|
48
|
+
retryOnFailure?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* whether or not to continue if the step fails
|
|
52
|
+
*/
|
|
53
|
+
ignoreFailure?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* a step used for executing an action belonging to an integration
|
|
58
|
+
*/
|
|
59
|
+
export interface IActionStep extends IBaseStep {
|
|
60
|
+
/**
|
|
61
|
+
* the step type
|
|
62
|
+
*/
|
|
63
|
+
type: StepType.ACTION;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* configuration for the step
|
|
67
|
+
*/
|
|
68
|
+
parameters: IActionStepParameters;
|
|
69
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { resolveParamsToSources } from '../../../resolvers/resolver.utils';
|
|
2
|
+
import { KeyedSource } from '../../../resolvers/resolvers.interface';
|
|
3
|
+
import { Step } from '../../step';
|
|
4
|
+
import { StepType } from '../../step.interface';
|
|
5
|
+
import {
|
|
6
|
+
IActionStep,
|
|
7
|
+
IActionStepInit,
|
|
8
|
+
IActionStepParameters,
|
|
9
|
+
} from './action.interface';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* a step that executes an action
|
|
13
|
+
*/
|
|
14
|
+
export class ActionStep<I extends Record<string, unknown>, O = any>
|
|
15
|
+
extends Step<IActionStepInit<I, O>, IActionStepParameters>
|
|
16
|
+
implements IActionStep
|
|
17
|
+
{
|
|
18
|
+
/**
|
|
19
|
+
* the step type
|
|
20
|
+
*
|
|
21
|
+
* @type {StepType}
|
|
22
|
+
* @memberof Step
|
|
23
|
+
*/
|
|
24
|
+
type: StepType.ACTION = StepType.ACTION;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* configuration for the step
|
|
28
|
+
*/
|
|
29
|
+
parameters: IActionStepParameters;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* initialization parameters
|
|
33
|
+
*/
|
|
34
|
+
private _parameters: IActionStepInit<I, O>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
* @readonly
|
|
40
|
+
* @type {O}
|
|
41
|
+
* @memberof ActionStep
|
|
42
|
+
*/
|
|
43
|
+
get output(): O {
|
|
44
|
+
return {} as O;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor(params: IActionStepInit<I, O>) {
|
|
48
|
+
super(params);
|
|
49
|
+
this._parameters = params;
|
|
50
|
+
this.parameters = this.serializeParameters();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* serialize parameters for storage
|
|
55
|
+
*/
|
|
56
|
+
serializeParameters(): IActionStepParameters {
|
|
57
|
+
const actionParameters = this._parameters.parameters;
|
|
58
|
+
const serializedActionParameters: KeyedSource[] =
|
|
59
|
+
resolveParamsToSources(actionParameters);
|
|
60
|
+
|
|
61
|
+
const output: IActionStepParameters = {
|
|
62
|
+
...this._parameters,
|
|
63
|
+
actionParameters: serializedActionParameters,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
delete output['parameters'];
|
|
67
|
+
|
|
68
|
+
return output;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Condition,
|
|
3
|
+
ConditionWrapper,
|
|
4
|
+
} from '../../../resolvers/resolvers.interface';
|
|
5
|
+
import {
|
|
6
|
+
IBaseStep,
|
|
7
|
+
IBaseStepParameters,
|
|
8
|
+
StepType,
|
|
9
|
+
} from '../../step.interface-base';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* conditional input
|
|
13
|
+
* 1- Operator is used when there is no AND and OR operator used
|
|
14
|
+
* 2- Array<Operator> is used for AND(...operators)
|
|
15
|
+
* 3 - Array<Operator[]> is used for OR(AND(...operators))
|
|
16
|
+
*/
|
|
17
|
+
export type ConditionalInput =
|
|
18
|
+
| Condition
|
|
19
|
+
| Array<Condition>
|
|
20
|
+
| Array<Condition[]>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* represents a path of steps that can be traversed based on an evaluation of a condition
|
|
24
|
+
*/
|
|
25
|
+
export type Choice = {
|
|
26
|
+
/**
|
|
27
|
+
* the condition to be evaluated
|
|
28
|
+
*/
|
|
29
|
+
conditionWrapper?: ConditionWrapper;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* signifies this is the preferred path
|
|
33
|
+
*/
|
|
34
|
+
isDefault: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* a label for the path; used in the UI
|
|
38
|
+
*/
|
|
39
|
+
label: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* the id of the first step in the path
|
|
43
|
+
*/
|
|
44
|
+
next: string | undefined | null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* parameters used to initialize a conditional step
|
|
49
|
+
*/
|
|
50
|
+
export interface IConditionalStepInit extends IBaseStepParameters {
|
|
51
|
+
/**
|
|
52
|
+
* conditions for conditional step
|
|
53
|
+
*/
|
|
54
|
+
if: ConditionalInput;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* parameters used for initializing a ConditionalStep
|
|
59
|
+
*/
|
|
60
|
+
export interface IConditionalStepParameters extends IBaseStepParameters {
|
|
61
|
+
/**
|
|
62
|
+
* the choices for the conditional step
|
|
63
|
+
*/
|
|
64
|
+
choices: Choice[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* a step used for iterating over arrays
|
|
69
|
+
*/
|
|
70
|
+
export interface IConditionalStep extends IBaseStep {
|
|
71
|
+
/**
|
|
72
|
+
* the step type
|
|
73
|
+
*/
|
|
74
|
+
type: StepType.IFELSE;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* configuration for the step
|
|
78
|
+
*/
|
|
79
|
+
parameters: {
|
|
80
|
+
choices: Choice[];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ConditionWrapper } from '../../../resolvers';
|
|
2
|
+
import { Step } from '../../step';
|
|
3
|
+
import { StepType } from '../../step.interface';
|
|
4
|
+
import {
|
|
5
|
+
Choice,
|
|
6
|
+
IConditionalStep,
|
|
7
|
+
IConditionalStepInit,
|
|
8
|
+
IConditionalStepParameters,
|
|
9
|
+
} from './conditional.interface';
|
|
10
|
+
import { parseConditionInput } from './conditional.utils';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* a step used for iterating over arrays
|
|
14
|
+
*/
|
|
15
|
+
export class ConditionalStep
|
|
16
|
+
extends Step<IConditionalStepInit, IConditionalStepParameters>
|
|
17
|
+
implements IConditionalStep
|
|
18
|
+
{
|
|
19
|
+
/**
|
|
20
|
+
* the step type
|
|
21
|
+
*
|
|
22
|
+
* @type {StepType}
|
|
23
|
+
* @memberof Step
|
|
24
|
+
*/
|
|
25
|
+
type: StepType.IFELSE = StepType.IFELSE;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* configuration for the fanout step
|
|
29
|
+
*
|
|
30
|
+
* @type {IConditionalStepParameters}
|
|
31
|
+
* @memberof FanOutStep
|
|
32
|
+
*/
|
|
33
|
+
parameters: IConditionalStepParameters;
|
|
34
|
+
|
|
35
|
+
private _parameters: IConditionalStepInit;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* step pointing to when if condition is true
|
|
39
|
+
*/
|
|
40
|
+
private _ifStep: Step | undefined = undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* step pointing to when if condition is false
|
|
44
|
+
*/
|
|
45
|
+
private _elseStep: Step | undefined = undefined;
|
|
46
|
+
|
|
47
|
+
constructor(params: IConditionalStepInit) {
|
|
48
|
+
super(params);
|
|
49
|
+
this._parameters = params;
|
|
50
|
+
this.parameters = this.serializeParameters();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* chain steps that should executed for "true" condition
|
|
55
|
+
* @param step
|
|
56
|
+
*/
|
|
57
|
+
whenTrue(step: Step): Step {
|
|
58
|
+
this._ifStep = step;
|
|
59
|
+
this.parameters = this.serializeParameters();
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* chain steps that should executed for "false" condition
|
|
65
|
+
* @param step
|
|
66
|
+
*/
|
|
67
|
+
whenFalse(step: Step): Step {
|
|
68
|
+
this._elseStep = step;
|
|
69
|
+
this.parameters = this.serializeParameters();
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* serialize parameters for storage
|
|
75
|
+
*/
|
|
76
|
+
serializeParameters(): IConditionalStepParameters {
|
|
77
|
+
const conditionWrapper: ConditionWrapper = parseConditionInput(
|
|
78
|
+
this._parameters.if,
|
|
79
|
+
);
|
|
80
|
+
const ifTrue: Choice = {
|
|
81
|
+
conditionWrapper,
|
|
82
|
+
isDefault: true,
|
|
83
|
+
label: 'Yes',
|
|
84
|
+
next: this._ifStep?.id,
|
|
85
|
+
};
|
|
86
|
+
const ifFalse: Choice = {
|
|
87
|
+
isDefault: false,
|
|
88
|
+
label: 'No',
|
|
89
|
+
next: this._elseStep?.id,
|
|
90
|
+
};
|
|
91
|
+
const choices: Choice[] = [ifTrue, ifFalse];
|
|
92
|
+
return {
|
|
93
|
+
choices,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Condition,
|
|
3
|
+
ConditionWrapper,
|
|
4
|
+
OperatorCondition,
|
|
5
|
+
} from '../../../resolvers';
|
|
6
|
+
import { ConditionalInput } from './conditional.interface';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* check if passed object is of condition type
|
|
10
|
+
* @param mayBeCondition
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const isCondition = (mayBeCondition: unknown): mayBeCondition is Condition => {
|
|
14
|
+
if (
|
|
15
|
+
mayBeCondition &&
|
|
16
|
+
typeof mayBeCondition === 'object' &&
|
|
17
|
+
mayBeCondition['type'] === 'OPERATOR'
|
|
18
|
+
) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* check if value is conditional input
|
|
26
|
+
* @param value
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export const isConditionalInput = (
|
|
30
|
+
value: unknown,
|
|
31
|
+
): value is ConditionalInput => {
|
|
32
|
+
if (typeof value !== 'object' || !value) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (isCondition(value)) {
|
|
36
|
+
return true;
|
|
37
|
+
} else if (Array.isArray(value)) {
|
|
38
|
+
const isAndCondition: boolean = value.every((value) => isCondition(value));
|
|
39
|
+
const isOrCondition: boolean = value.every(
|
|
40
|
+
(value) =>
|
|
41
|
+
Array.isArray(value) &&
|
|
42
|
+
value.every((innerValue) => isCondition(innerValue)),
|
|
43
|
+
);
|
|
44
|
+
return isAndCondition || isOrCondition;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* parse condition input to condition wrapper object
|
|
51
|
+
* @param conditionInput
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export const parseConditionInput = (
|
|
55
|
+
conditionInput: ConditionalInput,
|
|
56
|
+
): ConditionWrapper => {
|
|
57
|
+
if (isCondition(conditionInput)) {
|
|
58
|
+
return {
|
|
59
|
+
type: 'JOIN',
|
|
60
|
+
join: 'OR',
|
|
61
|
+
conditions: [
|
|
62
|
+
{
|
|
63
|
+
join: 'AND',
|
|
64
|
+
type: 'JOIN',
|
|
65
|
+
conditions: [
|
|
66
|
+
{
|
|
67
|
+
type: 'OPERATOR',
|
|
68
|
+
condition: conditionInput,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const firstCondition: Condition | Condition[] = conditionInput[0];
|
|
77
|
+
if (isCondition(firstCondition)) {
|
|
78
|
+
return {
|
|
79
|
+
type: 'JOIN',
|
|
80
|
+
join: 'OR',
|
|
81
|
+
conditions: [
|
|
82
|
+
{
|
|
83
|
+
join: 'AND',
|
|
84
|
+
type: 'JOIN',
|
|
85
|
+
conditions: (conditionInput as Condition[]).map(
|
|
86
|
+
(condition: Condition): OperatorCondition => ({
|
|
87
|
+
type: 'OPERATOR',
|
|
88
|
+
condition,
|
|
89
|
+
}),
|
|
90
|
+
),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
type: 'JOIN',
|
|
98
|
+
join: 'OR',
|
|
99
|
+
conditions: (conditionInput as Array<Condition[]>).map(
|
|
100
|
+
(conditions: Condition[]) => ({
|
|
101
|
+
join: 'AND',
|
|
102
|
+
type: 'JOIN',
|
|
103
|
+
conditions: conditions.map((condition: Condition) => ({
|
|
104
|
+
type: 'OPERATOR',
|
|
105
|
+
condition,
|
|
106
|
+
})),
|
|
107
|
+
}),
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DataType, Source } from '../../../resolvers/resolvers.interface';
|
|
2
|
+
import {
|
|
3
|
+
IBaseStep,
|
|
4
|
+
IBaseStepParameters,
|
|
5
|
+
StepType,
|
|
6
|
+
} from '../../step.interface-base';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* unit of delay value
|
|
10
|
+
*/
|
|
11
|
+
export enum DelayUnit {
|
|
12
|
+
SECONDS = 'SECONDS',
|
|
13
|
+
MINUTES = 'MINUTES',
|
|
14
|
+
HOURS = 'HOURS',
|
|
15
|
+
DAYS = 'DAYS',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* parameters used for initializing an delay step
|
|
20
|
+
*/
|
|
21
|
+
export interface IDelayStepInit extends IBaseStepParameters {
|
|
22
|
+
/**
|
|
23
|
+
* unit for delay value
|
|
24
|
+
*/
|
|
25
|
+
unit?: keyof typeof DelayUnit;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* value of delay time in seconds if unit key is not passed
|
|
29
|
+
*/
|
|
30
|
+
value: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* parameters for delay step
|
|
35
|
+
*/
|
|
36
|
+
export interface IDelayStepParameters extends IBaseStepParameters {
|
|
37
|
+
/**
|
|
38
|
+
* unit for delay value
|
|
39
|
+
*/
|
|
40
|
+
unit: DelayUnit;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* value of delay time
|
|
44
|
+
*/
|
|
45
|
+
value: Source<DataType.NON_DECIMAL>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* whether or not to retry when the step fails
|
|
49
|
+
*/
|
|
50
|
+
retryOnFailure?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* whether or not to continue if the step fails
|
|
54
|
+
*/
|
|
55
|
+
ignoreFailure?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* a delay step
|
|
60
|
+
*/
|
|
61
|
+
export interface IDelayStep extends IBaseStep {
|
|
62
|
+
/**
|
|
63
|
+
* the step type
|
|
64
|
+
*/
|
|
65
|
+
type: StepType.DELAY;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* configuration for the step
|
|
69
|
+
*/
|
|
70
|
+
parameters: IDelayStepParameters;
|
|
71
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DataType, resolveToSource } from '../../../resolvers';
|
|
2
|
+
import { Step } from '../../step';
|
|
3
|
+
import { StepType } from '../../step.interface';
|
|
4
|
+
import {
|
|
5
|
+
DelayUnit,
|
|
6
|
+
IDelayStep,
|
|
7
|
+
IDelayStepInit,
|
|
8
|
+
IDelayStepParameters,
|
|
9
|
+
} from './delay.interface';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* a step that executes an delay step
|
|
13
|
+
*/
|
|
14
|
+
export class DelayStep
|
|
15
|
+
extends Step<IDelayStepInit, IDelayStepParameters>
|
|
16
|
+
implements IDelayStep
|
|
17
|
+
{
|
|
18
|
+
/**
|
|
19
|
+
* the step type
|
|
20
|
+
*
|
|
21
|
+
* @type {StepType}
|
|
22
|
+
* @memberof Step
|
|
23
|
+
*/
|
|
24
|
+
type: StepType.DELAY = StepType.DELAY;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* configuration for the step
|
|
28
|
+
*/
|
|
29
|
+
parameters: IDelayStepParameters;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* initialization parameters
|
|
33
|
+
*/
|
|
34
|
+
private _parameters: IDelayStepInit;
|
|
35
|
+
|
|
36
|
+
constructor(params: IDelayStepInit) {
|
|
37
|
+
super(params);
|
|
38
|
+
this._parameters = params;
|
|
39
|
+
this.parameters = this.serializeParameters();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* serialize parameters for storage
|
|
44
|
+
*/
|
|
45
|
+
serializeParameters(): IDelayStepParameters {
|
|
46
|
+
return {
|
|
47
|
+
unit: (this._parameters.unit || DelayUnit.SECONDS) as DelayUnit,
|
|
48
|
+
value: resolveToSource(this._parameters.value, DataType.NON_DECIMAL),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DataType, Source } from '../../../resolvers/resolvers.interface';
|
|
2
|
+
import {
|
|
3
|
+
IBaseStep,
|
|
4
|
+
IBaseStepParameters,
|
|
5
|
+
StepType,
|
|
6
|
+
} from '../../step.interface-base';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* parameters for initializing fanout step
|
|
10
|
+
*/
|
|
11
|
+
export interface IFanOutStepInit extends IBaseStepParameters {
|
|
12
|
+
/**
|
|
13
|
+
* the items to iterate over
|
|
14
|
+
*/
|
|
15
|
+
iterator: Array<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* parameters used for initializing a FanOutStep
|
|
20
|
+
*/
|
|
21
|
+
export interface IFanOutStepParameters extends IBaseStepParameters {
|
|
22
|
+
/**
|
|
23
|
+
* the items to iterate over
|
|
24
|
+
*/
|
|
25
|
+
iterator: Source<DataType.ARRAY>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* first step in the fanout
|
|
29
|
+
*/
|
|
30
|
+
nextToIterate?: string | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* a step used for iterating over arrays
|
|
35
|
+
*/
|
|
36
|
+
export interface IFanOutStep extends IBaseStep {
|
|
37
|
+
/**
|
|
38
|
+
* the step type
|
|
39
|
+
*/
|
|
40
|
+
type: StepType.MAP;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* configuration for the step
|
|
44
|
+
*/
|
|
45
|
+
parameters: IFanOutStepParameters;
|
|
46
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { resolveToSource } from '../../../resolvers/resolver.utils';
|
|
2
|
+
import { DataType } from '../../../resolvers/resolvers.interface';
|
|
3
|
+
import { Step } from '../../step';
|
|
4
|
+
import { StepType } from '../../step.interface';
|
|
5
|
+
import {
|
|
6
|
+
IFanOutStep,
|
|
7
|
+
IFanOutStepInit,
|
|
8
|
+
IFanOutStepParameters,
|
|
9
|
+
} from './fanout.interface';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* a step used for iterating over arrays
|
|
13
|
+
*/
|
|
14
|
+
export class FanOutStep extends Step implements IFanOutStep {
|
|
15
|
+
/**
|
|
16
|
+
* the step type
|
|
17
|
+
*
|
|
18
|
+
* @type {StepType.MAP}
|
|
19
|
+
* @memberof Step
|
|
20
|
+
*/
|
|
21
|
+
type: StepType.MAP = StepType.MAP;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* configuration for the fanout step
|
|
25
|
+
*
|
|
26
|
+
* @type {IFanOutStep['parameters']}
|
|
27
|
+
* @memberof FanOutStep
|
|
28
|
+
*/
|
|
29
|
+
parameters: IFanOutStepParameters;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* parameters used for initializing fanout
|
|
33
|
+
*/
|
|
34
|
+
private _parameters: IFanOutStepInit;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* step to iterate
|
|
38
|
+
*/
|
|
39
|
+
private _nextToIterate: Step | undefined = undefined;
|
|
40
|
+
|
|
41
|
+
constructor(params: IFanOutStepInit) {
|
|
42
|
+
super(params);
|
|
43
|
+
this._parameters = params;
|
|
44
|
+
this._parameters.iterator = params.iterator;
|
|
45
|
+
this.parameters = this.serializeParameters();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* used to specify the first step within the fanout
|
|
50
|
+
* @param step the first step within the fanout
|
|
51
|
+
*/
|
|
52
|
+
branch(step: Step): Step {
|
|
53
|
+
this._nextToIterate = step;
|
|
54
|
+
this.parameters.nextToIterate = this._nextToIterate.id;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* serialize parameters for storage
|
|
60
|
+
*/
|
|
61
|
+
serializeParameters(): IFanOutStepParameters {
|
|
62
|
+
const iterator: Array<any> = this._parameters.iterator;
|
|
63
|
+
return {
|
|
64
|
+
iterator: resolveToSource(iterator, DataType.ARRAY),
|
|
65
|
+
nextToIterate: this._nextToIterate?.id,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|