api-def 0.12.1 → 0.14.0-alpha.1

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 (87) hide show
  1. package/README.md +3 -0
  2. package/bin/index.js +312 -313
  3. package/cjs/Api.d.ts +1 -1
  4. package/cjs/Api.js +99 -145
  5. package/cjs/ApiTypes.d.ts +3 -2
  6. package/cjs/ApiUtils.js +30 -32
  7. package/cjs/Endpoint.d.ts +1 -1
  8. package/cjs/Endpoint.js +112 -175
  9. package/cjs/EndpointBuilder.d.ts +17 -0
  10. package/cjs/EndpointBuilder.js +55 -36
  11. package/cjs/QueryHandling.js +12 -13
  12. package/cjs/RequestConfig.js +54 -36
  13. package/cjs/RequestContext.d.ts +2 -1
  14. package/cjs/RequestContext.js +143 -180
  15. package/cjs/RequestError.js +16 -19
  16. package/cjs/Requester.js +231 -312
  17. package/cjs/TextDecoding.js +31 -31
  18. package/cjs/Utils.d.ts +1 -0
  19. package/cjs/Utils.js +74 -25
  20. package/cjs/Validation.d.ts +8 -1
  21. package/cjs/backend/AxiosRequestBackend.d.ts +1 -1
  22. package/cjs/backend/AxiosRequestBackend.js +65 -172
  23. package/cjs/backend/FetchRequestBackend.d.ts +1 -1
  24. package/cjs/backend/FetchRequestBackend.js +108 -154
  25. package/cjs/backend/MockRequestBackend.d.ts +1 -1
  26. package/cjs/backend/MockRequestBackend.js +146 -208
  27. package/cjs/cache/ClientCaching.js +26 -74
  28. package/cjs/cache/LocalForageClientCacheBackend.js +15 -83
  29. package/cjs/cache/LocalStorageClientCacheBackend.js +14 -73
  30. package/cjs/index.d.ts +11 -11
  31. package/cjs/index.js +24 -21
  32. package/cjs/middleware/ClientCacheMiddleware.js +80 -103
  33. package/cjs/middleware/LoggingMiddleware.js +71 -42
  34. package/cjs/util/retry/index.js +42 -9
  35. package/cjs/util/retry/lib/retry.js +25 -27
  36. package/cjs/util/retry/lib/retryOperation.d.ts +1 -26
  37. package/cjs/util/retry/lib/retryOperation.js +21 -23
  38. package/esm/Api.d.ts +6 -6
  39. package/esm/Api.js +12 -25
  40. package/esm/ApiConstants.d.ts +1 -1
  41. package/esm/ApiTypes.d.ts +7 -6
  42. package/esm/ApiUtils.d.ts +2 -2
  43. package/esm/ApiUtils.js +4 -5
  44. package/esm/Endpoint.d.ts +6 -6
  45. package/esm/Endpoint.js +22 -28
  46. package/esm/EndpointBuilder.d.ts +21 -4
  47. package/esm/EndpointBuilder.js +38 -10
  48. package/esm/MockingTypes.d.ts +1 -1
  49. package/esm/QueryHandling.d.ts +1 -1
  50. package/esm/QueryHandling.js +2 -3
  51. package/esm/RequestConfig.d.ts +1 -1
  52. package/esm/RequestConfig.js +6 -7
  53. package/esm/RequestContext.d.ts +8 -7
  54. package/esm/RequestContext.js +33 -27
  55. package/esm/RequestError.d.ts +3 -3
  56. package/esm/RequestError.js +2 -3
  57. package/esm/Requester.d.ts +2 -2
  58. package/esm/Requester.js +45 -50
  59. package/esm/UtilTypes.d.ts +1 -1
  60. package/esm/Utils.d.ts +1 -0
  61. package/esm/Utils.js +54 -2
  62. package/esm/Validation.d.ts +8 -1
  63. package/esm/backend/AxiosRequestBackend.d.ts +4 -4
  64. package/esm/backend/AxiosRequestBackend.js +47 -84
  65. package/esm/backend/FetchRequestBackend.d.ts +5 -5
  66. package/esm/backend/FetchRequestBackend.js +50 -64
  67. package/esm/backend/MockRequestBackend.d.ts +4 -4
  68. package/esm/backend/MockRequestBackend.js +105 -136
  69. package/esm/backend/RequestBackend.d.ts +2 -2
  70. package/esm/cache/ClientCaching.d.ts +1 -1
  71. package/esm/cache/ClientCaching.js +8 -17
  72. package/esm/cache/LocalForageClientCacheBackend.d.ts +1 -1
  73. package/esm/cache/LocalForageClientCacheBackend.js +8 -25
  74. package/esm/cache/LocalStorageClientCacheBackend.d.ts +1 -1
  75. package/esm/cache/LocalStorageClientCacheBackend.js +9 -26
  76. package/esm/index.d.ts +16 -16
  77. package/esm/index.js +15 -15
  78. package/esm/middleware/ClientCacheMiddleware.d.ts +1 -1
  79. package/esm/middleware/ClientCacheMiddleware.js +8 -17
  80. package/esm/middleware/LoggingMiddleware.d.ts +1 -1
  81. package/esm/middleware/LoggingMiddleware.js +5 -6
  82. package/esm/util/retry/index.js +1 -1
  83. package/esm/util/retry/lib/retry.d.ts +1 -1
  84. package/esm/util/retry/lib/retry.js +13 -7
  85. package/esm/util/retry/lib/retryOperation.d.ts +1 -26
  86. package/esm/util/retry/lib/retryOperation.js +1 -1
  87. package/package.json +67 -28
