@toolproof-npm/shared 0.1.97 → 0.1.99
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/_lib/utils/stepCreation.d.ts +7 -0
- package/dist/_lib/utils/{makeHelpers.js → stepCreation.js} +26 -6
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +6 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/_lib/utils/makeHelpers.d.ts +0 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WorkStepJson, BranchStepJson, WhileStepJson, ForStepJson, JobJson } from '@toolproof-npm/schema';
|
|
2
|
+
export declare const createWorkStepFromJob: (job: JobJson) => Promise<WorkStepJson>;
|
|
3
|
+
export declare const createLoopStepFromJob: (whatJob: JobJson, whenJob: JobJson, kind: "for" | "while") => Promise<ForStepJson | WhileStepJson>;
|
|
4
|
+
export declare const createBranchStepFromJobPairs: (cases: {
|
|
5
|
+
whatJob: JobJson;
|
|
6
|
+
whenJob: JobJson;
|
|
7
|
+
}[]) => Promise<BranchStepJson>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CONSTANTS } from '@toolproof-npm/shared/constants';
|
|
2
2
|
import { getNewIdentity } from '@toolproof-npm/shared/server';
|
|
3
3
|
// DOC: Helper function to construct an Execution object from a job
|
|
4
|
-
const
|
|
4
|
+
const createExecutionFromJob = async (job, executionRef) => {
|
|
5
5
|
const execIdentity = executionRef ?? await getNewIdentity(CONSTANTS.TERMINALS.execution);
|
|
6
6
|
const inputBindingMap = {};
|
|
7
7
|
const inputs = job.roles.inputMap;
|
|
@@ -25,10 +25,10 @@ const makeExecutionFromJob = async (job, executionRef) => {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
// DOC: Helper function to construct a WorkStep object from an jobMetaJson (does not append to statelessStrategy.steps)
|
|
28
|
-
export const
|
|
28
|
+
export const createWorkStepFromJob = async (job) => {
|
|
29
29
|
const workStepIdentity = await getNewIdentity(CONSTANTS.STEPS.work);
|
|
30
30
|
const executionRef = workStepIdentity.replace(CONSTANTS.STEPS.work.toUpperCase(), 'execution'.toUpperCase()); // ATTENTION: use function
|
|
31
|
-
const execution = await
|
|
31
|
+
const execution = await createExecutionFromJob(job, executionRef);
|
|
32
32
|
const newWorkStep = {
|
|
33
33
|
identity: workStepIdentity,
|
|
34
34
|
kind: CONSTANTS.STEPS.work,
|
|
@@ -37,11 +37,11 @@ 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
|
|
40
|
+
export const createLoopStepFromJob = async (whatJob, whenJob, kind) => {
|
|
41
41
|
// Create the "what" WorkStep from the provided job
|
|
42
|
-
const whatWorkStep = await
|
|
42
|
+
const whatWorkStep = await createWorkStepFromJob(whatJob);
|
|
43
43
|
// Create the "when" WorkStep from the LessThan job
|
|
44
|
-
const whenWorkStep = await
|
|
44
|
+
const whenWorkStep = await createWorkStepFromJob(whenJob);
|
|
45
45
|
// Generate loop step identity based on kind
|
|
46
46
|
const stepIdentity = (kind === 'for'
|
|
47
47
|
? await getNewIdentity(CONSTANTS.STEPS.for)
|
|
@@ -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 createBranchStepFromJobPairs = 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 createWorkStepFromJob(whatJob);
|
|
66
|
+
const whenWorkStep = await createWorkStepFromJob(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
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * as CONSTANTS from './constants.js';
|
|
|
2
2
|
export * as TYPES from './_lib/types.js';
|
|
3
3
|
export * as UTILS from './_lib/utils/utils.js';
|
|
4
4
|
export * as RESOURCE_CREATION from './_lib/utils/resourceCreation.js';
|
|
5
|
-
export * as
|
|
5
|
+
export * as STEP_CREATION from './_lib/utils/stepCreation.js';
|
|
6
6
|
export * from './firebaseAdminHelpers.js';
|
|
7
7
|
export * from './firebaseAdminInit.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,6 @@ export * as CONSTANTS from './constants.js';
|
|
|
2
2
|
export * as TYPES from './_lib/types.js';
|
|
3
3
|
export * as UTILS from './_lib/utils/utils.js';
|
|
4
4
|
export * as RESOURCE_CREATION from './_lib/utils/resourceCreation.js';
|
|
5
|
-
export * as
|
|
5
|
+
export * as STEP_CREATION from './_lib/utils/stepCreation.js';
|
|
6
6
|
export * from './firebaseAdminHelpers.js';
|
|
7
7
|
export * from './firebaseAdminInit.js';
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { WorkStepJson, WhileStepJson, ForStepJson, JobJson } from '@toolproof-npm/schema';
|
|
2
|
-
export declare const makeWorkStepFromJob: (job: JobJson) => Promise<WorkStepJson>;
|
|
3
|
-
export declare const makeLoopStepFromJob: (job: JobJson, whenJob: JobJson, kind: "for" | "while") => Promise<ForStepJson | WhileStepJson>;
|