@toolproof-npm/shared 0.1.98 → 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.
|
@@ -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)
|
|
@@ -57,13 +57,13 @@ export const makeLoopStepFromJob = async (whatJob, whenJob, kind) => {
|
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
// DOC: Helper function to construct a BranchStep from an array of job pairs
|
|
60
|
-
export const
|
|
60
|
+
export const createBranchStepFromJobPairs = async (cases) => {
|
|
61
61
|
// Generate branch step identity
|
|
62
62
|
const branchStepIdentity = await getNewIdentity(CONSTANTS.STEPS.branch);
|
|
63
63
|
// Create WorkSteps for each case (what and when pair)
|
|
64
64
|
const casesWithWorkSteps = await Promise.all(cases.map(async ({ whatJob, whenJob }) => {
|
|
65
|
-
const whatWorkStep = await
|
|
66
|
-
const whenWorkStep = await
|
|
65
|
+
const whatWorkStep = await createWorkStepFromJob(whatJob);
|
|
66
|
+
const whenWorkStep = await createWorkStepFromJob(whenJob);
|
|
67
67
|
return {
|
|
68
68
|
what: whatWorkStep,
|
|
69
69
|
when: whenWorkStep
|
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,7 +0,0 @@
|
|
|
1
|
-
import type { WorkStepJson, BranchStepJson, WhileStepJson, ForStepJson, JobJson } from '@toolproof-npm/schema';
|
|
2
|
-
export declare const makeWorkStepFromJob: (job: JobJson) => Promise<WorkStepJson>;
|
|
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>;
|