@teamkeel/functions-runtime 0.455.2 → 0.457.0
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 +53 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -150,7 +150,10 @@ var KeelCamelCasePlugin = class {
|
|
|
150
150
|
}
|
|
151
151
|
constructor(opt) {
|
|
152
152
|
this.opt = opt;
|
|
153
|
-
this.CamelCasePlugin = new CamelCasePlugin(
|
|
153
|
+
this.CamelCasePlugin = new CamelCasePlugin({
|
|
154
|
+
...opt,
|
|
155
|
+
underscoreBeforeDigits: true
|
|
156
|
+
});
|
|
154
157
|
}
|
|
155
158
|
transformQuery(args) {
|
|
156
159
|
return this.CamelCasePlugin.transformQuery(args);
|
|
@@ -994,18 +997,34 @@ __name(isReferencingExistingRecord, "isReferencingExistingRecord");
|
|
|
994
997
|
import { sql as sql2 } from "kysely";
|
|
995
998
|
|
|
996
999
|
// src/casing.js
|
|
997
|
-
import {
|
|
1000
|
+
import {
|
|
1001
|
+
snakeCase as snakeCaseBase,
|
|
1002
|
+
camelCase as camelCaseBase
|
|
1003
|
+
} from "change-case";
|
|
1004
|
+
var splitRegexp = [
|
|
1005
|
+
/([a-z0-9])([A-Z])/g,
|
|
1006
|
+
/([A-Z])([A-Z][a-z])/g,
|
|
1007
|
+
/([a-zA-Z])([0-9])/g
|
|
1008
|
+
];
|
|
1009
|
+
function camelCaseTransform(input, index) {
|
|
1010
|
+
if (index === 0) return input.toLowerCase();
|
|
1011
|
+
const firstChar = input.charAt(0);
|
|
1012
|
+
const lowerChars = input.substr(1).toLowerCase();
|
|
1013
|
+
return `${firstChar.toUpperCase()}${lowerChars}`;
|
|
1014
|
+
}
|
|
1015
|
+
__name(camelCaseTransform, "camelCaseTransform");
|
|
1016
|
+
function snakeCase(str) {
|
|
1017
|
+
return snakeCaseBase(str, { splitRegexp });
|
|
1018
|
+
}
|
|
1019
|
+
__name(snakeCase, "snakeCase");
|
|
1020
|
+
function camelCase(str) {
|
|
1021
|
+
return camelCaseBase(str, { transform: camelCaseTransform, splitRegexp });
|
|
1022
|
+
}
|
|
1023
|
+
__name(camelCase, "camelCase");
|
|
998
1024
|
function camelCaseObject(obj = {}) {
|
|
999
1025
|
const r = {};
|
|
1000
1026
|
for (const key of Object.keys(obj)) {
|
|
1001
|
-
r[camelCase(key
|
|
1002
|
-
transform: camelCaseTransform,
|
|
1003
|
-
splitRegexp: [
|
|
1004
|
-
/([a-z0-9])([A-Z])/g,
|
|
1005
|
-
/([A-Z])([A-Z][a-z])/g,
|
|
1006
|
-
/([a-zA-Z])([0-9])/g
|
|
1007
|
-
]
|
|
1008
|
-
})] = obj[key];
|
|
1027
|
+
r[camelCase(key)] = obj[key];
|
|
1009
1028
|
}
|
|
1010
1029
|
return r;
|
|
1011
1030
|
}
|
|
@@ -1013,13 +1032,7 @@ __name(camelCaseObject, "camelCaseObject");
|
|
|
1013
1032
|
function snakeCaseObject(obj) {
|
|
1014
1033
|
const r = {};
|
|
1015
1034
|
for (const key of Object.keys(obj)) {
|
|
1016
|
-
r[snakeCase(key
|
|
1017
|
-
splitRegexp: [
|
|
1018
|
-
/([a-z0-9])([A-Z])/g,
|
|
1019
|
-
/([A-Z])([A-Z][a-z])/g,
|
|
1020
|
-
/([a-zA-Z])([0-9])/g
|
|
1021
|
-
]
|
|
1022
|
-
})] = obj[key];
|
|
1035
|
+
r[snakeCase(key)] = obj[key];
|
|
1023
1036
|
}
|
|
1024
1037
|
return r;
|
|
1025
1038
|
}
|
|
@@ -1029,13 +1042,6 @@ function upperCamelCase(s) {
|
|
|
1029
1042
|
return s[0].toUpperCase() + s.substring(1);
|
|
1030
1043
|
}
|
|
1031
1044
|
__name(upperCamelCase, "upperCamelCase");
|
|
1032
|
-
function camelCaseTransform(input, index) {
|
|
1033
|
-
if (index === 0) return input.toLowerCase();
|
|
1034
|
-
const firstChar = input.charAt(0);
|
|
1035
|
-
const lowerChars = input.substr(1).toLowerCase();
|
|
1036
|
-
return `${firstChar.toUpperCase()}${lowerChars}`;
|
|
1037
|
-
}
|
|
1038
|
-
__name(camelCaseTransform, "camelCaseTransform");
|
|
1039
1045
|
|
|
1040
1046
|
// src/TimePeriod.js
|
|
1041
1047
|
var TimePeriod = class _TimePeriod {
|
|
@@ -4267,15 +4273,18 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4267
4273
|
const failedSteps = past.filter(
|
|
4268
4274
|
(step) => step.status === "FAILED" /* FAILED */
|
|
4269
4275
|
);
|
|
4276
|
+
const runningSteps = past.filter(
|
|
4277
|
+
(step) => step.status === "RUNNING" /* RUNNING */
|
|
4278
|
+
);
|
|
4270
4279
|
if (newSteps.length > 1) {
|
|
4271
4280
|
throw new Error("Multiple NEW steps found for the same step");
|
|
4272
4281
|
}
|
|
4273
4282
|
if (completedSteps.length > 1) {
|
|
4274
4283
|
throw new Error("Multiple completed steps found for the same step");
|
|
4275
4284
|
}
|
|
4276
|
-
if (completedSteps.length
|
|
4285
|
+
if (completedSteps.length === 1 && newSteps.length === 1) {
|
|
4277
4286
|
throw new Error(
|
|
4278
|
-
"
|
|
4287
|
+
"Found both a completed and a pending NEW step for the same step"
|
|
4279
4288
|
);
|
|
4280
4289
|
}
|
|
4281
4290
|
if (completedSteps.length === 1) {
|
|
@@ -4285,9 +4294,15 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4285
4294
|
}
|
|
4286
4295
|
if (newSteps.length === 1) {
|
|
4287
4296
|
let result = null;
|
|
4288
|
-
await db.updateTable("keel.flow_step").set({
|
|
4297
|
+
const claimed = await db.updateTable("keel.flow_step").set({
|
|
4298
|
+
status: "RUNNING" /* RUNNING */,
|
|
4289
4299
|
startTime: /* @__PURE__ */ new Date()
|
|
4290
|
-
}).where("id", "=", newSteps[0].id).
|
|
4300
|
+
}).where("id", "=", newSteps[0].id).where("status", "=", "NEW" /* NEW */).returning("id").executeTakeFirst();
|
|
4301
|
+
if (!claimed) {
|
|
4302
|
+
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4303
|
+
span.setAttribute("step.status", "RUNNING" /* RUNNING */);
|
|
4304
|
+
throw new StepCreatedDisrupt();
|
|
4305
|
+
}
|
|
4291
4306
|
try {
|
|
4292
4307
|
const stepArgs = {
|
|
4293
4308
|
attempt: failedSteps.length + 1,
|
|
@@ -4325,6 +4340,11 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4325
4340
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4326
4341
|
return result;
|
|
4327
4342
|
}
|
|
4343
|
+
if (runningSteps.length >= 1) {
|
|
4344
|
+
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4345
|
+
span.setAttribute("step.status", "RUNNING" /* RUNNING */);
|
|
4346
|
+
throw new StepCreatedDisrupt();
|
|
4347
|
+
}
|
|
4328
4348
|
await insertNewStep(db, runId, name, options.stage);
|
|
4329
4349
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4330
4350
|
span.setAttribute("step.status", "NEW" /* NEW */);
|