@tanstack/angular-query 5.0.0-rc.4 → 5.0.0-rc.5
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/hydration-state-key.mjs +10 -13
- package/hydration-state-key.mjs.map +1 -1
- package/index.mjs +8 -20
- package/index.mjs.map +1 -1
- package/infinite-query-options.d.ts +7 -18
- package/infinite-query-options.mjs +6 -5
- package/infinite-query-options.mjs.map +1 -1
- package/inject-base-query.d.ts +3 -0
- package/inject-base-query.mjs +62 -58
- package/inject-base-query.mjs.map +1 -1
- package/inject-infinite-query.d.ts +7 -11
- package/inject-infinite-query.mjs +16 -32
- package/inject-infinite-query.mjs.map +1 -1
- package/inject-is-fetching.d.ts +1 -1
- package/inject-is-fetching.mjs +22 -15
- package/inject-is-fetching.mjs.map +1 -1
- package/inject-is-mutating.d.ts +1 -1
- package/inject-is-mutating.mjs +22 -15
- package/inject-is-mutating.mjs.map +1 -1
- package/inject-is-restoring.d.ts +2 -0
- package/inject-is-restoring.mjs +28 -17
- package/inject-is-restoring.mjs.map +1 -1
- package/inject-mutation-state.d.ts +9 -0
- package/inject-mutation-state.mjs +25 -23
- package/inject-mutation-state.mjs.map +1 -1
- package/inject-mutation.d.ts +2 -4
- package/inject-mutation.mjs +87 -67
- package/inject-mutation.mjs.map +1 -1
- package/inject-queries.d.ts +1 -3
- package/inject-queries.mjs +122 -114
- package/inject-queries.mjs.map +1 -1
- package/inject-queries.types.d.ts +15 -0
- package/inject-query.d.ts +7 -13
- package/inject-query.mjs +11 -14
- package/inject-query.mjs.map +1 -1
- package/internal.mjs +2 -7
- package/mutation-options.d.ts +2 -6
- package/mutation-options.mjs +6 -5
- package/mutation-options.mjs.map +1 -1
- package/package.json +2 -2
- package/providers.d.ts +16 -14
- package/providers.mjs +138 -75
- package/providers.mjs.map +1 -1
- package/query-options.d.ts +6 -16
- package/query-options.mjs +6 -5
- package/query-options.mjs.map +1 -1
- package/query-resource.d.ts +4 -3
- package/query-resource.mjs +72 -63
- package/query-resource.mjs.map +1 -1
- package/schematics/migrate-from-experimental/index.js +2 -2
- package/schematics/ng-add/index.js +1 -1
- package/types.d.ts +70 -10
- package/utils/inject-external-store.d.ts +3 -0
- package/utils/inject-external-store.mjs +54 -38
- package/utils/inject-external-store.mjs.map +1 -1
- package/utils/inject-pending-tasks-lifecycle.d.ts +13 -1
- package/utils/inject-pending-tasks-lifecycle.mjs +32 -29
- package/utils/inject-pending-tasks-lifecycle.mjs.map +1 -1
- package/utils/inject-query-zone.d.ts +4 -1
- package/utils/inject-query-zone.mjs +12 -7
- package/utils/inject-query-zone.mjs.map +1 -1
- package/utils/resource-types.d.ts +3 -0
- package/utils/result-fields.d.ts +9 -0
- package/utils/result-fields.mjs +55 -62
- package/utils/result-fields.mjs.map +1 -1
- package/utils/signal-proxy.d.ts +6 -0
- package/utils/signal-proxy.mjs +16 -9
- package/utils/signal-proxy.mjs.map +1 -1
- package/internal.mjs.map +0 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NgZone, inject } from "@angular/core";
|
|
2
|
+
//#region src/utils/inject-query-zone.ts
|
|
3
|
+
/**
|
|
4
|
+
* Keeps Query's background timers out of Angular's stability tracking.
|
|
5
|
+
* @returns A function that runs callbacks outside the injected NgZone.
|
|
6
|
+
*/
|
|
2
7
|
function injectQueryZone() {
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
const ngZone = inject(NgZone);
|
|
9
|
+
return (fn) => ngZone.runOutsideAngular(fn);
|
|
5
10
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=inject-query-zone.mjs.map
|
|
11
|
+
//#endregion
|
|
12
|
+
export { injectQueryZone };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=inject-query-zone.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-query-zone.mjs","sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n
|
|
1
|
+
{"version":3,"file":"inject-query-zone.mjs","names":[],"sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n/**\n * Keeps Query's background timers out of Angular's stability tracking.\n * @returns A function that runs callbacks outside the injected NgZone.\n */\nexport function injectQueryZone() {\n const ngZone = inject(NgZone)\n return <T>(fn: () => T): T => ngZone.runOutsideAngular(fn)\n}\n"],"mappings":";;;;;;AAMA,SAAgB,kBAAkB;CAChC,MAAM,SAAS,OAAO,MAAM;CAC5B,QAAW,OAAmB,OAAO,kBAAkB,EAAE;AAC3D"}
|
package/utils/result-fields.d.ts
CHANGED
|
@@ -72,9 +72,18 @@ declare const mutationFields: {
|
|
|
72
72
|
isSuccess: true;
|
|
73
73
|
};
|
|
74
74
|
export declare const queryResultFields: Array<keyof typeof queryFields>;
|
|
75
|
+
/**
|
|
76
|
+
* The query observer value fields exposed as Angular signals.
|
|
77
|
+
*/
|
|
75
78
|
export type QueryResultFields = (typeof queryResultFields)[number];
|
|
76
79
|
export declare const infiniteQueryResultFields: Array<keyof typeof infiniteQueryFields>;
|
|
80
|
+
/**
|
|
81
|
+
* The paginated query observer value fields exposed as Angular signals.
|
|
82
|
+
*/
|
|
77
83
|
export type InfiniteQueryResultFields = (typeof infiniteQueryResultFields)[number];
|
|
78
84
|
export declare const mutationResultFields: Array<keyof typeof mutationFields>;
|
|
85
|
+
/**
|
|
86
|
+
* The mutation observer value fields exposed as Angular signals.
|
|
87
|
+
*/
|
|
79
88
|
export type MutationResultFields = (typeof mutationResultFields)[number];
|
|
80
89
|
export {};
|
package/utils/result-fields.mjs
CHANGED
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
//#region src/utils/result-fields.ts
|
|
2
|
+
var queryFields = {
|
|
3
|
+
data: true,
|
|
4
|
+
dataUpdatedAt: true,
|
|
5
|
+
error: true,
|
|
6
|
+
errorUpdatedAt: true,
|
|
7
|
+
failureCount: true,
|
|
8
|
+
failureReason: true,
|
|
9
|
+
errorUpdateCount: true,
|
|
10
|
+
isError: true,
|
|
11
|
+
isFetched: true,
|
|
12
|
+
isFetchedAfterMount: true,
|
|
13
|
+
isFetching: true,
|
|
14
|
+
isLoading: true,
|
|
15
|
+
isPending: true,
|
|
16
|
+
isLoadingError: true,
|
|
17
|
+
isInitialLoading: true,
|
|
18
|
+
isPaused: true,
|
|
19
|
+
isPlaceholderData: true,
|
|
20
|
+
isRefetchError: true,
|
|
21
|
+
isRefetching: true,
|
|
22
|
+
isStale: true,
|
|
23
|
+
isSuccess: true,
|
|
24
|
+
isEnabled: true,
|
|
25
|
+
status: true,
|
|
26
|
+
fetchStatus: true
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
var infiniteQueryFields = {
|
|
29
|
+
...queryFields,
|
|
30
|
+
hasNextPage: true,
|
|
31
|
+
hasPreviousPage: true,
|
|
32
|
+
isFetchNextPageError: true,
|
|
33
|
+
isFetchingNextPage: true,
|
|
34
|
+
isFetchPreviousPageError: true,
|
|
35
|
+
isFetchingPreviousPage: true
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
var mutationFields = {
|
|
38
|
+
context: true,
|
|
39
|
+
data: true,
|
|
40
|
+
error: true,
|
|
41
|
+
failureCount: true,
|
|
42
|
+
failureReason: true,
|
|
43
|
+
isPaused: true,
|
|
44
|
+
status: true,
|
|
45
|
+
variables: true,
|
|
46
|
+
submittedAt: true,
|
|
47
|
+
isError: true,
|
|
48
|
+
isIdle: true,
|
|
49
|
+
isPending: true,
|
|
50
|
+
isSuccess: true
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
mutationFields
|
|
59
|
-
);
|
|
60
|
-
export {
|
|
61
|
-
infiniteQueryResultFields,
|
|
62
|
-
mutationResultFields,
|
|
63
|
-
queryResultFields
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=result-fields.mjs.map
|
|
52
|
+
var queryResultFields = /* #__PURE__ */ Object.keys(queryFields);
|
|
53
|
+
var infiniteQueryResultFields = /* #__PURE__ */ Object.keys(infiniteQueryFields);
|
|
54
|
+
var mutationResultFields = /* #__PURE__ */ Object.keys(mutationFields);
|
|
55
|
+
//#endregion
|
|
56
|
+
export { infiniteQueryResultFields, mutationResultFields, queryResultFields };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=result-fields.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-fields.mjs","sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /*
|
|
1
|
+
{"version":3,"file":"result-fields.mjs","names":[],"sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /* #__PURE__ */ Object.keys(\n queryFields,\n) as Array<keyof typeof queryFields>\n/**\n * The query observer value fields exposed as Angular signals.\n */\nexport type QueryResultFields = (typeof queryResultFields)[number]\n\nexport const infiniteQueryResultFields = /* #__PURE__ */ Object.keys(\n infiniteQueryFields,\n) as Array<keyof typeof infiniteQueryFields>\n/**\n * The paginated query observer value fields exposed as Angular signals.\n */\nexport type InfiniteQueryResultFields =\n (typeof infiniteQueryResultFields)[number]\n\nexport const mutationResultFields = /* #__PURE__ */ Object.keys(\n mutationFields,\n) as Array<keyof typeof mutationFields>\n/**\n * The mutation observer value fields exposed as Angular signals.\n */\nexport type MutationResultFields = (typeof mutationResultFields)[number]\n"],"mappings":";AAUA,IAAM,cAAc;CAClB,MAAM;CACN,eAAe;CACf,OAAO;CACP,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,WAAW;CACX,qBAAqB;CACrB,YAAY;CACZ,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,kBAAkB;CAClB,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,cAAc;CACd,SAAS;CACT,WAAW;CACX,WAAW;CACX,QAAQ;CACR,aAAa;AACf;AAEA,IAAM,sBAAsB;CAC1B,GAAG;CACH,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,oBAAoB;CACpB,0BAA0B;CAC1B,wBAAwB;AAC1B;AAEA,IAAM,iBAAiB;CACrB,SAAS;CACT,MAAM;CACN,OAAO;CACP,cAAc;CACd,eAAe;CACf,UAAU;CACV,QAAQ;CACR,WAAW;CACX,aAAa;CACb,SAAS;CACT,QAAQ;CACR,WAAW;CACX,WAAW;AACb;AAEA,IAAa,oBAAoC,uBAAO,KACtD,WACF;AAMA,IAAa,4BAA4C,uBAAO,KAC9D,mBACF;AAOA,IAAa,uBAAuC,uBAAO,KACzD,cACF"}
|
package/utils/signal-proxy.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Signal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Names of object properties whose values are callable.
|
|
4
|
+
*/
|
|
2
5
|
export type MethodKeys<T> = {
|
|
3
6
|
[K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never;
|
|
4
7
|
}[keyof T];
|
|
8
|
+
/**
|
|
9
|
+
* Exposes selected object fields as Angular signals and leaves all other fields unchanged.
|
|
10
|
+
*/
|
|
5
11
|
export type MapToSignals<T, TSignalFields extends keyof any = never> = {
|
|
6
12
|
[K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>;
|
|
7
13
|
} & {
|
package/utils/signal-proxy.mjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { computed } from "@angular/core";
|
|
2
|
+
//#region src/utils/signal-proxy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Maps known result fields to lazy computed signals on an ordinary object.
|
|
5
|
+
* Creating or enumerating the fields never evaluates the source. Imperative
|
|
6
|
+
* methods are defined by each adapter, outside this mapping.
|
|
7
|
+
* @param inputSignal - The source snapshot.
|
|
8
|
+
* @param fields - The fields exposed as signals.
|
|
9
|
+
* @returns An object containing one stable signal per field.
|
|
10
|
+
*/
|
|
2
11
|
function signalProxy(inputSignal, fields) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
return result;
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const field of fields) result[field] = computed(() => inputSignal()[field]);
|
|
14
|
+
return result;
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=signal-proxy.mjs.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { signalProxy };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=signal-proxy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal-proxy.mjs","sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"
|
|
1
|
+
{"version":3,"file":"signal-proxy.mjs","names":[],"sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\n/**\n * Names of object properties whose values are callable.\n */\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\n/**\n * Exposes selected object fields as Angular signals and leaves all other fields unchanged.\n */\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,YACd,aACA,QACiC;CACjC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,SAAS,QAClB,OAAO,SAAS,eAAe,YAAY,CAAC,CAAC,MAAM;CAErD,OAAO;AACT"}
|
package/internal.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|