@@ -1,4 +1,4 @@
1
- import type { ClientCacheBackend } from "./ClientCacheBackend";
1
+ import type { ClientCacheBackend } from "./ClientCacheBackend.js";
2
2
  export default class LocalForageClientCacheBackend implements ClientCacheBackend {
3
3
  private store;
4
4
  constructor(localforage: any);
@@ -1,36 +1,19 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export default class LocalForageClientCacheBackend {
11
2
  constructor(localforage) {
12
3
  this.store = localforage.createInstance({
13
4
  name: "requestClientCache",
14
5
  });
15
6
  }
16
- getItem(key) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- return this.store.getItem(key);
19
- });
7
+ async getItem(key) {
8
+ return this.store.getItem(key);
20
9
  }
21
- setItem(key, value) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- yield this.store.setItem(key, value);
24
- });
10
+ async setItem(key, value) {
11
+ await this.store.setItem(key, value);
25
12
  }
26
- removeItem(key) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- yield this.store.removeItem(key);
29
- });
13
+ async removeItem(key) {
14
+ await this.store.removeItem(key);
30
15
  }
31
- clear() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- yield this.store.clear();
34
- });
16
+ async clear() {
17
+ await this.store.clear();
35
18
  }
36
19
  }
@@ -1,4 +1,4 @@
1
- import type { ClientCacheBackend } from "./ClientCacheBackend";
1
+ import type { ClientCacheBackend } from "./ClientCacheBackend.js";
2
2
  export default class LocalStorageClientCacheBackend implements ClientCacheBackend {
3
3
  getItem(key: string): Promise<any>;
4
4
  setItem(key: string, value: any): Promise<void>;
@@ -1,32 +1,15 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export default class LocalStorageClientCacheBackend {
11
- getItem(key) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const item = localStorage.getItem(key);
14
- return item ? JSON.parse(item) : null;
15
- });
2
+ async getItem(key) {
3
+ const item = localStorage.getItem(key);
4
+ return item ? JSON.parse(item) : null;
16
5
  }
17
- setItem(key, value) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- localStorage.setItem(key, JSON.stringify(value));
20
- });
6
+ async setItem(key, value) {
7
+ localStorage.setItem(key, JSON.stringify(value));
21
8
  }
