@internxt/sdk 1.15.1 → 1.15.2

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,16 +1,10 @@
1
1
  import { BasicAuth } from '../auth/types';
2
2
  import { AppDetails } from '../shared';
3
- import { BridgeUrl, FinishMultipartUploadPayload, FinishUploadPayload, FinishUploadResponse, GetDownloadLinksResponse, NetworkRequestConfig, StartUploadPayload, StartUploadResponse } from './types';
3
+ import { BridgeUrl, FinishMultipartUploadPayload, FinishUploadPayload, FinishUploadResponse, GetDownloadLinksResponse, StartUploadPayload, StartUploadResponse } from './types';
4
4
  export * from './types';
5
- export declare class DuplicatedIndexesError extends Error {
6
- constructor();
7
- }
8
5
  export declare class InvalidFileIndexError extends Error {
9
6
  constructor();
10
7
  }
11
- export declare class InvalidUploadIndexError extends Error {
12
- constructor();
13
- }
14
8
  export declare class InvalidUploadSizeError extends Error {
15
9
  constructor();
16
10
  }
@@ -30,9 +24,9 @@ export declare class Network {
30
24
  }): Network;
31
25
  private constructor();
32
26
  get credentials(): BasicAuth;
33
- startUpload(bucketId: string, payload: StartUploadPayload, parts?: number): Promise<StartUploadResponse>;
34
- finishUpload(bucketId: string, payload: FinishUploadPayload): Promise<FinishUploadResponse>;
35
- finishMultipartUpload(bucketId: string, payload: FinishMultipartUploadPayload): Promise<FinishUploadResponse>;
27
+ startUpload(bucketId: string, fileSize: number, signal?: AbortSignal, parts?: number): Promise<StartUploadResponse>;
28
+ finishUpload(bucketId: string, payload: FinishUploadPayload, signal?: AbortSignal): Promise<FinishUploadResponse>;
29
+ finishMultipartUpload(bucketId: string, payload: FinishMultipartUploadPayload, signal?: AbortSignal): Promise<FinishUploadResponse>;
36
30
  getDownloadLinks(bucketId: string, fileId: string, token?: string): Promise<GetDownloadLinksResponse>;
37
31
  deleteFile(bucketId: string, fileId: string): Promise<void>;
38
32
  /**
@@ -40,14 +34,14 @@ export declare class Network {
40
34
  * @param bucketId
41
35
  * @param uploads
42
36
  */
43
- static startUpload(bucketId: string, payload: StartUploadPayload, { client, appDetails, auth }: NetworkRequestConfig, parts?: number): Promise<StartUploadResponse>;
37
+ startUploadRequest(bucketId: string, payload: StartUploadPayload, signal?: AbortSignal, parts?: number): Promise<StartUploadResponse>;
44
38
  /**
45
39
  * Finishes the upload of a file
46
40
  * @param bucketId
47
41
  * @param index
48
42
  * @param shards
49
43
  */
