@spoosh/react 0.7.1 → 0.7.3

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  React hooks for Spoosh - `useRead`, `useWrite`, and `useInfiniteRead`.
4
4
 
5
- **[Documentation](https://spoosh.dev/docs/integrations/react)** · **Requirements:** TypeScript >= 5.0, React >= 18.0
5
+ **[Documentation](https://spoosh.dev/docs/react)** · **Requirements:** TypeScript >= 5.0, React >= 18.0
6
6
 
7
7
  ## Installation
8
8
 
package/dist/index.d.mts CHANGED
@@ -370,7 +370,7 @@ type SpooshReactHooks<TDefaultError, TSchema, TPlugins extends PluginArray> = {
370
370
  * Shape of a Spoosh instance required for creating React hooks.
371
371
  */
372
372
  type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
373
- /** The API client instance */
373
+ /** The API instance */
374
374
  api: TApi;
375
375
  /** State manager for caching and state */
376
376
  stateManager: StateManager;
@@ -392,7 +392,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
392
392
  * @template TSchema - The API schema type
393
393
  * @template TDefaultError - The default error type
394
394
  * @template TPlugins - The plugins array type
395
- * @template TApi - The API client type
395
+ * @template TApi - The API type
396
396
  * @param instance - The Spoosh instance containing api, stateManager, eventEmitter, and pluginExecutor
397
397
  * @returns An object containing useRead, useWrite, useInfiniteRead hooks and plugin instance APIs
398
398
  *
package/dist/index.d.ts CHANGED
@@ -370,7 +370,7 @@ type SpooshReactHooks<TDefaultError, TSchema, TPlugins extends PluginArray> = {
370
370
  * Shape of a Spoosh instance required for creating React hooks.
371
371
  */
372
372
  type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
373
- /** The API client instance */
373
+ /** The API instance */
374
374
  api: TApi;
375
375
  /** State manager for caching and state */
376
376
  stateManager: StateManager;
@@ -392,7 +392,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
392
392
  * @template TSchema - The API schema type
393
393
  * @template TDefaultError - The default error type
394
394
  * @template TPlugins - The plugins array type
395
- * @template TApi - The API client type
395
+ * @template TApi - The API type
396
396
  * @param instance - The Spoosh instance containing api, stateManager, eventEmitter, and pluginExecutor
397
397
  * @returns An object containing useRead, useWrite, useInfiniteRead hooks and plugin instance APIs
398
398
  *
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ function createUseRead(options) {
60
60
  const resolvedPath = (0, import_core.resolvePath)(pathSegments, requestOptions?.params);
61
61
  const resolvedTags = (0, import_core.resolveTags)({ tags }, resolvedPath);
62
62
  const queryKey = stateManager.createQueryKey({
63
- path: pathSegments,
63
+ path: capturedCall.path,
64
64
  method: capturedCall.method,
65
65
  options: capturedCall.options
66
66
  });
@@ -76,7 +76,7 @@ function createUseRead(options) {
76
76
  if (!controllerRef.current || baseQueryKeyChanged) {
77
77
  const controller2 = (0, import_core.createOperationController)({
78
78
  operationType: "read",
79
- path: pathSegments,
79
+ path: capturedCall.path,
80
80
  method: capturedCall.method,
81
81
  tags: resolvedTags,
82
82
  requestOptions: capturedCall.options,
@@ -185,7 +185,7 @@ function createUseRead(options) {
185
185
  }, []);
186
186
  const trigger = (0, import_react.useCallback)(
187
187
  async (triggerOptions) => {
188
- const { force = false, ...overrideOptions } = triggerOptions ?? {};
188
+ const { force = true, ...overrideOptions } = triggerOptions ?? {};
189
189
  const hasOverrides = Object.keys(overrideOptions).length > 0;
190
190
  if (!hasOverrides) {
191
191
  return executeWithTracking(force, void 0);
@@ -195,7 +195,7 @@ function createUseRead(options) {
195
195
  ...overrideOptions
196
196
  };
197
197
  const newQueryKey = stateManager.createQueryKey({
198
- path: pathSegments,
198
+ path: capturedCall.path,
199
199
  method: capturedCall.method,
200
200
  options: mergedOptions
201
201
  });
@@ -207,7 +207,7 @@ function createUseRead(options) {
207
207
  const newResolvedTags = (0, import_core.resolveTags)({ tags }, newResolvedPath);
208
208
  const newController = (0, import_core.createOperationController)({
209
209
  operationType: "read",
210
- path: pathSegments,
210
+ path: capturedCall.path,
211
211
  method: capturedCall.method,
212
212
  tags: newResolvedTags,
213
213
  requestOptions: mergedOptions,
@@ -316,7 +316,7 @@ function createUseWrite(options) {
316
316
  }
317
317
  const pathSegments = selectedEndpoint.path.split("/").filter(Boolean);
318
318
  const queryKey = stateManager.createQueryKey({
319
- path: pathSegments,
319
+ path: selectedEndpoint.path,
320
320
  method: selectedEndpoint.method,
321
321
  options: void 0
322
322
  });
@@ -325,7 +325,7 @@ function createUseWrite(options) {
325
325
  controllerRef.current = {
326
326
  controller: (0, import_core2.createOperationController)({
327
327
  operationType: "write",
328
- path: pathSegments,
328
+ path: selectedEndpoint.path,
329
329
  method: selectedEndpoint.method,
330
330
  tags: [],
331
331
  stateManager,
@@ -464,7 +464,7 @@ function createUseInfiniteRead(options) {
464
464
  prevPageRequestRef.current = prevPageRequest;
465
465
  mergerRef.current = merger;
466
466
  const queryKey = stateManager.createQueryKey({
467
- path: pathSegments,
467
+ path: capturedCall.path,
468
468
  method: capturedCall.method,
469
469
  options: baseOptionsForKey
470
470
  });
@@ -472,7 +472,7 @@ function createUseInfiniteRead(options) {
472
472
  if (!controllerRef.current || controllerRef.current.queryKey !== queryKey) {
473
473
  controllerRef.current = {
474
474
  controller: (0, import_core3.createInfiniteReadController)({
475
- path: pathSegments,
475
+ path: capturedCall.path,
476
476
  method: capturedCall.method,
477
477
  tags: resolvedTags,
478
478
  initialRequest,
package/dist/index.mjs CHANGED
@@ -44,7 +44,7 @@ function createUseRead(options) {
44
44
  const resolvedPath = resolvePath(pathSegments, requestOptions?.params);
45
45
  const resolvedTags = resolveTags({ tags }, resolvedPath);
46
46
  const queryKey = stateManager.createQueryKey({
47
- path: pathSegments,
47
+ path: capturedCall.path,
48
48
  method: capturedCall.method,
49
49
  options: capturedCall.options
50
50
  });
@@ -60,7 +60,7 @@ function createUseRead(options) {
60
60
  if (!controllerRef.current || baseQueryKeyChanged) {
61
61
  const controller2 = createOperationController({
62
62
  operationType: "read",
63
- path: pathSegments,
63
+ path: capturedCall.path,
64
64
  method: capturedCall.method,
65
65
  tags: resolvedTags,
66
66
  requestOptions: capturedCall.options,
@@ -169,7 +169,7 @@ function createUseRead(options) {
169
169
  }, []);
170
170
  const trigger = useCallback(
171
171
  async (triggerOptions) => {
172
- const { force = false, ...overrideOptions } = triggerOptions ?? {};
172
+ const { force = true, ...overrideOptions } = triggerOptions ?? {};
173
173
  const hasOverrides = Object.keys(overrideOptions).length > 0;
174
174
  if (!hasOverrides) {
175
175
  return executeWithTracking(force, void 0);
@@ -179,7 +179,7 @@ function createUseRead(options) {
179
179
  ...overrideOptions
180
180
  };
181
181
  const newQueryKey = stateManager.createQueryKey({
182
- path: pathSegments,
182
+ path: capturedCall.path,
183
183
  method: capturedCall.method,
184
184
  options: mergedOptions
185
185
  });
@@ -191,7 +191,7 @@ function createUseRead(options) {
191
191
  const newResolvedTags = resolveTags({ tags }, newResolvedPath);
192
192
  const newController = createOperationController({
193
193
  operationType: "read",
194
- path: pathSegments,
194
+ path: capturedCall.path,
195
195
  method: capturedCall.method,
196
196
  tags: newResolvedTags,
197
197
  requestOptions: mergedOptions,
@@ -311,7 +311,7 @@ function createUseWrite(options) {
311
311
  }
312
312
  const pathSegments = selectedEndpoint.path.split("/").filter(Boolean);
313
313
  const queryKey = stateManager.createQueryKey({
314
- path: pathSegments,
314
+ path: selectedEndpoint.path,
315
315
  method: selectedEndpoint.method,
316
316
  options: void 0
317
317
  });
@@ -320,7 +320,7 @@ function createUseWrite(options) {
320
320
  controllerRef.current = {
321
321
  controller: createOperationController2({
322
322
  operationType: "write",
323
- path: pathSegments,
323
+ path: selectedEndpoint.path,
324
324
  method: selectedEndpoint.method,
325
325
  tags: [],
326
326
  stateManager,
@@ -470,7 +470,7 @@ function createUseInfiniteRead(options) {
470
470
  prevPageRequestRef.current = prevPageRequest;
471
471
  mergerRef.current = merger;
472
472
  const queryKey = stateManager.createQueryKey({
473
- path: pathSegments,
473
+ path: capturedCall.path,
474
474
  method: capturedCall.method,
475
475
  options: baseOptionsForKey
476
476
  });
@@ -478,7 +478,7 @@ function createUseInfiniteRead(options) {
478
478
  if (!controllerRef.current || controllerRef.current.queryKey !== queryKey) {
479
479
  controllerRef.current = {
480
480
  controller: createInfiniteReadController({
481
- path: pathSegments,
481
+ path: capturedCall.path,
482
482
  method: capturedCall.method,
483
483
  tags: resolvedTags,
484
484
  initialRequest,
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@spoosh/react",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "license": "MIT",
5
- "description": "React hooks for Spoosh API client",
5
+ "description": "React hooks for Spoosh API toolkit",
6
6
  "keywords": [
7
7
  "spoosh",
8
8
  "react",
9
9
  "hooks",
10
- "api-client",
10
+ "api-toolkit",
11
11
  "useRead",
12
12
  "useWrite"
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/nxnom/spoosh.git",
16
+ "url": "git+https://github.com/spooshdev/spoosh.git",
17
17
  "directory": "packages/react"
18
18
  },
19
19
  "bugs": {
20
- "url": "https://github.com/nxnom/spoosh/issues"
20
+ "url": "https://github.com/spooshdev/spoosh/issues"
21
21
  },
22
- "homepage": "https://spoosh.dev/react/docs",
22
+ "homepage": "https://spoosh.dev/docs/react",
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
@@ -34,14 +34,14 @@
34
34
  }
35
35
  },
36
36
  "peerDependencies": {
37
- "@spoosh/core": ">=0.7.0",
37
+ "@spoosh/core": ">=0.11.0",
38
38
  "react": "^18 || ^19"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@testing-library/react": "^16.0.0",
42
42
  "jsdom": "^26.0.0",
43
- "@spoosh/core": "0.9.3",
44
- "@spoosh/test-utils": "0.1.5"
43
+ "@spoosh/core": "0.11.0",
44
+ "@spoosh/test-utils": "0.1.6"
45
45
  },
46
46
  "scripts": {
47
47
  "dev": "tsup --watch",