@arrowsphere/api-client 2.7.0 → 2.8.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4
4
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [2.8.0] - 2022-03-03
7
+
8
+ ### Added
9
+
10
+ - Add endpoint graphQL
11
+
6
12
  ## [2.7.0] - 2022-03-03
7
13
 
8
14
  ### Added
@@ -0,0 +1,27 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import * as Dom from 'graphql-request/dist/types.dom';
3
+ import { Options } from './abstractClient';
4
+ import { GetProductsType } from './catalog';
5
+ 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;
15
+ protected client: GraphQLClient;
16
+ protected url: string;
17
+ protected token: string;
18
+ protected optionsHeader?: Dom.RequestInit['headers'];
19
+ protected options: Options;
20
+ private getClient;
21
+ setToken(apiKey: string): this;
22
+ setUrl(url: string): this;
23
+ setOptionsHeader(options: Dom.RequestInit['headers']): this;
24
+ setOptions(options: Options): this;
25
+ protected post(query: string): Promise<GraphQLResponseTypes>;
26
+ protected generateUrl(): string;
27
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AbstractGraphQLClient = void 0;
7
+ const graphql_request_1 = require("graphql-request");
8
+ const url_1 = require("url");
9
+ const path_1 = __importDefault(require("path"));
10
+ class AbstractGraphQLClient {
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
+ this.url = '';
21
+ this.token = '';
22
+ this.options = {};
23
+ }
24
+ getClient() {
25
+ this.client = new graphql_request_1.GraphQLClient(this.generateUrl());
26
+ return this;
27
+ }
28
+ setToken(apiKey) {
29
+ this.token = apiKey;
30
+ return this;
31
+ }
32
+ setUrl(url) {
33
+ this.url = url;
34
+ return this;
35
+ }
36
+ setOptionsHeader(options) {
37
+ this.optionsHeader = options;
38
+ return this;
39
+ }
40
+ setOptions(options) {
41
+ this.options = options;
42
+ return this;
43
+ }
44
+ async post(query) {
45
+ this.getClient().client.setHeaders({
46
+ authorization: this.token,
47
+ ...this.optionsHeader,
48
+ });
49
+ return await this.client.request(query);
50
+ }
51
+ generateUrl() {
52
+ const url = new url_1.URL(`${this.options.isAdmin ? path_1.default.join('admin', this.basePath) : this.basePath}${this.path}`, this.url);
53
+ return url.toString();
54
+ }
55
+ }
56
+ exports.AbstractGraphQLClient = AbstractGraphQLClient;
57
+ //# sourceMappingURL=abstractGraphQLClient.js.map
@@ -0,0 +1,17 @@
1
+ import { AbstractGraphQLClient } from '../abstractGraphQLClient';
2
+ import { GetProductsType } from './types/catalogGraphQLTypes';
3
+ export declare class CatalogGraphQLClient extends AbstractGraphQLClient {
4
+ /**
5
+ * The base path of the Catalog API
6
+ */
7
+ private ROOT_PATH;
8
+ /**
9
+ * The base path of the API
10
+ */
11
+ protected basePath: string;
12
+ /**
13
+ * The Path of graphql catalog API
14
+ */
15
+ private GRAPHQL;
16
+ find(request: string): Promise<GetProductsType>;
17
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CatalogGraphQLClient = void 0;
4
+ const abstractGraphQLClient_1 = require("../abstractGraphQLClient");
5
+ // import { inspect } from 'util';
6
+ class CatalogGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
7
+ constructor() {
8
+ super(...arguments);
9
+ /**
10
+ * The base path of the Catalog API
11
+ */
12
+ this.ROOT_PATH = 'catalog/';
13
+ /**
14
+ * The base path of the API
15
+ */
16
+ this.basePath = this.ROOT_PATH;
17
+ /**
18
+ * The Path of graphql catalog API
19
+ */
20
+ this.GRAPHQL = 'graphql';
21
+ }
22
+ async find(request) {
23
+ this.path = this.GRAPHQL;
24
+ return await this.post(request);
25
+ }
26
+ }
27
+ exports.CatalogGraphQLClient = CatalogGraphQLClient;
28
+ //# sourceMappingURL=catalogGraphQLClient.js.map
@@ -0,0 +1,2 @@
1
+ export * from './types/catalogGraphQLTypes';
2
+ export * from './catalogGraphQLClient';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./types/catalogGraphQLTypes"), exports);
14
+ __exportStar(require("./catalogGraphQLClient"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,224 @@
1
+ export declare type GetProductsType = {
2
+ getProducts?: PaginatedProductsType;
3
+ };
4
+ export declare type PaginatedProductsType = {
5
+ filters?: Array<FiltersType>;
6
+ pagination?: PaginationType;
7
+ products?: Array<ProductType>;
8
+ topOffers?: Array<ProductType>;
9
+ };
10
+ export declare type FiltersType = {
11
+ name?: string;
12
+ values?: FiltersValuesType;
13
+ };
14
+ export declare type FiltersValuesType = {
15
+ value?: string;
16
+ count?: number;
17
+ };
18
+ export declare type PaginationType = {
19
+ perPage?: number;
20
+ currentPage?: number;
21
+ totalPage?: number;
22
+ total?: number;
23
+ next?: string;
24
+ previous?: string;
25
+ };
26
+ export declare type ProductType = {
27
+ id?: string;
28
+ identifiers?: IdentifiersType;
29
+ name?: string;
30
+ classification?: string;
31
+ arrowCategories?: Array<string>;
32
+ arrowSubCategories?: Array<string>;
33
+ licenseAgreementType?: string;
34
+ family?: FamilyType;
35
+ isAddon?: boolean;
36
+ hasAddons?: boolean;
37
+ actionFlags?: ActionFlagsType;
38
+ addonPrimaries?: Array<IdentifiersType>;
39
+ conversionOfferPrimaries?: Array<IdentifiersType>;
40
+ baseOfferPrimaries?: Array<IdentifiersType>;
41
+ assets?: AssetsType;
42
+ environmentAvailability?: string;
43
+ marketplace?: string;
44
+ isEnabled?: boolean;
45
+ isTrial?: boolean;
46
+ isIndirectBusiness?: boolean;
47
+ lastUpdate?: string;
48
+ marketingText?: MarketingTextType;
49
+ vendorOfferUrl?: string;
50
+ serviceDescription?: string;
51
+ eula?: string;
52
+ endCustomerEula?: string;
53
+ endCustomerRequirements?: string;
54
+ endCustomerFeatures?: string;
55
+ xspUrl?: string;
56
+ saleConstraints?: SaleConstraintsType;
57
+ vendor?: VendorType;
58
+ program?: ProgramType;
59
+ weightTopSales?: number;
60
+ weightForced?: number;
61
+ priceBand?: Array<PriceBandType>;
62
+ defaultPriceBand?: PriceBandType;
63
+ relatedOffers?: Array<RelatedOfferType>;
64
+ resellers?: OfferResellersType;
65
+ scope?: string;
66
+ };
67
+ export declare type IdentifiersType = {
68
+ arrowsphere?: ArrowsphereIdentifierType;
69
+ vendor?: VendorIdentifierType;
70
+ };
71
+ export declare type ArrowsphereIdentifierType = {
72
+ sku?: string;
73
+ skuXsp?: string;
74
+ skuXac?: string;
75
+ orderableSku?: string;
76
+ };
77
+ export declare type VendorIdentifierType = {
78
+ name?: string;
79
+ family?: string;
80
+ offerName?: string;
81
+ sku?: string;
82
+ attributes?: AttributesType;
83
+ };
84
+ export declare type AttributesType = {
85
+ cancelSubscription?: boolean;
86
+ canSwitchAutoRenew?: boolean;
87
+ decreaseSeats?: boolean;
88
+ increaseSeats?: boolean;
89
+ partIdentifier?: string;
90
+ periodicity?: number;
91
+ planId?: string;
92
+ productId?: string;
93
+ productSku?: string;
94
+ reactivateSubscription?: boolean;
95
+ suspendSubscription?: boolean;
96
+ term?: number;
97
+ unitType?: string;
98
+ };
99
+ export declare type FamilyType = {
100
+ id?: string;
101
+ name?: string;
102
+ };
103
+ export declare type ActionFlagsType = {
104
+ isAutoRenew?: boolean;
105
+ isManualProvisioning?: boolean;
106
+ renewalSku?: string;
107
+ };
108
+ export declare type AssetsType = {
109
+ featurePictureUrl?: string;
110
+ mainLogoUrl?: string;
111
+ pictureUrl?: string;
112
+ squareLogoUrl?: string;
113
+ };
114
+ export declare type MarketingTextType = {
115
+ overviewDescription?: string;
116
+ featuresShort?: string;
117
+ featuresFull?: string;
118
+ features?: string;
119
+ };
120
+ export declare type SaleConstraintsType = {
121
+ customerQualifications?: Array<string>;
122
+ resellerQualifications?: Array<string>;
123
+ minQuantity?: number;
124
+ maxQuantity?: number;
125
+ maxSubscriptionConstraint?: string;
126
+ maxSubscriptionPerCustomer?: number;
127
+ saleGroup?: string;
128
+ requiredAttributes?: Array<string>;
129
+ };
130
+ export declare type VendorType = {
131
+ name?: string;
132
+ };
133
+ export declare type ProgramType = {
134
+ isEnabled?: boolean;
135
+ legacyCode?: string;
136
+ names?: ProgramNameType;
137
+ };
138
+ export declare type ProgramNameType = {
139
+ full?: string;
140
+ };
141
+ export declare type PriceBandType = {
142
+ actionFlags?: PriceBandActionFlagsType;
143
+ attributes?: Array<AttributeType>;
144
+ billing?: BillingType;
145
+ currency?: string;
146
+ dynamicAttributes?: DynamicAttributesType;
147
+ family?: FamilyType;
148
+ identifiers?: PriceBandIdentifiersType;
149
+ isEnabled?: boolean;
150
+ marketplace?: string;
151
+ name?: string;
152
+ orderingType?: string;
153
+ prices?: PricesType;
154
+ saleConstraints?: PriceBandSaleConstraintsType;
155
+ uom?: UomType;
156
+ };
157
+ export declare type PriceBandActionFlagsType = {
158
+ canBeCancelled?: boolean;
159
+ canBeReactivated?: boolean;
160
+ canBeSuspended?: boolean;
161
+ canDecreaseSeats?: boolean;
162
+ canIncreaseSeats?: boolean;
163
+ };
164
+ export declare type AttributeType = {
165
+ name?: string;
166
+ value?: string;
167
+ };
168
+ export declare type BillingType = {
169
+ cycle?: number;
170
+ term?: number;
171
+ type?: string;
172
+ };
173
+ export declare type DynamicAttributesType = {
174
+ diskSize?: string;
175
+ ram?: string;
176
+ region?: string;
177
+ vCpu?: string;
178
+ reservationsAutofitGroup?: string;
179
+ acu?: string;
180
+ marketSegment?: string;
181
+ version?: string;
182
+ metric?: string;
183
+ };
184
+ export declare type PriceBandIdentifiersType = {
185
+ arrowsphere?: PriceBandArrowsphereIdentifierType;
186
+ erp?: ErpIdentifierType;
187
+ vendor?: PriceBandVendorIdentifierType;
188
+ };
189
+ export declare type PriceBandArrowsphereIdentifierType = {
190
+ sku?: string;
191
+ };
192
+ export declare type ErpIdentifierType = {
193
+ sku?: string;
194
+ };
195
+ export declare type PriceBandVendorIdentifierType = {
196
+ purchasePlan?: string;
197
+ sku?: string;
198
+ };
199
+ export declare type PricesType = {
200
+ buy?: string;
201
+ sell?: string;
202
+ public?: string;
203
+ };
204
+ export declare type PriceBandSaleConstraintsType = {
205
+ availableDate?: string;
206
+ expiryDate?: string;
207
+ minQuantity?: number;
208
+ maxQuantity?: number;
209
+ };
210
+ export declare type UomType = {
211
+ quantity?: number;
212
+ type?: string;
213
+ };
214
+ export declare type RelatedOfferType = {
215
+ vendor?: string;
216
+ sku?: string;
217
+ };
218
+ export declare type OfferResellersType = {
219
+ owner?: ResellerType;
220
+ viewers?: Array<ResellerType>;
221
+ };
222
+ export declare type ResellerType = {
223
+ xspRef?: string;
224
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=catalogGraphQLTypes.js.map
package/build/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from './publicApiClient';
2
+ export * from './publicGraphQLClient';
2
3
  export * from './abstractEntity';
3
4
  export * from './abstractClient';
5
+ export * from './abstractGraphQLClient';
6
+ export * from './catalog/';
4
7
  export * from './licenses/';
5
8
  export * from './general/';
6
9
  export * from './subscriptions/';
package/build/index.js CHANGED
@@ -11,8 +11,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./publicApiClient"), exports);
14
+ __exportStar(require("./publicGraphQLClient"), exports);
14
15
  __exportStar(require("./abstractEntity"), exports);
15
16
  __exportStar(require("./abstractClient"), exports);
17
+ __exportStar(require("./abstractGraphQLClient"), exports);
18
+ __exportStar(require("./catalog/"), exports);
16
19
  __exportStar(require("./licenses/"), exports);
17
20
  __exportStar(require("./general/"), exports);
18
21
  __exportStar(require("./subscriptions/"), exports);
@@ -0,0 +1,5 @@
1
+ import { CatalogGraphQLClient } from './catalog/catalogGraphQLClient';
2
+ import { AbstractGraphQLClient } from './abstractGraphQLClient';
3
+ export declare class PublicGraphQLClient extends AbstractGraphQLClient {
4
+ getCatalogGraphQLClient(): CatalogGraphQLClient;
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PublicGraphQLClient = void 0;
4
+ const catalogGraphQLClient_1 = require("./catalog/catalogGraphQLClient");
5
+ const abstractGraphQLClient_1 = require("./abstractGraphQLClient");
6
+ class PublicGraphQLClient extends abstractGraphQLClient_1.AbstractGraphQLClient {
7
+ getCatalogGraphQLClient() {
8
+ return new catalogGraphQLClient_1.CatalogGraphQLClient().setUrl(this.url).setToken(this.token);
9
+ }
10
+ }
11
+ exports.PublicGraphQLClient = PublicGraphQLClient;
12
+ //# sourceMappingURL=publicGraphQLClient.js.map
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": "2.7.0",
7
+ "version": "2.8.0",
8
8
  "description": "Node.js client for ArrowSphere's public API",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",
@@ -80,6 +80,8 @@
80
80
  "dependencies": {
81
81
  "@types/validatorjs": "3.15.0",
82
82
  "axios": "0.21.1",
83
+ "graphql": "^16.3.0",
84
+ "graphql-request": "^4.0.0",
83
85
  "validatorjs": "3.22.1"
84
86
  }
85
87
  }