@arrowsphere/api-client 3.112.0 → 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,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
|
+
## [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
|
+
|
|
6
12
|
## [3.112.0] - 2024.04.24
|
|
7
13
|
|
|
8
14
|
### Added
|
|
@@ -67,7 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
67
73
|
- [customer/contact] add organization object in customer contact payload
|
|
68
74
|
|
|
69
75
|
### Updated
|
|
70
|
-
- Add
|
|
76
|
+
- Add some configs for IDE
|
|
71
77
|
|
|
72
78
|
## [3.101.0] - 2024.03.19
|
|
73
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
|
|
@@ -335,13 +335,13 @@ class LicensesClient extends abstractRestfulClient_1.AbstractRestfulClient {
|
|
|
335
335
|
};
|
|
336
336
|
postData = postSetRateData;
|
|
337
337
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
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
|
+
}
|
|
345
345
|
return await this.post(postData);
|
|
346
346
|
}
|
|
347
347
|
async updateConfig(reference, config) {
|
|
@@ -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