50
- private static finishUpload;
44
+ private finishUploadRequest;
51
45
  /**
52
46
  * Gets the download links for a file
53
47
  * @param bucketId
@@ -76,23 +76,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
76
76
  }
77
77
  };
78
78
  Object.defineProperty(exports, "__esModule", { value: true });
79
- exports.Network = exports.InvalidMultipartValueError = exports.FileTooSmallForMultipartError = exports.InvalidUploadSizeError = exports.InvalidUploadIndexError = exports.InvalidFileIndexError = exports.DuplicatedIndexesError = void 0;
79
+ exports.Network = exports.InvalidMultipartValueError = exports.FileTooSmallForMultipartError = exports.InvalidUploadSizeError = exports.InvalidFileIndexError = void 0;
80
80
  var index_1 = require("../shared/headers/index");
81
81
  var client_1 = require("../shared/http/client");
82
82
  var utils_1 = require("../utils");
83
83
  var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
84
84
  var uuidValidate = function (str) { return UUID_REGEX.test(str); };
85
85
  __exportStar(require("./types"), exports);
86
- var DuplicatedIndexesError = /** @class */ (function (_super) {
87
- __extends(DuplicatedIndexesError, _super);
88
- function DuplicatedIndexesError() {
89
- var _this = _super.call(this, 'Duplicated indexes found') || this;
90
- Object.setPrototypeOf(_this, DuplicatedIndexesError.prototype);
91
- return _this;
92
- }
93
- return DuplicatedIndexesError;
94
- }(Error));
95
- exports.DuplicatedIndexesError = DuplicatedIndexesError;
96
86
  var InvalidFileIndexError = /** @class */ (function (_super) {
97
87
  __extends(InvalidFileIndexError, _super);
98
88
  function InvalidFileIndexError() {
@@ -103,16 +93,6 @@ var InvalidFileIndexError = /** @class */ (function (_super) {
103
93
  return InvalidFileIndexError;
104
94
  }(Error));
105
95
  exports.InvalidFileIndexError = InvalidFileIndexError;
106
- var InvalidUploadIndexError = /** @class */ (function (_super) {
107
- __extends(InvalidUploadIndexError, _super);
108
- function InvalidUploadIndexError() {
109
- var _this = _super.call(this, 'Invalid upload index') || this;
110
- Object.setPrototypeOf(_this, InvalidUploadIndexError.prototype);
111
- return _this;
112
- }
113
- return InvalidUploadIndexError;
114
- }(Error));
115
- exports.InvalidUploadIndexError = InvalidUploadIndexError;
116
96
  var InvalidUploadSizeError = /** @class */ (function (_super) {
117
97
  __extends(InvalidUploadSizeError, _super);
118
98
  function InvalidUploadSizeError() {
@@ -162,82 +142,92 @@ var Network = /** @class */ (function () {
162
142
  enumerable: false,
163
143
  configurable: true
164
144
  });
165
- Network.prototype.startUpload = function (bucketId, payload, parts) {
166
- if (parts === void 0) { parts = 1; }
167
- var totalSize = 0;
168
- for (var _i = 0, _a = payload.uploads; _i < _a.length; _i++) {
169
- var _b = _a[_i], index = _b.index, size = _b.size;
170
- if (index < 0) {
171
- throw new InvalidUploadIndexError();
172
- }
173
- if (size < 0) {
174
- throw new InvalidUploadSizeError();
175
- }
176
- totalSize += size;
177
- }
178
- var MB100 = 100 * 1024 * 1024;
179
- if (totalSize < MB100 && parts > 1) {
180
- throw new FileTooSmallForMultipartError();
181
- }
182
- if (!Number.isInteger(parts) || parts < 1) {
183
- throw new InvalidMultipartValueError();
184
- }
185
- var uploadIndexesWithoutDuplicates = new Set(payload.uploads.map(function (upload) { return upload.index; }));
186
- if (uploadIndexesWithoutDuplicates.size < payload.uploads.length) {
187
- throw new DuplicatedIndexesError();
188
- }
189
- return Network.startUpload(bucketId, payload, {
190
- client: this.client,
191
- appDetails: this.appDetails,
192
- auth: this.auth,
193
- }, parts);
145
+ Network.prototype.startUpload = function (bucketId_1, fileSize_1, signal_1) {
146
+ return __awaiter(this, arguments, void 0, function (bucketId, fileSize, signal, parts) {
147
+ var MB100;
148
+ if (parts === void 0) { parts = 1; }
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ if (fileSize <= 0) {
153
+ throw new InvalidUploadSizeError();
154
+ }
155
+ MB100 = 100 * 1024 * 1024;
156
+ if (fileSize < MB100 && parts > 1) {
157
+ throw new FileTooSmallForMultipartError();
158
+ }
159
+ if (!Number.isInteger(parts) || parts < 1) {
160
+ throw new InvalidMultipartValueError();
161
+ }
162
+ return [4 /*yield*/, this.startUploadRequest(bucketId, { uploads: [{ index: 0, size: fileSize }] }, signal, parts)];
163
+ case 1: return [2 /*return*/, _a.sent()];
164
+ }
165
+ });
166
+ });
194
167
  };
195
- Network.prototype.finishUpload = function (bucketId, payload) {
196
- var index = payload.index, shards = payload.shards;
197
- if (!(0, utils_1.isHexString)(index) || index.length !== 64) {
198
- throw new InvalidFileIndexError();
199
- }
200
- for (var _i = 0, shards_1 = shards; _i < shards_1.length; _i++) {
201
- var shard = shards_1[_i];
202
- if (!uuidValidate(shard.uuid)) {
203
- throw new Error('Invalid UUID');
204
- }
205
- }
206
- return Network.finishUpload(bucketId, payload, {
207
- client: this.client,
208
- appDetails: this.appDetails,
209
- auth: this.auth,
168
+ Network.prototype.finishUpload = function (bucketId, payload, signal) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var index, shards, _i, shards_1, shard;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0:
174
+ index = payload.index, shards = payload.shards;
175
+ if (!(0, utils_1.isHexString)(index) || index.length !== 64) {
176
+ throw new InvalidFileIndexError();
177
+ }
178
+ for (_i = 0, shards_1 = shards; _i < shards_1.length; _i++) {
179
+ shard = shards_1[_i];
180
+ if (!uuidValidate(shard.uuid)) {
181
+ throw new Error('Invalid UUID');
182
+ }
183
+ }
184
+ return [4 /*yield*/, this.finishUploadRequest(bucketId, payload, signal)];
185
+ case 1: return [2 /*return*/, _a.sent()];
186
+ }
187
+ });
210
188
  });
211
189
  };
212
- Network.prototype.finishMultipartUpload = function (bucketId, payload) {
213
- var index = payload.index, shards = payload.shards;
214
- if (!(0, utils_1.isHexString)(index) || index.length !== 64) {
215
- throw new InvalidFileIndexError();
216
- }
217
- for (var _i = 0, shards_2 = shards; _i < shards_2.length; _i++) {
218
- var shard = shards_2[_i];
219
- if (!uuidValidate(shard.uuid)) {
220
- throw new Error('Invalid UUID');
221
- }
222
- if (!shard.UploadId) {
223
- throw new Error('Missing UploadId');
224
- }
225
- if (!shard.parts) {
226
- throw new Error('Missing parts');
227
- }
228
- }
229
- return Network.finishUpload(bucketId, payload, {
230
- client: this.client,
231
- appDetails: this.appDetails,
232
- auth: this.auth,
190
+ Network.prototype.finishMultipartUpload = function (bucketId, payload, signal) {
191
+ return __awaiter(this, void 0, void 0, function () {
192
+ var index, shards, _i, shards_2, shard;
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0:
196
+ index = payload.index, shards = payload.shards;
197
+ if (!(0, utils_1.isHexString)(index) || index.length !== 64) {
198
+ throw new InvalidFileIndexError();
199
+ }
200
+ for (_i = 0, shards_2 = shards; _i < shards_2.length; _i++) {
201
+ shard = shards_2[_i];
202
+ if (!uuidValidate(shard.uuid)) {
203
+ throw new Error('Invalid UUID');
204
+ }
205
+ if (!shard.UploadId) {
206
+ throw new Error('Missing UploadId');
207
+ }
208
+ if (!shard.parts) {
209
+ throw new Error('Missing parts');
210
+ }
211
+ }
212
+ return [4 /*yield*/, this.finishUploadRequest(bucketId, payload, signal)];
213
+ case 1: return [2 /*return*/, _a.sent()];
214
+ }
215
+ });
233
216
  });
234
217
  };
235
218
  Network.prototype.getDownloadLinks = function (bucketId, fileId, token) {
236
- return Network.getDownloadLinks(bucketId, fileId, {
237
- client: this.client,
238
- appDetails: this.appDetails,
239
- auth: this.auth,
240
- }, token);
219
+ return __awaiter(this, void 0, void 0, function () {
220
+ return __generator(this, function (_a) {
221
+ switch (_a.label) {
222
+ case 0: return [4 /*yield*/, Network.getDownloadLinks(bucketId, fileId, {
223
+ client: this.client,
224
+ appDetails: this.appDetails,
225
+ auth: this.auth,
226
+ }, token)];
227
+ case 1: return [2 /*return*/, _a.sent()];
228
+ }
229
+ });
230
+ });
241
231
  };
242
232
  Network.prototype.deleteFile = function (bucketId, fileId) {
243
233
  return __awaiter(this, void 0, void 0, function () {
@@ -260,11 +250,19 @@ var Network = /** @class */ (function () {
260
250
  * @param bucketId
261
251
  * @param uploads
262
252
  */
263
- Network.startUpload = function (bucketId, payload, _a, parts) {
264
- var client = _a.client, appDetails = _a.appDetails, auth = _a.auth;
265
- if (parts === void 0) { parts = 1; }
266
- var headers = Network.headersWithBasicAuth(appDetails, auth);
267
- return client.post("/v2/buckets/".concat(bucketId, "/files/start?multiparts=").concat(parts), payload, headers);
253
+ Network.prototype.startUploadRequest = function (bucketId_1, payload_1, signal_1) {
254
+ return __awaiter(this, arguments, void 0, function (bucketId, payload, signal, parts) {
255
+ var headers;
256
+ if (parts === void 0) { parts = 1; }
257
+ return __generator(this, function (_a) {
258
+ switch (_a.label) {
259
+ case 0:
260
+ headers = Network.headersWithBasicAuth(this.appDetails, this.auth);
261
+ return [4 /*yield*/, this.client.post("/v2/buckets/".concat(bucketId, "/files/start?multiparts=").concat(parts), payload, headers, signal)];
262
+ case 1: return [2 /*return*/, _a.sent()];
263
+ }
264
+ });
265
+ });
268
266
  };
269
267
  /**
270
268
  * Finishes the upload of a file
@@ -272,33 +270,58 @@ var Network = /** @class */ (function () {
272
270
  * @param index
273
271
  * @param shards
274
272
  */
275
- Network.finishUpload = function (bucketId, payload, _a) {
276
- var client = _a.client, appDetails = _a.appDetails, auth = _a.auth;
277
- var headers = Network.headersWithBasicAuth(appDetails, auth);
278
- return client.post("/v2/buckets/".concat(bucketId, "/files/finish"), payload, headers);
273
+ Network.prototype.finishUploadRequest = function (bucketId, payload, signal) {
274
+ return __awaiter(this, void 0, void 0, function () {
275
+ var headers;
276
+ return __generator(this, function (_a) {
277
+ switch (_a.label) {
278
+ case 0:
279
+ headers = Network.headersWithBasicAuth(this.appDetails, this.auth);
280
+ return [4 /*yield*/, this.client.post("/v2/buckets/".concat(bucketId, "/files/finish"), payload, headers, signal)];
281
+ case 1: return [2 /*return*/, _a.sent()];
282
+ }
283
+ });
284
+ });
279
285
  };
280
286
  /**
281
287
  * Gets the download links for a file
282
288
  * @param bucketId
283
289
  * @param file
284
290
  */
285
- Network.getDownloadLinks = function (bucketId, fileId, _a, token) {
286
- var client = _a.client, appDetails = _a.appDetails, auth = _a.auth;
287
- // ES ESTE EL QUE FALLA AL INTENTAR DESCARGAR UN FILE
288
- var headers = token
289
- ? Network.headersWithAuthToken(appDetails, token)
290
- : Network.headersWithBasicAuth(appDetails, auth);
291
- return client.get("/buckets/".concat(bucketId, "/files/").concat(fileId, "/info"), __assign(__assign({}, headers), { 'x-api-version': '2' }));
291
+ Network.getDownloadLinks = function (bucketId_1, fileId_1, _a, token_1) {
292
+ return __awaiter(this, arguments, void 0, function (bucketId, fileId, _b, token) {
293
+ var headers;
294
+ var client = _b.client, appDetails = _b.appDetails, auth = _b.auth;
295
+ return __generator(this, function (_c) {
296
+ switch (_c.label) {
297
+ case 0:
298
+ headers = token
299
+ ? Network.headersWithAuthToken(appDetails, token)
300
+ : Network.headersWithBasicAuth(appDetails, auth);
301
+ return [4 /*yield*/, client.get("/buckets/".concat(bucketId, "/files/").concat(fileId, "/info"), __assign(__assign({}, headers), { 'x-api-version': '2' }))];
302
+ case 1: return [2 /*return*/, _c.sent()];
303
+ }
304
+ });
305
+ });
292
306
  };
293
307
  /**
294
308
  * Deletes a file
295
309
  * @param bucketId
296
310
  * @param file
297
311
  */
298
- Network.deleteFile = function (bucketId, fileId, _a) {
299
- var client = _a.client, appDetails = _a.appDetails, auth = _a.auth;
300
- var headers = Network.headersWithBasicAuth(appDetails, auth);
301
- return client.delete("/v2/buckets/".concat(bucketId, "/files/").concat(fileId), headers);
312
+ Network.deleteFile = function (bucketId_1, fileId_1, _a) {
313
+ return __awaiter(this, arguments, void 0, function (bucketId, fileId, _b) {
314
+ var headers;
315
+ var client = _b.client, appDetails = _b.appDetails, auth = _b.auth;
316
+ return __generator(this, function (_c) {
317
+ switch (_c.label) {
318
+ case 0:
319
+ headers = Network.headersWithBasicAuth(appDetails, auth);
320
+ return [4 /*yield*/, client.delete("/v2/buckets/".concat(bucketId, "/files/").concat(fileId), headers)];
321
+ case 1: return [2 /*return*/, _c.sent()];
322
+ }
323
+ });
324
+ });
302
325
  };
303
326
  /**
304
327
  * Gets headers with basic auth
@@ -1,4 +1,4 @@
1
1
  import { Network } from '.';
2
2
  import { Crypto, EncryptFileFunction, UploadFileFunction, UploadFileMultipartFunction } from './types';
3
- export declare function uploadFile(network: Network, crypto: Crypto, bucketId: string, mnemonic: string, fileSize: number, encryptFile: EncryptFileFunction, uploadFile: UploadFileFunction): Promise<string>;
4
- export declare function uploadMultipartFile(network: Network, crypto: Crypto, bucketId: string, mnemonic: string, fileSize: number, encryptFile: EncryptFileFunction, uploadMultiparts: UploadFileMultipartFunction, parts?: number): Promise<string>;
3
+ export declare function uploadFile(network: Network, crypto: Crypto, bucketId: string, mnemonic: string, fileSize: number, encryptFile: EncryptFileFunction, uploadFile: UploadFileFunction, signal?: AbortSignal): Promise<string>;
4
+ export declare function uploadMultipartFile(network: Network, crypto: Crypto, bucketId: string, mnemonic: string, fileSize: number, encryptFile: EncryptFileFunction, uploadMultiparts: UploadFileMultipartFunction, signal?: AbortSignal, parts?: number): Promise<string>;
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.uploadFile = uploadFile;
40
40
  exports.uploadMultipartFile = uploadMultipartFile;
41
41
  var errors_1 = require("./errors");
42
- function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadFile) {
42
+ function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadFile, signal) {
43
43
  return __awaiter(this, void 0, void 0, function () {
44
44
  var index, iv, key, mnemonicIsValid, uploads, _a, url, uuid, hash, finishUploadPayload, finishUploadResponse, err_1, context;
45
45
  return __generator(this, function (_b) {
@@ -55,14 +55,7 @@ function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile,
55
55
  return [4 /*yield*/, crypto.generateFileKey(mnemonic, bucketId, index)];
56
56
  case 1:
57
57
  key = _b.sent();
58
- return [4 /*yield*/, network.startUpload(bucketId, {
59
- uploads: [
60
- {
61
- index: 0,
62
- size: fileSize,
63
- },
64
- ],
65
- })];
58
+ return [4 /*yield*/, network.startUpload(bucketId, fileSize, signal)];
66
59
  case 2:
67
60
  uploads = (_b.sent()).uploads;
68
61
  _a = uploads[0], url = _a.url, uuid = _a.uuid;
@@ -79,7 +72,7 @@ function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile,
79
72
  index: index.toString('hex'),
80
73
  shards: [{ hash: hash, uuid: uuid }],
81
74
  };
82
- return [4 /*yield*/, network.finishUpload(bucketId, finishUploadPayload)];
75
+ return [4 /*yield*/, network.finishUpload(bucketId, finishUploadPayload, signal)];
83
76
  case 5:
84
77
  finishUploadResponse = _b.sent();
85
78
  return [2 /*return*/, finishUploadResponse.id];
@@ -100,8 +93,8 @@ function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile,
100
93
  });
101
94
  });
102
95
  }
103
- function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSize_1, encryptFile_1, uploadMultiparts_1) {
104
- return __awaiter(this, arguments, void 0, function (network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadMultiparts, parts) {
96
+ function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSize_1, encryptFile_1, uploadMultiparts_1, signal_1) {
97
+ return __awaiter(this, arguments, void 0, function (network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadMultiparts, signal, parts) {
105
98
  var mnemonicIsValid, index, iv, key, uploads, _a, urls, uuid, UploadId, _b, hash, uploadedPartsReference, finishUploadPayload, finishUploadResponse;
106
99
  if (parts === void 0) { parts = 1; }
107
100
  return __generator(this, function (_c) {
@@ -116,14 +109,7 @@ function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSi
116
109
  return [4 /*yield*/, crypto.generateFileKey(mnemonic, bucketId, index)];
117
110
  case 1:
118
111
  key = _c.sent();
119
- return [4 /*yield*/, network.startUpload(bucketId, {
120
- uploads: [
121
- {
122
- index: 0,
123
- size: fileSize,
124
- },
125
- ],
126
- }, parts)];
112
+ return [4 /*yield*/, network.startUpload(bucketId, fileSize, signal, parts)];
127
113
  case 2:
128
114
  uploads = (_c.sent()).uploads;
129
115
  _a = uploads[0], urls = _a.urls, uuid = _a.uuid, UploadId = _a.UploadId;
@@ -143,7 +129,7 @@ function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSi
143
129
  index: index.toString('hex'),
144
130
  shards: [{ hash: hash, uuid: uuid, UploadId: UploadId, parts: uploadedPartsReference }],
145
131
  };
146
- return [4 /*yield*/, network.finishUpload(bucketId, finishUploadPayload)];
132
+ return [4 /*yield*/, network.finishUpload(bucketId, finishUploadPayload, signal)];
147
133
  case 5:
148
134
  finishUploadResponse = _c.sent();
149
135
  return [2 /*return*/, finishUploadResponse.id];
@@ -62,7 +62,7 @@ export declare class HttpClient {
62
62
  * @param params
63
63
  * @param headers
64
64
  */
65
- post<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
65
+ post<Response>(url: URL, params: Parameters, headers: Headers, signal?: AbortSignal): Promise<Response>;
66
66
  /**
67
67
  * Requests a POST FORM
68
68
  * @param url
@@ -1,4 +1,40 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
40
  };
@@ -58,8 +94,15 @@ var HttpClient = /** @class */ (function () {
58
94
  * @param headers
59
95
  */
60
96
  HttpClient.prototype.get = function (url, headers) {
61
- var _this = this;
62
- return this.execute(function () { return _this.axios.get(url, { headers: headers }); });
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var _this = this;
99
+ return __generator(this, function (_a) {
100
+ switch (_a.label) {
101
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.get(url, { headers: headers }); })];
102
+ case 1: return [2 /*return*/, _a.sent()];
103
+ }
104
+ });
105
+ });
63
106
  };
64
107
  /**
65
108
  * Requests a GET
@@ -68,8 +111,15 @@ var HttpClient = /** @class */ (function () {
68
111
  * @param headers
69
112
  */
70
113
  HttpClient.prototype.getWithParams = function (url, params, headers) {
71
- var _this = this;
72
- return this.execute(function () { return _this.axios.get(url, { params: params, headers: headers }); });
114
+ return __awaiter(this, void 0, void 0, function () {
115
+ var _this = this;
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.get(url, { params: params, headers: headers }); })];
119
+ case 1: return [2 /*return*/, _a.sent()];
120
+ }
121
+ });
122
+ });
73
123
  };
74
124
  /**
75
125
  * Requests a GET with option to cancel
@@ -93,9 +143,16 @@ var HttpClient = /** @class */ (function () {
93
143
  * @param params
94
144
  * @param headers
95
145
  */
96
- HttpClient.prototype.post = function (url, params, headers) {
97
- var _this = this;
98
- return this.execute(function () { return _this.axios.post(url, params, { headers: headers }); });
146
+ HttpClient.prototype.post = function (url, params, headers, signal) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ var _this = this;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.post(url, params, { headers: headers, signal: signal }); })];
152
+ case 1: return [2 /*return*/, _a.sent()];
153
+ }
154
+ });
155
+ });
99
156
  };
