@avalabs/glacier-sdk 2.8.0-canary.5601e64.0 → 2.8.0-canary.5825aa6.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 (33) hide show
  1. package/dist/index.d.ts +232 -160
  2. package/dist/index.js +184 -120
  3. package/esm/generated/Glacier.d.ts +4 -0
  4. package/esm/generated/Glacier.js +6 -0
  5. package/esm/generated/core/CancelablePromise.d.ts +2 -8
  6. package/esm/generated/core/CancelablePromise.js +41 -36
  7. package/esm/generated/core/OpenAPI.d.ts +5 -5
  8. package/esm/generated/core/request.js +25 -9
  9. package/esm/generated/models/ChainInfo.d.ts +1 -0
  10. package/esm/generated/models/GetChainResponse.d.ts +1 -0
  11. package/esm/generated/models/GlacierApiFeature.d.ts +5 -0
  12. package/esm/generated/models/GlacierApiFeature.js +6 -0
  13. package/esm/generated/models/PrimaryNetworkOptions.d.ts +1 -1
  14. package/esm/generated/models/RegisterWebhookRequest.d.ts +8 -0
  15. package/esm/generated/models/RpcErrorDto.d.ts +7 -0
  16. package/esm/generated/models/RpcErrorResponseDto.d.ts +9 -0
  17. package/esm/generated/models/RpcRequestBodyDto.d.ts +8 -0
  18. package/esm/generated/models/RpcSuccessResponseDto.d.ts +7 -0
  19. package/esm/generated/models/UpdateWebhookRequest.d.ts +2 -0
  20. package/esm/generated/models/WebhookResponse.d.ts +8 -0
  21. package/esm/generated/services/DefaultService.d.ts +0 -86
  22. package/esm/generated/services/DefaultService.js +0 -73
  23. package/esm/generated/services/EvmChainsService.d.ts +6 -1
  24. package/esm/generated/services/EvmChainsService.js +4 -2
  25. package/esm/generated/services/PrimaryNetworkService.d.ts +1 -1
  26. package/esm/generated/services/PrimaryNetworkService.js +1 -1
  27. package/esm/generated/services/RpcService.d.ts +25 -0
  28. package/esm/generated/services/RpcService.js +24 -0
  29. package/esm/generated/services/WebhooksService.d.ts +95 -0
  30. package/esm/generated/services/WebhooksService.js +80 -0
  31. package/esm/index.d.ts +7 -0
  32. package/esm/index.js +3 -0
  33. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -33,71 +33,75 @@ class CancelError extends Error {
33
33
  }
34
34
  }
