@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.js
CHANGED
|
@@ -4060,6 +4060,23 @@ var defaultOpts = {
|
|
|
4060
4060
|
retries: 4,
|
|
4061
4061
|
timeout: 6e4
|
|
4062
4062
|
};
|
|
4063
|
+
async function insertNewStep(db, runId, name, stage) {
|
|
4064
|
+
await db.transaction().execute(async (trx) => {
|
|
4065
|
+
await trx.selectFrom("keel.flow_run").select("id").where("id", "=", runId).forUpdate().executeTakeFirst();
|
|
4066
|
+
const existing = await trx.selectFrom("keel.flow_step").select("id").where("run_id", "=", runId).where("name", "=", name).where("status", "=", "NEW" /* NEW */).executeTakeFirst();
|
|
4067
|
+
if (existing) {
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
await trx.insertInto("keel.flow_step").values({
|
|
4071
|
+
run_id: runId,
|
|
4072
|
+
name,
|
|
4073
|
+
stage,
|
|
4074
|
+
status: "NEW" /* NEW */,
|
|
4075
|
+
type: "FUNCTION" /* FUNCTION */
|
|
4076
|
+
}).execute();
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4079
|
+
__name(insertNewStep, "insertNewStep");
|
|
4063
4080
|
function createFlowContext(runId, data, action, callback, element, spanId, ctx) {
|
|
4064
4081
|
const usedNames = /* @__PURE__ */ new Set();
|
|
4065
4082
|
return {
|
|
@@ -4150,13 +4167,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4150
4167
|
}
|
|
4151
4168
|
throw new ExhuastedRetriesDisrupt();
|
|
4152
4169
|
}
|
|
4153
|
-
await db.
|
|
4154
|
-
run_id: runId,
|
|
4155
|
-
name,
|
|
4156
|
-
stage: options.stage,
|
|
4157
|
-
status: "NEW" /* NEW */,
|
|
4158
|
-
type: "FUNCTION" /* FUNCTION */
|
|
4159
|
-
}).returningAll().executeTakeFirst();
|
|
4170
|
+
await insertNewStep(db, runId, name, options.stage);
|
|
4160
4171
|
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4161
4172
|
throw new StepCreatedDisrupt(
|
|
4162
4173
|
options.retryPolicy ? new Date(
|
|
@@ -4173,13 +4184,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4173
4184
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4174
4185
|
return result;
|
|
4175
4186
|
}
|
|
4176
|
-
await db.
|
|
4177
|
-
run_id: runId,
|
|
4178
|
-
name,
|
|
4179
|
-
stage: options.stage,
|
|
4180
|
-
status: "NEW" /* NEW */,
|
|
4181
|
-
type: "FUNCTION" /* FUNCTION */
|
|
4182
|
-
}).returningAll().executeTakeFirst();
|
|
4187
|
+
await insertNewStep(db, runId, name, options.stage);
|
|
4183
4188
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4184
4189
|
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4185
4190
|
throw new StepCreatedDisrupt();
|