@punks/backend-entity-manager 0.0.145 → 0.0.146
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/cjs/index.js +23 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/templates/pipelines/instance/index.d.ts +1 -0
- package/dist/cjs/types/templates/pipelines/utils/index.d.ts +4 -0
- package/dist/cjs/types/types/pipelines.d.ts +3 -0
- package/dist/esm/index.js +23 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/templates/pipelines/instance/index.d.ts +1 -0
- package/dist/esm/types/templates/pipelines/utils/index.d.ts +4 -0
- package/dist/esm/types/types/pipelines.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -21166,6 +21166,11 @@ const mapPipelineErrorType = (stepError) => {
|
|
|
21166
21166
|
}
|
|
21167
21167
|
};
|
|
21168
21168
|
|
|
21169
|
+
const isOperationSuccessStatus = (type) => {
|
|
21170
|
+
return ["success", "skipped"].includes(type);
|
|
21171
|
+
};
|
|
21172
|
+
const isOperationRollbackErrorStatus = (type) => ["error"].includes(type);
|
|
21173
|
+
|
|
21169
21174
|
class PipelineInstance {
|
|
21170
21175
|
constructor(definition, input, context) {
|
|
21171
21176
|
this.definition = definition;
|
|
@@ -21242,10 +21247,9 @@ class PipelineInstance {
|
|
|
21242
21247
|
result: x,
|
|
21243
21248
|
operation: step.operations[i],
|
|
21244
21249
|
}));
|
|
21245
|
-
// .filter((x) => x.result.type === "success")
|
|
21246
21250
|
const rollbackOperations = completedOperations.map((x) => this.rollbackOperations(x.operation, x.result.input, getOperationOutput(x.result), state));
|
|
21247
21251
|
const rollbackResults = await Promise.all(rollbackOperations);
|
|
21248
|
-
const isRollbackError = rollbackResults.some((x) => x.type
|
|
21252
|
+
const isRollbackError = rollbackResults.some((x) => isOperationRollbackErrorStatus(x.type));
|
|
21249
21253
|
if (isRollbackError) {
|
|
21250
21254
|
return {
|
|
21251
21255
|
type: "error",
|
|
@@ -21276,7 +21280,7 @@ class PipelineInstance {
|
|
|
21276
21280
|
}
|
|
21277
21281
|
const stepOperations = step.operations.map((x) => this.executeOperation(x, input, state));
|
|
21278
21282
|
const operationResults = await Promise.all(stepOperations);
|
|
21279
|
-
const isSuccess = operationResults.every((x) => x.type
|
|
21283
|
+
const isSuccess = operationResults.every((x) => isOperationSuccessStatus(x.type));
|
|
21280
21284
|
if (isSuccess) {
|
|
21281
21285
|
const output = step.outputsReducer
|
|
21282
21286
|
? step.outputsReducer(operationResults.map((x) => getOperationOutput(x)))
|
|
@@ -21297,6 +21301,16 @@ class PipelineInstance {
|
|
|
21297
21301
|
}
|
|
21298
21302
|
async executeOperation(operation, input, state) {
|
|
21299
21303
|
try {
|
|
21304
|
+
const shouldSkip = await this.shouldSkipOperation(operation, input, state);
|
|
21305
|
+
if (shouldSkip) {
|
|
21306
|
+
this.logger.info(`Pipeline operation skipped -> operation:${operation.name}`, {
|
|
21307
|
+
input,
|
|
21308
|
+
});
|
|
21309
|
+
return {
|
|
21310
|
+
type: "skipped",
|
|
21311
|
+
input,
|
|
21312
|
+
};
|
|
21313
|
+
}
|
|
21300
21314
|
const operationResult = await operation.operation.action(input, state);
|
|
21301
21315
|
return {
|
|
21302
21316
|
type: "success",
|
|
@@ -21315,6 +21329,12 @@ class PipelineInstance {
|
|
|
21315
21329
|
};
|
|
21316
21330
|
}
|
|
21317
21331
|
}
|
|
21332
|
+
async shouldSkipOperation({ operation, }, input, state) {
|
|
21333
|
+
if (!operation.skipIf) {
|
|
21334
|
+
return false;
|
|
21335
|
+
}
|
|
21336
|
+
return await operation.skipIf(input, state);
|
|
21337
|
+
}
|
|
21318
21338
|
async rollbackOperations(operation, operationInput, operationOutput, state) {
|
|
21319
21339
|
if (!operation.rollbackOperations?.length) {
|
|
21320
21340
|
return {
|