@arrowsphere/api-client 3.70.0-rc.bdj.4 → 3.70.0-rc.bdj.6

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,6 +1,6 @@
1
1
  import { AbstractGraphQLClient } from '../abstractGraphQLClient';
2
2
  import { ArrowCompanyType, EndCustomerType, PartnerType } from './types/entities/company';
3
- import { SelectAllQueryType, SelectAllResultType, SelectOneQueryType, SelectOneResultType } from './types/graphqlApiQueries';
3
+ import { InputPaginationType, SelectAllQueryType, SelectAllResultType, SelectOneQueryType, SelectOneResultType } from './types/graphqlApiQueries';
4
4
  import { ArrowCompanySchema, EndCustomerSchema, PartnerSchema, SelectOneResponseDataSchema } from './types/graphqlApiSchemas';
5
5
  export declare class GraphqlApiClient extends AbstractGraphQLClient {
6
6
  /**
@@ -10,8 +10,8 @@ export declare class GraphqlApiClient extends AbstractGraphQLClient {
10
10
  find<GraphQLResponseTypes>(request: string): Promise<GraphQLResponseTypes | null>;
11
11
  selectAll(query: SelectAllQueryType): Promise<SelectAllResultType | null>;
12
12
  selectOne(query: SelectOneQueryType): Promise<SelectOneResultType | null>;
13
- findOneById<T>(id: number, fieldSchema: SelectOneResponseDataSchema): Promise<T | null>;
14
- findEndCustomerById(id: number, fields: EndCustomerSchema): Promise<EndCustomerType | null>;
15
- findPartnerById(id: number, fields: PartnerSchema): Promise<PartnerType | null>;
16
- findArrowCompanyById(id: number, fields: ArrowCompanySchema): Promise<ArrowCompanyType | null>;
13
+ findOneById<T>(id: number, fieldSchema: SelectOneResponseDataSchema, pagination?: InputPaginationType): Promise<T | null>;
14
+ findEndCustomerById(id: number, fields: EndCustomerSchema, pagination?: InputPaginationType): Promise<EndCustomerType | null>;
15
+ findPartnerById(id: number, fields: PartnerSchema, pagination?: InputPaginationType): Promise<PartnerType | null>;
16
+ findArrowCompanyById(id: number, fields: ArrowCompanySchema, pagination?: InputPaginationType): Promise<ArrowCompanyType | null>;
17
17
  }
@@ -30,30 +30,43 @@ class GraphqlApiClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
30
30
  const result = await this.find(queryStr);
31
31
  return result;
32
32
  }
33
- async findOneById(id, fieldSchema) {
34
- var _a, _b, _c, _d, _e, _f, _g;
33
+ async findOneById(id, fieldSchema, pagination) {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h;
35
35
  const keys = Object.keys(fieldSchema);
36
36
  if (keys.length === 0) {
37
37
  return null;
38
38
  }
39
39
  const type = keys[0];
40
- const query = {
41
- [graphqlApiQueries_1.Queries.SELECT_ONE]: {
42
- __args: {
43
- [graphqlApiQueries_1.QueryVariablesField.FILTERS]: {
44
- [graphqlApiQueries_1.InputSearchFilterField.GROUPS]: [
40
+ const queryArguments = {
41
+ [graphqlApiQueries_1.QueryVariablesField.FILTERS]: {
42
+ [graphqlApiQueries_1.InputSearchFilterField.GROUPS]: [
43
+ {
44
+ [graphqlApiQueries_1.InputFiltersField.ITEMS]: [
45
45
  {
46
- [graphqlApiQueries_1.InputFiltersField.ITEMS]: [
47
- {
48
- [graphqlApiQueries_1.InputFilterValueField.NAME]: 'id',
49
- [graphqlApiQueries_1.InputFilterValueField.OPERATOR]: graphqlApiQueries_1.ComparisonOperator.EQUALS,
50
- [graphqlApiQueries_1.InputFilterValueField.VALUE]: [`${id}`],
51
- },
52
- ],
46
+ [graphqlApiQueries_1.InputFilterValueField.NAME]: 'id',
47
+ [graphqlApiQueries_1.InputFilterValueField.OPERATOR]: graphqlApiQueries_1.ComparisonOperator.EQUALS,
48
+ [graphqlApiQueries_1.InputFilterValueField.VALUE]: [`${id}`],
53
49
  },
54
50
  ],
55
51
  },
56
- },
52
+ ],
53
+ },
54
+ };
55
+ if ((pagination === null || pagination === void 0 ? void 0 : pagination[graphqlApiQueries_1.InputPaginationField.PER_PAGE]) ||
56
+ (pagination === null || pagination === void 0 ? void 0 : pagination[graphqlApiQueries_1.InputPaginationField.PAGE])) {
57
+ queryArguments[graphqlApiQueries_1.QueryVariablesField.PAGINATION] = {
58
+ [graphqlApiQueries_1.InputPaginationField.PAGE]: (_a = pagination === null || pagination === void 0 ? void 0 : pagination[graphqlApiQueries_1.InputPaginationField.PAGE]) !== null && _a !== void 0 ? _a : 1,
59
+ };
60
+ if (pagination === null || pagination === void 0 ? void 0 : pagination[graphqlApiQueries_1.InputPaginationField.PER_PAGE]) {
61
+ queryArguments[graphqlApiQueries_1.QueryVariablesField.PAGINATION] = {
62
+ ...queryArguments[graphqlApiQueries_1.QueryVariablesField.PAGINATION],
63
+ [graphqlApiQueries_1.InputPaginationField.PER_PAGE]: pagination === null || pagination === void 0 ? void 0 : pagination[graphqlApiQueries_1.InputPaginationField.PER_PAGE],
64
+ };
65
+ }
66
+ }
67
+ const query = {
68
+ [graphqlApiQueries_1.Queries.SELECT_ONE]: {
69
+ __args: queryArguments,
57
70
  [graphqlApiQueries_1.SelectableField.DATA]: fieldSchema,
58
71
  [graphqlApiQueries_1.SelectableField.ERRORS]: {
59
72
  [graphqlApiQueries_1.ErrorsField.MESSAGE]: true,
@@ -62,25 +75,25 @@ class GraphqlApiClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
62
75
  };
63
76
  const queryStr = this.stringifyQuery(query);
64
77
  const result = await this.find(queryStr);
65
- if ((_c = (_b = (_a = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _a === void 0 ? void 0 : _a[graphqlApiQueries_1.SelectableField.ERRORS]) === null || _b === void 0 ? void 0 : _b[graphqlApiQueries_1.ErrorsField.MESSAGE]) === null || _c === void 0 ? void 0 : _c.length) {
66
- throw new Error((_e = (_d = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _d === void 0 ? void 0 : _d[graphqlApiQueries_1.SelectableField.ERRORS]) === null || _e === void 0 ? void 0 : _e[graphqlApiQueries_1.ErrorsField.MESSAGE]);
78
+ if ((_d = (_c = (_b = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _b === void 0 ? void 0 : _b[graphqlApiQueries_1.SelectableField.ERRORS]) === null || _c === void 0 ? void 0 : _c[graphqlApiQueries_1.ErrorsField.MESSAGE]) === null || _d === void 0 ? void 0 : _d.length) {
79
+ throw new Error((_f = (_e = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _e === void 0 ? void 0 : _e[graphqlApiQueries_1.SelectableField.ERRORS]) === null || _f === void 0 ? void 0 : _f[graphqlApiQueries_1.ErrorsField.MESSAGE]);
67
80
  }
68
- return (_g = (_f = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _f === void 0 ? void 0 : _f[graphqlApiQueries_1.SelectableField.DATA]) === null || _g === void 0 ? void 0 : _g[type];
81
+ return (_h = (_g = result === null || result === void 0 ? void 0 : result[graphqlApiQueries_1.Queries.SELECT_ONE]) === null || _g === void 0 ? void 0 : _g[graphqlApiQueries_1.SelectableField.DATA]) === null || _h === void 0 ? void 0 : _h[type];
69
82
  }
70
- async findEndCustomerById(id, fields) {
83
+ async findEndCustomerById(id, fields, pagination) {
71
84
  return await this.findOneById(id, {
72
85
  [graphqlApiQueries_1.SelectDataField.END_CUSTOMER]: fields,
73
- });
86
+ }, pagination);
74
87
  }
75
- async findPartnerById(id, fields) {
88
+ async findPartnerById(id, fields, pagination) {
76
89
  return await this.findOneById(id, {
77
90
  [graphqlApiQueries_1.SelectDataField.PARTNER]: fields,
78
- });
91
+ }, pagination);
79
92
  }
80
- async findArrowCompanyById(id, fields) {
93
+ async findArrowCompanyById(id, fields, pagination) {
81
94
  return await this.findOneById(id, {
82
95
  [graphqlApiQueries_1.SelectDataField.ARROW_COMPANY]: fields,
83
- });
96
+ }, pagination);
84
97
  }
85
98
  }
86
99
  exports.GraphqlApiClient = GraphqlApiClient;
@@ -28,6 +28,7 @@ declare type BaseCompanyType = {
28
28
  resellerId?: number;
29
29
  state?: string;
30
30
  vatNumber?: string;
31
+ workgroup?: WorkgroupType;
31
32
  zip?: string;
32
33
  };
33
34
  export declare type EndCustomerType = BaseCompanyType & {
@@ -38,17 +39,18 @@ declare type CountableType = {
38
39
  total?: number;
39
40
  };
40
41
  export declare type PartnerType = BaseCompanyType & {
42
+ contactsCount?: CountableType;
41
43
  country?: CountryType;
42
- type?: CompanyTypeType;
43
- subscriptions?: SubscriptionType[];
44
- workgroup?: WorkgroupType;
45
- subscriptionsPendingCount?: CountableType;
46
- subscriptionsCount?: CountableType;
44
+ customersCount?: CountableType;
45
+ ordersCount?: CountableType;
47
46
  ordersNeedCount?: CountableType;
48
47
  reportsCount?: CountableType;
49
- ordersCount?: CountableType;
50
- customersCount?: CountableType;
51
- contactsCount?: CountableType;
48
+ subscriptions?: SubscriptionType[];
49
+ subscriptionsCount?: CountableType;
50
+ subscriptionsPendingCount?: CountableType;
51
+ type?: CompanyTypeType;
52
+ };
53
+ export declare type ArrowCompanyType = Omit<BaseCompanyType, 'partnerTags'> & {
54
+ subscriptions?: SubscriptionType[];
52
55
  };
53
- export declare type ArrowCompanyType = Omit<BaseCompanyType, 'partnerTags'>;
54
56
  export {};
@@ -200,7 +200,7 @@ export declare enum Queries {
200
200
  }
201
201
  export declare type SelectOneQueryType = {
202
202
  [Queries.SELECT_ONE]: {
203
- __args?: Omit<QueryVariablesType, QueryVariablesField.PAGINATION>;
203
+ __args?: QueryVariablesType;
204
204
  [SelectableField.DATA]: SelectOneResponseDataSchema;
205
205
  [SelectableField.ERRORS]?: ErrorsSchema;
206
206
  };
@@ -13,6 +13,9 @@ declare type MissingFieldsOfCompanySchema = {
13
13
  partnerTags?: PartnertagSchema;
14
14
  subscriptions?: SubscriptionSchema;
15
15
  };
16
+ declare type MissingFieldsOfArrowCompanySchema = {
17
+ subscriptions?: SubscriptionSchema;
18
+ };
16
19
  declare type MissingFieldsOfEndCustomerSchema = {
17
20
  contacts?: ContactsSchema;
18
21
  partnerTags?: PartnertagSchema;
@@ -20,8 +23,8 @@ declare type MissingFieldsOfEndCustomerSchema = {
20
23
  };
21
24
  export declare type EndCustomerSchema = Merge<Schema<EndCustomerType, boolean>, MissingFieldsOfEndCustomerSchema>;
22
25
  export declare type PartnerSchema = Merge<Schema<PartnerType, boolean>, MissingFieldsOfCompanySchema>;
26
+ export declare type ArrowCompanySchema = Merge<Schema<ArrowCompanyType, boolean>, MissingFieldsOfArrowCompanySchema>;
23
27
  export declare type ContactsSchema = Schema<ContactsType, boolean>;
24
- export declare type ArrowCompanySchema = Schema<ArrowCompanyType, boolean>;
25
28
  export declare type ContinentSchema = Schema<ContinentType, boolean>;
26
29
  export declare type CountrySchema = Schema<CountryType, boolean>;
27
30
  export declare type ErrorsSchema = Schema<ErrorsType, boolean>;
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.70.0-rc.bdj.4",
7
+ "version": "3.70.0-rc.bdj.6",
8
8
  "description": "Node.js client for ArrowSphere's public API",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",