@teamkeel/functions-runtime 0.453.0 → 0.454.2
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 +63 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +62 -19
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ __export(index_exports, {
|
|
|
47
47
|
RetryConstant: () => RetryConstant,
|
|
48
48
|
STEP_STATUS: () => STEP_STATUS,
|
|
49
49
|
STEP_TYPE: () => STEP_TYPE,
|
|
50
|
+
Signature: () => Signature,
|
|
50
51
|
TaskAPI: () => TaskAPI,
|
|
51
52
|
checkBuiltInPermissions: () => checkBuiltInPermissions,
|
|
52
53
|
createFlowContext: () => createFlowContext,
|
|
@@ -3341,6 +3342,37 @@ function tryExecuteFlow(db, request, cb) {
|
|
|
3341
3342
|
}
|
|
3342
3343
|
__name(tryExecuteFlow, "tryExecuteFlow");
|
|
3343
3344
|
|
|
3345
|
+
// src/flows/ui/elements/input/signature.ts
|
|
3346
|
+
var Signature = class {
|
|
3347
|
+
static {
|
|
3348
|
+
__name(this, "Signature");
|
|
3349
|
+
}
|
|
3350
|
+
constructor(data) {
|
|
3351
|
+
this.svg = data.svg;
|
|
3352
|
+
this.signedAt = data.signedAt;
|
|
3353
|
+
}
|
|
3354
|
+
async toPngDataURL() {
|
|
3355
|
+
const sharp = (await import("sharp")).default;
|
|
3356
|
+
const png = await sharp(Buffer.from(this.svg), { density: 300 }).png().toBuffer();
|
|
3357
|
+
return `data:image/png;base64,${png.toString("base64")}`;
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
var signatureInput = /* @__PURE__ */ __name((name, options) => {
|
|
3361
|
+
return {
|
|
3362
|
+
__type: "input",
|
|
3363
|
+
uiConfig: {
|
|
3364
|
+
__type: "ui.input.signature",
|
|
3365
|
+
name,
|
|
3366
|
+
label: options?.label || name,
|
|
3367
|
+
optional: options?.optional || false,
|
|
3368
|
+
disabled: options?.disabled || false,
|
|
3369
|
+
helpText: options?.helpText
|
|
3370
|
+
},
|
|
3371
|
+
validate: options?.validate,
|
|
3372
|
+
getData: /* @__PURE__ */ __name((x) => new Signature(x), "getData")
|
|
3373
|
+
};
|
|
3374
|
+
}, "signatureInput");
|
|
3375
|
+
|
|
3344
3376
|
// src/flows/ui/elements/input/text.ts
|
|
3345
3377
|
var textInput = /* @__PURE__ */ __name((name, options) => {
|
|
3346
3378
|
return {
|
|
@@ -3472,6 +3504,28 @@ var selectOne = /* @__PURE__ */ __name((name, options) => {
|
|
|
3472
3504
|
}, "selectOne");
|
|
3473
3505
|
|
|
3474
3506
|
// src/flows/ui/page.ts
|
|
3507
|
+
async function applyElementGetData(content, data) {
|
|
3508
|
+
if (!data || typeof data !== "object" || !Array.isArray(content)) return data;
|
|
3509
|
+
for (const c of content) {
|
|
3510
|
+
const resolved = await c;
|
|
3511
|
+
if (!resolved || !("__type" in resolved)) continue;
|
|
3512
|
+
const name = resolved.uiConfig?.name;
|
|
3513
|
+
if (!name || !(name in data)) continue;
|
|
3514
|
+
if (resolved.__type === "input" && typeof resolved.getData === "function") {
|
|
3515
|
+
data[name] = resolved.getData(data[name]);
|
|
3516
|
+
} else if (resolved.__type === "iterator") {
|
|
3517
|
+
const rows = data[name];
|
|
3518
|
+
const inner = resolved.uiConfig?.content;
|
|
3519
|
+
if (Array.isArray(rows) && Array.isArray(inner)) {
|
|
3520
|
+
for (let i = 0; i < rows.length; i++) {
|
|
3521
|
+
rows[i] = await applyElementGetData(inner, rows[i]);
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
return data;
|
|
3527
|
+
}
|
|
3528
|
+
__name(applyElementGetData, "applyElementGetData");
|
|
3475
3529
|
async function callbackFn(elements, elementName, callbackName, data) {
|
|
3476
3530
|
const element = elements.find(
|
|
3477
3531
|
(el) => el.uiConfig && el.uiConfig.name === elementName
|
|
@@ -4009,23 +4063,6 @@ var imageCapture = /* @__PURE__ */ __name((name, options) => {
|
|
|
4009
4063
|
};
|
|
4010
4064
|
}, "imageCapture");
|
|
4011
4065
|
|
|
4012
|
-
// src/flows/ui/elements/input/signature.ts
|
|
4013
|
-
var signatureInput = /* @__PURE__ */ __name((name, options) => {
|
|
4014
|
-
return {
|
|
4015
|
-
__type: "input",
|
|
4016
|
-
uiConfig: {
|
|
4017
|
-
__type: "ui.input.signature",
|
|
4018
|
-
name,
|
|
4019
|
-
label: options?.label || name,
|
|
4020
|
-
optional: options?.optional || false,
|
|
4021
|
-
disabled: options?.disabled || false,
|
|
4022
|
-
helpText: options?.helpText
|
|
4023
|
-
},
|
|
4024
|
-
validate: options?.validate,
|
|
4025
|
-
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
4026
|
-
};
|
|
4027
|
-
}, "signatureInput");
|
|
4028
|
-
|
|
4029
4066
|
// src/flows/ui/elements/iterator.ts
|
|
4030
4067
|
var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
4031
4068
|
return {
|
|
@@ -4368,7 +4405,10 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4368
4405
|
if (step && step.status === "COMPLETED" /* COMPLETED */) {
|
|
4369
4406
|
span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
|
|
4370
4407
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4371
|
-
const parsedData2 =
|
|
4408
|
+
const parsedData2 = await applyElementGetData(
|
|
4409
|
+
options.content,
|
|
4410
|
+
transformRichDataTypes(step.value)
|
|
4411
|
+
);
|
|
4372
4412
|
if (step.action) {
|
|
4373
4413
|
return { data: parsedData2, action: step.action };
|
|
4374
4414
|
}
|
|
@@ -4445,7 +4485,10 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
4445
4485
|
endTime: /* @__PURE__ */ new Date()
|
|
4446
4486
|
}).where("id", "=", step.id).returningAll().executeTakeFirst();
|
|
4447
4487
|
span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
|
|
4448
|
-
const parsedData =
|
|
4488
|
+
const parsedData = await applyElementGetData(
|
|
4489
|
+
options.content,
|
|
4490
|
+
transformRichDataTypes(data)
|
|
4491
|
+
);
|
|
4449
4492
|
if (action) {
|
|
4450
4493
|
return { data: parsedData, action };
|
|
4451
4494
|
}
|
|
@@ -4718,6 +4761,7 @@ __name(ksuid, "ksuid");
|
|
|
4718
4761
|
RetryConstant,
|
|
4719
4762
|
STEP_STATUS,
|
|
4720
4763
|
STEP_TYPE,
|
|
4764
|
+
Signature,
|
|
4721
4765
|
TaskAPI,
|
|
4722
4766
|
checkBuiltInPermissions,
|
|
4723
4767
|
createFlowContext,
|