@arrowsphere/api-client 1.0.2 → 2.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +72 -3
  2. package/README.md +2 -1
  3. package/UPGRADING.md +43 -0
  4. package/build/licenses/entities/filterFindResult.d.ts +2 -2
  5. package/build/licenses/entities/findResult.d.ts +17 -9
  6. package/build/licenses/entities/findResult.js +4 -4
  7. package/build/licenses/entities/getLicense/actionMessagesGetResult.d.ts +25 -0
  8. package/build/licenses/entities/getLicense/actionMessagesGetResult.js +69 -0
  9. package/build/licenses/entities/getLicense/actionsGetResult.d.ts +40 -0
  10. package/build/licenses/entities/getLicense/actionsGetResult.js +103 -0
  11. package/build/licenses/entities/getLicense/buySellFindResult.d.ts +16 -0
  12. package/build/licenses/entities/getLicense/buySellFindResult.js +47 -0
  13. package/build/licenses/entities/getLicense/licenseGetResult.d.ts +93 -0
  14. package/build/licenses/entities/getLicense/licenseGetResult.js +244 -0
  15. package/build/licenses/entities/getLicense/licensePriceGetResult.d.ts +17 -0
  16. package/build/licenses/entities/getLicense/licensePriceGetResult.js +56 -0
  17. package/build/licenses/entities/getLicense/orderGetResult.d.ts +16 -0
  18. package/build/licenses/entities/getLicense/orderGetResult.js +47 -0
  19. package/build/licenses/entities/license/activeSeatsFindResult.d.ts +33 -0
  20. package/build/licenses/entities/license/activeSeatsFindResult.js +47 -0
  21. package/build/licenses/entities/license/configFindResult.d.ts +37 -0
  22. package/build/licenses/entities/license/configFindResult.js +59 -0
  23. package/build/licenses/entities/license/licenseFindResult.d.ts +266 -13
  24. package/build/licenses/entities/license/licenseFindResult.js +324 -13
  25. package/build/licenses/entities/license/priceFindResult.d.ts +54 -0
  26. package/build/licenses/entities/license/priceFindResult.js +76 -0
  27. package/build/licenses/entities/license/warningFindResult.d.ts +33 -0
  28. package/build/licenses/entities/license/warningFindResult.js +51 -0
  29. package/build/licenses/entities/offer/actionFlagsFindResult.d.ts +37 -0
  30. package/build/licenses/entities/offer/actionFlagsFindResult.js +59 -0
  31. package/build/licenses/entities/offer/offerFindResult.d.ts +63 -0
  32. package/build/licenses/entities/offer/offerFindResult.js +109 -0
  33. package/build/licenses/entities/offer/priceBandFindResult.d.ts +72 -0
  34. package/build/licenses/entities/offer/priceBandFindResult.js +131 -0
  35. package/build/licenses/entities/offer/priceband/billingFindResult.d.ts +37 -0
  36. package/build/licenses/entities/offer/priceband/billingFindResult.js +59 -0
  37. package/build/licenses/entities/offer/priceband/identifiers/arrowsphereFindResult.d.ts +25 -0
  38. package/build/licenses/entities/offer/priceband/identifiers/arrowsphereFindResult.js +43 -0
  39. package/build/licenses/entities/offer/priceband/identifiersFindResult.d.ts +25 -0
  40. package/build/licenses/entities/offer/priceband/identifiersFindResult.js +47 -0
  41. package/build/licenses/entities/offer/priceband/priceBandActionFlagsFindResult.d.ts +49 -0
  42. package/build/licenses/entities/offer/priceband/priceBandActionFlagsFindResult.js +80 -0
  43. package/build/licenses/entities/offer/priceband/priceBandPriceFindResult.d.ts +37 -0
  44. package/build/licenses/entities/offer/priceband/priceBandPriceFindResult.js +59 -0
  45. package/build/licenses/entities/offer/priceband/saleConstraintsFindResult.d.ts +29 -0
  46. package/build/licenses/entities/offer/priceband/saleConstraintsFindResult.js +47 -0
  47. package/build/licenses/index.d.ts +20 -3
  48. package/build/licenses/index.js +20 -3
  49. package/build/licenses/licensesClient.d.ts +94 -22
  50. package/build/licenses/licensesClient.js +90 -6
  51. package/build/publicApiClient.js +3 -1
  52. package/package.json +2 -2
  53. package/build/licenses/entities/license/abstractLicense.d.ts +0 -177
  54. package/build/licenses/entities/license/abstractLicense.js +0 -363
  55. package/build/licenses/entities/offer/licenseOfferFindResult.d.ts +0 -108
  56. package/build/licenses/entities/offer/licenseOfferFindResult.js +0 -232
