@arrowsphere/api-client 3.112.0-rc.bdj.1 → 3.113.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,22 @@
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
+ ## [3.113.0] - 2024.04.24
7
+
8
+ ### Added
9
+ - [License Bulk actions] allow REST clients to post a file with form/multipart
10
+ - [License Bulk actions] send file to upload changes
11
+
12
+ ## [3.112.0] - 2024.04.24
13
+
14
+ ### Added
15
+ - [License find] Add keywords endCustomerOrganizationUnit to find licenses
16
+
17
+ ## [3.111.0] - 2024.04.24
18
+
19
+ ### Added
20
+ - [Get License] Add fields price.total.init, price.unit.init
21
+
6
22
  ## [3.110.0] - 2024.04.18
7
23
 
8
24
  ### Added
@@ -57,7 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
57
73
  - [customer/contact] add organization object in customer contact payload
58
74
 
59
75
  ### Updated
60
- - Add sommes configs for IDE
76
+ - Add some configs for IDE
61
77
 
62
78
  ## [3.101.0] - 2024.03.19
63
79
 
@@ -1,5 +1,7 @@
1
+ /// <reference types="node" />
1
2
  import { AxiosInstance, AxiosResponse } from 'axios';
2
3
  import { AbstractHttpClient, Headers } from './AbstractHttpClient';
4
+ import { File } from 'node:buffer';
3
5
  /**
4
6
  * Lists of available query parameters for the API call
5
7
  */
@@ -26,7 +28,15 @@ export declare type ParametersWithPaginationType = (Parameters & {
26
28
  [ParameterKeys.PER_PAGE_CAMEL]?: number;
27
29
  });
28
30
  export declare type Parameters = Record<string, string | string[] | number | number[] | boolean | null | undefined>;
31
+ export declare enum FileUploadKeys {
32
+ Fields = "fields",
33
+ File = "file"
34
+ }
29
35
  export declare type Payload = Record<string, unknown> | Array<Payload>;
