@teamkeel/functions-runtime 0.452.0 → 0.452.1
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/index.cjs +19 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4093,6 +4093,23 @@ var defaultOpts = {
|
|
|
4093
4093
|
retries: 4,
|
|
4094
4094
|
timeout: 6e4
|
|
4095
4095
|
};
|
|
4096
|
+
async function insertNewStep(db, runId, name, stage) {
|
|
4097
|
+
await db.transaction().execute(async (trx) => {
|
|
4098
|
+
await trx.selectFrom("keel.flow_run").select("id").where("id", "=", runId).forUpdate().executeTakeFirst();
|
|
4099
|
+
const existing = await trx.selectFrom("keel.flow_step").select("id").where("run_id", "=", runId).where("name", "=", name).where("status", "=", "NEW" /* NEW */).executeTakeFirst();
|
|
4100
|
+
if (existing) {
|
|
4101
|
+
return;
|
|
4102
|
+
}
|
|
4103
|
+
await trx.insertInto("keel.flow_step").values({
|
|
4104
|
+
run_id: runId,
|
|
4105
|
+
name,
|
|
4106
|
+
stage,
|
|
4107
|
+
status: "NEW" /* NEW */,
|
|
4108
|
+
type: "FUNCTION" /* FUNCTION */
|
|
4109
|
+
}).execute();
|
|
4110
|
+
});
|
|
4111
|
+
}
|
|
4112
|
+
__name(insertNewStep, "insertNewStep");
|
|
4096
4113
|
function createFlowContext(runId, data, action, callback, element, spanId, ctx) {
|
|
4097
4114
|
const usedNames = /* @__PURE__ */ new Set();
|
|
4098
4115
|
return {
|
|
@@ -4183,13 +4200,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4183
4200
|
}
|
|
4184
4201
|
throw new ExhuastedRetriesDisrupt();
|
|
4185
4202
|
}
|
|
4186
|
-
await db.
|
|
4187
|
-
run_id: runId,
|
|
4188
|
-
name,
|
|
4189
|
-
stage: options.stage,
|
|
4190
|
-
status: "NEW" /* NEW */,
|
|
4191
|
-
type: "FUNCTION" /* FUNCTION */
|
|
4192
|
-
}).returningAll().executeTakeFirst();
|
|
4203
|
+
await insertNewStep(db, runId, name, options.stage);
|
|
4193
4204
|
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4194
4205
|
throw new StepCreatedDisrupt(
|
|
4195
4206
|
options.retryPolicy ? new Date(
|
|
@@ -4206,13 +4217,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4206
4217
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4207
4218
|
return result;
|
|
4208
4219
|
}
|
|
4209
|
-
await db.
|
|
4210
|
-
run_id: runId,
|
|
4211
|
-
name,
|
|
4212
|
-
stage: options.stage,
|
|
4213
|
-
status: "NEW" /* NEW */,
|
|
4214
|
-
type: "FUNCTION" /* FUNCTION */
|
|
4215
|
-
}).returningAll().executeTakeFirst();
|
|
4220
|
+
await insertNewStep(db, runId, name, options.stage);
|
|
4216
4221
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4217
4222
|
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4218
4223
|
throw new StepCreatedDisrupt();
|