@@ -6,6 +6,7 @@ exports.LicensesClient = exports.LicenseFindParameters = void 0;
6
6
  */
7
7
  const abstractClient_1 = require("../abstractClient");
8
8
  const findResult_1 = require("./entities/findResult");
9
+ const configFindResult_1 = require("./entities/license/configFindResult");
9
10
  /**
10
11
  * Parameters passable to the request for refining search.
11
12
  */
@@ -59,6 +60,46 @@ var LicenseFindParameters;
59
60
  * Use this operator to search for all keywords with values in the range specified (for date ranges)
60
61
  */
61
62
  LicenseFindParameters["OPERATOR_BETWEEN"] = "BETWEEN";
63
+ /**
64
+ * Use this operator to search with a compare field Equal
65
+ */
66
+ LicenseFindParameters["OPERATOR_EQ"] = "EQ";
67
+ /**
68
+ * Use this operator to search with a compare field Not Equal
69
+ */
70
+ LicenseFindParameters["OPERATOR_NEQ"] = "NEQ";
71
+ /**
72
+ * Use this operator to search with a compare field Greater Than
73
+ */
74
+ LicenseFindParameters["OPERATOR_GT"] = "GT";
75
+ /**
76
+ * Use this operator to search with a compare field Greater Than or Equal
77
+ */
78
+ LicenseFindParameters["OPERATOR_GTE"] = "GTE";
79
+ /**
80
+ * Use this operator to search with a compare field Lower Than
81
+ */
82
+ LicenseFindParameters["OPERATOR_LT"] = "LT";
83
+ /**
84
+ * Use this operator to search with a compare field Lower Than or Equal
85
+ */
86
+ LicenseFindParameters["OPERATOR_LTE"] = "LTE";
87
+ /**
88
+ * Use this filter to compare 2 value with other filter like FILTERS_GTE / FILTERS_LT / FILTERS_LTE
89
+ */
90
+ LicenseFindParameters["FILTERS_GT"] = "gt";
91
+ /**
92
+ * Use this filter to compare 2 value with other filter like FILTERS_GT / FILTERS_LT / FILTERS_LTE
93
+ */
94
+ LicenseFindParameters["FILTERS_GTE"] = "gte";
95
+ /**
96
+ * Use this filter to compare 2 value with other filter like FILTERS_GT / FILTERS_GTE / FILTERS_LTE
97
+ */
98
+ LicenseFindParameters["FILTERS_LT"] = "lt";
99
+ /**
100
+ * Use this filter to compare 2 value with other filter like FILTERS_GT / FILTERS_GTE / FILTERS_LT
101
+ */
102
+ LicenseFindParameters["FILTERS_LTE"] = "lte";
62
103
  })(LicenseFindParameters = exports.LicenseFindParameters || (exports.LicenseFindParameters = {}));
