@shipengine/connect-carrier-api 4.0.0-beta → 4.0.0-beta.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.
Files changed (40) hide show
  1. package/lib/app/carrier-app-definition.d.ts +7 -0
  2. package/lib/models/index.d.ts +1 -0
  3. package/lib/models/index.js +1 -0
  4. package/lib/models/index.js.map +1 -1
  5. package/lib/models/native-rating/context-results.d.ts +3 -0
  6. package/lib/models/native-rating/context-results.js +3 -0
  7. package/lib/models/native-rating/context-results.js.map +1 -0
  8. package/lib/models/native-rating/get-rates.d.ts +7 -0
  9. package/lib/models/native-rating/get-rates.js +3 -0
  10. package/lib/models/native-rating/get-rates.js.map +1 -0
  11. package/lib/models/native-rating/get-variables.d.ts +6 -0
  12. package/lib/models/native-rating/get-variables.js +3 -0
  13. package/lib/models/native-rating/get-variables.js.map +1 -0
  14. package/lib/models/native-rating/get-zone.d.ts +6 -0
  15. package/lib/models/native-rating/get-zone.js +3 -0
  16. package/lib/models/native-rating/get-zone.js.map +1 -0
  17. package/lib/models/native-rating/implementation-type.d.ts +30 -0
  18. package/lib/models/native-rating/implementation-type.js +8 -0
  19. package/lib/models/native-rating/implementation-type.js.map +1 -0
  20. package/lib/models/native-rating/index.d.ts +7 -0
  21. package/lib/models/native-rating/index.js +11 -0
  22. package/lib/models/native-rating/index.js.map +1 -0
  23. package/lib/models/native-rating/numeric-currency.d.ts +5 -0
  24. package/lib/models/native-rating/numeric-currency.js +3 -0
  25. package/lib/models/native-rating/numeric-currency.js.map +1 -0
  26. package/lib/models/native-rating/rating-context.d.ts +15 -0
  27. package/lib/models/native-rating/rating-context.js +3 -0
  28. package/lib/models/native-rating/rating-context.js.map +1 -0
  29. package/package.json +4 -4
  30. package/src/app/carrier-app-definition.ts +10 -0
  31. package/src/models/index.ts +1 -0
  32. package/src/models/native-rating/context-results.ts +3 -0
  33. package/src/models/native-rating/get-rates.ts +9 -0
  34. package/src/models/native-rating/get-variables.ts +8 -0
  35. package/src/models/native-rating/get-zone.ts +9 -0
  36. package/src/models/native-rating/implementation-type.ts +33 -0
  37. package/src/models/native-rating/index.ts +7 -0
  38. package/src/models/native-rating/numeric-currency.ts +5 -0
  39. package/src/models/native-rating/rating-context.ts +19 -0
  40. package/tsconfig.tsbuildinfo +1 -1
@@ -2,6 +2,7 @@ import { ImportedTrackingEvent } from '../models';
2
2
  import { RegisterRequest, CreateLabelRequest, VoidLabelsRequest, CreateManifestRequest, GetManifestRequest, SchedulePickupRequest, CancelPickupRequest, GetRatesRequest, TrackingRequest, CancelNotificationRequest, CreateNotificationRequest, ValidateInboundDataRequest, NormalizeTrackingDataRequest, GetRelayPointsRequest, GetServicePointsRequest, GetServicePointRequest, ImportTrackingEventsRequest } from '../requests';
3
3
  import { RegisterResponse, CreateLabelResponse, VoidLabelsResponse, CreateManifestResponse, SchedulePickupResponse, CancelPickupResponse, GetRatesResponse, TrackingResponse, CancelNotificationResponse, CreateNotificationResponse, ValidateInboundDataResponse, NormalizeTrackingDataResponse, GetRelayPointsResponse, GetServicePointsResponse, GetServicePointResponse } from '../responses';
4
4
  import { CarrierAppMetadata } from './metadata/carrier-app-metadata';
5
+ import { RequestResponseInfo } from '@shipengine/connect-runtime';
5
6
  /**
6
7
  * @description This defines a connect carrier app
7
8
  */
@@ -92,4 +93,10 @@ export interface CarrierAppDefinition {
92
93
  * @param request Data needed by the provider to import tracking events
93
94
  */
94
95
  ImportTrackingEvents?: (request: ImportTrackingEventsRequest) => AsyncGenerator<ImportedTrackingEvent>;
96
+ /** @description A method that gets additional context to log from the request when logging */
97
+ getAdditionalContext?: (req: Request) => Record<string, string>;
98
+ /** @description A method that redacts external HTTP requests and responses to prevent logging sensitive information */
99
+ redactExternalRequest?: (req: RequestResponseInfo) => Promise<RequestResponseInfo> | RequestResponseInfo;
100
+ /** @description A method that gets additional information to return with the diagnostic version route */
101
+ getAdditionalVersionInfo?: () => Promise<Record<string, string>> | Record<string, string>;
95
102
  }
