@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.d.cts CHANGED
@@ -686,9 +686,14 @@ interface UiElementInputImageCaptureApiResponse extends BaseUiInputResponse<"ui.
686
686
  type ElementDataType = {
687
687
  svg: string;
688
688
  signedAt: string;
689
- ipAddress: string;
690
689
  };
691
- type UiElementInputSignature = InputElement<ElementDataType, {}>;
690
+ declare class Signature {
691
+ readonly svg: string;
692
+ readonly signedAt: string;
693
+ constructor(data: ElementDataType);
694
+ toPngDataURL(): Promise<string>;
695
+ }
696
+ type UiElementInputSignature = InputElement<ElementDataType, {}, Signature>;
692
697
  interface UiElementInputSignatureApiResponse extends BaseUiInputResponse<"ui.input.signature", ElementDataType> {
693
698
  }
694
699
 
@@ -1684,4 +1689,4 @@ type FlowListResult = {
1684
1689
  };
1685
1690
  };
1686
1691
 
1687
- export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, type ListResult, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, type PartialPageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskFlowFunction, type TaskStatus, type TimestampQueryInput, type TraceAPI, type TraceAttributeValue, type TraceAttributes, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, createTraceAPI, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
1692
+ export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, type ListResult, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, type PartialPageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, Signature, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskFlowFunction, type TaskStatus, type TimestampQueryInput, type TraceAPI, type TraceAttributeValue, type TraceAttributes, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, createTraceAPI, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
package/dist/index.d.ts CHANGED
@@ -686,9 +686,14 @@ interface UiElementInputImageCaptureApiResponse extends BaseUiInputResponse<"ui.
686
686
  type ElementDataType = {
687
687
  svg: string;
688
688
  signedAt: string;
689
- ipAddress: string;
690
689
  };
691
- type UiElementInputSignature = InputElement<ElementDataType, {}>;
690
+ declare class Signature {
691
+ readonly svg: string;
692
+ readonly signedAt: string;
693
+ constructor(data: ElementDataType);
694
+ toPngDataURL(): Promise<string>;
695
+ }
696
+ type UiElementInputSignature = InputElement<ElementDataType, {}, Signature>;
692
697
  interface UiElementInputSignatureApiResponse extends BaseUiInputResponse<"ui.input.signature", ElementDataType> {
693
698
  }
694
699
 
@@ -1684,4 +1689,4 @@ type FlowListResult = {
1684
1689
  };
1685
1690
  };
1686
1691
 
1687
- export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, type ListResult, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, type PartialPageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskFlowFunction, type TaskStatus, type TimestampQueryInput, type TraceAPI, type TraceAttributeValue, type TraceAttributes, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, createTraceAPI, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
1692
+ export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, type ListResult, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, type PartialPageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, Signature, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskFlowFunction, type TaskStatus, type TimestampQueryInput, type TraceAPI, type TraceAttributeValue, type TraceAttributes, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, createTraceAPI, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
package/dist/index.js CHANGED
@@ -3308,6 +3308,37 @@ function tryExecuteFlow(db, request, cb) {
3308
3308
  }
3309
3309
  __name(tryExecuteFlow, "tryExecuteFlow");
3310
3310
 
3311
+ // src/flows/ui/elements/input/signature.ts
3312
+ var Signature = class {
3313
+ static {
3314
+ __name(this, "Signature");
3315
+ }
3316
+ constructor(data) {
3317
+ this.svg = data.svg;
3318
+ this.signedAt = data.signedAt;
3319
+ }
3320
+ async toPngDataURL() {
3321
+ const sharp = (await import("sharp")).default;
3322
+ const png = await sharp(Buffer.from(this.svg), { density: 300 }).png().toBuffer();
3323
+ return `data:image/png;base64,${png.toString("base64")}`;
3324
+ }
3325
+ };
3326
+ var signatureInput = /* @__PURE__ */ __name((name, options) => {
3327
+ return {
3328
+ __type: "input",
3329
+ uiConfig: {
3330
+ __type: "ui.input.signature",
3331
+ name,
3332
+ label: options?.label || name,
3333
+ optional: options?.optional || false,
3334
+ disabled: options?.disabled || false,
3335
+ helpText: options?.helpText
3336
+ },
3337
+ validate: options?.validate,
3338
+ getData: /* @__PURE__ */ __name((x) => new Signature(x), "getData")
3339
+ };
3340
+ }, "signatureInput");
3341
+
3311
3342
  // src/flows/ui/elements/input/text.ts
