@toolproof-npm/shared 0.1.99 → 0.1.100

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.
@@ -5,3 +5,4 @@ export declare const createBranchStepFromJobPairs: (cases: {
5
5
  whatJob: JobJson;
6
6
  whenJob: JobJson;
7
7
  }[]) => Promise<BranchStepJson>;
8
+ export declare const cloneForStep: (forStep: ForStepJson) => Promise<ForStepJson>;
@@ -76,3 +76,51 @@ export const createBranchStepFromJobPairs = async (cases) => {
76
76
  cases: casesWithWorkSteps
77
77
  };
78
78
  };
79
+ // DOC: Helper function to clone a ForStep with new identities for steps and executions, preserving job references and bindings
80
+ export const cloneForStep = async (forStep) => {
81
+ // Generate new ForStep identity
82
+ const newForStepIdentity = await getNewIdentity(CONSTANTS.STEPS.for);
83
+ // Clone the "what" WorkStep
84
+ const originalWhatWorkStep = forStep.case.what;
85
+ const newWhatWorkStepIdentity = await getNewIdentity(CONSTANTS.STEPS.work);
86
+ const newWhatExecutionIdentity = newWhatWorkStepIdentity.replace(CONSTANTS.STEPS.work.toUpperCase(), 'execution'.toUpperCase());
87
+ const newWhatExecution = {
88
+ identity: newWhatExecutionIdentity,
89
+ jobRef: originalWhatWorkStep.execution.jobRef,
90
+ roleBindings: {
91
+ inputBindingMap: { ...originalWhatWorkStep.execution.roleBindings.inputBindingMap },
92
+ outputBindingMap: { ...originalWhatWorkStep.execution.roleBindings.outputBindingMap }
93
+ }
94
+ };
95
+ const newWhatWorkStep = {
96
+ identity: newWhatWorkStepIdentity,
97
+ kind: CONSTANTS.STEPS.work,
98
+ execution: newWhatExecution
99
+ };
100
+ // Clone the "when" WorkStep
101
+ const originalWhenWorkStep = forStep.case.when;
102
+ const newWhenWorkStepIdentity = await getNewIdentity(CONSTANTS.STEPS.work);
103
+ const newWhenExecutionIdentity = newWhenWorkStepIdentity.replace(CONSTANTS.STEPS.work.toUpperCase(), 'execution'.toUpperCase());
104
+ const newWhenExecution = {
105
+ identity: newWhenExecutionIdentity,
106
+ jobRef: originalWhenWorkStep.execution.jobRef,
107
+ roleBindings: {
108
+ inputBindingMap: { ...originalWhenWorkStep.execution.roleBindings.inputBindingMap },
109
+ outputBindingMap: { ...originalWhenWorkStep.execution.roleBindings.outputBindingMap }
110
+ }
111
+ };
112
+ const newWhenWorkStep = {
113
+ identity: newWhenWorkStepIdentity,
114
+ kind: CONSTANTS.STEPS.work,
115
+ execution: newWhenExecution
116
+ };
117
+ // Assemble the cloned ForStep
118
+ return {
119
+ identity: newForStepIdentity,
120
+ kind: CONSTANTS.STEPS.for,
121
+ case: {
122
+ what: newWhatWorkStep,
123
+ when: newWhenWorkStep
124
+ }
125
+ };
126
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolproof-npm/shared",
3
- "version": "0.1.99",
3
+ "version": "0.1.100",
4
4
  "description": "Core library utilities for ToolProof",
5
5
  "keywords": [
6
6
  "toolproof",