@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.
Files changed (222) hide show
  1. package/lib/app/carrier-app.js +6 -39
  2. package/lib/app/carrier-app.js.map +1 -1
  3. package/lib/app/internal/carrier-specification.js +14 -1
  4. package/lib/app/internal/carrier-specification.js.map +1 -1
  5. package/lib/app/internal/metadata.js.map +1 -1
  6. package/lib/app/metadata/account-modals.d.ts +8 -2
  7. package/lib/app/metadata/account-modals.js.map +1 -1
  8. package/lib/app/metadata/carrier-app-metadata.js.map +1 -1
  9. package/lib/app/metadata/carrier.d.ts +1 -0
  10. package/lib/app/metadata/carrier.js +6 -12
  11. package/lib/app/metadata/carrier.js.map +1 -1
  12. package/lib/app/metadata/label-formats.js.map +1 -1
  13. package/lib/app/metadata/label-sizes.js.map +1 -1
  14. package/lib/app/metadata/monoauth.js.map +1 -1
  15. package/lib/app/metadata/package-type.d.ts +1 -0
  16. package/lib/app/metadata/package-type.js +3 -0
  17. package/lib/app/metadata/package-type.js.map +1 -1
  18. package/lib/app/metadata/service-class.js.map +1 -1
  19. package/lib/app/metadata/service-grade.js.map +1 -1
  20. package/lib/app/metadata/shipping-service.d.ts +1 -0
  21. package/lib/app/metadata/shipping-service.js +7 -16
  22. package/lib/app/metadata/shipping-service.js.map +1 -1
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -0
  25. package/lib/index.js.map +1 -1
  26. package/lib/models/addresses/address-base.d.ts +13 -13
  27. package/lib/models/addresses/address-base.js.map +1 -1
  28. package/lib/models/addresses/address-residential-indicator.d.ts +3 -0
  29. package/lib/models/addresses/address-residential-indicator.js +3 -0
  30. package/lib/models/addresses/address-residential-indicator.js.map +1 -1
  31. package/lib/models/addresses/ship-from-display.d.ts +1 -0
  32. package/lib/models/addresses/ship-from-display.js +1 -0
  33. package/lib/models/addresses/ship-from-display.js.map +1 -1
  34. package/lib/models/addresses/ship-from.d.ts +1 -0
  35. package/lib/models/addresses/ship-from.js +1 -0
  36. package/lib/models/addresses/ship-from.js.map +1 -1
  37. package/lib/models/addresses/ship-to.d.ts +1 -0
  38. package/lib/models/addresses/ship-to.js +1 -0
  39. package/lib/models/addresses/ship-to.js.map +1 -1
  40. package/lib/models/advanced-options.d.ts +1 -1
  41. package/lib/models/authorization.d.ts +2 -0
  42. package/lib/models/authorization.js.map +1 -1
  43. package/lib/models/billing/billing-categories.d.ts +1 -1
  44. package/lib/models/billing/billing-categories.js +1 -1
  45. package/lib/models/billing/billing-categories.js.map +1 -1
  46. package/lib/models/billing/billing-line-item.d.ts +5 -0
  47. package/lib/models/billing/billing-line-item.js +2 -2
  48. package/lib/models/billing/billing-line-item.js.map +1 -1
  49. package/lib/models/confirmation-types.d.ts +5 -5
  50. package/lib/models/confirmation-types.js +5 -5
  51. package/lib/models/confirmation-types.js.map +1 -1
  52. package/lib/models/currency.d.ts +2 -0
  53. package/lib/models/currency.js.map +1 -1
  54. package/lib/models/customs/customs-content-types.d.ts +5 -1
  55. package/lib/models/customs/customs-content-types.js +5 -1
  56. package/lib/models/customs/customs-content-types.js.map +1 -1
  57. package/lib/models/customs/customs-item.d.ts +9 -1
  58. package/lib/models/customs/customs-item.js +1 -1
  59. package/lib/models/customs/customs-item.js.map +1 -1
  60. package/lib/models/customs/customs-non-delivery.d.ts +2 -0
  61. package/lib/models/customs/customs-non-delivery.js +2 -0
  62. package/lib/models/customs/customs-non-delivery.js.map +1 -1
  63. package/lib/models/customs/customs.d.ts +6 -1
  64. package/lib/models/customs/customs.js +1 -1
  65. package/lib/models/customs/customs.js.map +1 -1
  66. package/lib/models/documents/document-type.d.ts +4 -0
  67. package/lib/models/documents/document-type.js +4 -0
  68. package/lib/models/documents/document-type.js.map +1 -1
  69. package/lib/models/documents/document.d.ts +3 -0
  70. package/lib/models/documents/document.js.map +1 -1
  71. package/lib/models/errors/detailed-error.d.ts +1 -1
  72. package/lib/models/errors/detailed-error.js +1 -1
  73. package/lib/models/errors/detailed-error.js.map +1 -1
  74. package/lib/models/errors/standardized-error-code.d.ts +1 -1
  75. package/lib/models/errors/standardized-error-code.js +1 -1
  76. package/lib/models/errors/standardized-error-code.js.map +1 -1
  77. package/lib/models/fulfillment-plans/fulfillment-plan-details.d.ts +4 -1
  78. package/lib/models/fulfillment-plans/fulfillment-plan-details.js +1 -1
  79. package/lib/models/fulfillment-plans/fulfillment-plan-details.js.map +1 -1
  80. package/lib/models/fulfillment-plans/fulfillment-plan-items.d.ts +4 -4
  81. package/lib/models/fulfillment-plans/raw-external-source.d.ts +2 -0
  82. package/lib/models/fulfillment-plans/raw-external-source.js +1 -0
  83. package/lib/models/fulfillment-plans/raw-external-source.js.map +1 -1
  84. package/lib/models/labels/document-formats.js.map +1 -1
  85. package/lib/models/labels/form-download.d.ts +2 -0
  86. package/lib/models/labels/form-download.js +1 -0
  87. package/lib/models/labels/form-download.js.map +1 -1
  88. package/lib/models/labels/label-download.d.ts +2 -0
  89. package/lib/models/labels/label-download.js +1 -0
  90. package/lib/models/labels/label-download.js.map +1 -1
  91. package/lib/models/labels/label-package.d.ts +2 -0
  92. package/lib/models/labels/label-package.js.map +1 -1
  93. package/lib/models/labels/return-label-details.d.ts +1 -0
  94. package/lib/models/labels/return-label-details.js.map +1 -1
  95. package/lib/models/labels/void-request.d.ts +2 -0
  96. package/lib/models/labels/void-request.js.map +1 -1
  97. package/lib/models/labels/void-response.d.ts +1 -1
  98. package/lib/models/manifests/label.d.ts +2 -0
  99. package/lib/models/manifests/label.js.map +1 -1
  100. package/lib/models/manifests/manifest.d.ts +5 -1
  101. package/lib/models/manifests/manifest.js +1 -1
  102. package/lib/models/manifests/manifest.js.map +1 -1
  103. package/lib/models/package.d.ts +6 -0
  104. package/lib/models/package.js.map +1 -1
  105. package/lib/models/pickup/cancellation-details.d.ts +1 -0
  106. package/lib/models/pickup/cancellation-details.js.map +1 -1
  107. package/lib/models/pickup/pickup-confirmation.d.ts +3 -0
  108. package/lib/models/pickup/pickup-confirmation.js.map +1 -1
  109. package/lib/models/pickup/pickup-contact-details.d.ts +6 -1
  110. package/lib/models/pickup/pickup-contact-details.js +1 -1
  111. package/lib/models/pickup/pickup-contact-details.js.map +1 -1
  112. package/lib/models/pickup/pickup-location-details.d.ts +1 -0
  113. package/lib/models/pickup/pickup-location-details.js.map +1 -1
  114. package/lib/models/pickup/pickup-package.d.ts +7 -0
  115. package/lib/models/pickup/pickup-package.js.map +1 -1
  116. package/lib/models/pickup/pickup-shipment-details.d.ts +1 -0
  117. package/lib/models/pickup/pickup-shipment-details.js.map +1 -1
  118. package/lib/models/pickup/pickup-window.d.ts +5 -1
  119. package/lib/models/pickup/pickup-window.js +1 -1
  120. package/lib/models/pickup/pickup-window.js.map +1 -1
  121. package/lib/models/pickup/shipment-identifier.d.ts +2 -0
  122. package/lib/models/pickup/shipment-identifier.js.map +1 -1
  123. package/lib/models/pickup/shipped-package.d.ts +7 -0
  124. package/lib/models/pickup/shipped-package.js.map +1 -1
  125. package/lib/models/pickup/shipped-shipment.d.ts +6 -0
  126. package/lib/models/pickup/shipped-shipment.js.map +1 -1
  127. package/lib/models/rates/rate.d.ts +2 -4
  128. package/lib/models/rates/rate.js.map +1 -1
  129. package/lib/models/registration/credentials.d.ts +2 -0
  130. package/lib/models/registration/credentials.js.map +1 -1
  131. package/lib/models/resource-download.d.ts +2 -0
  132. package/lib/models/resource-download.js.map +1 -1
  133. package/lib/models/taxes/tax-identifier.d.ts +1 -1
  134. package/lib/models/taxes/tax-identifier.js +1 -1
  135. package/lib/models/taxes/tax-identifier.js.map +1 -1
  136. package/lib/models/tracking/lat-long.d.ts +2 -2
  137. package/lib/models/tracking/service.d.ts +2 -0
  138. package/lib/models/tracking/service.js.map +1 -1
  139. package/lib/models/tracking/track-event.d.ts +9 -0
  140. package/lib/models/tracking/track-event.js.map +1 -1
  141. package/lib/models/tracking/tracking-info.d.ts +18 -0
  142. package/lib/models/tracking/tracking-info.js.map +1 -1
  143. package/lib/models/tracking/update-method.js.map +1 -1
  144. package/lib/models/units/dimension-details.d.ts +4 -0
  145. package/lib/models/units/dimension-details.js.map +1 -1
  146. package/lib/models/units/weight-details.d.ts +4 -0
  147. package/lib/models/units/weight-details.js.map +1 -1
  148. package/lib/responses/normalize-tracking-data-response.js.map +1 -1
  149. package/lib/responses/validate-inbound-data-response.js.map +1 -1
  150. package/package.json +1 -1
  151. package/spec.json +355 -176
  152. package/src/app/carrier-app-definition.ts +5 -15
  153. package/src/app/carrier-app.ts +9 -45
  154. package/src/app/internal/carrier-specification.ts +20 -7
  155. package/src/app/internal/metadata.ts +1 -3
  156. package/src/app/metadata/account-modals.ts +8 -2
  157. package/src/app/metadata/carrier-app-metadata.ts +1 -6
  158. package/src/app/metadata/carrier.ts +11 -28
  159. package/src/app/metadata/label-formats.ts +1 -3
  160. package/src/app/metadata/label-sizes.ts +1 -3
  161. package/src/app/metadata/monoauth.ts +1 -4
  162. package/src/app/metadata/package-type.ts +4 -0
  163. package/src/app/metadata/service-class.ts +1 -3
  164. package/src/app/metadata/service-grade.ts +1 -3
  165. package/src/app/metadata/shipping-service.ts +10 -24
  166. package/src/index.ts +1 -0
  167. package/src/models/addresses/address-base.ts +13 -14
  168. package/src/models/addresses/address-residential-indicator.ts +3 -0
  169. package/src/models/addresses/ship-from-display.ts +1 -0
  170. package/src/models/addresses/ship-from.ts +1 -0
  171. package/src/models/addresses/ship-to.ts +1 -0
  172. package/src/models/advanced-options.ts +1 -1
  173. package/src/models/authorization.ts +2 -0
  174. package/src/models/billing/billing-categories.ts +2 -4
  175. package/src/models/billing/billing-line-item.ts +8 -6
  176. package/src/models/confirmation-types.ts +5 -5
  177. package/src/models/currency.ts +2 -0
  178. package/src/models/customs/customs-content-types.ts +5 -1
  179. package/src/models/customs/customs-item.ts +9 -1
  180. package/src/models/customs/customs-non-delivery.ts +2 -0
  181. package/src/models/customs/customs.ts +6 -1
  182. package/src/models/documents/document-type.ts +5 -3
  183. package/src/models/documents/document.ts +4 -4
  184. package/src/models/errors/detailed-error.ts +1 -1
  185. package/src/models/errors/standardized-error-code.ts +1 -1
  186. package/src/models/fulfillment-plans/fulfillment-plan-details.ts +4 -1
  187. package/src/models/fulfillment-plans/fulfillment-plan-items.ts +4 -4
  188. package/src/models/fulfillment-plans/raw-external-source.ts +2 -0
  189. package/src/models/labels/document-formats.ts +1 -3
  190. package/src/models/labels/form-download.ts +2 -0
  191. package/src/models/labels/label-download.ts +2 -0
  192. package/src/models/labels/label-package.ts +2 -0
  193. package/src/models/labels/return-label-details.ts +1 -0
  194. package/src/models/labels/void-request.ts +2 -0
  195. package/src/models/labels/void-response.ts +1 -1
  196. package/src/models/manifests/label.ts +2 -0
  197. package/src/models/manifests/manifest.ts +5 -1
  198. package/src/models/package.ts +6 -0
  199. package/src/models/pickup/cancellation-details.ts +1 -0
  200. package/src/models/pickup/pickup-confirmation.ts +4 -4
  201. package/src/models/pickup/pickup-contact-details.ts +6 -1
  202. package/src/models/pickup/pickup-location-details.ts +1 -0
  203. package/src/models/pickup/pickup-package.ts +7 -0
  204. package/src/models/pickup/pickup-shipment-details.ts +1 -0
  205. package/src/models/pickup/pickup-window.ts +5 -1
  206. package/src/models/pickup/shipment-identifier.ts +2 -0
  207. package/src/models/pickup/shipped-package.ts +7 -0
  208. package/src/models/pickup/shipped-shipment.ts +6 -0
  209. package/src/models/rates/rate.ts +3 -8
  210. package/src/models/registration/credentials.ts +2 -0
  211. package/src/models/resource-download.ts +2 -0
  212. package/src/models/taxes/tax-identifier.ts +1 -1
  213. package/src/models/tracking/lat-long.ts +2 -2
  214. package/src/models/tracking/service.ts +2 -0
  215. package/src/models/tracking/track-event.ts +9 -0
  216. package/src/models/tracking/tracking-info.ts +18 -0
  217. package/src/models/tracking/update-method.ts +1 -3
  218. package/src/models/units/dimension-details.ts +4 -0
  219. package/src/models/units/weight-details.ts +4 -0
  220. package/src/responses/normalize-tracking-data-response.ts +1 -6
  221. package/src/responses/validate-inbound-data-response.ts +1 -4
  222. 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
@@ -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
- Method.POST,
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
- formSchema: {
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
- formSchema: {
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
- ShippingOptionDictionary,
6
- ShippingOptionDictionarySchema,
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(),
@@ -6,6 +6,4 @@ export enum LabelFormatsEnum {
6
6
  PNG = 'PNG',
7
7
  }
8
8
 
9
- export const LabelFormatsEnumSchema = Joi.string().valid(
10
- ...Object.values(LabelFormatsEnum),
11
- );
9
+ export const LabelFormatsEnumSchema = Joi.string().valid(...Object.values(LabelFormatsEnum));
@@ -5,6 +5,4 @@ export enum LabelSizesEnum {
5
5
  Inches4x8 = 'Inches4x8',
6
6
  }
7
7
 
8
- export const LabelSizesEnumSchema = Joi.string().valid(
9
- ...Object.values(LabelSizesEnum),
10
- );
8
+ export const LabelSizesEnumSchema = Joi.string().valid(...Object.values(LabelSizesEnum));
@@ -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));
@@ -9,6 +9,4 @@ export enum ServiceGradeEnum {
9
9
  Standard = 'Standard',
10
10
  }
11
11
 
12
- export const ServiceGradeEnumSchema = Joi.string().valid(
13
- ...Object.values(ServiceGradeEnum),
14
- );
12
+ export const ServiceGradeEnumSchema = Joi.string().valid(...Object.values(ServiceGradeEnum));
@@ -1,12 +1,6 @@
1
1
  import { ConfirmationType, ConfirmationTypeSchema } from './confirmation-type';
2
- import {
3
- CountryAssociation,
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
- .optional()
44
- .items(CountryAssociationSchema)
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
@@ -5,3 +5,4 @@ export * as responses from './responses';
5
5
  export * from './requests';
6
6
  export * from './responses';
7
7
  export * from './app';
8
+ export * from './models';
@@ -1,35 +1,34 @@
1
1
  import { AddressResidentialIndicator } from './address-residential-indicator';
2
2
 
3
3
  export class AddressBase {
4
- /** @description Name of the contact */
4
+ /** @description The full name of the contact contact associated with the address */
5
5
  name?: string;
6
- /** @description First or given name of the contact */
6
+ /** @description The first name of the contact associated with the address */
7
7
  first_name?: string;
8
- /** @description Last or family name of the contact */
8
+ /** @description The last name of the contact associated with the address */
9
9
  last_name?: string;
10
- /** @description Email of the contact */
10
+ /** @description The email of the contact associated with the address */
11
11
  email?: string;
12
- /** @description Phone number of the contact. Cannot include newline chars. */
13
-
12
+ /** @description The phone number of the contact associated with the address (No Newline Characters) */
14
13
  phone_number?: string;
15
- /** @description Company name, if applicable. Cannot include newline chars. */
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 Address fields separated by line. Up to 100 chars per line. Cannot include newline chars. */
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. Cannot contain newline chars. */
18
+ /** @description City or locality (No Newline Characters) */
20
19
  city_locality?: string;
21
- /** @description State or province. Cannot contain newline chars. */
20
+ /** @description State or province (No Newline Characters) */
22
21
  state_province?: string;
23
- /** @description Zip or postal code. Cannot include newline chars. */
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 Metadata for this address */
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,3 +1,4 @@
1
1
  import { AddressBase } from './address-base';
2
2
 
3
+ /** @description The address that should be displayed on the label as the ship from location */
3
4
  export class ShipFromDisplay extends AddressBase {}
@@ -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;
@@ -1,4 +1,6 @@
1
1
  export class Authorization {
2
+ /** @description The access token used to authorize the request */
2
3
  access_token?: string;
4
+ /** @description Optional - any additional information required to authorize the request */
3
5
  connection_context?: any;
4
6
  }
@@ -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
  }
@@ -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