@arrowsphere/api-client 3.28.0-rc.bdj.2 → 3.28.0-rc.bjp.2

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
@@ -50,6 +50,17 @@ 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
+
53
64
  - [SecurityScore](./src/securityScore/README.md)
54
65
 
55
66
  ### Licenses
@@ -32,4 +32,5 @@ export declare abstract class AbstractHttpClient {
32
32
  * Will find appropriate ErrorHandlers and apply them to the error in order of registering.
33
33
  */
34
34
  protected handleError(error: PublicApiClientException): Promise<HandleHttpExceptionOutput>;
35
+ protected mapToPublicApiException(error: any): PublicApiClientException;
35
36
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractHttpClient = void 0;
4
+ const exception_1 = require("./exception");
4
5
  class AbstractHttpClient {
5
6
  constructor() {
6
7
  /**
@@ -44,11 +45,7 @@ class AbstractHttpClient {
44
45
  * Will find appropriate ErrorHandlers and apply them to the error in order of registering.
45
46
  */
46
47
  async handleError(error) {
47
- const appropriateHandlers = this.httpExceptionHandlers.filter((handler) => {
48
- console.log('httpStatus', error.httpCode);
49
- const res = handler.getHandledHttpStatuses().includes(error.httpCode);
50
- return res;
51
- });
48
+ const appropriateHandlers = this.httpExceptionHandlers.filter((handler) => handler.getHandledHttpStatuses().includes(error.httpCode));
52
49
  // handle retry
53
50
  const output = { mustRetry: false };
54
51
  for (const handler of appropriateHandlers) {
@@ -59,6 +56,10 @@ class AbstractHttpClient {
59
56
  }
60
57
  return output;
61
58
  }
59
+ mapToPublicApiException(error) {
60
+ var _a, _b;
61
+ 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);
62
+ }
62
63
  }
63
64
  exports.AbstractHttpClient = AbstractHttpClient;
64
65
  //# sourceMappingURL=AbstractHttpClient.js.map
@@ -1,7 +1,9 @@
1
1
  import { GraphQLClient } from 'graphql-request';
2
2
  import * as Dom from 'graphql-request/dist/types.dom';
3
3
  import { Options } from './abstractClient';
4
+ import { GetProductsType } from './catalog';
4
5
  import { AbstractHttpClient } from './AbstractHttpClient';
6
+ export declare type GraphQLResponseTypes = GetProductsType;
5
7
  export declare abstract class AbstractGraphQLClient extends AbstractHttpClient {
6
8
  protected client: GraphQLClient;
7
9
  protected optionsHeader?: Dom.RequestInit['headers'];
@@ -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
@@ -1,2 +1,4 @@
1
1
  export * from './catalogGraphQLClient';
2
2
  export * from './types/catalogGraphQLTypes';
3
+ export * from './types/catalogGraphQLQueries';
4
+ export * from './types/catalogGraphQLSchemas';
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./catalogGraphQLClient"), exports);
18
18
  __exportStar(require("./types/catalogGraphQLTypes"), exports);
19
+ __exportStar(require("./types/catalogGraphQLQueries"), exports);
20
+ __exportStar(require("./types/catalogGraphQLSchemas"), exports);
19
21
  //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=catalogGraphQLQueries.js.map
@@ -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,4 @@
1
+ "use strict";
2
+ // Here are the schemas, they are useful to build the graphql requests
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=catalogGraphQLSchemas.js.map
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
+ // Here are the types, they are useful to have exact types of the responses
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  //# sourceMappingURL=catalogGraphQLTypes.js.map
@@ -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
@@ -1,4 +1,4 @@
1
- import { HandleHttpExceptionOutput } from '././HandleHttpExceptionOutput';
1
+ import { HandleHttpExceptionOutput } from './HandleHttpExceptionOutput';
2
2
  import { Hooks } from './Hooks';
3
3
  import { PublicApiClientException } from '../publicApiClientException';
4
4
  /**
@@ -1,5 +1,6 @@
1
1
  export declare class PublicApiClientException extends Error {
2
2
  httpCode: number;
3
3
  httpError: string;
4
- constructor(message: string, httpError?: string, httpCode?: number);
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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/ArrowSphere/nodejs-api-client.git"
6
6
  },
7
- "version": "3.28.0-rc.bdj.2",
7
+ "version": "3.28.0-rc.bjp.2",
8
8
  "description": "Node.js client for ArrowSphere's public API",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",