@toolproof-npm/shared 0.1.97 → 0.1.98
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.
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import type { WorkStepJson, WhileStepJson, ForStepJson, JobJson } from '@toolproof-npm/schema';
|
|
1
|
+
import type { WorkStepJson, BranchStepJson, WhileStepJson, ForStepJson, JobJson } from '@toolproof-npm/schema';
|
|
2
2
|
export declare const makeWorkStepFromJob: (job: JobJson) => Promise<WorkStepJson>;
|
|
3
|
-
export declare const makeLoopStepFromJob: (
|
|
3
|
+
export declare const makeLoopStepFromJob: (whatJob: JobJson, whenJob: JobJson, kind: "for" | "while") => Promise<ForStepJson | WhileStepJson>;
|
|
4
|
+
export declare const makeBranchStepFromJobPairs: (cases: {
|
|
5
|
+
whatJob: JobJson;
|
|
6
|
+
whenJob: JobJson;
|
|
7
|
+
}[]) => Promise<BranchStepJson>;
|
|
@@ -37,9 +37,9 @@ export const makeWorkStepFromJob = async (job) => {
|
|
|
37
37
|
return newWorkStep;
|
|
38
38
|
};
|
|
39
39
|
// DOC: Helper function to construct a ForStep or WhileStep from a job
|
|
40
|
-
export const makeLoopStepFromJob = async (
|
|
40
|
+
export const makeLoopStepFromJob = async (whatJob, whenJob, kind) => {
|
|
41
41
|
// Create the "what" WorkStep from the provided job
|
|
42
|
-
const whatWorkStep = await makeWorkStepFromJob(
|
|
42
|
+
const whatWorkStep = await makeWorkStepFromJob(whatJob);
|
|
43
43
|
// Create the "when" WorkStep from the LessThan job
|
|
44
44
|
const whenWorkStep = await makeWorkStepFromJob(whenJob);
|
|
45
45
|
// Generate loop step identity based on kind
|
|
@@ -56,3 +56,23 @@ export const makeLoopStepFromJob = async (job, whenJob, kind) => {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
+
// DOC: Helper function to construct a BranchStep from an array of job pairs
|
|
60
|
+
export const makeBranchStepFromJobPairs = async (cases) => {
|
|
61
|
+
// Generate branch step identity
|
|
62
|
+
const branchStepIdentity = await getNewIdentity(CONSTANTS.STEPS.branch);
|
|
63
|
+
// Create WorkSteps for each case (what and when pair)
|
|
64
|
+
const casesWithWorkSteps = await Promise.all(cases.map(async ({ whatJob, whenJob }) => {
|
|
65
|
+
const whatWorkStep = await makeWorkStepFromJob(whatJob);
|
|
66
|
+
const whenWorkStep = await makeWorkStepFromJob(whenJob);
|
|
67
|
+
return {
|
|
68
|
+
what: whatWorkStep,
|
|
69
|
+
when: whenWorkStep
|
|
70
|
+
};
|
|
71
|
+
}));
|
|
72
|
+
// Assemble the branch step
|
|
73
|
+
return {
|
|
74
|
+
identity: branchStepIdentity,
|
|
75
|
+
kind: CONSTANTS.STEPS.branch,
|
|
76
|
+
cases: casesWithWorkSteps
|
|
77
|
+
};
|
|
78
|
+
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -44,12 +44,16 @@ export declare const CONSTANTS: {
|
|
|
44
44
|
readonly TYPE_ResourceFormat: "TYPE-ResourceFormat";
|
|
45
45
|
readonly TYPE_ResourceType: "TYPE-ResourceType";
|
|
46
46
|
readonly TYPE_Job: "TYPE-Job";
|
|
47
|
+
readonly TYPE_Error: "TYPE-Error";
|
|
47
48
|
readonly TYPE_StatelessStrategy: "TYPE-StatelessStrategy";
|
|
48
49
|
readonly TYPE_StatefulStrategy: "TYPE-StatefulStrategy";
|
|
49
50
|
readonly ROLE_Manual: "ROLE-Manual";
|
|
50
|
-
readonly
|
|
51
|
+
readonly ROLE_ErrorOutput: "ROLE-ErrorOutput";
|
|
52
|
+
readonly ROLE_DynamicSource: "ROLE-u4vW7PDlX6V9IGJoNxhl";
|
|
53
|
+
readonly ROLE_StaticTarget: "ROLE-xLaQo8L1fMxKTQUJcaJn";
|
|
54
|
+
readonly ROLE_Decison: "ROLE-C4FKVwXipgngzPQc3MDc";
|
|
51
55
|
readonly JOB_Engine: "JOB-Engine";
|
|
52
|
-
readonly
|
|
56
|
+
readonly JOB_LessThan: "JOB-LessThan";
|
|
53
57
|
readonly BOOLEAN_false: "RESOURCE-VqJIcOpv9E3zFuGVpN7J";
|
|
54
58
|
readonly BOOLEAN_true: "RESOURCE-iZX1cxZ9ImJRzty9Ob4G";
|
|
55
59
|
};
|
package/dist/constants.js
CHANGED
|
@@ -44,12 +44,16 @@ export const CONSTANTS = {
|
|
|
44
44
|
TYPE_ResourceFormat: 'TYPE-ResourceFormat',
|
|
45
45
|
TYPE_ResourceType: 'TYPE-ResourceType',
|
|
46
46
|
TYPE_Job: 'TYPE-Job',
|
|
47
|
+
TYPE_Error: 'TYPE-Error',
|
|
47
48
|
TYPE_StatelessStrategy: 'TYPE-StatelessStrategy',
|
|
48
49
|
TYPE_StatefulStrategy: 'TYPE-StatefulStrategy',
|
|
49
50
|
ROLE_Manual: 'ROLE-Manual',
|
|
50
|
-
|
|
51
|
+
ROLE_ErrorOutput: 'ROLE-ErrorOutput',
|
|
52
|
+
ROLE_DynamicSource: 'ROLE-u4vW7PDlX6V9IGJoNxhl',
|
|
53
|
+
ROLE_StaticTarget: 'ROLE-xLaQo8L1fMxKTQUJcaJn',
|
|
54
|
+
ROLE_Decison: 'ROLE-C4FKVwXipgngzPQc3MDc',
|
|
51
55
|
JOB_Engine: 'JOB-Engine',
|
|
52
|
-
|
|
56
|
+
JOB_LessThan: 'JOB-LessThan',
|
|
53
57
|
BOOLEAN_false: 'RESOURCE-VqJIcOpv9E3zFuGVpN7J',
|
|
54
58
|
BOOLEAN_true: 'RESOURCE-iZX1cxZ9ImJRzty9Ob4G',
|
|
55
59
|
},
|