From bde6e0d6172bad40a28f8412ea54f28951d36a62 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 7 May 2025 10:28:14 -0300 Subject: [PATCH 1/6] transloadit init --- .../cancel-assembly/cancel-assembly.mjs | 26 ++++ .../create-assembly/create-assembly.mjs | 57 +++++++++ .../get-assembly-status.mjs | 25 ++++ components/transloadit/package.json | 2 +- .../new-assembly-completed-instant.mjs | 83 +++++++++++++ .../new-assembly-error-instant.mjs | 109 +++++++++++++++++ .../new-upload-instant/new-upload-instant.mjs | 73 ++++++++++++ components/transloadit/transloadit.app.mjs | 112 +++++++++++++++++- 8 files changed, 484 insertions(+), 3 deletions(-) create mode 100644 components/transloadit/actions/cancel-assembly/cancel-assembly.mjs create mode 100644 components/transloadit/actions/create-assembly/create-assembly.mjs create mode 100644 components/transloadit/actions/get-assembly-status/get-assembly-status.mjs create mode 100644 components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs create mode 100644 components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs create mode 100644 components/transloadit/sources/new-upload-instant/new-upload-instant.mjs diff --git a/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs b/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs new file mode 100644 index 0000000000000..545b4408b679c --- /dev/null +++ b/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs @@ -0,0 +1,26 @@ +import transloadit from "../../transloadit.app.mjs"; + +export default { + key: "transloadit-cancel-assembly", + name: "Cancel Assembly", + description: "Cancel a running assembly by its assembly ID. Useful for aborting processing jobs that are no longer needed. [See the documentation](https://transloadit.com/docs/api/assemblies-assembly-id-delete/)", + version: "0.0.{{ts}}", + type: "action", + props: { + transloadit, + assemblyId: { + propDefinition: [ + transloadit, + "assemblyId", + ], + }, + }, + async run({ $ }) { + const response = await this.transloadit.cancelAssembly({ + assemblyId: this.assemblyId, + }); + + $.export("$summary", `Successfully canceled assembly with ID ${response.assembly_id}`); + return response; + }, +}; diff --git a/components/transloadit/actions/create-assembly/create-assembly.mjs b/components/transloadit/actions/create-assembly/create-assembly.mjs new file mode 100644 index 0000000000000..8ab8054c00e37 --- /dev/null +++ b/components/transloadit/actions/create-assembly/create-assembly.mjs @@ -0,0 +1,57 @@ +import transloadit from "../../transloadit.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "transloadit-create-assembly", + name: "Create Assembly", + description: "Create a new assembly to process files using a specified template and steps. [See the documentation](https://transloadit.com/docs/api/assemblies-post/)", + version: "0.0.{{ts}}", + type: "action", + props: { + transloadit, + templateId: { + propDefinition: [ + transloadit, + "templateId", + ], + optional: true, + }, + steps: { + propDefinition: [ + transloadit, + "steps", + ], + optional: true, + }, + files: { + propDefinition: [ + transloadit, + "files", + ], + }, + notifyUrl: { + propDefinition: [ + transloadit, + "notifyUrl", + ], + optional: true, + }, + }, + async run({ $ }) { + if (!this.templateId && !this.steps) { + throw new Error("Either 'templateId' or 'steps' must be provided."); + } + + const response = await this.transloadit.createAssembly({ + templateId: this.templateId, + steps: this.steps + ? JSON.parse(this.steps) + : undefined, + files: this.files, + notifyUrl: this.notifyUrl, + }); + + $.export("$summary", `Assembly created successfully with ID ${response.assembly_id}`); + return response; + }, +}; diff --git a/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs b/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs new file mode 100644 index 0000000000000..7d78d488929a3 --- /dev/null +++ b/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs @@ -0,0 +1,25 @@ +import transloadit from "../../transloadit.app.mjs"; + +export default { + key: "transloadit-get-assembly-status", + name: "Get Assembly Status", + description: "Retrieve the current status and results of an existing assembly. [See the documentation](https://transloadit.com/docs/api/assemblies-assembly-id-get/)", + version: "0.0.{{ts}}", + type: "action", + props: { + transloadit, + assemblyId: { + propDefinition: [ + transloadit, + "assemblyId", + ], + }, + }, + async run({ $ }) { + const response = await this.transloadit.getAssemblyStatus({ + assemblyId: this.assemblyId, + }); + $.export("$summary", `Successfully retrieved assembly status for ${this.assemblyId}`); + return response; + }, +}; diff --git a/components/transloadit/package.json b/components/transloadit/package.json index 5606326e0d245..33b5c1596dfca 100644 --- a/components/transloadit/package.json +++ b/components/transloadit/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs b/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs new file mode 100644 index 0000000000000..565b5e4a219d6 --- /dev/null +++ b/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs @@ -0,0 +1,83 @@ +import transloadit from "../../transloadit.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "transloadit-new-assembly-completed-instant", + name: "New Assembly Completed (Instant)", + description: "Emit new event when a Transloadit assembly finishes processing. Requires the assembly template or notification URL to be configured in Transloadit to call the webhook. [See the documentation](https://transloadit.com/docs/api)", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + transloadit: { + type: "app", + app: "transloadit", + }, + http: { + type: "$.interface.http", + customResponse: true, + }, + db: "$.service.db", + }, + hooks: { + async deploy() { + try { + const assemblies = await this.transloadit._makeRequest({ + method: "GET", + path: "/assemblies", + params: { + auth: { + key: this.transloadit.$auth.api_key, + }, + sort: "created", + order: "desc", + limit: 50, + }, + }); + for (const assembly of assemblies) { + this.$emit(assembly, { + id: assembly.id, + summary: `New assembly completed with ID: ${assembly.id}`, + ts: Date.parse(assembly.finished), + }); + } + } catch (error) { + console.error("Error fetching assemblies:", error); + } + }, + async activate() { + // Webhook setup is expected to be configured within Transloadit; no action necessary + }, + async deactivate() { + // Webhook cleanup is expected to be configured within Transloadit; no action necessary + }, + }, + async run(event) { + const { + httpRequest, body, + } = event; + const computedSignature = this.transloadit.computeSignature(httpRequest.body); + const receivedSignature = httpRequest.headers["transloadit-signature"]; + + if (computedSignature !== receivedSignature) { + await this.http.respond({ + status: 401, + body: "Unauthorized", + }); + return; + } + + await this.http.respond({ + status: 200, + body: "OK", + }); + + if (body.ok === "ASSEMBLY_COMPLETED") { + this.$emit(body, { + id: body.assembly_id, + summary: `Assembly completed with ID: ${body.assembly_id}`, + ts: Date.now(), + }); + } + }, +}; diff --git a/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs b/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs new file mode 100644 index 0000000000000..8ed75cf4d622d --- /dev/null +++ b/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs @@ -0,0 +1,109 @@ +import transloadit from "../../transloadit.app.mjs"; +import { axios } from "@pipedream/platform"; +import crypto from "crypto"; + +export default { + key: "transloadit-new-assembly-error-instant", + name: "New Assembly Error", + description: "Emit new event when an error occurs during assembly processing. Requires webhook support to be enabled through assembly options in Transloadit. [See the documentation](https://transloadit.com/docs/api/)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + transloadit: { + type: "app", + app: "transloadit", + }, + http: { + type: "$.interface.http", + customResponse: true, + }, + db: "$.service.db", + templateId: { + propDefinition: [ + transloadit, + "templateId", + ], + }, + notifyUrl: { + propDefinition: [ + transloadit, + "notifyUrl", + ], + }, + steps: { + propDefinition: [ + transloadit, + "steps", + ], + }, + }, + methods: { + _generateSignature(secretKey, rawBody) { + return crypto.createHmac("sha256", secretKey).update(rawBody) + .digest("hex"); + }, + }, + hooks: { + async deploy() { + const assemblies = await this.transloadit._makeRequest({ + path: "/assemblies", + params: { + limit: 50, + sort: "desc", + }, + }); + for (const assembly of assemblies.items) { + if (assembly.error) { + this.$emit(assembly, { + id: assembly.id, + summary: `Assembly Error: ${assembly.id}`, + ts: new Date(assembly.created).getTime(), + }); + } + } + }, + async activate() { + const response = await this.transloadit.createAssembly({ + templateId: this.templateId, + steps: this.steps, + notifyUrl: this.notifyUrl, + }); + this.db.set("assemblyId", response.assembly_id); + }, + async deactivate() { + const assemblyId = this.db.get("assemblyId"); + if (assemblyId) { + await this.transloadit.cancelAssembly({ + assemblyId, + }); + } + }, + }, + async run(event) { + const rawBody = event.body_raw; + const providedSignature = event.headers["transloadit-signature"]; + const computedSignature = this._generateSignature(this.transloadit.$auth.secret, rawBody); + + if (computedSignature !== providedSignature) { + this.http.respond({ + status: 401, + body: "Unauthorized", + }); + return; + } + + if (event.body.ok === "ASSEMBLY_ERROR") { + this.$emit(event.body, { + id: event.body.assembly_id, + summary: `Assembly error: ${event.body.error}`, + ts: new Date(event.body.assembly_creation_date).getTime(), + }); + } + + this.http.respond({ + status: 200, + body: "OK", + }); + }, +}; diff --git a/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs b/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs new file mode 100644 index 0000000000000..804f552d4e62d --- /dev/null +++ b/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs @@ -0,0 +1,73 @@ +import transloadit from "../../transloadit.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "transloadit-new-upload-instant", + name: "New Upload Instant", + description: "Emit new event when a new file is uploaded to trigger an assembly. [See the documentation](https://transloadit.com/docs/api/)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + transloadit, + http: { + type: "$.interface.http", + customResponse: false, + }, + db: "$.service.db", + templateId: { + propDefinition: [ + transloadit, + "templateId", + ], + }, + notifyUrl: { + propDefinition: [ + transloadit, + "notifyUrl", + ], + }, + files: { + propDefinition: [ + transloadit, + "files", + ], + }, + steps: { + propDefinition: [ + transloadit, + "steps", + ], + optional: true, + }, + }, + hooks: { + async deploy() { + // Logic for emitting historical data, if applicable + }, + async activate() { + // Logic to create a webhook subscription, if applicable + }, + async deactivate() { + // Logic to remove the webhook subscription, if applicable + }, + }, + methods: { + async triggerAssembly() { + return await this.transloadit.createAssembly({ + templateId: this.templateId, + steps: this.steps, + files: this.files, + notifyUrl: this.notifyUrl, + }); + }, + }, + async run(event) { + const { data: body } = event; + this.$emit(body, { + id: body.assembly_id, + summary: `New upload: ${body.assembly_id}`, + ts: Date.parse(body.uploaded_at) || Date.now(), + }); + }, +}; diff --git a/components/transloadit/transloadit.app.mjs b/components/transloadit/transloadit.app.mjs index da1748d53899e..aa07c0d10fe6d 100644 --- a/components/transloadit/transloadit.app.mjs +++ b/components/transloadit/transloadit.app.mjs @@ -1,9 +1,117 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "transloadit", - propDefinitions: {}, + propDefinitions: { + templateId: { + type: "string", + label: "Template ID", + description: "The ID of the template to use for the assembly.", + }, + assemblyId: { + type: "string", + label: "Assembly ID", + description: "The ID of the assembly.", + }, + notifyUrl: { + type: "string", + label: "Notify URL", + description: "The URL to send the webhook notification to.", + }, + fileUrl: { + type: "string", + label: "File URL", + description: "The URL of the file to upload and trigger an assembly.", + }, + steps: { + type: "string", + label: "Steps", + description: "JSON string defining the assembly processing steps.", + optional: true, + }, + files: { + type: "string[]", + label: "Files", + description: "A list of files to process in the assembly.", + }, + }, methods: { - // this.$auth contains connected account data + _baseUrl() { + return "https://api2.transloadit.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + method = "GET", + path = "/", + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + "Content-Type": "application/json", + "Authorization": `Transloadit ${this.$auth.api_key}`, + }, + }); + }, + async createAssembly({ + templateId, steps, files, notifyUrl, + }) { + return this._makeRequest({ + method: "POST", + path: "/assemblies", + data: { + params: { + auth: { + key: this.$auth.api_key, + }, + template_id: templateId, + steps: JSON.parse(steps), + notify_url: notifyUrl, + }, + files, + }, + }); + }, + async getAssemblyStatus({ assemblyId }) { + return this._makeRequest({ + method: "GET", + path: `/assemblies/${assemblyId}`, + }); + }, + async cancelAssembly({ assemblyId }) { + return this._makeRequest({ + method: "DELETE", + path: `/assemblies/${assemblyId}`, + }); + }, + async replayAssemblyNotification({ assemblyId }) { + return this._makeRequest({ + method: "POST", + path: `/assembly_notifications/${assemblyId}/replay`, + data: { + params: { + auth: { + key: this.$auth.api_key, + }, + }, + }, + }); + }, + async emitAssemblyFinishedEvent() { + // Logic to handle the webhook for assembly finished + }, + async emitAssemblyErrorEvent() { + // Logic to handle the webhook for assembly error + }, + async emitFileUploadedEvent() { + // Logic to handle the webhook for file uploaded + }, authKeys() { console.log(Object.keys(this.$auth)); }, From 9c211ba50e21f0c2fc9be75535f7e591adb6fb94 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 7 May 2025 16:42:18 -0300 Subject: [PATCH 2/6] [Components] transloadit #16556 Sources - New Assembly Completed - New Assembly Error Actions - Create Assembly - Cancel Assembly - Get Assembly Status --- common/constants.mjs | 1 + .../cancel-assembly/cancel-assembly.mjs | 8 +- .../create-assembly/create-assembly.mjs | 80 ++++++--- .../get-assembly-status.mjs | 6 +- components/transloadit/common/utils.mjs | 24 +++ components/transloadit/package.json | 6 +- .../transloadit/sources/common/base.mjs | 61 +++++++ .../new-assembly-completed-instant.mjs | 83 --------- .../new-assembly-completed.mjs | 22 +++ .../new-assembly-completed/test-event.mjs | 19 +++ .../new-assembly-error-instant.mjs | 109 ------------ .../new-assembly-error/new-assembly-error.mjs | 22 +++ .../sources/new-assembly-error/test-event.mjs | 21 +++ .../new-upload-instant/new-upload-instant.mjs | 73 -------- components/transloadit/transloadit.app.mjs | 160 ++++++++---------- 15 files changed, 305 insertions(+), 390 deletions(-) create mode 100644 common/constants.mjs create mode 100644 components/transloadit/common/utils.mjs create mode 100644 components/transloadit/sources/common/base.mjs delete mode 100644 components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs create mode 100644 components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs create mode 100644 components/transloadit/sources/new-assembly-completed/test-event.mjs delete mode 100644 components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs create mode 100644 components/transloadit/sources/new-assembly-error/new-assembly-error.mjs create mode 100644 components/transloadit/sources/new-assembly-error/test-event.mjs delete mode 100644 components/transloadit/sources/new-upload-instant/new-upload-instant.mjs diff --git a/common/constants.mjs b/common/constants.mjs new file mode 100644 index 0000000000000..bdbbeda0cca36 --- /dev/null +++ b/common/constants.mjs @@ -0,0 +1 @@ +export const LIMIT = 5000; diff --git a/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs b/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs index 545b4408b679c..ff819cd19edf7 100644 --- a/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs +++ b/components/transloadit/actions/cancel-assembly/cancel-assembly.mjs @@ -4,7 +4,7 @@ export default { key: "transloadit-cancel-assembly", name: "Cancel Assembly", description: "Cancel a running assembly by its assembly ID. Useful for aborting processing jobs that are no longer needed. [See the documentation](https://transloadit.com/docs/api/assemblies-assembly-id-delete/)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { transloadit, @@ -16,11 +16,9 @@ export default { }, }, async run({ $ }) { - const response = await this.transloadit.cancelAssembly({ - assemblyId: this.assemblyId, - }); + const response = await this.transloadit.cancelAssembly(this.assemblyId); - $.export("$summary", `Successfully canceled assembly with ID ${response.assembly_id}`); + $.export("$summary", `Successfully canceled assembly with ID ${this.assemblyId}`); return response; }, }; diff --git a/components/transloadit/actions/create-assembly/create-assembly.mjs b/components/transloadit/actions/create-assembly/create-assembly.mjs index 8ab8054c00e37..7fd2b7fbc73b2 100644 --- a/components/transloadit/actions/create-assembly/create-assembly.mjs +++ b/components/transloadit/actions/create-assembly/create-assembly.mjs @@ -1,14 +1,26 @@ +import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/utils.mjs"; import transloadit from "../../transloadit.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "transloadit-create-assembly", name: "Create Assembly", description: "Create a new assembly to process files using a specified template and steps. [See the documentation](https://transloadit.com/docs/api/assemblies-post/)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { transloadit, + info: { + type: "alert", + alertType: "info", + content: "Note: By default, the `steps` parameter allows you to override Template Steps at runtime. However, if `Allow Steps Override` is set to `false`, then steps and `Template Id` become mutually exclusive. In this case, you can only supply one of these parameters. See [Overruling Templates at Runtime](https://transloadit.com/docs/topics/templates/#overruling-templates-at-runtime).", + }, + allowStepsOverride: { + type: "boolean", + label: "Allow Steps Override", + description: "Set this to `false` to disallow [Overruling Templates at Runtime](https://transloadit.com/docs/topics/templates/#overruling-templates-at-runtime). If you set this to `false` then `Template Id` and `Steps` will be mutually exclusive and you may only supply one of those parameters. Recommended when deploying Transloadit in untrusted environments. This makes sense to set as part of a Template, rather than on the Assembly itself when creating it.", + default: true, + }, templateId: { propDefinition: [ transloadit, @@ -17,41 +29,57 @@ export default { optional: true, }, steps: { - propDefinition: [ - transloadit, - "steps", - ], + type: "object", + label: "Steps", + description: "Assembly Instructions comprise all the Steps executed on uploaded/imported files by the Transloadit back-end during file conversion or encoding. [See the documentation](https://transloadit.com/docs/topics/assembly-instructions/) for more information.", optional: true, }, - files: { - propDefinition: [ - transloadit, - "files", - ], - }, notifyUrl: { - propDefinition: [ - transloadit, - "notifyUrl", - ], + type: "string", + label: "Notify URL", + description: "Transloadit can send a Pingback to your server when the Assembly is completed. We'll send the Assembly status in a form url-encoded JSON string inside of a `transloadit` field in a multipart POST request to the URL supplied here.", + optional: true, + }, + quiet: { + type: "boolean", + label: "Quiet", + description: "Set this to `true` to reduce the response from an Assembly POST request to only the necessary fields. This prevents any potentially confidential information being leaked to the end user who is making the Assembly request. A successful Assembly will only include the `ok` and `assembly_id` fields. An erroneous Assembly will only include the `error`, `http_code`, `message` and `assembly_id` fields. The full Assembly Status will then still be sent to the `Notify URL` if one was specified.", optional: true, }, }, async run({ $ }) { + if (!this.allowStepsOverride && this.templateId && this.steps) { + throw new Error("Either 'templateId' or 'steps' must be provided, not both."); + } if (!this.templateId && !this.steps) { throw new Error("Either 'templateId' or 'steps' must be provided."); } - const response = await this.transloadit.createAssembly({ - templateId: this.templateId, - steps: this.steps - ? JSON.parse(this.steps) - : undefined, - files: this.files, - notifyUrl: this.notifyUrl, - }); + try { + const response = await this.transloadit.createAssembly({ + params: { + template_id: this.templateId, + steps: parseObject(this.steps), + fields: this.fields, + notify_url: this.notifyUrl, + allow_steps_override: this.allowStepsOverride, + quiet: this.quiet, + }, + }); - $.export("$summary", `Assembly created successfully with ID ${response.assembly_id}`); - return response; + if (response.results.resize) { + $.export("$summary", `Assembly created successfully with ID ${response.assembly_id}`); + } else { + $.export("$summary", "The Assembly didn't produce any output. Make sure you used a valid image file"); + } + + return response; + } catch (err) { + let message = `Unable to process Assembly. ${err}`; + if (err.assemblyId) { + message += `More info: https://transloadit.com/assemblies/${err.assemblyId}`; + } + throw new ConfigurationError(message); + } }, }; diff --git a/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs b/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs index 7d78d488929a3..1c4a55085298b 100644 --- a/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs +++ b/components/transloadit/actions/get-assembly-status/get-assembly-status.mjs @@ -4,7 +4,7 @@ export default { key: "transloadit-get-assembly-status", name: "Get Assembly Status", description: "Retrieve the current status and results of an existing assembly. [See the documentation](https://transloadit.com/docs/api/assemblies-assembly-id-get/)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { transloadit, @@ -16,9 +16,7 @@ export default { }, }, async run({ $ }) { - const response = await this.transloadit.getAssemblyStatus({ - assemblyId: this.assemblyId, - }); + const response = await this.transloadit.getAssemblyStatus(this.assemblyId); $.export("$summary", `Successfully retrieved assembly status for ${this.assemblyId}`); return response; }, diff --git a/components/transloadit/common/utils.mjs b/components/transloadit/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/transloadit/common/utils.mjs @@ -0,0 +1,24 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/transloadit/package.json b/components/transloadit/package.json index 33b5c1596dfca..c51513c9e3a87 100644 --- a/components/transloadit/package.json +++ b/components/transloadit/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/transloadit", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Transloadit Components", "main": "transloadit.app.mjs", "keywords": [ @@ -11,5 +11,9 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3", + "transloadit": "^3.0.2" } } diff --git a/components/transloadit/sources/common/base.mjs b/components/transloadit/sources/common/base.mjs new file mode 100644 index 0000000000000..8b994c1f0d777 --- /dev/null +++ b/components/transloadit/sources/common/base.mjs @@ -0,0 +1,61 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import transloadit from "../../transloadit.app.mjs"; + +export default { + props: { + transloadit, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastDate() { + return this.db.get("lastDate") || "1970-01-01 00:00:00"; + }, + _setLastDate(lastDate) { + this.db.set("lastDate", lastDate); + }, + async emitEvent(maxResults = false) { + const lastDate = this._getLastDate(); + + const response = this.transloadit.paginate({ + fn: this.transloadit.listAssemblies, + params: { + fromdate: lastDate, + type: this.getType(), + }, + maxResults, + }); + + let responseArray = []; + for await (const item of response) { + if (Date.parse(item.created) <= Date.parse(lastDate)) break; + responseArray.push(item); + } + + if (responseArray.length) { + this._setLastDate(responseArray[0].created); + } + + for (const item of responseArray.reverse()) { + this.$emit(item, { + id: item.id, + summary: this.getSummary(item), + ts: item.created_ts, + }); + } + }, + }, + hooks: { + async deploy() { + await this.emitEvent(25); + }, + }, + async run() { + await this.emitEvent(); + }, +}; diff --git a/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs b/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs deleted file mode 100644 index 565b5e4a219d6..0000000000000 --- a/components/transloadit/sources/new-assembly-completed-instant/new-assembly-completed-instant.mjs +++ /dev/null @@ -1,83 +0,0 @@ -import transloadit from "../../transloadit.app.mjs"; -import { axios } from "@pipedream/platform"; - -export default { - key: "transloadit-new-assembly-completed-instant", - name: "New Assembly Completed (Instant)", - description: "Emit new event when a Transloadit assembly finishes processing. Requires the assembly template or notification URL to be configured in Transloadit to call the webhook. [See the documentation](https://transloadit.com/docs/api)", - version: "0.0.1", - type: "source", - dedupe: "unique", - props: { - transloadit: { - type: "app", - app: "transloadit", - }, - http: { - type: "$.interface.http", - customResponse: true, - }, - db: "$.service.db", - }, - hooks: { - async deploy() { - try { - const assemblies = await this.transloadit._makeRequest({ - method: "GET", - path: "/assemblies", - params: { - auth: { - key: this.transloadit.$auth.api_key, - }, - sort: "created", - order: "desc", - limit: 50, - }, - }); - for (const assembly of assemblies) { - this.$emit(assembly, { - id: assembly.id, - summary: `New assembly completed with ID: ${assembly.id}`, - ts: Date.parse(assembly.finished), - }); - } - } catch (error) { - console.error("Error fetching assemblies:", error); - } - }, - async activate() { - // Webhook setup is expected to be configured within Transloadit; no action necessary - }, - async deactivate() { - // Webhook cleanup is expected to be configured within Transloadit; no action necessary - }, - }, - async run(event) { - const { - httpRequest, body, - } = event; - const computedSignature = this.transloadit.computeSignature(httpRequest.body); - const receivedSignature = httpRequest.headers["transloadit-signature"]; - - if (computedSignature !== receivedSignature) { - await this.http.respond({ - status: 401, - body: "Unauthorized", - }); - return; - } - - await this.http.respond({ - status: 200, - body: "OK", - }); - - if (body.ok === "ASSEMBLY_COMPLETED") { - this.$emit(body, { - id: body.assembly_id, - summary: `Assembly completed with ID: ${body.assembly_id}`, - ts: Date.now(), - }); - } - }, -}; diff --git a/components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs b/components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs new file mode 100644 index 0000000000000..9f43e83179e46 --- /dev/null +++ b/components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs @@ -0,0 +1,22 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "transloadit-new-assembly-completed", + name: "New Assembly Completed", + description: "Emit new event when a Transloadit assembly finishes processing. [See the documentation](https://transloadit.com/docs/api/assemblies-get/)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getType() { + return "completed"; + }, + getSummary(item) { + return `New assembly completed with ID: ${item.id}`; + }, + }, + sampleEmit, +}; diff --git a/components/transloadit/sources/new-assembly-completed/test-event.mjs b/components/transloadit/sources/new-assembly-completed/test-event.mjs new file mode 100644 index 0000000000000..1004a210b6d5a --- /dev/null +++ b/components/transloadit/sources/new-assembly-completed/test-event.mjs @@ -0,0 +1,19 @@ +export default { + "id": "195c60855fda4fb9a3b2f848374ca4e1", + "parent_id": null, + "account_id": "7c91e50845204dea9ed4791f7d8440f1", + "template_id": "40b0efc6b37f432dbe9485017b52a7b7", + "instance": "tam.transloadit.com", + "notify_url": null, + "redirect_url": null, + "files": "[\"Saturn as seen from the Cas....jpg\"]", + "region": "eu-west-1", + "warning_count": 0, + "execution_duration": 2.337, + "execution_start": "2023-02-11T16:04:24.000Z", + "ok": "ASSEMBLY_COMPLETED", + "error": null, + "created": "2023-02-11T16:04:22.000Z", + "created_ts": 1676131462, + "template_name": "my-template-1676131432311" +} \ No newline at end of file diff --git a/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs b/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs deleted file mode 100644 index 8ed75cf4d622d..0000000000000 --- a/components/transloadit/sources/new-assembly-error-instant/new-assembly-error-instant.mjs +++ /dev/null @@ -1,109 +0,0 @@ -import transloadit from "../../transloadit.app.mjs"; -import { axios } from "@pipedream/platform"; -import crypto from "crypto"; - -export default { - key: "transloadit-new-assembly-error-instant", - name: "New Assembly Error", - description: "Emit new event when an error occurs during assembly processing. Requires webhook support to be enabled through assembly options in Transloadit. [See the documentation](https://transloadit.com/docs/api/)", - version: "0.0.{{ts}}", - type: "source", - dedupe: "unique", - props: { - transloadit: { - type: "app", - app: "transloadit", - }, - http: { - type: "$.interface.http", - customResponse: true, - }, - db: "$.service.db", - templateId: { - propDefinition: [ - transloadit, - "templateId", - ], - }, - notifyUrl: { - propDefinition: [ - transloadit, - "notifyUrl", - ], - }, - steps: { - propDefinition: [ - transloadit, - "steps", - ], - }, - }, - methods: { - _generateSignature(secretKey, rawBody) { - return crypto.createHmac("sha256", secretKey).update(rawBody) - .digest("hex"); - }, - }, - hooks: { - async deploy() { - const assemblies = await this.transloadit._makeRequest({ - path: "/assemblies", - params: { - limit: 50, - sort: "desc", - }, - }); - for (const assembly of assemblies.items) { - if (assembly.error) { - this.$emit(assembly, { - id: assembly.id, - summary: `Assembly Error: ${assembly.id}`, - ts: new Date(assembly.created).getTime(), - }); - } - } - }, - async activate() { - const response = await this.transloadit.createAssembly({ - templateId: this.templateId, - steps: this.steps, - notifyUrl: this.notifyUrl, - }); - this.db.set("assemblyId", response.assembly_id); - }, - async deactivate() { - const assemblyId = this.db.get("assemblyId"); - if (assemblyId) { - await this.transloadit.cancelAssembly({ - assemblyId, - }); - } - }, - }, - async run(event) { - const rawBody = event.body_raw; - const providedSignature = event.headers["transloadit-signature"]; - const computedSignature = this._generateSignature(this.transloadit.$auth.secret, rawBody); - - if (computedSignature !== providedSignature) { - this.http.respond({ - status: 401, - body: "Unauthorized", - }); - return; - } - - if (event.body.ok === "ASSEMBLY_ERROR") { - this.$emit(event.body, { - id: event.body.assembly_id, - summary: `Assembly error: ${event.body.error}`, - ts: new Date(event.body.assembly_creation_date).getTime(), - }); - } - - this.http.respond({ - status: 200, - body: "OK", - }); - }, -}; diff --git a/components/transloadit/sources/new-assembly-error/new-assembly-error.mjs b/components/transloadit/sources/new-assembly-error/new-assembly-error.mjs new file mode 100644 index 0000000000000..0286839abb554 --- /dev/null +++ b/components/transloadit/sources/new-assembly-error/new-assembly-error.mjs @@ -0,0 +1,22 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "transloadit-new-assembly-error", + name: "New Assembly Failed", + description: "Emit new event when a failed occurs during assembly processing. [See the documentation](https://transloadit.com/docs/api/assemblies-get/)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getType() { + return "failed"; + }, + getSummary(item) { + return `New assembly failed with ID: ${item.id}`; + }, + }, + sampleEmit, +}; diff --git a/components/transloadit/sources/new-assembly-error/test-event.mjs b/components/transloadit/sources/new-assembly-error/test-event.mjs new file mode 100644 index 0000000000000..b4d579db0e65f --- /dev/null +++ b/components/transloadit/sources/new-assembly-error/test-event.mjs @@ -0,0 +1,21 @@ +export default { + "id": "195c60855fda4fb9a3b2f848374ca4e1", + "parent_id": null, + "account_id": "7c91e50845204dea9ed4791f7d8440f1", + "template_id": "40b0efc6b37f432dbe9485017b52a7b7", + "instance": "tam.transloadit.com", + "notify_url": null, + "redirect_url": null, + "files": "[]", + "region": "eu-west-1", + "warning_count": 0, + "num_input_files": 0, + "bytes_usage": 0, + "execution_duration": 2.337, + "execution_start": "2023-02-11T16:04:24.000Z", + "ok": null, + "error": "ASSEMBLY_NO_STEPS", + "created": "2023-02-11T16:04:22.000Z", + "created_ts": 1676131462, + "template_name": "" +} \ No newline at end of file diff --git a/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs b/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs deleted file mode 100644 index 804f552d4e62d..0000000000000 --- a/components/transloadit/sources/new-upload-instant/new-upload-instant.mjs +++ /dev/null @@ -1,73 +0,0 @@ -import transloadit from "../../transloadit.app.mjs"; -import { axios } from "@pipedream/platform"; - -export default { - key: "transloadit-new-upload-instant", - name: "New Upload Instant", - description: "Emit new event when a new file is uploaded to trigger an assembly. [See the documentation](https://transloadit.com/docs/api/)", - version: "0.0.{{ts}}", - type: "source", - dedupe: "unique", - props: { - transloadit, - http: { - type: "$.interface.http", - customResponse: false, - }, - db: "$.service.db", - templateId: { - propDefinition: [ - transloadit, - "templateId", - ], - }, - notifyUrl: { - propDefinition: [ - transloadit, - "notifyUrl", - ], - }, - files: { - propDefinition: [ - transloadit, - "files", - ], - }, - steps: { - propDefinition: [ - transloadit, - "steps", - ], - optional: true, - }, - }, - hooks: { - async deploy() { - // Logic for emitting historical data, if applicable - }, - async activate() { - // Logic to create a webhook subscription, if applicable - }, - async deactivate() { - // Logic to remove the webhook subscription, if applicable - }, - }, - methods: { - async triggerAssembly() { - return await this.transloadit.createAssembly({ - templateId: this.templateId, - steps: this.steps, - files: this.files, - notifyUrl: this.notifyUrl, - }); - }, - }, - async run(event) { - const { data: body } = event; - this.$emit(body, { - id: body.assembly_id, - summary: `New upload: ${body.assembly_id}`, - ts: Date.parse(body.uploaded_at) || Date.now(), - }); - }, -}; diff --git a/components/transloadit/transloadit.app.mjs b/components/transloadit/transloadit.app.mjs index aa07c0d10fe6d..8b6ea5d67a02a 100644 --- a/components/transloadit/transloadit.app.mjs +++ b/components/transloadit/transloadit.app.mjs @@ -1,4 +1,5 @@ -import { axios } from "@pipedream/platform"; +import Transloadit from "transloadit"; +import { LIMIT } from "../../common/constants.mjs"; export default { type: "app", @@ -7,113 +8,94 @@ export default { templateId: { type: "string", label: "Template ID", - description: "The ID of the template to use for the assembly.", + description: "The ID of the Template that contains your Assembly Instructions. If you set `Allow steps Override` to `false` then `steps` and `Template Id` will be mutually exclusive and you may only supply one of these parameters.", + async options({ page }) { + const { items } = await this.listTemplates({ + params: { + page: page * LIMIT, + pageSize: LIMIT, + }, + }); + + return items.map(({ + id: value, name: label, + }) => ({ + label, + value, + })); + }, }, assemblyId: { type: "string", label: "Assembly ID", description: "The ID of the assembly.", - }, - notifyUrl: { - type: "string", - label: "Notify URL", - description: "The URL to send the webhook notification to.", - }, - fileUrl: { - type: "string", - label: "File URL", - description: "The URL of the file to upload and trigger an assembly.", - }, - steps: { - type: "string", - label: "Steps", - description: "JSON string defining the assembly processing steps.", - optional: true, - }, - files: { - type: "string[]", - label: "Files", - description: "A list of files to process in the assembly.", + async options({ page }) { + const { items } = await this.listAssemblies({ + params: { + page: page * LIMIT, + pageSize: LIMIT, + }, + }); + + return items.map(({ id }) => id); + }, }, }, methods: { _baseUrl() { return "https://api2.transloadit.com"; }, - async _makeRequest(opts = {}) { - const { - $ = this, - method = "GET", - path = "/", - headers, - ...otherOpts - } = opts; - return axios($, { - ...otherOpts, - method, - url: this._baseUrl() + path, - headers: { - ...headers, - "Content-Type": "application/json", - "Authorization": `Transloadit ${this.$auth.api_key}`, - }, - }); - }, - async createAssembly({ - templateId, steps, files, notifyUrl, - }) { - return this._makeRequest({ - method: "POST", - path: "/assemblies", - data: { - params: { - auth: { - key: this.$auth.api_key, - }, - template_id: templateId, - steps: JSON.parse(steps), - notify_url: notifyUrl, - }, - files, - }, + _client() { + return new Transloadit({ + authKey: this.$auth.auth_key, + authSecret: this.$auth.auth_secret, }); }, - async getAssemblyStatus({ assemblyId }) { - return this._makeRequest({ - method: "GET", - path: `/assemblies/${assemblyId}`, + createAssembly(opts = {}) { + const client = this._client(); + return client.createAssembly({ + ...opts, + waitForCompletion: true, }); }, - async cancelAssembly({ assemblyId }) { - return this._makeRequest({ - method: "DELETE", - path: `/assemblies/${assemblyId}`, - }); - }, - async replayAssemblyNotification({ assemblyId }) { - return this._makeRequest({ - method: "POST", - path: `/assembly_notifications/${assemblyId}/replay`, - data: { - params: { - auth: { - key: this.$auth.api_key, - }, - }, - }, - }); + listAssemblies(opts = {}) { + const client = this._client(); + return client.listAssemblies(opts); }, - async emitAssemblyFinishedEvent() { - // Logic to handle the webhook for assembly finished + listTemplates(opts = {}) { + const client = this._client(); + return client.listTemplates(opts); }, - async emitAssemblyErrorEvent() { - // Logic to handle the webhook for assembly error + cancelAssembly(assemblyId) { + const client = this._client(); + return client.cancelAssembly(assemblyId); }, - async emitFileUploadedEvent() { - // Logic to handle the webhook for file uploaded + getAssemblyStatus(assemblyId) { + const client = this._client(); + return client.getAssembly(assemblyId); }, - authKeys() { - console.log(Object.keys(this.$auth)); + async *paginate({ + fn, params = {}, maxResults = null, + }) { + let hasMore = false; + let count = 0; + let page = 0; + + do { + params.page = ++page; + params.pagesize = LIMIT; + const { items } = await fn(params); + for (const d of items) { + yield d; + + if (maxResults && ++count === maxResults) { + return count; + } + } + + hasMore = items.length; + + } while (hasMore); }, }, }; From da937bec02699af24742803ef76c9361020cf204 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 7 May 2025 16:44:10 -0300 Subject: [PATCH 3/6] pnpm update --- pnpm-lock.yaml | 151 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 138 insertions(+), 13 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8eff70230254..ef0bfc8b0d353 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2112,8 +2112,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/catch_all_verifier: - specifiers: {} + components/catch_all_verifier: {} components/cats: dependencies: @@ -9916,8 +9915,7 @@ importers: components/planning_center: {} - components/planpoint: - specifiers: {} + components/planpoint: {} components/planso_forms: {} @@ -13450,7 +13448,14 @@ importers: components/translate_com: {} - components/transloadit: {} + components/transloadit: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 + transloadit: + specifier: ^3.0.2 + version: 3.0.2 components/travis_ci: dependencies: @@ -15307,14 +15312,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/browsers: dependencies: '@sparticuz/chromium': @@ -21711,6 +21708,9 @@ packages: columns-sdk@0.0.6: resolution: {integrity: sha512-yaOcRgaV+XdIarxDOvpzUErxvvzbAfxiM4zQrrGvzCRMxdBBIg6CYThkcPxhl0BdCYwDumL4GQFrkefAMk38cg==} + combine-errors@3.0.3: + resolution: {integrity: sha512-C8ikRNRMygCwaTx+Ek3Yr+OuZzgZjduCOfSQBjbM8V3MfgcjSTeto/GXP6PAwKvJz/v15b7GHZvx5rOlczFw/Q==} + combined-stream@1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} @@ -22016,6 +22016,9 @@ packages: resolution: {integrity: sha512-/sR1A6avsI0IOeeOThWlnZqnx5/aoBsI2FznAmFiMC5loQissvItrVAkkc+AJEhBb/FC9nkVkjH2NyqYQkzNHw==} engines: {'0': node >=0.6.0} + custom-error-instance@2.1.1: + resolution: {integrity: sha512-p6JFxJc3M4OTD2li2qaHkDCw9SfMw82Ldr6OC9Je1aXiGfhx2W8p3GaoeaGrPJTUN9NirTM/KTxHWMUdR1rsUg==} + cyclist@1.0.2: resolution: {integrity: sha512-0sVXIohTfLqVIW3kb/0n6IiWF3Ifj5nm2XaSrLq2DI6fKIGa2fYAZdk917rUneaeLVpYfFcyXE2ft0fe3remsA==} @@ -24389,6 +24392,10 @@ packages: resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==} engines: {node: '>=12'} + into-stream@6.0.0: + resolution: {integrity: sha512-XHbaOAvP+uFKUFsOgoNPRjLkwB+I22JFPFe5OjTkQ0nwgj6+pSjb4NmB6VMxaPshLiOf+zcpOCBQuLwC1KHhZA==} + engines: {node: '>=10'} + invariant@2.2.4: resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} @@ -24978,6 +24985,9 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} + js-base64@2.6.4: + resolution: {integrity: sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==} + js-base64@3.7.2: resolution: {integrity: sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==} @@ -25408,6 +25418,24 @@ packages: lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} + lodash._baseiteratee@4.7.0: + resolution: {integrity: sha512-nqB9M+wITz0BX/Q2xg6fQ8mLkyfF7MU7eE+MNBNjTHFKeKaZAPEzEg+E8LWxKWf1DQVflNEn9N49yAuqKh2mWQ==} + + lodash._basetostring@4.12.0: + resolution: {integrity: sha512-SwcRIbyxnN6CFEEK4K1y+zuApvWdpQdBHM/swxP962s8HIxPO3alBH5t3m/dl+f4CMUug6sJb7Pww8d13/9WSw==} + + lodash._baseuniq@4.6.0: + resolution: {integrity: sha512-Ja1YevpHZctlI5beLA7oc5KNDhGcPixFhcqSiORHNsp/1QTv7amAXzw+gu4YOvErqVlMVyIJGgtzeepCnnur0A==} + + lodash._createset@4.0.3: + resolution: {integrity: sha512-GTkC6YMprrJZCYU3zcqZj+jkXkrXzq3IPBcF/fIPpNEAB4hZEtXU8zp/RwKOvZl43NUmwDbyRk3+ZTbeRdEBXA==} + + lodash._root@3.0.1: + resolution: {integrity: sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==} + + lodash._stringtopath@4.8.0: + resolution: {integrity: sha512-SXL66C731p0xPDC5LZg4wI5H+dJo/EO4KTqOMwLYCH3+FmmfAKJEZCm6ohGpI+T1xwsDsJCfL4OnhorllvlTPQ==} + lodash.assign@4.2.0: resolution: {integrity: sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw==} @@ -25498,6 +25526,9 @@ packages: lodash.sortby@4.7.0: resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} + lodash.throttle@4.1.1: + resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} + lodash.topath@4.5.2: resolution: {integrity: sha512-1/W4dM+35DwvE/iEd1M9ekewOSTlpFekhw9mhAtrwjVqUr83/ilQiyAvmg4tVX7Unkcfl1KC+i9WdaT4B6aQcg==} @@ -25513,6 +25544,9 @@ packages: lodash.uniq@4.5.0: resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} + lodash.uniqby@4.5.0: + resolution: {integrity: sha512-IRt7cfTtHy6f1aRVA5n7kT8rgN3N1nH6MOWLcHfpWG2SH19E3JksLK38MktLxZDhlAjCP9jpIXkOnRXlu6oByQ==} + lodash.uniqby@4.7.0: resolution: {integrity: sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww==} @@ -26775,6 +26809,10 @@ packages: resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==} engines: {node: '>=4'} + p-is-promise@3.0.0: + resolution: {integrity: sha512-Wo8VsW4IRQSKVXsJCn7TomUaVtyfjVDn3nUP7kE967BQk0CwFpdbZs0X0uk5sW9mkBa9eNM7hCMaG93WUAwxYQ==} + engines: {node: '>=8'} + p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -27319,6 +27357,10 @@ packages: prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + proper-lockfile@2.0.1: + resolution: {integrity: sha512-rjaeGbsmhNDcDInmwi4MuI6mRwJu6zq8GjYCLuSuE7GF+4UjgzkL69sVKKJ2T2xH61kK7rXvGYpvaTu909oXaQ==} + engines: {node: '>=4.0.0'} + property-information@6.5.0: resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==} @@ -27933,6 +27975,9 @@ packages: resolution: {integrity: sha512-dUOvLMJ0/JJYEn8NrpOaGNE7X3vpI5XlZS/u0ANjqtcZVKnIxP7IgCFwrKTxENw29emmwug53awKtaMm4i9g5w==} engines: {node: '>=14'} + retry@0.10.1: + resolution: {integrity: sha512-ZXUSQYTHdl3uS7IuCehYfMzKyIDBNoAuUblvy5oGO5UJSUTmStUUVPXbA9Qxd173Bgre53yCQczQuHgRWAdvJQ==} + retry@0.12.0: resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} engines: {node: '>= 4'} @@ -28958,6 +29003,10 @@ packages: resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} engines: {node: '>=12'} + transloadit@3.0.2: + resolution: {integrity: sha512-FvhKs0EBiQufK29irGLM/4aMIrfU5S/TiHB3h+DcO2hjRnVVM2WC278UQJCrNO4L/REE8IKWx/mQzQW2MrrLsg==} + engines: {node: '>= 10.0.0'} + tree-kill@1.2.2: resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} hasBin: true @@ -29093,6 +29142,9 @@ packages: turndown@7.2.0: resolution: {integrity: sha512-eCZGBN4nNNqM9Owkv9HAtWRYfLA4h909E/WGAWWBpmB275ehNhZyk87/Tpvjbp0jjNl9XwCsbe6bm6CqFsgD+A==} + tus-js-client@2.3.2: + resolution: {integrity: sha512-5a2rm7gp+G7Z+ZB0AO4PzD/dwczB3n1fZeWO5W8AWLJ12RRk1rY4Aeb2VAYX9oKGE+/rGPrdxoFPA/vDSVKnpg==} + tweetnacl@0.14.5: resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} @@ -39140,6 +39192,11 @@ snapshots: - debug - supports-color + combine-errors@3.0.3: + dependencies: + custom-error-instance: 2.1.1 + lodash.uniqby: 4.5.0 + combined-stream@1.0.8: dependencies: delayed-stream: 1.0.0 @@ -39491,6 +39548,8 @@ snapshots: custom-error-generator@7.0.0: {} + custom-error-instance@2.1.1: {} + cyclist@1.0.2: {} cytoscape-cose-bilkent@4.1.0(cytoscape@3.30.4): @@ -42673,6 +42732,11 @@ snapshots: internmap@2.0.3: {} + into-stream@6.0.0: + dependencies: + from2: 2.3.0 + p-is-promise: 3.0.0 + invariant@2.2.4: dependencies: loose-envify: 1.4.0 @@ -43517,6 +43581,8 @@ snapshots: joycon@3.1.1: {} + js-base64@2.6.4: {} + js-base64@3.7.2: {} js-base64@3.7.7: {} @@ -44021,6 +44087,25 @@ snapshots: lodash-es@4.17.21: {} + lodash._baseiteratee@4.7.0: + dependencies: + lodash._stringtopath: 4.8.0 + + lodash._basetostring@4.12.0: {} + + lodash._baseuniq@4.6.0: + dependencies: + lodash._createset: 4.0.3 + lodash._root: 3.0.1 + + lodash._createset@4.0.3: {} + + lodash._root@3.0.1: {} + + lodash._stringtopath@4.8.0: + dependencies: + lodash._basetostring: 4.12.0 + lodash.assign@4.2.0: {} lodash.camelcase@4.3.0: {} @@ -44079,6 +44164,8 @@ snapshots: lodash.sortby@4.7.0: {} + lodash.throttle@4.1.1: {} + lodash.topath@4.5.2: {} lodash.transform@4.6.0: {} @@ -44089,6 +44176,11 @@ snapshots: lodash.uniq@4.5.0: {} + lodash.uniqby@4.5.0: + dependencies: + lodash._baseiteratee: 4.7.0 + lodash._baseuniq: 4.6.0 + lodash.uniqby@4.7.0: {} lodash@4.17.21: {} @@ -45972,6 +46064,8 @@ snapshots: p-finally@1.0.0: {} + p-is-promise@3.0.0: {} + p-limit@2.3.0: dependencies: p-try: 2.2.0 @@ -46523,6 +46617,11 @@ snapshots: object-assign: 4.1.1 react-is: 16.13.1 + proper-lockfile@2.0.1: + dependencies: + graceful-fs: 4.2.11 + retry: 0.10.1 + property-information@6.5.0: {} proto3-json-serializer@1.1.1: @@ -47701,6 +47800,8 @@ snapshots: - encoding - supports-color + retry@0.10.1: {} + retry@0.12.0: {} retry@0.13.1: {} @@ -49057,6 +49158,20 @@ snapshots: dependencies: punycode: 2.3.1 + transloadit@3.0.2: + dependencies: + debug: 4.4.0 + form-data: 3.0.2 + got: 11.8.6 + into-stream: 6.0.0 + is-stream: 2.0.1 + lodash: 4.17.21 + p-map: 4.0.0 + tus-js-client: 2.3.2 + uuid: 8.3.2 + transitivePeerDependencies: + - supports-color + tree-kill@1.2.2: {} trim-lines@3.0.1: {} @@ -49219,6 +49334,16 @@ snapshots: dependencies: '@mixmark-io/domino': 2.2.0 + tus-js-client@2.3.2: + dependencies: + buffer-from: 1.1.2 + combine-errors: 3.0.3 + is-stream: 2.0.1 + js-base64: 2.6.4 + lodash.throttle: 4.1.1 + proper-lockfile: 2.0.1 + url-parse: 1.5.10 + tweetnacl@0.14.5: {} twilio@3.84.1: From 6296ed0737043f15952ee0794cf8c8e8d609b492 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 8 May 2025 13:07:42 -0300 Subject: [PATCH 4/6] some adjusts --- .../transloadit/actions/create-assembly/create-assembly.mjs | 5 ++--- {common => components/transloadit/common}/constants.mjs | 0 components/transloadit/transloadit.app.mjs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) rename {common => components/transloadit/common}/constants.mjs (100%) diff --git a/components/transloadit/actions/create-assembly/create-assembly.mjs b/components/transloadit/actions/create-assembly/create-assembly.mjs index 7fd2b7fbc73b2..3026a116cdf2e 100644 --- a/components/transloadit/actions/create-assembly/create-assembly.mjs +++ b/components/transloadit/actions/create-assembly/create-assembly.mjs @@ -49,10 +49,10 @@ export default { }, async run({ $ }) { if (!this.allowStepsOverride && this.templateId && this.steps) { - throw new Error("Either 'templateId' or 'steps' must be provided, not both."); + throw new ConfigurationError("Either 'templateId' or 'steps' must be provided, not both."); } if (!this.templateId && !this.steps) { - throw new Error("Either 'templateId' or 'steps' must be provided."); + throw new ConfigurationError("Either 'templateId' or 'steps' must be provided."); } try { @@ -60,7 +60,6 @@ export default { params: { template_id: this.templateId, steps: parseObject(this.steps), - fields: this.fields, notify_url: this.notifyUrl, allow_steps_override: this.allowStepsOverride, quiet: this.quiet, diff --git a/common/constants.mjs b/components/transloadit/common/constants.mjs similarity index 100% rename from common/constants.mjs rename to components/transloadit/common/constants.mjs diff --git a/components/transloadit/transloadit.app.mjs b/components/transloadit/transloadit.app.mjs index 8b6ea5d67a02a..615ce5b8507fa 100644 --- a/components/transloadit/transloadit.app.mjs +++ b/components/transloadit/transloadit.app.mjs @@ -1,5 +1,5 @@ import Transloadit from "transloadit"; -import { LIMIT } from "../../common/constants.mjs"; +import { LIMIT } from "./common/constants.mjs"; export default { type: "app", From 77086a991f4f6d90ad9b83b76fa4508686040099 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 8 May 2025 16:37:13 -0300 Subject: [PATCH 5/6] Update components/transloadit/transloadit.app.mjs Co-authored-by: michelle0927 --- components/transloadit/transloadit.app.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/transloadit/transloadit.app.mjs b/components/transloadit/transloadit.app.mjs index 615ce5b8507fa..731017a4d5ed8 100644 --- a/components/transloadit/transloadit.app.mjs +++ b/components/transloadit/transloadit.app.mjs @@ -13,7 +13,7 @@ export default { const { items } = await this.listTemplates({ params: { page: page * LIMIT, - pageSize: LIMIT, + pagesize: LIMIT, }, }); From 65309784ea5da80bd9319bd8303bf4d03fae46d8 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 8 May 2025 16:38:10 -0300 Subject: [PATCH 6/6] Update components/transloadit/transloadit.app.mjs Co-authored-by: michelle0927 --- components/transloadit/transloadit.app.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/transloadit/transloadit.app.mjs b/components/transloadit/transloadit.app.mjs index 731017a4d5ed8..5fdb69ccf30b5 100644 --- a/components/transloadit/transloadit.app.mjs +++ b/components/transloadit/transloadit.app.mjs @@ -33,7 +33,7 @@ export default { const { items } = await this.listAssemblies({ params: { page: page * LIMIT, - pageSize: LIMIT, + pagesize: LIMIT, }, });