n8n-nodes-ups 0.2.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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -0
  3. package/dist/credentials/UpsOAuth2Api.credentials.d.ts +10 -0
  4. package/dist/credentials/UpsOAuth2Api.credentials.js +76 -0
  5. package/dist/credentials/UpsOAuth2Api.credentials.js.map +1 -0
  6. package/dist/credentials/ups.svg +5 -0
  7. package/dist/nodes/Ups/Ups.node.d.ts +4 -0
  8. package/dist/nodes/Ups/Ups.node.js +53 -0
  9. package/dist/nodes/Ups/Ups.node.js.map +1 -0
  10. package/dist/nodes/Ups/Ups.node.json +18 -0
  11. package/dist/nodes/Ups/core/buildCommodities.d.ts +10 -0
  12. package/dist/nodes/Ups/core/buildCommodities.js +21 -0
  13. package/dist/nodes/Ups/core/buildCommodities.js.map +1 -0
  14. package/dist/nodes/Ups/core/buildInternationalForms.d.ts +17 -0
  15. package/dist/nodes/Ups/core/buildInternationalForms.js +34 -0
  16. package/dist/nodes/Ups/core/buildInternationalForms.js.map +1 -0
  17. package/dist/nodes/Ups/core/extractCharges.d.ts +20 -0
  18. package/dist/nodes/Ups/core/extractCharges.js +13 -0
  19. package/dist/nodes/Ups/core/extractCharges.js.map +1 -0
  20. package/dist/nodes/Ups/core/extractForms.d.ts +23 -0
  21. package/dist/nodes/Ups/core/extractForms.js +25 -0
  22. package/dist/nodes/Ups/core/extractForms.js.map +1 -0
  23. package/dist/nodes/Ups/core/extractLabel.d.ts +30 -0
  24. package/dist/nodes/Ups/core/extractLabel.js +35 -0
  25. package/dist/nodes/Ups/core/extractLabel.js.map +1 -0
  26. package/dist/nodes/Ups/core/flattenRates.d.ts +36 -0
  27. package/dist/nodes/Ups/core/flattenRates.js +58 -0
  28. package/dist/nodes/Ups/core/flattenRates.js.map +1 -0
  29. package/dist/nodes/Ups/core/isInternational.d.ts +9 -0
  30. package/dist/nodes/Ups/core/isInternational.js +15 -0
  31. package/dist/nodes/Ups/core/isInternational.js.map +1 -0
  32. package/dist/nodes/Ups/core/mapTrackStatus.d.ts +48 -0
  33. package/dist/nodes/Ups/core/mapTrackStatus.js +55 -0
  34. package/dist/nodes/Ups/core/mapTrackStatus.js.map +1 -0
  35. package/dist/nodes/Ups/core/mapUpsError.d.ts +2 -0
  36. package/dist/nodes/Ups/core/mapUpsError.js +52 -0
  37. package/dist/nodes/Ups/core/mapUpsError.js.map +1 -0
  38. package/dist/nodes/Ups/core/shapeCandidates.d.ts +37 -0
  39. package/dist/nodes/Ups/core/shapeCandidates.js +68 -0
  40. package/dist/nodes/Ups/core/shapeCandidates.js.map +1 -0
  41. package/dist/nodes/Ups/core/toMoney.d.ts +6 -0
  42. package/dist/nodes/Ups/core/toMoney.js +16 -0
  43. package/dist/nodes/Ups/core/toMoney.js.map +1 -0
  44. package/dist/nodes/Ups/core/toUpsAddress.d.ts +12 -0
  45. package/dist/nodes/Ups/core/toUpsAddress.js +17 -0
  46. package/dist/nodes/Ups/core/toUpsAddress.js.map +1 -0
  47. package/dist/nodes/Ups/core/toXavAddress.d.ts +16 -0
  48. package/dist/nodes/Ups/core/toXavAddress.js +26 -0
  49. package/dist/nodes/Ups/core/toXavAddress.js.map +1 -0
  50. package/dist/nodes/Ups/core/types.d.ts +73 -0
  51. package/dist/nodes/Ups/core/types.js +3 -0
  52. package/dist/nodes/Ups/core/types.js.map +1 -0
  53. package/dist/nodes/Ups/resources/address/index.d.ts +2 -0
  54. package/dist/nodes/Ups/resources/address/index.js +20 -0
  55. package/dist/nodes/Ups/resources/address/index.js.map +1 -0
  56. package/dist/nodes/Ups/resources/address/validate.operation.d.ts +24 -0
  57. package/dist/nodes/Ups/resources/address/validate.operation.js +109 -0
  58. package/dist/nodes/Ups/resources/address/validate.operation.js.map +1 -0
  59. package/dist/nodes/Ups/resources/shipping/create.operation.d.ts +24 -0
  60. package/dist/nodes/Ups/resources/shipping/create.operation.js +363 -0
  61. package/dist/nodes/Ups/resources/shipping/create.operation.js.map +1 -0
  62. package/dist/nodes/Ups/resources/shipping/getRates.operation.d.ts +24 -0
  63. package/dist/nodes/Ups/resources/shipping/getRates.operation.js +126 -0
  64. package/dist/nodes/Ups/resources/shipping/getRates.operation.js.map +1 -0
  65. package/dist/nodes/Ups/resources/shipping/index.d.ts +2 -0
  66. package/dist/nodes/Ups/resources/shipping/index.js +22 -0
  67. package/dist/nodes/Ups/resources/shipping/index.js.map +1 -0
  68. package/dist/nodes/Ups/resources/shipping/shared.d.ts +34 -0
  69. package/dist/nodes/Ups/resources/shipping/shared.js +165 -0
  70. package/dist/nodes/Ups/resources/shipping/shared.js.map +1 -0
  71. package/dist/nodes/Ups/resources/tracking/index.d.ts +2 -0
  72. package/dist/nodes/Ups/resources/tracking/index.js +20 -0
  73. package/dist/nodes/Ups/resources/tracking/index.js.map +1 -0
  74. package/dist/nodes/Ups/resources/tracking/track.operation.d.ts +24 -0
  75. package/dist/nodes/Ups/resources/tracking/track.operation.js +73 -0
  76. package/dist/nodes/Ups/resources/tracking/track.operation.js.map +1 -0
  77. package/dist/nodes/Ups/ups.dark.svg +13 -0
  78. package/dist/nodes/Ups/ups.svg +13 -0
  79. package/dist/package.json +61 -0
  80. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nodrel-dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # n8n-nodes-ups