100
157
  /**
101
158
  * Requests a POST FORM
@@ -104,8 +161,15 @@ var HttpClient = /** @class */ (function () {
104
161
  * @param headers
105
162
  */
106
163
  HttpClient.prototype.postForm = function (url, params, headers) {
107
- var _this = this;
108
- return this.execute(function () { return _this.axios.postForm(url, params, { headers: headers }); });
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var _this = this;
166
+ return __generator(this, function (_a) {
167
+ switch (_a.label) {
168
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.postForm(url, params, { headers: headers }); })];
169
+ case 1: return [2 /*return*/, _a.sent()];
170
+ }
171
+ });
172
+ });
109
173
  };
110
174
  /**
111
175
  * Requests a POST with option to cancel
@@ -131,8 +195,15 @@ var HttpClient = /** @class */ (function () {
131
195
  * @param headers
132
196
  */
133
197
  HttpClient.prototype.patch = function (url, params, headers) {
134
- var _this = this;
135
- return this.execute(function () { return _this.axios.patch(url, params, { headers: headers }); });
198
+ return __awaiter(this, void 0, void 0, function () {
199
+ var _this = this;
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.patch(url, params, { headers: headers }); })];
203
+ case 1: return [2 /*return*/, _a.sent()];
204
+ }
205
+ });
206
+ });
136
207
  };
