@hyper-fetch/core 8.1.1 → 8.2.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.
Files changed (166) hide show
  1. package/README.md +137 -52
  2. package/__tests__/e2e/e2e.advanced.spec.ts +7 -7
  3. package/__tests__/features/adapter/adapter.base.spec.ts +2 -1
  4. package/__tests__/features/adapter/adapter.bindings.spec.ts +4 -4
  5. package/__tests__/features/adapter/adapter.browser.spec.ts +0 -1
  6. package/__tests__/features/adapter/adapter.server.spec.ts +4 -5
  7. package/__tests__/features/adapter/adapter.utils.spec.ts +6 -7
  8. package/__tests__/features/cache/cache.base.spec.ts +7 -7
  9. package/__tests__/features/cache/cache.events.spec.ts +15 -15
  10. package/__tests__/features/cache/cache.garbage-collector.spec.ts +18 -18
  11. package/__tests__/features/cache/cache.lazy-storage.spec.ts +8 -8
  12. package/__tests__/features/cache/cache.modes.spec.ts +7 -6
  13. package/__tests__/features/cache/cache.scoping.spec.ts +12 -8
  14. package/__tests__/features/cache/cache.typescript.spec.ts +2 -2
  15. package/__tests__/features/cache/cache.utils.spec.ts +14 -14
  16. package/__tests__/features/client/client.auth.spec.ts +0 -1
  17. package/__tests__/features/client/client.base.spec.ts +2 -3
  18. package/__tests__/features/client/client.from-json.spec.ts +0 -1
  19. package/__tests__/features/client/client.hydration.spec.ts +5 -5
  20. package/__tests__/features/client/client.interceptor.spec.ts +3 -3
  21. package/__tests__/features/client/client.methods.spec.ts +5 -5
  22. package/__tests__/features/client/client.middleware.spec.ts +2 -2
  23. package/__tests__/features/client/client.utils.spec.ts +16 -15
  24. package/__tests__/features/dispatcher/dispatcher.base.spec.ts +3 -3
  25. package/__tests__/features/dispatcher/dispatcher.custom-storage.spec.ts +4 -5
  26. package/__tests__/features/dispatcher/dispatcher.events.spec.ts +4 -4
  27. package/__tests__/features/dispatcher/dispatcher.queue.spec.ts +13 -13
  28. package/__tests__/features/dispatcher/dispatcher.requests.spec.ts +10 -10
  29. package/__tests__/features/dispatcher/dispatcher.utils.spec.ts +35 -8
  30. package/__tests__/features/managers/app/app.manager.base.spec.ts +2 -3
  31. package/__tests__/features/managers/logger/logger.base.spec.ts +1 -2
  32. package/__tests__/features/managers/request/request.manager.base.spec.ts +8 -9
  33. package/__tests__/features/managers/request/request.manager.events.spec.ts +1 -2
  34. package/__tests__/features/mocker/mocker.base.spec.ts +6 -6
  35. package/__tests__/features/plugin/plugin.base.spec.ts +1 -2
  36. package/__tests__/features/request/request.cloning.spec.ts +0 -1
  37. package/__tests__/features/request/request.deduplicate-defaults.spec.ts +79 -0
  38. package/__tests__/features/request/request.retry-on-error.spec.ts +1 -2
  39. package/__tests__/features/request/request.sending.spec.ts +73 -24
  40. package/__tests__/features/request/request.setters.spec.ts +4 -3
  41. package/__tests__/features/request/request.typescript.spec.ts +0 -1
  42. package/__tests__/features/request/request.utils.spec.ts +1 -0
  43. package/__tests__/features/sdk/sdk.base.spec.ts +7 -12
  44. package/__tests__/features/sdk/sdk.configuration.spec.ts +5 -7
  45. package/__tests__/features/sdk/sdk.request-fields.spec.ts +80 -0
  46. package/__tests__/features/sdk/sdk.types.spec.ts +283 -0
  47. package/__tests__/shared/callbacks.shared.ts +1 -1
  48. package/__tests__/tsconfig.json +4 -17
  49. package/__tests__/utils/adapter.utils.ts +1 -2
  50. package/__tests__/utils/callbacks.utils.ts +1 -2
  51. package/__tests__/utils/dispatcher.utils.ts +1 -1
  52. package/__tests__/vitest.setup.ts +1 -1
  53. package/dist/adapter/adapter.d.ts +22 -5
  54. package/dist/adapter/adapter.d.ts.map +1 -1
  55. package/dist/adapter/adapter.types.d.ts +9 -1
  56. package/dist/adapter/adapter.types.d.ts.map +1 -1
  57. package/dist/adapter/adapter.utils.d.ts.map +1 -1
  58. package/dist/cache/cache.d.ts +6 -9
  59. package/dist/cache/cache.d.ts.map +1 -1
  60. package/dist/cache/cache.events.d.ts +7 -4
  61. package/dist/cache/cache.events.d.ts.map +1 -1
  62. package/dist/cache/cache.types.d.ts +1 -0
  63. package/dist/cache/cache.types.d.ts.map +1 -1
  64. package/dist/client/client.create.d.ts +1 -1
  65. package/dist/client/client.create.d.ts.map +1 -1
  66. package/dist/client/client.d.ts +8 -4
  67. package/dist/client/client.d.ts.map +1 -1
  68. package/dist/client/client.types.d.ts +1 -1
  69. package/dist/client/client.types.d.ts.map +1 -1
  70. package/dist/client/client.utils.d.ts.map +1 -1
  71. package/dist/constants/http.constants.d.ts +5 -1
  72. package/dist/constants/http.constants.d.ts.map +1 -1
  73. package/dist/constants/time.constants.d.ts.map +1 -1
  74. package/dist/dispatcher/dispatcher.d.ts +4 -4
  75. package/dist/dispatcher/dispatcher.d.ts.map +1 -1
  76. package/dist/dispatcher/dispatcher.events.d.ts +1 -1
  77. package/dist/dispatcher/dispatcher.events.d.ts.map +1 -1
  78. package/dist/dispatcher/dispatcher.utils.d.ts +1 -1
  79. package/dist/dispatcher/dispatcher.utils.d.ts.map +1 -1
  80. package/dist/http-adapter/http-adapter.constants.d.ts.map +1 -1
  81. package/dist/http-adapter/http-adapter.d.ts.map +1 -1
  82. package/dist/http-adapter/http-adapter.fetch.d.ts +2 -2
  83. package/dist/http-adapter/http-adapter.fetch.d.ts.map +1 -1
  84. package/dist/http-adapter/http-adapter.types.d.ts +2 -2
  85. package/dist/http-adapter/http-adapter.types.d.ts.map +1 -1
  86. package/dist/http-adapter/http-adapter.utils.d.ts.map +1 -1
  87. package/dist/index.mjs +2382 -2301
  88. package/dist/index.mjs.map +1 -1
  89. package/dist/managers/app/app.manager.constants.d.ts +1 -1
  90. package/dist/managers/app/app.manager.constants.d.ts.map +1 -1
  91. package/dist/managers/app/app.manager.d.ts +1 -1
  92. package/dist/managers/app/app.manager.d.ts.map +1 -1
  93. package/dist/managers/app/app.manager.events.d.ts +9 -0
  94. package/dist/managers/app/app.manager.events.d.ts.map +1 -1
  95. package/dist/managers/logger/logger.manager.d.ts +1 -1
  96. package/dist/managers/logger/logger.manager.d.ts.map +1 -1
  97. package/dist/managers/request/request.manager.d.ts.map +1 -1
  98. package/dist/managers/request/request.manager.events.d.ts +14 -3
  99. package/dist/managers/request/request.manager.events.d.ts.map +1 -1
  100. package/dist/mocker/mocker.types.d.ts +1 -0
  101. package/dist/mocker/mocker.types.d.ts.map +1 -1
  102. package/dist/plugin/plugin.d.ts +17 -1
  103. package/dist/plugin/plugin.d.ts.map +1 -1
  104. package/dist/plugin/plugin.types.d.ts +5 -4
  105. package/dist/plugin/plugin.types.d.ts.map +1 -1
  106. package/dist/request/request.d.ts +33 -4
  107. package/dist/request/request.d.ts.map +1 -1
  108. package/dist/request/request.hooks.d.ts +2 -2
  109. package/dist/request/request.hooks.d.ts.map +1 -1
  110. package/dist/request/request.types.d.ts +92 -5
  111. package/dist/request/request.types.d.ts.map +1 -1
  112. package/dist/request/request.utils.d.ts.map +1 -1
  113. package/dist/sdk/sdk.d.ts +25 -5
  114. package/dist/sdk/sdk.d.ts.map +1 -1
  115. package/dist/types/http.types.d.ts +1 -1
  116. package/dist/types/http.types.d.ts.map +1 -1
  117. package/dist/types/request.types.d.ts +2 -2
  118. package/dist/types/request.types.d.ts.map +1 -1
  119. package/dist/utils/emitter.utils.d.ts +1 -1
  120. package/dist/utils/emitter.utils.d.ts.map +1 -1
  121. package/package.json +8 -8
  122. package/src/adapter/adapter.bindings.ts +14 -14
  123. package/src/adapter/adapter.ts +28 -10
  124. package/src/adapter/adapter.types.ts +10 -1
  125. package/src/adapter/adapter.utils.ts +5 -5
  126. package/src/cache/cache.events.ts +7 -5
  127. package/src/cache/cache.ts +14 -17
  128. package/src/cache/cache.types.ts +1 -0
  129. package/src/client/client.create.ts +1 -1
  130. package/src/client/client.ts +14 -9
  131. package/src/client/client.types.ts +2 -2
  132. package/src/client/client.utils.ts +3 -2
  133. package/src/constants/http.constants.ts +5 -0
  134. package/src/constants/time.constants.ts +1 -1
  135. package/src/dispatcher/dispatcher.events.ts +1 -2
  136. package/src/dispatcher/dispatcher.ts +13 -13
  137. package/src/dispatcher/dispatcher.utils.ts +10 -4
  138. package/src/http-adapter/http-adapter.constants.ts +1 -0
  139. package/src/http-adapter/http-adapter.fetch.ts +19 -9
  140. package/src/http-adapter/http-adapter.ts +2 -1
  141. package/src/http-adapter/http-adapter.types.ts +3 -2
  142. package/src/http-adapter/http-adapter.utils.ts +15 -11
  143. package/src/managers/app/app.manager.constants.ts +2 -1
  144. package/src/managers/app/app.manager.events.ts +9 -1
  145. package/src/managers/app/app.manager.ts +1 -1
  146. package/src/managers/app/app.manager.utils.ts +2 -2
  147. package/src/managers/logger/logger.manager.ts +1 -2
  148. package/src/managers/request/request.manager.events.ts +14 -12
  149. package/src/managers/request/request.manager.ts +4 -4
  150. package/src/mocker/mocker.ts +2 -2
  151. package/src/mocker/mocker.types.ts +1 -0
  152. package/src/plugin/plugin.ts +17 -1
  153. package/src/plugin/plugin.types.ts +5 -4
  154. package/src/request/request.hooks.ts +6 -5
  155. package/src/request/request.ts +77 -34
  156. package/src/request/request.types.ts +107 -5
  157. package/src/request/request.utils.ts +17 -16
  158. package/src/sdk/sdk.ts +79 -23
  159. package/src/types/http.types.ts +1 -1
  160. package/src/types/request.types.ts +3 -2
  161. package/src/utils/emitter.utils.ts +1 -1
  162. package/src/utils/uuid.utils.ts +1 -1
  163. package/tsconfig.json +30 -2
  164. package/vite.config.ts +14 -20
  165. package/.eslintrc.cjs +0 -12
  166. package/tsconfig.base.json +0 -7
