@teamkeel/functions-runtime 0.454.2 → 0.454.3
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 +33 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -530,9 +530,9 @@ var InstrumentedClient = class extends Client {
|
|
|
530
530
|
}
|
|
531
531
|
async query(...args) {
|
|
532
532
|
const _super = super.query.bind(this);
|
|
533
|
-
const
|
|
533
|
+
const sql4 = args[0];
|
|
534
534
|
let sqlAttribute = false;
|
|
535
|
-
let spanName = txStatements[
|
|
535
|
+
let spanName = txStatements[sql4.toLowerCase()];
|
|
536
536
|
if (!spanName) {
|
|
537
537
|
spanName = "Database Query";
|
|
538
538
|
sqlAttribute = true;
|
|
@@ -600,9 +600,9 @@ function getDialect(connString) {
|
|
|
600
600
|
pool.on("connect", (client) => {
|
|
601
601
|
const originalQuery = client.query;
|
|
602
602
|
client.query = function(...args) {
|
|
603
|
-
const
|
|
603
|
+
const sql4 = args[0];
|
|
604
604
|
let sqlAttribute = false;
|
|
605
|
-
let spanName = txStatements[
|
|
605
|
+
let spanName = txStatements[sql4.toLowerCase()];
|
|
606
606
|
if (!spanName) {
|
|
607
607
|
spanName = "Database Query";
|
|
608
608
|
sqlAttribute = true;
|
|
@@ -1097,23 +1097,23 @@ var TimePeriod = class _TimePeriod {
|
|
|
1097
1097
|
return new _TimePeriod(period, value, offset, complete2);
|
|
1098
1098
|
}
|
|
1099
1099
|
periodStartSQL() {
|
|
1100
|
-
let
|
|
1100
|
+
let sql4 = "NOW()";
|
|
1101
1101
|
if (this.offset !== 0) {
|
|
1102
|
-
|
|
1102
|
+
sql4 = `${sql4} + INTERVAL '${this.offset} ${this.period}'`;
|
|
1103
1103
|
}
|
|
1104
1104
|
if (this.complete) {
|
|
1105
|
-
|
|
1105
|
+
sql4 = `DATE_TRUNC('${this.period}', ${sql4})`;
|
|
1106
1106
|
} else {
|
|
1107
|
-
|
|
1107
|
+
sql4 = `(${sql4})`;
|
|
1108
1108
|
}
|
|
1109
|
-
return
|
|
1109
|
+
return sql4;
|
|
1110
1110
|
}
|
|
1111
1111
|
periodEndSQL() {
|
|
1112
|
-
let
|
|
1112
|
+
let sql4 = this.periodStartSQL();
|
|
1113
1113
|
if (this.value != 0) {
|
|
1114
|
-
|
|
1114
|
+
sql4 = `(${sql4} + INTERVAL '${this.value} ${this.period}')`;
|
|
1115
1115
|
}
|
|
1116
|
-
return
|
|
1116
|
+
return sql4;
|
|
1117
1117
|
}
|
|
1118
1118
|
};
|
|
1119
1119
|
|
|
@@ -3286,24 +3286,11 @@ import {
|
|
|
3286
3286
|
import * as opentelemetry6 from "@opentelemetry/api";
|
|
3287
3287
|
|
|
3288
3288
|
// src/tryExecuteFlow.js
|
|
3289
|
-
import { sql as sql4 } from "kysely";
|
|
3290
3289
|
function tryExecuteFlow(db, request, cb) {
|
|
3291
|
-
return withDatabase(db, false, async (
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
sDb
|
|
3296
|
-
);
|
|
3297
|
-
}
|
|
3298
|
-
try {
|
|
3299
|
-
return await withAuditContext(request, async () => {
|
|
3300
|
-
return cb();
|
|
3301
|
-
});
|
|
3302
|
-
} finally {
|
|
3303
|
-
if (runId && sDb) {
|
|
3304
|
-
await sql4`SELECT pg_advisory_unlock(hashtextextended(${runId}, 0))`.execute(sDb).catch(() => void 0);
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3290
|
+
return withDatabase(db, false, async () => {
|
|
3291
|
+
return withAuditContext(request, async () => {
|
|
3292
|
+
return cb();
|
|
3293
|
+
});
|
|
3307
3294
|
});
|
|
3308
3295
|
}
|
|
3309
3296
|
__name(tryExecuteFlow, "tryExecuteFlow");
|
|
@@ -4367,7 +4354,22 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4367
4354
|
throw new Error(`Duplicate step name: ${name}`);
|
|
4368
4355
|
}
|
|
4369
4356
|
usedNames.add(name);
|
|
4370
|
-
|
|
4357
|
+
const { step, inserted } = await db.transaction().execute(async (trx) => {
|
|
4358
|
+
await trx.selectFrom("keel.flow_run").select("id").where("id", "=", runId).forUpdate().executeTakeFirst();
|
|
4359
|
+
const existing = await trx.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
|
|
4360
|
+
if (existing) {
|
|
4361
|
+
return { step: existing, inserted: false };
|
|
4362
|
+
}
|
|
4363
|
+
const created = await trx.insertInto("keel.flow_step").values({
|
|
4364
|
+
run_id: runId,
|
|
4365
|
+
name,
|
|
4366
|
+
stage: options.stage,
|
|
4367
|
+
status: "PENDING" /* PENDING */,
|
|
4368
|
+
type: "UI" /* UI */,
|
|
4369
|
+
startTime: /* @__PURE__ */ new Date()
|
|
4370
|
+
}).returningAll().executeTakeFirstOrThrow();
|
|
4371
|
+
return { step: created, inserted: true };
|
|
4372
|
+
});
|
|
4371
4373
|
if (step && step.status === "COMPLETED" /* COMPLETED */) {
|
|
4372
4374
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4373
4375
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
@@ -4380,15 +4382,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4380
4382
|
}
|
|
4381
4383
|
return parsedData2;
|
|
4382
4384
|
}
|
|
4383
|
-
if (
|
|
4384
|
-
step = await db.insertInto("keel.flow_step").values({
|
|
4385
|
-
run_id: runId,
|
|
4386
|
-
name,
|
|
4387
|
-
stage: options.stage,
|
|
4388
|
-
status: "PENDING" /* PENDING */,
|
|
4389
|
-
type: "UI" /* UI */,
|
|
4390
|
-
startTime: /* @__PURE__ */ new Date()
|
|
4391
|
-
}).returningAll().executeTakeFirst();
|
|
4385
|
+
if (inserted) {
|
|
4392
4386
|
span.setAttribute("rendered", true);
|
|
4393
4387
|
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4394
4388
|
throw new UIRenderDisrupt(
|