137
208
  /**
138
209
  * Requests a PUT
@@ -141,8 +212,15 @@ var HttpClient = /** @class */ (function () {
141
212
  * @param headers
142
213
  */
143
214
  HttpClient.prototype.put = function (url, params, headers) {
144
- var _this = this;
145
- return this.execute(function () { return _this.axios.put(url, params, { headers: headers }); });
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var _this = this;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.put(url, params, { headers: headers }); })];
220
+ case 1: return [2 /*return*/, _a.sent()];
221
+ }
222
+ });
223
+ });
146
224
  };
147
225
  /**
148
226
  * Requests a PUT FORM
@@ -151,8 +229,15 @@ var HttpClient = /** @class */ (function () {
151
229
  * @param headers
152
230
  */
153
231
  HttpClient.prototype.putForm = function (url, params, headers) {
154
- var _this = this;
155
- return this.execute(function () { return _this.axios.putForm(url, params, { headers: headers }); });
232
+ return __awaiter(this, void 0, void 0, function () {
233
+ var _this = this;
234
+ return __generator(this, function (_a) {
235
+ switch (_a.label) {
236
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.putForm(url, params, { headers: headers }); })];
237
+ case 1: return [2 /*return*/, _a.sent()];
238
+ }
239
+ });
240
+ });
156
241
  };
157
242
  /**
158
243
  * Requests a DELETE
@@ -161,8 +246,15 @@ var HttpClient = /** @class */ (function () {
161
246
  * @param params
162
247
  */
163
248
  HttpClient.prototype.delete = function (url, headers, params) {
164
- var _this = this;
165
- return this.execute(function () { return _this.axios.delete(url, { headers: headers, data: params }); });
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ var _this = this;
251
+ return __generator(this, function (_a) {
252
+ switch (_a.label) {
253
+ case 0: return [4 /*yield*/, this.execute(function () { return _this.axios.delete(url, { headers: headers, data: params }); })];
254
+ case 1: return [2 /*return*/, _a.sent()];
255
+ }
256
+ });
257
+ });
166
258
  };
167
259
  /**
168
260
  * Sets middlewares into the client for common behaviour managing
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@internxt/sdk",
3
3
  "author": "Internxt <hello@internxt.com>",
4
- "version": "1.15.1",
4
+ "version": "1.15.2",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",