22
- removeItem(key) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- localStorage.removeItem(key);
25
- });
9
+ async removeItem(key) {
10
+ localStorage.removeItem(key);
26
11
  }
27
- clear() {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- localStorage.clear();
30
- });
12
+ async clear() {
13
+ localStorage.clear();
31
14
  }
32
15
  }
package/esm/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from "./Api";
2
- export * from "./ApiTypes";
3
- export * from "./UtilTypes";
4
- export * from "./ApiConstants";
5
- export { default as retry } from "./util/retry";
1
+ export * from "./Api.js";
2
+ export * from "./ApiConstants.js";
3
+ export * from "./ApiTypes.js";
4
+ export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend.js";
5
+ export { default as FetchRequestBackend } from "./backend/FetchRequestBackend.js";
6
+ export { default as RequestBackend } from "./backend/RequestBackend.js";
7
+ export { clearClientCache, setClientCacheBackend } from "./cache/ClientCaching.js";
8
+ export { default as LocalForageClientCacheBackend } from "./cache/LocalForageClientCacheBackend.js";
9
+ export { default as LocalStorageClientCacheBackend } from "./cache/LocalStorageClientCacheBackend.js";
10
+ export { default as Endpoint, type EndpointConfig } from "./Endpoint.js";
11
+ export { default as EndpointBuilder, type EndpointBuildOptions } from "./EndpointBuilder.js";
12
+ export { default as ClientCacheMiddleware } from "./middleware/ClientCacheMiddleware.js";
13
+ export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware.js";
14
+ export { getErrorResponse, isRequestError, type RequestError } from "./RequestError.js";
15
+ export * from "./UtilTypes.js";
16
+ export { default as retry } from "./util/retry/index.js";
6
17
  export type { RetryOptions } from "./util/retry/interfaces";
