@spoosh/core 0.4.0 → 0.4.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.
package/dist/index.d.mts CHANGED
@@ -96,6 +96,8 @@ type AnyRequestOptions = BaseRequestOptions & {
96
96
  urlEncoded?: Record<string, unknown>;
97
97
  params?: Record<string, string | number>;
98
98
  signal?: AbortSignal;
99
+ /** @internal Path transformer function. Set by plugins like path-case. */
100
+ _pathTransformer?: (path: string[]) => string[];
99
101
  } & Partial<RetryConfig>;
100
102
  type DynamicParamsOption = {
101
103
  params?: Record<string, string | number>;
package/dist/index.d.ts CHANGED
@@ -96,6 +96,8 @@ type AnyRequestOptions = BaseRequestOptions & {
96
96
  urlEncoded?: Record<string, unknown>;
97
97
  params?: Record<string, string | number>;
98
98
  signal?: AbortSignal;
99
+ /** @internal Path transformer function. Set by plugins like path-case. */
100
+ _pathTransformer?: (path: string[]) => string[];
99
101
  } & Partial<RetryConfig>;
100
102
  type DynamicParamsOption = {
101
103
  params?: Record<string, string | number>;
package/dist/index.js CHANGED
@@ -336,7 +336,8 @@ async function executeCoreFetch(config) {
336
336
  const maxRetries = requestOptions?.retries ?? 3;
337
337
  const baseDelay = requestOptions?.retryDelay ?? 1e3;
338
338
  const retryCount = maxRetries === false ? 0 : maxRetries;
339
- const url = buildUrl(baseUrl, path, requestOptions?.query);
339
+ const finalPath = requestOptions?._pathTransformer?.(path) ?? path;
340
+ const url = buildUrl(baseUrl, finalPath, requestOptions?.query);
340
341
  let headers = await mergeHeaders(defaultHeaders, requestOptions?.headers);
341
342
  const fetchInit = {
342
343
  ...fetchDefaults,
@@ -529,7 +530,7 @@ function createSelectorProxy(onCapture) {
529
530
  // Handles function call syntax for dynamic segments: api.posts("123"), api.users(userId)
530
531
  apply(_, __, args) {
531
532
  const [segment] = args;
532
- return createProxy([...path, segment]);
533
+ return createProxy([...path, String(segment)]);
533
534
  }
534
535
  });
535
536
  };
package/dist/index.mjs CHANGED
@@ -281,7 +281,8 @@ async function executeCoreFetch(config) {
281
281
  const maxRetries = requestOptions?.retries ?? 3;
282
282
  const baseDelay = requestOptions?.retryDelay ?? 1e3;
283
283
  const retryCount = maxRetries === false ? 0 : maxRetries;
284
- const url = buildUrl(baseUrl, path, requestOptions?.query);
284
+ const finalPath = requestOptions?._pathTransformer?.(path) ?? path;
285
+ const url = buildUrl(baseUrl, finalPath, requestOptions?.query);
285
286
  let headers = await mergeHeaders(defaultHeaders, requestOptions?.headers);
286
287
  const fetchInit = {
287
288
  ...fetchDefaults,
@@ -474,7 +475,7 @@ function createSelectorProxy(onCapture) {
474
475
  // Handles function call syntax for dynamic segments: api.posts("123"), api.users(userId)
475
476
  apply(_, __, args) {
476
477
  const [segment] = args;
477
- return createProxy([...path, segment]);
478
+ return createProxy([...path, String(segment)]);
478
479
  }
479
480
  });
480
481
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Type-safe API client with plugin middleware system",
6
6
  "keywords": [
@@ -20,7 +20,7 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/nxnom/spoosh/issues"
22
22
  },
23
- "homepage": "https://spoosh.dev/docs/core",
23
+ "homepage": "https://spoosh.dev/react/docs/core",
24
24
  "publishConfig": {
25
25
  "access": "public"
26
26
  },