@teamkeel/functions-runtime 0.451.1 → 0.452.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 +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4077,12 +4077,15 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4077
4077
|
step: /* @__PURE__ */ __name(async (name, optionsOrFn, fn) => {
|
|
4078
4078
|
return withSpan(`Step - ${name}`, async (span) => {
|
|
4079
4079
|
return withUserSpan(span, async () => {
|
|
4080
|
+
span.setAttribute("step.type", "FUNCTION" /* FUNCTION */);
|
|
4081
|
+
span.setAttribute("step.name", name);
|
|
4080
4082
|
const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
|
|
4081
4083
|
const actualFn = typeof optionsOrFn === "function" ? optionsOrFn : fn;
|
|
4082
4084
|
options.retries = options.retries ?? defaultOpts.retries;
|
|
4083
4085
|
options.timeout = options.timeout ?? defaultOpts.timeout;
|
|
4084
4086
|
const db = useDatabase();
|
|
4085
4087
|
if (usedNames.has(name)) {
|
|
4088
|
+
span.setAttribute("step.status", "FAILED" /* FAILED */);
|
|
4086
4089
|
await db.insertInto("keel.flow_step").values({
|
|
4087
4090
|
run_id: runId,
|
|
4088
4091
|
name,
|
|
@@ -4119,6 +4122,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4119
4122
|
}
|
|
4120
4123
|
if (completedSteps.length === 1) {
|
|
4121
4124
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4125
|
+
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4122
4126
|
return completedSteps[0].value;
|
|
4123
4127
|
}
|
|
4124
4128
|
if (newSteps.length === 1) {
|
|
@@ -4140,6 +4144,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4140
4144
|
error: e instanceof Error ? e.message : "An error occurred"
|
|
4141
4145
|
}).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
|
|
4142
4146
|
if (failedSteps.length >= options.retries || e instanceof NonRetriableError) {
|
|
4147
|
+
span.setAttribute("step.status", "FAILED" /* FAILED */);
|
|
4143
4148
|
if (options.onFailure) {
|
|
4144
4149
|
await options.onFailure();
|
|
4145
4150
|
}
|
|
@@ -4152,6 +4157,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4152
4157
|
status: "NEW" /* NEW */,
|
|
4153
4158
|
type: "FUNCTION" /* FUNCTION */
|
|
4154
4159
|
}).returningAll().executeTakeFirst();
|
|
4160
|
+
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4155
4161
|
throw new StepCreatedDisrupt(
|
|
4156
4162
|
options.retryPolicy ? new Date(
|
|
4157
4163
|
Date.now() + options.retryPolicy(failedSteps.length + 1)
|
|
@@ -4164,6 +4170,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4164
4170
|
spanId,
|
|
4165
4171
|
endTime: /* @__PURE__ */ new Date()
|
|
4166
4172
|
}).where("id", "=", newSteps[0].id).returningAll().executeTakeFirst();
|
|
4173
|
+
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4167
4174
|
return result;
|
|
4168
4175
|
}
|
|
4169
4176
|
await db.insertInto("keel.flow_step").values({
|
|
@@ -4174,6 +4181,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4174
4181
|
type: "FUNCTION" /* FUNCTION */
|
|
4175
4182
|
}).returningAll().executeTakeFirst();
|
|
4176
4183
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4184
|
+
span.setAttribute("step.status", "NEW" /* NEW */);
|
|
4177
4185
|
throw new StepCreatedDisrupt();
|
|
4178
4186
|
});
|
|
4179
4187
|
});
|
|
@@ -4182,9 +4190,12 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4182
4190
|
page: /* @__PURE__ */ __name((async (name, options) => {
|
|
4183
4191
|
return withSpan(`Page - ${name}`, async (span) => {
|
|
4184
4192
|
return withUserSpan(span, async () => {
|
|
4193
|
+
span.setAttribute("step.type", "UI" /* UI */);
|
|
4194
|
+
span.setAttribute("step.name", name);
|
|
4185
4195
|
const db = useDatabase();
|
|
4186
4196
|
const isCallback = element && callback;
|
|
4187
4197
|
if (usedNames.has(name)) {
|
|
4198
|
+
span.setAttribute("step.status", "FAILED" /* FAILED */);
|
|
4188
4199
|
await db.insertInto("keel.flow_step").values({
|
|
4189
4200
|
run_id: runId,
|
|
4190
4201
|
name,
|
|
@@ -4201,6 +4212,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4201
4212
|
let step = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
|
|
4202
4213
|
if (step && step.status === "COMPLETED" /* COMPLETED */) {
|
|
4203
4214
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4215
|
+
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4204
4216
|
const parsedData2 = transformRichDataTypes(step.value);
|
|
4205
4217
|
if (step.action) {
|
|
4206
4218
|
return { data: parsedData2, action: step.action };
|
|
@@ -4217,6 +4229,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4217
4229
|
startTime: /* @__PURE__ */ new Date()
|
|
4218
4230
|
}).returningAll().executeTakeFirst();
|
|
4219
4231
|
span.setAttribute("rendered", true);
|
|
4232
|
+
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4220
4233
|
throw new UIRenderDisrupt(
|
|
4221
4234
|
step?.id,
|
|
4222
4235
|
(await page(options, null, null)).page
|
|
@@ -4224,6 +4237,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4224
4237
|
}
|
|
4225
4238
|
if (isCallback) {
|
|
4226
4239
|
span.setAttribute("callback", callback);
|
|
4240
|
+
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4227
4241
|
try {
|
|
4228
4242
|
const response = await callbackFn(
|
|
4229
4243
|
options.content,
|
|
@@ -4243,6 +4257,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4243
4257
|
}
|
|
4244
4258
|
}
|
|
4245
4259
|
if (!data) {
|
|
4260
|
+
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4246
4261
|
throw new UIRenderDisrupt(
|
|
4247
4262
|
step?.id,
|
|
4248
4263
|
(await page(options, null, null)).page
|
|
@@ -4255,8 +4270,10 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4255
4270
|
}
|
|
4256
4271
|
} catch (e) {
|
|
4257
4272
|
if (e instanceof UIRenderDisrupt) {
|
|
4273
|
+
span.setAttribute("step.status", "PENDING" /* PENDING */);
|
|
4258
4274
|
throw e;
|
|
4259
4275
|
}
|
|
4276
|
+
span.setAttribute("step.status", "FAILED" /* FAILED */);
|
|
4260
4277
|
await db.updateTable("keel.flow_step").set({
|
|
4261
4278
|
status: "FAILED" /* FAILED */,
|
|
4262
4279
|
spanId,
|
|
@@ -4272,6 +4289,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4272
4289
|
spanId,
|
|
4273
4290
|
endTime: /* @__PURE__ */ new Date()
|
|
4274
4291
|
}).where("id", "=", step.id).returningAll().executeTakeFirst();
|
|
4292
|
+
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4275
4293
|
const parsedData = transformRichDataTypes(data);
|
|
4276
4294
|
if (action) {
|
|
4277
4295
|
return { data: parsedData, action };
|