@spoosh/react 0.7.4 → 0.8.0
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 +2 -2
- package/dist/index.d.mts +3 -47
- package/dist/index.d.ts +3 -47
- package/dist/index.js +11 -15
- package/dist/index.mjs +11 -15
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -16,14 +16,14 @@ npm install @spoosh/core @spoosh/react
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { Spoosh } from "@spoosh/core";
|
|
19
|
-
import {
|
|
19
|
+
import { create } from "@spoosh/react";
|
|
20
20
|
import { cachePlugin } from "@spoosh/plugin-cache";
|
|
21
21
|
|
|
22
22
|
const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
|
|
23
23
|
cachePlugin({ staleTime: 5000 }),
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
-
export const { useRead, useWrite, useInfiniteRead } =
|
|
26
|
+
export const { useRead, useWrite, useInfiniteRead } = create(spoosh);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### useRead
|
package/dist/index.d.mts
CHANGED
|
@@ -398,7 +398,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
|
|
|
398
398
|
*
|
|
399
399
|
* @example
|
|
400
400
|
* ```ts
|
|
401
|
-
* const { useRead, useWrite, useInfiniteRead } =
|
|
401
|
+
* const { useRead, useWrite, useInfiniteRead } = create(spooshInstance);
|
|
402
402
|
*
|
|
403
403
|
* function MyComponent() {
|
|
404
404
|
* const { data, loading } = useRead((api) => api("posts").GET());
|
|
@@ -406,51 +406,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
|
|
|
406
406
|
* }
|
|
407
407
|
* ```
|
|
408
408
|
*/
|
|
409
|
-
declare function
|
|
410
|
-
|
|
411
|
-
declare function createUseRead<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TReadFn extends (api: ReadApiClient<TSchema, TDefaultError>) => Promise<SpooshResponse<unknown, unknown>>, TReadOpts extends BaseReadOptions & ResolveTypes<((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
412
|
-
readOptions: infer R;
|
|
413
|
-
} ? R : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
414
|
-
readOptions: infer R;
|
|
415
|
-
} ? R : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, TReadFn extends (...args: unknown[]) => Promise<{
|
|
416
|
-
data: infer D;
|
|
417
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
418
|
-
error: infer E;
|
|
419
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
420
|
-
error: infer E;
|
|
421
|
-
}> ? E : unknown, ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn> extends never ? never : Record<ExtractResponseParamNames<TReadFn>, string | number>>> = BaseReadOptions & ResolveTypes<((TPlugins[number] extends infer T_3 ? T_3 extends TPlugins[number] ? T_3 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
422
|
-
readOptions: infer R;
|
|
423
|
-
} ? R : object : object : never : never) extends infer T_4 ? T_4 extends (TPlugins[number] extends infer T_5 ? T_5 extends TPlugins[number] ? T_5 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
424
|
-
readOptions: infer R;
|
|
425
|
-
} ? R : object : object : never : never) ? T_4 extends unknown ? (x: T_4) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, TReadFn extends (...args: unknown[]) => Promise<{
|
|
426
|
-
data: infer D;
|
|
427
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
428
|
-
error: infer E;
|
|
429
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
430
|
-
error: infer E;
|
|
431
|
-
}> ? E : unknown, ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn> extends never ? never : Record<ExtractResponseParamNames<TReadFn>, string | number>>>>(readFn: TReadFn, readOptions?: TReadOpts) => BaseReadResult<TReadFn extends (...args: unknown[]) => Promise<{
|
|
432
|
-
data: infer D;
|
|
433
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
434
|
-
error: infer E;
|
|
435
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
436
|
-
error: infer E;
|
|
437
|
-
}> ? E : unknown, ResolveResultTypes<MergePluginResults<TPlugins>["read"], TReadOpts>, TriggerOptions<TReadFn>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
|
|
438
|
-
|
|
439
|
-
declare function createUseWrite<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TMethod extends (...args: never[]) => Promise<SpooshResponse<unknown, unknown>>>(writeFn: (api: WriteApiClient<TSchema, TDefaultError>) => TMethod) => BaseWriteResult<ExtractMethodData<TMethod>, [ExtractMethodError<TMethod>] extends [unknown] ? TDefaultError : ExtractMethodError<TMethod>, ExtractMethodOptions<TMethod> & ResolveTypes<((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
440
|
-
writeOptions: infer W;
|
|
441
|
-
} ? W : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
442
|
-
writeOptions: infer W;
|
|
443
|
-
} ? W : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, ExtractMethodData<TMethod>, [ExtractMethodError<TMethod>] extends [unknown] ? TDefaultError : ExtractMethodError<TMethod>, ExtractMethodQuery<TMethod>, ExtractMethodBody<TMethod>, ExtractResponseParamNames<TMethod> extends never ? never : Record<ExtractResponseParamNames<TMethod>, string | number>>>, MergePluginResults<TPlugins>["write"]> & WriteResponseInputFields<ExtractResponseQuery<TMethod>, ExtractResponseBody<TMethod>, ExtractResponseParamNames<TMethod>>;
|
|
444
|
-
|
|
445
|
-
declare function createUseInfiniteRead<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TData, TItem, TError = TDefaultError, TRequest extends AnyInfiniteRequestOptions = AnyInfiniteRequestOptions>(readFn: (api: InfiniteReadApiClient<TSchema, TDefaultError>) => Promise<SpooshResponse<TData, TError>>, readOptions: BaseInfiniteReadOptions<TData, TItem, TRequest> & (((TPlugins[number] extends infer T_3 ? T_3 extends TPlugins[number] ? T_3 extends SpooshPlugin<infer Types_1 extends PluginTypeConfig> ? Types_1 extends {
|
|
446
|
-
infiniteReadOptions: infer I_1;
|
|
447
|
-
} ? I_1 : object : object : never : never) extends infer T_4 ? T_4 extends (TPlugins[number] extends infer T_5 ? T_5 extends TPlugins[number] ? T_5 extends SpooshPlugin<infer Types_1 extends PluginTypeConfig> ? Types_1 extends {
|
|
448
|
-
infiniteReadOptions: infer I_1;
|
|
449
|
-
} ? I_1 : object : object : never : never) ? T_4 extends unknown ? (x: T_4) => void : never : never : never) extends (x: infer I) => void ? I : never)) => BaseInfiniteReadResult<TData, TError, TItem, ((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
450
|
-
readResult: infer R;
|
|
451
|
-
} ? R : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
452
|
-
readResult: infer R;
|
|
453
|
-
} ? R : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never>;
|
|
409
|
+
declare function create<TSchema, TDefaultError, TPlugins extends PluginArray, TApi>(instance: SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins>): SpooshReactHooks<TDefaultError, TSchema, TPlugins>;
|
|
454
410
|
|
|
455
411
|
type PluginHooksConfig<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]> = {
|
|
456
412
|
baseUrl: string;
|
|
@@ -458,4 +414,4 @@ type PluginHooksConfig<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[
|
|
|
458
414
|
plugins: TPlugins;
|
|
459
415
|
};
|
|
460
416
|
|
|
461
|
-
export { type AnyInfiniteRequestOptions, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type ExtractCoreMethodOptions, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type ExtractResponseRequestOptions, type InfiniteNextContext, type InfinitePrevContext, type InfiniteReadApiClient, type PluginHooksConfig, type ReadApiClient, type ResponseInputFields, type SpooshReactHooks, type TriggerOptions, type UseInfiniteReadResult, type UseReadResult, type UseWriteResult, type WriteApiClient, type WriteResponseInputFields,
|
|
417
|
+
export { type AnyInfiniteRequestOptions, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type ExtractCoreMethodOptions, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type ExtractResponseRequestOptions, type InfiniteNextContext, type InfinitePrevContext, type InfiniteReadApiClient, type PluginHooksConfig, type ReadApiClient, type ResponseInputFields, type SpooshReactHooks, type TriggerOptions, type UseInfiniteReadResult, type UseReadResult, type UseWriteResult, type WriteApiClient, type WriteResponseInputFields, create };
|
package/dist/index.d.ts
CHANGED
|
@@ -398,7 +398,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
|
|
|
398
398
|
*
|
|
399
399
|
* @example
|
|
400
400
|
* ```ts
|
|
401
|
-
* const { useRead, useWrite, useInfiniteRead } =
|
|
401
|
+
* const { useRead, useWrite, useInfiniteRead } = create(spooshInstance);
|
|
402
402
|
*
|
|
403
403
|
* function MyComponent() {
|
|
404
404
|
* const { data, loading } = useRead((api) => api("posts").GET());
|
|
@@ -406,51 +406,7 @@ type SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins> = {
|
|
|
406
406
|
* }
|
|
407
407
|
* ```
|
|
408
408
|
*/
|
|
409
|
-
declare function
|
|
410
|
-
|
|
411
|
-
declare function createUseRead<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TReadFn extends (api: ReadApiClient<TSchema, TDefaultError>) => Promise<SpooshResponse<unknown, unknown>>, TReadOpts extends BaseReadOptions & ResolveTypes<((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
412
|
-
readOptions: infer R;
|
|
413
|
-
} ? R : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
414
|
-
readOptions: infer R;
|
|
415
|
-
} ? R : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, TReadFn extends (...args: unknown[]) => Promise<{
|
|
416
|
-
data: infer D;
|
|
417
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
418
|
-
error: infer E;
|
|
419
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
420
|
-
error: infer E;
|
|
421
|
-
}> ? E : unknown, ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn> extends never ? never : Record<ExtractResponseParamNames<TReadFn>, string | number>>> = BaseReadOptions & ResolveTypes<((TPlugins[number] extends infer T_3 ? T_3 extends TPlugins[number] ? T_3 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
422
|
-
readOptions: infer R;
|
|
423
|
-
} ? R : object : object : never : never) extends infer T_4 ? T_4 extends (TPlugins[number] extends infer T_5 ? T_5 extends TPlugins[number] ? T_5 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
424
|
-
readOptions: infer R;
|
|
425
|
-
} ? R : object : object : never : never) ? T_4 extends unknown ? (x: T_4) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, TReadFn extends (...args: unknown[]) => Promise<{
|
|
426
|
-
data: infer D;
|
|
427
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
428
|
-
error: infer E;
|
|
429
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
430
|
-
error: infer E;
|
|
431
|
-
}> ? E : unknown, ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn> extends never ? never : Record<ExtractResponseParamNames<TReadFn>, string | number>>>>(readFn: TReadFn, readOptions?: TReadOpts) => BaseReadResult<TReadFn extends (...args: unknown[]) => Promise<{
|
|
432
|
-
data: infer D;
|
|
433
|
-
}> ? D : unknown, [TReadFn extends (...args: unknown[]) => Promise<{
|
|
434
|
-
error: infer E;
|
|
435
|
-
}> ? E : unknown] extends [unknown] ? TDefaultError : TReadFn extends (...args: unknown[]) => Promise<{
|
|
436
|
-
error: infer E;
|
|
437
|
-
}> ? E : unknown, ResolveResultTypes<MergePluginResults<TPlugins>["read"], TReadOpts>, TriggerOptions<TReadFn>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
|
|
438
|
-
|
|
439
|
-
declare function createUseWrite<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TMethod extends (...args: never[]) => Promise<SpooshResponse<unknown, unknown>>>(writeFn: (api: WriteApiClient<TSchema, TDefaultError>) => TMethod) => BaseWriteResult<ExtractMethodData<TMethod>, [ExtractMethodError<TMethod>] extends [unknown] ? TDefaultError : ExtractMethodError<TMethod>, ExtractMethodOptions<TMethod> & ResolveTypes<((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
440
|
-
writeOptions: infer W;
|
|
441
|
-
} ? W : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
442
|
-
writeOptions: infer W;
|
|
443
|
-
} ? W : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, ResolverContext<TSchema, ExtractMethodData<TMethod>, [ExtractMethodError<TMethod>] extends [unknown] ? TDefaultError : ExtractMethodError<TMethod>, ExtractMethodQuery<TMethod>, ExtractMethodBody<TMethod>, ExtractResponseParamNames<TMethod> extends never ? never : Record<ExtractResponseParamNames<TMethod>, string | number>>>, MergePluginResults<TPlugins>["write"]> & WriteResponseInputFields<ExtractResponseQuery<TMethod>, ExtractResponseBody<TMethod>, ExtractResponseParamNames<TMethod>>;
|
|
444
|
-
|
|
445
|
-
declare function createUseInfiniteRead<TSchema, TDefaultError, TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]>(options: Omit<SpooshInstanceShape<unknown, TSchema, TDefaultError, TPlugins>, "_types">): <TData, TItem, TError = TDefaultError, TRequest extends AnyInfiniteRequestOptions = AnyInfiniteRequestOptions>(readFn: (api: InfiniteReadApiClient<TSchema, TDefaultError>) => Promise<SpooshResponse<TData, TError>>, readOptions: BaseInfiniteReadOptions<TData, TItem, TRequest> & (((TPlugins[number] extends infer T_3 ? T_3 extends TPlugins[number] ? T_3 extends SpooshPlugin<infer Types_1 extends PluginTypeConfig> ? Types_1 extends {
|
|
446
|
-
infiniteReadOptions: infer I_1;
|
|
447
|
-
} ? I_1 : object : object : never : never) extends infer T_4 ? T_4 extends (TPlugins[number] extends infer T_5 ? T_5 extends TPlugins[number] ? T_5 extends SpooshPlugin<infer Types_1 extends PluginTypeConfig> ? Types_1 extends {
|
|
448
|
-
infiniteReadOptions: infer I_1;
|
|
449
|
-
} ? I_1 : object : object : never : never) ? T_4 extends unknown ? (x: T_4) => void : never : never : never) extends (x: infer I) => void ? I : never)) => BaseInfiniteReadResult<TData, TError, TItem, ((TPlugins[number] extends infer T ? T extends TPlugins[number] ? T extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
450
|
-
readResult: infer R;
|
|
451
|
-
} ? R : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
|
|
452
|
-
readResult: infer R;
|
|
453
|
-
} ? R : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never>;
|
|
409
|
+
declare function create<TSchema, TDefaultError, TPlugins extends PluginArray, TApi>(instance: SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins>): SpooshReactHooks<TDefaultError, TSchema, TPlugins>;
|
|
454
410
|
|
|
455
411
|
type PluginHooksConfig<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]> = {
|
|
456
412
|
baseUrl: string;
|
|
@@ -458,4 +414,4 @@ type PluginHooksConfig<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[
|
|
|
458
414
|
plugins: TPlugins;
|
|
459
415
|
};
|
|
460
416
|
|
|
461
|
-
export { type AnyInfiniteRequestOptions, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type ExtractCoreMethodOptions, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type ExtractResponseRequestOptions, type InfiniteNextContext, type InfinitePrevContext, type InfiniteReadApiClient, type PluginHooksConfig, type ReadApiClient, type ResponseInputFields, type SpooshReactHooks, type TriggerOptions, type UseInfiniteReadResult, type UseReadResult, type UseWriteResult, type WriteApiClient, type WriteResponseInputFields,
|
|
417
|
+
export { type AnyInfiniteRequestOptions, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type ExtractCoreMethodOptions, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type ExtractResponseRequestOptions, type InfiniteNextContext, type InfinitePrevContext, type InfiniteReadApiClient, type PluginHooksConfig, type ReadApiClient, type ResponseInputFields, type SpooshReactHooks, type TriggerOptions, type UseInfiniteReadResult, type UseReadResult, type UseWriteResult, type WriteApiClient, type WriteResponseInputFields, create };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
-
"use client";
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -22,10 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
21
|
// src/index.ts
|
|
23
22
|
var src_exports = {};
|
|
24
23
|
__export(src_exports, {
|
|
25
|
-
|
|
26
|
-
createUseInfiniteRead: () => createUseInfiniteRead,
|
|
27
|
-
createUseRead: () => createUseRead,
|
|
28
|
-
createUseWrite: () => createUseWrite
|
|
24
|
+
create: () => create
|
|
29
25
|
});
|
|
30
26
|
module.exports = __toCommonJS(src_exports);
|
|
31
27
|
|
|
@@ -40,7 +36,7 @@ function createUseRead(options) {
|
|
|
40
36
|
tags,
|
|
41
37
|
...pluginOpts
|
|
42
38
|
} = readOptions ?? {};
|
|
43
|
-
const
|
|
39
|
+
const instanceId = (0, import_react.useId)();
|
|
44
40
|
const selectorResultRef = (0, import_react.useRef)({
|
|
45
41
|
call: null,
|
|
46
42
|
selector: null
|
|
@@ -83,7 +79,7 @@ function createUseRead(options) {
|
|
|
83
79
|
stateManager,
|
|
84
80
|
eventEmitter,
|
|
85
81
|
pluginExecutor,
|
|
86
|
-
|
|
82
|
+
instanceId,
|
|
87
83
|
fetchFn: async (fetchOpts) => {
|
|
88
84
|
const pathMethods = api(capturedCall.path);
|
|
89
85
|
const method = pathMethods[capturedCall.method];
|
|
@@ -214,7 +210,7 @@ function createUseRead(options) {
|
|
|
214
210
|
stateManager,
|
|
215
211
|
eventEmitter,
|
|
216
212
|
pluginExecutor,
|
|
217
|
-
|
|
213
|
+
instanceId,
|
|
218
214
|
fetchFn: async (fetchOpts) => {
|
|
219
215
|
const pathMethods = api(capturedCall.path);
|
|
220
216
|
const method = pathMethods[capturedCall.method];
|
|
@@ -256,7 +252,7 @@ function createUseRead(options) {
|
|
|
256
252
|
stateManager,
|
|
257
253
|
eventEmitter,
|
|
258
254
|
pluginExecutor,
|
|
259
|
-
|
|
255
|
+
instanceId,
|
|
260
256
|
pluginOpts,
|
|
261
257
|
api
|
|
262
258
|
]
|
|
@@ -299,7 +295,7 @@ var import_core2 = require("@spoosh/core");
|
|
|
299
295
|
function createUseWrite(options) {
|
|
300
296
|
const { api, stateManager, pluginExecutor, eventEmitter } = options;
|
|
301
297
|
function useWrite(writeFn) {
|
|
302
|
-
const
|
|
298
|
+
const instanceId = (0, import_react2.useId)();
|
|
303
299
|
const selectorResultRef = (0, import_react2.useRef)({
|
|
304
300
|
call: null,
|
|
305
301
|
selector: null
|
|
@@ -331,7 +327,7 @@ function createUseWrite(options) {
|
|
|
331
327
|
stateManager,
|
|
332
328
|
eventEmitter,
|
|
333
329
|
pluginExecutor,
|
|
334
|
-
|
|
330
|
+
instanceId,
|
|
335
331
|
fetchFn: async (fetchOpts) => {
|
|
336
332
|
const pathMethods = api(selectedEndpoint.path);
|
|
337
333
|
const method = pathMethods[selectedEndpoint.method];
|
|
@@ -423,7 +419,7 @@ function createUseInfiniteRead(options) {
|
|
|
423
419
|
prevPageRequest,
|
|
424
420
|
...pluginOpts
|
|
425
421
|
} = readOptions;
|
|
426
|
-
const
|
|
422
|
+
const instanceId = (0, import_react3.useId)();
|
|
427
423
|
const selectorResultRef = (0, import_react3.useRef)({
|
|
428
424
|
call: null,
|
|
429
425
|
selector: null
|
|
@@ -485,7 +481,7 @@ function createUseInfiniteRead(options) {
|
|
|
485
481
|
stateManager,
|
|
486
482
|
eventEmitter,
|
|
487
483
|
pluginExecutor,
|
|
488
|
-
|
|
484
|
+
instanceId,
|
|
489
485
|
fetchFn: async (opts, signal) => {
|
|
490
486
|
const pathMethods = api(capturedCall.path);
|
|
491
487
|
const method = pathMethods[capturedCall.method];
|
|
@@ -591,8 +587,8 @@ function createUseInfiniteRead(options) {
|
|
|
591
587
|
};
|
|
592
588
|
}
|
|
593
589
|
|
|
594
|
-
// src/
|
|
595
|
-
function
|
|
590
|
+
// src/create/index.ts
|
|
591
|
+
function create(instance) {
|
|
596
592
|
const { api, stateManager, eventEmitter, pluginExecutor } = instance;
|
|
597
593
|
const useRead = createUseRead({
|
|
598
594
|
api,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use client";
|
|
3
2
|
|
|
4
3
|
// src/useRead/index.ts
|
|
5
4
|
import {
|
|
@@ -24,7 +23,7 @@ function createUseRead(options) {
|
|
|
24
23
|
tags,
|
|
25
24
|
...pluginOpts
|
|
26
25
|
} = readOptions ?? {};
|
|
27
|
-
const
|
|
26
|
+
const instanceId = useId();
|
|
28
27
|
const selectorResultRef = useRef({
|
|
29
28
|
call: null,
|
|
30
29
|
selector: null
|
|
@@ -67,7 +66,7 @@ function createUseRead(options) {
|
|
|
67
66
|
stateManager,
|
|
68
67
|
eventEmitter,
|
|
69
68
|
pluginExecutor,
|
|
70
|
-
|
|
69
|
+
instanceId,
|
|
71
70
|
fetchFn: async (fetchOpts) => {
|
|
72
71
|
const pathMethods = api(capturedCall.path);
|
|
73
72
|
const method = pathMethods[capturedCall.method];
|
|
@@ -198,7 +197,7 @@ function createUseRead(options) {
|
|
|
198
197
|
stateManager,
|
|
199
198
|
eventEmitter,
|
|
200
199
|
pluginExecutor,
|
|
201
|
-
|
|
200
|
+
instanceId,
|
|
202
201
|
fetchFn: async (fetchOpts) => {
|
|
203
202
|
const pathMethods = api(capturedCall.path);
|
|
204
203
|
const method = pathMethods[capturedCall.method];
|
|
@@ -240,7 +239,7 @@ function createUseRead(options) {
|
|
|
240
239
|
stateManager,
|
|
241
240
|
eventEmitter,
|
|
242
241
|
pluginExecutor,
|
|
243
|
-
|
|
242
|
+
instanceId,
|
|
244
243
|
pluginOpts,
|
|
245
244
|
api
|
|
246
245
|
]
|
|
@@ -294,7 +293,7 @@ import {
|
|
|
294
293
|
function createUseWrite(options) {
|
|
295
294
|
const { api, stateManager, pluginExecutor, eventEmitter } = options;
|
|
296
295
|
function useWrite(writeFn) {
|
|
297
|
-
const
|
|
296
|
+
const instanceId = useId2();
|
|
298
297
|
const selectorResultRef = useRef2({
|
|
299
298
|
call: null,
|
|
300
299
|
selector: null
|
|
@@ -326,7 +325,7 @@ function createUseWrite(options) {
|
|
|
326
325
|
stateManager,
|
|
327
326
|
eventEmitter,
|
|
328
327
|
pluginExecutor,
|
|
329
|
-
|
|
328
|
+
instanceId,
|
|
330
329
|
fetchFn: async (fetchOpts) => {
|
|
331
330
|
const pathMethods = api(selectedEndpoint.path);
|
|
332
331
|
const method = pathMethods[selectedEndpoint.method];
|
|
@@ -429,7 +428,7 @@ function createUseInfiniteRead(options) {
|
|
|
429
428
|
prevPageRequest,
|
|
430
429
|
...pluginOpts
|
|
431
430
|
} = readOptions;
|
|
432
|
-
const
|
|
431
|
+
const instanceId = useId3();
|
|
433
432
|
const selectorResultRef = useRef3({
|
|
434
433
|
call: null,
|
|
435
434
|
selector: null
|
|
@@ -491,7 +490,7 @@ function createUseInfiniteRead(options) {
|
|
|
491
490
|
stateManager,
|
|
492
491
|
eventEmitter,
|
|
493
492
|
pluginExecutor,
|
|
494
|
-
|
|
493
|
+
instanceId,
|
|
495
494
|
fetchFn: async (opts, signal) => {
|
|
496
495
|
const pathMethods = api(capturedCall.path);
|
|
497
496
|
const method = pathMethods[capturedCall.method];
|
|
@@ -597,8 +596,8 @@ function createUseInfiniteRead(options) {
|
|
|
597
596
|
};
|
|
598
597
|
}
|
|
599
598
|
|
|
600
|
-
// src/
|
|
601
|
-
function
|
|
599
|
+
// src/create/index.ts
|
|
600
|
+
function create(instance) {
|
|
602
601
|
const { api, stateManager, eventEmitter, pluginExecutor } = instance;
|
|
603
602
|
const useRead = createUseRead({
|
|
604
603
|
api,
|
|
@@ -642,8 +641,5 @@ function createReactSpoosh(instance) {
|
|
|
642
641
|
};
|
|
643
642
|
}
|
|
644
643
|
export {
|
|
645
|
-
|
|
646
|
-
createUseInfiniteRead,
|
|
647
|
-
createUseRead,
|
|
648
|
-
createUseWrite
|
|
644
|
+
create
|
|
649
645
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React hooks for Spoosh API toolkit",
|
|
6
6
|
"keywords": [
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@spoosh/core": ">=0.
|
|
37
|
+
"@spoosh/core": ">=0.12.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.
|
|
44
|
-
"@spoosh/test-utils": "0.1.
|
|
43
|
+
"@spoosh/core": "0.12.0",
|
|
44
|
+
"@spoosh/test-utils": "0.1.8"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "tsup --watch",
|