@teamkeel/functions-runtime 0.425.1 → 0.427.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 CHANGED
@@ -785,6 +785,21 @@ var File = class _File extends InlineFile {
785
785
  const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
786
786
  return new URL(url);
787
787
  }
788
+ // Generates a presigned upload URL. If the file doesn't have a key, a new one will be generated
789
+ async getPresignedUploadUrl() {
790
+ if (!s3Client) {
791
+ throw new Error("S3 client is required");
792
+ }
793
+ if (!this.key) {
794
+ this._key = import_ksuid.default.randomSync().string;
795
+ }
796
+ const command = new import_client_s3.PutObjectCommand({
797
+ Bucket: process.env.KEEL_FILES_BUCKET_NAME,
798
+ Key: "files/" + this.key
799
+ });
800
+ const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
801
+ return new URL(url);
802
+ }
788
803
  // Persists the file
789
804
  toDbRecord() {
790
805
  return {
@@ -2895,6 +2910,31 @@ var datePickerInput = /* @__PURE__ */ __name((name, options) => {
2895
2910
  };
2896
2911
  }, "datePickerInput");
2897
2912
 
2913
+ // src/flows/ui/elements/input/file.ts
2914
+ var fileInput = /* @__PURE__ */ __name((name, options) => {
2915
+ return {
2916
+ __type: "input",
2917
+ uiConfig: {
2918
+ __type: "ui.input.file",
2919
+ name,
2920
+ label: options?.label || name,
2921
+ optional: options?.optional || false,
2922
+ disabled: options?.disabled || false,
2923
+ helpText: options?.helpText
2924
+ },
2925
+ validate: options?.validate,
2926
+ getData: /* @__PURE__ */ __name((x) => x, "getData"),
2927
+ getPresignedUploadURL: /* @__PURE__ */ __name((async (input) => {
2928
+ const file2 = new File(input);
2929
+ const url = await file2.getPresignedUploadUrl();
2930
+ return {
2931
+ url: url.toString(),
2932
+ key: file2.key
2933
+ };
2934
+ }), "getPresignedUploadURL")
2935
+ };
2936
+ }, "fileInput");
2937
+
2898
2938
  // src/flows/ui/elements/iterator.ts
2899
2939
  var iterator = /* @__PURE__ */ __name((name, options) => {
2900
2940
  return {
@@ -3213,10 +3253,11 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
3213
3253
  let step = await db.selectFrom("keel.flow_step").where("run_id", "=", runId).where("name", "=", name).selectAll().executeTakeFirst();
3214
3254
  if (step && step.status === "COMPLETED" /* COMPLETED */) {
3215
3255
  span.setAttribute(KEEL_INTERNAL_ATTR, KEEL_INTERNAL_CHILDREN);
3256
+ const parsedData2 = transformRichDataTypes(step.value);
3216
3257
  if (step.action) {
3217
- return { data: step.value, action: step.action };
3258
+ return { data: parsedData2, action: step.action };
3218
3259
  }
3219
- return step.value;
3260
+ return parsedData2;
3220
3261
  }
3221
3262
  if (!step) {
3222
3263
  step = await db.insertInto("keel.flow_step").values({
@@ -3283,10 +3324,11 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
3283
3324
  spanId,
3284
3325
  endTime: /* @__PURE__ */ new Date()
3285
3326
  }).where("id", "=", step.id).returningAll().executeTakeFirst();
3327
+ const parsedData = transformRichDataTypes(data);
3286
3328
  if (action) {
3287
- return { data, action };
3329
+ return { data: parsedData, action };
3288
3330
  }
3289
- return data;
3331
+ return parsedData;
3290
3332
  });
3291
3333
  }), "page"),
3292
3334
  inputs: {
@@ -3295,7 +3337,8 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
3295
3337
  boolean: booleanInput,
3296
3338
  dataGrid: dataGridInput,
3297
3339
  datePicker: datePickerInput,
3298
- scan
3340
+ scan,
3341
+ file: fileInput
3299
3342
  },
3300
3343
  display: {
3301
3344
  divider,