@shipengine/connect-carrier-api 2.2.4 → 2.3.3
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/jest.config.js +6 -0
- package/lib/app/carrier-app.js +8 -49
- 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/billing/billing-categories.js.map +1 -1
- package/lib/models/billing/billing-line-item.js.map +1 -1
- package/lib/models/documents/document-type.js.map +1 -1
- package/lib/models/documents/document.js.map +1 -1
- package/lib/models/labels/document-formats.js.map +1 -1
- package/lib/models/pickup/pickup-confirmation.js.map +1 -1
- package/lib/models/rates/rate.js.map +1 -1
- package/lib/models/tracking/update-method.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/lib/spec.d.ts +2 -0
- package/lib/spec.js +6 -0
- package/lib/spec.js.map +1 -0
- package/lib/spec.test.d.ts +1 -0
- package/lib/spec.test.js +12 -0
- package/lib/spec.test.js.map +1 -0
- package/package.json +6 -2
- package/src/app/carrier-app-definition.ts +5 -15
- package/src/app/carrier-app.ts +11 -55
- 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/billing/billing-categories.ts +1 -3
- package/src/models/billing/billing-line-item.ts +1 -4
- package/src/models/documents/document-type.ts +1 -3
- package/src/models/documents/document.ts +1 -4
- package/src/models/labels/document-formats.ts +1 -3
- package/src/models/pickup/pickup-confirmation.ts +1 -4
- package/src/models/rates/rate.ts +1 -4
- package/src/models/tracking/update-method.ts +1 -3
- package/src/responses/normalize-tracking-data-response.ts +1 -6
- package/src/responses/validate-inbound-data-response.ts +1 -4
- package/src/spec.test.ts +10 -0
- package/src/spec.ts +2 -0
- 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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CarrierAppDefinition } from '.';
|
|
2
2
|
import { ConnectRuntimeApp, Method, Route, BrandedImages } from './internal';
|
|
3
3
|
import { ApiEndpoints } from './constants';
|
|
4
|
-
import {
|
|
5
|
-
import { readFileSync, existsSync } from 'fs';
|
|
4
|
+
import { OpenApiSpecification } from '../spec';
|
|
6
5
|
|
|
7
6
|
import { Metadata } from './internal/metadata';
|
|
8
7
|
import { CarrierSpecification } from './internal/carrier-specification';
|
|
@@ -44,15 +43,11 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
44
43
|
c.DefaultSupportedCountries?.flatMap((sc) => sc.FromCountry),
|
|
45
44
|
);
|
|
46
45
|
const serviceCountries = definition.Metadata.Carriers.flatMap((c) =>
|
|
47
|
-
c.ShippingServices?.flatMap((s) => s.SupportedCountries).flatMap(
|
|
48
|
-
(sc) => sc?.FromCountry,
|
|
49
|
-
),
|
|
46
|
+
c.ShippingServices?.flatMap((s) => s.SupportedCountries).flatMap((sc) => sc?.FromCountry),
|
|
50
47
|
);
|
|
51
48
|
countries.push(...rootCountries);
|
|
52
49
|
countries.push(...serviceCountries);
|
|
53
|
-
const uniqueCountries = [...new Set(countries)].filter(
|
|
54
|
-
(c) => c !== undefined,
|
|
55
|
-
) as string[];
|
|
50
|
+
const uniqueCountries = [...new Set(countries)].filter((c) => c !== undefined) as string[];
|
|
56
51
|
return uniqueCountries;
|
|
57
52
|
};
|
|
58
53
|
this.validate = () => {
|
|
@@ -71,18 +66,8 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
71
66
|
definition.CancelNotification,
|
|
72
67
|
CancelNotificationResponseSchema,
|
|
73
68
|
],
|
|
74
|
-
[
|
|
75
|
-
|
|
76
|
-
ApiEndpoints.CancelPickup,
|
|
77
|
-
definition.CancelPickup,
|
|
78
|
-
CancelPickupResponseSchema,
|
|
79
|
-
],
|
|
80
|
-
[
|
|
81
|
-
Method.POST,
|
|
82
|
-
ApiEndpoints.CreateLabel,
|
|
83
|
-
definition.CreateLabel,
|
|
84
|
-
CreateLabelResponseSchema,
|
|
85
|
-
],
|
|
69
|
+
[Method.POST, ApiEndpoints.CancelPickup, definition.CancelPickup, CancelPickupResponseSchema],
|
|
70
|
+
[Method.POST, ApiEndpoints.CreateLabel, definition.CreateLabel, CreateLabelResponseSchema],
|
|
86
71
|
[
|
|
87
72
|
Method.POST,
|
|
88
73
|
ApiEndpoints.CreateManifest,
|
|
@@ -95,48 +80,28 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
95
80
|
definition.CreateNotification,
|
|
96
81
|
CreateNotificationResponseSchema,
|
|
97
82
|
],
|
|
98
|
-
[
|
|
99
|
-
Method.POST,
|
|
100
|
-
ApiEndpoints.GetRates,
|
|
101
|
-
definition.GetRates,
|
|
102
|
-
GetRatesResponseSchema,
|
|
103
|
-
],
|
|
83
|
+
[Method.POST, ApiEndpoints.GetRates, definition.GetRates, GetRatesResponseSchema],
|
|
104
84
|
[
|
|
105
85
|
Method.POST,
|
|
106
86
|
ApiEndpoints.NormalizeTrackingData,
|
|
107
87
|
definition.NormalizeTrackingData,
|
|
108
88
|
NormalizeTrackingDataResponseSchema,
|
|
109
89
|
],
|
|
110
|
-
[
|
|
111
|
-
Method.POST,
|
|
112
|
-
ApiEndpoints.Register,
|
|
113
|
-
definition.Register,
|
|
114
|
-
RegisterResponseSchema,
|
|
115
|
-
],
|
|
90
|
+
[Method.POST, ApiEndpoints.Register, definition.Register, RegisterResponseSchema],
|
|
116
91
|
[
|
|
117
92
|
Method.POST,
|
|
118
93
|
ApiEndpoints.SchedulePickup,
|
|
119
94
|
definition.SchedulePickup,
|
|
120
95
|
SchedulePickupResponseSchema,
|
|
121
96
|
],
|
|
122
|
-
[
|
|
123
|
-
Method.POST,
|
|
124
|
-
ApiEndpoints.Track,
|
|
125
|
-
definition.Track,
|
|
126
|
-
TrackingResponseSchema,
|
|
127
|
-
],
|
|
97
|
+
[Method.POST, ApiEndpoints.Track, definition.Track, TrackingResponseSchema],
|
|
128
98
|
[
|
|
129
99
|
Method.POST,
|
|
130
100
|
ApiEndpoints.ValidateInboundData,
|
|
131
101
|
definition.ValidateInboundData,
|
|
132
102
|
ValidateInboundDataResponseSchema,
|
|
133
103
|
],
|
|
134
|
-
[
|
|
135
|
-
Method.POST,
|
|
136
|
-
ApiEndpoints.VoidLabels,
|
|
137
|
-
definition.VoidLabels,
|
|
138
|
-
VoidLabelsResponseSchema,
|
|
139
|
-
],
|
|
104
|
+
[Method.POST, ApiEndpoints.VoidLabels, definition.VoidLabels, VoidLabelsResponseSchema],
|
|
140
105
|
).forEach(([method, path, implementation, schema]) => {
|
|
141
106
|
if (implementation) {
|
|
142
107
|
this.routes.push({
|
|
@@ -147,23 +112,14 @@ export class CarrierApp implements ConnectRuntimeApp {
|
|
|
147
112
|
const validationResults = schema.validate(result, {
|
|
148
113
|
abortEarly: false,
|
|
149
114
|
});
|
|
150
|
-
const errors = validationResults?.error?.details?.map(
|
|
151
|
-
(detail) => detail.message,
|
|
152
|
-
);
|
|
115
|
+
const errors = validationResults?.error?.details?.map((detail) => detail.message);
|
|
153
116
|
return errors;
|
|
154
117
|
},
|
|
155
118
|
});
|
|
156
119
|
}
|
|
157
120
|
});
|
|
158
121
|
this.data = new Metadata(definition);
|
|
159
|
-
|
|
160
|
-
const jsonSpecPath = resolve(__dirname, '../../spec.json');
|
|
161
|
-
const yamlSpecPath = resolve(__dirname, '../../spec.yaml');
|
|
162
|
-
if (existsSync(jsonSpecPath)) {
|
|
163
|
-
this.redoc = readFileSync(jsonSpecPath).toString();
|
|
164
|
-
} else if (existsSync(yamlSpecPath)) {
|
|
165
|
-
this.redoc = readFileSync(yamlSpecPath).toString();
|
|
166
|
-
}
|
|
122
|
+
this.redoc = JSON.stringify(OpenApiSpecification);
|
|
167
123
|
}
|
|
168
124
|
getImages(): BrandedImages[] {
|
|
169
125
|
const mapBrandedImages = (carrier: CarrierSpecification): BrandedImages => {
|
|
@@ -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,8 +1,5 @@
|
|
|
1
1
|
import { DocumentType, DocumentTypeSchema } from './document-type';
|
|
2
|
-
import {
|
|
3
|
-
DocumentFormat,
|
|
4
|
-
DocumentFormatSchema,
|
|
5
|
-
} from '../labels/document-formats';
|
|
2
|
+
import { DocumentFormat, DocumentFormatSchema } from '../labels/document-formats';
|
|
6
3
|
import Joi from 'joi';
|
|
7
4
|
|
|
8
5
|
/** @description Basic structure for a document */
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
2
|
import { Identifier, IdentifierSchema } from '../identifier';
|
|
3
|
-
import {
|
|
4
|
-
ShipmentIdentifier,
|
|
5
|
-
ShipmentIdentifierSchema,
|
|
6
|
-
} from './shipment-identifier';
|
|
3
|
+
import { ShipmentIdentifier, ShipmentIdentifierSchema } from './shipment-identifier';
|
|
7
4
|
|
|
8
5
|
/** @description Basic structure for a pickup confirmation */
|
|
9
6
|
export class PickupConfirmation {
|
package/src/models/rates/rate.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
|
-
import {
|
|
3
|
-
BillingLineItem,
|
|
4
|
-
BillingLineItemSchema,
|
|
5
|
-
} from '../billing/billing-line-item';
|
|
2
|
+
import { BillingLineItem, BillingLineItemSchema } from '../billing/billing-line-item';
|
|
6
3
|
import { TimeWindow, TimeWindowSchema } from '../time-window';
|
|
7
4
|
|
|
8
5
|
/** @description Basic structure for a rate */
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { BaseResponse, BaseResponseSchema } from './base-response';
|
|
2
|
-
import {
|
|
3
|
-
UpdateMethods,
|
|
4
|
-
TrackingInfo,
|
|
5
|
-
TrackingInfoSchema,
|
|
6
|
-
UpdateMethodsSchema,
|
|
7
|
-
} from '../models';
|
|
2
|
+
import { UpdateMethods, TrackingInfo, TrackingInfoSchema, UpdateMethodsSchema } from '../models';
|
|
8
3
|
import Joi from 'joi';
|
|
9
4
|
|
|
10
5
|
/** @description Basic structure for a response to normalize inbound tracking data */
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { BaseResponse, BaseResponseSchema } from './base-response';
|
|
2
|
-
import {
|
|
3
|
-
InboundDataContentTypes,
|
|
4
|
-
InboundDataContentTypesSchema,
|
|
5
|
-
} from '../models';
|
|
2
|
+
import { InboundDataContentTypes, InboundDataContentTypesSchema } from '../models';
|
|
6
3
|
import Joi from 'joi';
|
|
7
4
|
|
|
8
5
|
/** @description Basic structure for a response to validate inbound data */
|
package/src/spec.test.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OpenApiSpecification } from './spec';
|
|
2
|
+
describe('when importing the open api specification', () => {
|
|
3
|
+
it('it should load', () => {
|
|
4
|
+
expect(OpenApiSpecification).toBeDefined();
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
it('it should have the shape of an openapi document', () => {
|
|
8
|
+
expect(OpenApiSpecification.openapi).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
});
|
package/src/spec.ts
ADDED