@nodrel-dev/n8n-nodes-ups 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +249 -0
- package/dist/credentials/UpsOAuth2Api.credentials.d.ts +10 -0
- package/dist/credentials/UpsOAuth2Api.credentials.js +76 -0
- package/dist/credentials/UpsOAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/ups.svg +5 -0
- package/dist/nodes/Ups/Ups.node.d.ts +4 -0
- package/dist/nodes/Ups/Ups.node.js +53 -0
- package/dist/nodes/Ups/Ups.node.js.map +1 -0
- package/dist/nodes/Ups/Ups.node.json +18 -0
- package/dist/nodes/Ups/core/buildCommodities.d.ts +10 -0
- package/dist/nodes/Ups/core/buildCommodities.js +21 -0
- package/dist/nodes/Ups/core/buildCommodities.js.map +1 -0
- package/dist/nodes/Ups/core/buildInternationalForms.d.ts +17 -0
- package/dist/nodes/Ups/core/buildInternationalForms.js +34 -0
- package/dist/nodes/Ups/core/buildInternationalForms.js.map +1 -0
- package/dist/nodes/Ups/core/extractCharges.d.ts +20 -0
- package/dist/nodes/Ups/core/extractCharges.js +13 -0
- package/dist/nodes/Ups/core/extractCharges.js.map +1 -0
- package/dist/nodes/Ups/core/extractForms.d.ts +23 -0
- package/dist/nodes/Ups/core/extractForms.js +25 -0
- package/dist/nodes/Ups/core/extractForms.js.map +1 -0
- package/dist/nodes/Ups/core/extractLabel.d.ts +30 -0
- package/dist/nodes/Ups/core/extractLabel.js +35 -0
- package/dist/nodes/Ups/core/extractLabel.js.map +1 -0
- package/dist/nodes/Ups/core/flattenRates.d.ts +36 -0
- package/dist/nodes/Ups/core/flattenRates.js +58 -0
- package/dist/nodes/Ups/core/flattenRates.js.map +1 -0
- package/dist/nodes/Ups/core/isInternational.d.ts +9 -0
- package/dist/nodes/Ups/core/isInternational.js +15 -0
- package/dist/nodes/Ups/core/isInternational.js.map +1 -0
- package/dist/nodes/Ups/core/mapTrackStatus.d.ts +48 -0
- package/dist/nodes/Ups/core/mapTrackStatus.js +55 -0
- package/dist/nodes/Ups/core/mapTrackStatus.js.map +1 -0
- package/dist/nodes/Ups/core/mapUpsError.d.ts +2 -0
- package/dist/nodes/Ups/core/mapUpsError.js +52 -0
- package/dist/nodes/Ups/core/mapUpsError.js.map +1 -0
- package/dist/nodes/Ups/core/shapeCandidates.d.ts +37 -0
- package/dist/nodes/Ups/core/shapeCandidates.js +68 -0
- package/dist/nodes/Ups/core/shapeCandidates.js.map +1 -0
- package/dist/nodes/Ups/core/toMoney.d.ts +6 -0
- package/dist/nodes/Ups/core/toMoney.js +16 -0
- package/dist/nodes/Ups/core/toMoney.js.map +1 -0
- package/dist/nodes/Ups/core/toUpsAddress.d.ts +12 -0
- package/dist/nodes/Ups/core/toUpsAddress.js +17 -0
- package/dist/nodes/Ups/core/toUpsAddress.js.map +1 -0
- package/dist/nodes/Ups/core/toXavAddress.d.ts +16 -0
- package/dist/nodes/Ups/core/toXavAddress.js +26 -0
- package/dist/nodes/Ups/core/toXavAddress.js.map +1 -0
- package/dist/nodes/Ups/core/types.d.ts +73 -0
- package/dist/nodes/Ups/core/types.js +3 -0
- package/dist/nodes/Ups/core/types.js.map +1 -0
- package/dist/nodes/Ups/resources/address/index.d.ts +2 -0
- package/dist/nodes/Ups/resources/address/index.js +20 -0
- package/dist/nodes/Ups/resources/address/index.js.map +1 -0
- package/dist/nodes/Ups/resources/address/validate.operation.d.ts +24 -0
- package/dist/nodes/Ups/resources/address/validate.operation.js +109 -0
- package/dist/nodes/Ups/resources/address/validate.operation.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/create.operation.d.ts +24 -0
- package/dist/nodes/Ups/resources/shipping/create.operation.js +363 -0
- package/dist/nodes/Ups/resources/shipping/create.operation.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/getRates.operation.d.ts +24 -0
- package/dist/nodes/Ups/resources/shipping/getRates.operation.js +126 -0
- package/dist/nodes/Ups/resources/shipping/getRates.operation.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/index.d.ts +2 -0
- package/dist/nodes/Ups/resources/shipping/index.js +22 -0
- package/dist/nodes/Ups/resources/shipping/index.js.map +1 -0
- package/dist/nodes/Ups/resources/shipping/shared.d.ts +34 -0
- package/dist/nodes/Ups/resources/shipping/shared.js +165 -0
- package/dist/nodes/Ups/resources/shipping/shared.js.map +1 -0
- package/dist/nodes/Ups/resources/tracking/index.d.ts +2 -0
- package/dist/nodes/Ups/resources/tracking/index.js +20 -0
- package/dist/nodes/Ups/resources/tracking/index.js.map +1 -0
- package/dist/nodes/Ups/resources/tracking/track.operation.d.ts +24 -0
- package/dist/nodes/Ups/resources/tracking/track.operation.js +73 -0
- package/dist/nodes/Ups/resources/tracking/track.operation.js.map +1 -0
- package/dist/nodes/Ups/ups.dark.svg +13 -0
- package/dist/nodes/Ups/ups.svg +13 -0
- package/dist/package.json +61 -0
- package/package.json +61 -0
|
@@ -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 {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenRates = flattenRates;
|
|
4
|
+
const toMoney_1 = require("./toMoney");
|
|
5
|
+
const NO_NEGOTIATED_ALERT = 'No negotiated rates were returned. Confirm your account number is enabled for negotiated rates.';
|
|
6
|
+
function toArray(value) {
|
|
7
|
+
if (value === undefined || value === null)
|
|
8
|
+
return [];
|
|
9
|
+
return Array.isArray(value) ? value : [value];
|
|
10
|
+
}
|
|
11
|
+
function alertText(alert) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return (_b = (_a = alert.Description) !== null && _a !== void 0 ? _a : alert.Code) !== null && _b !== void 0 ? _b : '';
|
|
14
|
+
}
|
|
15
|
+
function parseTransitDays(value) {
|
|
16
|
+
if (value === undefined || value === '')
|
|
17
|
+
return null;
|
|
18
|
+
const n = Number.parseInt(value, 10);
|
|
19
|
+
return Number.isNaN(n) ? null : n;
|
|
20
|
+
}
|
|
21
|
+
function flattenRates(response, options) {
|
|
22
|
+
var _a;
|
|
23
|
+
const rate = response.RateResponse;
|
|
24
|
+
const shipments = toArray(rate === null || rate === void 0 ? void 0 : rate.RatedShipment);
|
|
25
|
+
const lines = shipments.map((shipment) => {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
27
|
+
const published = (_a = (0, toMoney_1.toMoney)(shipment.TotalCharges)) !== null && _a !== void 0 ? _a : { amount: '0', currency: 'USD' };
|
|
28
|
+
return {
|
|
29
|
+
serviceCode: (_c = (_b = shipment.Service) === null || _b === void 0 ? void 0 : _b.Code) !== null && _c !== void 0 ? _c : '',
|
|
30
|
+
serviceName: (_e = (_d = shipment.Service) === null || _d === void 0 ? void 0 : _d.Description) !== null && _e !== void 0 ? _e : '',
|
|
31
|
+
negotiated: (0, toMoney_1.toMoney)((_f = shipment.NegotiatedRateCharges) === null || _f === void 0 ? void 0 : _f.TotalCharge),
|
|
32
|
+
published,
|
|
33
|
+
billingWeight: (_h = (_g = shipment.BillingWeight) === null || _g === void 0 ? void 0 : _g.Weight) !== null && _h !== void 0 ? _h : null,
|
|
34
|
+
transitDays: options.wantTransit
|
|
35
|
+
? parseTransitDays((_j = shipment.GuaranteedDelivery) === null || _j === void 0 ? void 0 : _j.BusinessDaysInTransit)
|
|
36
|
+
: null,
|
|
37
|
+
guaranteedBy: options.wantTransit
|
|
38
|
+
? ((_l = (_k = shipment.GuaranteedDelivery) === null || _k === void 0 ? void 0 : _k.DeliveryByTime) !== null && _l !== void 0 ? _l : null)
|
|
39
|
+
: null,
|
|
40
|
+
alerts: toArray(shipment.RatedShipmentAlert)
|
|
41
|
+
.map(alertText)
|
|
42
|
+
.filter((a) => a.length > 0),
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
if (lines.length === 0)
|
|
46
|
+
return lines;
|
|
47
|
+
const requestAlerts = toArray((_a = rate === null || rate === void 0 ? void 0 : rate.Response) === null || _a === void 0 ? void 0 : _a.Alert)
|
|
48
|
+
.map(alertText)
|
|
49
|
+
.filter((a) => a.length > 0);
|
|
50
|
+
if (requestAlerts.length > 0) {
|
|
51
|
+
lines[0].alerts = [...lines[0].alerts, ...requestAlerts];
|
|
52
|
+
}
|
|
53
|
+
if (lines.every((l) => l.negotiated === null)) {
|
|
54
|
+
lines[0].alerts = [...lines[0].alerts, NO_NEGOTIATED_ALERT];
|
|
55
|
+
}
|
|
56
|
+
return lines;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=flattenRates.js.map
|
|
@@ -0,0 +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AAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC;IAC1D,CAAC;IAGD,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/C,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInternational = isInternational;
|
|
4
|
+
function normalize(code) {
|
|
5
|
+
return (code !== null && code !== void 0 ? code : '').trim().toUpperCase();
|
|
6
|
+
}
|
|
7
|
+
function isInternational(input) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const origin = normalize((_a = input.shipFrom) === null || _a === void 0 ? void 0 : _a.countryCode) || normalize((_b = input.shipper) === null || _b === void 0 ? void 0 : _b.countryCode);
|
|
10
|
+
const destination = normalize((_c = input.shipTo) === null || _c === void 0 ? void 0 : _c.countryCode);
|
|
11
|
+
if (!origin || !destination)
|
|
12
|
+
return false;
|
|
13
|
+
return origin !== destination;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=isInternational.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isInternational.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/isInternational.ts"],"names":[],"mappings":";;AAkBA,0CAMC;AAVD,SAAS,SAAS,CAAC,IAAwB;IAC1C,OAAO,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC1C,CAAC;AAED,SAAgB,eAAe,CAAC,KAAyB;;IACxD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAA,KAAK,CAAC,QAAQ,0CAAE,WAAW,CAAC,IAAI,SAAS,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,WAAW,CAAC,CAAC;IAC/F,MAAM,WAAW,GAAG,SAAS,CAAC,MAAA,KAAK,CAAC,MAAM,0CAAE,WAAW,CAAC,CAAC;IAEzD,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,MAAM,KAAK,WAAW,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { TrackResult } from './types';
|
|
2
|
+
export type TrackDetail = 'detailed' | 'status';
|
|
3
|
+
interface RawAddress {
|
|
4
|
+
city?: string;
|
|
5
|
+
stateProvince?: string;
|
|
6
|
+
countryCode?: string;
|
|
7
|
+
country?: string;
|
|
8
|
+
}
|
|
9
|
+
interface RawStatus {
|
|
10
|
+
type?: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
statusCode?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RawActivity {
|
|
16
|
+
date?: string;
|
|
17
|
+
time?: string;
|
|
18
|
+
status?: RawStatus;
|
|
19
|
+
location?: {
|
|
20
|
+
address?: RawAddress;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface RawPackage {
|
|
24
|
+
trackingNumber?: string;
|
|
25
|
+
currentStatus?: RawStatus;
|
|
26
|
+
service?: {
|
|
27
|
+
code?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
};
|
|
30
|
+
deliveryDate?: Array<{
|
|
31
|
+
type?: string;
|
|
32
|
+
date?: string;
|
|
33
|
+
}>;
|
|
34
|
+
activity?: RawActivity[];
|
|
35
|
+
}
|
|
36
|
+
interface RawShipment {
|
|
37
|
+
inquiryNumber?: string;
|
|
38
|
+
package?: RawPackage[];
|
|
39
|
+
}
|
|
40
|
+
interface TrackResponse {
|
|
41
|
+
trackResponse?: {
|
|
42
|
+
shipment?: RawShipment[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function mapTrackStatus(response: TrackResponse, options: {
|
|
46
|
+
detail: TrackDetail;
|
|
47
|
+
}): TrackResult[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapTrackStatus = mapTrackStatus;
|
|
4
|
+
function formatLocation(address) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!address)
|
|
7
|
+
return undefined;
|
|
8
|
+
const parts = [
|
|
9
|
+
address.city,
|
|
10
|
+
address.stateProvince,
|
|
11
|
+
(_a = address.countryCode) !== null && _a !== void 0 ? _a : address.country,
|
|
12
|
+
].filter((p) => Boolean(p));
|
|
13
|
+
return parts.length > 0 ? parts.join(', ') : undefined;
|
|
14
|
+
}
|
|
15
|
+
function mapActivity(raw) {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
|
+
return {
|
|
18
|
+
date: raw.date,
|
|
19
|
+
time: raw.time,
|
|
20
|
+
statusType: (_a = raw.status) === null || _a === void 0 ? void 0 : _a.type,
|
|
21
|
+
statusCode: (_b = raw.status) === null || _b === void 0 ? void 0 : _b.code,
|
|
22
|
+
statusDescription: (_c = raw.status) === null || _c === void 0 ? void 0 : _c.description,
|
|
23
|
+
location: formatLocation((_d = raw.location) === null || _d === void 0 ? void 0 : _d.address),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function pickDeliveryDate(pkg) {
|
|
27
|
+
if (!Array.isArray(pkg.deliveryDate) || pkg.deliveryDate.length === 0)
|
|
28
|
+
return undefined;
|
|
29
|
+
const delivered = pkg.deliveryDate.find((d) => d.type === 'DEL');
|
|
30
|
+
return (delivered !== null && delivered !== void 0 ? delivered : pkg.deliveryDate[pkg.deliveryDate.length - 1]).date;
|
|
31
|
+
}
|
|
32
|
+
function mapTrackStatus(response, options) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f;
|
|
34
|
+
const shipments = (_b = (_a = response.trackResponse) === null || _a === void 0 ? void 0 : _a.shipment) !== null && _b !== void 0 ? _b : [];
|
|
35
|
+
const results = [];
|
|
36
|
+
for (const shipment of shipments) {
|
|
37
|
+
for (const pkg of (_c = shipment.package) !== null && _c !== void 0 ? _c : []) {
|
|
38
|
+
const status = pkg.currentStatus;
|
|
39
|
+
const result = {
|
|
40
|
+
trackingNumber: (_e = (_d = pkg.trackingNumber) !== null && _d !== void 0 ? _d : shipment.inquiryNumber) !== null && _e !== void 0 ? _e : '',
|
|
41
|
+
statusType: status === null || status === void 0 ? void 0 : status.type,
|
|
42
|
+
statusCode: status === null || status === void 0 ? void 0 : status.code,
|
|
43
|
+
statusDescription: status === null || status === void 0 ? void 0 : status.description,
|
|
44
|
+
deliveryDate: pickDeliveryDate(pkg),
|
|
45
|
+
service: (_f = pkg.service) === null || _f === void 0 ? void 0 : _f.description,
|
|
46
|
+
};
|
|
47
|
+
if (options.detail === 'detailed' && Array.isArray(pkg.activity) && pkg.activity.length > 0) {
|
|
48
|
+
result.activity = pkg.activity.map(mapActivity);
|
|
49
|
+
}
|
|
50
|
+
results.push(result);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=mapTrackStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapTrackStatus.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/mapTrackStatus.ts"],"names":[],"mappings":";;AA0EA,wCA6BC;AAzDD,SAAS,cAAc,CAAC,OAAoB;;IAC3C,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,KAAK,GAAG;QACb,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,aAAa;QACrB,MAAA,OAAO,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,mCAAI,EAAE,CAAC;IACzD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,MAAA,QAAQ,CAAC,OAAO,mCAAI,EAAE,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC;YACjC,MAAM,MAAM,GAAgB;gBAC3B,cAAc,EAAE,MAAA,MAAA,GAAG,CAAC,cAAc,mCAAI,QAAQ,CAAC,aAAa,mCAAI,EAAE;gBAClE,UAAU,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI;gBACxB,UAAU,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI;gBACxB,iBAAiB,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW;gBACtC,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC;gBACnC,OAAO,EAAE,MAAA,GAAG,CAAC,OAAO,0CAAE,WAAW;aACjC,CAAC;YAGF,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7F,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACjD,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapUpsError = mapUpsError;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
function extractErrors(responseData) {
|
|
6
|
+
if (responseData === null || typeof responseData !== 'object')
|
|
7
|
+
return [];
|
|
8
|
+
const data = responseData;
|
|
9
|
+
const response = data.response;
|
|
10
|
+
if (response && Array.isArray(response.errors)) {
|
|
11
|
+
return response.errors;
|
|
12
|
+
}
|
|
13
|
+
const capitalized = data.Response;
|
|
14
|
+
const nested = capitalized === null || capitalized === void 0 ? void 0 : capitalized.response;
|
|
15
|
+
if (nested && Array.isArray(nested.errors)) {
|
|
16
|
+
return nested.errors;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(data.errors)) {
|
|
19
|
+
return data.errors;
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
function classify(statusCode) {
|
|
24
|
+
if (statusCode === 401 || statusCode === 403)
|
|
25
|
+
return 'auth';
|
|
26
|
+
if (statusCode === 429 || statusCode >= 500)
|
|
27
|
+
return 'transient';
|
|
28
|
+
return 'input';
|
|
29
|
+
}
|
|
30
|
+
const CLASS_PREFIX = {
|
|
31
|
+
auth: 'UPS authentication failed',
|
|
32
|
+
input: 'UPS rejected the request (invalid input)',
|
|
33
|
+
transient: 'UPS is temporarily unavailable — try again',
|
|
34
|
+
};
|
|
35
|
+
function mapUpsError(node, responseData, statusCode) {
|
|
36
|
+
const errors = extractErrors(responseData);
|
|
37
|
+
const cls = classify(statusCode);
|
|
38
|
+
const prefix = CLASS_PREFIX[cls];
|
|
39
|
+
const detail = errors.length > 0
|
|
40
|
+
? errors
|
|
41
|
+
.map((e) => { var _a, _b; return `${(_a = e.code) !== null && _a !== void 0 ? _a : 'UNKNOWN'}: ${(_b = e.message) !== null && _b !== void 0 ? _b : 'No message provided by UPS'}`; })
|
|
42
|
+
.join('; ')
|
|
43
|
+
: 'No structured error was returned by UPS.';
|
|
44
|
+
const message = `${prefix} — ${detail}`;
|
|
45
|
+
throw new n8n_workflow_1.NodeApiError(node, (responseData !== null && responseData !== void 0 ? responseData : {}), {
|
|
46
|
+
message,
|
|
47
|
+
description: detail,
|
|
48
|
+
httpCode: String(statusCode),
|
|
49
|
+
level: cls === 'transient' ? 'warning' : 'error',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=mapUpsError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapUpsError.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/mapUpsError.ts"],"names":[],"mappings":";;AA0DA,kCAqBC;AA/ED,+CAA4C;AAkB5C,SAAS,aAAa,CAAC,YAAqB;IAC3C,IAAI,YAAY,KAAK,IAAI,IAAI,OAAO,YAAY,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzE,MAAM,IAAI,GAAG,YAAuC,CAAC;IAGrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAA+C,CAAC;IACtE,IAAI,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAChD,OAAO,QAAQ,CAAC,MAAoB,CAAC;IACtC,CAAC;IAGD,MAAM,WAAW,GAAG,IAAI,CAAC,QAA+C,CAAC;IACzE,MAAM,MAAM,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAA+C,CAAC;IAC5E,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC,MAAoB,CAAC;IACpC,CAAC;IAGD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,MAAoB,CAAC;IAClC,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC;AAID,SAAS,QAAQ,CAAC,UAAkB;IACnC,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,MAAM,CAAC;IAC5D,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,IAAI,GAAG;QAAE,OAAO,WAAW,CAAC;IAChE,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,MAAM,YAAY,GAA+B;IAEhD,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE,0CAA0C;IACjD,SAAS,EAAE,4CAA4C;CACvD,CAAC;AAEF,SAAgB,WAAW,CAAC,IAAW,EAAE,YAAqB,EAAE,UAAkB;IACjF,MAAM,MAAM,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAGjC,MAAM,MAAM,GACX,MAAM,CAAC,MAAM,GAAG,CAAC;QAChB,CAAC,CAAC,MAAM;aACL,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,eAAC,OAAA,GAAG,MAAA,CAAC,CAAC,IAAI,mCAAI,SAAS,KAAK,MAAA,CAAC,CAAC,OAAO,mCAAI,4BAA4B,EAAE,CAAA,EAAA,CAAC;aAClF,IAAI,CAAC,IAAI,CAAC;QACb,CAAC,CAAC,0CAA0C,CAAC;IAE/C,MAAM,OAAO,GAAG,GAAG,MAAM,MAAM,MAAM,EAAE,CAAC;IAExC,MAAM,IAAI,2BAAY,CAAC,IAAI,EAAE,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAe,EAAE;QAChE,OAAO;QACP,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC;QAC5B,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KAChD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Address } from './types';
|
|
2
|
+
export type Resolution = 'valid' | 'ambiguous' | 'none';
|
|
3
|
+
export interface AddressValidationResult {
|
|
4
|
+
resolution: Resolution;
|
|
5
|
+
classification: {
|
|
6
|
+
code: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
candidates: Address[];
|
|
10
|
+
}
|
|
11
|
+
interface RawAddressKeyFormat {
|
|
12
|
+
AddressLine?: string[] | string;
|
|
13
|
+
PoliticalDivision2?: string;
|
|
14
|
+
PoliticalDivision1?: string;
|
|
15
|
+
PostcodePrimaryLow?: string;
|
|
16
|
+
PostcodeExtendedLow?: string;
|
|
17
|
+
CountryCode?: string;
|
|
18
|
+
}
|
|
19
|
+
interface RawClassification {
|
|
20
|
+
Code?: string;
|
|
21
|
+
Description?: string;
|
|
22
|
+
}
|
|
23
|
+
interface RawCandidate {
|
|
24
|
+
AddressClassification?: RawClassification;
|
|
25
|
+
AddressKeyFormat?: RawAddressKeyFormat;
|
|
26
|
+
}
|
|
27
|
+
interface XavResponse {
|
|
28
|
+
XAVResponse?: {
|
|
29
|
+
ValidAddressIndicator?: unknown;
|
|
30
|
+
AmbiguousAddressIndicator?: unknown;
|
|
31
|
+
NoCandidatesIndicator?: unknown;
|
|
32
|
+
AddressClassification?: RawClassification;
|
|
33
|
+
Candidate?: RawCandidate[] | RawCandidate;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare function shapeCandidates(response: XavResponse): AddressValidationResult;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shapeCandidates = shapeCandidates;
|
|
4
|
+
const CLASSIFICATION_LABELS = {
|
|
5
|
+
'0': 'UnClassified',
|
|
6
|
+
'1': 'Commercial',
|
|
7
|
+
'2': 'Residential',
|
|
8
|
+
};
|
|
9
|
+
function labelFor(code, description) {
|
|
10
|
+
var _a;
|
|
11
|
+
const safeCode = code !== null && code !== void 0 ? code : '0';
|
|
12
|
+
return {
|
|
13
|
+
code: safeCode,
|
|
14
|
+
label: (_a = description !== null && description !== void 0 ? description : CLASSIFICATION_LABELS[safeCode]) !== null && _a !== void 0 ? _a : 'UnClassified',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function resolutionOf(xav) {
|
|
18
|
+
if (xav.ValidAddressIndicator !== undefined)
|
|
19
|
+
return 'valid';
|
|
20
|
+
if (xav.AmbiguousAddressIndicator !== undefined)
|
|
21
|
+
return 'ambiguous';
|
|
22
|
+
return 'none';
|
|
23
|
+
}
|
|
24
|
+
function toAddress(akf, classification) {
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
26
|
+
const lines = Array.isArray(akf.AddressLine)
|
|
27
|
+
? akf.AddressLine
|
|
28
|
+
: akf.AddressLine
|
|
29
|
+
? [akf.AddressLine]
|
|
30
|
+
: [];
|
|
31
|
+
const postal = akf.PostcodeExtendedLow
|
|
32
|
+
? `${(_a = akf.PostcodePrimaryLow) !== null && _a !== void 0 ? _a : ''}-${akf.PostcodeExtendedLow}`
|
|
33
|
+
: ((_b = akf.PostcodePrimaryLow) !== null && _b !== void 0 ? _b : '');
|
|
34
|
+
const address = {
|
|
35
|
+
addressLines: lines,
|
|
36
|
+
city: (_c = akf.PoliticalDivision2) !== null && _c !== void 0 ? _c : '',
|
|
37
|
+
stateProvinceCode: (_d = akf.PoliticalDivision1) !== null && _d !== void 0 ? _d : '',
|
|
38
|
+
postalCode: postal,
|
|
39
|
+
countryCode: (_e = akf.CountryCode) !== null && _e !== void 0 ? _e : '',
|
|
40
|
+
};
|
|
41
|
+
if ((classification === null || classification === void 0 ? void 0 : classification.Code) === '2')
|
|
42
|
+
address.residential = true;
|
|
43
|
+
if ((classification === null || classification === void 0 ? void 0 : classification.Code) === '1')
|
|
44
|
+
address.residential = false;
|
|
45
|
+
return address;
|
|
46
|
+
}
|
|
47
|
+
function shapeCandidates(response) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const xav = response.XAVResponse;
|
|
50
|
+
if (!xav) {
|
|
51
|
+
return { resolution: 'none', classification: labelFor('0'), candidates: [] };
|
|
52
|
+
}
|
|
53
|
+
const rawCandidates = Array.isArray(xav.Candidate)
|
|
54
|
+
? xav.Candidate
|
|
55
|
+
: xav.Candidate
|
|
56
|
+
? [xav.Candidate]
|
|
57
|
+
: [];
|
|
58
|
+
const topClassification = labelFor((_a = xav.AddressClassification) === null || _a === void 0 ? void 0 : _a.Code, (_b = xav.AddressClassification) === null || _b === void 0 ? void 0 : _b.Description);
|
|
59
|
+
const candidates = rawCandidates
|
|
60
|
+
.filter((c) => c.AddressKeyFormat)
|
|
61
|
+
.map((c) => toAddress(c.AddressKeyFormat, c.AddressClassification));
|
|
62
|
+
return {
|
|
63
|
+
resolution: resolutionOf(xav),
|
|
64
|
+
classification: topClassification,
|
|
65
|
+
candidates,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=shapeCandidates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapeCandidates.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/shapeCandidates.ts"],"names":[],"mappings":";;AAyFA,0CA0BC;AAvED,MAAM,qBAAqB,GAA2B;IACrD,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,aAAa;CAClB,CAAC;AAEF,SAAS,QAAQ,CAAC,IAAwB,EAAE,WAAoB;;IAC/D,MAAM,QAAQ,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,GAAG,CAAC;IAC7B,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,MAAA,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,qBAAqB,CAAC,QAAQ,CAAC,mCAAI,cAAc;KACvE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAA4C;IACjE,IAAI,GAAG,CAAC,qBAAqB,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC5D,IAAI,GAAG,CAAC,yBAAyB,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IACpE,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,SAAS,C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9E,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACjD,CAAC,CAAC,GAAG,CAAC,SAAS;QACf,CAAC,CAAC,GAAG,CAAC,SAAS;YACd,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,iBAAiB,GAAG,QAAQ,CACjC,MAAA,GAAG,CAAC,qBAAqB,0CAAE,IAAI,EAC/B,MAAA,GAAG,CAAC,qBAAqB,0CAAE,WAAW,CACtC,CAAC;IAEF,MAAM,UAAU,GAAG,aAAa;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAuC,EAAE,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAE5F,OAAO;QACN,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC;QAC7B,cAAc,EAAE,iBAAiB;QACjC,UAAU;KACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMoney = toMoney;
|
|
4
|
+
function toMoney(charge) {
|
|
5
|
+
if (!charge)
|
|
6
|
+
return null;
|
|
7
|
+
const { CurrencyCode, MonetaryValue } = charge;
|
|
8
|
+
if (!CurrencyCode ||
|
|
9
|
+
MonetaryValue === undefined ||
|
|
10
|
+
MonetaryValue === null ||
|
|
11
|
+
MonetaryValue === '') {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return { amount: MonetaryValue, currency: CurrencyCode };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=toMoney.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toMoney.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/toMoney.ts"],"names":[],"mappings":";;AAWA,0BAYC;AAZD,SAAgB,OAAO,CAAC,MAAoC;IAC3D,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IAC/C,IACC,CAAC,YAAY;QACb,aAAa,KAAK,SAAS;QAC3B,aAAa,KAAK,IAAI;QACtB,aAAa,KAAK,EAAE,EACnB,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NormalizedAddressInput } from './toXavAddress';
|
|
2
|
+
export interface UpsAddress {
|
|
3
|
+
AddressLine: string[];
|
|
4
|
+
City: string;
|
|
5
|
+
StateProvinceCode: string;
|
|
6
|
+
PostalCode: string;
|
|
7
|
+
CountryCode: string;
|
|
8
|
+
ResidentialAddressIndicator?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function toUpsAddress(input: NormalizedAddressInput & {
|
|
11
|
+
residential?: boolean;
|
|
12
|
+
}): UpsAddress;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toUpsAddress = toUpsAddress;
|
|
4
|
+
function toUpsAddress(input) {
|
|
5
|
+
var _a;
|
|
6
|
+
const address = {
|
|
7
|
+
AddressLine: ((_a = input.addressLines) !== null && _a !== void 0 ? _a : []).map((l) => l.trim()).filter((l) => l.length > 0),
|
|
8
|
+
City: input.city,
|
|
9
|
+
StateProvinceCode: input.stateProvinceCode,
|
|
10
|
+
PostalCode: input.postalCode,
|
|
11
|
+
CountryCode: input.countryCode,
|
|
12
|
+
};
|
|
13
|
+
if (input.residential)
|
|
14
|
+
address.ResidentialAddressIndicator = '';
|
|
15
|
+
return address;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=toUpsAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUpsAddress.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/toUpsAddress.ts"],"names":[],"mappings":";;AAeA,oCAYC;AAZD,SAAgB,YAAY,CAC3B,KAAyD;;IAEzD,MAAM,OAAO,GAAe;QAC3B,WAAW,EAAE,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACxF,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;KAC9B,CAAC;IACF,IAAI,KAAK,CAAC,WAAW;QAAE,OAAO,CAAC,2BAA2B,GAAG,EAAE,CAAC;IAChE,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface NormalizedAddressInput {
|
|
2
|
+
addressLines: string[];
|
|
3
|
+
city: string;
|
|
4
|
+
stateProvinceCode: string;
|
|
5
|
+
postalCode: string;
|
|
6
|
+
countryCode: string;
|
|
7
|
+
}
|
|
8
|
+
export interface XavAddressKeyFormat {
|
|
9
|
+
AddressLine: string[];
|
|
10
|
+
PoliticalDivision2: string;
|
|
11
|
+
PoliticalDivision1: string;
|
|
12
|
+
PostcodePrimaryLow: string;
|
|
13
|
+
PostcodeExtendedLow?: string;
|
|
14
|
+
CountryCode: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function toXavAddress(input: NormalizedAddressInput): XavAddressKeyFormat;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toXavAddress = toXavAddress;
|
|
4
|
+
function splitPostcode(postalCode) {
|
|
5
|
+
const trimmed = (postalCode !== null && postalCode !== void 0 ? postalCode : '').trim();
|
|
6
|
+
const dash = trimmed.indexOf('-');
|
|
7
|
+
if (dash > -1) {
|
|
8
|
+
return { primary: trimmed.slice(0, dash), extended: trimmed.slice(dash + 1) || undefined };
|
|
9
|
+
}
|
|
10
|
+
return { primary: trimmed };
|
|
11
|
+
}
|
|
12
|
+
function toXavAddress(input) {
|
|
13
|
+
var _a;
|
|
14
|
+
const { primary, extended } = splitPostcode(input.postalCode);
|
|
15
|
+
const result = {
|
|
16
|
+
AddressLine: ((_a = input.addressLines) !== null && _a !== void 0 ? _a : []).map((l) => l.trim()).filter((l) => l.length > 0),
|
|
17
|
+
PoliticalDivision2: input.city,
|
|
18
|
+
PoliticalDivision1: input.stateProvinceCode,
|
|
19
|
+
PostcodePrimaryLow: primary,
|
|
20
|
+
CountryCode: input.countryCode,
|
|
21
|
+
};
|
|
22
|
+
if (extended)
|
|
23
|
+
result.PostcodeExtendedLow = extended;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=toXavAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toXavAddress.js","sourceRoot":"","sources":["../../../../nodes/Ups/core/toXavAddress.ts"],"names":[],"mappings":";;AA+BA,oCAWC;AApBD,SAAS,aAAa,CAAC,UAAkB;IACxC,MAAM,OAAO,GAAG,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;QACf,OAAO,EAAE,O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