@@ -18,6 +18,7 @@ export * from './inbound-content-types';
18
18
  export * from './insurance-providers';
19
19
  export * from './labels';
20
20
  export * from './manifests';
21
+ export * from './native-rating';
21
22
  export * from './package';
22
23
  export * from './pickup';
23
24
  export * from './rates';
@@ -21,6 +21,7 @@ tslib_1.__exportStar(require("./inbound-content-types"), exports);
21
21
  tslib_1.__exportStar(require("./insurance-providers"), exports);
22
22
  tslib_1.__exportStar(require("./labels"), exports);
23
23
  tslib_1.__exportStar(require("./manifests"), exports);
24
+ tslib_1.__exportStar(require("./native-rating"), exports);
24
25
  tslib_1.__exportStar(require("./package"), exports);
25
26
  tslib_1.__exportStar(require("./pickup"), exports);
26
27
  tslib_1.__exportStar(require("./rates"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,6DAAmC;AACnC,0DAAgC;AAChC,oDAA0B;AAC1B,+DAAqC;AACrC,4DAAkC;AAClC,qDAA2B;AAC3B,oDAA0B;AAC1B,kEAAwC;AACxC,2DAAiC;AACjC,sDAA4B;AAC5B,mDAAyB;AACzB,8DAAoC;AACpC,8DAAoC;AACpC,uDAA6B;AAC7B,yEAA+C;AAC/C,kEAAwC;AACxC,gEAAsC;AACtC,mDAAyB;AACzB,sDAA4B;AAC5B,oDAA0B;AAC1B,mDAAyB;AACzB,kDAAwB;AACxB,yDAA+B;AAC/B,yDAA+B;AAC/B,qEAA2C;AAC3C,8DAAoC;AACpC,kDAAwB;AACxB,+DAAqC;AACrC,wDAA8B;AAC9B,qDAA2B;AAC3B,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,6DAAmC;AACnC,0DAAgC;AAChC,oDAA0B;AAC1B,+DAAqC;AACrC,4DAAkC;AAClC,qDAA2B;AAC3B,oDAA0B;AAC1B,kEAAwC;AACxC,2DAAiC;AACjC,sDAA4B;AAC5B,mDAAyB;AACzB,8DAAoC;AACpC,8DAAoC;AACpC,uDAA6B;AAC7B,yEAA+C;AAC/C,kEAAwC;AACxC,gEAAsC;AACtC,mDAAyB;AACzB,sDAA4B;AAC5B,0DAAgC;AAChC,oDAA0B;AAC1B,mDAAyB;AACzB,kDAAwB;AACxB,yDAA+B;AAC/B,yDAA+B;AAC/B,qEAA2C;AAC3C,8DAAoC;AACpC,kDAAwB;AACxB,+DAAqC;AACrC,wDAA8B;AAC9B,qDAA2B;AAC3B,kDAAwB"}
@@ -0,0 +1,3 @@
1
+ export interface ContextResults<T> {
2
+ [dataKey: string]: T;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=context-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-results.js","sourceRoot":"","sources":["../../../src/models/native-rating/context-results.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { ContextResults } from './context-results';
2
+ import { NumericCurrency } from './numeric-currency';
3
+ export type GetRatesResults = ContextResults<NumericCurrency>;
4
+ /** Function to get rates from the context */
5
+ export interface GetRates {
6
+ (dataKeys: string[]): Promise<GetRatesResults>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=get-rates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-rates.js","sourceRoot":"","sources":["../../../src/models/native-rating/get-rates.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { ContextResults } from './context-results';
2
+ export type GetVariableResults = ContextResults<any>;
3
+ /** Function to get rating variables from the context */
4
+ export interface GetVariables {
5
+ (dataKeys: string[]): Promise<GetVariableResults>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=get-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-variables.js","sourceRoot":"","sources":["../../../src/models/native-rating/get-variables.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { ContextResults } from './context-results';
2
+ export type GetZoneResults = ContextResults<any>;
3
+ /** Function to get zone data from the context */
4
+ export interface GetZone {
5
+ (dataKeys: string[]): Promise<GetZoneResults>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=get-zone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-zone.js","sourceRoot":"","sources":["../../../src/models/native-rating/get-zone.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { GetRatesRequest, Rate } from '@shipengine/connect-carrier-api';
2
+ import type { RatingContext } from './rating-context';
3
+ /** A rate request shipment with its corresponding id */
4
+ export interface ShipmentAndId {
5
+ /** rate_request_identifier for the rate request */
6
+ id: string;
7
+ /** Shipment for the rate request */
8
+ shipment: GetRatesRequest;
9
+ }
10
+ /** Rate results with its corresponding rate request id */
11
+ export interface RateResultsAndId {
12
+ /** rate_request_identifier for the corresponding rate request */
13
+ id: string;
14
+ /** Error, if any */
15
+ error?: unknown;
16
+ /** Rates for a given rate request */
17
+ rates: Rate[];
18
+ }
19
+ /** Implementation of a carrier */
20
+ export interface RatingCarrier {
21
+ /** Rate shipments
22
+ * @param context Native Rating context that can be used by the implementation to interact with the underlying service
23
+ * @param shipment Shipments that should be rated
24
+ * @returns List of rates for the given shipments
25
+ */
26
+ rateShipments: (context: RatingContext, shipment: ShipmentAndId[]) => Promise<RateResultsAndId[]>;
27
+ }
28
+ /** Signify a validation error from the carrier */
29
+ export declare class CarrierValidationError extends Error {
30
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarrierValidationError = void 0;
4
+ /** Signify a validation error from the carrier */
5
+ class CarrierValidationError extends Error {
6
+ }
7
+ exports.CarrierValidationError = CarrierValidationError;
8
+ //# sourceMappingURL=implementation-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementation-type.js","sourceRoot":"","sources":["../../../src/models/native-rating/implementation-type.ts"],"names":[],"mappings":";;;AA+BA,kDAAkD;AAClD,MAAa,sBAAuB,SAAQ,KAAK;CAAG;AAApD,wDAAoD"}
@@ -0,0 +1,7 @@
1
+ export * from './context-results';
2
+ export * from './get-rates';
3
+ export * from './get-variables';
4
+ export * from './get-zone';
5
+ export * from './implementation-type';
6
+ export * from './numeric-currency';
7
+ export * from './rating-context';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./context-results"), exports);
5
+ tslib_1.__exportStar(require("./get-rates"), exports);
6
+ tslib_1.__exportStar(require("./get-variables"), exports);
7
+ tslib_1.__exportStar(require("./get-zone"), exports);
8
+ tslib_1.__exportStar(require("./implementation-type"), exports);
9
+ tslib_1.__exportStar(require("./numeric-currency"), exports);
10
+ tslib_1.__exportStar(require("./rating-context"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/native-rating/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,sDAA4B;AAC5B,0DAAgC;AAChC,qDAA2B;AAC3B,gEAAsC;AACtC,6DAAmC;AACnC,2DAAiC"}
@@ -0,0 +1,5 @@
1
+ /** NumericCurrency so that we don't have to convert from the string Currency all over the place */
2
+ export interface NumericCurrency {
3
+ currency: string;
4
+ amount: number | undefined;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=numeric-currency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-currency.js","sourceRoot":"","sources":["../../../src/models/native-rating/numeric-currency.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { Logger } from 'winston';
2
+ import { GetVariables } from './get-variables';
3
+ import { GetRates } from './get-rates';
4
+ import { GetZone } from './get-zone';
5
+ /** Rates request context */
6
+ export interface RatingContext {
7
+ /** Function to get rates for given keys */
8
+ getRates: GetRates;
9
+ /** Function to get variables for given keys */
10
+ getVariables: GetVariables;
11
+ /** Function to get zone for given keys */
12
+ getZone: GetZone;
13
+ /** Logger that implementers can use */
14
+ log: Logger;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=rating-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating-context.js","sourceRoot":"","sources":["../../../src/models/native-rating/rating-context.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@shipengine/connect-carrier-api",
3
- "version": "4.0.0-beta",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "This is the typescript/javascript definitions for carrier api",
5
- "homepage": "https://github.com/ShipEngine/connect",
5
+ "homepage": "https://connect.shipengine.com",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "github.com/shipengine/connect"
20
+ "url": "github.com/shipstation/ipaas-connect"
21
21
  },
22
22
  "keywords": [
23
23
  "ipaas",
@@ -44,7 +44,7 @@
44
44
  "tslib": "^2.5.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "@shipengine/connect-runtime": "^4.0.0-beta",
47
+ "@shipengine/connect-runtime": "^4.0.0-beta.2",
48
48
  "express": "^4.18.2",
49
49
  "winston": "^3.8.2"
50
50
  }
@@ -39,6 +39,8 @@ import {
39
39
 
40
40
  import { CarrierAppMetadata } from './metadata/carrier-app-metadata';
41
41
 
42
+ import { RequestResponseInfo } from '@shipengine/connect-runtime';
43
+
42
44
  /**
43
45
  * @description This defines a connect carrier app
44
46
  */
@@ -153,4 +155,12 @@ export interface CarrierAppDefinition {
153
155
  ImportTrackingEvents?: (
154
156
  request: ImportTrackingEventsRequest,
155
157
  ) => AsyncGenerator<ImportedTrackingEvent>;
158
+ /** @description A method that gets additional context to log from the request when logging */
159
+ getAdditionalContext?: (req: Request) => Record<string, string>;
160
+ /** @description A method that redacts external HTTP requests and responses to prevent logging sensitive information */
161
+ redactExternalRequest?: (
162
+ req: RequestResponseInfo,
163
+ ) => Promise<RequestResponseInfo> | RequestResponseInfo;
164
+ /** @description A method that gets additional information to return with the diagnostic version route */
165
+ getAdditionalVersionInfo?: () => Promise<Record<string, string>> | Record<string, string>;
156
166
  }
@@ -18,6 +18,7 @@ export * from './inbound-content-types';
18
18
  export * from './insurance-providers';
19
19
  export * from './labels';
20
20
  export * from './manifests';
21
+ export * from './native-rating';
21
22
  export * from './package';
22
23
  export * from './pickup';
23
24
  export * from './rates';
@@ -0,0 +1,3 @@
1
+ export interface ContextResults<T> {
2
+ [dataKey: string]: T;
3
+ }
@@ -0,0 +1,9 @@
1
+ import { ContextResults } from './context-results';
2
+ import { NumericCurrency } from './numeric-currency';
3
+
4
+ export type GetRatesResults = ContextResults<NumericCurrency>;
5
+
6
+ /** Function to get rates from the context */
7
+ export interface GetRates {
8
+ (dataKeys: string[]): Promise<GetRatesResults>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { ContextResults } from './context-results';
2
+
3
+ export type GetVariableResults = ContextResults<any>;
4
+
5
+ /** Function to get rating variables from the context */
6
+ export interface GetVariables {
7
+ (dataKeys: string[]): Promise<GetVariableResults>;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { ContextResults } from './context-results';
2
+
3
+ export type GetZoneResults = ContextResults<any>;
4
+
5
+ /** Function to get zone data from the context */
6
+ export interface GetZone {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ (dataKeys: string[]): Promise<GetZoneResults>;
9
+ }
@@ -0,0 +1,33 @@
1
+ import type { GetRatesRequest, Rate } from '@shipengine/connect-carrier-api';
2
+ import type { RatingContext } from './rating-context';
3
+
4
+ /** A rate request shipment with its corresponding id */
5
+ export interface ShipmentAndId {
6
+ /** rate_request_identifier for the rate request */
7
+ id: string;
8
+ /** Shipment for the rate request */
9
+ shipment: GetRatesRequest;
10
+ }
11
+
12
+ /** Rate results with its corresponding rate request id */
13
+ export interface RateResultsAndId {
14
+ /** rate_request_identifier for the corresponding rate request */
15
+ id: string;
16
+ /** Error, if any */
17
+ error?: unknown;
18
+ /** Rates for a given rate request */
19
+ rates: Rate[];
20
+ }
21
+
22
+ /** Implementation of a carrier */
23
+ export interface RatingCarrier {
24
+ /** Rate shipments
25
+ * @param context Native Rating context that can be used by the implementation to interact with the underlying service
26
+ * @param shipment Shipments that should be rated
27
+ * @returns List of rates for the given shipments
28
+ */
29
+ rateShipments: (context: RatingContext, shipment: ShipmentAndId[]) => Promise<RateResultsAndId[]>;
30
+ }
31
+
32
+ /** Signify a validation error from the carrier */
33
+ export class CarrierValidationError extends Error {}
@@ -0,0 +1,7 @@
1
+ export * from './context-results';
2
+ export * from './get-rates';
3
+ export * from './get-variables';
4
+ export * from './get-zone';
5
+ export * from './implementation-type';
6
+ export * from './numeric-currency';
7
+ export * from './rating-context';
@@ -0,0 +1,5 @@
1
+ /** NumericCurrency so that we don't have to convert from the string Currency all over the place */
2
+ export interface NumericCurrency {
3
+ currency: string;
4
+ amount: number | undefined;
5
+ }
@@ -0,0 +1,19 @@
1
+ import { Logger } from 'winston';
2
+ import { GetVariables } from './get-variables';
3
+ import { GetRates } from './get-rates';
4
+ import { GetZone } from './get-zone';
5
+
6
+ /** Rates request context */
7
+ export interface RatingContext {
8
+ /** Function to get rates for given keys */
9
+ getRates: GetRates;
10
+
11
+ /** Function to get variables for given keys */
12
+ getVariables: GetVariables;
13
+
14
+ /** Function to get zone for given keys */
15
+ getZone: GetZone;
16
+
17
+ /** Logger that implementers can use */
18
+ log: Logger;
19
+ }