@arrowsphere/api-client 3.29.0-rc.uts.1 → 3.30.0-rc.bdj.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/abstractClient.d.ts +3 -19
- package/build/abstractClient.js +8 -23
- package/build/abstractGraphQLClient.d.ts +4 -14
- package/build/abstractGraphQLClient.js +32 -23
- 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/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/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/licenses/entities/findResult.d.ts +1 -1
- package/build/licenses/entities/findResult.js +1 -1
- 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 +48 -0
- package/build/securityScore/entities/getPartnerData.js +109 -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 +63 -0
- package/build/securityScore/types/securityScoreGraphQLQueries.js +7 -0
- package/build/securityScore/types/securityScoreGraphQLSchemas.d.ts +92 -0
- package/build/securityScore/types/securityScoreGraphQLSchemas.js +3 -0
- package/build/securityScore/types/securityScoreGraphQLTypes.d.ts +225 -0
- package/build/securityScore/types/securityScoreGraphQLTypes.js +3 -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,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 AbstractClient {
|
|
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 AbstractClient 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
|
*/
|
|
@@ -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
|
package/build/abstractClient.js
CHANGED
|
@@ -8,12 +8,14 @@ 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 AbstractClient {
|
|
31
|
+
class AbstractClient extends AbstractHttpClient_1.AbstractHttpClient {
|
|
30
32
|
/**
|
|
31
33
|
* AbstractClient constructor.
|
|
32
34
|
* @returns AbstractClient
|
|
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
|
|
@@ -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
|
}
|
|
@@ -2,26 +2,16 @@ import { GraphQLClient } from 'graphql-request';
|
|
|
2
2
|
import * as Dom from 'graphql-request/dist/types.dom';
|
|
3
3
|
import { Options } from './abstractClient';
|
|
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,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 {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For field __args
|
|
3
|
+
*/
|
|
4
|
+
export declare type QueryArguments = {
|
|
5
|
+
paginate?: PaginateArgument;
|
|
6
|
+
searchBody: SearchBodyArgument;
|
|
7
|
+
};
|
|
8
|
+
export declare type PaginateArgument = {
|
|
9
|
+
page: number;
|
|
10
|
+
perPage: number;
|
|
11
|
+
};
|
|
12
|
+
export declare type SearchBodyArgument = {
|
|
13
|
+
aggregatorFilter?: string[];
|
|
14
|
+
endCustomerRef?: string;
|
|
15
|
+
exclusionFilters?: SearchFilterArgument[];
|
|
16
|
+
filters?: SearchFilterArgument[];
|
|
17
|
+
getFamilies?: boolean;
|
|
18
|
+
highlight?: boolean;
|
|
19
|
+
keywords?: string;
|
|
20
|
+
marketplace?: string;
|
|
21
|
+
quantity?: number;
|
|
22
|
+
resellerRef?: string;
|
|
23
|
+
restricted?: boolean;
|
|
24
|
+
sort?: SortArgument;
|
|
25
|
+
topOffers?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare type SearchFilterArgument = {
|
|
28
|
+
name: string;
|
|
29
|
+
value: string | string[];
|
|
30
|
+
operator?: OperatorArgument;
|
|
31
|
+
filters?: SearchFilterArgument[];
|
|
32
|
+
};
|
|
33
|
+
export declare enum OperatorArgument {
|
|
34
|
+
OR = "OR",
|
|
35
|
+
AND = "AND",
|
|
36
|
+
BETWEEN = "BETWEEN"
|
|
37
|
+
}
|
|
38
|
+
export declare type SortArgument = {
|
|
39
|
+
name?: string;
|
|
40
|
+
order?: string;
|
|
41
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperatorArgument = void 0;
|
|
4
|
+
var OperatorArgument;
|
|
5
|
+
(function (OperatorArgument) {
|
|
6
|
+
OperatorArgument["OR"] = "OR";
|
|
7
|
+
OperatorArgument["AND"] = "AND";
|
|
8
|
+
OperatorArgument["BETWEEN"] = "BETWEEN";
|
|
9
|
+
})(OperatorArgument = exports.OperatorArgument || (exports.OperatorArgument = {}));
|
|
10
|
+
//# sourceMappingURL=queryArguments.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HandleHttpExceptionOutput } from './HandleHttpExceptionOutput';
|
|
2
|
+
import { Hooks } from './Hooks';
|
|
3
|
+
import { PublicApiClientException } from '../publicApiClientException';
|
|
4
|
+
/**
|
|
5
|
+
* Implementations can be outside of this project to inject other dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export interface HttpExceptionHandler {
|
|
8
|
+
handle(error: PublicApiClientException, hooks: Hooks): Promise<HandleHttpExceptionOutput>;
|
|
9
|
+
getHandledHttpStatuses(): number[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./HttpExceptionHandler"), exports);
|
|
18
|
+
__exportStar(require("./HandleHttpExceptionOutput"), exports);
|
|
19
|
+
__exportStar(require("./Hooks"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare class PublicApiClientException extends Error {
|
|
2
2
|
httpCode: number;
|
|
3
3
|
httpError: string;
|
|
4
|
-
|
|
4
|
+
config?: any;
|
|
5
|
+
constructor(message: string, httpError?: string, httpCode?: number, config?: {});
|
|
5
6
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PublicApiClientException = void 0;
|
|
4
4
|
class PublicApiClientException extends Error {
|
|
5
|
-
constructor(message, httpError = '', httpCode = 0) {
|
|
5
|
+
constructor(message, httpError = '', httpCode = 0, config = {}) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.httpCode = httpCode;
|
|
8
8
|
this.httpError = httpError;
|
|
9
|
+
this.config = config;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.PublicApiClientException = PublicApiClientException;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __exportStar(require("./shared/"), exports);
|
|
|
48
48
|
__exportStar(require("./security/"), exports);
|
|
49
49
|
__exportStar(require("./subscriptions/"), exports);
|
|
50
50
|
__exportStar(require("./supportCenter/"), exports);
|
|
51
|
+
__exportStar(require("./securityScore/"), exports);
|
|
51
52
|
const ContactInformation = __importStar(require("./contact"));
|
|
52
53
|
exports.ContactInformation = ContactInformation;
|
|
53
54
|
//# sourceMappingURL=index.js.map
|