From 0e7289b0cb8e25e5dded6617625a3c06a1637add Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 22 Aug 2025 15:50:59 -0400 Subject: [PATCH 1/2] new components --- .../cancel-shipment/cancel-shipment.mjs | 26 +++ .../create-shipment/create-shipment.mjs | 148 +++++++++++++++++ .../get-shipment-state/get-shipment-state.mjs | 26 +++ .../actions/get-shipment/get-shipment.mjs | 26 +++ .../actions/list-shipments/list-shipments.mjs | 52 ++++++ .../list-time-slots/list-time-slots.mjs | 35 ++++ components/trunkrs/common/constants.mjs | 48 ++++++ components/trunkrs/package.json | 7 +- .../trunkrs/sources/common/base-webhook.mjs | 56 +++++++ .../new-shipment-created.mjs | 18 ++ .../new-shipment-created/test-event.mjs | 10 ++ .../shipment-cancelled/shipment-cancelled.mjs | 18 ++ .../sources/shipment-cancelled/test-event.mjs | 10 ++ .../shipment-reviewed/shipment-reviewed.mjs | 18 ++ .../sources/shipment-reviewed/test-event.mjs | 10 ++ .../shipment-state-updated.mjs | 18 ++ .../shipment-state-updated/test-event.mjs | 10 ++ components/trunkrs/trunkrs.app.mjs | 156 +++++++++++++++++- 18 files changed, 685 insertions(+), 7 deletions(-) create mode 100644 components/trunkrs/actions/cancel-shipment/cancel-shipment.mjs create mode 100644 components/trunkrs/actions/create-shipment/create-shipment.mjs create mode 100644 components/trunkrs/actions/get-shipment-state/get-shipment-state.mjs create mode 100644 components/trunkrs/actions/get-shipment/get-shipment.mjs create mode 100644 components/trunkrs/actions/list-shipments/list-shipments.mjs create mode 100644 components/trunkrs/actions/list-time-slots/list-time-slots.mjs create mode 100644 components/trunkrs/common/constants.mjs create mode 100644 components/trunkrs/sources/common/base-webhook.mjs create mode 100644 components/trunkrs/sources/new-shipment-created/new-shipment-created.mjs create mode 100644 components/trunkrs/sources/new-shipment-created/test-event.mjs create mode 100644 components/trunkrs/sources/shipment-cancelled/shipment-cancelled.mjs create mode 100644 components/trunkrs/sources/shipment-cancelled/test-event.mjs create mode 100644 components/trunkrs/sources/shipment-reviewed/shipment-reviewed.mjs create mode 100644 components/trunkrs/sources/shipment-reviewed/test-event.mjs create mode 100644 components/trunkrs/sources/shipment-state-updated/shipment-state-updated.mjs create mode 100644 components/trunkrs/sources/shipment-state-updated/test-event.mjs diff --git a/components/trunkrs/actions/cancel-shipment/cancel-shipment.mjs b/components/trunkrs/actions/cancel-shipment/cancel-shipment.mjs new file mode 100644 index 0000000000000..8621b7830ed05 --- /dev/null +++ b/components/trunkrs/actions/cancel-shipment/cancel-shipment.mjs @@ -0,0 +1,26 @@ +import trunkrs from "../../trunkrs.app.mjs"; + +export default { + key: "trunkrs-cancel-shipment", + name: "Cancel Shipment", + description: "Cancel a shipment. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/29cfeecfd2273-cancel-shipment)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + trunkrsNr: { + propDefinition: [ + trunkrs, + "trunkrsNr", + ], + }, + }, + async run({ $ }) { + const { data } = await this.trunkrs.cancelShipment({ + $, + trunkrsNr: this.trunkrsNr, + }); + $.export("$summary", `Successfully cancelled shipment ${this.trunkrsNr}.`); + return data; + }, +}; diff --git a/components/trunkrs/actions/create-shipment/create-shipment.mjs b/components/trunkrs/actions/create-shipment/create-shipment.mjs new file mode 100644 index 0000000000000..48bc2ec7c4012 --- /dev/null +++ b/components/trunkrs/actions/create-shipment/create-shipment.mjs @@ -0,0 +1,148 @@ +import trunkrs from "../../trunkrs.app.mjs"; + +export default { + key: "trunkrs-create-shipment", + name: "Create Shipment", + description: "Create a new shipment. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/85ba39933b755-create-shipment)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + orderReference: { + type: "string", + label: "Order Reference", + description: "Internal order reference provided by customer, this must be unique", + }, + senderName: { + type: "string", + label: "Sender Name", + description: "The name of the sender", + }, + senderEmailAddress: { + type: "string", + label: "Sender Email Address", + description: "The email address of the sender", + }, + senderStreetAddress: { + type: "string", + label: "Sender Street Address", + description: "The street address of the sender", + }, + senderPostalCode: { + type: "string", + label: "Sender Postal Code", + description: "The postal code of the sender", + }, + senderCity: { + type: "string", + label: "Sender City", + description: "The city of the sender", + }, + senderCountry: { + propDefinition: [ + trunkrs, + "country", + ], + description: "The country of the sender", + }, + recipientName: { + type: "string", + label: "Recipient Name", + description: "The name of the recipient", + }, + recipientEmailAddress: { + type: "string", + label: "Recipient Email Address", + description: "The email address of the recipient", + }, + recipientStreetAddress: { + type: "string", + label: "Recipient Street Address", + description: "The street address of the recipient", + }, + recipientPostalCode: { + type: "string", + label: "Recipient Postal Code", + description: "The postal code of the recipient", + }, + recipientCity: { + type: "string", + label: "Recipient City", + description: "The city of the recipient", + }, + recipientCountry: { + propDefinition: [ + trunkrs, + "country", + ], + }, + parcelWeightUnit: { + type: "string", + label: "Parcel Weight Unit", + description: "The unit of weight for the parcels", + options: [ + "g", + "kg", + ], + }, + parcelWeights: { + type: "string[]", + label: "Parcel Weights", + description: "An array of weights for the parcels in the unit provided by the parcelWeightUnit prop", + }, + timeSlotId: { + propDefinition: [ + trunkrs, + "timeSlotId", + (c) => ({ + country: c.recipientCountry, + postalCode: c.recipientPostalCode, + }), + ], + }, + service: { + type: "string", + label: "Service", + description: "Specifies the service level of this parcel. To use the freezer service, set the value to SAME_DAY_FROZEN_FOOD.", + options: [ + "SAME_DAY", + "SAME_DAY_FROZEN_FOOD", + ], + optional: true, + }, + }, + async run({ $ }) { + const { data } = await this.trunkrs.createShipment({ + $, + data: { + orderReference: this.orderReference, + sender: { + name: this.senderName, + emailAddress: this.senderEmailAddress, + address: this.senderStreetAddress, + postalCode: this.senderPostalCode, + city: this.senderCity, + country: this.senderCountry, + }, + recipient: { + name: this.recipientName, + emailAddress: this.recipientEmailAddress, + address: this.recipientStreetAddress, + postalCode: this.recipientPostalCode, + city: this.recipientCity, + country: this.recipientCountry, + }, + parcel: this.parcelWeights.map((weight) => ({ + weight: { + unit: this.parcelWeightUnit, + value: +weight, + }, + })), + timeSlotId: this.timeSlotId, + service: this.service, + }, + }); + $.export("$summary", "Successfully created shipment."); + return data; + }, +}; diff --git a/components/trunkrs/actions/get-shipment-state/get-shipment-state.mjs b/components/trunkrs/actions/get-shipment-state/get-shipment-state.mjs new file mode 100644 index 0000000000000..b020cb14cdda9 --- /dev/null +++ b/components/trunkrs/actions/get-shipment-state/get-shipment-state.mjs @@ -0,0 +1,26 @@ +import trunkrs from "../../trunkrs.app.mjs"; + +export default { + key: "trunkrs-get-shipment-state", + name: "Get Shipment State", + description: "Get the state of a shipment. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/47b5b585da6c9-get-status-for-specific-shipment)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + trunkrsNr: { + propDefinition: [ + trunkrs, + "trunkrsNr", + ], + }, + }, + async run({ $ }) { + const { data } = await this.trunkrs.getShipmentState({ + $, + trunkrsNr: this.trunkrsNr, + }); + $.export("$summary", `Successfully fetched shipment state for ${this.trunkrsNr}.`); + return data; + }, +}; diff --git a/components/trunkrs/actions/get-shipment/get-shipment.mjs b/components/trunkrs/actions/get-shipment/get-shipment.mjs new file mode 100644 index 0000000000000..4fd087e2d6948 --- /dev/null +++ b/components/trunkrs/actions/get-shipment/get-shipment.mjs @@ -0,0 +1,26 @@ +import trunkrs from "../../trunkrs.app.mjs"; + +export default { + key: "trunkrs-get-shipment", + name: "Get Shipment", + description: "Get a shipment by its Trunkrs number. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/34c6f57bded33-get-a-specific-shipment)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + trunkrsNr: { + propDefinition: [ + trunkrs, + "trunkrsNr", + ], + }, + }, + async run({ $ }) { + const { data } = await this.trunkrs.getShipment({ + $, + trunkrsNr: this.trunkrsNr, + }); + $.export("$summary", `Successfully fetched shipment ${this.trunkrsNr}.`); + return data; + }, +}; diff --git a/components/trunkrs/actions/list-shipments/list-shipments.mjs b/components/trunkrs/actions/list-shipments/list-shipments.mjs new file mode 100644 index 0000000000000..8b069b7868ed9 --- /dev/null +++ b/components/trunkrs/actions/list-shipments/list-shipments.mjs @@ -0,0 +1,52 @@ +import trunkrs from "../../trunkrs.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + key: "trunkrs-list-shipments", + name: "List Shipments", + description: "List all shipments. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/b425314ab6c67-list-shipments)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + sort: { + type: "string", + label: "Sort", + description: "The field to sort by. Fields prepended with a dash (-) are sorted in descending order.", + options: constants.SHIPMENT_SORT_FIELDS, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of shipments to return. Default: 100", + default: 100, + optional: true, + }, + offset: { + type: "integer", + label: "Offset", + description: "The offset to start from. Default: 0", + optional: true, + }, + }, + async run({ $ }) { + const results = this.trunkrs.paginate({ + fn: this.trunkrs.listShipments, + args: { + $, + params: { + sort: this.sort, + offset: this.offset, + }, + }, + max: this.maxResults, + }); + + const shipments = []; + for await (const shipment of results) { + shipments.push(shipment); + } + $.export("$summary", `Successfully fetched ${shipments.length} shipments.`); + return shipments; + }, +}; diff --git a/components/trunkrs/actions/list-time-slots/list-time-slots.mjs b/components/trunkrs/actions/list-time-slots/list-time-slots.mjs new file mode 100644 index 0000000000000..71b58f189a11d --- /dev/null +++ b/components/trunkrs/actions/list-time-slots/list-time-slots.mjs @@ -0,0 +1,35 @@ +import trunkrs from "../../trunkrs.app.mjs"; + +export default { + key: "trunkrs-list-time-slots", + name: "List Time Slots", + description: "List time slots. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/5f27080ea3314-list-time-slots)", + version: "0.0.1", + type: "action", + props: { + trunkrs, + country: { + propDefinition: [ + trunkrs, + "country", + ], + }, + postalCode: { + type: "string", + label: "Postal Code", + description: "The postal code of the recipient", + optional: true, + }, + }, + async run({ $ }) { + const { data } = await this.trunkrs.listTimeSlots({ + $, + params: { + country: this.country, + postalCode: this.postalCode, + }, + }); + $.export("$summary", `Successfully fetched ${data.length} time slots.`); + return data; + }, +}; diff --git a/components/trunkrs/common/constants.mjs b/components/trunkrs/common/constants.mjs new file mode 100644 index 0000000000000..3bb01e6a84496 --- /dev/null +++ b/components/trunkrs/common/constants.mjs @@ -0,0 +1,48 @@ +const COUNTRIES = [ + { + value: "NL", + label: "Netherlands", + }, + { + value: "BE", + label: "Belgium", + }, +]; + +const WEBHOOK_EVENTS = [ + "onStateUpdate", + "onCreation", + "onCancellation", + "onReview", +]; + +const SHIPMENT_SORT_FIELDS = [ + "trunkrsNr", + "-trunkrsNr", + "recipient.name", + "-recipient.name", + "orderReference", + "-orderReference", + "sender.companyName", + "-sender.companyName", + "sender.name", + "-sender.name", + "timeSlot.id", + "-timeSlot.id", + "timeSlot.cutOffTime", + "-timeSlot.cutOffTime", + "state.code", + "-state.code", + "state.reasonCode", + "-state.reasonCode", + "state.timeStamp", + "-state.timeStamp", + "service", + "-service", +]; + +export default { + COUNTRIES, + WEBHOOK_EVENTS, + SHIPMENT_SORT_FIELDS, +}; diff --git a/components/trunkrs/package.json b/components/trunkrs/package.json index 69e7284c4b990..f609bc95a9fe5 100644 --- a/components/trunkrs/package.json +++ b/components/trunkrs/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/trunkrs", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Trunkrs Components", "main": "trunkrs.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/components/trunkrs/sources/common/base-webhook.mjs b/components/trunkrs/sources/common/base-webhook.mjs new file mode 100644 index 0000000000000..774056ec96e4b --- /dev/null +++ b/components/trunkrs/sources/common/base-webhook.mjs @@ -0,0 +1,56 @@ +import trunkrs from "../../trunkrs.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + props: { + trunkrs, + db: "$.service.db", + http: "$.interface.http", + }, + hooks: { + async activate() { + const { data } = await this.trunkrs.createWebhook({ + data: { + url: this.http.endpoint, + header: {}, + event: this.getEvent(), + }, + }); + this._setHookId(data.id); + }, + async deactivate() { + const hookId = this._getHookId(); + if (hookId) { + await this.trunkrs.deleteWebhook({ + webhookId: hookId, + }); + } + }, + }, + methods: { + _getHookId() { + return this.db.get("hookId"); + }, + _setHookId(hookId) { + this.db.set("hookId", hookId); + }, + generateMeta(event) { + return { + id: event.state.timestamp, + summary: `New ${this.getEvent()} event received`, + ts: Date.parse(event.state.timestamp), + }; + }, + getEvent() { + throw new ConfigurationError("getEvent is not implemented"); + }, + }, + async run(event) { + const { body } = event; + if (!body) { + return; + } + const meta = this.generateMeta(body); + this.$emit(body, meta); + }, +}; diff --git a/components/trunkrs/sources/new-shipment-created/new-shipment-created.mjs b/components/trunkrs/sources/new-shipment-created/new-shipment-created.mjs new file mode 100644 index 0000000000000..459396cf0cd7a --- /dev/null +++ b/components/trunkrs/sources/new-shipment-created/new-shipment-created.mjs @@ -0,0 +1,18 @@ +import common from "../common/base-webhook.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "trunkrs-new-shipment-created", + name: "New Shipment Created (Instant)", + description: "Emit new event when a new shipment is created. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/05ac4fa1b9ade-create-webhook-subscription)", + version: "0.0.1", + type: "source", + methods: { + ...common.methods, + getEvent() { + return "onCreation"; + }, + }, + sampleEmit, +}; diff --git a/components/trunkrs/sources/new-shipment-created/test-event.mjs b/components/trunkrs/sources/new-shipment-created/test-event.mjs new file mode 100644 index 0000000000000..69d0245af10f5 --- /dev/null +++ b/components/trunkrs/sources/new-shipment-created/test-event.mjs @@ -0,0 +1,10 @@ +export default { + trunkrsNr: 3256906, + orderReference: '36273459471', + link: 'https://staging-api.trunkrs.nl/api/v2/shipments/3256906', + state: { + code: 'DATA_PROCESSED', + timestamp: '2025-08-22T19:43:27.414Z', + currentOwner: { type: 'MERCHANT', name: "Satterfield, Stehr and O'Keefe" } + } +} \ No newline at end of file diff --git a/components/trunkrs/sources/shipment-cancelled/shipment-cancelled.mjs b/components/trunkrs/sources/shipment-cancelled/shipment-cancelled.mjs new file mode 100644 index 0000000000000..73be743d76b17 --- /dev/null +++ b/components/trunkrs/sources/shipment-cancelled/shipment-cancelled.mjs @@ -0,0 +1,18 @@ +import common from "../common/base-webhook.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "trunkrs-shipment-cancelled", + name: "Shipment Cancelled (Instant)", + description: "Emit new event when a shipment is cancelled. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/05ac4fa1b9ade-create-webhook-subscription)", + version: "0.0.1", + type: "source", + methods: { + ...common.methods, + getEvent() { + return "onCancellation"; + }, + }, + sampleEmit, +}; diff --git a/components/trunkrs/sources/shipment-cancelled/test-event.mjs b/components/trunkrs/sources/shipment-cancelled/test-event.mjs new file mode 100644 index 0000000000000..3920ea3ebdd9f --- /dev/null +++ b/components/trunkrs/sources/shipment-cancelled/test-event.mjs @@ -0,0 +1,10 @@ +export default { + trunkrsNr: 3299275, + orderReference: '30261842310', + link: 'https://staging-api.trunkrs.nl/api/v2/shipments/3299275', + state: { + code: 'DATA_PROCESSED', + timestamp: '2025-08-22T19:44:27.224Z', + currentOwner: { type: 'MERCHANT', name: 'Harris Group' } + } +} \ No newline at end of file diff --git a/components/trunkrs/sources/shipment-reviewed/shipment-reviewed.mjs b/components/trunkrs/sources/shipment-reviewed/shipment-reviewed.mjs new file mode 100644 index 0000000000000..30cbf63b559f8 --- /dev/null +++ b/components/trunkrs/sources/shipment-reviewed/shipment-reviewed.mjs @@ -0,0 +1,18 @@ +import common from "../common/base-webhook.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "trunkrs-shipment-reviewed", + name: "Shipment Reviewed (Instant)", + description: "Emit new event when a shipment is reviewed. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/05ac4fa1b9ade-create-webhook-subscription)", + version: "0.0.1", + type: "source", + methods: { + ...common.methods, + getEvent() { + return "onReview"; + }, + }, + sampleEmit, +}; diff --git a/components/trunkrs/sources/shipment-reviewed/test-event.mjs b/components/trunkrs/sources/shipment-reviewed/test-event.mjs new file mode 100644 index 0000000000000..ab29c9c6fac68 --- /dev/null +++ b/components/trunkrs/sources/shipment-reviewed/test-event.mjs @@ -0,0 +1,10 @@ +export default { + trunkrsNr: 3618093, + orderReference: '34857013133', + link: 'https://staging-api.trunkrs.nl/api/v2/shipments/3618093', + state: { + code: 'DATA_PROCESSED', + timestamp: '2025-08-22T19:41:05.213Z', + currentOwner: { type: 'MERCHANT', name: 'Zboncak, Kautzer and Gottlieb' } + } +} \ No newline at end of file diff --git a/components/trunkrs/sources/shipment-state-updated/shipment-state-updated.mjs b/components/trunkrs/sources/shipment-state-updated/shipment-state-updated.mjs new file mode 100644 index 0000000000000..df5f415638ce2 --- /dev/null +++ b/components/trunkrs/sources/shipment-state-updated/shipment-state-updated.mjs @@ -0,0 +1,18 @@ +import common from "../common/base-webhook.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "trunkrs-shipment-state-updated", + name: "Shipment State Updated (Instant)", + description: "Emit new event when a shipment state is updated. [See the documentation](https://docs.trunkrs.nl/docs/v2-api-documentation/05ac4fa1b9ade-create-webhook-subscription)", + version: "0.0.1", + type: "source", + methods: { + ...common.methods, + getEvent() { + return "onStateUpdate"; + }, + }, + sampleEmit, +}; diff --git a/components/trunkrs/sources/shipment-state-updated/test-event.mjs b/components/trunkrs/sources/shipment-state-updated/test-event.mjs new file mode 100644 index 0000000000000..79f25ecd9c4b0 --- /dev/null +++ b/components/trunkrs/sources/shipment-state-updated/test-event.mjs @@ -0,0 +1,10 @@ +export default { + trunkrsNr: 3859236, + orderReference: '30260933596', + link: 'https://staging-api.trunkrs.nl/api/v2/shipments/3859236', + state: { + code: 'DATA_PROCESSED', + timestamp: '2025-08-22T19:42:18.334Z', + currentOwner: { type: 'MERCHANT', name: 'Turcotte, Stamm and Purdy' } + } +} \ No newline at end of file diff --git a/components/trunkrs/trunkrs.app.mjs b/components/trunkrs/trunkrs.app.mjs index 67bb634a056a8..be3a8f17c80cd 100644 --- a/components/trunkrs/trunkrs.app.mjs +++ b/components/trunkrs/trunkrs.app.mjs @@ -1,11 +1,157 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; +const DEFAULT_LIMIT = 100; + export default { type: "app", app: "trunkrs", - propDefinitions: {}, + propDefinitions: { + trunkrsNr: { + type: "string", + label: "Trunkrs Number", + description: "The Trunkrs number of the shipment", + async options({ page }) { + const { data } = await this.listShipments({ + params: { + limit: DEFAULT_LIMIT, + offset: page * DEFAULT_LIMIT, + }, + }); + return data?.map((shipment) => ({ + label: shipment.orderReference, + value: shipment.trunkrsNr, + })) || []; + }, + }, + timeSlotId: { + type: "string", + label: "Time Slot ID", + description: "The ID of the time slot to use for the shipment", + optional: true, + async options({ + country, postalCode, + }) { + const { data } = await this.listTimeSlots({ + params: { + country, + postalCode, + }, + }); + return data.map(({ + id, merchant, deliveryWindow, + }) => ({ + label: `${merchant.name} - ${deliveryWindow.start} - ${deliveryWindow.end}`, + value: id, + }) ); + }, + }, + country: { + type: "string", + label: "Country", + description: "The country of the sender", + options: constants.COUNTRIES, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return `${this.$auth.environment}/api/v2`; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + headers: { + "x-api-key": `${this.$auth.api_key}`, + }, + ...opts, + }); + }, + createWebhook(opts = {}) { + return this._makeRequest({ + path: "/webhooks", + method: "POST", + ...opts, + }); + }, + deleteWebhook({ + webhookId, ...opts + }) { + return this._makeRequest({ + path: `/webhooks/${webhookId}`, + method: "DELETE", + ...opts, + }); + }, + getShipment({ + trunkrsNr, ...opts + }) { + return this._makeRequest({ + path: `/shipments/${trunkrsNr}`, + ...opts, + }); + }, + getShipmentState({ + trunkrsNr, ...opts + }) { + return this._makeRequest({ + path: `/shipments/${trunkrsNr}/status`, + ...opts, + }); + }, + listShipments(opts = {}) { + return this._makeRequest({ + path: "/shipments", + ...opts, + }); + }, + listTimeSlots(opts = {}) { + return this._makeRequest({ + path: "/timeslots", + ...opts, + }); + }, + createShipment(opts = {}) { + return this._makeRequest({ + path: "/shipments", + method: "POST", + ...opts, + }); + }, + cancelShipment({ + trunkrsNr, ...opts + }) { + return this._makeRequest({ + path: `/shipments/${trunkrsNr}`, + method: "DELETE", + ...opts, + }); + }, + async *paginate({ + fn, args, max, + }) { + args = { + ...args, + params: { + ...args?.params, + limit: DEFAULT_LIMIT, + }, + }; + let total, count = 0; + do { + const { data } = await fn(args); + total = data?.length; + if (!data?.length) { + return; + } + for (const item of data) { + yield item; + if (max && ++count >= max) { + return; + } + } + args.params.offset += args.params.limit; + } while (total === args.params.limit); }, }, -}; \ No newline at end of file +}; From fa84a7724df1dec18f74ba3d5acf2cd1d24078d3 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 22 Aug 2025 15:52:18 -0400 Subject: [PATCH 2/2] pnpm-lock.yaml --- pnpm-lock.yaml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53220ec198c45..7192333ec60c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8809,8 +8809,7 @@ importers: components/mindbody: {} - components/mindee: - specifiers: {} + components/mindee: {} components/mindmeister: {} @@ -11030,7 +11029,11 @@ importers: specifier: ^3.1.0 version: 3.1.0 - components/prisma_management_api: {} + components/prisma_management_api: + dependencies: + '@pipedream/platform': + specifier: ^1.5.1 + version: 1.6.6 components/prismic: {} @@ -14609,7 +14612,11 @@ importers: specifier: ^1.6.2 version: 1.6.6 - components/trunkrs: {} + components/trunkrs: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/truss: {} @@ -16028,8 +16035,7 @@ importers: specifier: ^4.0.0 version: 4.0.1 - components/zapr_link: - specifiers: {} + components/zapr_link: {} components/zendesk: dependencies: @@ -40402,6 +40408,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: