@shipengine/connect-carrier-api 2.3.0 → 2.3.5
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-definition.d.ts +6 -1
- package/lib/app/carrier-app.js +9 -50
- package/lib/app/carrier-app.js.map +1 -1
- package/lib/app/constants.d.ts +1 -0
- package/lib/app/constants.js +1 -0
- package/lib/app/constants.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 +3 -0
- 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.js +3 -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/service-class.js.map +1 -1
- package/lib/app/metadata/service-grade.js.map +1 -1
- package/lib/app/metadata/shipping-service.js +4 -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/manifest-status.d.ts +10 -0
- package/lib/models/manifest-status.js +16 -0
- package/lib/models/manifest-status.js.map +1 -0
- 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/requests/get-manifest-request.d.ts +9 -0
- package/lib/requests/get-manifest-request.js +9 -0
- package/lib/requests/get-manifest-request.js.map +1 -0
- package/lib/requests/index.d.ts +1 -0
- package/lib/requests/index.js +1 -0
- package/lib/requests/index.js.map +1 -1
- package/lib/responses/create-manifest-response.d.ts +6 -0
- package/lib/responses/create-manifest-response.js +6 -0
- package/lib/responses/create-manifest-response.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/spec.json +107 -0
- package/src/app/carrier-app-definition.ts +13 -15
- package/src/app/carrier-app.ts +12 -55
- package/src/app/constants.ts +1 -0
- package/src/app/internal/carrier-specification.ts +20 -7
- package/src/app/internal/metadata.ts +5 -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 +7 -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/service-class.ts +1 -3
- package/src/app/metadata/service-grade.ts +1 -3
- package/src/app/metadata/shipping-service.ts +6 -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/manifest-status.ts +11 -0
- 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/requests/get-manifest-request.ts +13 -0
- package/src/requests/index.ts +1 -0
- package/src/responses/create-manifest-response.ts +11 -0
- 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
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const base_response_1 = require("./base-response");
|
|
6
6
|
const models_1 = require("../models");
|
|
7
7
|
const joi_1 = tslib_1.__importDefault(require("joi"));
|
|
8
|
+
const manifest_status_1 = require("../models/manifest-status");
|
|
8
9
|
/** @description Basic structure for a response to create a manifest */
|
|
9
10
|
class CreateManifestResponse extends base_response_1.BaseResponse {
|
|
10
11
|
}
|
|
@@ -12,5 +13,10 @@ exports.CreateManifestResponse = CreateManifestResponse;
|
|
|
12
13
|
exports.CreateManifestResponseSchema = base_response_1.BaseResponseSchema.keys({
|
|
13
14
|
transaction_id: joi_1.default.string().required(),
|
|
14
15
|
manifests: joi_1.default.array().optional().items(models_1.ManifestSchema),
|
|
16
|
+
manifest_request_id: joi_1.default.number().optional(),
|
|
17
|
+
manifest_status: manifest_status_1.ManifestStatusSchema.optional,
|
|
18
|
+
total_shipments: joi_1.default.number().optional(),
|
|
19
|
+
total_invalid: joi_1.default.number().optional(),
|
|
20
|
+
manifest_identifiers: joi_1.default.any().optional(),
|
|
15
21
|
});
|
|
16
22
|
//# sourceMappingURL=create-manifest-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-manifest-response.js","sourceRoot":"","sources":["../../src/responses/create-manifest-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,sCAAqD;AACrD,sDAAsB;
|
|
1
|
+
{"version":3,"file":"create-manifest-response.js","sourceRoot":"","sources":["../../src/responses/create-manifest-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,sCAAqD;AACrD,sDAAsB;AACtB,+DAAiF;AAEjF,uEAAuE;AACvE,MAAa,sBAAuB,SAAQ,4BAAY;CAQvD;AARD,wDAQC;AAEY,QAAA,4BAA4B,GAAG,kCAAkB,CAAC,IAAI,CAAC;IAClE,cAAc,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACvC,SAAS,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,uBAAc,CAAC;IACvD,mBAAmB,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5C,eAAe,EAAE,sCAAoB,CAAC,QAAQ;IAC9C,eAAe,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,aAAa,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACtC,oBAAoB,EAAE,aAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-tracking-data-response.js","sourceRoot":"","sources":["../../src/responses/normalize-tracking-data-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"normalize-tracking-data-response.js","sourceRoot":"","sources":["../../src/responses/normalize-tracking-data-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,sCAAiG;AACjG,sDAAsB;AAEtB,qFAAqF;AACrF,MAAa,6BAA8B,SAAQ,4BAAY;CAQ9D;AARD,sEAQC;AAEY,QAAA,mCAAmC,GAAG,kCAAkB,CAAC,IAAI,CAAC;IACzE,aAAa,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,2BAAkB,CAAC;IAC/D,aAAa,EAAE,4BAAmB;CACnC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-inbound-data-response.js","sourceRoot":"","sources":["../../src/responses/validate-inbound-data-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"validate-inbound-data-response.js","sourceRoot":"","sources":["../../src/responses/validate-inbound-data-response.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,sCAAmF;AACnF,sDAAsB;AAEtB,2EAA2E;AAC3E,MAAa,2BAA4B,SAAQ,4BAAY;CAG5D;AAHD,kEAGC;AAEY,QAAA,iCAAiC,GAAG,kCAAkB,CAAC,IAAI,CAAC;IACvE,aAAa,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,sCAA6B,CAAC;CAC3E,CAAC,CAAC"}
|
package/lib/spec.d.ts
ADDED
package/lib/spec.js
ADDED
package/lib/spec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,oDAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/spec.test.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const spec_1 = require("./spec");
|
|
4
|
+
describe('when importing the open api specification', () => {
|
|
5
|
+
it('it should load', () => {
|
|
6
|
+
expect(spec_1.OpenApiSpecification).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
it('it should have the shape of an openapi document', () => {
|
|
9
|
+
expect(spec_1.OpenApiSpecification.openapi).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=spec.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.test.js","sourceRoot":"","sources":["../src/spec.test.ts"],"names":[],"mappings":";;AAAA,iCAA8C;AAC9C,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,2BAAoB,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,2BAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipengine/connect-carrier-api",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"description": "This is the typescript/javascript definitions for carrier api",
|
|
5
5
|
"homepage": "https://github.com/ShipEngine/connect",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"format": "prettier --single-quote --trailing-comma=all --write \"src/**/*.ts\"",
|
|
13
13
|
"lint": "prettier --single-quote --trailing-comma=all --check \"src/**/*.ts\"",
|
|
14
14
|
"release": "yarn version:release",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "jest",
|
|
16
16
|
"watch": "yarn build:watch"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@types/jest": "^27.0.3",
|
|
35
|
+
"@types/sanitize-html": "^2.6.2",
|
|
36
|
+
"jest": "^27.4.5",
|
|
34
37
|
"prettier": "^2.4.0",
|
|
38
|
+
"ts-jest": "^27.1.2",
|
|
35
39
|
"typescript": "^4.3.5"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
package/spec.json
CHANGED
|
@@ -362,6 +362,89 @@
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
},
|
|
365
|
+
"/GetManifest": {
|
|
366
|
+
"post": {
|
|
367
|
+
"tags": ["Manifesting"],
|
|
368
|
+
"description": "This method retrieves an end-of-day manifest and should be implemented by carrier apps that support retrieving end-of-day manifesting following create.",
|
|
369
|
+
"operationId": "Get Manifest",
|
|
370
|
+
"parameters": [
|
|
371
|
+
{
|
|
372
|
+
"name": "ShipStation-TransactionID",
|
|
373
|
+
"in": "header",
|
|
374
|
+
"description": "The transaction ID uniquely represents this request.",
|
|
375
|
+
"schema": {
|
|
376
|
+
"type": "string",
|
|
377
|
+
"format": "uuid"
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
"requestBody": {
|
|
382
|
+
"description": "An object containing information required to retrieve a manifest.",
|
|
383
|
+
"content": {
|
|
384
|
+
"application/json": {
|
|
385
|
+
"schema": {
|
|
386
|
+
"$ref": "#/components/schemas/GetManifestRequest"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
"responses": {
|
|
392
|
+
"400": {
|
|
393
|
+
"description": "Can be an internal or external error indicating an issue with the request that must be corrected.",
|
|
394
|
+
"content": {
|
|
395
|
+
"application/json": {
|
|
396
|
+
"schema": {
|
|
397
|
+
"$ref": "#/components/schemas/BadRequestResponse"
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"401": {
|
|
403
|
+
"description": "Use this to indicate an authentication or authorization error.",
|
|
404
|
+
"content": {
|
|
405
|
+
"application/json": {
|
|
406
|
+
"schema": {
|
|
407
|
+
"$ref": "#/components/schemas/UnauthorizedResponse"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
"500": {
|
|
413
|
+
"description": "An unexpected error occurred in the carrier app.",
|
|
414
|
+
"content": {
|
|
415
|
+
"application/json": {
|
|
416
|
+
"schema": {
|
|
417
|
+
"$ref": "#/components/schemas/InternalServerErrorResponse"
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
"520": {
|
|
423
|
+
"description": "Use this when an error is the result of calling an external service, such as an API. This indicates that the error came from a downstream service rather than directly in your app.",
|
|
424
|
+
"content": {
|
|
425
|
+
"application/json": {
|
|
426
|
+
"schema": {
|
|
427
|
+
"$ref": "#/components/schemas/ExternalServerErrorResponse"
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"404": {
|
|
433
|
+
"description": "Use this when the behavior is not supported or the behavior is not available for the user."
|
|
434
|
+
},
|
|
435
|
+
"200": {
|
|
436
|
+
"description": "This object model represents the response from a successful get manifest request. It is the same as the response from create manifest",
|
|
437
|
+
"content": {
|
|
438
|
+
"application/json": {
|
|
439
|
+
"schema": {
|
|
440
|
+
"$ref": "#/components/schemas/CreateManifestResponse"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
},
|
|
365
448
|
"/ValidateInboundData": {
|
|
366
449
|
"post": {
|
|
367
450
|
"tags": ["Normalize Inbound Data"],
|
|
@@ -1900,6 +1983,30 @@
|
|
|
1900
1983
|
"additionalProperties": false,
|
|
1901
1984
|
"description": "This model represents the response from a successful create label request."
|
|
1902
1985
|
},
|
|
1986
|
+
"GetManifestRequest": {
|
|
1987
|
+
"type": "object",
|
|
1988
|
+
"allOf": [
|
|
1989
|
+
{
|
|
1990
|
+
"$ref": "#/components/schemas/BaseRequest"
|
|
1991
|
+
}
|
|
1992
|
+
],
|
|
1993
|
+
"properties": {
|
|
1994
|
+
"manifest_request_id":{
|
|
1995
|
+
"type": "integer"
|
|
1996
|
+
},
|
|
1997
|
+
"manifest_identifiers": {
|
|
1998
|
+
"type": "array",
|
|
1999
|
+
"items": {
|
|
2000
|
+
"$ref": "#/components/schemas/Identifier"
|
|
2001
|
+
}
|
|
2002
|
+
},
|
|
2003
|
+
"return_immediately": {
|
|
2004
|
+
"type": "boolean"
|
|
2005
|
+
}
|
|
2006
|
+
},
|
|
2007
|
+
"additionalProperties": false,
|
|
2008
|
+
"description": "This model represents the request payload needed to retrieve a previously created manifest."
|
|
2009
|
+
},
|
|
1903
2010
|
"CreateManifestRequest": {
|
|
1904
2011
|
"type": "object",
|
|
1905
2012
|
"allOf": [
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CreateLabelRequest,
|
|
4
4
|
VoidLabelsRequest,
|
|
5
5
|
CreateManifestRequest,
|
|
6
|
+
GetManifestRequest,
|
|
6
7
|
SchedulePickupRequest,
|
|
7
8
|
CancelPickupRequest,
|
|
8
9
|
GetRatesRequest,
|
|
@@ -39,23 +40,17 @@ export interface CarrierAppDefinition {
|
|
|
39
40
|
* @description This method is used to register an account
|
|
40
41
|
* @param request The information needed to register or initialize a connection with the shipping provider
|
|
41
42
|
*/
|
|
42
|
-
Register?: (
|
|
43
|
-
request: RegisterRequest,
|
|
44
|
-
) => RegisterResponse | Promise<RegisterResponse>;
|
|
43
|
+
Register?: (request: RegisterRequest) => RegisterResponse | Promise<RegisterResponse>;
|
|
45
44
|
/**
|
|
46
45
|
* @description This method is used to create a label
|
|
47
46
|
* @param request Data needed by the provider to create a label
|
|
48
47
|
*/
|
|
49
|
-
CreateLabel?: (
|
|
50
|
-
request: CreateLabelRequest,
|
|
51
|
-
) => CreateLabelResponse | Promise<CreateLabelResponse>;
|
|
48
|
+
CreateLabel?: (request: CreateLabelRequest) => CreateLabelResponse | Promise<CreateLabelResponse>;
|
|
52
49
|
/**
|
|
53
50
|
* @description This method is used to void multiple labels
|
|
54
51
|
* @param request Data needed by the provider to void multiple labels
|
|
55
52
|
*/
|
|
56
|
-
VoidLabels?: (
|
|
57
|
-
request: VoidLabelsRequest,
|
|
58
|
-
) => VoidLabelsResponse | Promise<VoidLabelsResponse>;
|
|
53
|
+
VoidLabels?: (request: VoidLabelsRequest) => VoidLabelsResponse | Promise<VoidLabelsResponse>;
|
|
59
54
|
/**
|
|
60
55
|
* @description This method is used to create a manifest with a carrier
|
|
61
56
|
* @param request Data needed by the provider to create a manifest
|
|
@@ -63,6 +58,13 @@ export interface CarrierAppDefinition {
|
|
|
63
58
|
CreateManifest?: (
|
|
64
59
|
request: CreateManifestRequest,
|
|
65
60
|
) => CreateManifestResponse | Promise<CreateManifestResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* @description This method is used to retrieve a manifest with a carrier
|
|
63
|
+
* @param request Data needed by the provider to retrieve a previousely created manifest
|
|
64
|
+
*/
|
|
65
|
+
GetManifest?: (
|
|
66
|
+
request: GetManifestRequest,
|
|
67
|
+
) => CreateManifestResponse | Promise<CreateManifestResponse>;
|
|
66
68
|
/**
|
|
67
69
|
* @description This endpoint is used to schedule an adhoc pickup with the shipping provider
|
|
68
70
|
* @param request Data needed by the provider to schedule adhoc pickups
|
|
@@ -81,16 +83,12 @@ export interface CarrierAppDefinition {
|
|
|
81
83
|
* @description This endpoint is used to get rates for a particular shipment
|
|
82
84
|
* @param request Data needed by the provider to get a rate estimate
|
|
83
85
|
*/
|
|
84
|
-
GetRates?: (
|
|
85
|
-
request: GetRatesRequest,
|
|
86
|
-
) => GetRatesResponse | Promise<GetRatesResponse>;
|
|
86
|
+
GetRates?: (request: GetRatesRequest) => GetRatesResponse | Promise<GetRatesResponse>;
|
|
87
87
|
/**
|
|
88
88
|
* @description This endpoint is used to get tracking information about a shipment
|
|
89
89
|
* @param request Data needed by the provider to track a shipment
|
|
90
90
|
*/
|
|
91
|
-
Track?: (
|
|
92
|
-
request: TrackingRequest,
|
|
93
|
-
) => TrackingResponse | Promise<TrackingResponse>;
|
|
91
|
+
Track?: (request: TrackingRequest) => TrackingResponse | Promise<TrackingResponse>;
|
|
94
92
|
/**
|
|
95
93
|
* @description This endpoint is used to submit notification of the creation of a shipment
|
|
96
94
|
* @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,72 +66,43 @@ 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,
|
|
89
74
|
definition.CreateManifest,
|
|
90
75
|
CreateManifestResponseSchema,
|
|
91
76
|
],
|
|
77
|
+
[Method.POST, ApiEndpoints.GetManifest, definition.GetManifest, CreateManifestResponseSchema],
|
|
92
78
|
[
|
|
93
79
|
Method.POST,
|
|
94
80
|
ApiEndpoints.CreateNotification,
|
|
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,23 +113,14 @@ 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
|
});
|
|
156
120
|
}
|
|
157
121
|
});
|
|
158
122
|
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
|
-
}
|
|
123
|
+
this.redoc = JSON.stringify(OpenApiSpecification);
|
|
167
124
|
}
|
|
168
125
|
getImages(): BrandedImages[] {
|
|
169
126
|
const mapBrandedImages = (carrier: CarrierSpecification): BrandedImages => {
|
package/src/app/constants.ts
CHANGED
|
@@ -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;
|
|
@@ -30,6 +30,10 @@ const mapFunctions = (app: CarrierAppDefinition): FunctionSpecification[] => {
|
|
|
30
30
|
fns.push(fn('CreateManifest'));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
if (app.GetManifest) {
|
|
34
|
+
fns.push(fn('GetManifest'));
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
if (app.SchedulePickup) {
|
|
34
38
|
fns.push(fn('SchedulePickup'));
|
|
35
39
|
}
|
|
@@ -63,9 +67,7 @@ export class Metadata implements CarrierAppSpecification {
|
|
|
63
67
|
if (this.AuthProcess) {
|
|
64
68
|
this.AuthProcess.Identifier.Version = '2.0';
|
|
65
69
|
}
|
|
66
|
-
this.Carriers = app.Metadata.Carriers.map(
|
|
67
|
-
(c) => new CarrierSpecification(c),
|
|
68
|
-
);
|
|
70
|
+
this.Carriers = app.Metadata.Carriers.map((c) => new CarrierSpecification(c));
|
|
69
71
|
|
|
70
72
|
this.Connector = {
|
|
71
73
|
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
|
|
|
@@ -55,25 +43,16 @@ const fileExists = (value: string, helpers: any) => {
|
|
|
55
43
|
export const CarrierSchema = Joi.object({
|
|
56
44
|
AccountModals: AccountModalsSchema.required(),
|
|
57
45
|
PackageTypes: Joi.array().optional().items(PackageTypeSchema).unique('Id'),
|
|
58
|
-
ShippingServices: Joi.array()
|
|
59
|
-
.optional()
|
|
60
|
-
.items(ShippingServiceSchema)
|
|
61
|
-
.unique('Id'),
|
|
46
|
+
ShippingServices: Joi.array().optional().items(ShippingServiceSchema).unique('Id'),
|
|
62
47
|
ShippingOptions: ShippingOptionDictionarySchema.optional(),
|
|
63
48
|
DefaultSupportedCountries: Joi.array()
|
|
64
49
|
.optional()
|
|
65
50
|
.items(CountryAssociationSchema)
|
|
66
51
|
.unique('FromCountry'),
|
|
67
|
-
DefaultLabelSizes: Joi.array()
|
|
68
|
-
.optional()
|
|
69
|
-
.items(LabelSizesEnumSchema)
|
|
70
|
-
.unique(),
|
|
52
|
+
DefaultLabelSizes: Joi.array().optional().items(LabelSizesEnumSchema).unique(),
|
|
71
53
|
LabelFormats: Joi.array().optional().items(LabelFormatsEnumSchema).unique(),
|
|
72
54
|
DefaultConfirmationTypes: ConfirmationDictionarySchema.optional(),
|
|
73
|
-
CarrierAttributes: Joi.array()
|
|
74
|
-
.optional()
|
|
75
|
-
.items(CarrierAttributeEnumSchema)
|
|
76
|
-
.unique(),
|
|
55
|
+
CarrierAttributes: Joi.array().optional().items(CarrierAttributeEnumSchema).unique(),
|
|
77
56
|
TrackingUrl: Joi.string()
|
|
78
57
|
.optional()
|
|
79
58
|
.pattern(
|
|
@@ -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(),
|
|
@@ -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));
|