@shipengine/connect-carrier-api 2.2.2 → 2.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/lib/app/carrier-app.js +6 -39
- package/lib/app/carrier-app.js.map +1 -1
- package/lib/app/internal/carrier-specification.js +14 -1
- package/lib/app/internal/carrier-specification.js.map +1 -1
- package/lib/app/internal/metadata.js.map +1 -1
- package/lib/app/metadata/account-modals.d.ts +8 -2
- package/lib/app/metadata/account-modals.js.map +1 -1
- package/lib/app/metadata/carrier-app-metadata.js.map +1 -1
- package/lib/app/metadata/carrier.d.ts +1 -0
- package/lib/app/metadata/carrier.js +6 -12
- package/lib/app/metadata/carrier.js.map +1 -1
- package/lib/app/metadata/label-formats.js.map +1 -1
- package/lib/app/metadata/label-sizes.js.map +1 -1
- package/lib/app/metadata/monoauth.js.map +1 -1
- package/lib/app/metadata/package-type.d.ts +1 -0
- package/lib/app/metadata/package-type.js +3 -0
- package/lib/app/metadata/package-type.js.map +1 -1
- package/lib/app/metadata/service-class.js.map +1 -1
- package/lib/app/metadata/service-grade.js.map +1 -1
- package/lib/app/metadata/shipping-service.d.ts +1 -0
- package/lib/app/metadata/shipping-service.js +7 -16
- package/lib/app/metadata/shipping-service.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/models/addresses/address-base.d.ts +13 -13
- package/lib/models/addresses/address-base.js.map +1 -1
- package/lib/models/addresses/address-residential-indicator.d.ts +3 -0
- package/lib/models/addresses/address-residential-indicator.js +3 -0
- package/lib/models/addresses/address-residential-indicator.js.map +1 -1
- package/lib/models/addresses/ship-from-display.d.ts +1 -0
- package/lib/models/addresses/ship-from-display.js +1 -0
- package/lib/models/addresses/ship-from-display.js.map +1 -1
- package/lib/models/addresses/ship-from.d.ts +1 -0
- package/lib/models/addresses/ship-from.js +1 -0
- package/lib/models/addresses/ship-from.js.map +1 -1
- package/lib/models/addresses/ship-to.d.ts +1 -0
- package/lib/models/addresses/ship-to.js +1 -0
- package/lib/models/addresses/ship-to.js.map +1 -1
- package/lib/models/advanced-options.d.ts +1 -1
- package/lib/models/authorization.d.ts +2 -0
- package/lib/models/authorization.js.map +1 -1
- package/lib/models/billing/billing-categories.d.ts +1 -1
- package/lib/models/billing/billing-categories.js +1 -1
- package/lib/models/billing/billing-categories.js.map +1 -1
- package/lib/models/billing/billing-line-item.d.ts +5 -0
- package/lib/models/billing/billing-line-item.js +2 -2
- package/lib/models/billing/billing-line-item.js.map +1 -1
- package/lib/models/confirmation-types.d.ts +5 -5
- package/lib/models/confirmation-types.js +5 -5
- package/lib/models/confirmation-types.js.map +1 -1
- package/lib/models/currency.d.ts +2 -0
- package/lib/models/currency.js.map +1 -1
- package/lib/models/customs/customs-content-types.d.ts +5 -1
- package/lib/models/customs/customs-content-types.js +5 -1
- package/lib/models/customs/customs-content-types.js.map +1 -1
- package/lib/models/customs/customs-item.d.ts +9 -1
- package/lib/models/customs/customs-item.js +1 -1
- package/lib/models/customs/customs-item.js.map +1 -1
- package/lib/models/customs/customs-non-delivery.d.ts +2 -0
- package/lib/models/customs/customs-non-delivery.js +2 -0
- package/lib/models/customs/customs-non-delivery.js.map +1 -1
- package/lib/models/customs/customs.d.ts +6 -1
- package/lib/models/customs/customs.js +1 -1
- package/lib/models/customs/customs.js.map +1 -1
- package/lib/models/documents/document-type.d.ts +4 -0
- package/lib/models/documents/document-type.js +4 -0
- package/lib/models/documents/document-type.js.map +1 -1
- package/lib/models/documents/document.d.ts +3 -0
- package/lib/models/documents/document.js.map +1 -1
- package/lib/models/errors/detailed-error.d.ts +1 -1
- package/lib/models/errors/detailed-error.js +1 -1
- package/lib/models/errors/detailed-error.js.map +1 -1
- package/lib/models/errors/standardized-error-code.d.ts +1 -1
- package/lib/models/errors/standardized-error-code.js +1 -1
- package/lib/models/errors/standardized-error-code.js.map +1 -1
- package/lib/models/fulfillment-plans/fulfillment-plan-details.d.ts +4 -1
- package/lib/models/fulfillment-plans/fulfillment-plan-details.js +1 -1
- package/lib/models/fulfillment-plans/fulfillment-plan-details.js.map +1 -1
- package/lib/models/fulfillment-plans/fulfillment-plan-items.d.ts +4 -4
- package/lib/models/fulfillment-plans/raw-external-source.d.ts +2 -0
- package/lib/models/fulfillment-plans/raw-external-source.js +1 -0
- package/lib/models/fulfillment-plans/raw-external-source.js.map +1 -1
- package/lib/models/labels/document-formats.js.map +1 -1
- package/lib/models/labels/form-download.d.ts +2 -0
- package/lib/models/labels/form-download.js +1 -0
- package/lib/models/labels/form-download.js.map +1 -1
- package/lib/models/labels/label-download.d.ts +2 -0
- package/lib/models/labels/label-download.js +1 -0
- package/lib/models/labels/label-download.js.map +1 -1
- package/lib/models/labels/label-package.d.ts +2 -0
- package/lib/models/labels/label-package.js.map +1 -1
- package/lib/models/labels/return-label-details.d.ts +1 -0
- package/lib/models/labels/return-label-details.js.map +1 -1
- package/lib/models/labels/void-request.d.ts +2 -0
- package/lib/models/labels/void-request.js.map +1 -1
- package/lib/models/labels/void-response.d.ts +1 -1
- package/lib/models/manifests/label.d.ts +2 -0
- package/lib/models/manifests/label.js.map +1 -1
- package/lib/models/manifests/manifest.d.ts +5 -1
- package/lib/models/manifests/manifest.js +1 -1
- package/lib/models/manifests/manifest.js.map +1 -1
- package/lib/models/package.d.ts +6 -0
- package/lib/models/package.js.map +1 -1
- package/lib/models/pickup/cancellation-details.d.ts +1 -0
- package/lib/models/pickup/cancellation-details.js.map +1 -1
- package/lib/models/pickup/pickup-confirmation.d.ts +3 -0
- package/lib/models/pickup/pickup-confirmation.js.map +1 -1
- package/lib/models/pickup/pickup-contact-details.d.ts +6 -1
- package/lib/models/pickup/pickup-contact-details.js +1 -1
- package/lib/models/pickup/pickup-contact-details.js.map +1 -1
- package/lib/models/pickup/pickup-location-details.d.ts +1 -0
- package/lib/models/pickup/pickup-location-details.js.map +1 -1
- package/lib/models/pickup/pickup-package.d.ts +7 -0
- package/lib/models/pickup/pickup-package.js.map +1 -1
- package/lib/models/pickup/pickup-shipment-details.d.ts +1 -0
- package/lib/models/pickup/pickup-shipment-details.js.map +1 -1
- package/lib/models/pickup/pickup-window.d.ts +5 -1
- package/lib/models/pickup/pickup-window.js +1 -1
- package/lib/models/pickup/pickup-window.js.map +1 -1
- package/lib/models/pickup/shipment-identifier.d.ts +2 -0
- package/lib/models/pickup/shipment-identifier.js.map +1 -1
- package/lib/models/pickup/shipped-package.d.ts +7 -0
- package/lib/models/pickup/shipped-package.js.map +1 -1
- package/lib/models/pickup/shipped-shipment.d.ts +6 -0
- package/lib/models/pickup/shipped-shipment.js.map +1 -1
- package/lib/models/rates/rate.d.ts +2 -4
- package/lib/models/rates/rate.js.map +1 -1
- package/lib/models/registration/credentials.d.ts +2 -0
- package/lib/models/registration/credentials.js.map +1 -1
- package/lib/models/resource-download.d.ts +2 -0
- package/lib/models/resource-download.js.map +1 -1
- package/lib/models/taxes/tax-identifier.d.ts +1 -1
- package/lib/models/taxes/tax-identifier.js +1 -1
- package/lib/models/taxes/tax-identifier.js.map +1 -1
- package/lib/models/tracking/lat-long.d.ts +2 -2
- package/lib/models/tracking/service.d.ts +2 -0
- package/lib/models/tracking/service.js.map +1 -1
- package/lib/models/tracking/track-event.d.ts +9 -0
- package/lib/models/tracking/track-event.js.map +1 -1
- package/lib/models/tracking/tracking-info.d.ts +18 -0
- package/lib/models/tracking/tracking-info.js.map +1 -1
- package/lib/models/tracking/update-method.js.map +1 -1
- package/lib/models/units/dimension-details.d.ts +4 -0
- package/lib/models/units/dimension-details.js.map +1 -1
- package/lib/models/units/weight-details.d.ts +4 -0
- package/lib/models/units/weight-details.js.map +1 -1
- package/lib/responses/normalize-tracking-data-response.js.map +1 -1
- package/lib/responses/validate-inbound-data-response.js.map +1 -1
- package/package.json +1 -1
- package/spec.json +355 -176
- package/src/app/carrier-app-definition.ts +5 -15
- package/src/app/carrier-app.ts +9 -45
- package/src/app/internal/carrier-specification.ts +20 -7
- package/src/app/internal/metadata.ts +1 -3
- package/src/app/metadata/account-modals.ts +8 -2
- package/src/app/metadata/carrier-app-metadata.ts +1 -6
- package/src/app/metadata/carrier.ts +11 -28
- package/src/app/metadata/label-formats.ts +1 -3
- package/src/app/metadata/label-sizes.ts +1 -3
- package/src/app/metadata/monoauth.ts +1 -4
- package/src/app/metadata/package-type.ts +4 -0
- package/src/app/metadata/service-class.ts +1 -3
- package/src/app/metadata/service-grade.ts +1 -3
- package/src/app/metadata/shipping-service.ts +10 -24
- package/src/index.ts +1 -0
- package/src/models/addresses/address-base.ts +13 -14
- package/src/models/addresses/address-residential-indicator.ts +3 -0
- package/src/models/addresses/ship-from-display.ts +1 -0
- package/src/models/addresses/ship-from.ts +1 -0
- package/src/models/addresses/ship-to.ts +1 -0
- package/src/models/advanced-options.ts +1 -1
- package/src/models/authorization.ts +2 -0
- package/src/models/billing/billing-categories.ts +2 -4
- package/src/models/billing/billing-line-item.ts +8 -6
- package/src/models/confirmation-types.ts +5 -5
- package/src/models/currency.ts +2 -0
- package/src/models/customs/customs-content-types.ts +5 -1
- package/src/models/customs/customs-item.ts +9 -1
- package/src/models/customs/customs-non-delivery.ts +2 -0
- package/src/models/customs/customs.ts +6 -1
- package/src/models/documents/document-type.ts +5 -3
- package/src/models/documents/document.ts +4 -4
- package/src/models/errors/detailed-error.ts +1 -1
- package/src/models/errors/standardized-error-code.ts +1 -1
- package/src/models/fulfillment-plans/fulfillment-plan-details.ts +4 -1
- package/src/models/fulfillment-plans/fulfillment-plan-items.ts +4 -4
- package/src/models/fulfillment-plans/raw-external-source.ts +2 -0
- package/src/models/labels/document-formats.ts +1 -3
- package/src/models/labels/form-download.ts +2 -0
- package/src/models/labels/label-download.ts +2 -0
- package/src/models/labels/label-package.ts +2 -0
- package/src/models/labels/return-label-details.ts +1 -0
- package/src/models/labels/void-request.ts +2 -0
- package/src/models/labels/void-response.ts +1 -1
- package/src/models/manifests/label.ts +2 -0
- package/src/models/manifests/manifest.ts +5 -1
- package/src/models/package.ts +6 -0
- package/src/models/pickup/cancellation-details.ts +1 -0
- package/src/models/pickup/pickup-confirmation.ts +4 -4
- package/src/models/pickup/pickup-contact-details.ts +6 -1
- package/src/models/pickup/pickup-location-details.ts +1 -0
- package/src/models/pickup/pickup-package.ts +7 -0
- package/src/models/pickup/pickup-shipment-details.ts +1 -0
- package/src/models/pickup/pickup-window.ts +5 -1
- package/src/models/pickup/shipment-identifier.ts +2 -0
- package/src/models/pickup/shipped-package.ts +7 -0
- package/src/models/pickup/shipped-shipment.ts +6 -0
- package/src/models/rates/rate.ts +3 -8
- package/src/models/registration/credentials.ts +2 -0
- package/src/models/resource-download.ts +2 -0
- package/src/models/taxes/tax-identifier.ts +1 -1
- package/src/models/tracking/lat-long.ts +2 -2
- package/src/models/tracking/service.ts +2 -0
- package/src/models/tracking/track-event.ts +9 -0
- package/src/models/tracking/tracking-info.ts +18 -0
- package/src/models/tracking/update-method.ts +1 -3
- package/src/models/units/dimension-details.ts +4 -0
- package/src/models/units/weight-details.ts +4 -0
- package/src/responses/normalize-tracking-data-response.ts +1 -6
- package/src/responses/validate-inbound-data-response.ts +1 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -39,23 +39,17 @@ export interface CarrierAppDefinition {
|
|
|
39
39
|
* @description This method is used to register an account
|
|
40
40
|
* @param request The information needed to register or initialize a connection with the shipping provider
|
|
41
41
|
*/
|
|
42
|
-
Register?: (
|
|
43
|
-
request: RegisterRequest,
|
|
44
|
-
) => RegisterResponse | Promise<RegisterResponse>;
|
|
42
|
+
Register?: (request: RegisterRequest) => RegisterResponse | Promise<RegisterResponse>;
|
|
45
43
|
/**
|
|
46
44
|
* @description This method is used to create a label
|
|
47
45
|
* @param request Data needed by the provider to create a label
|
|
48
46
|
*/
|
|
49
|
-
CreateLabel?: (
|
|
50
|
-
request: CreateLabelRequest,
|
|
51
|
-
) => CreateLabelResponse | Promise<CreateLabelResponse>;
|
|
47
|
+
CreateLabel?: (request: CreateLabelRequest) => CreateLabelResponse | Promise<CreateLabelResponse>;
|
|
52
48
|
/**
|
|
53
49
|
* @description This method is used to void multiple labels
|
|
54
50
|
* @param request Data needed by the provider to void multiple labels
|
|
55
51
|
*/
|
|
56
|
-
VoidLabels?: (
|
|
57
|
-
request: VoidLabelsRequest,
|
|
58
|
-
) => VoidLabelsResponse | Promise<VoidLabelsResponse>;
|
|
52
|
+
VoidLabels?: (request: VoidLabelsRequest) => VoidLabelsResponse | Promise<VoidLabelsResponse>;
|
|
59
53
|
/**
|
|
60
54
|
* @description This method is used to create a manifest with a carrier
|
|
61
55
|
* @param request Data needed by the provider to create a manifest
|
|
@@ -81,16 +75,12 @@ export interface CarrierAppDefinition {
|
|
|
81
75
|
* @description This endpoint is used to get rates for a particular shipment
|
|
82
76
|
* @param request Data needed by the provider to get a rate estimate
|
|
83
77
|
*/
|
|
84
|
-
GetRates?: (
|
|
85
|
-
request: GetRatesRequest,
|
|
86
|
-
) => GetRatesResponse | Promise<GetRatesResponse>;
|
|
78
|
+
GetRates?: (request: GetRatesRequest) => GetRatesResponse | Promise<GetRatesResponse>;
|
|
87
79
|
/**
|
|
88
80
|
* @description This endpoint is used to get tracking information about a shipment
|
|
89
81
|
* @param request Data needed by the provider to track a shipment
|
|
90
82
|
*/
|
|
91
|
-
Track?: (
|
|
92
|
-
request: TrackingRequest,
|
|
93
|
-
) => TrackingResponse | Promise<TrackingResponse>;
|
|
83
|
+
Track?: (request: TrackingRequest) => TrackingResponse | Promise<TrackingResponse>;
|
|
94
84
|
/**
|
|
95
85
|
* @description This endpoint is used to submit notification of the creation of a shipment
|
|
96
86
|
* @param request Data needed by the provider to inform them of a shipment
|
package/src/app/carrier-app.ts
CHANGED
|
@@ -44,15 +44,11 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
44
44
|
c.DefaultSupportedCountries?.flatMap((sc) => sc.FromCountry),
|
|
45
45
|
);
|
|
46
46
|
const serviceCountries = definition.Metadata.Carriers.flatMap((c) =>
|
|
47
|
-
c.ShippingServices?.flatMap((s) => s.SupportedCountries).flatMap(
|
|
48
|
-
(sc) => sc?.FromCountry,
|
|
49
|
-
),
|
|
47
|
+
c.ShippingServices?.flatMap((s) => s.SupportedCountries).flatMap((sc) => sc?.FromCountry),
|
|
50
48
|
);
|
|
51
49
|
countries.push(...rootCountries);
|
|
52
50
|
countries.push(...serviceCountries);
|
|
53
|
-
const uniqueCountries = [...new Set(countries)].filter(
|
|
54
|
-
(c) => c !== undefined,
|
|
55
|
-
) as string[];
|
|
51
|
+
const uniqueCountries = [...new Set(countries)].filter((c) => c !== undefined) as string[];
|
|
56
52
|
return uniqueCountries;
|
|
57
53
|
};
|
|
58
54
|
this.validate = () => {
|
|
@@ -71,18 +67,8 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
71
67
|
definition.CancelNotification,
|
|
72
68
|
CancelNotificationResponseSchema,
|
|
73
69
|
],
|
|
74
|
-
[
|
|
75
|
-
|
|
76
|
-
ApiEndpoints.CancelPickup,
|
|
77
|
-
definition.CancelPickup,
|
|
78
|
-
CancelPickupResponseSchema,
|
|
79
|
-
],
|
|
80
|
-
[
|
|
81
|
-
Method.POST,
|
|
82
|
-
ApiEndpoints.CreateLabel,
|
|
83
|
-
definition.CreateLabel,
|
|
84
|
-
CreateLabelResponseSchema,
|
|
85
|
-
],
|
|
70
|
+
[Method.POST, ApiEndpoints.CancelPickup, definition.CancelPickup, CancelPickupResponseSchema],
|
|
71
|
+
[Method.POST, ApiEndpoints.CreateLabel, definition.CreateLabel, CreateLabelResponseSchema],
|
|
86
72
|
[
|
|
87
73
|
Method.POST,
|
|
88
74
|
ApiEndpoints.CreateManifest,
|
|
@@ -95,48 +81,28 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
95
81
|
definition.CreateNotification,
|
|
96
82
|
CreateNotificationResponseSchema,
|
|
97
83
|
],
|
|
98
|
-
[
|
|
99
|
-
Method.POST,
|
|
100
|
-
ApiEndpoints.GetRates,
|
|
101
|
-
definition.GetRates,
|
|
102
|
-
GetRatesResponseSchema,
|
|
103
|
-
],
|
|
84
|
+
[Method.POST, ApiEndpoints.GetRates, definition.GetRates, GetRatesResponseSchema],
|
|
104
85
|
[
|
|
105
86
|
Method.POST,
|
|
106
87
|
ApiEndpoints.NormalizeTrackingData,
|
|
107
88
|
definition.NormalizeTrackingData,
|
|
108
89
|
NormalizeTrackingDataResponseSchema,
|
|
109
90
|
],
|
|
110
|
-
[
|
|
111
|
-
Method.POST,
|
|
112
|
-
ApiEndpoints.Register,
|
|
113
|
-
definition.Register,
|
|
114
|
-
RegisterResponseSchema,
|
|
115
|
-
],
|
|
91
|
+
[Method.POST, ApiEndpoints.Register, definition.Register, RegisterResponseSchema],
|
|
116
92
|
[
|
|
117
93
|
Method.POST,
|
|
118
94
|
ApiEndpoints.SchedulePickup,
|
|
119
95
|
definition.SchedulePickup,
|
|
120
96
|
SchedulePickupResponseSchema,
|
|
121
97
|
],
|
|
122
|
-
[
|
|
123
|
-
Method.POST,
|
|
124
|
-
ApiEndpoints.Track,
|
|
125
|
-
definition.Track,
|
|
126
|
-
TrackingResponseSchema,
|
|
127
|
-
],
|
|
98
|
+
[Method.POST, ApiEndpoints.Track, definition.Track, TrackingResponseSchema],
|
|
128
99
|
[
|
|
129
100
|
Method.POST,
|
|
130
101
|
ApiEndpoints.ValidateInboundData,
|
|
131
102
|
definition.ValidateInboundData,
|
|
132
103
|
ValidateInboundDataResponseSchema,
|
|
133
104
|
],
|
|
134
|
-
[
|
|
135
|
-
Method.POST,
|
|
136
|
-
ApiEndpoints.VoidLabels,
|
|
137
|
-
definition.VoidLabels,
|
|
138
|
-
VoidLabelsResponseSchema,
|
|
139
|
-
],
|
|
105
|
+
[Method.POST, ApiEndpoints.VoidLabels, definition.VoidLabels, VoidLabelsResponseSchema],
|
|
140
106
|
).forEach(([method, path, implementation, schema]) => {
|
|
141
107
|
if (implementation) {
|
|
142
108
|
this.routes.push({
|
|
@@ -147,9 +113,7 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
147
113
|
const validationResults = schema.validate(result, {
|
|
148
114
|
abortEarly: false,
|
|
149
115
|
});
|
|
150
|
-
const errors = validationResults?.error?.details?.map(
|
|
151
|
-
(detail) => detail.message,
|
|
152
|
-
);
|
|
116
|
+
const errors = validationResults?.error?.details?.map((detail) => detail.message);
|
|
153
117
|
return errors;
|
|
154
118
|
},
|
|
155
119
|
});
|
|
@@ -37,9 +37,7 @@ export const mapShippingOptions = (
|
|
|
37
37
|
return ret;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const mapConfirmationTypes = (
|
|
41
|
-
types?: ConfirmationDictionary,
|
|
42
|
-
): ConfirmationType[] => {
|
|
40
|
+
export const mapConfirmationTypes = (types?: ConfirmationDictionary): ConfirmationType[] => {
|
|
43
41
|
if (!types) {
|
|
44
42
|
return [];
|
|
45
43
|
}
|
|
@@ -56,6 +54,23 @@ export const mapConfirmationTypes = (
|
|
|
56
54
|
return ret;
|
|
57
55
|
};
|
|
58
56
|
|
|
57
|
+
const mapAccountModal = (modal: AccountModals): AccountModals => {
|
|
58
|
+
return {
|
|
59
|
+
RegistrationFormSchema: {
|
|
60
|
+
JsonSchema:
|
|
61
|
+
modal.RegistrationFormSchema.JsonSchema ??
|
|
62
|
+
modal.RegistrationFormSchema.formSchema?.jsonSchema,
|
|
63
|
+
UiSchema:
|
|
64
|
+
modal.RegistrationFormSchema.UiSchema ?? modal.RegistrationFormSchema.formSchema?.uiSchema,
|
|
65
|
+
},
|
|
66
|
+
SettingsFormSchema: {
|
|
67
|
+
JsonSchema:
|
|
68
|
+
modal.SettingsFormSchema.JsonSchema ?? modal.SettingsFormSchema.formSchema?.jsonSchema,
|
|
69
|
+
UiSchema: modal.SettingsFormSchema.UiSchema ?? modal.SettingsFormSchema.formSchema?.uiSchema,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
59
74
|
/** @description This represents what we send to data manager */
|
|
60
75
|
export class CarrierSpecification {
|
|
61
76
|
Id: string;
|
|
@@ -84,16 +99,14 @@ export class CarrierSpecification {
|
|
|
84
99
|
};
|
|
85
100
|
this.Id = definition.Id;
|
|
86
101
|
this.Name = definition.Name;
|
|
87
|
-
this.AccountModals = definition.AccountModals;
|
|
102
|
+
this.AccountModals = mapAccountModal(definition.AccountModals);
|
|
88
103
|
this.PackageTypes = definition.PackageTypes;
|
|
89
104
|
this.ShippingServices = definition.ShippingServices;
|
|
90
105
|
this.ShippingOptions = mapShippingOptions(definition.ShippingOptions);
|
|
91
106
|
this.DefaultSupportedCountries = definition.DefaultSupportedCountries;
|
|
92
107
|
this.DefaultLabelSizes = definition.DefaultLabelSizes;
|
|
93
108
|
this.LabelFormats = definition.LabelFormats;
|
|
94
|
-
this.DefaultConfirmationTypes = mapConfirmationTypes(
|
|
95
|
-
definition.DefaultConfirmationTypes,
|
|
96
|
-
);
|
|
109
|
+
this.DefaultConfirmationTypes = mapConfirmationTypes(definition.DefaultConfirmationTypes);
|
|
97
110
|
this.CarrierAttributes = definition.CarrierAttributes;
|
|
98
111
|
this.TrackingUrl = definition.TrackingUrl;
|
|
99
112
|
this.CarrierUrl = definition.CarrierUrl;
|
|
@@ -63,9 +63,7 @@ export class Metadata implements CarrierAppSpecification {
|
|
|
63
63
|
if (this.AuthProcess) {
|
|
64
64
|
this.AuthProcess.Identifier.Version = '2.0';
|
|
65
65
|
}
|
|
66
|
-
this.Carriers = app.Metadata.Carriers.map(
|
|
67
|
-
(c) => new CarrierSpecification(c),
|
|
68
|
-
);
|
|
66
|
+
this.Carriers = app.Metadata.Carriers.map((c) => new CarrierSpecification(c));
|
|
69
67
|
|
|
70
68
|
this.Connector = {
|
|
71
69
|
DiagnosticRoutes: {
|
|
@@ -3,17 +3,23 @@ import Joi from 'joi';
|
|
|
3
3
|
export interface AccountModals {
|
|
4
4
|
/** @description Schema for the form to register with the carrier */
|
|
5
5
|
RegistrationFormSchema: {
|
|
6
|
-
|
|
6
|
+
/** @deprecated Please use JsonSchema & UiSchema */
|
|
7
|
+
formSchema?: {
|
|
7
8
|
jsonSchema: object;
|
|
8
9
|
uiSchema: object;
|
|
9
10
|
};
|
|
11
|
+
JsonSchema?: object;
|
|
12
|
+
UiSchema?: object;
|
|
10
13
|
};
|
|
11
14
|
/** @description Schema for the form to update carrier settings */
|
|
12
15
|
SettingsFormSchema: {
|
|
13
|
-
|
|
16
|
+
/** @deprecated Please use JsonSchema & UiSchema */
|
|
17
|
+
formSchema?: {
|
|
14
18
|
jsonSchema: object;
|
|
15
19
|
uiSchema: object;
|
|
16
20
|
};
|
|
21
|
+
JsonSchema?: object;
|
|
22
|
+
UiSchema?: object;
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
25
|
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
|
-
import {
|
|
3
|
-
AuthSpecification,
|
|
4
|
-
AuthSpecificationSchema,
|
|
5
|
-
Carrier,
|
|
6
|
-
CarrierSchema,
|
|
7
|
-
} from '.';
|
|
2
|
+
import { AuthSpecification, AuthSpecificationSchema, Carrier, CarrierSchema } from '.';
|
|
8
3
|
|
|
9
4
|
export interface CarrierAppMetadata {
|
|
10
5
|
/** @description Id of the carrier app */
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { AccountModals, AccountModalsSchema } from './account-modals';
|
|
2
2
|
import { PackageType, PackageTypeSchema } from './package-type';
|
|
3
3
|
import { ShippingService, ShippingServiceSchema } from './shipping-service';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from './shipping-option';
|
|
8
|
-
import {
|
|
9
|
-
CountryAssociation,
|
|
10
|
-
CountryAssociationSchema,
|
|
11
|
-
} from './country-association';
|
|
12
|
-
import {
|
|
13
|
-
CarrierAttributeEnum,
|
|
14
|
-
CarrierAttributeEnumSchema,
|
|
15
|
-
} from './carrier-attributes';
|
|
4
|
+
import { ShippingOptionDictionary, ShippingOptionDictionarySchema } from './shipping-option';
|
|
5
|
+
import { CountryAssociation, CountryAssociationSchema } from './country-association';
|
|
6
|
+
import { CarrierAttributeEnum, CarrierAttributeEnumSchema } from './carrier-attributes';
|
|
16
7
|
import { LabelFormatsEnum, LabelFormatsEnumSchema } from './label-formats';
|
|
17
8
|
import { LabelSizesEnum, LabelSizesEnumSchema } from './label-sizes';
|
|
18
|
-
import {
|
|
19
|
-
ConfirmationDictionary,
|
|
20
|
-
ConfirmationDictionarySchema,
|
|
21
|
-
} from './confirmation-type';
|
|
9
|
+
import { ConfirmationDictionary, ConfirmationDictionarySchema } from './confirmation-type';
|
|
22
10
|
import { existsSync } from 'fs';
|
|
23
11
|
import Joi from 'joi';
|
|
24
12
|
|
|
@@ -37,6 +25,7 @@ export interface Carrier {
|
|
|
37
25
|
CarrierUrl?: string;
|
|
38
26
|
Description?: string;
|
|
39
27
|
Name: string;
|
|
28
|
+
ApiCode?: string;
|
|
40
29
|
Id: string;
|
|
41
30
|
Images: {
|
|
42
31
|
Logo: string;
|
|
@@ -54,25 +43,16 @@ const fileExists = (value: string, helpers: any) => {
|
|
|
54
43
|
export const CarrierSchema = Joi.object({
|
|
55
44
|
AccountModals: AccountModalsSchema.required(),
|
|
56
45
|
PackageTypes: Joi.array().optional().items(PackageTypeSchema).unique('Id'),
|
|
57
|
-
ShippingServices: Joi.array()
|
|
58
|
-
.optional()
|
|
59
|
-
.items(ShippingServiceSchema)
|
|
60
|
-
.unique('Id'),
|
|
46
|
+
ShippingServices: Joi.array().optional().items(ShippingServiceSchema).unique('Id'),
|
|
61
47
|
ShippingOptions: ShippingOptionDictionarySchema.optional(),
|
|
62
48
|
DefaultSupportedCountries: Joi.array()
|
|
63
49
|
.optional()
|
|
64
50
|
.items(CountryAssociationSchema)
|
|
65
51
|
.unique('FromCountry'),
|
|
66
|
-
DefaultLabelSizes: Joi.array()
|
|
67
|
-
.optional()
|
|
68
|
-
.items(LabelSizesEnumSchema)
|
|
69
|
-
.unique(),
|
|
52
|
+
DefaultLabelSizes: Joi.array().optional().items(LabelSizesEnumSchema).unique(),
|
|
70
53
|
LabelFormats: Joi.array().optional().items(LabelFormatsEnumSchema).unique(),
|
|
71
54
|
DefaultConfirmationTypes: ConfirmationDictionarySchema.optional(),
|
|
72
|
-
CarrierAttributes: Joi.array()
|
|
73
|
-
.optional()
|
|
74
|
-
.items(CarrierAttributeEnumSchema)
|
|
75
|
-
.unique(),
|
|
55
|
+
CarrierAttributes: Joi.array().optional().items(CarrierAttributeEnumSchema).unique(),
|
|
76
56
|
TrackingUrl: Joi.string()
|
|
77
57
|
.optional()
|
|
78
58
|
.pattern(
|
|
@@ -84,6 +64,9 @@ export const CarrierSchema = Joi.object({
|
|
|
84
64
|
CarrierUrl: Joi.string().optional().uri().max(200),
|
|
85
65
|
Description: Joi.string().optional().max(250),
|
|
86
66
|
Name: Joi.string().required().max(50),
|
|
67
|
+
ApiCode: Joi.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.pattern(/^[a-z][a-z0-9_]*[a-z]$/, 'ApiCode'),
|
|
87
70
|
Id: Joi.string()
|
|
88
71
|
.uuid({ version: ['uuidv4'] })
|
|
89
72
|
.required(),
|
|
@@ -67,10 +67,7 @@ export class ResponseTransformationConfiguration {
|
|
|
67
67
|
connection_context?: MapOfStrings;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export const MapOfStringsSchema = Joi.object().pattern(
|
|
71
|
-
Joi.string(),
|
|
72
|
-
Joi.string(),
|
|
73
|
-
);
|
|
70
|
+
export const MapOfStringsSchema = Joi.object().pattern(Joi.string(), Joi.string());
|
|
74
71
|
|
|
75
72
|
export const ResponseTransformationConfigurationSchema = Joi.object({
|
|
76
73
|
access_token: Joi.string().required(),
|
|
@@ -9,6 +9,7 @@ export enum RequiredToShipEnum {
|
|
|
9
9
|
export interface PackageType {
|
|
10
10
|
Id: string;
|
|
11
11
|
Name: string;
|
|
12
|
+
ApiCode?: string;
|
|
12
13
|
CarrierPackageTypeCode: string;
|
|
13
14
|
Description?: string;
|
|
14
15
|
Abbreviation?: string;
|
|
@@ -27,6 +28,9 @@ export const PackageTypeSchema = Joi.object({
|
|
|
27
28
|
.uuid({ version: ['uuidv4'] })
|
|
28
29
|
.required(),
|
|
29
30
|
Name: Joi.string().required().max(50),
|
|
31
|
+
ApiCode: Joi.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.pattern(/^[a-z][a-z0-9_]*[a-z]$/, 'ApiCode'),
|
|
30
34
|
CarrierPackageTypeCode: Joi.string().required().max(50),
|
|
31
35
|
Description: Joi.string().optional().max(500),
|
|
32
36
|
Abbreviation: Joi.string().optional().max(20),
|
|
@@ -12,6 +12,4 @@ export enum ServiceClassEnum {
|
|
|
12
12
|
ThreeDay = 'ThreeDay',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const ServiceClassEnumSchema = Joi.string().valid(
|
|
16
|
-
...Object.values(ServiceClassEnum),
|
|
17
|
-
);
|
|
15
|
+
export const ServiceClassEnumSchema = Joi.string().valid(...Object.values(ServiceClassEnum));
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ConfirmationType, ConfirmationTypeSchema } from './confirmation-type';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
CountryAssociationSchema,
|
|
5
|
-
} from './country-association';
|
|
6
|
-
import {
|
|
7
|
-
ServiceAttributesEnum,
|
|
8
|
-
ServiceAttributesEnumSchema,
|
|
9
|
-
} from './services-attributes';
|
|
2
|
+
import { CountryAssociation, CountryAssociationSchema } from './country-association';
|
|
3
|
+
import { ServiceAttributesEnum, ServiceAttributesEnumSchema } from './services-attributes';
|
|
10
4
|
import { LabelSizesEnum, LabelSizesEnumSchema } from './label-sizes';
|
|
11
5
|
import { ServiceClassEnum, ServiceClassEnumSchema } from './service-class';
|
|
12
6
|
import { ServiceGradeEnum, ServiceGradeEnumSchema } from './service-grade';
|
|
@@ -30,27 +24,16 @@ export interface ShippingService {
|
|
|
30
24
|
Code: string;
|
|
31
25
|
Abbreviation?: string;
|
|
32
26
|
Name: string;
|
|
27
|
+
ApiCode?: string;
|
|
33
28
|
Id: string;
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
export const ShippingServiceSchema = Joi.object({
|
|
37
|
-
ConfirmationTypes: Joi.array()
|
|
38
|
-
.optional()
|
|
39
|
-
.items(ConfirmationTypeSchema)
|
|
40
|
-
.unique('Type'),
|
|
32
|
+
ConfirmationTypes: Joi.array().optional().items(ConfirmationTypeSchema).unique('Type'),
|
|
41
33
|
ServiceAttributes: Joi.array().items(ServiceAttributesEnumSchema).optional(),
|
|
42
|
-
SupportedCountries: Joi.array()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.unique('FromCountry'),
|
|
46
|
-
SupportedLabelSizes: Joi.array()
|
|
47
|
-
.optional()
|
|
48
|
-
.items(LabelSizesEnumSchema)
|
|
49
|
-
.unique(),
|
|
50
|
-
RequiredProperties: Joi.array()
|
|
51
|
-
.optional()
|
|
52
|
-
.items(ServiceRequiredPropertiesEnumSchema)
|
|
53
|
-
.unique(),
|
|
34
|
+
SupportedCountries: Joi.array().optional().items(CountryAssociationSchema).unique('FromCountry'),
|
|
35
|
+
SupportedLabelSizes: Joi.array().optional().items(LabelSizesEnumSchema).unique(),
|
|
36
|
+
RequiredProperties: Joi.array().optional().items(ServiceRequiredPropertiesEnumSchema).unique(),
|
|
54
37
|
Grade: ServiceGradeEnumSchema.optional(),
|
|
55
38
|
Class: ServiceClassEnumSchema.optional(),
|
|
56
39
|
LabelCode: Joi.string().optional().max(50),
|
|
@@ -58,6 +41,9 @@ export const ShippingServiceSchema = Joi.object({
|
|
|
58
41
|
Code: Joi.string().required().max(50),
|
|
59
42
|
Abbreviation: Joi.string().optional().max(20),
|
|
60
43
|
Name: Joi.string().required().max(80),
|
|
44
|
+
ApiCode: Joi.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.pattern(/^[a-z][a-z0-9_]*[a-z]$/, 'ApiCode'),
|
|
61
47
|
Id: Joi.string()
|
|
62
48
|
.uuid({ version: ['uuidv4'] })
|
|
63
49
|
.required(),
|
package/src/index.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { AddressResidentialIndicator } from './address-residential-indicator';
|
|
2
2
|
|
|
3
3
|
export class AddressBase {
|
|
4
|
-
/** @description
|
|
4
|
+
/** @description The full name of the contact contact associated with the address */
|
|
5
5
|
name?: string;
|
|
6
|
-
/** @description
|
|
6
|
+
/** @description The first name of the contact associated with the address */
|
|
7
7
|
first_name?: string;
|
|
8
|
-
/** @description
|
|
8
|
+
/** @description The last name of the contact associated with the address */
|
|
9
9
|
last_name?: string;
|
|
10
|
-
/** @description
|
|
10
|
+
/** @description The email of the contact associated with the address */
|
|
11
11
|
email?: string;
|
|
12
|
-
/** @description
|
|
13
|
-
|
|
12
|
+
/** @description The phone number of the contact associated with the address (No Newline Characters) */
|
|
14
13
|
phone_number?: string;
|
|
15
|
-
/** @description
|
|
14
|
+
/** @description The name of the company associated with this address (No Newline Characters) max length 100 characters */
|
|
16
15
|
company_name?: string;
|
|
17
|
-
/** @description
|
|
16
|
+
/** @description The address lines of the address (No Newline Characters) max length 100 characters */
|
|
18
17
|
address_lines?: string[];
|
|
19
|
-
/** @description City or locality
|
|
18
|
+
/** @description City or locality (No Newline Characters) */
|
|
20
19
|
city_locality?: string;
|
|
21
|
-
/** @description State or province
|
|
20
|
+
/** @description State or province (No Newline Characters) */
|
|
22
21
|
state_province?: string;
|
|
23
|
-
/** @description Zip or postal code
|
|
22
|
+
/** @description Zip or postal code (No Newline Characters) */
|
|
24
23
|
postal_code!: string;
|
|
25
|
-
/** @description ISO 3166-1 two-letter country code */
|
|
24
|
+
/** @description ISO 3166-1 two-letter country code max length 2 characters */
|
|
26
25
|
country_code!: string;
|
|
27
26
|
/** @description Whether the address is residential or commercial */
|
|
28
27
|
address_residential_indicator?: AddressResidentialIndicator;
|
|
29
28
|
/** @description Whether the country of the shipment address is a member of the EU */
|
|
30
29
|
is_eu?: boolean;
|
|
31
|
-
/** @description
|
|
30
|
+
/** @description Additional metadata provided for specific requests */
|
|
32
31
|
address_metadata?: { [key: string]: string };
|
|
33
|
-
/** @description Instructions to help the carrier navigate to the address
|
|
32
|
+
/** @description Instructions to help the carrier navigate to the address */
|
|
34
33
|
instructions?: string;
|
|
35
34
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** @description Used for indicating whether an address is residential or commercial */
|
|
2
2
|
export enum AddressResidentialIndicator {
|
|
3
|
+
/** @description Indicates that it is unknown whether or not the address is in a residential or commercial area */
|
|
3
4
|
Unknown = 'unknown',
|
|
5
|
+
/** @description Indicates that the address is in a residential area */
|
|
4
6
|
Yes = 'yes',
|
|
7
|
+
/** @description Indicates that the address is not in a residential area */
|
|
5
8
|
No = 'no',
|
|
6
9
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AddressBase } from './address-base';
|
|
2
2
|
import { TaxIdentifier } from '../taxes/tax-identifier';
|
|
3
3
|
|
|
4
|
+
/** @description The address for where the shipment will be shipped from */
|
|
4
5
|
export class ShipFrom extends AddressBase {
|
|
5
6
|
/** @description Tax IDs associated with the exporter */
|
|
6
7
|
tax_identifiers?: TaxIdentifier[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AddressBase } from './address-base';
|
|
2
2
|
import { TaxIdentifier } from '../taxes/tax-identifier';
|
|
3
3
|
|
|
4
|
+
/** @description The address that a shipment will be delivered to */
|
|
4
5
|
export class ShipTo extends AddressBase {
|
|
5
6
|
/** @description Tax IDs associated with the consignee */
|
|
6
7
|
tax_identifiers?: TaxIdentifier[];
|
|
@@ -12,7 +12,7 @@ export class AdvancedOptions {
|
|
|
12
12
|
bill_duties_to_sender?: boolean;
|
|
13
13
|
/** @description Whether Saturday delivery is permissible */
|
|
14
14
|
saturday_delivery?: boolean;
|
|
15
|
-
/** @description Amount to be paid to the driver, used for local delivery and courier services
|
|
15
|
+
/** @description Amount to be paid to the driver, used for local delivery and courier services */
|
|
16
16
|
tip?: Currency;
|
|
17
17
|
/** @description Any other custom shipping options */
|
|
18
18
|
[key: string]: any;
|
|
@@ -22,10 +22,8 @@ export enum BillingCategories {
|
|
|
22
22
|
Oversize = 'oversize',
|
|
23
23
|
Returns = 'returns',
|
|
24
24
|
Notifications = 'notifications',
|
|
25
|
-
/** @description Amount to be paid to the driver, used for local delivery and courier services
|
|
25
|
+
/** @description Amount to be paid to the driver, used for local delivery and courier services */
|
|
26
26
|
Tip = 'tip',
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const BillingCategoriesSchema = Joi.string().valid(
|
|
30
|
-
...Object.values(BillingCategories),
|
|
31
|
-
);
|
|
29
|
+
export const BillingCategoriesSchema = Joi.string().valid(...Object.values(BillingCategories));
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BillingCategories,
|
|
3
|
-
BillingCategoriesSchema,
|
|
4
|
-
} from './billing-categories';
|
|
1
|
+
import { BillingCategories, BillingCategoriesSchema } from './billing-categories';
|
|
5
2
|
import { Currency, CurrencySchema } from '../currency';
|
|
6
3
|
import Joi from 'joi';
|
|
7
4
|
|
|
8
5
|
/** @description Basic structure of each charge or line item */
|
|
9
6
|
export class BillingLineItem {
|
|
7
|
+
/** A generalized category for what type of billing line item this is */
|
|
10
8
|
billing_category!: BillingCategories;
|
|
9
|
+
/** @description If the carrier provides a description from their API about the billing charge (not specific to the user). Maximum length of 100 characters. */
|
|
11
10
|
carrier_description?: string;
|
|
11
|
+
/** @description If the carrier provides a billing code for */
|
|
12
12
|
carrier_billing_code?: string;
|
|
13
|
+
/** @description This will often be empty; however, if there was additionally specific information about the charge it should go here, could also be a reference number. Maximum length of 250 characters. */
|
|
13
14
|
memo?: string;
|
|
15
|
+
/** @description Total amount of the line item */
|
|
14
16
|
amount!: Currency;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const BillingLineItemSchema = Joi.object({
|
|
18
20
|
billing_category: BillingCategoriesSchema.required(),
|
|
19
|
-
carrier_description: Joi.string().optional().empty(),
|
|
21
|
+
carrier_description: Joi.string().optional().empty().max(100),
|
|
20
22
|
carrier_billing_code: Joi.string().optional().empty(),
|
|
21
|
-
memo: Joi.string().optional().empty(),
|
|
23
|
+
memo: Joi.string().optional().empty().max(250),
|
|
22
24
|
amount: CurrencySchema.required(),
|
|
23
25
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** @description Types of delivery confirmation */
|
|
2
2
|
export enum ConfirmationTypes {
|
|
3
|
-
/** @description No confirmation is requested
|
|
3
|
+
/** @description No confirmation is requested */
|
|
4
4
|
None = 'None',
|
|
5
|
-
/** @description Delivery confirmation is requested
|
|
5
|
+
/** @description Delivery confirmation is requested */
|
|
6
6
|
Delivery = 'Delivery',
|
|
7
|
-
/** @description A signature is required. This signature may be a neighbor, building manager, or the recipient can authorize the release of the package (without being present)
|
|
7
|
+
/** @description A signature is required. This signature may be a neighbor, building manager, or the recipient can authorize the release of the package (without being present) */
|
|
8
8
|
Signature = 'Signature',
|
|
9
|
-
/** @description A signature of an adult is required
|
|
9
|
+
/** @description A signature of an adult is required */
|
|
10
10
|
AdultSignature = 'AdultSignature',
|
|
11
|
-
/** @description Only supported by FedEx. The signature of somebody at the address is required
|
|
11
|
+
/** @description Only supported by FedEx. The signature of somebody at the address is required */
|
|
12
12
|
DirectSignature = 'DirectSignature',
|
|
13
13
|
}
|
package/src/models/currency.ts
CHANGED
|
@@ -2,7 +2,9 @@ import Joi from 'joi';
|
|
|
2
2
|
|
|
3
3
|
/** @description Basic structure for defining an amount of money and its currency */
|
|
4
4
|
export class Currency {
|
|
5
|
+
/** @description The ISO 4217 Currency Code (USD, EUR, etc) https://www.iso.org/iso-4217-currency-codes.html */
|
|
5
6
|
currency!: string;
|
|
7
|
+
/** @description The amount */
|
|
6
8
|
amount!: string;
|
|
7
9
|
}
|
|
8
10
|
|