@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.cjs
CHANGED
|
@@ -588,9 +588,9 @@ var InstrumentedClient = class extends import_pg.Client {
|
|
|
588
588
|
}
|
|
589
589
|
async query(...args) {
|
|
590
590
|
const _super = super.query.bind(this);
|
|
591
|
-
const
|
|
591
|
+
const sql4 = args[0];
|
|
592
592
|
let sqlAttribute = false;
|
|
593
|
-
let spanName = txStatements[
|
|
593
|
+
let spanName = txStatements[sql4.toLowerCase()];
|
|
594
594
|
if (!spanName) {
|
|
595
595
|
spanName = "Database Query";
|
|
596
596
|
sqlAttribute = true;
|
|
@@ -658,9 +658,9 @@ function getDialect(connString) {
|
|
|
658
658
|
pool.on("connect", (client) => {
|
|
659
659
|
const originalQuery = client.query;
|
|
660
660
|
client.query = function(...args) {
|
|
661
|
-
const
|
|
661
|
+
const sql4 = args[0];
|
|
662
662
|
let sqlAttribute = false;
|
|
663
|
-
let spanName = txStatements[
|
|
663
|
+
let spanName = txStatements[sql4.toLowerCase()];
|
|
664
664
|
if (!spanName) {
|
|
665
665
|
spanName = "Database Query";
|
|
666
666
|
sqlAttribute = true;
|
|
@@ -1151,23 +1151,23 @@ var TimePeriod = class _TimePeriod {
|
|
|
1151
1151
|
return new _TimePeriod(period, value, offset, complete2);
|
|
1152
1152
|
}
|
|
1153
1153
|
periodStartSQL() {
|
|
1154
|
-
let
|
|
1154
|
+
let sql4 = "NOW()";
|
|
1155
1155
|
if (this.offset !== 0) {
|
|
1156
|
-
|
|
1156
|
+
sql4 = `${sql4} + INTERVAL '${this.offset} ${this.period}'`;
|
|
1157
1157
|
}
|
|
1158
1158
|
if (this.complete) {
|
|
1159
|
-
|
|
1159
|
+
sql4 = `DATE_TRUNC('${this.period}', ${sql4})`;
|
|
1160
1160
|
} else {
|
|
1161
|
-
|
|
1161
|
+
sql4 = `(${sql4})`;
|
|
1162
1162
|
}
|
|
1163
|
-
return
|
|
1163
|
+
return sql4;
|
|
1164
1164
|
}
|
|
1165
1165
|
periodEndSQL() {
|
|
1166
|
-
let
|
|
1166
|
+
let sql4 = this.periodStartSQL();
|
|
1167
1167
|
if (this.value != 0) {
|
|
1168
|
-
|
|
1168
|
+
sql4 = `(${sql4} + INTERVAL '${this.value} ${this.period}')`;
|
|
1169
1169
|
}
|
|
1170
|
-
return
|
|
1170
|
+
return sql4;
|
|
1171
1171
|
}
|
|
1172
1172
|
};
|
|
1173
1173
|
|
|
@@ -3320,24 +3320,11 @@ var import_json_rpc_26 = require("json-rpc-2.0");
|
|
|
3320
3320
|
var opentelemetry6 = __toESM(require("@opentelemetry/api"), 1);
|
|
3321
3321
|
|
|
3322
3322
|
// src/tryExecuteFlow.js
|
|
3323
|
-
var import_kysely6 = require("kysely");
|
|
3324
3323
|
function tryExecuteFlow(db, request, cb) {
|
|
3325
|
-
return withDatabase(db, false, async (
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
sDb
|
|
3330
|
-
);
|
|
3331
|
-
}
|
|
3332
|
-
try {
|
|
3333
|
-
return await withAuditContext(request, async () => {
|
|
3334
|
-
return cb();
|
|
3335
|
-
});
|
|
3336
|
-
} finally {
|
|
3337
|
-
if (runId && sDb) {
|
|
3338
|
-
await import_kysely6.sql`SELECT pg_advisory_unlock(hashtextextended(${runId}, 0))`.execute(sDb).catch(() => void 0);
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3324
|
+
return withDatabase(db, false, async () => {
|
|
3325
|
+
return withAuditContext(request, async () => {
|
|
3326
|
+
return cb();
|
|
3327
|
+
});
|
|
3341
3328
|
});
|
|
3342
3329
|
}
|
|
3343
3330
|
__name(tryExecuteFlow, "tryExecuteFlow");
|
|
@@ -4401,7 +4388,22 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4401
4388
|
throw new Error(`Duplicate step name: ${name}`);
|
|
4402
4389
|
}
|
|
4403
4390
|
usedNames.add(name);
|
|
4404
|
-
|
|
4391
|
+
const { step, inserted } = await db.transaction().execute(async (trx) => {
|
|
4392
|
+
await trx.selectFrom("keel.flow_run").select("id").where("id", "=", runId).forUpdate().executeTakeFirst();
|
|
4393
|
+
const existing = await trx.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
|
|
4394
|
+
if (existing) {
|
|
4395
|
+
return { step: existing, inserted: false };
|
|
4396
|
+
}
|
|
4397
|
+
const created = await trx.insertInto("keel.flow_step").values({
|
|
4398
|
+
run_id: runId,
|
|
4399
|
+
name,
|
|
4400
|
+
stage: options.stage,
|
|
4401
|
+
status: "PENDING" /* PENDING */,
|
|
4402
|
+
type: "UI" /* UI */,
|
|
4403
|
+
startTime: /* @__PURE__ */ new Date()
|
|
4404
|
+
}).returningAll().executeTakeFirstOrThrow();
|
|
4405
|
+
return { step: created, inserted: true };
|
|
4406
|
+
});
|
|
4405
4407
|
if (step && step.status === "COMPLETED" /* COMPLETED */) {
|
|
4406
4408
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4407
4409
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
@@ -4414,15 +4416,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4414
4416
|
}
|
|
4415
4417
|
return parsedData2;
|
|
4416
4418
|
}
|
|
4417
|
-
if (
|
|
4418
|
-
step = await db.insertInto("keel.flow_step").values({
|
|
4419
|
-
run_id: runId,
|
|
4420
|
-
name,
|
|
4421
|
-
stage: options.stage,
|
|
4422
|
-
status: "PENDING" /* PENDING */,
|
|
4423
|
-
type: "UI" /* UI */,
|
|
4424
|
-
startTime: /* @__PURE__ */ new Date()
|
|
4425
|
-
}).returningAll().executeTakeFirst();
|
|
4419
|
+
if (inserted) {
|
|
4426
4420
|
span.setAttribute("rendered", true);
|
|
4427
4421
|
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4428
4422
|
throw new UIRenderDisrupt(
|