35
35
  class CancelablePromise {
36
- [Symbol.toStringTag];
37
- _isResolved;
38
- _isRejected;
39
- _isCancelled;
40
- _cancelHandlers;
41
- _promise;
42
- _resolve;
43
- _reject;
36
+ #isResolved;
37
+ #isRejected;
38
+ #isCancelled;
39
+ #cancelHandlers;
40
+ #promise;
41
+ #resolve;
42
+ #reject;
44
43
  constructor(executor) {
45
- this._isResolved = false;
46
- this._isRejected = false;
47
- this._isCancelled = false;
48
- this._cancelHandlers = [];
49
- this._promise = new Promise((resolve, reject) => {
50
- this._resolve = resolve;
51
- this._reject = reject;
44
+ this.#isResolved = false;
45
+ this.#isRejected = false;
46
+ this.#isCancelled = false;
47
+ this.#cancelHandlers = [];
48
+ this.#promise = new Promise((resolve, reject) => {
49
+ this.#resolve = resolve;
50
+ this.#reject = reject;
52
51
  const onResolve = (value) => {
53
- if (this._isResolved || this._isRejected || this._isCancelled) {
52
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
54
53
  return;
55
54
  }
56
- this._isResolved = true;
57
- this._resolve?.(value);
55
+ this.#isResolved = true;
56
+ if (this.#resolve)
57
+ this.#resolve(value);
58
58
  };
59
59
  const onReject = (reason) => {
60
- if (this._isResolved || this._isRejected || this._isCancelled) {
60
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
61
61
  return;
62
62
  }
63
- this._isRejected = true;
64
- this._reject?.(reason);
63
+ this.#isRejected = true;
64
+ if (this.#reject)
65
+ this.#reject(reason);
65
66
  };
66
67
  const onCancel = (cancelHandler) => {
67
- if (this._isResolved || this._isRejected || this._isCancelled) {
68
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
68
69
  return;
69
70
  }
70
- this._cancelHandlers.push(cancelHandler);
71
+ this.#cancelHandlers.push(cancelHandler);
71
72
  };
72
73
  Object.defineProperty(onCancel, "isResolved", {
73
- get: () => this._isResolved
74
+ get: () => this.#isResolved
74
75
  });
75
76
  Object.defineProperty(onCancel, "isRejected", {
76
- get: () => this._isRejected
77
+ get: () => this.#isRejected
77
78
  });
78
79
  Object.defineProperty(onCancel, "isCancelled", {
79
- get: () => this._isCancelled
80
+ get: () => this.#isCancelled
80
81
  });
81
82
  return executor(onResolve, onReject, onCancel);
82
83
  });
83
84
  }
85
+ get [Symbol.toStringTag]() {
86
+ return "Cancellable Promise";
87
+ }
84
88
  then(onFulfilled, onRejected) {
85
- return this._promise.then(onFulfilled, onRejected);
89
+ return this.#promise.then(onFulfilled, onRejected);
86
90
  }
87
91
  catch(onRejected) {
88
- return this._promise.catch(onRejected);
92
+ return this.#promise.catch(onRejected);
89
93
  }
90
94
  finally(onFinally) {
91
- return this._promise.finally(onFinally);
95
+ return this.#promise.finally(onFinally);
92
96
  }
93
97
  cancel() {
94
- if (this._isResolved || this._isRejected || this._isCancelled) {
98
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
95
99
  return;
96
100
  }
97
- this._isCancelled = true;
98
- if (this._cancelHandlers.length) {
101
+ this.#isCancelled = true;
102
+ if (this.#cancelHandlers.length) {
99
103
  try {
100
- for (const cancelHandler of this._cancelHandlers) {
104
+ for (const cancelHandler of this.#cancelHandlers) {
101
105
  cancelHandler();
102
106
  }
103
107
  } catch (error) {
@@ -105,11 +109,12 @@ class CancelablePromise {
105
109
  return;
106
110
  }
107
111
  }
108
- this._cancelHandlers.length = 0;
109
- this._reject?.(new CancelError("Request aborted"));
112
+ this.#cancelHandlers.length = 0;
113
+ if (this.#reject)
114
+ this.#reject(new CancelError("Request aborted"));
110
115
  }
111
116
  get isCancelled() {
112
- return this._isCancelled;
117
+ return this.#isCancelled;
113
118
  }
114
119
  }
115
120
 
@@ -205,10 +210,12 @@ const resolve = async (options, resolver) => {
205
210
  return resolver;
206
211
  };
207
212
  const getHeaders = async (config, options) => {
208
- const token = await resolve(options, config.TOKEN);
209
- const username = await resolve(options, config.USERNAME);
210
- const password = await resolve(options, config.PASSWORD);
211
- const additionalHeaders = await resolve(options, config.HEADERS);
213
+ const [token, username, password, additionalHeaders] = await Promise.all([
214
+ resolve(options, config.TOKEN),
215
+ resolve(options, config.USERNAME),
216
+ resolve(options, config.PASSWORD),
217
+ resolve(options, config.HEADERS)
218
+ ]);
212
219
  const headers = Object.entries({
213
220
  Accept: "application/json",
214
221
  ...additionalHeaders,
@@ -224,7 +231,7 @@ const getHeaders = async (config, options) => {
224
231
  const credentials = base64(`${username}:${password}`);
225
232
  headers["Authorization"] = `Basic ${credentials}`;
226
233
  }
227
- if (options.body) {
234
+ if (options.body !== void 0) {
228
235
  if (options.mediaType) {
229
236
  headers["Content-Type"] = options.mediaType;
230
237
  } else if (isBlob(options.body)) {
@@ -238,7 +245,7 @@ const getHeaders = async (config, options) => {
238
245
  return new Headers(headers);
239
246
  };
240
247
  const getRequestBody = (options) => {
241
- if (options.body) {
248
+ if (options.body !== void 0) {
242
249
  if (options.mediaType?.includes("/json")) {
243
250
  return JSON.stringify(options.body);
244
251
  } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
@@ -277,7 +284,8 @@ const getResponseBody = async (response) => {
277
284
  try {
278
285
  const contentType = response.headers.get("Content-Type");
279
286
  if (contentType) {
280
- const isJSON = contentType.toLowerCase().startsWith("application/json");
287
+ const jsonTypes = ["application/json", "application/problem+json"];
288
+ const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
281
289
  if (isJSON) {
282
290
  return await response.json();
283
291
  } else {
@@ -306,7 +314,20 @@ const catchErrorCodes = (options, result) => {
306
314
  throw new ApiError(options, result, error);
307
315
  }
308
316
  if (!result.ok) {
309
- throw new ApiError(options, result, "Generic Error");
317
+ const errorStatus = result.status ?? "unknown";
318
+ const errorStatusText = result.statusText ?? "unknown";
319
+ const errorBody = (() => {
320
+ try {
321
+ return JSON.stringify(result.body, null, 2);
322
+ } catch (e) {
323
+ return void 0;
324
+ }
325
+ })();
326
+ throw new ApiError(
327
+ options,
328
+ result,
329
+ `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
330
+ );
310
331
  }
311
332
  };
312
333
  const request = (config, options) => {
@@ -355,79 +376,6 @@ class DefaultService {
355
376
  url: "/v1/media/uploadImage"
356
377
  });
357
378
  }
358
- registerWebhook({
359
- requestBody
360
- }) {
361
- return this.httpRequest.request({
362
- method: "POST",
363
- url: "/v1/webhooks",
364
- body: requestBody,
365
- mediaType: "application/json"
366
- });
367
- }
368
- listWebhooks({
369
- pageToken,
370
- pageSize = 10,
371
- status
372
- }) {
373
- return this.httpRequest.request({
374
- method: "GET",
375
- url: "/v1/webhooks",
376
- query: {
377
- "pageToken": pageToken,
378
- "pageSize": pageSize,
379
- "status": status
380
- }
381
- });
382
- }
383
- getWebhook({
384
- id
385
- }) {
386
- return this.httpRequest.request({
387
- method: "GET",
388
- url: "/v1/webhooks/{id}",
389
- path: {
390
- "id": id
391
- }
392
- });
393
- }
394
- deactivateWebhook({
395
- id
396
- }) {
397
- return this.httpRequest.request({
398
- method: "DELETE",
399
- url: "/v1/webhooks/{id}",
400
- path: {
401
- "id": id
402
- }
403
- });
404
- }
405
- updateWebhook({
406
- id,
407
- requestBody
408
- }) {
409
- return this.httpRequest.request({
410
- method: "PATCH",
411
- url: "/v1/webhooks/{id}",
412
- path: {
413
- "id": id
414
- },
415
- body: requestBody,
416
- mediaType: "application/json"
417
- });
418
- }
419
- generateSharedSecret() {
420
- return this.httpRequest.request({
421
- method: "POST",
422
- url: "/v1/webhooks:generateOrRotateSharedSecret"
423
- });
424
- }
425
- getSharedSecret() {
426
- return this.httpRequest.request({
427
- method: "GET",
428
- url: "/v1/webhooks:getSharedSecret"
429
- });
430
- }
431
379
  }
432
380
 
433
381
  class EvmBalancesService {
@@ -586,13 +534,15 @@ class EvmChainsService {
586
534
  this.httpRequest = httpRequest;
587
535
  }
588
536
  supportedChains({
589
- network
537
+ network,
538
+ feature
590
539
  }) {
591
540
  return this.httpRequest.request({
592
541
  method: "GET",
593
542
  url: "/v1/chains",
594
543
  query: {
595
- "network": network
544
+ "network": network,
545
+ "feature": feature
596
546
  }
597
547
  });
598
548
  }
@@ -1084,7 +1034,7 @@ class PrimaryNetworkService {
1084
1034
  minDelegationCapacity,
1085
1035
  maxDelegationCapacity,
1086
1036
  minTimeRemaining,
1087
- maxTimeRemaining = 2147483647,
1037
+ maxTimeRemaining,
1088
1038
  minFeePercentage,
1089
1039
  maxFeePercentage,
1090
1040
  subnetId
@@ -1503,6 +1453,29 @@ class PrimaryNetworkVerticesService {
1503
1453
  }
1504
1454
  }
1505
1455
 
1456
+ class RpcService {
1457
+ constructor(httpRequest) {
1458
+ this.httpRequest = httpRequest;
1459
+ }
1460
+ rpc({
1461
+ chainId,
1462
+ requestBody
1463
+ }) {
1464
+ return this.httpRequest.request({
1465
+ method: "POST",
1466
+ url: "/v1/ext/bc/{chainId}/rpc",
1467
+ path: {
1468
+ "chainId": chainId
1469
+ },
1470
+ body: requestBody,
1471
+ mediaType: "application/json",
1472
+ errors: {
1473
+ 504: `Request timed out`
1474
+ }
1475
+ });
1476
+ }
1477
+ }
1478
+
1506
1479
  class TeleporterService {
1507
1480
  constructor(httpRequest) {
1508
1481
  this.httpRequest = httpRequest;
@@ -1541,6 +1514,85 @@ class TeleporterService {
1541
1514
  }
1542
1515
  }
1543
1516
 
1517
+ class WebhooksService {
1518
+ constructor(httpRequest) {
1519
+ this.httpRequest = httpRequest;
1520
+ }
1521
+ registerWebhook({
1522
+ requestBody
1523
+ }) {
1524
+ return this.httpRequest.request({
1525
+ method: "POST",
1526
+ url: "/v1/webhooks",
1527
+ body: requestBody,
1528
+ mediaType: "application/json"
1529
+ });
1530
+ }
1531
+ listWebhooks({
1532
+ pageToken,
1533
+ pageSize = 10,
1534
+ status
1535
+ }) {
1536
+ return this.httpRequest.request({
1537
+ method: "GET",
1538
+ url: "/v1/webhooks",
1539
+ query: {
1540
+ "pageToken": pageToken,
1541
+ "pageSize": pageSize,
1542
+ "status": status
1543
+ }
1544
+ });
1545
+ }
1546
+ getWebhook({
1547
+ id
1548
+ }) {
1549
+ return this.httpRequest.request({
1550
+ method: "GET",
1551
+ url: "/v1/webhooks/{id}",
1552
+ path: {
1553
+ "id": id
1554
+ }
1555
+ });
1556
+ }
1557
+ deactivateWebhook({
1558
+ id
1559
+ }) {
1560
+ return this.httpRequest.request({
1561
+ method: "DELETE",
1562
+ url: "/v1/webhooks/{id}",
1563
+ path: {
1564
+ "id": id
1565
+ }
1566
+ });
1567
+ }
1568
+ updateWebhook({
1569
+ id,
1570
+ requestBody
1571
+ }) {
1572
+ return this.httpRequest.request({
1573
+ method: "PATCH",
1574
+ url: "/v1/webhooks/{id}",
1575
+ path: {
1576
+ "id": id
1577
+ },
1578
+ body: requestBody,
1579
+ mediaType: "application/json"
1580
+ });
1581
+ }
1582
+ generateSharedSecret() {
1583
+ return this.httpRequest.request({
1584
+ method: "POST",
1585
+ url: "/v1/webhooks:generateOrRotateSharedSecret"
1586
+ });
1587
+ }
1588
+ getSharedSecret() {
1589
+ return this.httpRequest.request({
1590
+ method: "GET",
1591
+ url: "/v1/webhooks:getSharedSecret"
1592
+ });
1593
+ }
1594
+ }
1595
+
1544
1596
  class Glacier {
1545
1597
  default;
1546
1598
  evmBalances;
@@ -1558,7 +1610,9 @@ class Glacier {
1558
1610
  primaryNetworkTransactions;
1559
1611
  primaryNetworkUtxOs;
1560
1612
  primaryNetworkVertices;
1613
+ rpc;
1561
1614
  teleporter;
1615
+ webhooks;
1562
1616
  request;
1563
1617
  constructor(config, HttpRequest = FetchHttpRequest) {
1564
1618
  this.request = new HttpRequest({
@@ -1588,7 +1642,9 @@ class Glacier {
1588
1642
  this.primaryNetworkTransactions = new PrimaryNetworkTransactionsService(this.request);
1589
1643
  this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
1590
1644
  this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
1645
+ this.rpc = new RpcService(this.request);
1591
1646
  this.teleporter = new TeleporterService(this.request);
1647
+ this.webhooks = new WebhooksService(this.request);
1592
1648
  }
1593
1649
  }
1594
1650
 
@@ -1813,6 +1869,11 @@ var EVMOperationType = /* @__PURE__ */ ((EVMOperationType2) => {
1813
1869
  return EVMOperationType2;
1814
1870
  })(EVMOperationType || {});
1815
1871
 
1872
+ var GlacierApiFeature = /* @__PURE__ */ ((GlacierApiFeature2) => {
1873
+ GlacierApiFeature2["NFT_INDEXING"] = "nftIndexing";
1874
+ return GlacierApiFeature2;
1875
+ })(GlacierApiFeature || {});
1876
+
1816
1877
  var InternalTransactionOpCall = /* @__PURE__ */ ((InternalTransactionOpCall2) => {
1817
1878
  InternalTransactionOpCall2["UNKNOWN"] = "UNKNOWN";
1818
1879
  InternalTransactionOpCall2["CALL"] = "CALL";
@@ -2128,6 +2189,7 @@ exports.EvmChainsService = EvmChainsService;
2128
2189
  exports.EvmContractsService = EvmContractsService;
2129
2190
  exports.EvmTransactionsService = EvmTransactionsService;
2130
2191
  exports.Glacier = Glacier;
2192
+ exports.GlacierApiFeature = GlacierApiFeature;
2131
2193
  exports.HealthCheckService = HealthCheckService;
2132
2194
  exports.InternalTransactionOpCall = InternalTransactionOpCall;
2133
2195
  exports.Network = Network;
@@ -2156,6 +2218,7 @@ exports.PrimaryNetworkUtxOsService = PrimaryNetworkUtxOsService;
2156
2218
  exports.PrimaryNetworkVerticesService = PrimaryNetworkVerticesService;
2157
2219
  exports.ResourceLinkType = ResourceLinkType;
2158
2220
  exports.RewardType = RewardType;
2221
+ exports.RpcService = RpcService;
2159
2222
  exports.SortOrder = SortOrder;
2160
2223
  exports.TeleporterService = TeleporterService;
2161
2224
  exports.TransactionMethodType = TransactionMethodType;
@@ -2165,5 +2228,6 @@ exports.ValidationStatusType = ValidationStatusType;
2165
2228
  exports.VmName = VmName;
2166
2229
  exports.WebhookStatus = WebhookStatus;
2167
2230
  exports.WebhookStatusType = WebhookStatusType;
2231
+ exports.WebhooksService = WebhooksService;
2168
2232
  exports.XChainId = XChainId;
2169
2233
  exports.XChainTransactionType = XChainTransactionType;
@@ -16,7 +16,9 @@ import { PrimaryNetworkRewardsService } from './services/PrimaryNetworkRewardsSe
16
16
  import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTransactionsService.js';
17
17
  import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
18
18
  import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
19
+ import { RpcService } from './services/RpcService.js';
19
20
  import { TeleporterService } from './services/TeleporterService.js';
21
+ import { WebhooksService } from './services/WebhooksService.js';
20
22
 
21
23
  type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
22
24
  declare class Glacier {
@@ -36,7 +38,9 @@ declare class Glacier {
36
38
  readonly primaryNetworkTransactions: PrimaryNetworkTransactionsService;
37
39
  readonly primaryNetworkUtxOs: PrimaryNetworkUtxOsService;
38
40
  readonly primaryNetworkVertices: PrimaryNetworkVerticesService;
41
+ readonly rpc: RpcService;
39
42
  readonly teleporter: TeleporterService;
43
+ readonly webhooks: WebhooksService;
40
44
  readonly request: BaseHttpRequest;
41
45
  constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
42
46
  }
@@ -15,7 +15,9 @@ import { PrimaryNetworkRewardsService } from './services/PrimaryNetworkRewardsSe
15
15
  import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTransactionsService.js';
16
16
  import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
17
17
  import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
18
+ import { RpcService } from './services/RpcService.js';
18
19
  import { TeleporterService } from './services/TeleporterService.js';
20
+ import { WebhooksService } from './services/WebhooksService.js';
19
21
 
20
22
  class Glacier {
21
23
  default;
@@ -34,7 +36,9 @@ class Glacier {
34
36
  primaryNetworkTransactions;
35
37
  primaryNetworkUtxOs;
36
38
  primaryNetworkVertices;
39
+ rpc;
37
40
  teleporter;
41
+ webhooks;
38
42
  request;
39
43
  constructor(config, HttpRequest = FetchHttpRequest) {
40
44
  this.request = new HttpRequest({
@@ -64,7 +68,9 @@ class Glacier {
64
68
  this.primaryNetworkTransactions = new PrimaryNetworkTransactionsService(this.request);
65
69
  this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
66
70
  this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
71
+ this.rpc = new RpcService(this.request);
67
72
  this.teleporter = new TeleporterService(this.request);
73
+ this.webhooks = new WebhooksService(this.request);
68
74
  }
69
75
  }
70
76
 
@@ -9,15 +9,9 @@ interface OnCancel {
9
9
  (cancelHandler: () => void): void;
10
10
  }
11
11
  declare class CancelablePromise<T> implements Promise<T> {
12
- readonly [Symbol.toStringTag]: string;
13
- private _isResolved;
14
- private _isRejected;
15
- private _isCancelled;
16
- private readonly _cancelHandlers;
17
- private readonly _promise;
18
- private _resolve?;
19
- private _reject?;
12
+ #private;
20
13
  constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
14
+ get [Symbol.toStringTag](): string;
21
15
  then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
22
16
  catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
23
17
  finally(onFinally?: (() => void) | null): Promise<T>;
@@ -8,71 +8,75 @@ class CancelError extends Error {
8
8
  }
9
9
  }
10
10
  class CancelablePromise {
11
- [Symbol.toStringTag];
12
- _isResolved;
13
- _isRejected;
14
- _isCancelled;
15
- _cancelHandlers;
16
- _promise;
17
- _resolve;
18
- _reject;
11
+ #isResolved;
12
+ #isRejected;
13
+ #isCancelled;
14
+ #cancelHandlers;
15
+ #promise;
16
+ #resolve;
17
+ #reject;
19
18
  constructor(executor) {
20
- this._isResolved = false;
21
- this._isRejected = false;
22
- this._isCancelled = false;
23
- this._cancelHandlers = [];
24
- this._promise = new Promise((resolve, reject) => {
25
- this._resolve = resolve;
26
- this._reject = reject;
19
+ this.#isResolved = false;
20
+ this.#isRejected = false;
21
+ this.#isCancelled = false;
22
+ this.#cancelHandlers = [];
23
+ this.#promise = new Promise((resolve, reject) => {
24
+ this.#resolve = resolve;
25
+ this.#reject = reject;
27
26
  const onResolve = (value) => {
28
- if (this._isResolved || this._isRejected || this._isCancelled) {
27
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
29
28
  return;
30
29
  }
31
- this._isResolved = true;
32
- this._resolve?.(value);
30
+ this.#isResolved = true;
31
+ if (this.#resolve)
32
+ this.#resolve(value);
33
33
  };
34
34
  const onReject = (reason) => {
35
- if (this._isResolved || this._isRejected || this._isCancelled) {
35
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
36
36
  return;
37
37
  }
38
- this._isRejected = true;
39
- this._reject?.(reason);
38
+ this.#isRejected = true;
39
+ if (this.#reject)
40
+ this.#reject(reason);
40
41
  };
41
42
  const onCancel = (cancelHandler) => {
42
- if (this._isResolved || this._isRejected || this._isCancelled) {
43
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
43
44
  return;
44
45
  }
45
- this._cancelHandlers.push(cancelHandler);
46
+ this.#cancelHandlers.push(cancelHandler);
46
47
  };
47
48
  Object.defineProperty(onCancel, "isResolved", {
48
- get: () => this._isResolved
49
+ get: () => this.#isResolved
49
50
  });
50
51
  Object.defineProperty(onCancel, "isRejected", {
51
- get: () => this._isRejected
52
+ get: () => this.#isRejected
52
53
  });
53
54
  Object.defineProperty(onCancel, "isCancelled", {
54
- get: () => this._isCancelled
55
+ get: () => this.#isCancelled
55
56
  });
56
57
  return executor(onResolve, onReject, onCancel);
57
58
  });
58
59
  }
60
+ get [Symbol.toStringTag]() {
61
+ return "Cancellable Promise";
62
+ }
59
63
  then(onFulfilled, onRejected) {
60
- return this._promise.then(onFulfilled, onRejected);
64
+ return this.#promise.then(onFulfilled, onRejected);
61
65
  }
62
66
  catch(onRejected) {
63
- return this._promise.catch(onRejected);
67
+ return this.#promise.catch(onRejected);
64
68
  }
65
69
  finally(onFinally) {
66
- return this._promise.finally(onFinally);
70
+ return this.#promise.finally(onFinally);
67
71
  }
68
72
  cancel() {
69
- if (this._isResolved || this._isRejected || this._isCancelled) {
73
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
70
74
  return;
71
75
  }
72
- this._isCancelled = true;
73
- if (this._cancelHandlers.length) {
76
+ this.#isCancelled = true;
77
+ if (this.#cancelHandlers.length) {
74
78
  try {
75
- for (const cancelHandler of this._cancelHandlers) {
79
+ for (const cancelHandler of this.#cancelHandlers) {
76
80
  cancelHandler();
77
81
  }
78
82
  } catch (error) {
@@ -80,11 +84,12 @@ class CancelablePromise {
80
84
  return;
81
85
  }
82
86
  }
83
- this._cancelHandlers.length = 0;
84
- this._reject?.(new CancelError("Request aborted"));
87
+ this.#cancelHandlers.length = 0;
88
+ if (this.#reject)
89
+ this.#reject(new CancelError("Request aborted"));
85
90
  }
86
91
  get isCancelled() {
87
- return this._isCancelled;
92
+ return this.#isCancelled;
88
93
  }
89
94
  }
90
95
 
@@ -7,11 +7,11 @@ type OpenAPIConfig = {
7
7
  VERSION: string;
8
8
  WITH_CREDENTIALS: boolean;
9
9
  CREDENTIALS: 'include' | 'omit' | 'same-origin';
10
- TOKEN?: string | Resolver<string>;
11
- USERNAME?: string | Resolver<string>;
12
- PASSWORD?: string | Resolver<string>;
13
- HEADERS?: Headers | Resolver<Headers>;
14
- ENCODE_PATH?: (path: string) => string;
10
+ TOKEN?: string | Resolver<string> | undefined;
11
+ USERNAME?: string | Resolver<string> | undefined;
12
+ PASSWORD?: string | Resolver<string> | undefined;
13
+ HEADERS?: Headers | Resolver<Headers> | undefined;
14
+ ENCODE_PATH?: ((path: string) => string) | undefined;
15
15
  };
16
16
  declare const OpenAPI: OpenAPIConfig;
17
17