package/src/sdk/sdk.ts CHANGED
@@ -1,12 +1,52 @@
1
1
  import type { ClientInstance } from "client";
2
2
  import type { RequestInstance } from "request";
3
- import type { ExtractEndpointType } from "types";
3
+ import { Request } from "request";
4
+ import type {
5
+ ExtractEndpointType,
6
+ ExtractResponseType,
7
+ ExtractPayloadType,
8
+ ExtractQueryParamsType,
9
+ ExtractLocalErrorType,
10
+ ExtractHasPayloadType,
11
+ ExtractHasParamsType,
12
+ ExtractHasQueryParamsType,
13
+ ExtractMutationContextType,
14
+ } from "types";
4
15
 
5
16
  export type RecursiveSchemaType = Record<
6
17
  string, // for example users / $userId / posts / $postId
7
18
  any
8
19
  >;
9
20
 
21
+ /**
22
+ * Recursively walks a schema and rebuilds every `Request` leaf with the SDK's actual client
23
+ * type injected into the `Client` generic slot. Lets users omit `client` from their
24
+ * `RequestModel<{...}>` declarations - the SDK fills it in from the client passed to
25
+ * `createSdk(client)`.
26
+ *
27
+ * Non-Request leaves (primitive values, plain types) are passed through unchanged. Nested
28
+ * schema objects are recursed into. Depth is guarded at 10 levels to keep the type checker
29
+ * within reasonable bounds.
30
+ */
31
+ export type InjectClient<T, TClient extends ClientInstance, Depth extends unknown[] = []> = Depth["length"] extends 10
32
+ ? T
33
+ : T extends RequestInstance
34
+ ? Request<
35
+ ExtractResponseType<T>,
36
+ ExtractPayloadType<T>,
37
+ ExtractQueryParamsType<T>,
38
+ ExtractLocalErrorType<T>,
39
+ ExtractEndpointType<T> extends string ? ExtractEndpointType<T> : string,
40
+ TClient,
41
+ ExtractHasPayloadType<T> extends boolean ? ExtractHasPayloadType<T> : false,
42
+ ExtractHasParamsType<T> extends boolean ? ExtractHasParamsType<T> : false,
43
+ ExtractHasQueryParamsType<T> extends boolean ? ExtractHasQueryParamsType<T> : false,
44
+ ExtractMutationContextType<T>
45
+ >
46
+ : T extends Record<string, any>
47
+ ? { [K in keyof T]: InjectClient<T[K], TClient, [...Depth, unknown]> }
48
+ : T;
49
+
10
50
  /**
11
51
  * Per-request defaults that can be applied via SDK configuration.
12
52
  * These mirror the chainable setters on Request (headers, cache, retry, etc.).
@@ -97,14 +137,16 @@ export type CreateSdkOptions<Schema extends RecursiveSchemaType = RecursiveSchem
97
137
  defaults?: SdkConfigurationMap<Schema>;
98
138
  };
99
139
 
140
+ const OPTIONAL_REQUEST_FIELDS = Request.OPTIONAL_FIELDS;
141
+
100
142
  const getMethod = (key: string, options?: CreateSdkOptions<any>) => {
101
143
  const { methodTransform = (method: string) => method.toUpperCase() } = options ?? {};
102
144
  return methodTransform(key);
103
145
  };
104
146
 
105
147
  const endpointMatchesPattern = (endpoint: string, pattern: string): boolean => {
106
- if (pattern === "*") return true;
107
- if (pattern === endpoint) return true;
148
+ if (pattern === "*") {return true;}
149
+ if (pattern === endpoint) {return true;}
108
150
  // Simple wildcard: "/users/*" matches "/users/:userId", "/users/:userId/posts", etc.
109
151
  if (pattern.endsWith("/*")) {
110
152
  const prefix = pattern.slice(0, -1);
@@ -119,17 +161,17 @@ const isDotPath = (key: string): boolean => {
119
161
 
120
162
  const applyObjectDefaults = (request: RequestInstance, config: SdkRequestDefaults): RequestInstance => {
121
163
  let result = request;
122
- if (config.headers) result = result.setHeaders(config.headers);
123
- if (config.auth !== undefined) result = result.setAuth(config.auth);
124
- if (config.cache !== undefined) result = result.setCache(config.cache);
125
- if (config.cacheTime !== undefined) result = result.setCacheTime(config.cacheTime);
126
- if (config.staleTime !== undefined) result = result.setStaleTime(config.staleTime);
127
- if (config.retry !== undefined) result = result.setRetry(config.retry);
128
- if (config.retryTime !== undefined) result = result.setRetryTime(config.retryTime);
129
- if (config.cancelable !== undefined) result = result.setCancelable(config.cancelable);
130
- if (config.queued !== undefined) result = result.setQueued(config.queued);
131
- if (config.offline !== undefined) result = result.setOffline(config.offline);
132
- if (config.deduplicate !== undefined) result = result.setDeduplicate(config.deduplicate);
164
+ if (config.headers) {result = result.setHeaders(config.headers);}
165
+ if (config.auth !== undefined) {result = result.setAuth(config.auth);}
166
+ if (config.cache !== undefined) {result = result.setCache(config.cache);}
167
+ if (config.cacheTime !== undefined) {result = result.setCacheTime(config.cacheTime);}
168
+ if (config.staleTime !== undefined) {result = result.setStaleTime(config.staleTime);}
169
+ if (config.retry !== undefined) {result = result.setRetry(config.retry);}
170
+ if (config.retryTime !== undefined) {result = result.setRetryTime(config.retryTime);}
171
+ if (config.cancelable !== undefined) {result = result.setCancelable(config.cancelable);}
172
+ if (config.queued !== undefined) {result = result.setQueued(config.queued);}
173
+ if (config.offline !== undefined) {result = result.setOffline(config.offline);}
174
+ if (config.deduplicate !== undefined) {result = result.setDeduplicate(config.deduplicate);}
133
175
  if (config.deduplicateTime !== undefined && config.deduplicateTime !== null) {
134
176
  result = result.setDeduplicateTime(config.deduplicateTime);
135
177
  }
@@ -141,7 +183,7 @@ const applyDefaults = (
141
183
  context: { endpoint: string; sdkPath: string; defaults?: Partial<Record<string, SdkConfigurationValue>> },
142
184
  ): RequestInstance => {
143
185
  const { endpoint, sdkPath, defaults } = context;
144
- if (!defaults) return request;
186
+ if (!defaults) {return request;}
145
187
 
146
188
  let result = request;
147
189
  const entries = Object.entries(defaults);
@@ -153,7 +195,7 @@ const applyDefaults = (
153
195
 
154
196
  for (let i = 0; i < entries.length; i += 1) {
155
197
  const [key, value] = entries[i];
156
- if (!value) continue;
198
+ if (!value) {continue;}
157
199
  const entry: [string, SdkConfigurationValue] = [key, value];
158
200
  if (entry[0] === "*") {
159
201
  globalEntries.push(entry);
@@ -197,7 +239,7 @@ const createRecursiveProxy = (
197
239
  return new Proxy(() => {}, {
198
240
  get: (_target, key: string) => {
199
241
  if (typeof key === "symbol" || key === "inspect") {
200
- return undefined;
242
+ return;
201
243
  }
202
244
 
203
245
  // Check if this is a method (starts with $) or a path segment
@@ -210,7 +252,7 @@ const createRecursiveProxy = (
210
252
  methodName = key.slice(1);
211
253
  pathSegment = `:${key.slice(1)}`;
212
254
  } else if (options?.camelCaseToKebabCase) {
213
- pathSegment = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
255
+ pathSegment = key.replaceAll(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
214
256
  }
215
257
 
216
258
  // Build the sdk dot-path for method-specific configuration matching
@@ -231,7 +273,11 @@ const createRecursiveProxy = (
231
273
  return new Proxy(request, {
232
274
  get: (reqTarget, reqKey: string) => {
233
275
  // If the property exists on the request instance (like .send(), .setParams()), return it.
234
- if (reqKey in reqTarget) {
276
+ // Optional fields are checked by name as well: transpilers that compile class
277
+ // properties in loose mode (Metro on React Native) drop uninitialized field
278
+ // declarations, and falling through to the deeper proxy would hand callers a
279
+ // truthy path proxy where they expect undefined.
280
+ if (reqKey in reqTarget || (OPTIONAL_REQUEST_FIELDS as readonly string[]).includes(reqKey)) {
235
281
  return reqTarget[reqKey as keyof typeof reqTarget];
236
282
  }
237
283
  // Otherwise, it's a deeper path, so delegate to the deeper proxy.
@@ -242,18 +288,28 @@ const createRecursiveProxy = (
242
288
  });
243
289
  };
244
290
 
245
- export type SdkInstance<Schema extends RecursiveSchemaType> = Schema & {
291
+ /**
292
+ * The fully-resolved SDK instance type returned by `createSdk`.
293
+ *
294
+ * The schema is rewritten via {@link InjectClient} so every `Request` leaf carries the
295
+ * actual client type passed to `createSdk(client)` - users do not need to repeat
296
+ * `client: AppClient` in every `RequestModel<{...}>` declaration.
297
+ */
298
+ export type SdkInstance<
299
+ Schema extends RecursiveSchemaType,
300
+ TClient extends ClientInstance = ClientInstance,
301
+ > = InjectClient<Schema, TClient> & {
246
302
  /**
247
303
  * Apply request defaults to the SDK. Returns a new SDK instance with the configuration applied.
248
304
  * Use "*" to match all endpoints, or specific endpoint strings / wildcard patterns.
249
305
  */
250
- $configure: (defaults: SdkConfigurationMap<Schema>) => SdkInstance<Schema>;
306
+ $configure: (defaults: SdkConfigurationMap<Schema>) => SdkInstance<Schema, TClient>;
251
307
  };