7
- export { isRequestError, getErrorResponse, type RequestError } from "./RequestError";
8
- export { default as Endpoint, type EndpointConfig } from "./Endpoint";
9
- export { default as EndpointBuilder, type EndpointBuildOptions } from "./EndpointBuilder";
10
- export { clearClientCache, setClientCacheBackend } from "./cache/ClientCaching";
11
- export { default as LocalStorageClientCacheBackend } from "./cache/LocalStorageClientCacheBackend";
12
- export { default as LocalForageClientCacheBackend } from "./cache/LocalForageClientCacheBackend";
13
- export { default as RequestBackend } from "./backend/RequestBackend";
14
- export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend";
15
- export { default as FetchRequestBackend } from "./backend/FetchRequestBackend";
16
- export { default as ClientCacheMiddleware } from "./middleware/ClientCacheMiddleware";
17
- export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware";
package/esm/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  /// <reference types="typescript" />
2
- export * from "./Api";
3
- export * from "./ApiTypes";
4
- export * from "./UtilTypes";
5
- export * from "./ApiConstants";
6
- export { default as retry } from "./util/retry";
7
- export { isRequestError, getErrorResponse } from "./RequestError";
8
- export { default as Endpoint } from "./Endpoint";
9
- export { default as EndpointBuilder } from "./EndpointBuilder";
10
- export { clearClientCache, setClientCacheBackend } from "./cache/ClientCaching";
11
- export { default as LocalStorageClientCacheBackend } from "./cache/LocalStorageClientCacheBackend";
12
- export { default as LocalForageClientCacheBackend } from "./cache/LocalForageClientCacheBackend";
13
- export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend";
14
- export { default as FetchRequestBackend } from "./backend/FetchRequestBackend";
15
- export { default as ClientCacheMiddleware } from "./middleware/ClientCacheMiddleware";
16
- export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware";
2
+ export * from "./Api.js";
3
+ export * from "./ApiConstants.js";
4
+ export * from "./ApiTypes.js";
5
+ export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend.js";
6
+ export { default as FetchRequestBackend } from "./backend/FetchRequestBackend.js";
7
+ export { clearClientCache, setClientCacheBackend } from "./cache/ClientCaching.js";
8
+ export { default as LocalForageClientCacheBackend } from "./cache/LocalForageClientCacheBackend.js";
9
+ export { default as LocalStorageClientCacheBackend } from "./cache/LocalStorageClientCacheBackend.js";
10
+ export { default as Endpoint } from "./Endpoint.js";
11
+ export { default as EndpointBuilder } from "./EndpointBuilder.js";
12
+ export { default as ClientCacheMiddleware } from "./middleware/ClientCacheMiddleware.js";
13
+ export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware.js";
14
+ export { getErrorResponse, isRequestError } from "./RequestError.js";
15
+ export * from "./UtilTypes.js";
16
+ export { default as retry } from "./util/retry/index.js";
@@ -1,4 +1,4 @@
1
- import type { RequestMiddleware } from "../ApiTypes";
1
+ import type { RequestMiddleware } from "../ApiTypes.js";
2
2
  export interface ClientCacheMiddlewareOptions {
3
3
  defaultExpiry?: number;
4
4
  predicate?: () => boolean;
@@ -1,17 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { CacheSource, EventResultType, RequestEvent, RequestMethod } from "../ApiConstants";
11
- import * as ClientCaching from "../cache/ClientCaching";
1
+ import { CacheSource, EventResultType, RequestEvent, RequestMethod } from "../ApiConstants.js";
2
+ import * as ClientCaching from "../cache/ClientCaching.js";
12
3
  const ClientCacheMiddleware = (options = {}) => {
13
4
  return {
14
- [RequestEvent.SUCCESS]: (context) => __awaiter(void 0, void 0, void 0, function* () {
5
+ [RequestEvent.SUCCESS]: async (context) => {
15
6
  if (context.method !== RequestMethod.GET)
16
7
  return;
17
8
  const { clientCache } = context.requestConfig || {};
@@ -20,17 +11,17 @@ const ClientCacheMiddleware = (options = {}) => {
20
11
  const expiry = typeof clientCache === "number"
21
12
  ? clientCache
22
13
  : options.defaultExpiry || ClientCaching.DEFAULT_CLIENT_CACHE_EXPIRY;
23
- yield ClientCaching.setClientCachedItem(context.key, context.response, expiry);
14
+ await ClientCaching.setClientCachedItem(context.key, context.response, expiry);
24
15
  }
25
- }),
26
- [RequestEvent.BEFORE_SEND]: (context) => __awaiter(void 0, void 0, void 0, function* () {
16
+ },
17
+ [RequestEvent.BEFORE_SEND]: async (context) => {
27
18
  if (context.method !== RequestMethod.GET)
28
19
  return;
29
20
  const { clientCache } = context.requestConfig || {};
30
21
  const shouldCache = !options.predicate || options.predicate();
31
22
  if (clientCache && shouldCache) {
32
23
  if (clientCache) {
33
- const cachedValue = yield ClientCaching.getClientCachedItem(context.key);
24
+ const cachedValue = await ClientCaching.getClientCachedItem(context.key);
34
25
  if (cachedValue) {
35
26
  context.stats.cached = {
36
27
  is: true,
@@ -54,7 +45,7 @@ const ClientCacheMiddleware = (options = {}) => {
54
45
  "Cache-Control": "no-cache, no-store, must-revalidate",
55
46
  });
56
47
  }
57
- }),
48
+ },
58
49
  };
59
50
  };
60
51
  export default ClientCacheMiddleware;
@@ -1,4 +1,4 @@
1
- import type { RequestMiddleware } from "../ApiTypes";
1
+ import type { RequestMiddleware } from "../ApiTypes.js";
2
2
  export interface LoggingMiddlewareOptions {
3
3
  predicate?: () => boolean;
4
4
  }
@@ -1,6 +1,6 @@
1
- import { RequestEvent } from "../ApiConstants";
2
- import * as ApiUtils from "../ApiUtils";
3
- import * as Utils from "../Utils";
1
+ import { RequestEvent } from "../ApiConstants.js";
2
+ import * as ApiUtils from "../ApiUtils.js";
3
+ import * as Utils from "../Utils.js";
4
4
  var LogType;
5
5
  (function (LogType) {
6
6
  LogType[LogType["INFO"] = 0] = "INFO";
@@ -25,7 +25,7 @@ const diagnoseError = (error) => {
25
25
  return { message: "client-side error", error };
26
26
  }
27
27
  const { status, data } = error.response;
28
- const code = data === null || data === void 0 ? void 0 : data.code;
28
+ const code = data?.code;
29
29
  return {
30
30
  message: `responded with ${status}${code ? ` (${code})` : ""}`,
31
31
  response: error.response,
@@ -57,9 +57,8 @@ const LoggingMiddleware = (config = {}) => {
57
57
  log(context, LogType.INFO, context.stats.attempt > 1 ? "retrying" : "sending", config);
58
58
  },
59
59
  [RequestEvent.SUCCESS]: (context) => {
60
- var _a;
61
60
  const cacheSource = context.cacheInfo.source;
62
- log(context, LogType.SUCCESS, `responded with ${(_a = context.response) === null || _a === void 0 ? void 0 : _a.status}${cacheSource ? ` (cached by ${cacheSource})` : ""}`, config);
61
+ log(context, LogType.SUCCESS, `responded with ${context.response?.status}${cacheSource ? ` (cached by ${cacheSource})` : ""}`, config);
63
62
  },
64
63
  [RequestEvent.ERROR]: (context) => {
65
64
  if (context.error) {
@@ -1,4 +1,4 @@
1
- import * as retrier from "./lib/retry";
1
+ import * as retrier from "./lib/retry.js";
2
2
  // Retry is just transplanted from here:
3
3
  // https://www.npmjs.com/package/retry (lib), and
4
4
  // https://www.npmjs.com/package/async-retry (RetryFunction)
@@ -1,3 +1,3 @@
1
1
  import type { RetryOptions } from "../interfaces";
2
- import RetryOperation from "./retryOperation";
2
+ import RetryOperation from "./retryOperation.js";
3
3
  export declare const operation: (options: RetryOptions) => RetryOperation;
@@ -1,14 +1,13 @@
1
- import RetryOperation from "./retryOperation";
1
+ import RetryOperation from "./retryOperation.js";
2
2
  export const operation = (options) => {
3
3
  const timeouts = _timeouts(options);
4
4
  return new RetryOperation(timeouts, {
5
5
  forever: options && (options.forever || options.retries === Number.POSITIVE_INFINITY),
6
- unref: options === null || options === void 0 ? void 0 : options.unref,
7
- maxRetryTime: options === null || options === void 0 ? void 0 : options.maxRetryTime,
6
+ unref: options?.unref,
7
+ maxRetryTime: options?.maxRetryTime,
8
8
  });
9
9
  };
10
10
  const _timeouts = (options) => {
11
- var _a;
12
11
  const createTimeout = (attempt, opts) => {
13
12
  const random = opts.randomize ? Math.random() + 1 : 1;
14
13
  let timeout = Math.round(random * Math.max(opts.minTimeout, 1) * opts.factor ** attempt);
@@ -16,16 +15,23 @@ const _timeouts = (options) => {
16
15
  return timeout;
17
16
  };
18
17
  const defaultRetries = 10;
19
- const opts = Object.assign({ retries: defaultRetries, factor: 2, minTimeout: 1 * 1000, maxTimeout: Number.POSITIVE_INFINITY, randomize: false }, options);
18
+ const opts = {
19
+ retries: defaultRetries,
20
+ factor: 2,
21
+ minTimeout: 1 * 1000,
22
+ maxTimeout: Number.POSITIVE_INFINITY,
23
+ randomize: false,
24
+ ...options,
25
+ };
20
26
  if (opts.minTimeout > opts.maxTimeout) {
21
27
  throw new Error("minTimeout is greater than maxTimeout");
22
28
  }
23
29
  const timeouts = [];
24
- const numRetries = (_a = opts.retries) !== null && _a !== void 0 ? _a : defaultRetries;
30
+ const numRetries = opts.retries ?? defaultRetries;
25
31
  for (let i = 0; i < numRetries; i++) {
26
32
  timeouts.push(createTimeout(i, opts));
27
33
  }
28
- if ((options === null || options === void 0 ? void 0 : options.forever) && !timeouts.length) {
34
+ if (options?.forever && !timeouts.length) {
29
35
  timeouts.push(createTimeout(numRetries, opts));
30
36
  }
31
37
  // sort the array numerically ascending
@@ -1,27 +1,2 @@
1
- export default RetryOperation;
2
1
  declare function RetryOperation(timeouts: any, options: any): void;
3
- declare class RetryOperation {
4
- constructor(timeouts: any, options: any);
5
- _originalTimeouts: any;
6
- _timeouts: any;
7
- _options: any;
8
- _maxRetryTime: any;
9
- _fn: any;
10
- _errors: any[];
11
- _attempts: number;
12
- _operationTimeout: any;
13
- _operationTimeoutCb: any;
14
- _timeout: NodeJS.Timeout | null;
15
- _operationStart: number | null;
16
- _timer: NodeJS.Timeout | null;
17
- _cachedTimeouts: any;
18
- reset(): void;
19
- stop(): void;
20
- retry(err: any): boolean;
21
- attempt(fn: any, timeoutOps: any): void;
22
- try(fn: any): void;
23
- start: (fn: any) => void;
24
- errors(): any[];
25
- attempts(): number;
26
- mainError(): any;
27
- }
2
+ export default RetryOperation;
@@ -2,7 +2,7 @@ function RetryOperation(timeouts, options) {
2
2
  this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
3
3
  this._timeouts = timeouts;
4
4
  this._options = options || {};
5
- this._maxRetryTime = (options === null || options === void 0 ? void 0 : options.maxRetryTime) || Number.POSITIVE_INFINITY;
5
+ this._maxRetryTime = options?.maxRetryTime || Number.POSITIVE_INFINITY;
6
6
  this._fn = null;
7
7
  this._errors = [];
8
8
  this._attempts = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-def",
3
- "version": "0.12.1",
3
+ "version": "0.14.0-alpha.1",
4
4
  "description": "Typed API definitions with middleware support",
5
5
  "main": "cjs/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -8,60 +8,99 @@
8
8
  "bin": {
9
9
  "api-def": "bin/index.js"
10
10
  },
11
+ "engines": {
12
+ "node": ">=22"
13
+ },
11
14
  "sideEffects": false,
12
15
  "scripts": {
13
16
  "generate:fixtures": "bun scripts/generateFixtures.ts",
14
17
  "prepublishOnly": "npm run check:fix && npm run test && npm run build",
15
- "test": "jest",
18
+ "test": "jest --watchman=false",
16
19
  "example:start": "cd example && npm run start",
17
- "check:fix": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check --write",
18
- "check": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check",
20
+ "check:fix": "tsgo --noEmit --project tsconfig.json && npx @biomejs/biome check --write",
21
+ "check": "tsgo --noEmit --project tsconfig.json && npx @biomejs/biome check",
19
22
  "cleanup": "rimraf esm && rimraf cjs",
20
23
  "build": "npm run cleanup && npm run build:esm && npm run build:cjs && npm run build:cli",
21
- "build:esm": "tsc --module es2015 --target es2016 --outDir esm --preserveWatchOutput && rm -rf esm/tests",
22
- "build:cjs": "tsc --module commonjs --target es5 --outDir cjs --preserveWatchOutput && rm -rf cjs/tests",
24
+ "build:esm": "tsgo --project tsconfig.esm.json --outDir esm --preserveWatchOutput && tsc-alias --project tsconfig.esm.json --outDir esm --resolve-full-paths --resolve-full-extension .js && rm -rf esm/tests",
25
+ "build:cjs": "tsgo --project tsconfig.cjs.json --outDir cjs --preserveWatchOutput && rm -rf cjs/tests",
23
26
  "build:cli": "esbuild cli/index.ts --bundle --platform=node --outfile=bin/index.js --minify --legal-comments=none",
24
27
  "website:dev": "cd website && npm run start",
25
28
  "website:deploy": "cd website && npm run deploy"
26
29
  },
27
- "keywords": ["typescript", "javascript", "node", "web", "api", "typed", "cache", "fetch", "retry", "middleware"],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./esm/index.d.ts",
33
+ "import": "./esm/index.js",
34
+ "require": "./cjs/index.js"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "keywords": [
39
+ "typescript",
40
+ "javascript",
41
+ "node",
42
+ "web",
43
+ "api",
44
+ "typed",
45
+ "cache",
46
+ "fetch",
47
+ "retry",
48
+ "middleware"
49
+ ],
28
50
  "author": "James Waterhouse <09jwater@gmail.com>",
29
51
  "license": "MIT",
30
- "files": ["LICENSE", "README.md", "esm/", "cjs/", "bin/"],
52
+ "files": [
53
+ "LICENSE",
54
+ "README.md",
55
+ "esm/",
56
+ "cjs/",
57
+ "bin/"
58
+ ],
31
59
  "jest": {
32
60
  "transform": {
33
61
  "^.+\\.(t|j)sx?$": [
34
62
  "@swc/jest",
35
63
  {
36
- "env": {}
64
+ "jsc": {
65
+ "target": "es2020"
66
+ },
67
+ "module": {
68
+ "type": "commonjs"
69
+ }
37
70
  }
38
71
  ]
39
- }
72
+ },
73
+ "transformIgnorePatterns": [
74
+ "/node_modules/(?!parse-json|index-to-position)/"
75
+ ]
40
76
  },
41
77
  "repository": "https://github.com/Censkh/api-def",
42
78
  "devDependencies": {
43
- "@biomejs/biome": "1.9.4",
79
+ "@biomejs/biome": "2.4.16",
44
80
  "@redocly/openapi-core": "^1.34.3",
45
- "@swc/core": "^1.12.11",
81
+ "@swc/core": "^1.15.40",
46
82
  "@swc/jest": "^0.2.39",
47
83
  "@types/axios": "0.14.4",
48
- "@types/bun": "^1.2.18",
84
+ "@types/bun": "^1.3.14",
49
85
  "@types/jest": "^30.0.0",
50
- "@types/lodash": "^4.17.20",
51
- "@types/node": "24.0.12",
52
- "@types/qs": "6.14.0",
53
- "axios": "1.10.0",
54
- "commander": "^14.0.0",
55
- "cross-env": "7.0.3",
56
- "esbuild": "^0.25.6",
57
- "jest": "latest",
58
- "lodash": "^4.17.21",
59
- "chalk": "4.1.2",
86
+ "@types/lodash": "^4.17.24",
87
+ "@types/node": "25.9.1",
88
+ "@types/qs": "6.15.1",
89
+ "@typescript/native-preview": "7.0.0-dev.20260603.1",
90
+ "axios": "1.17.0",
91
+ "commander": "^15.0.0",
92
+ "cross-env": "10.1.0",
93
+ "esbuild": "^0.28.0",
94
+ "formdata-node": "6.0.3",
95
+ "jest": "30.4.2",
96
+ "kleur": "^4.1.5",
97
+ "lodash": "^4.18.1",
60
98
  "npm-run-all": "4.1.5",
61
- "openapi-typescript": "7.6.1",
62
- "qs": "6.14.0",
63
- "rimraf": "6.0.1",
64
- "typescript": "^5.8.3",
65
- "zod": "3.25.76"
99
+ "openapi-typescript": "7.13.0",
100
+ "qs": "6.15.2",
101
+ "rimraf": "6.1.3",
102
+ "tsc-alias": "^1.8.16",
103
+ "typescript": "^6.0.3",
104
+ "zod": "4.4.3"
66
105
  }
67
106
  }