enlace 0.0.1-beta.11 → 0.0.1-beta.12

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/README.md CHANGED
@@ -341,7 +341,7 @@ function PostList({ posts }: { posts: Post[] }) {
341
341
 
342
342
  const handleDelete = (postId: number) => {
343
343
  // Pass the actual ID when triggering
344
- trigger({ pathParams: { id: postId } });
344
+ trigger({ params: { id: postId } });
345
345
  };
346
346
 
347
347
  return (
@@ -366,7 +366,7 @@ const { trigger } = useAPI(
366
366
  (api) => api.users[":userId"].posts[":postId"].delete
367
367
  );
368
368
 
369
- trigger({ pathParams: { userId: "1", postId: "42" } });
369
+ trigger({ params: { userId: "1", postId: "42" } });
370
370
  // → DELETE /users/1/posts/42
371
371
  ```
372
372
 
@@ -376,7 +376,7 @@ trigger({ pathParams: { userId: "1", postId: "42" } });
376
376
  const { trigger } = useAPI((api) => api.products[":id"].patch);
377
377
 
378
378
  trigger({
379
- pathParams: { id: "123" },
379
+ params: { id: "123" },
380
380
  body: { name: "Updated Product" },
381
381
  });
382
382
  // → PATCH /products/123 with body
@@ -618,7 +618,7 @@ type RequestOptions = {
618
618
  headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>); // Request headers
619
619
  tags?: string[]; // Cache tags (GET only)
620
620
  revalidateTags?: string[]; // Tags to invalidate after mutation
621
- pathParams?: Record<string, string | number>; // Dynamic path parameters
621
+ params?: Record<string, string | number>; // Dynamic path parameters
622
622
  };
623
623
  ```
624
624
 
@@ -15,9 +15,9 @@ type ReactRequestOptionsBase = {
15
15
  * Used to replace :paramName placeholders in the URL path.
16
16
  * @example
17
17
  * // With path api.products[':id'].delete
18
- * trigger({ pathParams: { id: '123' } }) // → DELETE /products/123
18
+ * trigger({ params: { id: '123' } }) // → DELETE /products/123
19
19
  */
20
- pathParams?: Record<string, string | number>;
20
+ params?: Record<string, string | number>;
21
21
  };
22
22
  /** Options for query mode hooks */
23
23
  type UseEnlaceQueryOptions = {
@@ -15,9 +15,9 @@ type ReactRequestOptionsBase = {
15
15
  * Used to replace :paramName placeholders in the URL path.
16
16
  * @example
17
17
  * // With path api.products[':id'].delete
18
- * trigger({ pathParams: { id: '123' } }) // → DELETE /products/123
18
+ * trigger({ params: { id: '123' } }) // → DELETE /products/123
19
19
  */
20
- pathParams?: Record<string, string | number>;
20
+ params?: Record<string, string | number>;
21
21
  };
22
22
  /** Options for query mode hooks */
23
23
  type UseEnlaceQueryOptions = {
@@ -178,12 +178,12 @@ function onRevalidate(callback) {
178
178
  }
179
179
 
180
180
  // src/react/useQueryMode.ts
181
- function resolvePath(path, pathParams) {
182
- if (!pathParams) return path;
181
+ function resolvePath(path, params) {
182
+ if (!params) return path;
183
183
  return path.map((segment) => {
184
184
  if (segment.startsWith(":")) {
185
185
  const paramName = segment.slice(1);
186
- const value = pathParams[paramName];
186
+ const value = params[paramName];
187
187
  if (value === void 0) {
188
188
  throw new Error(`Missing path parameter: ${paramName}`);
189
189
  }
@@ -196,10 +196,7 @@ function useQueryMode(api, trackedCall, options) {
196
196
  const { autoGenerateTags, staleTime, enabled } = options;
197
197
  const queryKey = createQueryKey(trackedCall);
198
198
  const requestOptions = trackedCall.options;
199
- const resolvedPath = resolvePath(
200
- trackedCall.path,
201
- requestOptions?.pathParams
202
- );
199
+ const resolvedPath = resolvePath(trackedCall.path, requestOptions?.params);
203
200
  const queryTags = requestOptions?.tags ?? (autoGenerateTags ? generateTags(resolvedPath) : []);
204
201
  const getCacheState = (includeNeedsFetch = false) => {
205
202
  const cached = getCache(queryKey);
@@ -329,12 +326,12 @@ function createTrackingProxy(onTrack) {
329
326
 
330
327
  // src/react/useSelectorMode.ts
331
328
  var import_react2 = require("react");
332
- function resolvePath2(path, pathParams) {
333
- if (!pathParams) return path;
329
+ function resolvePath2(path, params) {
330
+ if (!params) return path;
334
331
  return path.map((segment) => {
335
332
  if (segment.startsWith(":")) {
336
333
  const paramName = segment.slice(1);
337
- const value = pathParams[paramName];
334
+ const value = params[paramName];
338
335
  if (value === void 0) {
339
336
  throw new Error(`Missing path parameter: ${paramName}`);
340
337
  }
@@ -364,7 +361,7 @@ function useSelectorMode(config) {
364
361
  triggerRef.current = (async (...args) => {
365
362
  dispatch({ type: "FETCH_START" });
366
363
  const options = args[0];
367
- const resolvedPath = resolvePath2(pathRef.current, options?.pathParams);
364
+ const resolvedPath = resolvePath2(pathRef.current, options?.params);
368
365
  let res;
369
366
  if (hasPathParams(pathRef.current)) {
370
367
  let current = apiRef.current;
@@ -153,12 +153,12 @@ function onRevalidate(callback) {
153
153
  }
154
154
 
155
155
  // src/react/useQueryMode.ts
156
- function resolvePath(path, pathParams) {
157
- if (!pathParams) return path;
156
+ function resolvePath(path, params) {
157
+ if (!params) return path;
158
158
  return path.map((segment) => {
159
159
  if (segment.startsWith(":")) {
160
160
  const paramName = segment.slice(1);
161
- const value = pathParams[paramName];
161
+ const value = params[paramName];
162
162
  if (value === void 0) {
163
163
  throw new Error(`Missing path parameter: ${paramName}`);
164
164
  }
@@ -171,10 +171,7 @@ function useQueryMode(api, trackedCall, options) {
171
171
  const { autoGenerateTags, staleTime, enabled } = options;
172
172
  const queryKey = createQueryKey(trackedCall);
173
173
  const requestOptions = trackedCall.options;
174
- const resolvedPath = resolvePath(
175
- trackedCall.path,
176
- requestOptions?.pathParams
177
- );
174
+ const resolvedPath = resolvePath(trackedCall.path, requestOptions?.params);
178
175
  const queryTags = requestOptions?.tags ?? (autoGenerateTags ? generateTags(resolvedPath) : []);
179
176
  const getCacheState = (includeNeedsFetch = false) => {
180
177
  const cached = getCache(queryKey);
@@ -304,12 +301,12 @@ function createTrackingProxy(onTrack) {
304
301
 
305
302
  // src/react/useSelectorMode.ts
306
303
  import { useRef as useRef2, useReducer as useReducer2 } from "react";
307
- function resolvePath2(path, pathParams) {
308
- if (!pathParams) return path;
304
+ function resolvePath2(path, params) {
305
+ if (!params) return path;
309
306
  return path.map((segment) => {
310
307
  if (segment.startsWith(":")) {
311
308
  const paramName = segment.slice(1);
312
- const value = pathParams[paramName];
309
+ const value = params[paramName];
313
310
  if (value === void 0) {
314
311
  throw new Error(`Missing path parameter: ${paramName}`);
315
312
  }
@@ -339,7 +336,7 @@ function useSelectorMode(config) {
339
336
  triggerRef.current = (async (...args) => {
340
337
  dispatch({ type: "FETCH_START" });
341
338
  const options = args[0];
342
- const resolvedPath = resolvePath2(pathRef.current, options?.pathParams);
339
+ const resolvedPath = resolvePath2(pathRef.current, options?.params);
343
340
  let res;
344
341
  if (hasPathParams(pathRef.current)) {
345
342
  let current = apiRef.current;
package/dist/index.d.mts CHANGED
@@ -16,9 +16,9 @@ type ReactRequestOptionsBase = {
16
16
  * Used to replace :paramName placeholders in the URL path.
17
17
  * @example
18
18
  * // With path api.products[':id'].delete
19
- * trigger({ pathParams: { id: '123' } }) // → DELETE /products/123
19
+ * trigger({ params: { id: '123' } }) // → DELETE /products/123
20
20
  */
21
- pathParams?: Record<string, string | number>;
21
+ params?: Record<string, string | number>;
22
22
  };
23
23
  /** Options for createEnlaceHookReact factory */
24
24
  type EnlaceHookOptions = {
package/dist/index.d.ts CHANGED
@@ -16,9 +16,9 @@ type ReactRequestOptionsBase = {
16
16
  * Used to replace :paramName placeholders in the URL path.
17
17
  * @example
18
18
  * // With path api.products[':id'].delete
19
- * trigger({ pathParams: { id: '123' } }) // → DELETE /products/123
19
+ * trigger({ params: { id: '123' } }) // → DELETE /products/123
20
20
  */
21
- pathParams?: Record<string, string | number>;
21
+ params?: Record<string, string | number>;
22
22
  };
23
23
  /** Options for createEnlaceHookReact factory */
24
24
  type EnlaceHookOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enlace",
3
- "version": "0.0.1-beta.11",
3
+ "version": "0.0.1-beta.12",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"