@shipengine/connect-fulfillment-provider-api 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,18 @@
1
1
  # Fulfillment Provider API TypeScript Library
2
2
 
3
- This library contains types used in building ShipEngine Connect Fulfillment Provider apps - the requests, responses, and models used to implement the Fulfillment Provider API.
3
+ The purpose of this library is to provide a framework for integrating Fulfillment Providers into the network using JavaScript & TypeScript. It will contain the models and definitions for Request/Response Bodies.
4
+
5
+ ## Building & Publishing
6
+ To build the project use this command in the terminal from this directory.
7
+ ```
8
+ yarn build
9
+ ```
10
+
11
+ this will generate a ```./lib``` directory which contains the JavaScript & TypeScript.
12
+
13
+ To publish make sure you set the appropriate version in the package.json file and then:
14
+ ```
15
+ yarn build
16
+ yarn publish
17
+ ```
18
+
@@ -1,6 +1,6 @@
1
1
  import { FulfillmentProviderAppMetadata } from './fulfillment-provider-app-metadata';
2
- import { ConnectRequest, ReconnectRequest, DelegationRequest, StatusRequest, CancellationRequest, InventoryRequest, GetRatesRequest, GetRecentChangesRequest } from '..';
3
- import { ConnectResponse, ReconnectResponse, DelegationResponse, StatusResponse, CancellationResponse, InventoryResponse, GetRatesResponse, GetRecentChangesResponse } from '..';
2
+ import { ConnectRequest, DelegationRequest, StatusRequest, CancellationRequest, GetRatesRequest, GetRecentChangesRequest } from '..';
3
+ import { ConnectResponse, DelegationResponse, StatusResponse, CancellationResponse, GetRatesResponse, GetRecentChangesResponse } from '..';
4
4
  /**
5
5
  * Definition for an Fulfillment Provider App implementation
6
6
  */