252
308
 
253
309
  export const createSdk = <Client extends ClientInstance, RecursiveSchema extends RecursiveSchemaType>(
254
310
  client: Client,
255
311
  options?: CreateSdkOptions<RecursiveSchema>,
256
- ): SdkInstance<RecursiveSchema> => {
312
+ ): SdkInstance<RecursiveSchema, Client> => {
257
313
  const {
258
314
  camelCaseToKebabCase = true,
259
315
  methodTransform = (method: string) => method.toUpperCase(),
@@ -277,7 +333,7 @@ export const createSdk = <Client extends ClientInstance, RecursiveSchema extends
277
333
  }
278
334
  return target[key];
279
335
  },
280
- }) as SdkInstance<RecursiveSchema>;
336
+ }) as SdkInstance<RecursiveSchema, Client>;
281
337
  };
282
338
 
283
339
  /**
@@ -1,2 +1,2 @@
1
- export type HttpMethodsType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1
+ export type HttpMethodsType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "QUERY";
2
2
  export type HttpStatusType = number;
@@ -1,9 +1,10 @@
1
1
  import type { ResponseType } from "adapter";
2
+ import type { Client, ClientInstance } from "client";
2
3
  import type { ExtractUrlParams, Request, RequestInstance } from "request";
4
+
5
+ import type { ExtractAdapterEndpointType } from "./adapter.types";
3
6
  import type { ExtractClientAdapterType, ExtractClientGlobalError } from "./client.types";
4
- import type { Client, ClientInstance } from "client";
5
7
  import type { TypeWithDefaults } from "./helpers.types";
6
- import type { ExtractAdapterEndpointType } from "./adapter.types";
7
8
 
8
9
  export type ExtractAdapterResolvedType<T extends RequestInstance> = ResponseType<
9
10
  ExtractResponseType<T>,
@@ -3,7 +3,7 @@ import Emitter from "events";
3
3
  const getListenName = (event: string | symbol) => `listen_${String(event)}`;
4
4
 
5
5
  export class EventEmitter extends Emitter {
6
- emitCallbacks: Array<(event: string, data: any, isTriggeredExternally?: true) => void> = [];
6
+ emitCallbacks: ((event: string, data: any, isTriggeredExternally?: true) => void)[] = [];
7
7
 
8
8
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
9
9
  constructor(options?: ConstructorParameters<typeof Emitter>[0]) {
@@ -1,5 +1,5 @@
1
1
  import type { RequestInstance } from "request";
2
2
 
3
3
  export const getUniqueRequestId = (request: Pick<RequestInstance, "queryKey">) => {
4
- return `${request.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`;
4
+ return `${request.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
5
5
  };
package/tsconfig.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "baseUrl": "./src",
4
+ "types": ["node"],
5
5
  "paths": {
6
- "@hyper-fetch/core": ["../src"]
6
+ "adapter": ["./src/adapter"],
7
+ "adapter/*": ["./src/adapter/*"],
8
+ "cache": ["./src/cache"],
9
+ "cache/*": ["./src/cache/*"],
10
+ "client": ["./src/client"],
11
+ "client/*": ["./src/client/*"],
12
+ "constants": ["./src/constants"],
13
+ "constants/*": ["./src/constants/*"],
14
+ "dispatcher": ["./src/dispatcher"],
15
+ "dispatcher/*": ["./src/dispatcher/*"],
16
+ "http-adapter": ["./src/http-adapter"],
17
+ "http-adapter/*": ["./src/http-adapter/*"],
18
+ "managers": ["./src/managers"],
19
+ "managers/*": ["./src/managers/*"],
20
+ "mocker": ["./src/mocker"],
21
+ "mocker/*": ["./src/mocker/*"],
22
+ "plugin": ["./src/plugin"],
23
+ "plugin/*": ["./src/plugin/*"],
24
+ "request": ["./src/request"],
25
+ "request/*": ["./src/request/*"],
26
+ "sdk": ["./src/sdk"],
27
+ "sdk/*": ["./src/sdk/*"],
28
+ "types": ["./src/types"],
29
+ "types/*": ["./src/types/*"],
30
+ "utils": ["./src/utils"],
31
+ "utils/*": ["./src/utils/*"],
32
+ "index": ["./src/index"],
33
+ "@hyper-fetch/core": ["./src"]
7
34
  }
8
35
  },
36
+ "include": ["src/**/*.ts", "../../global.d.ts"],
9
37
  "exclude": ["node_modules", "dist", "vite.config.ts", "__tests__"]