2
+
3
+ An [n8n](https://n8n.io) community node for **UPS**. It talks directly to the UPS REST API on
4
+ your own UPS application and account number — no aggregator, no runtime dependencies.
5
+
6
+ Four operations across three resources:
7
+
8
+ | Resource | Operation | What it does |
9
+ |----------|-----------|--------------|
10
+ | **Tracking** | Track | Current status + scan history for a tracking number |
11
+ | **Address** | Validate | Standardize + classify an address (residential/commercial) |
12
+ | **Shipping** | Get Rates | Service options with published & negotiated rates + transit times |
13
+ | **Shipping** | Create | Create a shipment, return tracking number + label (and customs invoice for international) |
14
+
15
+ The node sets `usableAsTool: true`, so every operation is callable from the AI-Agent **tool**
16
+ path as well as the normal node path.
17
+
18
+ ## Installation
19
+
20
+ In n8n: **Settings → Community Nodes → Install** and enter `n8n-nodes-ups`.
21
+
22
+ ## Credentials
23
+
24
+ The node uses a single credential, **UPS OAuth2 API**, that covers all four operations (one UPS
25
+ OAuth app entitles every endpoint).
26
+
27
+ 1. Create an application in the [UPS Developer Portal](https://developer.ups.com/) and note its
28
+ **Client ID** and **Client Secret**.
29
+ 2. In n8n, create a **UPS OAuth2 API** credential:
30
+ - **Environment** — `Sandbox (CIE)` (default) or `Production`. This single switch drives **both**
31
+ the OAuth token URL and the API base URL, so they can never point at different hosts.
32
+ - **Client ID** / **Client Secret** — from your UPS application.
33
+ 3. Click **Test**. The test performs an authenticated Track probe; reaching UPS's Track layer
34
+ (even a "not found") confirms your credentials and environment. A `401/403` means the Client ID,
35
+ Secret, or Environment is wrong.
36
+
37
+ Grant type is OAuth2 **client credentials** (HTTP Basic, empty scope) — configured automatically;
38
+ nothing to set by hand. Secrets live only in n8n's encrypted credential store; never hardcode them.
39
+
40
+ ### Sandbox vs Production
41
+
42
+ | | Sandbox (CIE) | Production |
43
+ |---|---|---|
44
+ | Token URL | `https://wwwcie.ups.com/security/v1/oauth/token` | `https://onlinetools.ups.com/security/v1/oauth/token` |
45
+ | API base | `https://wwwcie.ups.com/api` | `https://onlinetools.ups.com/api` |
46
+
47
+ The Customer Integration Environment (CIE) is limited test data — e.g. address validation returns
48
+ street-level results for **US NY/CA** addresses only.
49
+
50
+ ## Operations
51
+
52
+ ### Tracking → Track
53
+ - **Tracking Number** (required) — one inquiry number per input item.
54
+ - **Detail** — *Detailed* (status + scan history) or *Status Only* (current status only).
55
+ - **Locale** — e.g. `en_US`.
56
+
57
+ Unknown numbers are flagged on their own item; with **Continue On Fail** the rest still process.
58
+
59
+ ### Address → Validate
60
+ - Address line(s), city, state/province, postal code, country.
61
+ - Returns one item with `resolution` (`valid` / `ambiguous` / `none`), a `classification`
62
+ (UnClassified / Commercial / Residential), and standardized `candidates[]`.
63
+
64
+ ### Shipping → Get Rates
65
+ - **Account Number** (required) — your ShipperNumber; also requests negotiated rates.
66
+ - Shipper / Ship To (and optional Ship From) addresses, package weight (+ unit) and optional
67
+ dimensions (+ unit).
68
+ - **Customs Value** — required when origin and destination countries differ (international).
69
+ - Emits **one output item per service**, each with published + negotiated price, transit days, and
70
+ any UPS alerts. If no negotiated rates are returned, a request-level alert is attached to the
71
+ first item.
72
+
73
+ ### Shipping → Create
74
+ - **Account Number** (required), **Service Code**, Shipper / Ship To (and optional Ship From),
75
+ package weight/dimensions, **Label Format** (GIF default; ZPL / EPL / SPL — no PDF label).
76
+ - **International** (origin ≠ destination country) additionally requires the customs fields:
77
+ reason for export, currency, terms of shipment, sold-to party, and at least one commodity line.
78
+ - Returns the tracking number plus the **label** as a binary attachment (`label`); international
79
+ shipments also return the **commercial invoice** PDF (`customsInvoice`). Label/invoice image data
80
+ is never embedded as a string in the JSON output.
81
+
82
+ Billing is to the shipper (transportation charges); international duties are billed to the receiver
83
+ (DDU) in this version.
84
+
85
+ ## AI-Agent tool usage
86
+
87
+ Because the node is tool-enabled, an AI Agent can call any operation directly (e.g. "track
88
+ 1Z…", "rate this shipment"). Test new workflows through both the normal node path and the tool
89
+ path.
90
+
91
+ ## Development
92
+
93
+ ```bash
94
+ npm install # install dev dependencies
95
+ npm test # run the pure-core unit tests (vitest)
96
+ npm run lint # n8n community-node lint (strict)
97
+ npm run build # compile to dist/
98
+ npm run dev # run locally inside n8n (Node.js >= 22.22)
99
+ ```
100
+
101
+ ## License
102
+
103
+ [MIT](LICENSE)
@@ -0,0 +1,10 @@
1
+ import type { ICredentialTestRequest, ICredentialType, Icon, INodeProperties } from 'n8n-workflow';
2
+ export declare class UpsOAuth2Api implements ICredentialType {
3
+ name: string;
4
+ extends: string[];
5
+ displayName: string;
6
+ icon: Icon;
7
+ documentationUrl: string;
8
+ properties: INodeProperties[];
9
+ test: ICredentialTestRequest;
10
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpsOAuth2Api = void 0;
4
+ const TOKEN_URL = {
5
+ sandbox: 'https://wwwcie.ups.com/security/v1/oauth/token',
6
+ production: 'https://onlinetools.ups.com/security/v1/oauth/token',
7
+ };
8
+ const API_HOST = {
9
+ sandbox: 'https://wwwcie.ups.com',
10
+ production: 'https://onlinetools.ups.com',
11
+ };
12
+ class UpsOAuth2Api {
13
+ constructor() {
14
+ this.name = 'upsOAuth2Api';
15
+ this.extends = ['oAuth2Api'];
16
+ this.displayName = 'UPS OAuth2 API';
17
+ this.icon = 'file:ups.svg';
18
+ this.documentationUrl = 'https://github.com/nodrel-dev/n8n-nodes-ups?tab=readme-ov-file#credentials';
19
+ this.properties = [
20
+ {
21
+ displayName: 'Environment',
22
+ name: 'environment',
23
+ type: 'options',
24
+ options: [
25
+ { name: 'Sandbox (CIE)', value: 'sandbox' },
26
+ { name: 'Production', value: 'production' },
27
+ ],
28
+ default: 'sandbox',
29
+ description: 'Which UPS environment to use. Sandbox is the Customer Integration Environment (CIE). Drives both the token URL and the API base URL.',
30
+ },
31
+ {
32
+ displayName: 'Grant Type',
33
+ name: 'grantType',
34
+ type: 'hidden',
35
+ default: 'clientCredentials',
36
+ },
37
+ {
38
+ displayName: 'Access Token URL',
39
+ name: 'accessTokenUrl',
40
+ type: 'hidden',
41
+ default: `={{ $self["environment"] === "production" ? "${TOKEN_URL.production}" : "${TOKEN_URL.sandbox}" }}`,
42
+ },
43
+ {
44
+ displayName: 'Auth URI Query Parameters',
45
+ name: 'authQueryParameters',
46
+ type: 'hidden',
47
+ default: '',
48
+ },
49
+ {
50
+ displayName: 'Scope',
51
+ name: 'scope',
52
+ type: 'hidden',
53
+ default: '',
54
+ },
55
+ {
56
+ displayName: 'Authentication',
57
+ name: 'authentication',
58
+ type: 'hidden',
59
+ default: 'header',
60
+ },
61
+ ];
62
+ this.test = {
63
+ request: {
64
+ baseURL: `={{ $credentials.environment === "production" ? "${API_HOST.production}" : "${API_HOST.sandbox}" }}`,
65
+ url: '/api/track/v1/details/1Z00000000000000000',
66
+ method: 'GET',
67
+ headers: {
68
+ transId: 'n8n-nodes-ups-credtest',
69
+ transactionSrc: 'n8n-nodes-ups',
70
+ },
71
+ },
72
+ };
73
+ }
74
+ }
75
+ exports.UpsOAuth2Api = UpsOAuth2Api;
76
+ //# sourceMappingURL=UpsOAuth2Api.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpsOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/UpsOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AASA,MAAM,SAAS,GAAG;IACjB,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,qDAAqD;CACjE,CAAC;AAGF,MAAM,QAAQ,GAAG;IAChB,OAAO,E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EAAE;gBACR,OAAO,EAAE,oDAAoD,QAAQ,CAAC,UAAU,QAAQ,QAAQ,CAAC,OAAO,MAAM;gBAC9G,GAAG,EAAE,2CAA2C;gBAChD,MAAM,EAAE,KAAK;gBAKb,OAAO,EAAE;oBACR,OAAO,EAAE,wBAAwB;oBACjC,cAAc,EAAE,eAAe;iBAC/B;aACD;SACD,CAAC;IACH,CAAC;CAAA;AArFD,oCAqFC"}
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#6f4e37" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
3
+ <polyline points="3.27 6.96 12 12.01 20.73 6.96"/>
4
+ <line x1="12" y1="22.08" x2="12" y2="12"/>
5
+ </svg>
@@ -0,0 +1,4 @@
1
+ import { type INodeType, type INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Ups implements INodeType {
3
+ description: INodeTypeDescription;
4
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Ups = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const tracking_1 = require("./resources/tracking");
6
+ const address_1 = require("./resources/address");
7
+ const shipping_1 = require("./resources/shipping");
8
+ class Ups {
9
+ constructor() {
10
+ this.description = {
11
+ displayName: 'UPS',
12
+ name: 'ups',
13
+ icon: { light: 'file:ups.svg', dark: 'file:ups.dark.svg' },
14
+ group: ['transform'],
15
+ version: 1,
16
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
17
+ description: 'Track shipments, validate addresses, rate, and create UPS shipments',
18
+ defaults: {
19
+ name: 'UPS',
20
+ },
21
+ usableAsTool: true,
22
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
23
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
24
+ credentials: [{ name: 'upsOAuth2Api', required: true }],
25
+ requestDefaults: {
26
+ baseURL: '={{ $credentials.environment === "production" ? "https://onlinetools.ups.com/api" : "https://wwwcie.ups.com/api" }}',
27
+ headers: {
28
+ Accept: 'application/json',
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ },
32
+ properties: [
33
+ {
34
+ displayName: 'Resource',
35
+ name: 'resource',
36
+ type: 'options',
37
+ noDataExpression: true,
38
+ options: [
39
+ { name: 'Address', value: 'address' },
40
+ { name: 'Shipping', value: 'shipping' },
41
+ { name: 'Tracking', value: 'tracking' },
42
+ ],
43
+ default: 'tracking',
44
+ },
45
+ ...tracking_1.trackingDescription,
46
+ ...address_1.addressDescription,
47
+ ...shipping_1.shippingDescription,
48
+ ],
49
+ };
50
+ }
51
+ }
52
+ exports.Ups = Ups;
53
+ //# sourceMappingURL=Ups.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ups.node.js","sourceRoot":"","sources":["../../../nodes/Ups/Ups.node.ts"],"names":[],"mappings":";;;AAAA,+CAA8F;AAC9F,mDAA2D;AAC3D,iDAAyD;AACzD,mDAA2D;AAE3D,MAAa,GAAG;IAAhB;QAMC,gBAAW,GAAyB;YACnC,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE;YAC1D,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,qEAAqE;YAClF,QAAQ,EAAE;gBACT,IAAI,EAAE,KAAK;aACX;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACvD,eAAe,EAAE;gBAIhB,OAAO,EACN,qHAAqH;gBACtH,OAAO,EAAE;oBACR,MAAM,EAAE,kBAAkB;oBAC1B,cAAc,EAAE,kBAAkB;iBAClC;aACD;YACD,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,UAAU;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACR,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;wBACrC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;wBACvC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;qBACvC;oBACD,OAAO,EAAE,UAAU;iBACnB;gBACD,GAAG,8BAAmB;gBACtB,GAAG,4BAAkB;gBACrB,GAAG,8BAAmB;aACtB;SACD,CAAC;IACH,CAAC;CAAA;AAlDD,kBAkDC"}
@@ -0,0 +1,18 @@
1
+ {
2
+ "node": "n8n-nodes-ups.ups",
3
+ "nodeVersion": "1.0",
4
+ "codexVersion": "1.0",
5
+ "categories": ["Miscellaneous"],
6
+ "resources": {
7
+ "credentialDocumentation": [
8
+ {
9
+ "url": "https://github.com/nodrel-dev/n8n-nodes-ups?tab=readme-ov-file#credentials"
10
+ }
11
+ ],
12
+ "primaryDocumentation": [
13
+ {
14
+ "url": "https://github.com/nodrel-dev/n8n-nodes-ups?tab=readme-ov-file"
15
+ }
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ import type { Product } from './types';
2
+ export interface CommodityLineInput {
3
+ description: string;
4
+ quantity: number;
5
+ unitValue: number;
6
+ unitOfMeasure: string;
7
+ commodityCode?: string;
8
+ originCountry?: string;
9
+ }
10
+ export declare function buildCommodities(items: CommodityLineInput[]): Product[];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCommodities = buildCommodities;
4
+ function buildCommodities(items) {
5
+ return items.map((item) => {
6
+ const product = {
7
+ Description: item.description,
8
+ Unit: {
9
+ Number: String(item.quantity),
10
+ UnitOfMeasurement: { Code: item.unitOfMeasure },
11
+ Value: String(item.unitValue),
12
+ },
13
+ };
14
+ if (item.commodityCode)
15
+ product.CommodityCode = item.commodityCode;
16
+ if (item.originCountry)
17
+ product.OriginCountryCode = item.originCountry;
18
+ return product;
19
+ });
20
+ }
21
+ //# sourceMappingURL=buildCommodities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildCommodities.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/buildCommodities.ts"],"names":[],"mappings":";;AAeA,4CAcC;AAdD,SAAgB,gBAAgB,CAAC,KAA2B;IAC3D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,OAAO,GAAY;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE;gBACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC7B,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE;gBAC/C,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;aAC7B;SACD,CAAC;QACF,IAAI,IAAI,CAAC,aAAa;YAAE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACnE,IAAI,IAAI,CAAC,aAAa;YAAE,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC;QACvE,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { InternationalForms, Product } from './types';
2
+ export interface CustomsInput {
3
+ reasonForExport: string;
4
+ currency: string;
5
+ termsOfShipment?: string;
6
+ invoiceNumber?: string;
7
+ invoiceDate?: string;
8
+ soldTo: {
9
+ name: string;
10
+ addressLines: string[];
11
+ city: string;
12
+ stateProvinceCode?: string;
13
+ postalCode?: string;
14
+ countryCode: string;
15
+ };
16
+ }
17
+ export declare function buildInternationalForms(customs: CustomsInput, commodities: Product[]): InternationalForms;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternationalForms = buildInternationalForms;
4
+ function buildInternationalForms(customs, commodities) {
5
+ var _a;
6
+ const forms = {
7
+ FormType: ['01'],
8
+ ReasonForExport: customs.reasonForExport,
9
+ CurrencyCode: customs.currency,
10
+ Contacts: {
11
+ SoldTo: {
12
+ Name: customs.soldTo.name,
13
+ Address: {
14
+ AddressLine: ((_a = customs.soldTo.addressLines) !== null && _a !== void 0 ? _a : []).filter((l) => l && l.trim().length > 0),
15
+ City: customs.soldTo.city,
16
+ CountryCode: customs.soldTo.countryCode,
17
+ },
18
+ },
19
+ },
20
+ Product: commodities,
21
+ };
22
+ if (customs.soldTo.stateProvinceCode)
23
+ forms.Contacts.SoldTo.Address.StateProvinceCode = customs.soldTo.stateProvinceCode;
24
+ if (customs.soldTo.postalCode)
25
+ forms.Contacts.SoldTo.Address.PostalCode = customs.soldTo.postalCode;
26
+ if (customs.termsOfShipment)
27
+ forms.TermsOfShipment = customs.termsOfShipment;
28
+ if (customs.invoiceNumber)
29
+ forms.InvoiceNumber = customs.invoiceNumber;
30
+ if (customs.invoiceDate)
31
+ forms.InvoiceDate = customs.invoiceDate;
32
+ return forms;
33
+ }
34
+ //# sourceMappingURL=buildInternationalForms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildInternationalForms.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/buildInternationalForms.ts"],"names":[],"mappings":";;AAsBA,0DA8BC;AA9BD,SAAgB,uBAAuB,CACtC,OAAqB,EACrB,WAAsB;;IAEtB,MAAM,KAAK,GAAuB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harges {
4
+ published: Money | null;
5
+ negotiated: Money | null;
6
+ }
7
+ interface ShipChargeResponse {
8
+ ShipmentResponse?: {
9
+ ShipmentResults?: {
10
+ ShipmentCharges?: {
11
+ TotalCharges?: UpsCharge;
12
+ };
13
+ NegotiatedRateCharges?: {
14
+ TotalCharge?: UpsCharge;
15
+ };
16
+ };
17
+ };
18
+ }
19
+ export declare function extractCharges(response: ShipChargeResponse): ExtractedCharges;
20
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCharges = extractCharges;
4
+ const toMoney_1 = require("./toMoney");
5
+ function extractCharges(response) {
6
+ var _a, _b, _c;
7
+ const results = (_a = response.ShipmentResponse) === null || _a === void 0 ? void 0 : _a.ShipmentResults;
8
+ return {
9
+ published: (0, toMoney_1.toMoney)((_b = results === null || results === void 0 ? void 0 : results.ShipmentCharges) === null || _b === void 0 ? void 0 : _b.TotalCharges),
10
+ negotiated: (0, toMoney_1.toMoney)((_c = results === null || results === void 0 ? void 0 : results.NegotiatedRateCharges) === null || _c === void 0 ? void 0 : _c.TotalCharge),
11
+ };
12
+ }
13
+ //# sourceMappingURL=extractCharges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractCharges.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/extractCharges.ts"],"names":[],"mappings":";;AAuBA,wCAMC;AA5BD,uCAAoD;AAsBpD,SAAgB,cAAc,CAAC,QAA4B;;IAC1D,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,eAAe,CAAC;IAC3D,OAAO;QACN,SAAS,EAAE,IAAA,iBAAO,EAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,0CAAE,YAAY,CAAC;QAC1D,UAAU,EAAE,IAAA,iBAAO,EAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,qBAAqB,0CAAE,WAAW,CAAC;KAChE,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ export interface ExtractedForm {
2
+ base64: string;
3
+ mime: string;
4
+ filename: string;
5
+ }
6
+ interface RawForm {
7
+ Image?: {
8
+ GraphicImage?: string;
9
+ ImageFormat?: {
10
+ Code?: string;
11
+ };
12
+ };
13
+ }
14
+ interface ShipResponse {
15
+ ShipmentResponse?: {
16
+ ShipmentResults?: {
17
+ ShipmentIdentificationNumber?: string;
18
+ Form?: RawForm[] | RawForm;
19
+ };
20
+ };
21
+ }
22
+ export declare function extractForms(response: ShipResponse): ExtractedForm[];
23
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractForms = extractForms;
4
+ function toArray(value) {
5
+ if (value === undefined || value === null)
6
+ return [];
7
+ return Array.isArray(value) ? value : [value];
8
+ }
9
+ function extractForms(response) {
10
+ var _a, _b;
11
+ const results = (_a = response.ShipmentResponse) === null || _a === void 0 ? void 0 : _a.ShipmentResults;
12
+ const shipmentId = (_b = results === null || results === void 0 ? void 0 : results.ShipmentIdentificationNumber) !== null && _b !== void 0 ? _b : 'shipment';
13
+ const forms = toArray(results === null || results === void 0 ? void 0 : results.Form);
14
+ return forms
15
+ .filter((form) => { var _a; return (_a = form.Image) === null || _a === void 0 ? void 0 : _a.GraphicImage; })
16
+ .map((form, index) => {
17
+ var _a;
18
+ return ({
19
+ base64: (_a = form.Image) === null || _a === void 0 ? void 0 : _a.GraphicImage,
20
+ mime: 'application/pdf',
21
+ filename: `customs-invoice-${shipmentId}${index > 0 ? `-${index + 1}` : ''}.pdf`,
22
+ });
23
+ });
24
+ }
25
+ //# sourceMappingURL=extractForms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractForms.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/extractForms.ts"],"names":[],"mappings":";;AA4BA,oCAaC;AAlBD,SAAS,OAAO,CAAI,KAA0B;IAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,YAAY,CAAC,QAAsB;;IAClD,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,eAAe,CAAC;IAC3D,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,4BAA4B,mCAAI,UAAU,CAAC;IACvE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,CAAC;IAErC,OAAO,KAAK;SACV,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAY,CAAA,EAAA,CAAC;SAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;QAAC,OAAA,CAAC;YACtB,MAAM,EAAE,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAsB;YAE1C,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,mBAAmB,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM;SAChF,CAAC,CAAA;KAAA,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,30 @@
1
+ export type LabelFormat = 'GIF' | 'ZPL' | 'EPL' | 'SPL';
2
+ export interface ExtractedLabel {
3
+ trackingNumber: string;
4
+ base64: string;
5
+ mime: string;
6
+ filename: string;
7
+ }
8
+ export interface ExtractLabelResult {
9
+ shipmentId: string;
10
+ labels: ExtractedLabel[];
11
+ }
12
+ interface RawPackageResult {
13
+ TrackingNumber?: string;
14
+ ShippingLabel?: {
15
+ ImageFormat?: {
16
+ Code?: string;
17
+ };
18
+ GraphicImage?: string;
19
+ };
20
+ }
21
+ interface ShipResponse {
22
+ ShipmentResponse?: {
23
+ ShipmentResults?: {
24
+ ShipmentIdentificationNumber?: string;
25
+ PackageResults?: RawPackageResult[] | RawPackageResult;
26
+ };
27
+ };
28
+ }
29
+ export declare function extractLabel(response: ShipResponse, requestedFormat: string): ExtractLabelResult;
30
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractLabel = extractLabel;
4
+ const MIME_BY_FORMAT = {
5
+ GIF: 'image/gif',
6
+ ZPL: 'text/plain',
7
+ EPL: 'text/plain',
8
+ SPL: 'text/plain',
9
+ };
10
+ function toArray(value) {
11
+ if (value === undefined || value === null)
12
+ return [];
13
+ return Array.isArray(value) ? value : [value];
14
+ }
15
+ function extractLabel(response, requestedFormat) {
16
+ var _a, _b;
17
+ const results = (_a = response.ShipmentResponse) === null || _a === void 0 ? void 0 : _a.ShipmentResults;
18
+ const shipmentId = (_b = results === null || results === void 0 ? void 0 : results.ShipmentIdentificationNumber) !== null && _b !== void 0 ? _b : '';
19
+ const packages = toArray(results === null || results === void 0 ? void 0 : results.PackageResults);
20
+ const labels = packages
21
+ .filter((pkg) => { var _a; return (_a = pkg.ShippingLabel) === null || _a === void 0 ? void 0 : _a.GraphicImage; })
22
+ .map((pkg) => {
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ const format = ((_d = (_c = (_b = (_a = pkg.ShippingLabel) === null || _a === void 0 ? void 0 : _a.ImageFormat) === null || _b === void 0 ? void 0 : _b.Code) !== null && _c !== void 0 ? _c : requestedFormat) !== null && _d !== void 0 ? _d : 'GIF').toUpperCase();
25
+ const trackingNumber = (_e = pkg.TrackingNumber) !== null && _e !== void 0 ? _e : shipmentId;
26
+ return {
27
+ trackingNumber,
28
+ base64: (_f = pkg.ShippingLabel) === null || _f === void 0 ? void 0 : _f.GraphicImage,
29
+ mime: (_g = MIME_BY_FORMAT[format]) !== null && _g !== void 0 ? _g : 'application/octet-stream',
30
+ filename: `${trackingNumber}.${format.toLowerCase()}`,
31
+ };
32
+ });
33
+ return { shipmentId, labels };
34
+ }
35
+ //# sourceMappingURL=extractLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractLabel.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/extractLabel.ts"],"names":[],"mappings":";;AAiDA,oCAuBC;AAnCD,MAAM,cAAc,GAA2B;IAC9C,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;CACjB,CAAC;AAEF,SAAS,OAAO,CAAI,KAA0B;IAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,YAAY,CAAC,QAAsB,EAAE,eAAuB;;IAC3E,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,eAAe,CAAC;IAC3D,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,4BAA4B,mCAAI,EAAE,CAAC;IAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,CAAC,CAAC;IAElD,MAAM,MAAM,GAAqB,QAAQ;SACvC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,MAAA,GAAG,CAAC,aAAa,0CAAE,YAAY,CAAA,EAAA,CAAC;SAChD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;QACZ,MAAM,MAAM,GAAG,CACd,MAAA,MAAA,MAAA,MAAA,GAAG,CAAC,aAAa,0CAAE,WAAW,0CAAE,IAAI,mCACpC,eAAe,mCACf,KAAK,CACL,CAAC,WAAW,EAAE,CAAC;QAChB,MAAM,cAAc,GAAG,MAAA,GAAG,CAAC,cAAc,mCAAI,UAAU,CAAC;QACxD,OAAO;YACN,cAAc;YACd,MAAM,EAAE,MAAA,GAAG,CAAC,aAAa,0CAAE,YAAsB;YACjD,IAAI,EAAE,MAAA,cAAc,CAAC,MAAM,CAAC,mCAAI,0BAA0B;YAC1D,QAAQ,EAAE,GAAG,cAAc,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE;SACrD,CAAC;IACH,CAAC,CAAC,CAAC;IAEJ,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { RateLine } from './types';
2
+ import { type UpsCharge } from './toMoney';
3
+ interface RawAlert {
4
+ Code?: string;
5
+ Description?: string;
6
+ }
7
+ interface RawRatedShipment {
8
+ Service?: {
9
+ Code?: string;
10
+ Description?: string;
11
+ };
12
+ BillingWeight?: {
13
+ Weight?: string;
14
+ };
15
+ TotalCharges?: UpsCharge;
16
+ NegotiatedRateCharges?: {
17
+ TotalCharge?: UpsCharge;
18
+ };
19
+ GuaranteedDelivery?: {
20
+ BusinessDaysInTransit?: string;
21
+ DeliveryByTime?: string;
22
+ };
23
+ RatedShipmentAlert?: RawAlert[] | RawAlert;
24
+ }
25
+ interface RateResponse {
26
+ RateResponse?: {
27
+ Response?: {
28
+ Alert?: RawAlert[] | RawAlert;
29
+ };
30
+ RatedShipment?: RawRatedShipment[] | RawRatedShipment;
31
+ };
32
+ }
33
+ export declare function flattenRates(response: RateResponse, options: {
34
+ wantTransit: boolean;
35
+ }): RateLine[];
36
+ export {};