3312
3343
  var textInput = /* @__PURE__ */ __name((name, options) => {
3313
3344
  return {
@@ -3439,6 +3470,28 @@ var selectOne = /* @__PURE__ */ __name((name, options) => {
3439
3470
  }, "selectOne");
3440
3471
 
3441
3472
  // src/flows/ui/page.ts
3473
+ async function applyElementGetData(content, data) {
3474
+ if (!data || typeof data !== "object" || !Array.isArray(content)) return data;
3475
+ for (const c of content) {
3476
+ const resolved = await c;
3477
+ if (!resolved || !("__type" in resolved)) continue;
3478
+ const name = resolved.uiConfig?.name;
3479
+ if (!name || !(name in data)) continue;
3480
+ if (resolved.__type === "input" && typeof resolved.getData === "function") {
3481
+ data[name] = resolved.getData(data[name]);
3482
+ } else if (resolved.__type === "iterator") {
3483
+ const rows = data[name];
3484
+ const inner = resolved.uiConfig?.content;
3485
+ if (Array.isArray(rows) && Array.isArray(inner)) {
3486
+ for (let i = 0; i < rows.length; i++) {
3487
+ rows[i] = await applyElementGetData(inner, rows[i]);
3488
+ }
3489
+ }
3490
+ }
3491
+ }
3492
+ return data;
3493
+ }
3494
+ __name(applyElementGetData, "applyElementGetData");
3442
3495
  async function callbackFn(elements, elementName, callbackName, data) {
3443
3496
  const element = elements.find(
3444
3497
  (el) => el.uiConfig && el.uiConfig.name === elementName
@@ -3976,23 +4029,6 @@ var imageCapture = /* @__PURE__ */ __name((name, options) => {
3976
4029
  };
3977
4030
  }, "imageCapture");
3978
4031
 
3979
- // src/flows/ui/elements/input/signature.ts
3980
- var signatureInput = /* @__PURE__ */ __name((name, options) => {
3981
- return {
3982
- __type: "input",
3983
- uiConfig: {
3984
- __type: "ui.input.signature",
3985
- name,
3986
- label: options?.label || name,
3987
- optional: options?.optional || false,
3988
- disabled: options?.disabled || false,
3989
- helpText: options?.helpText
3990
- },
3991
- validate: options?.validate,
3992
- getData: /* @__PURE__ */ __name((x) => x, "getData")
3993
- };
3994
- }, "signatureInput");
3995
-
3996
4032
  // src/flows/ui/elements/iterator.ts
3997
4033
  var iterator = /* @__PURE__ */ __name((name, options) => {
3998
4034
  return {
@@ -4335,7 +4371,10 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
4335
4371
  if (step && step.status === "COMPLETED" /* COMPLETED */) {
4336
4372
  span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
4337
4373
  span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
4338
- const parsedData2 = transformRichDataTypes(step.value);
4374
+ const parsedData2 = await applyElementGetData(
4375
+ options.content,
4376
+ transformRichDataTypes(step.value)
4377
+ );
4339
4378
  if (step.action) {
4340
4379
  return { data: parsedData2, action: step.action };
4341
4380
  }
@@ -4412,7 +4451,10 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
4412
4451
  endTime: /* @__PURE__ */ new Date()
4413
4452
  }).where("id", "=", step.id).returningAll().executeTakeFirst();
4414
4453
  span.setAttribute("step.status", "COMPLETED" /* COMPLETED */);
4415
- const parsedData = transformRichDataTypes(data);
4454
+ const parsedData = await applyElementGetData(
4455
+ options.content,
4456
+ transformRichDataTypes(data)
4457
+ );
4416
4458
  if (action) {
4417
4459
  return { data: parsedData, action };
4418
4460
  }
@@ -4684,6 +4726,7 @@ export {
4684
4726
  RetryConstant,
4685
4727
  STEP_STATUS,
4686
4728
  STEP_TYPE,
4729
+ Signature,
4687
4730
  TaskAPI,
4688
4731
  checkBuiltInPermissions,
4689
4732
  createFlowContext,