63
104
  class LicensesClient extends abstractClient_1.AbstractClient {
64
105
  constructor() {
@@ -75,6 +116,10 @@ class LicensesClient extends abstractClient_1.AbstractClient {
75
116
  * The path of the Find endpoint
76
117
  */
77
118
  this.FIND_PATH = 'v2/find';
119
+ /**
120
+ * The path of the Configs endpoint
121
+ */
122
+ this.CONFIGS_PATH = '/configs';
78
123
  }
79
124
  /**
80
125
  * Returns the raw result from the find endpoint call
@@ -100,12 +145,11 @@ class LicensesClient extends abstractClient_1.AbstractClient {
100
145
  *
101
146
  */
102
147
  async find(postData = {}, perPage = 100, page = 1, parameters = {}) {
103
- var _a, _b, _c, _d;
148
+ var _a, _b, _c, _d, _e, _f;
104
149
  this.setPerPage(perPage);
105
150
  this.setPage(page);
106
151
  const rawLicensePayload = {
107
152
  keyword: postData.keyword,
108
- sort: postData.sort,
109
153
  highlight: postData.highlight,
110
154
  };
111
155
  if (postData.keywords) {
@@ -124,12 +168,25 @@ class LicensesClient extends abstractClient_1.AbstractClient {
124
168
  if (postData.filters) {
125
169
  // Flatten with prefix for each type of filter (license and offer)
126
170
  rawLicensePayload.filters = {
127
- ...Object.entries((_c = postData.filters.license) !== null && _c !== void 0 ? _c : {}).reduce((acc, [keyword, value]) => {
128
- acc[`license.${keyword}`] = value;
171
+ ...Object.entries((_c = postData.filters.license) !== null && _c !== void 0 ? _c : {}).reduce((acc, [filter, value]) => {
172
+ acc[`license.${filter}`] = value;
129
173
  return acc;
130
174
  }, {}),
131
- ...Object.entries((_d = postData.filters.offer) !== null && _d !== void 0 ? _d : {}).reduce((acc, [keyword, value]) => {
132
- acc[`offer.${keyword}`] = value;
175
+ ...Object.entries((_d = postData.filters.offer) !== null && _d !== void 0 ? _d : {}).reduce((acc, [filter, value]) => {
176
+ acc[`offer.${filter}`] = value;
177
+ return acc;
178
+ }, {}),
179
+ };
180
+ }
181
+ if (postData.sort) {
182
+ // Flatten with prefix for each type of sort keys (license and offer)
183
+ rawLicensePayload.sort = {
184
+ ...Object.entries((_e = postData.sort.license) !== null && _e !== void 0 ? _e : {}).reduce((acc, [sort, value]) => {
185
+ acc[`license.${sort}`] = value;
186
+ return acc;
187
+ }, {}),
188
+ ...Object.entries((_f = postData.sort.offer) !== null && _f !== void 0 ? _f : {}).reduce((acc, [sort, value]) => {
189
+ acc[`offer.${sort}`] = value;
133
190
  return acc;
134
191
  }, {}),
135
192
  };
@@ -137,6 +194,33 @@ class LicensesClient extends abstractClient_1.AbstractClient {
137
194
  const response = await this.findRaw(rawLicensePayload, parameters);
138
195
  return new findResult_1.FindResult(response, this, rawLicensePayload, parameters);
139
196
  }
197
+ getConfigsRaw(reference) {
198
+ this.path = reference + this.CONFIGS_PATH;
199
+ return this.get();
200
+ }
201
+ async *getConfigs(reference) {
202
+ const rawResponse = await this.getConfigsRaw(reference);
203
+ for (const response of rawResponse.data) {
204
+ yield new configFindResult_1.ConfigFindResult(response).toJSON();
205
+ }
206
+ }
207
+ async updateConfigRaw(reference, config) {
208
+ this.path = reference + this.CONFIGS_PATH;
209
+ const postData = {
210
+ [configFindResult_1.ConfigFindResultFields.COLUMN_NAME]: config.name,
211
+ [configFindResult_1.ConfigFindResultFields.COLUMN_SCOPE]: config.scope,
212
+ [configFindResult_1.ConfigFindResultFields.COLUMN_STATE]: config.state,
213
+ };
214
+ return await this.post(postData);
215
+ }
216
+ async updateConfig(reference, config) {
217
+ const rawResponse = await this.updateConfigRaw(reference, config);
218
+ return new configFindResult_1.ConfigFindResult(rawResponse);
219
+ }
220
+ getLicense(licenseReference, parameters = {}) {
221
+ this.path = licenseReference;
222
+ return this.get(parameters);
223
+ }
140
224
  }
141
225
  exports.LicensesClient = LicensesClient;
142
226
  //# sourceMappingURL=licensesClient.js.map
@@ -17,7 +17,9 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
17
17
  * @returns {@link WhoAmIClient}
18
18
  */
19
19
  getWhoamiClient() {
20
- return new general_1.WhoAmIClient(this.client).setUrl(this.url).setApiKey(this.apiKey);
20
+ return new general_1.WhoAmIClient(this.client)
21
+ .setUrl(this.url)
22
+ .setApiKey(this.apiKey);
21
23
  }
22
24
  /**
23
25
  * Creates a new {@link LicensesClient} instance and returns it
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": "1.0.2",
7
+ "version": "2.1.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",
@@ -14,7 +14,7 @@
14
14
  "doc": "typedoc ./src/index.ts ./src/**/index.ts",
15
15
  "lint": "eslint ./{src,tests}/**/*.ts && prettier --list-different ./{src,tests}/**/*.ts",
16
16
  "lint:fix": "eslint ./{src,tests}/**/*.ts --fix && prettier --write ./{src,tests}/**/*.ts",
17
- "prepublishOnly": "npm run clean && npm run build",
17
+ "prepare": "npm run clean && npm run build",
18
18
  "test": "mocha -r ts-node/register \"tests/**/*.ts\"",
19
19
  "test:watch": "mocha --watch -r ts-node/register \"tests/**/*.ts\"",
20
20
  "test:coverage": "nyc --check-coverage npm run test",
@@ -1,177 +0,0 @@
1
- import { AbstractEntity } from '../../../abstractEntity';
2
- /**
3
- * Fields that can be present in License response and request data.
4
- */
5
- export declare enum LicenseFields {
6
- COLUMN_ACCEPT_EULA = "accept_eula",
7
- COLUMN_AUTO_RENEW = "auto_renew",
8
- COLUMN_BASE_SEAT = "base_seat",
9
- COLUMN_CATEGORY = "category",
10
- COLUMN_CLOUD_TYPE = "cloud_type",
11
- COLUMN_CUSTOMER_NAME = "customer_name",
12
- COLUMN_CUSTOMER_REF = "customer_ref",
13
- COLUMN_END_DATE = "end_date",
14
- COLUMN_FRIENDLY_NAME = "friendly_name",
15
- COLUMN_ID = "id",
16
- COLUMN_IS_ENABLED = "isEnabled",
17
- COLUMN_LAST_UPDATE = "lastUpdate",
18
- COLUMN_PARENT_LINE_ID = "parent_line_id",
19
- COLUMN_MARKETPLACE = "marketplace",
20
- COLUMN_MESSAGE = "message",
21
- COLUMN_OFFER = "offer",
22
- COLUMN_PARENT_ORDER_REF = "parent_order_ref",
23
- COLUMN_PARTNER_REF = "partner_ref",
24
- COLUMN_PERIODICITY = "periodicity",
25
- COLUMN_RESELLER_NAME = "reseller_name",
26
- COLUMN_RESELLER_REF = "reseller_ref",
27
- COLUMN_SEAT = "seat",
28
- COLUMN_SERVICE_REF = "service_ref",
29
- COLUMN_SKU = "sku",
30
- COLUMN_START_DATE = "start_date",
31
- COLUMN_STATUS_CODE = "status_code",
32
- COLUMN_STATUS_LABEL = "status_label",
33
- COLUMN_SUBSCRIPTION_ID = "subscription_id",
34
- COLUMN_SUBSIDIARY_NAME = "subsidiary_name",
35
- COLUMN_TERM = "term",
36
- COLUMN_TRIAL = "trial",
37
- COLUMN_TYPE = "type",
38
- COLUMN_UOM = "uom",
39
- COLUMN_VENDOR_CODE = "vendor_code",
40
- COLUMN_VENDOR_NAME = "vendor_name",
41
- COLUMN_VENDOR_SUBSCRIPTION_ID = "vendor_subscription_id",
42
- COLUMN_PRICE = "price",
43
- PRICE_BUY_PRICE = "buy_price",
44
- PRICE_LIST_PRICE = "list_price",
45
- PRICE_CURRENCY = "currency",
46
- COLUMN_ACTIVE_SEATS = "active_seats",
47
- ACTIVE_SEATS_LAST_UPDATE = "lastUpdate",
48
- ACTIVE_SEATS_NUMBER = "number"
49
- }
50
- /**
51
- * License data fields and their corresponding types
52
- */
53
- export declare type LicenseData = {
54
- [LicenseFields.COLUMN_ID]: number;
55
- [LicenseFields.COLUMN_ACCEPT_EULA]: boolean;
56
- [LicenseFields.COLUMN_ACTIVE_SEATS]: {
57
- [LicenseFields.ACTIVE_SEATS_LAST_UPDATE]: string | null;
58
- [LicenseFields.ACTIVE_SEATS_NUMBER]: number | null;
59
- };
60
- [LicenseFields.COLUMN_AUTO_RENEW]: boolean;
61
- [LicenseFields.COLUMN_BASE_SEAT]: number;
62
- [LicenseFields.COLUMN_CATEGORY]: string;
63
- [LicenseFields.COLUMN_CLOUD_TYPE]: string;
64
- [LicenseFields.COLUMN_CUSTOMER_NAME]: string;
65
- [LicenseFields.COLUMN_CUSTOMER_REF]: string;
66
- [LicenseFields.COLUMN_END_DATE]: string;
67
- [LicenseFields.COLUMN_FRIENDLY_NAME]: string | null;
68
- [LicenseFields.COLUMN_IS_ENABLED]: boolean;
69
- [LicenseFields.COLUMN_LAST_UPDATE]: string | null;
70
- [LicenseFields.COLUMN_MARKETPLACE]: string;
71
- [LicenseFields.COLUMN_MESSAGE]: string;
72
- [LicenseFields.COLUMN_OFFER]: string;
73
- [LicenseFields.COLUMN_PARENT_LINE_ID]: number | null;
74
- [LicenseFields.COLUMN_PARENT_ORDER_REF]: string | null;
75
- [LicenseFields.COLUMN_PARTNER_REF]: string;
76
- [LicenseFields.COLUMN_PERIODICITY]: number;
77
- [LicenseFields.COLUMN_PRICE]: {
78
- [LicenseFields.PRICE_BUY_PRICE]: number;
79
- [LicenseFields.PRICE_LIST_PRICE]: number;
80
- [LicenseFields.PRICE_CURRENCY]: string | null;
81
- };
82
- [LicenseFields.COLUMN_RESELLER_NAME]: string;
83
- [LicenseFields.COLUMN_RESELLER_REF]: string;
84
- [LicenseFields.COLUMN_SEAT]: number;
85
- [LicenseFields.COLUMN_SERVICE_REF]: string;
86
- [LicenseFields.COLUMN_SKU]: string;
87
- [LicenseFields.COLUMN_START_DATE]: string;
88
- [LicenseFields.COLUMN_STATUS_CODE]: number;
89
- [LicenseFields.COLUMN_STATUS_LABEL]: string;
90
- [LicenseFields.COLUMN_SUBSCRIPTION_ID]: string;
91
- [LicenseFields.COLUMN_SUBSIDIARY_NAME]: string;
92
- [LicenseFields.COLUMN_TERM]: number;
93
- [LicenseFields.COLUMN_TRIAL]: boolean;
94
- [LicenseFields.COLUMN_TYPE]: string;
95
- [LicenseFields.COLUMN_UOM]: string;
96
- [LicenseFields.COLUMN_VENDOR_CODE]: string;
97
- [LicenseFields.COLUMN_VENDOR_NAME]: string;
98
- [LicenseFields.COLUMN_VENDOR_SUBSCRIPTION_ID]: string | null;
99
- };
100
- /**
101
- * Abstract class of a License entity. Can only be instantiated through a {@link LicenseFindResult} object class
102
- */
103
- export declare abstract class AbstractLicense extends AbstractEntity<LicenseData> {
104
- #private;
105
- protected VALIDATION_RULES: {
106
- [x: string]: string;
107
- id: string;
108
- subscription_id: string;
109
- vendor_name: string;
110
- vendor_code: string;
111
- subsidiary_name: string;
112
- partner_ref: string;
113
- status_code: string;
114
- status_label: string;
115
- sku: string;
116
- cloud_type: string;
117
- base_seat: string;
118
- seat: string;
119
- trial: string;
120
- auto_renew: string;
121
- offer: string;
122
- accept_eula: string;
123
- price: string;
124
- };
125
- /**
126
- * AbstractLicense constructor.
127
- *
128
- * @param data - License data to construct the entity with.
129
- */
130
- protected constructor(data: LicenseData);
131
- get id(): number;
132
- get acceptEula(): boolean;
133
- get activeSeatsLastUpdate(): string | null;
134
- get activeSeatsNumber(): number | null;
135
- get autoRenew(): boolean;
136
- get baseSeat(): number;
137
- get buyPrice(): number;
138
- get category(): string;
139
- get classification(): string;
140
- get currency(): string | null;
141
- get customerName(): string;
142
- get customerRef(): string;
143
- get endDate(): string;
144
- get friendlyName(): string | null;
145
- get enabled(): boolean;
146
- get lastUpdate(): string | null;
147
- get listPrice(): number;
148
- get marketplace(): string;
149
- get message(): string;
150
- get offer(): string;
151
- get parentLineId(): number | null;
152
- get parentOrderRef(): string | null;
153
- get partnerRef(): string;
154
- get periodicity(): number;
155
- get resellerName(): string;
156
- get resellerRef(): string;
157
- get seat(): number;
158
- get serviceRef(): string;
159
- get sku(): string;
160
- get startDate(): string;
161
- get statusCode(): number;
162
- get statusLabel(): string;
163
- get subscriptionId(): string;
164
- get subsidiaryName(): string;
165
- get term(): number;
166
- isTrial(): boolean;
167
- get type(): string;
168
- get uom(): string;
169
- get vendorCode(): string;
170
- get vendorName(): string;
171
- get vendorSubscriptionId(): string | null;
172
- /**
173
- * Plain JSON object representation of the license entity.
174
- * @returns {@link LicenseData}
175
- */
176
- toJSON(): LicenseData;
177
- }