36
+ export interface PayloadWithFile {
37
+ [FileUploadKeys.Fields]?: Record<string, unknown>;
38
+ [FileUploadKeys.File]?: File;
39
+ }
30
40
  export declare type Options = {
31
41
  isAdmin?: boolean;
32
42
  returnAxiosData?: boolean;
@@ -145,7 +155,7 @@ export declare abstract class AbstractRestfulClient extends AbstractHttpClient {
145
155
  */
146
156
  private prepareHeaders;
147
157
  /**
148
- * Sends a POST request and returns the response
158
+ * Sends a POST request including file with header form/multipart and returns the response
149
159
  * @returns Promise\<AxiosResponse['data']\>
150
160
  * @param payload - Payload to be sent in the POST body
151
161
  * @param parameters - Query parameters to be sent in the request
@@ -153,6 +163,15 @@ export declare abstract class AbstractRestfulClient extends AbstractHttpClient {
153
163
  * @param options - Options to send
154
164
  */
155
165
  protected post(payload?: Payload, parameters?: Parameters, headers?: Headers, options?: Options): Promise<AxiosResponse['data']>;
166
+ /**
167
+ * Sends a POST request and returns the response
168
+ * @returns Promise\<AxiosResponse['data']\>
169
+ * @param payload - Payload to be sent in the POST body
170
+ * @param parameters - Query parameters to be sent in the request
171
+ * @param headers - Headers to be sent in the request
172
+ * @param options - Options to send
173
+ */
174
+ protected postFile(payload: PayloadWithFile, parameters?: Parameters, headers?: Headers, options?: Options): Promise<AxiosResponse['data']>;
156
175
  /**
157
176
  * Sends a PUT request
158
177
  * @param payload - Payload to be sent in the POST body
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AbstractRestfulClient = exports.ExtraInformationFields = exports.ParameterKeys = void 0;
6
+ exports.AbstractRestfulClient = exports.FileUploadKeys = exports.ExtraInformationFields = exports.ParameterKeys = void 0;
7
7
  const exception_1 = require("./exception");
8
8
  const querystring_1 = __importDefault(require("querystring"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -29,6 +29,11 @@ var ExtraInformationFields;
29
29
  (function (ExtraInformationFields) {
30
30
  ExtraInformationFields["COLUMN_EXTRA_INFORMATION"] = "extraInformation";
31
31
  })(ExtraInformationFields = exports.ExtraInformationFields || (exports.ExtraInformationFields = {}));
32
+ var FileUploadKeys;
33
+ (function (FileUploadKeys) {
34
+ FileUploadKeys["Fields"] = "fields";
35
+ FileUploadKeys["File"] = "file";
36
+ })(FileUploadKeys = exports.FileUploadKeys || (exports.FileUploadKeys = {}));
32
37
  class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
33
38
  /**
34
39
  * AbstractClient constructor.
@@ -161,7 +166,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
161
166
  };
162
167
  }
163
168
  /**
164
- * Sends a POST request and returns the response
169
+ * Sends a POST request including file with header form/multipart and returns the response
165
170
  * @returns Promise\<AxiosResponse['data']\>
166
171
  * @param payload - Payload to be sent in the POST body
167
172
  * @param parameters - Query parameters to be sent in the request
@@ -191,6 +196,49 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
191
196
  throw error;
192
197
  }
193
198
  }
199
+ /**
200
+ * Sends a POST request and returns the response
201
+ * @returns Promise\<AxiosResponse['data']\>
202
+ * @param payload - Payload to be sent in the POST body
203
+ * @param parameters - Query parameters to be sent in the request
204
+ * @param headers - Headers to be sent in the request
205
+ * @param options - Options to send
206
+ */
207
+ async postFile(payload, parameters = {}, headers = {}, options = {}) {
208
+ var _a;
209
+ if (!payload[FileUploadKeys.File]) {
210
+ throw new Error('File upload required');
211
+ }
212
+ // will force axios to append header 'multipart/form-data' and will attach a boundary automatically
213
+ headers['Content-Type'] = undefined;
214
+ const url = this.generateUrl(parameters, options);
215
+ const config = {
216
+ headers: this.prepareHeaders(headers),
217
+ };
218
+ const formData = new FormData();
219
+ formData.append(FileUploadKeys.File, payload[FileUploadKeys.File]);
220
+ for (const [key, value] of Object.entries((_a = payload[FileUploadKeys.Fields]) !== null && _a !== void 0 ? _a : {})) {
221
+ console.log(`${key}: ${value}`);
222
+ formData.set(key, value);
223
+ }
224
+ try {
225
+ const response = await this.client.post(url, formData, config);
226
+ return this.getResponse(response, options);
227
+ }
228
+ catch (error) {
229
+ if (error instanceof exception_1.PublicApiClientException) {
230
+ const { mustRetry } = await this.handleError(error);
231
+ if (mustRetry) {
232
+ const config = {
233
+ headers: this.prepareHeaders(headers),
234
+ };
235
+ const response = await this.client.post(url, payload, config);
236
+ return this.getResponse(response, options);
237
+ }
238
+ }
239
+ throw error;
240
+ }
241
+ }
194
242
  /**
195
243
  * Sends a PUT request
196
244
  * @param payload - Payload to be sent in the POST body
@@ -1,5 +1,5 @@
1
1
  import { AbstractEntity } from '../../../abstractEntity';
2
- import { FiltersParameters, SortParameters } from '../../licensesClient';
2
+ import { DataKeywords, FiltersParameters, SortParameters } from '../../licensesClient';
3
3
  export declare enum EndCustomerOrganizationUnitFindResultFields {
4
4
  COLUMN_ORGANIZATION_UNIT_REF = "organizationUnitRef",
5
5
  COLUMN_NAME = "name",
@@ -10,6 +10,11 @@ export declare type EndCustomerOrganizationUnitFindResultType = {
10
10
  [EndCustomerOrganizationUnitFindResultFields.COLUMN_NAME]: string;
11
11
  [EndCustomerOrganizationUnitFindResultFields.COLUMN_LAST_UPDATE]: string;
12
12
  };
13
+ export declare type EndCustomerOrganisationUnitDataKeywords = {
14
+ [EndCustomerOrganizationUnitFindResultFields.COLUMN_ORGANIZATION_UNIT_REF]?: DataKeywords;
15
+ [EndCustomerOrganizationUnitFindResultFields.COLUMN_NAME]?: DataKeywords;
16
+ [EndCustomerOrganizationUnitFindResultFields.COLUMN_LAST_UPDATE]?: DataKeywords;
17
+ };
13
18
  export declare type EndCustomerOrganizationUnitSortParameters = {
14
19
  [EndCustomerOrganizationUnitFindResultFields.COLUMN_ORGANIZATION_UNIT_REF]?: SortParameters;
15
20
  [EndCustomerOrganizationUnitFindResultFields.COLUMN_NAME]?: SortParameters;
@@ -23,7 +23,7 @@ import { ScheduleTasksResult } from './entities/schedule/scheduleTasksResult';
23
23
  import { CompanyTypeEnum, RateTypeEnum } from './entities/pricingRate/getPricingRateResult';
24
24
  import { PartialResponse } from '../partialResponse';
25
25
  import { BulkBodyArgument, SpecialPriceRateActive } from './types/bulkArguments';
26
- import { EndCustomerOrganizationUnitFiltersParameters, EndCustomerOrganizationUnitSortParameters } from './entities/endCustomerOrganizationUnit/endCustomerOrganizationUnitFindResult';
26
+ import { EndCustomerOrganisationUnitDataKeywords, EndCustomerOrganizationUnitFiltersParameters, EndCustomerOrganizationUnitSortParameters } from './entities/endCustomerOrganizationUnit/endCustomerOrganizationUnitFindResult';
27
27
  import { ConsumptionDailyPrediction } from '../consumption';
28
28
  import { GetSchedulesTasksResult } from './entities/schedule/getSchedulesTasksResult';
29
29
  import { GetScheduledTasksResult } from './entities/schedule/getScheduledTasksResult';
@@ -145,6 +145,7 @@ export declare type DataKeywords = {
145
145
  export declare type LicenseKeywordsParameters = {
146
146
  license?: LicenceFindDataKeywords;
147
147
  offer?: OfferFindResultDataKeywords;
148
+ endCustomerOrganizationUnit?: EndCustomerOrganisationUnitDataKeywords;
148
149
  };
149
150
  export declare type LicenseRawKeywordsParametersLicence = {
150
151
  [field: string]: DataKeywords | ActiveSeatsFindResultDataKeywords | ConfigFindResultDataKeywords | WarningFindResultDataKeywords | PriceFindResultDataKeywords | SecurityFindResultDataKeywords | undefined;
@@ -261,6 +261,7 @@ class LicensesClient extends abstractRestfulClient_1.AbstractRestfulClient {
261
261
  rawLicensePayload.keywords = {
262
262
  ...this.createKeywords(postData.keywords, 'license'),
263
263
  ...this.createKeywords(postData.keywords, 'offer'),
264
+ ...this.createKeywords(postData.keywords, 'endCustomerOrganizationUnit'),
264
265
  };
265
266
  }
266
267
  if (postData.filters) {
@@ -334,13 +335,13 @@ class LicensesClient extends abstractRestfulClient_1.AbstractRestfulClient {
334
335
  };
335
336
  postData = postSetRateData;
336
337
  }
337
- /*else if (bulkData.actionType == ActionTypes.UPLOAD_CHANGES) {
338
- const postUploadChangesData: BulkUploadChangesBody = {
339
- ...postData,
340
- [BulkBodyFields.FILE]: bulkData.file,
341
- };
342
- postData = postUploadChangesData;
343
- }*/
338
+ else if (bulkData.actionType == bulkArguments_1.ActionTypes.UPLOAD_CHANGES) {
339
+ const payload = {
340
+ [abstractRestfulClient_1.FileUploadKeys.Fields]: postData,
341
+ [abstractRestfulClient_1.FileUploadKeys.File]: bulkData[bulkArguments_1.BulkBodyFields.FILE],
342
+ };
343
+ return await this.postFile(payload);
344
+ }
344
345
  return await this.post(postData);
345
346
  }
346
347
  async updateConfig(reference, config) {
@@ -524,8 +525,7 @@ class LicensesClient extends abstractRestfulClient_1.AbstractRestfulClient {
524
525
  createKeywords(parameters, keyParent) {
525
526
  let appropriateParameters;
526
527
  if (typeof parameters === 'object') {
527
- appropriateParameters =
528
- keyParent === 'license' ? parameters.license : parameters.offer;
528
+ appropriateParameters = parameters[keyParent];
529
529
  }
530
530
  else {
531
531
  appropriateParameters = parameters;
@@ -1,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import type { Except } from 'type-fest';
3
+ import { File } from 'node:buffer';
2
4
  export declare enum ActionTypes {
3
5
  SET_RATE = "setRate",
4
6
  AUTO_RENEW = "autoRenew",
@@ -37,7 +39,8 @@ export declare type BulkBodyArgument = {
37
39
  [BulkBodyFields.SPECIAL_PRICE_RATE_TYPE]?: SpecialPriceRateTypes;
38
40
  [BulkBodyFields.SPECIAL_PRICE_RATE_VALUE]?: string;
39
41
  [BulkBodyFields.SPECIAL_RATE_EFFECTIVE_APPLICATION_DATE]?: SpecialRateEffectiveApplicationDate;
42
+ [BulkBodyFields.FILE]?: File;
40
43
  };
41
44
  export declare type BulkAutoRenewBody = Except<BulkBodyArgument, BulkBodyFields.SPECIAL_PRICE_RATE_TYPE & BulkBodyFields.SPECIAL_PRICE_RATE_VALUE & BulkBodyFields.SPECIAL_RATE_EFFECTIVE_APPLICATION_DATE & BulkBodyFields.FILE>;
42
45
  export declare type BulkSetRateBody = Except<BulkBodyArgument, BulkBodyFields.AUTO_RENEW_STATUS & BulkBodyFields.FILE>;
43
- export declare type BulkUploadChangesBody = Except<BulkBodyArgument, BulkBodyFields.AUTO_RENEW_STATUS & BulkBodyFields.SPECIAL_PRICE_RATE_TYPE & BulkBodyFields.SPECIAL_PRICE_RATE_VALUE & BulkBodyFields.SPECIAL_RATE_EFFECTIVE_APPLICATION_DATE>;
46
+ export declare type BulkUploadChangesBody = Except<BulkBodyArgument, BulkBodyFields.AUTO_RENEW_STATUS & BulkBodyFields.FILE & BulkBodyFields.SPECIAL_PRICE_RATE_TYPE & BulkBodyFields.SPECIAL_PRICE_RATE_VALUE & BulkBodyFields.SPECIAL_RATE_EFFECTIVE_APPLICATION_DATE>;
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.112.0-rc.bdj.1",
7
+ "version": "3.113.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",