@@ -10,10 +10,6 @@ export interface FulfillmentProviderAppDefinition {
10
10
  * Create a connection to a fulfillment provider.
11
11
  */
12
12
  connect: (request: ConnectRequest) => Promise<ConnectResponse>;
13
- /**
14
- * Refresh connection details for a connection.
15
- */
16
- reconnect: (request: ReconnectRequest) => Promise<ReconnectResponse>;
17
13
  /**
18
14
  * Delegate a fulfillment to a provider.
19
15
  */
@@ -26,10 +22,6 @@ export interface FulfillmentProviderAppDefinition {
26
22
  * Request that a delegated fulfillment be cancelled by the provider.
27
23
  */
28
24
  requestCancellation: (request: CancellationRequest) => Promise<CancellationResponse>;
29
- /**
30
- * Get paged results of inventory from the provider.
31
- */
32
- getInventory: (request: InventoryRequest) => Promise<InventoryResponse>;
33
25
  /**
34
26
  * Get rates for a fulfillment preview from a provider.
35
27
  */
@@ -3,6 +3,8 @@ export declare type FulfillmentProviderAppMetadata = {
3
3
  Id: string;
4
4
  /** @description The name of this integration */
5
5
  Name: string;
6
+ /** @description The specification for authorizing with this order source */
7
+ AuthProcess: AuthSpecification;
6
8
  /** @description A list of branded order sources associated with this integration */
7
9
  FulfillmentProviders: FulfillmentProviderDefinition[];
8
10
  };
@@ -44,3 +46,135 @@ export declare type FulfillmentProviderDefinition = {
44
46
  IconUrl: string;
45
47
  };
46
48
  };
49
+ /** @description Used to specify information about an integrations authentication */
50
+ export declare class AuthSpecification {
51
+ /** @description Identify the type of Auth being used by the integration */
52
+ Identifier: AuthIdentifier;
53
+ /** @description Added to allow oauth 1.0 to work. */
54
+ access_token?: AccessToken;
55
+ /** @description Authorization: the beginning of an OAuth2.0 flow that ensures the user is logged
56
+ * in and approves access to the Resource. */
57
+ authorization?: AuthorizationConfiguration;
58
+ /** @description Request Token: server-server code for token exchange */
59
+ request_token?: RequestTokenConfiguration;
60
+ /** @description Refresh Token: server-server refresh token exchange for access token
61
+ * **NOTE: sometimes a new RT is also created** */
62
+ refresh_token?: RefreshTokenConfiguration;
63
+ /** @description Advanced configurations used for oauth 1.0 */
64
+ advanced_configuration?: Parameter[];
65
+ /** @description Connections is an optional feature that an integration may provide. A common use
66
+ * of connections is to provide the ability to connect to a sandbox or production endpoint.
67
+ * Connection name values may be accessed in a flow e.g in the request_token section, the url is
68
+ * dynamic.
69
+ *
70
+ * "url_template": "{connection_name:$.url}/access/token/request", */
71
+ connections?: ConnectionNamesConfiguration;
72
+ }
73
+ export declare class AuthIdentifier {
74
+ AuthenticationType: AuthenticationType;
75
+ Version?: string;
76
+ IsSandbox?: boolean;
77
+ }
78
+ export declare enum AuthenticationType {
79
+ OAuth = "oauth",
80
+ Basic = "basic",
81
+ ApiKey = "apikey"
82
+ }
83
+ export declare class AccessToken {
84
+ /** @description OAuth1 only. The url to obtain the temporary Access (aka Request) Token to start a flow **/
85
+ url_template: string;
86
+ }
87
+ export declare class AuthorizationConfiguration {
88
+ /** @description The url to obtain the access token using the authorization code on the backend
89
+ * @example "http://{auth_state:store_name}.store.com/admin/oauth/authorize", "http://store.com/oauth/authorize" */
90
+ url_template: string;
91
+ /** @description A list of query parameters that will be attached to the url */
92
+ query_parameters?: Parameter[];
93
+ /** @description Method to use when making the server-server code for token request @example "GET", "POST" */
94
+ method?: string;
95
+ /** @description List of parameters that are sent to the integration during the server-server
96
+ * authorization request. These are built using the content type specified in the headers array. */
97
+ body?: Parameter[];
98
+ /** @description List of headers that are sent to the integration when authorizing a token */
99
+ headers?: Parameter[];
100
+ /** @description A nonce query parameter included on the accept request, then returned and validated on the redirect request */
101
+ nonce?: NonceConfiguration;
102
+ }
103
+ export declare class Parameter {
104
+ /** @description The name of the parameter */
105
+ name: string;
106
+ /** @description The value associated with the parameter */
107
+ value: string;
108
+ }
109
+ export declare class NonceConfiguration {
110
+ name: string;
111
+ }
112
+ export declare class RequestTokenConfiguration {
113
+ /** @description The url to obtain the access token using the authorization code on the backend @example "http://{auth_state:store_name}.store.com/admin/oauth/request", "http://store.com/oauth/request" */
114
+ url_template: string;
115
+ /** @description A list of query parameters that will be attached to the url */
116
+ query_parameters?: Parameter[];
117
+ /** @description Method to use when making the server-server code for token request @example "GET", "POST" */
118
+ method?: string;
119
+ /** @description List of parameters that are sent to the integration when exchanging the code for the token. These are built using ContentType */
120
+ body?: Parameter[];
121
+ /** @description List of headers that are sent to the integration when requesting a token */
122
+ headers?: Parameter[];
123
+ /** @description Response payload parsing */
124
+ response?: ResponseTransformationConfiguration;
125
+ }
126
+ export declare class ResponseTransformationConfiguration {
127
+ /** @description JSONPath to the JSON element for access_token. */
128
+ access_token: string;
129
+ /** @description JSONPath to the JSON element for token_type */
130
+ token_type: string;
131
+ /** @description JSONPath to the JSON element for refresh_token */
132
+ refresh_token?: string;
133
+ /** @description JSONPath to the JSON element for expires_in. Mutually exclusive with expires_at */
134
+ expires_in?: string;
135
+ /** @description Configuration for parsing a date-time, when the integration is lacking expires_in.
136
+ * Mutually exclusive with expires_in.
137
+ */
138
+ expires_at?: DateTimeConfiguration;
139
+ /** @description Optional collection of properties to include in the connection_context sent back with the auth flow result.
140
+ * Property value may be JSONPath or a string literal.
141
+ * E.g.
142
+ * "connection_context": {
143
+ * "store_id": "$.data.store_id"
144
+ * }
145
+ */
146
+ connection_context?: MapOfStrings;
147
+ }
148
+ export declare class DateTimeConfiguration {
149
+ /** @description JSONPath to the JSON element containing the date-time */
150
+ path: string;
151
+ /** @description DateTime format string compliant with
152
+ * https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings */
153
+ date_time_format: string;
154
+ }
155
+ export declare type MapOfStrings = {
156
+ [key: string]: string;
157
+ };
158
+ export declare class RefreshTokenConfiguration {
159
+ /** @description The url to refresh the access token using the authorization code on the backend @example "http://{auth_state:store_name}.store.com/admin/oauth/refresh", "http://store.com/oauth/refresh" */
160
+ url_template: string;
161
+ /** @description A list of query parameters that will be attached to the url */
162
+ query_parameters?: Parameter[];
163
+ /** @description Method to use when making the server-server code for token request @example "GET", "POST" */
164
+ method?: string;
165
+ /** @description List of parameters that are sent to the integration during the server-server refresh token request. These are built using the content type specified in the headers array. */
166
+ body?: Parameter[];
167
+ /** @description List of headers that are sent to the integration when refreshing a token */
168
+ headers?: Parameter[];
169
+ /** @description Response payload parsing */
170
+ response?: ResponseTransformationConfiguration;
171
+ }
172
+ export declare class ConnectionNamesConfiguration {
173
+ /** @description A unique list of connection names that the integration supports. */
174
+ connection_names: MapOfObjects;
175
+ /** @description The connection name that will be used when none is selected. */
176
+ default_connection_name: string;
177
+ }
178
+ export declare type MapOfObjects = {
179
+ [key: string]: any;
180
+ };
@@ -1,3 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionNamesConfiguration = exports.RefreshTokenConfiguration = exports.DateTimeConfiguration = exports.ResponseTransformationConfiguration = exports.RequestTokenConfiguration = exports.NonceConfiguration = exports.Parameter = exports.AuthorizationConfiguration = exports.AccessToken = exports.AuthenticationType = exports.AuthIdentifier = exports.AuthSpecification = void 0;
4
+ /** @description Used to specify information about an integrations authentication */
5
+ class AuthSpecification {
6
+ }
7
+ exports.AuthSpecification = AuthSpecification;
8
+ class AuthIdentifier {
9
+ }
10
+ exports.AuthIdentifier = AuthIdentifier;
11
+ var AuthenticationType;
12
+ (function (AuthenticationType) {
13
+ AuthenticationType["OAuth"] = "oauth";
14
+ AuthenticationType["Basic"] = "basic";
15
+ AuthenticationType["ApiKey"] = "apikey";
16
+ })(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
17
+ class AccessToken {
18
+ }
19
+ exports.AccessToken = AccessToken;
20
+ class AuthorizationConfiguration {
21
+ }
22
+ exports.AuthorizationConfiguration = AuthorizationConfiguration;
23
+ class Parameter {
24
+ }
25
+ exports.Parameter = Parameter;
26
+ class NonceConfiguration {
27
+ }
28
+ exports.NonceConfiguration = NonceConfiguration;
29
+ class RequestTokenConfiguration {
30
+ }
31
+ exports.RequestTokenConfiguration = RequestTokenConfiguration;
32
+ class ResponseTransformationConfiguration {
33
+ }
34
+ exports.ResponseTransformationConfiguration = ResponseTransformationConfiguration;
35
+ class DateTimeConfiguration {
36
+ }
37
+ exports.DateTimeConfiguration = DateTimeConfiguration;
38
+ class RefreshTokenConfiguration {
39
+ }
40
+ exports.RefreshTokenConfiguration = RefreshTokenConfiguration;
41
+ class ConnectionNamesConfiguration {
42
+ }
43
+ exports.ConnectionNamesConfiguration = ConnectionNamesConfiguration;
3
44
  //# sourceMappingURL=fulfillment-provider-app-metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fulfillment-provider-app-metadata.js","sourceRoot":"","sources":["../../src/app/fulfillment-provider-app-metadata.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"fulfillment-provider-app-metadata.js","sourceRoot":"","sources":["../../src/app/fulfillment-provider-app-metadata.ts"],"names":[],"mappings":";;;AAmDA,oFAAoF;AACpF,MAAa,iBAAiB;CAsB7B;AAtBD,8CAsBC;AAED,MAAa,cAAc;CAI1B;AAJD,wCAIC;AAED,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,qCAAe,CAAA;IACf,uCAAiB,CAAA;AACnB,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B;AAED,MAAa,WAAW;CAGvB;AAHD,kCAGC;AAED,MAAa,0BAA0B;CAetC;AAfD,gEAeC;AAED,MAAa,SAAS;CAKrB;AALD,8BAKC;AAED,MAAa,kBAAkB;CAE9B;AAFD,gDAEC;AAED,MAAa,yBAAyB;CAarC;AAbD,8DAaC;AAED,MAAa,mCAAmC;CAqB/C;AArBD,kFAqBC;AAED,MAAa,qBAAqB;CAMjC;AAND,sDAMC;AAMD,MAAa,yBAAyB;CAarC;AAbD,8DAaC;AAED,MAAa,4BAA4B;CAKxC;AALD,oEAKC"}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FulfillmentProviderApp = void 0;
4
- const path_1 = require("path");
5
- const fs_1 = require("fs");
4
+ const spec_1 = require("../spec");
6
5
  const internal_1 = require("./internal");
7
6
  const handleRequest = (implementation) => {
8
7
  return (request) => {
@@ -11,18 +10,13 @@ const handleRequest = (implementation) => {
11
10
  };
12
11
  class FulfillmentProviderApp {
13
12
  constructor(definition) {
14
- this.redoc = fs_1.readFileSync(path_1.resolve(__dirname, '../../spec.yaml')).toString();
13
+ this.redoc = JSON.stringify(spec_1.OpenApiSpecification);
15
14
  this.routes = [
16
15
  {
17
16
  method: internal_1.Method.POST,
18
17
  path: '/connect',
19
18
  handler: handleRequest(definition.connect),
20
19
  },
21
- {
22
- method: internal_1.Method.POST,
23
- path: '/reconnect',
24
- handler: handleRequest(definition.reconnect),
25
- },
26
20
  {
27
21
  method: internal_1.Method.POST,
28
22
  path: '/fulfillment/delegation',
@@ -38,11 +32,6 @@ class FulfillmentProviderApp {
38
32
  path: '/fulfillment/cancellation',
39
33
  handler: handleRequest(definition.requestCancellation),
40
34
  },
41
- {
42
- method: internal_1.Method.POST,
43
- path: '/inventory',
44
- handler: handleRequest(definition.getInventory),
45
- },
46
35
  {
47
36
  method: internal_1.Method.POST,
48
37
  path: '/rates',
@@ -1 +1 @@
1
- {"version":3,"file":"fulfillment-provider-app.js","sourceRoot":"","sources":["../../src/app/fulfillment-provider-app.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2BAAkC;AAElC,yCAMoB;AAEpB,MAAM,aAAa,GAAG,CAAC,cAAwB,EAAO,EAAE;IACtD,OAAO,CAAC,OAAY,EAAE,EAAE;QACtB,OAAO,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAa,sBAAsB;IAKjC,YAAY,UAA4C;QAFxD,UAAK,GAAG,iBAAY,CAAC,cAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAGrE,IAAI,CAAC,MAAM,GAAG;YACZ;gBACE,MAAM,EAAE,iBAAM,CAAC,IAAI;gBACnB,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;aAC3C;YACD;gBACE,MAAM,EAAE,iBAAM,CAAC,IAAI;gBACnB,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC;aAC7C;YACD;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aACpD;SACF,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,IAAI,8CAAmC,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxF,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACrD,OAAO;gBACL,EAAE,EAAE,QAAQ,CAAC,EAAE;gBACf,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;gBAC7B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;aAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,wDAmDC"}
@@ -1,82 +1,12 @@
1
1
  import { Route } from '.';
2
2
  import { FulfillmentProviderAppMetadata, Connector } from '..';
3
- export declare class FulfillmentProviderAppSpecification {
4
- /**
5
- *
6
- */
3
+ import { AuthSpecification, FulfillmentProviderDefinition } from '../fulfillment-provider-app-metadata';
4
+ export declare class FulfillmentProviderAppSpecification implements FulfillmentProviderAppMetadata {
7
5
  constructor(metadata: FulfillmentProviderAppMetadata, routes: Route[]);
8
- /** @description Fulfillment provider identifying information */
9
- Id: {
10
- /** @description The unique id for this integration */
11
- Id: string;
12
- /** @description The name of this integration */
13
- Name: string;
14
- /** @description The alternate name for this integration */
15
- Alias: string;
16
- };
17
- /** @description Internal state for this fulfillment provider */
18
- Status: string;
19
- /** @description A list of branded order sources associated with this integration */
20
- FulfillmentProviders: FulfillmentProviderSpecification[];
6
+ AuthProcess: AuthSpecification;
7
+ Id: string;
8
+ Name: string;
9
+ FulfillmentProviders: FulfillmentProviderDefinition[];
21
10
  /** @description Internal information about the connector */
22
11
  Connector: Connector;
23
12
  }
24
- export declare type FulfillmentProviderSpecification = {
25
- /** @description This is a unique GUID identifier for this order source */
26
- Id: string;
27
- /** @description The branded name for this fulfillment provider @example "FBA", "Shipwore" */
28
- Name: string;
29
- /** @description The long text description for this fulfillment provider */
30
- Description: string;
31
- /** @description Internal searchable tags to find this fulfillment provider */
32
- Tags: string;
33
- /** @description Internal human friendly and uniquely identifying code for exposing in an api */
34
- ApiCode: string;
35
- /** @description Internal flag for if this fulfillment provider supports inventory stocking details */
36
- InventoryLevels: boolean;
37
- /** @description Internal flag for if fulfillment provider is available for all customers */
38
- IsLive: boolean;
39
- /** @description Internal flag for if this fulfillment provider is enabled */
40
- Active: boolean;
41
- /** @description Internal order which this fulfillment provider is shown */
42
- SortOrder: number;
43
- /** @description The list of available fulfillment services */
44
- FulfillmentServices: FulfillmentServiceSpecification[];
45
- /** @description Specifies connection forms */
46
- AccountModals: {
47
- /** @description Defines fields for registration */
48
- RegistrationFormSchema: {
49
- JsonSchema: object;
50
- UiSchema: object;
51
- };
52
- /** @description Defines fields for changes to the connection */
53
- SettingsFormSchema: {
54
- JsonSchema: object;
55
- UiSchema: object;
56
- };
57
- };
58
- /** @description Images that will be used for this branded order source */
59
- Images: {
60
- /** @description The full path to the logo used in modals and other areas of our platform for this order source. Use join(__dirname, '../assets/logo.svg') @example "/dev/integration/assets/ordersource1/logo.svg" */
61
- LogoUrl: string;
62
- /** @description The full path to the icon used for this order source. Use join(__dirname, '../assets/logo.svg') @example "/dev/integration/assets/ordersource1/icon.svg" */
63
- IconUrl: string;
64
- };
65
- };
66
- export declare type FulfillmentServiceSpecification = {
67
- /** @description Name of the shipping service */
68
- Name: string;
69
- /** @description Shortened name of the shipping service */
70
- Abbreviation: string;
71
- /** @description Internal code for identifying this service */
72
- Code: string;
73
- /** @description Internal sorting order for this service */
74
- SortOrder: number;
75
- /** @description Internal flag for if this service is selectable */
76
- Active: boolean;
77
- /** @description Internal human friendly identifying code for exposing in an api */
78
- ApiCode: string;
79
- };
80
- export declare function snakeCase(text: string, options?: {
81
- delimiter: string;
82
- }): string;
@@ -1,108 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snakeCase = exports.FulfillmentProviderAppSpecification = void 0;
3
+ exports.FulfillmentProviderAppSpecification = void 0;
4
4
  class FulfillmentProviderAppSpecification {
5
- /**
6
- *
7
- */
8
5
  constructor(metadata, routes) {
9
- /** @description Internal state for this fulfillment provider */
10
- this.Status = 'Active';
11
- this.Id = {
12
- Id: metadata.Id,
13
- Name: metadata.Name,
14
- Alias: snakeCase(metadata.Name, { delimiter: '-' }).toLowerCase(),
15
- };
16
- let sortOrder = 0;
17
- this.FulfillmentProviders = metadata.FulfillmentProviders.map((p) => ({
18
- Id: p.Id,
19
- Name: p.Name,
20
- Description: p.Description,
21
- Tags: `|${formattedTags(['Fulfillment', ...extractTags(p.Name)])}|`,
22
- ApiCode: snakeCase(p.Name).toLowerCase(),
23
- InventoryLevels: true,
24
- IsLive: true,
25
- Active: true,
26
- SortOrder: sortOrder++,
27
- AccountModals: {
28
- RegistrationFormSchema: {
29
- JsonSchema: p.AccountModals.RegistrationFormSchema.JsonSchema,
30
- UiSchema: p.AccountModals.RegistrationFormSchema.UiSchema,
31
- },
32
- SettingsFormSchema: {
33
- JsonSchema: p.AccountModals.SettingsFormSchema.JsonSchema,
34
- UiSchema: p.AccountModals.SettingsFormSchema.UiSchema,
35
- },
36
- },
37
- Images: {
38
- IconUrl: p.Images.IconUrl,
39
- LogoUrl: p.Images.LogoUrl,
40
- },
41
- FulfillmentServices: p.FulfillmentServices.map((s) => ({
42
- Name: s.Name,
43
- Abbreviation: s.Abbreviation || s.Name,
44
- Active: true,
45
- Code: s.Name,
46
- SortOrder: sortOrder++,
47
- ApiCode: snakeCase(s.Name).toLowerCase(),
48
- })),
49
- }));
6
+ this.Id = metadata.Id;
7
+ this.Name = metadata.Name;
8
+ this.FulfillmentProviders = metadata.FulfillmentProviders;
9
+ this.AuthProcess = metadata.AuthProcess;
10
+ this.AuthProcess.Identifier.Version = '2.0';
50
11
  this.Connector = {
51
12
  DiagnosticRoutes: {
52
13
  Liveness: '/diagnostics/liveness',
53
14
  Readiness: '/diagnostics/readiness',
54
15
  Version: '/diagnostics/version',
55
16
  },
56
- ApiVersion: '1.0.0',
17
+ ApiVersion: '2.0.0',
57
18
  Functions: routes.map(mapRoutes),
58
19
  };
59
20
  }
60
21
  }
61
22
  exports.FulfillmentProviderAppSpecification = FulfillmentProviderAppSpecification;
62
- function extractTags(name) {
63
- return name.split(' ');
64
- }
65
- function formattedTags(parts) {
66
- return parts.join('|');
67
- }
68
- function mapRoutes(route) {
23
+ const mapRoutes = (route) => {
69
24
  return {
70
- Name: snakeCase(route.path.replace('/', ''), {
71
- delimiter: '-',
72
- }).toLowerCase(),
25
+ Name: route.path.replace('/', ''),
73
26
  IsSandboxed: false,
74
27
  };
75
- }
76
- function snakeCase(text, options = { delimiter: '_' }) {
77
- let snaked = '';
78
- let wasLower = false;
79
- let wasNumber = false;
80
- for (let i = 0; i < text.length; i++) {
81
- const l = text[i];
82
- const isLower = l >= 'a' && l <= 'z';
83
- const isNumber = l >= '0' && l <= '9';
84
- const isUpper = l >= 'A' && l <= 'Z';
85
- const isHyphen = l === '-' || l === '_' || l === ' ';
86
- if (!isLower && !isNumber && !isUpper && !isHyphen) {
87
- continue;
88
- }
89
- if (isHyphen) {
90
- snaked += options.delimiter;
91
- wasLower = false;
92
- wasNumber = false;
93
- continue;
94
- }
95
- if (isUpper && wasLower) {
96
- snaked += options.delimiter;
97
- }
98
- if ((isUpper || isLower) && wasNumber) {
99
- snaked += options.delimiter;
100
- }
101
- wasNumber = isNumber;
102
- wasLower = isLower;
103
- snaked += text[i];
104
- }
105
- return snaked;
106
- }
107
- exports.snakeCase = snakeCase;
28
+ };
108
29
  //# sourceMappingURL=metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/app/internal/metadata.ts"],"names":[],"mappings":";;;AAGA,MAAa,mCAAmC;IAC9C;;OAEG;IACH,YAAY,QAAwC,EAAE,MAAe;QAgErE,gEAAgE;QAChE,WAAM,GAAW,QAAQ,CAAC;QAhExB,IAAI,CAA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Ae;QACnE,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;QAE5C,IAAI,CAAC,SAAS,GAAG;YACf,gBAAgB,EAAE;gBAChB,QAAQ,EAAE,uBAAuB;gBACjC,SAAS,EAAE,wBAAwB;gBACnC,OAAO,EAAE,sBAAsB;aAChC;YACD,UAAU,EAAE,OAAO;YACnB,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;SACjC,CAAC;IACJ,CAAC;CAQF;AAzBD,kFAyBC;AAED,MAAM,SAAS,GAAG,CAAC,KAAY,EAAyB,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACjC,WAAW,EAAE,KAAK;KACnB,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/connect-fulfillment-provider-api",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "OpenAPI specification and TypeScript definitions for the Connect Fulfillment Provider API",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",