@arrowsphere/api-client 3.55.0-rc.fdi.1 → 3.55.0-rc.fdi.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,12 @@
1
1
  import { GraphQLClient } from 'graphql-request';
2
2
  import * as Dom from 'graphql-request/dist/types.dom';
3
- import { Options } from './abstractRestfulClient';
3
+ import { Options, ParameterKeys } from './abstractRestfulClient';
4
4
  import { GetProductsType } from './catalog';
5
5
  import { AbstractHttpClient } from './AbstractHttpClient';
6
6
  export declare type GraphQLResponseTypes = GetProductsType;
7
+ export declare type ConfigurationsGraphQLClient = {
8
+ [ParameterKeys.IS_LOGGING]?: boolean;
9
+ };
7
10
  export declare abstract class AbstractGraphQLClient extends AbstractHttpClient {
8
11
  /**
9
12
  * Must not be called directly.
@@ -12,9 +15,12 @@ export declare abstract class AbstractGraphQLClient extends AbstractHttpClient {
12
15
  protected graphQLClient: GraphQLClient;
13
16
  protected optionsHeader?: Dom.RequestInit['headers'];
14
17
  protected options: Options;
18
+ protected isLogging: boolean;
19
+ constructor(configuration?: ConfigurationsGraphQLClient);
15
20
  private getClientInstance;
16
21
  setOptions(options: Options): this;
17
22
  protected post<GraphQLResponseTypes>(query: string): Promise<GraphQLResponseTypes>;
23
+ private request;
18
24
  private applyHeaders;
19
25
  private generateUrl;
20
26
  protected stringifyQuery(query: any): string;
@@ -25,13 +25,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.AbstractGraphQLClient = void 0;
27
27
  const graphql_request_1 = require("graphql-request");
28
+ const abstractRestfulClient_1 = require("./abstractRestfulClient");
28
29
  const path = __importStar(require("path"));
29
30
  const json_to_graphql_query_1 = require("json-to-graphql-query");
30
31
  const AbstractHttpClient_1 = require("./AbstractHttpClient");
31
32
  class AbstractGraphQLClient extends AbstractHttpClient_1.AbstractHttpClient {
32
- constructor() {
33
- super(...arguments);
33
+ constructor(configuration) {
34
+ super();
34
35
  this.options = {};
36
+ this.isLogging = configuration
37
+ ? !!configuration[abstractRestfulClient_1.ParameterKeys.IS_LOGGING]
38
+ : false;
35
39
  }
36
40
  getClientInstance() {
37
41
  var _a;
@@ -44,7 +48,7 @@ class AbstractGraphQLClient extends AbstractHttpClient_1.AbstractHttpClient {
44
48
  async post(query) {
45
49
  try {
46
50
  this.applyHeaders();
47
- return await this.getClientInstance().request(query);
51
+ return await this.request(query);
48
52
  }
49
53
  catch (error) {
50
54
  const exception = this.mapToPublicApiException(error);
@@ -56,6 +60,16 @@ class AbstractGraphQLClient extends AbstractHttpClient_1.AbstractHttpClient {
56
60
  throw error;
57
61
  }
58
62
  }
63
+ async request(query) {
64
+ if (this.isLogging) {
65
+ console.info('GRAPHQL - Query : ', query);
66
+ }
67
+ const response = await this.getClientInstance().request(query);
68
+ if (this.isLogging) {
69
+ console.info('GRAPHQL - Response : ', response);
70
+ }
71
+ return response;
72
+ }
59
73
  applyHeaders() {
60
74
  const headers = {
61
75
  authorization: this.token,
@@ -12,7 +12,9 @@ class AccountGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient
12
12
  }
13
13
  async findByQuery(query) {
14
14
  this.path = '/graphql';
15
+ console.info('GRAPHQL Query brut :', query);
15
16
  const queryStr = this.stringifyQuery(query);
17
+ console.info('GRAPHQL Query after stringify :', query);
16
18
  try {
17
19
  return await this.post(queryStr);
18
20
  }
@@ -1,14 +1,15 @@
1
1
  import { CatalogGraphQLClient } from './catalog';
2
- import { AbstractGraphQLClient } from './abstractGraphQLClient';
2
+ import { AbstractGraphQLClient, ConfigurationsGraphQLClient } from './abstractGraphQLClient';
3
3
  import { SecurityScoreGraphQLClient } from './securityScore';
4
4
  import { GraphqlApiClient } from './graphqlApi';
5
5
  import { WellArchitectedGraphQLClient } from './wellArchitected';
6
6
  import { AccountGraphQLClient } from './account';
7
7
  export declare class PublicGraphQLClient extends AbstractGraphQLClient {
8
- getCatalogGraphQLClient(): CatalogGraphQLClient;
9
- getSecurityScoreGraphQLClient(): SecurityScoreGraphQLClient;
10
- getWellArchitectedGraphQLClient(): WellArchitectedGraphQLClient;
11
- getGraphqlApiClient(): GraphqlApiClient;
12
- getGraphqlAccountClient(): AccountGraphQLClient;
8
+ constructor();
9
+ getCatalogGraphQLClient(configuration?: ConfigurationsGraphQLClient): CatalogGraphQLClient;
10
+ getSecurityScoreGraphQLClient(configuration?: ConfigurationsGraphQLClient): SecurityScoreGraphQLClient;
11
+ getWellArchitectedGraphQLClient(configuration?: ConfigurationsGraphQLClient): WellArchitectedGraphQLClient;
12
+ getGraphqlApiClient(configuration?: ConfigurationsGraphQLClient): GraphqlApiClient;
13
+ getGraphqlAccountClient(configuration?: ConfigurationsGraphQLClient): AccountGraphQLClient;
13
14
  private applyConfig;
14
15
  }
@@ -8,28 +8,31 @@ const graphqlApi_1 = require("./graphqlApi");
8
8
  const wellArchitected_1 = require("./wellArchitected");
9
9
  const account_1 = require("./account");
10
10
  class PublicGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
11
- getCatalogGraphQLClient() {
12
- const client = new catalog_1.CatalogGraphQLClient();
11
+ constructor() {
12
+ super();
13
+ }
14
+ getCatalogGraphQLClient(configuration) {
15
+ const client = new catalog_1.CatalogGraphQLClient(configuration);
13
16
  this.applyConfig(client);
14
17
  return client;
15
18
  }
16
- getSecurityScoreGraphQLClient() {
17
- const client = new securityScore_1.SecurityScoreGraphQLClient();
19
+ getSecurityScoreGraphQLClient(configuration) {
20
+ const client = new securityScore_1.SecurityScoreGraphQLClient(configuration);
18
21
  this.applyConfig(client);
19
22
  return client;
20
23
  }
21
- getWellArchitectedGraphQLClient() {
22
- const client = new wellArchitected_1.WellArchitectedGraphQLClient();
24
+ getWellArchitectedGraphQLClient(configuration) {
25
+ const client = new wellArchitected_1.WellArchitectedGraphQLClient(configuration);
23
26
  this.applyConfig(client);
24
27
  return client;
25
28
  }
26
- getGraphqlApiClient() {
27
- const client = new graphqlApi_1.GraphqlApiClient();
29
+ getGraphqlApiClient(configuration) {
30
+ const client = new graphqlApi_1.GraphqlApiClient(configuration);
28
31
  this.applyConfig(client);
29
32
  return client;
30
33
  }
31
- getGraphqlAccountClient() {
32
- const client = new account_1.AccountGraphQLClient();
34
+ getGraphqlAccountClient(configuration) {
35
+ const client = new account_1.AccountGraphQLClient(configuration);
33
36
  this.applyConfig(client);
34
37
  return client;
35
38
  }
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.55.0-rc.fdi.1",
7
+ "version": "3.55.0-rc.fdi.3",
8
8
  "description": "Node.js client for ArrowSphere's public API",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",