@tanstack/angular-query-experimental 5.84.0 → 5.84.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.ts → index.d.ts} +1 -1
- package/{dist/inject-mutation.d.ts → inject-mutation.d.ts} +1 -2
- package/inject-mutation.mjs.map +1 -0
- package/{dist/mutation-options.d.ts → mutation-options.d.ts} +4 -8
- package/mutation-options.mjs.map +1 -0
- package/package.json +5 -41
- package/{dist/types.d.ts → types.d.ts} +3 -1
- package/dist/inject-mutation.mjs.map +0 -1
- package/dist/mutation-options.mjs.map +0 -1
- package/src/create-base-query.ts +0 -142
- package/src/index.ts +0 -64
- package/src/infinite-query-options.ts +0 -187
- package/src/inject-infinite-query.ts +0 -129
- package/src/inject-is-fetching.ts +0 -66
- package/src/inject-is-mutating.ts +0 -65
- package/src/inject-is-restoring.ts +0 -52
- package/src/inject-mutation-state.ts +0 -125
- package/src/inject-mutation.ts +0 -169
- package/src/inject-queries.ts +0 -271
- package/src/inject-query-client.ts +0 -23
- package/src/inject-query.ts +0 -230
- package/src/mutation-options.ts +0 -60
- package/src/providers.ts +0 -372
- package/src/query-options.ts +0 -178
- package/src/signal-proxy.ts +0 -46
- package/src/types.ts +0 -309
- package/src/util/is-dev-mode/is-dev-mode.ts +0 -3
- /package/{dist/create-base-query.d.ts → create-base-query.d.ts} +0 -0
- /package/{dist/create-base-query.mjs → create-base-query.mjs} +0 -0
- /package/{dist/create-base-query.mjs.map → create-base-query.mjs.map} +0 -0
- /package/{dist/index.mjs → index.mjs} +0 -0
- /package/{dist/index.mjs.map → index.mjs.map} +0 -0
- /package/{dist/infinite-query-options.d.ts → infinite-query-options.d.ts} +0 -0
- /package/{dist/infinite-query-options.mjs → infinite-query-options.mjs} +0 -0
- /package/{dist/infinite-query-options.mjs.map → infinite-query-options.mjs.map} +0 -0
- /package/{dist/inject-infinite-query.d.ts → inject-infinite-query.d.ts} +0 -0
- /package/{dist/inject-infinite-query.mjs → inject-infinite-query.mjs} +0 -0
- /package/{dist/inject-infinite-query.mjs.map → inject-infinite-query.mjs.map} +0 -0
- /package/{dist/inject-is-fetching.d.ts → inject-is-fetching.d.ts} +0 -0
- /package/{dist/inject-is-fetching.mjs → inject-is-fetching.mjs} +0 -0
- /package/{dist/inject-is-fetching.mjs.map → inject-is-fetching.mjs.map} +0 -0
- /package/{dist/inject-is-mutating.d.ts → inject-is-mutating.d.ts} +0 -0
- /package/{dist/inject-is-mutating.mjs → inject-is-mutating.mjs} +0 -0
- /package/{dist/inject-is-mutating.mjs.map → inject-is-mutating.mjs.map} +0 -0
- /package/{dist/inject-is-restoring.d.ts → inject-is-restoring.d.ts} +0 -0
- /package/{dist/inject-is-restoring.mjs → inject-is-restoring.mjs} +0 -0
- /package/{dist/inject-is-restoring.mjs.map → inject-is-restoring.mjs.map} +0 -0
- /package/{dist/inject-mutation-state.d.ts → inject-mutation-state.d.ts} +0 -0
- /package/{dist/inject-mutation-state.mjs → inject-mutation-state.mjs} +0 -0
- /package/{dist/inject-mutation-state.mjs.map → inject-mutation-state.mjs.map} +0 -0
- /package/{dist/inject-mutation.mjs → inject-mutation.mjs} +0 -0
- /package/{dist/inject-queries.d.ts → inject-queries.d.ts} +0 -0
- /package/{dist/inject-queries.mjs → inject-queries.mjs} +0 -0
- /package/{dist/inject-queries.mjs.map → inject-queries.mjs.map} +0 -0
- /package/{dist/inject-query-client.d.ts → inject-query-client.d.ts} +0 -0
- /package/{dist/inject-query-client.mjs → inject-query-client.mjs} +0 -0
- /package/{dist/inject-query-client.mjs.map → inject-query-client.mjs.map} +0 -0
- /package/{dist/inject-query.d.ts → inject-query.d.ts} +0 -0
- /package/{dist/inject-query.mjs → inject-query.mjs} +0 -0
- /package/{dist/inject-query.mjs.map → inject-query.mjs.map} +0 -0
- /package/{dist/mutation-options.mjs → mutation-options.mjs} +0 -0
- /package/{dist/providers.d.ts → providers.d.ts} +0 -0
- /package/{dist/providers.mjs → providers.mjs} +0 -0
- /package/{dist/providers.mjs.map → providers.mjs.map} +0 -0
- /package/{dist/query-options.d.ts → query-options.d.ts} +0 -0
- /package/{dist/query-options.mjs → query-options.mjs} +0 -0
- /package/{dist/query-options.mjs.map → query-options.mjs.map} +0 -0
- /package/{dist/signal-proxy.d.ts → signal-proxy.d.ts} +0 -0
- /package/{dist/signal-proxy.mjs → signal-proxy.mjs} +0 -0
- /package/{dist/signal-proxy.mjs.map → signal-proxy.mjs.map} +0 -0
- /package/{dist/util → util}/is-dev-mode/is-dev-mode.d.ts +0 -0
|
@@ -2,7 +2,7 @@ export * from '@tanstack/query-core';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export type { DefinedInitialDataOptions, UndefinedInitialDataOptions, UnusedSkipTokenOptions, } from './query-options.js';
|
|
4
4
|
export { queryOptions } from './query-options.js';
|
|
5
|
-
export type { CreateMutationOptions } from './
|
|
5
|
+
export type { CreateMutationOptions } from './types.js';
|
|
6
6
|
export { mutationOptions } from './mutation-options.js';
|
|
7
7
|
export type { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions, } from './infinite-query-options.js';
|
|
8
8
|
export { infiniteQueryOptions } from './infinite-query-options.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Injector } from '@angular/core';
|
|
2
2
|
import { DefaultError } from '@tanstack/query-core';
|
|
3
|
-
import { CreateMutationResult } from './types.js';
|
|
4
|
-
import { CreateMutationOptions } from './mutation-options.js';
|
|
3
|
+
import { CreateMutationOptions, CreateMutationResult } from './types.js';
|
|
5
4
|
export interface InjectMutationOptions {
|
|
6
5
|
/**
|
|
7
6
|
* The `Injector` in which to create the mutation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-mutation.mjs","sources":["../src/inject-mutation.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n noop,\n notifyManager,\n shouldThrowError,\n} from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type {\n CreateMutateFunction,\n CreateMutationOptions,\n CreateMutationResult,\n} from './types'\n\nexport interface InjectMutationOptions {\n /**\n * The `Injector` in which to create the mutation.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param injectMutationFn - A function that returns mutation options.\n * @param options - Additional configuration\n * @returns The mutation.\n * @public\n */\nexport function injectMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n injectMutationFn: () => CreateMutationOptions<\n TData,\n TError,\n TVariables,\n TContext\n >,\n options?: InjectMutationOptions,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n !options?.injector && assertInInjectionContext(injectMutation)\n const injector = options?.injector ?? inject(Injector)\n const destroyRef = injector.get(DestroyRef)\n const ngZone = injector.get(NgZone)\n const queryClient = injector.get(QueryClient)\n\n /**\n * computed() is used so signals can be inserted into the options\n * making it reactive. Wrapping options in a function ensures embedded expressions\n * are preserved and can keep being applied after signal changes\n */\n const optionsSignal = computed(injectMutationFn)\n\n const observerSignal = (() => {\n let instance: MutationObserver<TData, TError, TVariables, TContext> | null =\n null\n\n return computed(() => {\n return (instance ||= new MutationObserver(queryClient, optionsSignal()))\n })\n })()\n\n const mutateFnSignal = computed<\n CreateMutateFunction<TData, TError, TVariables, TContext>\n >(() => {\n const observer = observerSignal()\n return (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n }\n })\n\n /**\n * Computed signal that gets result from mutation cache based on passed options\n */\n const resultFromInitialOptionsSignal = computed(() => {\n const observer = observerSignal()\n return observer.getCurrentResult()\n })\n\n /**\n * Signal that contains result set by subscriber\n */\n const resultFromSubscriberSignal = signal<MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n effect(\n () => {\n const observer = observerSignal()\n const observerOptions = optionsSignal()\n\n untracked(() => {\n observer.setOptions(observerOptions)\n })\n },\n {\n injector,\n },\n )\n\n effect(\n () => {\n // observer.trackResult is not used as this optimization is not needed for Angular\n const observer = observerSignal()\n\n untracked(() => {\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(\n notifyManager.batchCalls((state) => {\n ngZone.run(() => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n ngZone.onError.emit(state.error)\n throw state.error\n }\n\n resultFromSubscriberSignal.set(state)\n })\n }),\n ),\n )\n destroyRef.onDestroy(unsubscribe)\n })\n },\n {\n injector,\n },\n )\n\n const resultSignal = computed(() => {\n const resultFromSubscriber = resultFromSubscriberSignal()\n const resultFromInitialOptions = resultFromInitialOptionsSignal()\n\n const result = resultFromSubscriber ?? resultFromInitialOptions\n\n return {\n ...result,\n mutate: mutateFnSignal(),\n mutateAsync: result.mutate,\n }\n })\n\n return signalProxy(resultSignal) as CreateMutationResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n}\n"],"names":[],"mappings":";;;AA4CgB,SAAA,eAMd,kBAMA,SAC2D;AAC1D,IAAA,mCAAS,aAAY,yBAAyB,cAAc;AAC7D,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC/C,QAAA,aAAa,SAAS,IAAI,UAAU;AACpC,QAAA,SAAS,SAAS,IAAI,MAAM;AAC5B,QAAA,cAAc,SAAS,IAAI,WAAW;AAOtC,QAAA,gBAAgB,SAAS,gBAAgB;AAE/C,QAAM,kBAAkB,MAAM;AAC5B,QAAI,WACF;AAEF,WAAO,SAAS,MAAM;AACpB,aAAQ,wBAAa,IAAI,iBAAiB,aAAa,eAAe;AAAA,IAAA,CACvE;AAAA,EAAA,GACA;AAEG,QAAA,iBAAiB,SAErB,MAAM;AACN,UAAM,WAAW,eAAe;AACzB,WAAA,CAAC,WAAW,kBAAkB;AACnC,eAAS,OAAO,WAAW,aAAa,EAAE,MAAM,IAAI;AAAA,IACtD;AAAA,EAAA,CACD;AAKK,QAAA,iCAAiC,SAAS,MAAM;AACpD,UAAM,WAAW,eAAe;AAChC,WAAO,SAAS,iBAAiB;AAAA,EAAA,CAClC;AAKK,QAAA,6BAA6B,OAKzB,IAAI;AAEd;AAAA,IACE,MAAM;AACJ,YAAM,WAAW,eAAe;AAChC,YAAM,kBAAkB,cAAc;AAEtC,gBAAU,MAAM;AACd,iBAAS,WAAW,eAAe;AAAA,MAAA,CACpC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEA;AAAA,IACE,MAAM;AAEJ,YAAM,WAAW,eAAe;AAEhC,gBAAU,MAAM;AACd,cAAM,cAAc,OAAO;AAAA,UAAkB,MAC3C,SAAS;AAAA,YACP,cAAc,WAAW,CAAC,UAAU;AAClC,qBAAO,IAAI,MAAM;AAEb,oBAAA,MAAM,WACN,iBAAiB,SAAS,QAAQ,cAAc,CAAC,MAAM,KAAK,CAAC,GAC7D;AACO,yBAAA,QAAQ,KAAK,MAAM,KAAK;AAC/B,wBAAM,MAAM;AAAA,gBAAA;AAGd,2CAA2B,IAAI,KAAK;AAAA,cAAA,CACrC;AAAA,YACF,CAAA;AAAA,UAAA;AAAA,QAEL;AACA,mBAAW,UAAU,WAAW;AAAA,MAAA,CACjC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEM,QAAA,eAAe,SAAS,MAAM;AAClC,UAAM,uBAAuB,2BAA2B;AACxD,UAAM,2BAA2B,+BAA+B;AAEhE,UAAM,SAAS,wBAAwB;AAEhC,WAAA;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,eAAe;AAAA,MACvB,aAAa,OAAO;AAAA,IACtB;AAAA,EAAA,CACD;AAED,SAAO,YAAY,YAAY;AAMjC;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DefaultError,
|
|
1
|
+
import { DefaultError, WithRequired } from '@tanstack/query-core';
|
|
2
|
+
import { CreateMutationOptions } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Allows to share and re-use mutation options in a type-safe way.
|
|
4
5
|
*
|
|
@@ -28,11 +29,6 @@ import { DefaultError, MutationObserverOptions, OmitKeyof } from '@tanstack/quer
|
|
|
28
29
|
* ```
|
|
29
30
|
* @param options - The mutation options.
|
|
30
31
|
* @returns Mutation options.
|
|
31
|
-
* @public
|
|
32
32
|
*/
|
|
33
|
-
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options:
|
|
34
|
-
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export interface CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
38
|
-
}
|
|
33
|
+
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: WithRequired<CreateMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey'>): WithRequired<CreateMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey'>;
|
|
34
|
+
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: Omit<CreateMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey'>): Omit<CreateMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-options.mjs","sources":["../src/mutation-options.ts"],"sourcesContent":["import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { CreateMutationOptions } from './types'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient);\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost);\n * },\n * });\n * }\n * }\n *\n * queries = inject(QueriesService)\n * idSignal = new Signal(0);\n * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))\n *\n * mutation.mutate({ title: 'New Title' })\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: WithRequired<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n >,\n): WithRequired<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: Omit<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n >,\n): Omit<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n>\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient);\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost);\n * },\n * });\n * }\n * }\n *\n * queries = inject(QueriesService)\n * idSignal = new Signal(0);\n * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))\n *\n * mutation.mutate({ title: 'New Title' })\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: CreateMutationOptions<TData, TError, TVariables, TContext>,\n): CreateMutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n"],"names":[],"mappings":"AA4FO,SAAS,gBAMd,SAC4D;AACrD,SAAA;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-query-experimental",
|
|
3
|
-
"version": "5.84.
|
|
3
|
+
"version": "5.84.2",
|
|
4
4
|
"description": "Signals for managing, caching and syncing asynchronous and remote data in Angular",
|
|
5
5
|
"author": "Arnoud de Vries",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,59 +27,23 @@
|
|
|
27
27
|
"tanstack"
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
|
-
"types": "
|
|
31
|
-
"module": "
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"module": "./index.mjs",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"@tanstack/custom-condition": "./src/index.ts",
|
|
35
|
-
"types": "./
|
|
36
|
-
"default": "./
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
|
+
"default": "./index.mjs"
|
|
37
37
|
},
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|
|
41
|
-
"files": [
|
|
42
|
-
"dist",
|
|
43
|
-
"src",
|
|
44
|
-
"!src/__tests__"
|
|
45
|
-
],
|
|
46
41
|
"dependencies": {
|
|
47
42
|
"@tanstack/query-core": "5.83.1",
|
|
48
43
|
"@tanstack/query-devtools": "5.84.0"
|
|
49
44
|
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@angular/common": "^20.0.0",
|
|
52
|
-
"@angular/compiler": "^20.0.0",
|
|
53
|
-
"@angular/core": "^20.0.0",
|
|
54
|
-
"@angular/platform-browser": "^20.0.0",
|
|
55
|
-
"eslint-plugin-jsdoc": "^50.5.0",
|
|
56
|
-
"npm-run-all2": "^5.0.0",
|
|
57
|
-
"vite-plugin-dts": "4.2.3",
|
|
58
|
-
"vite-plugin-externalize-deps": "^0.9.0",
|
|
59
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
60
|
-
"@tanstack/query-test-utils": "0.0.0"
|
|
61
|
-
},
|
|
62
45
|
"peerDependencies": {
|
|
63
46
|
"@angular/common": ">=16.0.0",
|
|
64
47
|
"@angular/core": ">=16.0.0"
|
|
65
|
-
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"clean": "premove ./build ./dist ./coverage ./dist-ts",
|
|
68
|
-
"compile": "tsc --build",
|
|
69
|
-
"test:eslint": "eslint ./src",
|
|
70
|
-
"test:types": "npm-run-all --serial test:types:*",
|
|
71
|
-
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js --build",
|
|
72
|
-
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js --build",
|
|
73
|
-
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js --build",
|
|
74
|
-
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js --build",
|
|
75
|
-
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build",
|
|
76
|
-
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build",
|
|
77
|
-
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
|
|
78
|
-
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
|
|
79
|
-
"test:types:tscurrent": "tsc --build",
|
|
80
|
-
"test:lib": "vitest",
|
|
81
|
-
"test:lib:dev": "pnpm run test:lib --watch",
|
|
82
|
-
"test:build": "pnpm pack && publint ./dist/*.tgz --strict && attw ./dist/*.tgz; premove ./dist/*.tgz",
|
|
83
|
-
"build": "vite build"
|
|
84
48
|
}
|
|
85
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefaultError, DefinedInfiniteQueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, MutateFunction, MutationObserverResult, OmitKeyof, Override, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/query-core';
|
|
1
|
+
import { DefaultError, DefinedInfiniteQueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, MutateFunction, MutationObserverOptions, MutationObserverResult, OmitKeyof, Override, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/query-core';
|
|
2
2
|
import { Signal } from '@angular/core';
|
|
3
3
|
import { MapToSignals } from './signal-proxy.js';
|
|
4
4
|
/**
|
|
@@ -50,6 +50,8 @@ export type CreateInfiniteQueryResult<TData = unknown, TError = DefaultError> =
|
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
52
|
export type DefinedCreateInfiniteQueryResult<TData = unknown, TError = DefaultError, TDefinedInfiniteQueryObserver = DefinedInfiniteQueryObserverResult<TData, TError>> = MapToSignals<TDefinedInfiniteQueryObserver>;
|
|
53
|
+
export interface CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
54
|
+
}
|
|
53
55
|
/**
|
|
54
56
|
* @public
|
|
55
57
|
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inject-mutation.mjs","sources":["../src/inject-mutation.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n noop,\n notifyManager,\n shouldThrowError,\n} from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type { CreateMutateFunction, CreateMutationResult } from './types'\nimport type { CreateMutationOptions } from './mutation-options'\n\nexport interface InjectMutationOptions {\n /**\n * The `Injector` in which to create the mutation.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param injectMutationFn - A function that returns mutation options.\n * @param options - Additional configuration\n * @returns The mutation.\n * @public\n */\nexport function injectMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n injectMutationFn: () => CreateMutationOptions<\n TData,\n TError,\n TVariables,\n TContext\n >,\n options?: InjectMutationOptions,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n !options?.injector && assertInInjectionContext(injectMutation)\n const injector = options?.injector ?? inject(Injector)\n const destroyRef = injector.get(DestroyRef)\n const ngZone = injector.get(NgZone)\n const queryClient = injector.get(QueryClient)\n\n /**\n * computed() is used so signals can be inserted into the options\n * making it reactive. Wrapping options in a function ensures embedded expressions\n * are preserved and can keep being applied after signal changes\n */\n const optionsSignal = computed(injectMutationFn)\n\n const observerSignal = (() => {\n let instance: MutationObserver<TData, TError, TVariables, TContext> | null =\n null\n\n return computed(() => {\n return (instance ||= new MutationObserver(queryClient, optionsSignal()))\n })\n })()\n\n const mutateFnSignal = computed<\n CreateMutateFunction<TData, TError, TVariables, TContext>\n >(() => {\n const observer = observerSignal()\n return (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n }\n })\n\n /**\n * Computed signal that gets result from mutation cache based on passed options\n */\n const resultFromInitialOptionsSignal = computed(() => {\n const observer = observerSignal()\n return observer.getCurrentResult()\n })\n\n /**\n * Signal that contains result set by subscriber\n */\n const resultFromSubscriberSignal = signal<MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n effect(\n () => {\n const observer = observerSignal()\n const observerOptions = optionsSignal()\n\n untracked(() => {\n observer.setOptions(observerOptions)\n })\n },\n {\n injector,\n },\n )\n\n effect(\n () => {\n // observer.trackResult is not used as this optimization is not needed for Angular\n const observer = observerSignal()\n\n untracked(() => {\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(\n notifyManager.batchCalls((state) => {\n ngZone.run(() => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n ngZone.onError.emit(state.error)\n throw state.error\n }\n\n resultFromSubscriberSignal.set(state)\n })\n }),\n ),\n )\n destroyRef.onDestroy(unsubscribe)\n })\n },\n {\n injector,\n },\n )\n\n const resultSignal = computed(() => {\n const resultFromSubscriber = resultFromSubscriberSignal()\n const resultFromInitialOptions = resultFromInitialOptionsSignal()\n\n const result = resultFromSubscriber ?? resultFromInitialOptions\n\n return {\n ...result,\n mutate: mutateFnSignal(),\n mutateAsync: result.mutate,\n }\n })\n\n return signalProxy(resultSignal) as CreateMutationResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n}\n"],"names":[],"mappings":";;;AAyCgB,SAAA,eAMd,kBAMA,SAC2D;AAC1D,IAAA,mCAAS,aAAY,yBAAyB,cAAc;AAC7D,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC/C,QAAA,aAAa,SAAS,IAAI,UAAU;AACpC,QAAA,SAAS,SAAS,IAAI,MAAM;AAC5B,QAAA,cAAc,SAAS,IAAI,WAAW;AAOtC,QAAA,gBAAgB,SAAS,gBAAgB;AAE/C,QAAM,kBAAkB,MAAM;AAC5B,QAAI,WACF;AAEF,WAAO,SAAS,MAAM;AACpB,aAAQ,wBAAa,IAAI,iBAAiB,aAAa,eAAe;AAAA,IAAA,CACvE;AAAA,EAAA,GACA;AAEG,QAAA,iBAAiB,SAErB,MAAM;AACN,UAAM,WAAW,eAAe;AACzB,WAAA,CAAC,WAAW,kBAAkB;AACnC,eAAS,OAAO,WAAW,aAAa,EAAE,MAAM,IAAI;AAAA,IACtD;AAAA,EAAA,CACD;AAKK,QAAA,iCAAiC,SAAS,MAAM;AACpD,UAAM,WAAW,eAAe;AAChC,WAAO,SAAS,iBAAiB;AAAA,EAAA,CAClC;AAKK,QAAA,6BAA6B,OAKzB,IAAI;AAEd;AAAA,IACE,MAAM;AACJ,YAAM,WAAW,eAAe;AAChC,YAAM,kBAAkB,cAAc;AAEtC,gBAAU,MAAM;AACd,iBAAS,WAAW,eAAe;AAAA,MAAA,CACpC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEA;AAAA,IACE,MAAM;AAEJ,YAAM,WAAW,eAAe;AAEhC,gBAAU,MAAM;AACd,cAAM,cAAc,OAAO;AAAA,UAAkB,MAC3C,SAAS;AAAA,YACP,cAAc,WAAW,CAAC,UAAU;AAClC,qBAAO,IAAI,MAAM;AAEb,oBAAA,MAAM,WACN,iBAAiB,SAAS,QAAQ,cAAc,CAAC,MAAM,KAAK,CAAC,GAC7D;AACO,yBAAA,QAAQ,KAAK,MAAM,KAAK;AAC/B,wBAAM,MAAM;AAAA,gBAAA;AAGd,2CAA2B,IAAI,KAAK;AAAA,cAAA,CACrC;AAAA,YACF,CAAA;AAAA,UAAA;AAAA,QAEL;AACA,mBAAW,UAAU,WAAW;AAAA,MAAA,CACjC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEM,QAAA,eAAe,SAAS,MAAM;AAClC,UAAM,uBAAuB,2BAA2B;AACxD,UAAM,2BAA2B,+BAA+B;AAEhE,UAAM,SAAS,wBAAwB;AAEhC,WAAA;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,eAAe;AAAA,MACvB,aAAa,OAAO;AAAA,IACtB;AAAA,EAAA,CACD;AAED,SAAO,YAAY,YAAY;AAMjC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-options.mjs","sources":["../src/mutation-options.ts"],"sourcesContent":["import type {\n DefaultError,\n MutationObserverOptions,\n OmitKeyof,\n} from '@tanstack/query-core'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient);\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost);\n * },\n * });\n * }\n * }\n *\n * queries = inject(QueriesService)\n * idSignal = new Signal(0);\n * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))\n *\n * mutation.mutate({ title: 'New Title' })\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n * @public\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n): CreateMutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n\n/**\n * @public\n */\nexport interface CreateMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends OmitKeyof<\n MutationObserverOptions<TData, TError, TVariables, TContext>,\n '_defaulted'\n > {}\n"],"names":[],"mappings":"AAqCO,SAAS,gBAMd,SAC4D;AACrD,SAAA;AACT;"}
|
package/src/create-base-query.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NgZone,
|
|
3
|
-
VERSION,
|
|
4
|
-
computed,
|
|
5
|
-
effect,
|
|
6
|
-
inject,
|
|
7
|
-
signal,
|
|
8
|
-
untracked,
|
|
9
|
-
} from '@angular/core'
|
|
10
|
-
import {
|
|
11
|
-
QueryClient,
|
|
12
|
-
notifyManager,
|
|
13
|
-
shouldThrowError,
|
|
14
|
-
} from '@tanstack/query-core'
|
|
15
|
-
import { signalProxy } from './signal-proxy'
|
|
16
|
-
import { injectIsRestoring } from './inject-is-restoring'
|
|
17
|
-
import type {
|
|
18
|
-
QueryKey,
|
|
19
|
-
QueryObserver,
|
|
20
|
-
QueryObserverResult,
|
|
21
|
-
} from '@tanstack/query-core'
|
|
22
|
-
import type { CreateBaseQueryOptions } from './types'
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base implementation for `injectQuery` and `injectInfiniteQuery`.
|
|
26
|
-
* @param optionsFn
|
|
27
|
-
* @param Observer
|
|
28
|
-
*/
|
|
29
|
-
export function createBaseQuery<
|
|
30
|
-
TQueryFnData,
|
|
31
|
-
TError,
|
|
32
|
-
TData,
|
|
33
|
-
TQueryData,
|
|
34
|
-
TQueryKey extends QueryKey,
|
|
35
|
-
>(
|
|
36
|
-
optionsFn: () => CreateBaseQueryOptions<
|
|
37
|
-
TQueryFnData,
|
|
38
|
-
TError,
|
|
39
|
-
TData,
|
|
40
|
-
TQueryData,
|
|
41
|
-
TQueryKey
|
|
42
|
-
>,
|
|
43
|
-
Observer: typeof QueryObserver,
|
|
44
|
-
) {
|
|
45
|
-
const ngZone = inject(NgZone)
|
|
46
|
-
const queryClient = inject(QueryClient)
|
|
47
|
-
const isRestoring = injectIsRestoring()
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Signal that has the default options from query client applied
|
|
51
|
-
* computed() is used so signals can be inserted into the options
|
|
52
|
-
* making it reactive. Wrapping options in a function ensures embedded expressions
|
|
53
|
-
* are preserved and can keep being applied after signal changes
|
|
54
|
-
*/
|
|
55
|
-
const defaultedOptionsSignal = computed(() => {
|
|
56
|
-
const defaultedOptions = queryClient.defaultQueryOptions(optionsFn())
|
|
57
|
-
defaultedOptions._optimisticResults = isRestoring()
|
|
58
|
-
? 'isRestoring'
|
|
59
|
-
: 'optimistic'
|
|
60
|
-
return defaultedOptions
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const observerSignal = (() => {
|
|
64
|
-
let instance: QueryObserver<
|
|
65
|
-
TQueryFnData,
|
|
66
|
-
TError,
|
|
67
|
-
TData,
|
|
68
|
-
TQueryData,
|
|
69
|
-
TQueryKey
|
|
70
|
-
> | null = null
|
|
71
|
-
|
|
72
|
-
return computed(() => {
|
|
73
|
-
return (instance ||= new Observer(queryClient, defaultedOptionsSignal()))
|
|
74
|
-
})
|
|
75
|
-
})()
|
|
76
|
-
|
|
77
|
-
const optimisticResultSignal = computed(() =>
|
|
78
|
-
observerSignal().getOptimisticResult(defaultedOptionsSignal()),
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const resultFromSubscriberSignal = signal<QueryObserverResult<
|
|
82
|
-
TData,
|
|
83
|
-
TError
|
|
84
|
-
> | null>(null)
|
|
85
|
-
|
|
86
|
-
effect(
|
|
87
|
-
(onCleanup) => {
|
|
88
|
-
const observer = observerSignal()
|
|
89
|
-
const defaultedOptions = defaultedOptionsSignal()
|
|
90
|
-
|
|
91
|
-
untracked(() => {
|
|
92
|
-
observer.setOptions(defaultedOptions)
|
|
93
|
-
})
|
|
94
|
-
onCleanup(() => {
|
|
95
|
-
ngZone.run(() => resultFromSubscriberSignal.set(null))
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
// Set allowSignalWrites to support Angular < v19
|
|
100
|
-
// Set to undefined to avoid warning on newer versions
|
|
101
|
-
allowSignalWrites: VERSION.major < '19' || undefined,
|
|
102
|
-
},
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
effect((onCleanup) => {
|
|
106
|
-
// observer.trackResult is not used as this optimization is not needed for Angular
|
|
107
|
-
const observer = observerSignal()
|
|
108
|
-
const unsubscribe = isRestoring()
|
|
109
|
-
? () => undefined
|
|
110
|
-
: untracked(() =>
|
|
111
|
-
ngZone.runOutsideAngular(() =>
|
|
112
|
-
observer.subscribe(
|
|
113
|
-
notifyManager.batchCalls((state) => {
|
|
114
|
-
ngZone.run(() => {
|
|
115
|
-
if (
|
|
116
|
-
state.isError &&
|
|
117
|
-
!state.isFetching &&
|
|
118
|
-
shouldThrowError(observer.options.throwOnError, [
|
|
119
|
-
state.error,
|
|
120
|
-
observer.getCurrentQuery(),
|
|
121
|
-
])
|
|
122
|
-
) {
|
|
123
|
-
ngZone.onError.emit(state.error)
|
|
124
|
-
throw state.error
|
|
125
|
-
}
|
|
126
|
-
resultFromSubscriberSignal.set(state)
|
|
127
|
-
})
|
|
128
|
-
}),
|
|
129
|
-
),
|
|
130
|
-
),
|
|
131
|
-
)
|
|
132
|
-
onCleanup(unsubscribe)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
return signalProxy(
|
|
136
|
-
computed(() => {
|
|
137
|
-
const subscriberResult = resultFromSubscriberSignal()
|
|
138
|
-
const optimisticResult = optimisticResultSignal()
|
|
139
|
-
return subscriberResult ?? optimisticResult
|
|
140
|
-
}),
|
|
141
|
-
)
|
|
142
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
|
|
3
|
-
// Re-export core
|
|
4
|
-
export * from '@tanstack/query-core'
|
|
5
|
-
|
|
6
|
-
export * from './types'
|
|
7
|
-
|
|
8
|
-
export type {
|
|
9
|
-
DefinedInitialDataOptions,
|
|
10
|
-
UndefinedInitialDataOptions,
|
|
11
|
-
UnusedSkipTokenOptions,
|
|
12
|
-
} from './query-options'
|
|
13
|
-
export { queryOptions } from './query-options'
|
|
14
|
-
|
|
15
|
-
export type { CreateMutationOptions } from './mutation-options'
|
|
16
|
-
export { mutationOptions } from './mutation-options'
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
DefinedInitialDataInfiniteOptions,
|
|
20
|
-
UndefinedInitialDataInfiniteOptions,
|
|
21
|
-
UnusedSkipTokenInfiniteOptions,
|
|
22
|
-
} from './infinite-query-options'
|
|
23
|
-
export { infiniteQueryOptions } from './infinite-query-options'
|
|
24
|
-
|
|
25
|
-
export type { InjectInfiniteQueryOptions } from './inject-infinite-query'
|
|
26
|
-
export { injectInfiniteQuery } from './inject-infinite-query'
|
|
27
|
-
|
|
28
|
-
export type { InjectIsFetchingOptions } from './inject-is-fetching'
|
|
29
|
-
export { injectIsFetching } from './inject-is-fetching'
|
|
30
|
-
|
|
31
|
-
export type { InjectIsMutatingOptions } from './inject-is-mutating'
|
|
32
|
-
export { injectIsMutating } from './inject-is-mutating'
|
|
33
|
-
|
|
34
|
-
export { injectIsRestoring, provideIsRestoring } from './inject-is-restoring'
|
|
35
|
-
|
|
36
|
-
export type { InjectMutationOptions } from './inject-mutation'
|
|
37
|
-
export { injectMutation } from './inject-mutation'
|
|
38
|
-
|
|
39
|
-
export type { InjectMutationStateOptions } from './inject-mutation-state'
|
|
40
|
-
export { injectMutationState } from './inject-mutation-state'
|
|
41
|
-
|
|
42
|
-
export type { QueriesOptions, QueriesResults } from './inject-queries'
|
|
43
|
-
export { injectQueries } from './inject-queries'
|
|
44
|
-
|
|
45
|
-
export type { InjectQueryOptions } from './inject-query'
|
|
46
|
-
export { injectQuery } from './inject-query'
|
|
47
|
-
|
|
48
|
-
export { injectQueryClient } from './inject-query-client'
|
|
49
|
-
|
|
50
|
-
export type {
|
|
51
|
-
DeveloperToolsFeature,
|
|
52
|
-
DevtoolsOptions,
|
|
53
|
-
PersistQueryClientFeature,
|
|
54
|
-
QueryFeature,
|
|
55
|
-
QueryFeatureKind,
|
|
56
|
-
QueryFeatures,
|
|
57
|
-
} from './providers'
|
|
58
|
-
export {
|
|
59
|
-
provideQueryClient,
|
|
60
|
-
provideTanStackQuery,
|
|
61
|
-
queryFeature,
|
|
62
|
-
queryFeatures,
|
|
63
|
-
withDevtools,
|
|
64
|
-
} from './providers'
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DataTag,
|
|
3
|
-
DefaultError,
|
|
4
|
-
InfiniteData,
|
|
5
|
-
InitialDataFunction,
|
|
6
|
-
NonUndefinedGuard,
|
|
7
|
-
OmitKeyof,
|
|
8
|
-
QueryKey,
|
|
9
|
-
SkipToken,
|
|
10
|
-
} from '@tanstack/query-core'
|
|
11
|
-
import type { CreateInfiniteQueryOptions } from './types'
|
|
12
|
-
|
|
13
|
-
export type UndefinedInitialDataInfiniteOptions<
|
|
14
|
-
TQueryFnData,
|
|
15
|
-
TError = DefaultError,
|
|
16
|
-
TData = InfiniteData<TQueryFnData>,
|
|
17
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
18
|
-
TPageParam = unknown,
|
|
19
|
-
> = CreateInfiniteQueryOptions<
|
|
20
|
-
TQueryFnData,
|
|
21
|
-
TError,
|
|
22
|
-
TData,
|
|
23
|
-
TQueryKey,
|
|
24
|
-
TPageParam
|
|
25
|
-
> & {
|
|
26
|
-
initialData?:
|
|
27
|
-
| undefined
|
|
28
|
-
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
29
|
-
| InitialDataFunction<
|
|
30
|
-
NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
31
|
-
>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type UnusedSkipTokenInfiniteOptions<
|
|
35
|
-
TQueryFnData,
|
|
36
|
-
TError = DefaultError,
|
|
37
|
-
TData = InfiniteData<TQueryFnData>,
|
|
38
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
39
|
-
TPageParam = unknown,
|
|
40
|
-
> = OmitKeyof<
|
|
41
|
-
CreateInfiniteQueryOptions<
|
|
42
|
-
TQueryFnData,
|
|
43
|
-
TError,
|
|
44
|
-
TData,
|
|
45
|
-
TQueryKey,
|
|
46
|
-
TPageParam
|
|
47
|
-
>,
|
|
48
|
-
'queryFn'
|
|
49
|
-
> & {
|
|
50
|
-
queryFn?: Exclude<
|
|
51
|
-
CreateInfiniteQueryOptions<
|
|
52
|
-
TQueryFnData,
|
|
53
|
-
TError,
|
|
54
|
-
TData,
|
|
55
|
-
TQueryKey,
|
|
56
|
-
TPageParam
|
|
57
|
-
>['queryFn'],
|
|
58
|
-
SkipToken | undefined
|
|
59
|
-
>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type DefinedInitialDataInfiniteOptions<
|
|
63
|
-
TQueryFnData,
|
|
64
|
-
TError = DefaultError,
|
|
65
|
-
TData = InfiniteData<TQueryFnData>,
|
|
66
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
67
|
-
TPageParam = unknown,
|
|
68
|
-
> = CreateInfiniteQueryOptions<
|
|
69
|
-
TQueryFnData,
|
|
70
|
-
TError,
|
|
71
|
-
TData,
|
|
72
|
-
TQueryKey,
|
|
73
|
-
TPageParam
|
|
74
|
-
> & {
|
|
75
|
-
initialData:
|
|
76
|
-
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
77
|
-
| (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
|
|
78
|
-
| undefined
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
83
|
-
*
|
|
84
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
85
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
86
|
-
* @returns The tagged infinite query options.
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
export function infiniteQueryOptions<
|
|
90
|
-
TQueryFnData,
|
|
91
|
-
TError = DefaultError,
|
|
92
|
-
TData = InfiniteData<TQueryFnData>,
|
|
93
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
94
|
-
TPageParam = unknown,
|
|
95
|
-
>(
|
|
96
|
-
options: DefinedInitialDataInfiniteOptions<
|
|
97
|
-
TQueryFnData,
|
|
98
|
-
TError,
|
|
99
|
-
TData,
|
|
100
|
-
TQueryKey,
|
|
101
|
-
TPageParam
|
|
102
|
-
>,
|
|
103
|
-
): DefinedInitialDataInfiniteOptions<
|
|
104
|
-
TQueryFnData,
|
|
105
|
-
TError,
|
|
106
|
-
TData,
|
|
107
|
-
TQueryKey,
|
|
108
|
-
TPageParam
|
|
109
|
-
> & {
|
|
110
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
115
|
-
*
|
|
116
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
117
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
118
|
-
* @returns The tagged infinite query options.
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
export function infiniteQueryOptions<
|
|
122
|
-
TQueryFnData,
|
|
123
|
-
TError = DefaultError,
|
|
124
|
-
TData = InfiniteData<TQueryFnData>,
|
|
125
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
126
|
-
TPageParam = unknown,
|
|
127
|
-
>(
|
|
128
|
-
options: UnusedSkipTokenInfiniteOptions<
|
|
129
|
-
TQueryFnData,
|
|
130
|
-
TError,
|
|
131
|
-
TData,
|
|
132
|
-
TQueryKey,
|
|
133
|
-
TPageParam
|
|
134
|
-
>,
|
|
135
|
-
): UnusedSkipTokenInfiniteOptions<
|
|
136
|
-
TQueryFnData,
|
|
137
|
-
TError,
|
|
138
|
-
TData,
|
|
139
|
-
TQueryKey,
|
|
140
|
-
TPageParam
|
|
141
|
-
> & {
|
|
142
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
147
|
-
*
|
|
148
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
149
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
150
|
-
* @returns The tagged infinite query options.
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
export function infiniteQueryOptions<
|
|
154
|
-
TQueryFnData,
|
|
155
|
-
TError = DefaultError,
|
|
156
|
-
TData = InfiniteData<TQueryFnData>,
|
|
157
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
158
|
-
TPageParam = unknown,
|
|
159
|
-
>(
|
|
160
|
-
options: UndefinedInitialDataInfiniteOptions<
|
|
161
|
-
TQueryFnData,
|
|
162
|
-
TError,
|
|
163
|
-
TData,
|
|
164
|
-
TQueryKey,
|
|
165
|
-
TPageParam
|
|
166
|
-
>,
|
|
167
|
-
): UndefinedInitialDataInfiniteOptions<
|
|
168
|
-
TQueryFnData,
|
|
169
|
-
TError,
|
|
170
|
-
TData,
|
|
171
|
-
TQueryKey,
|
|
172
|
-
TPageParam
|
|
173
|
-
> & {
|
|
174
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
179
|
-
*
|
|
180
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
181
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
182
|
-
* @returns The tagged infinite query options.
|
|
183
|
-
* @public
|
|
184
|
-
*/
|
|
185
|
-
export function infiniteQueryOptions(options: unknown) {
|
|
186
|
-
return options
|
|
187
|
-
}
|