10
38
  }
package/vite.config.ts CHANGED
@@ -1,45 +1,39 @@
1
1
  /// <reference types="vitest/config" />
2
+ import path from "path";
2
3
  import { defineConfig } from "vite";
3
4
  import dts from "vite-plugin-dts";
4
5
  import tsconfigPaths from "vite-tsconfig-paths";
5
- import path from "path";
6
- import { getDtsCompilerOptionsForPackage } from "../../scripts/vite-dts-internal-paths";
6
+
7
7
  import { getRollupExternalsFromPackageJson } from "../../scripts/vite-lib-externals-from-package";
8
8
 
9
9
  export default defineConfig({
10
10
  build: {
11
11
  lib: {
12
12
  entry: "src/index.ts",
13
- formats: ["es"],
14
13
  fileName: "index",
14
+ formats: ["es"],
15
15
  },
16
- sourcemap: true,
17
16
  minify: false,
18
17
  rollupOptions: {
19
18
  external: getRollupExternalsFromPackageJson(__dirname),
20
19
  },
20
+ sourcemap: true,
21
21
  },
22
- plugins: [
23
- dts({
24
- entryRoot: "src",
25
- compilerOptions: getDtsCompilerOptionsForPackage(__dirname),
26
- }),
27
- tsconfigPaths(),
28
- ],
22
+ plugins: [tsconfigPaths(), dts({ entryRoot: "src" })],
29
23
  test: {
30
- globals: true,
31
- environment: "jsdom",
32
- setupFiles: ["./__tests__/vitest.setup.ts"],
33
- include: ["__tests__/**/*.spec.{ts,tsx}", "src/**/*.spec.{ts,tsx}"],
34
- coverage: {
35
- provider: "v8",
36
- include: ["src/**/*.{ts,tsx}"],
37
- exclude: ["**/*.spec.*", "**/types.*", "**/constants.*", "**/index.ts"],
38
- },
39
24
  alias: {
40
25
  "@hyper-fetch/core": path.resolve(__dirname, "./src/index.ts"),
41
26
  "@hyper-fetch/sockets": path.resolve(__dirname, "../sockets/src/index.ts"),
42
27
  "@hyper-fetch/testing": path.resolve(__dirname, "../testing/src/index.ts"),
43
28
  },
29
+ coverage: {
30
+ exclude: ["**/*.spec.*", "**/types.*", "**/constants.*", "**/index.ts"],
31
+ include: ["src/**/*.{ts,tsx}"],
32
+ provider: "v8",
33
+ },
34
+ environment: "jsdom",
35
+ globals: true,
36
+ include: ["__tests__/**/*.spec.{ts,tsx}", "src/**/*.spec.{ts,tsx}"],
37
+ setupFiles: ["./__tests__/vitest.setup.ts"],
44
38
  },
45
39
  });
package/.eslintrc.cjs DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- extends: ["plugin:@nx/react", "../../.eslintrc.js"],
3
- parserOptions: {
4
- tsconfigRootDir: __dirname,
5
- project: ["./tsconfig.json", "./__tests__/tsconfig.json"],
6
- },
7
- rules: {
8
- "react/jsx-props-no-spreading": 0,
9
- "react/require-default-props": 0,
10
- },
11
- ignorePatterns: ["dist/", "coverage/", "vite.config.ts", "/*.js"],
12
- };
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "baseUrl": "./src"
6
- }
7
- }