@arrowsphere/api-client 3.29.0-rc.uts.1 → 3.30.0-rc-jpb.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 +12 -0
- package/build/AbstractHttpClient.d.ts +47 -0
- package/build/AbstractHttpClient.js +80 -0
- package/build/abstractGraphQLClient.d.ts +5 -15
- package/build/abstractGraphQLClient.js +32 -23
- package/build/{abstractClient.d.ts → abstractRestfulClient.d.ts} +6 -22
- package/build/{abstractClient.js → abstractRestfulClient.js} +14 -29
- package/build/campaign/campaignClient.d.ts +2 -2
- package/build/campaign/campaignClient.js +2 -2
- package/build/cart/cartClient.d.ts +2 -2
- package/build/cart/cartClient.js +2 -2
- package/build/catalog/catalogClient.d.ts +2 -2
- package/build/catalog/catalogClient.js +2 -2
- package/build/catalog/catalogGraphQLClient.d.ts +2 -0
- package/build/catalog/catalogGraphQLClient.js +14 -1
- package/build/catalog/index.d.ts +2 -0
- package/build/catalog/index.js +2 -0
- package/build/catalog/types/catalogGraphQLQueries.d.ts +12 -0
- package/build/catalog/types/catalogGraphQLQueries.js +3 -0
- package/build/catalog/types/catalogGraphQLSchemas.d.ts +30 -0
- package/build/catalog/types/catalogGraphQLSchemas.js +4 -0
- package/build/catalog/types/catalogGraphQLTypes.js +1 -0
- package/build/catalog/types/queryArguments.d.ts +41 -0
- package/build/catalog/types/queryArguments.js +10 -0
- package/build/consumption/consumptionClient.d.ts +2 -2
- package/build/consumption/consumptionClient.js +2 -2
- package/build/contact/contactClient.d.ts +2 -2
- package/build/contact/contactClient.js +2 -2
- package/build/customers/customersClient.d.ts +2 -2
- package/build/customers/customersClient.js +2 -2
- package/build/exception/exception-handlers/HandleHttpExceptionOutput.d.ts +3 -0
- package/build/exception/exception-handlers/HandleHttpExceptionOutput.js +3 -0
- package/build/exception/exception-handlers/Hooks.d.ts +3 -0
- package/build/exception/exception-handlers/Hooks.js +3 -0
- package/build/exception/exception-handlers/HttpExceptionHandler.d.ts +10 -0
- package/build/exception/exception-handlers/HttpExceptionHandler.js +3 -0
- package/build/exception/exception-handlers/index.d.ts +3 -0
- package/build/exception/exception-handlers/index.js +20 -0
- package/build/exception/publicApiClientException.d.ts +2 -1
- package/build/exception/publicApiClientException.js +2 -1
- package/build/general/checkDomainClient.d.ts +2 -2
- package/build/general/checkDomainClient.js +2 -2
- package/build/general/whoAmIClient.d.ts +2 -2
- package/build/general/whoAmIClient.js +2 -2
- package/build/index.d.ts +3 -1
- package/build/index.js +3 -1
- package/build/licenses/entities/findResult.d.ts +2 -2
- package/build/licenses/entities/findResult.js +1 -1
- package/build/licenses/licensesClient.d.ts +2 -2
- package/build/licenses/licensesClient.js +2 -2
- package/build/orders/ordersClient.d.ts +2 -2
- package/build/orders/ordersClient.js +2 -2
- package/build/publicApiClient.d.ts +4 -2
- package/build/publicApiClient.js +9 -2
- package/build/security/register/registerClient.d.ts +2 -2
- package/build/security/register/registerClient.js +2 -2
- package/build/security/standards/standardsClient.d.ts +2 -2
- package/build/security/standards/standardsClient.js +2 -2
- package/build/securityScore/entities/getCustomerAccountData.d.ts +48 -0
- package/build/securityScore/entities/getCustomerAccountData.js +111 -0
- package/build/securityScore/entities/getCustomerData.d.ts +51 -0
- package/build/securityScore/entities/getCustomerData.js +117 -0
- package/build/securityScore/entities/getPartnerData.d.ts +45 -0
- package/build/securityScore/entities/getPartnerData.js +102 -0
- package/build/securityScore/index.d.ts +7 -0
- package/build/securityScore/index.js +24 -0
- package/build/securityScore/securityScoreGraphQLClient.d.ts +19 -0
- package/build/securityScore/securityScoreGraphQLClient.js +61 -0
- package/build/securityScore/types/queryArguments.d.ts +108 -0
- package/build/securityScore/types/queryArguments.js +93 -0
- package/build/securityScore/types/securityScoreGraphQLQueries.d.ts +62 -0
- package/build/securityScore/types/securityScoreGraphQLQueries.js +7 -0
- package/build/securityScore/types/securityScoreGraphQLSchemas.d.ts +78 -0
- package/build/securityScore/types/securityScoreGraphQLSchemas.js +3 -0
- package/build/securityScore/types/securityScoreGraphQLTypes.d.ts +190 -0
- package/build/securityScore/types/securityScoreGraphQLTypes.js +3 -0
- package/build/subscriptions/subscriptionsClient.d.ts +2 -2
- package/build/subscriptions/subscriptionsClient.js +2 -2
- package/build/supportCenter/payloads/issue.d.ts +1 -1
- package/build/supportCenter/supportCenterClient.d.ts +2 -2
- package/build/supportCenter/supportCenterClient.js +2 -2
- package/build/user/UserClient.d.ts +10 -0
- package/build/user/UserClient.js +20 -0
- package/build/user/index.d.ts +2 -0
- package/build/user/index.js +19 -0
- package/build/user/types/CompleteWhoAmI.d.ts +18 -0
- package/build/user/types/CompleteWhoAmI.js +47 -0
- package/build/user/types/CompleteWhoAmICompany.d.ts +28 -0
- package/build/user/types/CompleteWhoAmICompany.js +74 -0
- package/build/user/types/CompleteWhoAmIUser.d.ts +37 -0
- package/build/user/types/CompleteWhoAmIUser.js +94 -0
- package/build/user/types/index.d.ts +3 -0
- package/build/user/types/index.js +20 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -50,6 +50,18 @@ The output documentation should be located in the `docs/` folder, just open the
|
|
|
50
50
|
|
|
51
51
|
- [CheckDomain](./src/general/CHECKDOMAIN.md)
|
|
52
52
|
- [WhoAmI](./src/general/WHOAMI.md)
|
|
53
|
+
- [Campaign](./src/campaign/README.md)
|
|
54
|
+
- [Cart](./src/cart/README.md)
|
|
55
|
+
- [Catalog](./src/catalog/README.md)
|
|
56
|
+
- [Consumption](./src/consumption/README.md)
|
|
57
|
+
- [Contact](./src/contact/README.md)
|
|
58
|
+
- [Customers](./src/customers/README.md)
|
|
59
|
+
- [Licenses](./src/licenses/README.md)
|
|
60
|
+
- [Orders](./src/orders/README.md)
|
|
61
|
+
- [Subscriptions](./src/subscriptions/README.md)
|
|
62
|
+
- [Support Center](./src/supportCenter/README.md)
|
|
63
|
+
|
|
64
|
+
- [SecurityScore](./src/securityScore/README.md)
|
|
53
65
|
|
|
54
66
|
### Licenses
|
|
55
67
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { HttpExceptionHandler, HandleHttpExceptionOutput } from './exception/exception-handlers';
|
|
2
|
+
import { PublicApiClientException } from './exception';
|
|
3
|
+
export declare enum HttpClientSecurity {
|
|
4
|
+
TOKEN = "token",
|
|
5
|
+
API_KEY = "apikey"
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class AbstractHttpClient {
|
|
8
|
+
/**
|
|
9
|
+
* Base path for HTTP calls
|
|
10
|
+
*/
|
|
11
|
+
protected basePath: string;
|
|
12
|
+
/**
|
|
13
|
+
* Current path for HTTP calls
|
|
14
|
+
*/
|
|
15
|
+
protected path: string;
|
|
16
|
+
/**
|
|
17
|
+
* Token to authenticate the user
|
|
18
|
+
*/
|
|
19
|
+
protected token: string;
|
|
20
|
+
/**
|
|
21
|
+
* ArrowSphere API URL
|
|
22
|
+
*/
|
|
23
|
+
protected url: string;
|
|
24
|
+
/**
|
|
25
|
+
* Http Exceptions Handlers
|
|
26
|
+
*/
|
|
27
|
+
protected httpExceptionHandlers: HttpExceptionHandler[];
|
|
28
|
+
/**
|
|
29
|
+
* Security used to auth on server
|
|
30
|
+
* Default to API_KEY to handle
|
|
31
|
+
* the existing codebase
|
|
32
|
+
*/
|
|
33
|
+
protected security: HttpClientSecurity;
|
|
34
|
+
setToken(token: string): this;
|
|
35
|
+
setUrl(url: string): this;
|
|
36
|
+
setSecurity(security: HttpClientSecurity): this;
|
|
37
|
+
/**
|
|
38
|
+
* Allow to register error/exception handler.
|
|
39
|
+
* Handlers can be developed in another projects as long as they respect the interface HttpExceptionHandler.
|
|
40
|
+
*/
|
|
41
|
+
registerHttpExceptionHandler(handler: HttpExceptionHandler): this;
|
|
42
|
+
/**
|
|
43
|
+
* Will find appropriate ErrorHandlers and apply them to the error in order of registering.
|
|
44
|
+
*/
|
|
45
|
+
protected handleError(error: PublicApiClientException): Promise<HandleHttpExceptionOutput>;
|
|
46
|
+
protected mapToPublicApiException(error: any): PublicApiClientException;
|
|
47
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractHttpClient = exports.HttpClientSecurity = void 0;
|
|
4
|
+
const exception_1 = require("./exception");
|
|
5
|
+
var HttpClientSecurity;
|
|
6
|
+
(function (HttpClientSecurity) {
|
|
7
|
+
HttpClientSecurity["TOKEN"] = "token";
|
|
8
|
+
HttpClientSecurity["API_KEY"] = "apikey";
|
|
9
|
+
})(HttpClientSecurity = exports.HttpClientSecurity || (exports.HttpClientSecurity = {}));
|
|
10
|
+
class AbstractHttpClient {
|
|
11
|
+
constructor() {
|
|
12
|
+
/**
|
|
13
|
+
* Base path for HTTP calls
|
|
14
|
+
*/
|
|
15
|
+
this.basePath = '';
|
|
16
|
+
/**
|
|
17
|
+
* Current path for HTTP calls
|
|
18
|
+
*/
|
|
19
|
+
this.path = '';
|
|
20
|
+
/**
|
|
21
|
+
* Token to authenticate the user
|
|
22
|
+
*/
|
|
23
|
+
this.token = '';
|
|
24
|
+
/**
|
|
25
|
+
* ArrowSphere API URL
|
|
26
|
+
*/
|
|
27
|
+
this.url = '';
|
|
28
|
+
/**
|
|
29
|
+
* Http Exceptions Handlers
|
|
30
|
+
*/
|
|
31
|
+
this.httpExceptionHandlers = [];
|
|
32
|
+
/**
|
|
33
|
+
* Security used to auth on server
|
|
34
|
+
* Default to API_KEY to handle
|
|
35
|
+
* the existing codebase
|
|
36
|
+
*/
|
|
37
|
+
this.security = HttpClientSecurity.API_KEY;
|
|
38
|
+
}
|
|
39
|
+
setToken(token) {
|
|
40
|
+
this.token = token;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
setUrl(url) {
|
|
44
|
+
this.url = url;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
setSecurity(security) {
|
|
48
|
+
this.security = security;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Allow to register error/exception handler.
|
|
53
|
+
* Handlers can be developed in another projects as long as they respect the interface HttpExceptionHandler.
|
|
54
|
+
*/
|
|
55
|
+
registerHttpExceptionHandler(handler) {
|
|
56
|
+
this.httpExceptionHandlers.push(handler);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Will find appropriate ErrorHandlers and apply them to the error in order of registering.
|
|
61
|
+
*/
|
|
62
|
+
async handleError(error) {
|
|
63
|
+
const appropriateHandlers = this.httpExceptionHandlers.filter((handler) => handler.getHandledHttpStatuses().includes(error.httpCode));
|
|
64
|
+
// handle retry
|
|
65
|
+
const output = { mustRetry: false };
|
|
66
|
+
for (const handler of appropriateHandlers) {
|
|
67
|
+
const res = await handler.handle(error, {
|
|
68
|
+
setToken: this.setToken,
|
|
69
|
+
});
|
|
70
|
+
output.mustRetry = res.mustRetry;
|
|
71
|
+
}
|
|
72
|
+
return output;
|
|
73
|
+
}
|
|
74
|
+
mapToPublicApiException(error) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return new exception_1.PublicApiClientException(error === null || error === void 0 ? void 0 : error.message, String(error), (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status, (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.config);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.AbstractHttpClient = AbstractHttpClient;
|
|
80
|
+
//# sourceMappingURL=AbstractHttpClient.js.map
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
import { GraphQLClient } from 'graphql-request';
|
|
2
2
|
import * as Dom from 'graphql-request/dist/types.dom';
|
|
3
|
-
import { Options } from './
|
|
3
|
+
import { Options } from './abstractRestfulClient';
|
|
4
4
|
import { GetProductsType } from './catalog';
|
|
5
|
+
import { AbstractHttpClient } from './AbstractHttpClient';
|
|
5
6
|
export declare type GraphQLResponseTypes = GetProductsType;
|
|
6
|
-
export declare abstract class AbstractGraphQLClient {
|
|
7
|
-
/**
|
|
8
|
-
* Base path for HTTP calls
|
|
9
|
-
*/
|
|
10
|
-
protected basePath: string;
|
|
11
|
-
/**
|
|
12
|
-
* Current path for HTTP calls
|
|
13
|
-
*/
|
|
14
|
-
protected path: string;
|
|
7
|
+
export declare abstract class AbstractGraphQLClient extends AbstractHttpClient {
|
|
15
8
|
protected client: GraphQLClient;
|
|
16
|
-
protected url: string;
|
|
17
|
-
protected token: string;
|
|
18
9
|
protected optionsHeader?: Dom.RequestInit['headers'];
|
|
19
10
|
protected options: Options;
|
|
20
11
|
private getClient;
|
|
21
|
-
setToken(apiKey: string): this;
|
|
22
|
-
setUrl(url: string): this;
|
|
23
12
|
setOptionsHeader(options: Dom.RequestInit['headers']): this;
|
|
24
13
|
setOptions(options: Options): this;
|
|
25
|
-
protected post(query: string): Promise<GraphQLResponseTypes>;
|
|
14
|
+
protected post<GraphQLResponseTypes>(query: string): Promise<GraphQLResponseTypes>;
|
|
26
15
|
protected generateUrl(): string;
|
|
16
|
+
protected stringifyQuery(query: any): string;
|
|
27
17
|
}
|
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.AbstractGraphQLClient = void 0;
|
|
7
27
|
const graphql_request_1 = require("graphql-request");
|
|
8
|
-
const
|
|
9
|
-
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const json_to_graphql_query_1 = require("json-to-graphql-query");
|
|
30
|
+
const AbstractHttpClient_1 = require("./AbstractHttpClient");
|
|
31
|
+
class AbstractGraphQLClient extends AbstractHttpClient_1.AbstractHttpClient {
|
|
10
32
|
constructor() {
|
|
11
|
-
|
|
12
|
-
* Base path for HTTP calls
|
|
13
|
-
*/
|
|
14
|
-
this.basePath = '';
|
|
15
|
-
/**
|
|
16
|
-
* Current path for HTTP calls
|
|
17
|
-
*/
|
|
18
|
-
this.path = '';
|
|
19
|
-
this.url = '';
|
|
20
|
-
this.token = '';
|
|
33
|
+
super(...arguments);
|
|
21
34
|
this.options = {};
|
|
22
35
|
}
|
|
23
36
|
getClient() {
|
|
24
37
|
this.client = new graphql_request_1.GraphQLClient(this.generateUrl());
|
|
25
38
|
return this;
|
|
26
39
|
}
|
|
27
|
-
setToken(apiKey) {
|
|
28
|
-
this.token = apiKey;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
setUrl(url) {
|
|
32
|
-
this.url = url;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
40
|
setOptionsHeader(options) {
|
|
36
41
|
this.optionsHeader = options;
|
|
37
42
|
return this;
|
|
@@ -48,9 +53,13 @@ class AbstractGraphQLClient {
|
|
|
48
53
|
return await this.client.request(query);
|
|
49
54
|
}
|
|
50
55
|
generateUrl() {
|
|
51
|
-
const url = new URL(`${this.options.isAdmin ?
|
|
56
|
+
const url = new URL(`${this.options.isAdmin ? path.join('admin', this.basePath) : this.basePath}${this.path}`, this.url);
|
|
52
57
|
return url.toString();
|
|
53
58
|
}
|
|
59
|
+
stringifyQuery(query) {
|
|
60
|
+
const graphqlQuery = (0, json_to_graphql_query_1.jsonToGraphQLQuery)(query);
|
|
61
|
+
return `{${graphqlQuery}}`;
|
|
62
|
+
}
|
|
54
63
|
}
|
|
55
64
|
exports.AbstractGraphQLClient = AbstractGraphQLClient;
|
|
56
65
|
//# sourceMappingURL=abstractGraphQLClient.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
import { AbstractHttpClient } from './AbstractHttpClient';
|
|
2
3
|
/**
|
|
3
4
|
* Lists of available query parameters for the API call
|
|
4
5
|
*/
|
|
5
6
|
export declare enum ParameterKeys {
|
|
6
7
|
API_KEY = "apiKey",
|
|
8
|
+
AUTHORIZATION = "Authorization",
|
|
7
9
|
HEADERS = "headers",
|
|
8
10
|
ORDER_BY = "order_by",
|
|
9
11
|
PAGE = "page",
|
|
@@ -36,23 +38,11 @@ export declare type ConfigurationsClient = {
|
|
|
36
38
|
export declare type ExtraInformationType = {
|
|
37
39
|
[ExtraInformationFields.COLUMN_EXTRA_INFORMATION]?: Record<string, unknown>;
|
|
38
40
|
};
|
|
39
|
-
export declare abstract class
|
|
40
|
-
/**
|
|
41
|
-
* Base path for HTTP calls
|
|
42
|
-
*/
|
|
43
|
-
protected basePath: string;
|
|
44
|
-
/**
|
|
45
|
-
* Current path for HTTP calls
|
|
46
|
-
*/
|
|
47
|
-
protected path: string;
|
|
41
|
+
export declare abstract class AbstractRestfulClient extends AbstractHttpClient {
|
|
48
42
|
/**
|
|
49
43
|
* Axios instance for client
|
|
50
44
|
*/
|
|
51
45
|
protected client: AxiosInstance;
|
|
52
|
-
/**
|
|
53
|
-
* ArrowSphere API URL
|
|
54
|
-
*/
|
|
55
|
-
protected url: string;
|
|
56
46
|
/**
|
|
57
47
|
* ArrowSphere API key
|
|
58
48
|
*/
|
|
@@ -75,7 +65,7 @@ export declare abstract class AbstractClient {
|
|
|
75
65
|
protected headers: Headers;
|
|
76
66
|
/**
|
|
77
67
|
* AbstractClient constructor.
|
|
78
|
-
* @returns
|
|
68
|
+
* @returns AbstractRestfulClient
|
|
79
69
|
*/
|
|
80
70
|
protected constructor(configuration?: ConfigurationsClient);
|
|
81
71
|
/**
|
|
@@ -84,12 +74,6 @@ export declare abstract class AbstractClient {
|
|
|
84
74
|
* @returns this
|
|
85
75
|
*/
|
|
86
76
|
setApiKey(key: string): this;
|
|
87
|
-
/**
|
|
88
|
-
* Sets the client ArrowSphere API url
|
|
89
|
-
* @param url - API url
|
|
90
|
-
* @returns this
|
|
91
|
-
*/
|
|
92
|
-
setUrl(url: string): this;
|
|
93
77
|
/**
|
|
94
78
|
* Returns the API url.
|
|
95
79
|
* @returns string
|
|
@@ -104,13 +88,13 @@ export declare abstract class AbstractClient {
|
|
|
104
88
|
/**
|
|
105
89
|
* Sets the page number
|
|
106
90
|
* @param page - Page number
|
|
107
|
-
* @returns
|
|
91
|
+
* @returns AbstractRestfulClient
|
|
108
92
|
*/
|
|
109
93
|
setPage(page: number): this;
|
|
110
94
|
/**
|
|
111
95
|
* Sets Header Information
|
|
112
96
|
* @param headers - Header axios information
|
|
113
|
-
* @returns
|
|
97
|
+
* @returns AbstractRestfulClient
|
|
114
98
|
*/
|
|
115
99
|
setHeaders(headers: Record<string, string>): this;
|
|
116
100
|
/**
|
|
@@ -3,17 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.AbstractRestfulClient = exports.ExtraInformationFields = exports.ParameterKeys = void 0;
|
|
7
7
|
const exception_1 = require("./exception");
|
|
8
8
|
const querystring_1 = __importDefault(require("querystring"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const axiosSingleton_1 = require("./axiosSingleton");
|
|
11
|
+
const AbstractHttpClient_1 = require("./AbstractHttpClient");
|
|
11
12
|
/**
|
|
12
13
|
* Lists of available query parameters for the API call
|
|
13
14
|
*/
|
|
14
15
|
var ParameterKeys;
|
|
15
16
|
(function (ParameterKeys) {
|
|
16
17
|
ParameterKeys["API_KEY"] = "apiKey";
|
|
18
|
+
ParameterKeys["AUTHORIZATION"] = "Authorization";
|
|
17
19
|
ParameterKeys["HEADERS"] = "headers";
|
|
18
20
|
ParameterKeys["ORDER_BY"] = "order_by";
|
|
19
21
|
ParameterKeys["PAGE"] = "page";
|
|
@@ -26,25 +28,14 @@ var ExtraInformationFields;
|
|
|
26
28
|
(function (ExtraInformationFields) {
|
|
27
29
|
ExtraInformationFields["COLUMN_EXTRA_INFORMATION"] = "extraInformation";
|
|
28
30
|
})(ExtraInformationFields = exports.ExtraInformationFields || (exports.ExtraInformationFields = {}));
|
|
29
|
-
class
|
|
31
|
+
class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
|
|
30
32
|
/**
|
|
31
33
|
* AbstractClient constructor.
|
|
32
|
-
* @returns
|
|
34
|
+
* @returns AbstractRestfulClient
|
|
33
35
|
*/
|
|
34
36
|
constructor(configuration) {
|
|
35
37
|
var _a, _b, _c;
|
|
36
|
-
|
|
37
|
-
* Base path for HTTP calls
|
|
38
|
-
*/
|
|
39
|
-
this.basePath = '';
|
|
40
|
-
/**
|
|
41
|
-
* Current path for HTTP calls
|
|
42
|
-
*/
|
|
43
|
-
this.path = '';
|
|
44
|
-
/**
|
|
45
|
-
* ArrowSphere API URL
|
|
46
|
-
*/
|
|
47
|
-
this.url = '';
|
|
38
|
+
super();
|
|
48
39
|
/**
|
|
49
40
|
* ArrowSphere API key
|
|
50
41
|
*/
|
|
@@ -79,15 +70,6 @@ class AbstractClient {
|
|
|
79
70
|
this.apiKey = key;
|
|
80
71
|
return this;
|
|
81
72
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Sets the client ArrowSphere API url
|
|
84
|
-
* @param url - API url
|
|
85
|
-
* @returns this
|
|
86
|
-
*/
|
|
87
|
-
setUrl(url) {
|
|
88
|
-
this.url = url;
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
73
|
/**
|
|
92
74
|
* Returns the API url.
|
|
93
75
|
* @returns string
|
|
@@ -107,7 +89,7 @@ class AbstractClient {
|
|
|
107
89
|
/**
|
|
108
90
|
* Sets the page number
|
|
109
91
|
* @param page - Page number
|
|
110
|
-
* @returns
|
|
92
|
+
* @returns AbstractRestfulClient
|
|
111
93
|
*/
|
|
112
94
|
setPage(page) {
|
|
113
95
|
this.page = page;
|
|
@@ -116,7 +98,7 @@ class AbstractClient {
|
|
|
116
98
|
/**
|
|
117
99
|
* Sets Header Information
|
|
118
100
|
* @param headers - Header axios information
|
|
119
|
-
* @returns
|
|
101
|
+
* @returns AbstractRestfulClient
|
|
120
102
|
*/
|
|
121
103
|
setHeaders(headers) {
|
|
122
104
|
this.headers = headers;
|
|
@@ -156,9 +138,12 @@ class AbstractClient {
|
|
|
156
138
|
* @returns {@link Headers}
|
|
157
139
|
*/
|
|
158
140
|
prepareHeaders(headers) {
|
|
141
|
+
const securityHeader = this.security === AbstractHttpClient_1.HttpClientSecurity.API_KEY
|
|
142
|
+
? { [ParameterKeys.API_KEY]: this.apiKey }
|
|
143
|
+
: { [ParameterKeys.AUTHORIZATION]: this.token };
|
|
159
144
|
return {
|
|
160
145
|
...headers,
|
|
161
|
-
|
|
146
|
+
...securityHeader,
|
|
162
147
|
...this.headers,
|
|
163
148
|
};
|
|
164
149
|
}
|
|
@@ -252,5 +237,5 @@ class AbstractClient {
|
|
|
252
237
|
return params;
|
|
253
238
|
}
|
|
254
239
|
}
|
|
255
|
-
exports.
|
|
256
|
-
//# sourceMappingURL=
|
|
240
|
+
exports.AbstractRestfulClient = AbstractRestfulClient;
|
|
241
|
+
//# sourceMappingURL=abstractRestfulClient.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractRestfulClient, Parameters } from '../abstractRestfulClient';
|
|
2
2
|
import { GetResult } from '../getResult';
|
|
3
3
|
import { Campaign } from './entities/campaign/campaign';
|
|
4
4
|
import { CampaignV2 } from './entities/v2/campaign/campaign';
|
|
@@ -15,7 +15,7 @@ export declare type PostEmailCampaignType = {
|
|
|
15
15
|
export declare type PostEmailCampaignMetadataType = {
|
|
16
16
|
[keys in string]: string;
|
|
17
17
|
};
|
|
18
|
-
export declare class CampaignClient extends
|
|
18
|
+
export declare class CampaignClient extends AbstractRestfulClient {
|
|
19
19
|
/**
|
|
20
20
|
* The base path of the API
|
|
21
21
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CampaignClient = exports.PostEmailCampaignFields = void 0;
|
|
4
|
-
const
|
|
4
|
+
const abstractRestfulClient_1 = require("../abstractRestfulClient");
|
|
5
5
|
const getResult_1 = require("../getResult");
|
|
6
6
|
const campaign_1 = require("./entities/campaign/campaign");
|
|
7
7
|
const campaign_2 = require("./entities/v2/campaign/campaign");
|
|
@@ -12,7 +12,7 @@ var PostEmailCampaignFields;
|
|
|
12
12
|
PostEmailCampaignFields["COLUMN_APPLICATION"] = "application";
|
|
13
13
|
PostEmailCampaignFields["COLUMN_METADATA"] = "metadata";
|
|
14
14
|
})(PostEmailCampaignFields = exports.PostEmailCampaignFields || (exports.PostEmailCampaignFields = {}));
|
|
15
|
-
class CampaignClient extends
|
|
15
|
+
class CampaignClient extends abstractRestfulClient_1.AbstractRestfulClient {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
18
18
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractRestfulClient, Parameters } from '../abstractRestfulClient';
|
|
2
2
|
import { GetResult } from '../getResult';
|
|
3
3
|
import { Item, ItemList } from './entities';
|
|
4
4
|
export declare enum ItemRequestFields {
|
|
@@ -23,7 +23,7 @@ export declare type ItemRequestType = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare type ItemAddRequestType = ItemRequestType;
|
|
25
25
|
export declare type ItemUpdateRequestType = ItemRequestType;
|
|
26
|
-
export declare class CartClient extends
|
|
26
|
+
export declare class CartClient extends AbstractRestfulClient {
|
|
27
27
|
protected basePath: string;
|
|
28
28
|
addItem(postData: ItemAddRequestType, parameters?: Parameters): Promise<GetResult<Item>>;
|
|
29
29
|
updateItem(itemId: string, postData: ItemUpdateRequestType, parameters?: Parameters): Promise<GetResult<Item>>;
|
package/build/cart/cartClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CartClient = exports.ItemAdditionalDataRequestFields = exports.ItemRequestFields = void 0;
|
|
4
|
-
const
|
|
4
|
+
const abstractRestfulClient_1 = require("../abstractRestfulClient");
|
|
5
5
|
const getResult_1 = require("../getResult");
|
|
6
6
|
const entities_1 = require("./entities");
|
|
7
7
|
var ItemRequestFields;
|
|
@@ -16,7 +16,7 @@ var ItemAdditionalDataRequestFields;
|
|
|
16
16
|
ItemAdditionalDataRequestFields["NAME"] = "name";
|
|
17
17
|
ItemAdditionalDataRequestFields["VALUE"] = "value";
|
|
18
18
|
})(ItemAdditionalDataRequestFields = exports.ItemAdditionalDataRequestFields || (exports.ItemAdditionalDataRequestFields = {}));
|
|
19
|
-
class CartClient extends
|
|
19
|
+
class CartClient extends abstractRestfulClient_1.AbstractRestfulClient {
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
22
|
this.basePath = '/cart';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractRestfulClient, Parameters } from '../abstractRestfulClient';
|
|
2
2
|
import { GetResult } from '../getResult';
|
|
3
3
|
import { Program } from './entities/program';
|
|
4
4
|
import { Programs } from './entities/programs';
|
|
5
|
-
export declare class CatalogClient extends
|
|
5
|
+
export declare class CatalogClient extends AbstractRestfulClient {
|
|
6
6
|
/**
|
|
7
7
|
* The base path of the API
|
|
8
8
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CatalogClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const abstractRestfulClient_1 = require("../abstractRestfulClient");
|
|
5
5
|
const getResult_1 = require("../getResult");
|
|
6
6
|
const program_1 = require("./entities/program");
|
|
7
7
|
const programs_1 = require("./entities/programs");
|
|
8
|
-
class CatalogClient extends
|
|
8
|
+
class CatalogClient extends abstractRestfulClient_1.AbstractRestfulClient {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractGraphQLClient } from '../abstractGraphQLClient';
|
|
2
2
|
import { GetProductsType } from './types/catalogGraphQLTypes';
|
|
3
|
+
import { CatalogQuery } from './types/catalogGraphQLQueries';
|
|
3
4
|
export declare class CatalogGraphQLClient extends AbstractGraphQLClient {
|
|
4
5
|
/**
|
|
5
6
|
* The base path of the API
|
|
@@ -10,4 +11,5 @@ export declare class CatalogGraphQLClient extends AbstractGraphQLClient {
|
|
|
10
11
|
*/
|
|
11
12
|
private GRAPHQL;
|
|
12
13
|
find(request: string): Promise<GetProductsType>;
|
|
14
|
+
findByQuery(query: CatalogQuery): Promise<GetProductsType | null>;
|
|
13
15
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CatalogGraphQLClient = void 0;
|
|
4
4
|
const abstractGraphQLClient_1 = require("../abstractGraphQLClient");
|
|
5
|
-
// import { inspect } from 'util';
|
|
6
5
|
class CatalogGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
|
|
7
6
|
constructor() {
|
|
8
7
|
super(...arguments);
|
|
@@ -19,6 +18,20 @@ class CatalogGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient
|
|
|
19
18
|
this.path = this.GRAPHQL;
|
|
20
19
|
return await this.post(request);
|
|
21
20
|
}
|
|
21
|
+
async findByQuery(query) {
|
|
22
|
+
const queryStr = this.stringifyQuery(query);
|
|
23
|
+
try {
|
|
24
|
+
return await this.find(queryStr);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const exception = this.mapToPublicApiException(error);
|
|
28
|
+
const { mustRetry } = await this.handleError(exception);
|
|
29
|
+
if (mustRetry) {
|
|
30
|
+
return await this.find(queryStr);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
22
35
|
}
|
|
23
36
|
exports.CatalogGraphQLClient = CatalogGraphQLClient;
|
|
24
37
|
//# sourceMappingURL=catalogGraphQLClient.js.map
|
package/build/catalog/index.d.ts
CHANGED
package/build/catalog/index.js
CHANGED
|
@@ -19,4 +19,6 @@ __exportStar(require("./catalogClient"), exports);
|
|
|
19
19
|
__exportStar(require("./types/catalogGraphQLTypes"), exports);
|
|
20
20
|
__exportStar(require("./entities/program"), exports);
|
|
21
21
|
__exportStar(require("./entities/programs"), exports);
|
|
22
|
+
__exportStar(require("./types/catalogGraphQLQueries"), exports);
|
|
23
|
+
__exportStar(require("./types/catalogGraphQLSchemas"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QueryArguments } from './queryArguments';
|
|
2
|
+
import { FiltersSchema, PaginationSchema, ProductSchema } from './catalogGraphQLSchemas';
|
|
3
|
+
export declare type CatalogQuery = {
|
|
4
|
+
getProducts: GetPaginatedProductsQuery;
|
|
5
|
+
};
|
|
6
|
+
export declare type GetPaginatedProductsQuery = {
|
|
7
|
+
__args: QueryArguments;
|
|
8
|
+
filters?: FiltersSchema;
|
|
9
|
+
pagination?: PaginationSchema;
|
|
10
|
+
products?: ProductSchema;
|
|
11
|
+
topOffers?: ProductSchema;
|
|
12
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AttributeType, FiltersType, IdentifiersType, PaginationType, PriceBandType, PricesType, ProductType, RelatedOfferType } from './catalogGraphQLTypes';
|
|
2
|
+
import { Merge, Schema } from 'type-fest';
|
|
3
|
+
export declare type PaginationSchema = Schema<PaginationType, boolean>;
|
|
4
|
+
export declare type FiltersSchema = Schema<FiltersType, boolean>;
|
|
5
|
+
declare type IdentifiersSchema = Schema<IdentifiersType, boolean>;
|
|
6
|
+
declare type RelatedOfferSchema = Schema<RelatedOfferType, boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Field of type array are not handled by Schema, they must be overwritten
|
|
9
|
+
*/
|
|
10
|
+
declare type MissingFieldsOfProductSchema = {
|
|
11
|
+
addonPrimaries?: IdentifiersSchema;
|
|
12
|
+
baseOfferPrimaries?: IdentifiersSchema;
|
|
13
|
+
conversionOfferPrimaries?: IdentifiersSchema;
|
|
14
|
+
relatedOffers?: RelatedOfferSchema;
|
|
15
|
+
priceBand?: PriceBandSchema;
|
|
16
|
+
};
|
|
17
|
+
export declare type ProductSchema = Merge<Schema<ProductType, boolean>, MissingFieldsOfProductSchema>;
|
|
18
|
+
declare type AttributeSchema = Schema<AttributeType, boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Field of type array are not handled by Schema, they must be overwritten
|
|
21
|
+
*/
|
|
22
|
+
declare type MissingFieldsOfPriceBandSchema = {
|
|
23
|
+
attributes?: Array<AttributeSchema>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* No type corresponding
|
|
27
|
+
*/
|
|
28
|
+
export declare type PriceBandSchema = Merge<Schema<PriceBandType, boolean>, MissingFieldsOfPriceBandSchema>;
|
|
29
|
+
export declare type PriceBandPriceSchema = Schema<PricesType, boolean>;
|
|
30
|
+
export {};
|