@tanstack/angular-db 0.1.36 → 0.1.38
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/cjs/index.cjs +18 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +11 -3
- package/dist/esm/index.d.ts +11 -3
- package/dist/esm/index.js +19 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +21 -21
- package/src/index.ts +55 -14
package/dist/cjs/index.cjs
CHANGED
|
@@ -11,6 +11,11 @@ function injectLiveQuery(opts) {
|
|
|
11
11
|
return opts;
|
|
12
12
|
}
|
|
13
13
|
if (typeof opts === `function`) {
|
|
14
|
+
const queryBuilder = new db.BaseQueryBuilder();
|
|
15
|
+
const result = opts(queryBuilder);
|
|
16
|
+
if (result === void 0 || result === null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
14
19
|
return db.createLiveQueryCollection({
|
|
15
20
|
query: opts,
|
|
16
21
|
startSync: true,
|
|
@@ -21,6 +26,11 @@ function injectLiveQuery(opts) {
|
|
|
21
26
|
if (isReactiveQueryOptions) {
|
|
22
27
|
const { params, query } = opts;
|
|
23
28
|
const currentParams = params();
|
|
29
|
+
const queryBuilder = new db.BaseQueryBuilder();
|
|
30
|
+
const result = query({ params: currentParams, q: queryBuilder });
|
|
31
|
+
if (result === void 0 || result === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
24
34
|
return db.createLiveQueryCollection({
|
|
25
35
|
query: (q) => query({ params: currentParams, q }),
|
|
26
36
|
startSync: true,
|
|
@@ -34,7 +44,9 @@ function injectLiveQuery(opts) {
|
|
|
34
44
|
});
|
|
35
45
|
const state = core.signal(/* @__PURE__ */ new Map());
|
|
36
46
|
const data = core.signal([]);
|
|
37
|
-
const status = core.signal(
|
|
47
|
+
const status = core.signal(
|
|
48
|
+
collection() ? `idle` : `disabled`
|
|
49
|
+
);
|
|
38
50
|
const syncDataFromCollection = (currentCollection) => {
|
|
39
51
|
const newState = new Map(currentCollection.entries());
|
|
40
52
|
const newData = Array.from(currentCollection.values());
|
|
@@ -50,6 +62,10 @@ function injectLiveQuery(opts) {
|
|
|
50
62
|
core.effect((onCleanup) => {
|
|
51
63
|
const currentCollection = collection();
|
|
52
64
|
if (!currentCollection) {
|
|
65
|
+
status.set(`disabled`);
|
|
66
|
+
state.set(/* @__PURE__ */ new Map());
|
|
67
|
+
data.set([]);
|
|
68
|
+
cleanup();
|
|
53
69
|
return;
|
|
54
70
|
}
|
|
55
71
|
cleanup();
|
|
@@ -76,7 +92,7 @@ function injectLiveQuery(opts) {
|
|
|
76
92
|
collection,
|
|
77
93
|
status,
|
|
78
94
|
isLoading: core.computed(() => status() === `loading`),
|
|
79
|
-
isReady: core.computed(() => status() === `ready`),
|
|
95
|
+
isReady: core.computed(() => status() === `ready` || status() === `disabled`),
|
|
80
96
|
isIdle: core.computed(() => status() === `idle`),
|
|
81
97
|
isError: core.computed(() => status() === `error`),
|
|
82
98
|
isCleanedUp: core.computed(() => status() === `cleaned-up`)
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { BaseQueryBuilder, createLiveQueryCollection } from '@tanstack/db'\nimport type {\n ChangeMessage,\n Collection,\n CollectionStatus,\n Context,\n GetResult,\n InitialQueryBuilder,\n LiveQueryCollectionConfig,\n QueryBuilder,\n} from '@tanstack/db'\nimport type { Signal } from '@angular/core'\n\n/**\n * The result of calling `injectLiveQuery`.\n * Contains reactive signals for the query state and data.\n */\nexport interface InjectLiveQueryResult<\n TResult extends object = any,\n TKey extends string | number = string | number,\n TUtils extends Record<string, any> = {},\n> {\n /** A signal containing the complete state map of results keyed by their ID */\n state: Signal<Map<TKey, TResult>>\n /** A signal containing the results as an array */\n data: Signal<Array<TResult>>\n /** A signal containing the underlying collection instance (null for disabled queries) */\n collection: Signal<Collection<TResult, TKey, TUtils> | null>\n /** A signal containing the current status of the collection */\n status: Signal<CollectionStatus | `disabled`>\n /** A signal indicating whether the collection is currently loading */\n isLoading: Signal<boolean>\n /** A signal indicating whether the collection is ready */\n isReady: Signal<boolean>\n /** A signal indicating whether the collection is idle */\n isIdle: Signal<boolean>\n /** A signal indicating whether the collection has an error */\n isError: Signal<boolean>\n /** A signal indicating whether the collection has been cleaned up */\n isCleanedUp: Signal<boolean>\n}\n\nexport function injectLiveQuery<\n TContext extends Context,\n TParams extends any,\n>(options: {\n params: () => TParams\n query: (args: {\n params: TParams\n q: InitialQueryBuilder\n }) => QueryBuilder<TContext>\n}): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<\n TContext extends Context,\n TParams extends any,\n>(options: {\n params: () => TParams\n query: (args: {\n params: TParams\n q: InitialQueryBuilder\n }) => QueryBuilder<TContext> | undefined | null\n}): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n queryFn: (\n q: InitialQueryBuilder,\n ) => QueryBuilder<TContext> | undefined | null,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n config: LiveQueryCollectionConfig<TContext>,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<\n TResult extends object,\n TKey extends string | number,\n TUtils extends Record<string, any>,\n>(\n liveQueryCollection: Collection<TResult, TKey, TUtils>,\n): InjectLiveQueryResult<TResult, TKey, TUtils>\nexport function injectLiveQuery(opts: any) {\n assertInInjectionContext(injectLiveQuery)\n const destroyRef = inject(DestroyRef)\n\n const collection = computed(() => {\n // Check if it's an existing collection\n const isExistingCollection =\n opts &&\n typeof opts === `object` &&\n typeof opts.subscribeChanges === `function` &&\n typeof opts.startSyncImmediate === `function` &&\n typeof opts.id === `string`\n\n if (isExistingCollection) {\n return opts\n }\n\n if (typeof opts === `function`) {\n // Check if query function returns null/undefined (disabled query)\n const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder\n const result = opts(queryBuilder)\n\n if (result === undefined || result === null) {\n // Disabled query - return null\n return null\n }\n\n return createLiveQueryCollection({\n query: opts,\n startSync: true,\n gcTime: 0,\n })\n }\n\n // Check if it's reactive query options\n const isReactiveQueryOptions =\n opts &&\n typeof opts === `object` &&\n typeof opts.query === `function` &&\n typeof opts.params === `function`\n\n if (isReactiveQueryOptions) {\n const { params, query } = opts\n const currentParams = params()\n\n // Check if query function returns null/undefined (disabled query)\n const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder\n const result = query({ params: currentParams, q: queryBuilder })\n\n if (result === undefined || result === null) {\n // Disabled query - return null\n return null\n }\n\n return createLiveQueryCollection({\n query: (q) => query({ params: currentParams, q }),\n startSync: true,\n gcTime: 0,\n })\n }\n\n // Handle LiveQueryCollectionConfig objects\n if (opts && typeof opts === `object` && typeof opts.query === `function`) {\n return createLiveQueryCollection(opts)\n }\n\n throw new Error(`Invalid options provided to injectLiveQuery`)\n })\n\n const state = signal(new Map<string | number, any>())\n const data = signal<Array<any>>([])\n const status = signal<CollectionStatus | `disabled`>(\n collection() ? `idle` : `disabled`,\n )\n\n const syncDataFromCollection = (\n currentCollection: Collection<any, any, any>,\n ) => {\n const newState = new Map(currentCollection.entries())\n const newData = Array.from(currentCollection.values())\n\n state.set(newState)\n data.set(newData)\n status.set(currentCollection.status)\n }\n\n let unsub: (() => void) | null = null\n const cleanup = () => {\n unsub?.()\n unsub = null\n }\n\n effect((onCleanup) => {\n const currentCollection = collection()\n\n // Handle null collection (disabled query)\n if (!currentCollection) {\n status.set(`disabled` as const)\n state.set(new Map())\n data.set([])\n cleanup()\n return\n }\n\n cleanup()\n\n // Initialize immediately with current state\n syncDataFromCollection(currentCollection)\n\n // Start sync if idle\n if (currentCollection.status === `idle`) {\n currentCollection.startSyncImmediate()\n // Update status after starting sync\n status.set(currentCollection.status)\n }\n\n // Subscribe to changes\n const subscription = currentCollection.subscribeChanges(\n (_: Array<ChangeMessage<any>>) => {\n syncDataFromCollection(currentCollection)\n },\n )\n unsub = subscription.unsubscribe.bind(subscription)\n\n // Handle ready state\n currentCollection.onFirstReady(() => {\n status.set(currentCollection.status)\n })\n\n onCleanup(cleanup)\n })\n\n destroyRef.onDestroy(cleanup)\n\n return {\n state,\n data,\n collection,\n status,\n isLoading: computed(() => status() === `loading`),\n isReady: computed(() => status() === `ready` || status() === `disabled`),\n isIdle: computed(() => status() === `idle`),\n isError: computed(() => status() === `error`),\n isCleanedUp: computed(() => status() === `cleaned-up`),\n }\n}\n"],"names":["assertInInjectionContext","inject","DestroyRef","computed","BaseQueryBuilder","createLiveQueryCollection","signal","effect"],"mappings":"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"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -9,10 +9,10 @@ export interface InjectLiveQueryResult<TResult extends object = any, TKey extend
|
|
|
9
9
|
state: Signal<Map<TKey, TResult>>;
|
|
10
10
|
/** A signal containing the results as an array */
|
|
11
11
|
data: Signal<Array<TResult>>;
|
|
12
|
-
/** A signal containing the underlying collection instance */
|
|
13
|
-
collection: Signal<Collection<TResult, TKey, TUtils
|
|
12
|
+
/** A signal containing the underlying collection instance (null for disabled queries) */
|
|
13
|
+
collection: Signal<Collection<TResult, TKey, TUtils> | null>;
|
|
14
14
|
/** A signal containing the current status of the collection */
|
|
15
|
-
status: Signal<CollectionStatus
|
|
15
|
+
status: Signal<CollectionStatus | `disabled`>;
|
|
16
16
|
/** A signal indicating whether the collection is currently loading */
|
|
17
17
|
isLoading: Signal<boolean>;
|
|
18
18
|
/** A signal indicating whether the collection is ready */
|
|
@@ -31,6 +31,14 @@ export declare function injectLiveQuery<TContext extends Context, TParams extend
|
|
|
31
31
|
q: InitialQueryBuilder;
|
|
32
32
|
}) => QueryBuilder<TContext>;
|
|
33
33
|
}): InjectLiveQueryResult<GetResult<TContext>>;
|
|
34
|
+
export declare function injectLiveQuery<TContext extends Context, TParams extends any>(options: {
|
|
35
|
+
params: () => TParams;
|
|
36
|
+
query: (args: {
|
|
37
|
+
params: TParams;
|
|
38
|
+
q: InitialQueryBuilder;
|
|
39
|
+
}) => QueryBuilder<TContext> | undefined | null;
|
|
40
|
+
}): InjectLiveQueryResult<GetResult<TContext>>;
|
|
34
41
|
export declare function injectLiveQuery<TContext extends Context>(queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>): InjectLiveQueryResult<GetResult<TContext>>;
|
|
42
|
+
export declare function injectLiveQuery<TContext extends Context>(queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext> | undefined | null): InjectLiveQueryResult<GetResult<TContext>>;
|
|
35
43
|
export declare function injectLiveQuery<TContext extends Context>(config: LiveQueryCollectionConfig<TContext>): InjectLiveQueryResult<GetResult<TContext>>;
|
|
36
44
|
export declare function injectLiveQuery<TResult extends object, TKey extends string | number, TUtils extends Record<string, any>>(liveQueryCollection: Collection<TResult, TKey, TUtils>): InjectLiveQueryResult<TResult, TKey, TUtils>;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export interface InjectLiveQueryResult<TResult extends object = any, TKey extend
|
|
|
9
9
|
state: Signal<Map<TKey, TResult>>;
|
|
10
10
|
/** A signal containing the results as an array */
|
|
11
11
|
data: Signal<Array<TResult>>;
|
|
12
|
-
/** A signal containing the underlying collection instance */
|
|
13
|
-
collection: Signal<Collection<TResult, TKey, TUtils
|
|
12
|
+
/** A signal containing the underlying collection instance (null for disabled queries) */
|
|
13
|
+
collection: Signal<Collection<TResult, TKey, TUtils> | null>;
|
|
14
14
|
/** A signal containing the current status of the collection */
|
|
15
|
-
status: Signal<CollectionStatus
|
|
15
|
+
status: Signal<CollectionStatus | `disabled`>;
|
|
16
16
|
/** A signal indicating whether the collection is currently loading */
|
|
17
17
|
isLoading: Signal<boolean>;
|
|
18
18
|
/** A signal indicating whether the collection is ready */
|
|
@@ -31,6 +31,14 @@ export declare function injectLiveQuery<TContext extends Context, TParams extend
|
|
|
31
31
|
q: InitialQueryBuilder;
|
|
32
32
|
}) => QueryBuilder<TContext>;
|
|
33
33
|
}): InjectLiveQueryResult<GetResult<TContext>>;
|
|
34
|
+
export declare function injectLiveQuery<TContext extends Context, TParams extends any>(options: {
|
|
35
|
+
params: () => TParams;
|
|
36
|
+
query: (args: {
|
|
37
|
+
params: TParams;
|
|
38
|
+
q: InitialQueryBuilder;
|
|
39
|
+
}) => QueryBuilder<TContext> | undefined | null;
|
|
40
|
+
}): InjectLiveQueryResult<GetResult<TContext>>;
|
|
34
41
|
export declare function injectLiveQuery<TContext extends Context>(queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>): InjectLiveQueryResult<GetResult<TContext>>;
|
|
42
|
+
export declare function injectLiveQuery<TContext extends Context>(queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext> | undefined | null): InjectLiveQueryResult<GetResult<TContext>>;
|
|
35
43
|
export declare function injectLiveQuery<TContext extends Context>(config: LiveQueryCollectionConfig<TContext>): InjectLiveQueryResult<GetResult<TContext>>;
|
|
36
44
|
export declare function injectLiveQuery<TResult extends object, TKey extends string | number, TUtils extends Record<string, any>>(liveQueryCollection: Collection<TResult, TKey, TUtils>): InjectLiveQueryResult<TResult, TKey, TUtils>;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertInInjectionContext, inject, DestroyRef, computed, signal, effect } from "@angular/core";
|
|
2
|
-
import { createLiveQueryCollection } from "@tanstack/db";
|
|
2
|
+
import { BaseQueryBuilder, createLiveQueryCollection } from "@tanstack/db";
|
|
3
3
|
function injectLiveQuery(opts) {
|
|
4
4
|
assertInInjectionContext(injectLiveQuery);
|
|
5
5
|
const destroyRef = inject(DestroyRef);
|
|
@@ -9,6 +9,11 @@ function injectLiveQuery(opts) {
|
|
|
9
9
|
return opts;
|
|
10
10
|
}
|
|
11
11
|
if (typeof opts === `function`) {
|
|
12
|
+
const queryBuilder = new BaseQueryBuilder();
|
|
13
|
+
const result = opts(queryBuilder);
|
|
14
|
+
if (result === void 0 || result === null) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
12
17
|
return createLiveQueryCollection({
|
|
13
18
|
query: opts,
|
|
14
19
|
startSync: true,
|
|
@@ -19,6 +24,11 @@ function injectLiveQuery(opts) {
|
|
|
19
24
|
if (isReactiveQueryOptions) {
|
|
20
25
|
const { params, query } = opts;
|
|
21
26
|
const currentParams = params();
|
|
27
|
+
const queryBuilder = new BaseQueryBuilder();
|
|
28
|
+
const result = query({ params: currentParams, q: queryBuilder });
|
|
29
|
+
if (result === void 0 || result === null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
22
32
|
return createLiveQueryCollection({
|
|
23
33
|
query: (q) => query({ params: currentParams, q }),
|
|
24
34
|
startSync: true,
|
|
@@ -32,7 +42,9 @@ function injectLiveQuery(opts) {
|
|
|
32
42
|
});
|
|
33
43
|
const state = signal(/* @__PURE__ */ new Map());
|
|
34
44
|
const data = signal([]);
|
|
35
|
-
const status = signal(
|
|
45
|
+
const status = signal(
|
|
46
|
+
collection() ? `idle` : `disabled`
|
|
47
|
+
);
|
|
36
48
|
const syncDataFromCollection = (currentCollection) => {
|
|
37
49
|
const newState = new Map(currentCollection.entries());
|
|
38
50
|
const newData = Array.from(currentCollection.values());
|
|
@@ -48,6 +60,10 @@ function injectLiveQuery(opts) {
|
|
|
48
60
|
effect((onCleanup) => {
|
|
49
61
|
const currentCollection = collection();
|
|
50
62
|
if (!currentCollection) {
|
|
63
|
+
status.set(`disabled`);
|
|
64
|
+
state.set(/* @__PURE__ */ new Map());
|
|
65
|
+
data.set([]);
|
|
66
|
+
cleanup();
|
|
51
67
|
return;
|
|
52
68
|
}
|
|
53
69
|
cleanup();
|
|
@@ -74,7 +90,7 @@ function injectLiveQuery(opts) {
|
|
|
74
90
|
collection,
|
|
75
91
|
status,
|
|
76
92
|
isLoading: computed(() => status() === `loading`),
|
|
77
|
-
isReady: computed(() => status() === `ready`),
|
|
93
|
+
isReady: computed(() => status() === `ready` || status() === `disabled`),
|
|
78
94
|
isIdle: computed(() => status() === `idle`),
|
|
79
95
|
isError: computed(() => status() === `error`),
|
|
80
96
|
isCleanedUp: computed(() => status() === `cleaned-up`)
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { BaseQueryBuilder, createLiveQueryCollection } from '@tanstack/db'\nimport type {\n ChangeMessage,\n Collection,\n CollectionStatus,\n Context,\n GetResult,\n InitialQueryBuilder,\n LiveQueryCollectionConfig,\n QueryBuilder,\n} from '@tanstack/db'\nimport type { Signal } from '@angular/core'\n\n/**\n * The result of calling `injectLiveQuery`.\n * Contains reactive signals for the query state and data.\n */\nexport interface InjectLiveQueryResult<\n TResult extends object = any,\n TKey extends string | number = string | number,\n TUtils extends Record<string, any> = {},\n> {\n /** A signal containing the complete state map of results keyed by their ID */\n state: Signal<Map<TKey, TResult>>\n /** A signal containing the results as an array */\n data: Signal<Array<TResult>>\n /** A signal containing the underlying collection instance (null for disabled queries) */\n collection: Signal<Collection<TResult, TKey, TUtils> | null>\n /** A signal containing the current status of the collection */\n status: Signal<CollectionStatus | `disabled`>\n /** A signal indicating whether the collection is currently loading */\n isLoading: Signal<boolean>\n /** A signal indicating whether the collection is ready */\n isReady: Signal<boolean>\n /** A signal indicating whether the collection is idle */\n isIdle: Signal<boolean>\n /** A signal indicating whether the collection has an error */\n isError: Signal<boolean>\n /** A signal indicating whether the collection has been cleaned up */\n isCleanedUp: Signal<boolean>\n}\n\nexport function injectLiveQuery<\n TContext extends Context,\n TParams extends any,\n>(options: {\n params: () => TParams\n query: (args: {\n params: TParams\n q: InitialQueryBuilder\n }) => QueryBuilder<TContext>\n}): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<\n TContext extends Context,\n TParams extends any,\n>(options: {\n params: () => TParams\n query: (args: {\n params: TParams\n q: InitialQueryBuilder\n }) => QueryBuilder<TContext> | undefined | null\n}): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n queryFn: (\n q: InitialQueryBuilder,\n ) => QueryBuilder<TContext> | undefined | null,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<TContext extends Context>(\n config: LiveQueryCollectionConfig<TContext>,\n): InjectLiveQueryResult<GetResult<TContext>>\nexport function injectLiveQuery<\n TResult extends object,\n TKey extends string | number,\n TUtils extends Record<string, any>,\n>(\n liveQueryCollection: Collection<TResult, TKey, TUtils>,\n): InjectLiveQueryResult<TResult, TKey, TUtils>\nexport function injectLiveQuery(opts: any) {\n assertInInjectionContext(injectLiveQuery)\n const destroyRef = inject(DestroyRef)\n\n const collection = computed(() => {\n // Check if it's an existing collection\n const isExistingCollection =\n opts &&\n typeof opts === `object` &&\n typeof opts.subscribeChanges === `function` &&\n typeof opts.startSyncImmediate === `function` &&\n typeof opts.id === `string`\n\n if (isExistingCollection) {\n return opts\n }\n\n if (typeof opts === `function`) {\n // Check if query function returns null/undefined (disabled query)\n const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder\n const result = opts(queryBuilder)\n\n if (result === undefined || result === null) {\n // Disabled query - return null\n return null\n }\n\n return createLiveQueryCollection({\n query: opts,\n startSync: true,\n gcTime: 0,\n })\n }\n\n // Check if it's reactive query options\n const isReactiveQueryOptions =\n opts &&\n typeof opts === `object` &&\n typeof opts.query === `function` &&\n typeof opts.params === `function`\n\n if (isReactiveQueryOptions) {\n const { params, query } = opts\n const currentParams = params()\n\n // Check if query function returns null/undefined (disabled query)\n const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder\n const result = query({ params: currentParams, q: queryBuilder })\n\n if (result === undefined || result === null) {\n // Disabled query - return null\n return null\n }\n\n return createLiveQueryCollection({\n query: (q) => query({ params: currentParams, q }),\n startSync: true,\n gcTime: 0,\n })\n }\n\n // Handle LiveQueryCollectionConfig objects\n if (opts && typeof opts === `object` && typeof opts.query === `function`) {\n return createLiveQueryCollection(opts)\n }\n\n throw new Error(`Invalid options provided to injectLiveQuery`)\n })\n\n const state = signal(new Map<string | number, any>())\n const data = signal<Array<any>>([])\n const status = signal<CollectionStatus | `disabled`>(\n collection() ? `idle` : `disabled`,\n )\n\n const syncDataFromCollection = (\n currentCollection: Collection<any, any, any>,\n ) => {\n const newState = new Map(currentCollection.entries())\n const newData = Array.from(currentCollection.values())\n\n state.set(newState)\n data.set(newData)\n status.set(currentCollection.status)\n }\n\n let unsub: (() => void) | null = null\n const cleanup = () => {\n unsub?.()\n unsub = null\n }\n\n effect((onCleanup) => {\n const currentCollection = collection()\n\n // Handle null collection (disabled query)\n if (!currentCollection) {\n status.set(`disabled` as const)\n state.set(new Map())\n data.set([])\n cleanup()\n return\n }\n\n cleanup()\n\n // Initialize immediately with current state\n syncDataFromCollection(currentCollection)\n\n // Start sync if idle\n if (currentCollection.status === `idle`) {\n currentCollection.startSyncImmediate()\n // Update status after starting sync\n status.set(currentCollection.status)\n }\n\n // Subscribe to changes\n const subscription = currentCollection.subscribeChanges(\n (_: Array<ChangeMessage<any>>) => {\n syncDataFromCollection(currentCollection)\n },\n )\n unsub = subscription.unsubscribe.bind(subscription)\n\n // Handle ready state\n currentCollection.onFirstReady(() => {\n status.set(currentCollection.status)\n })\n\n onCleanup(cleanup)\n })\n\n destroyRef.onDestroy(cleanup)\n\n return {\n state,\n data,\n collection,\n status,\n isLoading: computed(() => status() === `loading`),\n isReady: computed(() => status() === `ready` || status() === `disabled`),\n isIdle: computed(() => status() === `idle`),\n isError: computed(() => status() === `error`),\n isCleanedUp: computed(() => status() === `cleaned-up`),\n }\n}\n"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-db",
|
|
3
|
+
"version": "0.1.38",
|
|
3
4
|
"description": "Angular integration for @tanstack/db",
|
|
4
|
-
"version": "0.1.36",
|
|
5
5
|
"author": "Ethan McDaniel",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/TanStack/db.git",
|
|
9
|
+
"url": "git+https://github.com/TanStack/db.git",
|
|
10
10
|
"directory": "packages/angular-db"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://tanstack.com/db",
|
|
@@ -15,19 +15,10 @@
|
|
|
15
15
|
"angular",
|
|
16
16
|
"typescript"
|
|
17
17
|
],
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"@angular/common": "^19.2.15",
|
|
23
|
-
"@angular/compiler": "^20.0.0",
|
|
24
|
-
"@angular/core": "^19.2.16",
|
|
25
|
-
"@angular/platform-browser": "^19.2.16",
|
|
26
|
-
"@angular/platform-browser-dynamic": "^19.2.16",
|
|
27
|
-
"@vitest/coverage-istanbul": "^3.2.4",
|
|
28
|
-
"rxjs": "^7.8.2",
|
|
29
|
-
"zone.js": "^0.16.0"
|
|
30
|
-
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/cjs/index.cjs",
|
|
20
|
+
"module": "dist/esm/index.js",
|
|
21
|
+
"types": "dist/esm/index.d.ts",
|
|
31
22
|
"exports": {
|
|
32
23
|
".": {
|
|
33
24
|
"import": {
|
|
@@ -41,23 +32,32 @@
|
|
|
41
32
|
},
|
|
42
33
|
"./package.json": "./package.json"
|
|
43
34
|
},
|
|
35
|
+
"sideEffects": false,
|
|
44
36
|
"files": [
|
|
45
37
|
"dist",
|
|
46
38
|
"src"
|
|
47
39
|
],
|
|
48
|
-
"
|
|
49
|
-
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@tanstack/db": "0.5.12"
|
|
42
|
+
},
|
|
50
43
|
"peerDependencies": {
|
|
51
44
|
"@angular/core": ">=16.0.0",
|
|
52
45
|
"rxjs": ">=6.0.0"
|
|
53
46
|
},
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@angular/common": "^19.2.17",
|
|
49
|
+
"@angular/compiler": "^20.3.15",
|
|
50
|
+
"@angular/core": "^19.2.17",
|
|
51
|
+
"@angular/platform-browser": "^19.2.17",
|
|
52
|
+
"@angular/platform-browser-dynamic": "^19.2.17",
|
|
53
|
+
"@vitest/coverage-istanbul": "^3.2.4",
|
|
54
|
+
"rxjs": "^7.8.2",
|
|
55
|
+
"zone.js": "^0.16.0"
|
|
56
|
+
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "vite build",
|
|
59
59
|
"dev": "vite build --watch",
|
|
60
|
-
"test": "
|
|
60
|
+
"test": "vitest --run",
|
|
61
61
|
"lint": "eslint . --fix"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
effect,
|
|
6
6
|
inject,
|
|
7
7
|
signal,
|
|
8
|
-
} from
|
|
9
|
-
import { createLiveQueryCollection } from
|
|
8
|
+
} from '@angular/core'
|
|
9
|
+
import { BaseQueryBuilder, createLiveQueryCollection } from '@tanstack/db'
|
|
10
10
|
import type {
|
|
11
11
|
ChangeMessage,
|
|
12
12
|
Collection,
|
|
@@ -16,8 +16,8 @@ import type {
|
|
|
16
16
|
InitialQueryBuilder,
|
|
17
17
|
LiveQueryCollectionConfig,
|
|
18
18
|
QueryBuilder,
|
|
19
|
-
} from
|
|
20
|
-
import type { Signal } from
|
|
19
|
+
} from '@tanstack/db'
|
|
20
|
+
import type { Signal } from '@angular/core'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* The result of calling `injectLiveQuery`.
|
|
@@ -32,10 +32,10 @@ export interface InjectLiveQueryResult<
|
|
|
32
32
|
state: Signal<Map<TKey, TResult>>
|
|
33
33
|
/** A signal containing the results as an array */
|
|
34
34
|
data: Signal<Array<TResult>>
|
|
35
|
-
/** A signal containing the underlying collection instance */
|
|
36
|
-
collection: Signal<Collection<TResult, TKey, TUtils
|
|
35
|
+
/** A signal containing the underlying collection instance (null for disabled queries) */
|
|
36
|
+
collection: Signal<Collection<TResult, TKey, TUtils> | null>
|
|
37
37
|
/** A signal containing the current status of the collection */
|
|
38
|
-
status: Signal<CollectionStatus
|
|
38
|
+
status: Signal<CollectionStatus | `disabled`>
|
|
39
39
|
/** A signal indicating whether the collection is currently loading */
|
|
40
40
|
isLoading: Signal<boolean>
|
|
41
41
|
/** A signal indicating whether the collection is ready */
|
|
@@ -58,18 +58,33 @@ export function injectLiveQuery<
|
|
|
58
58
|
q: InitialQueryBuilder
|
|
59
59
|
}) => QueryBuilder<TContext>
|
|
60
60
|
}): InjectLiveQueryResult<GetResult<TContext>>
|
|
61
|
+
export function injectLiveQuery<
|
|
62
|
+
TContext extends Context,
|
|
63
|
+
TParams extends any,
|
|
64
|
+
>(options: {
|
|
65
|
+
params: () => TParams
|
|
66
|
+
query: (args: {
|
|
67
|
+
params: TParams
|
|
68
|
+
q: InitialQueryBuilder
|
|
69
|
+
}) => QueryBuilder<TContext> | undefined | null
|
|
70
|
+
}): InjectLiveQueryResult<GetResult<TContext>>
|
|
61
71
|
export function injectLiveQuery<TContext extends Context>(
|
|
62
|
-
queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext
|
|
72
|
+
queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>,
|
|
63
73
|
): InjectLiveQueryResult<GetResult<TContext>>
|
|
64
74
|
export function injectLiveQuery<TContext extends Context>(
|
|
65
|
-
|
|
75
|
+
queryFn: (
|
|
76
|
+
q: InitialQueryBuilder,
|
|
77
|
+
) => QueryBuilder<TContext> | undefined | null,
|
|
78
|
+
): InjectLiveQueryResult<GetResult<TContext>>
|
|
79
|
+
export function injectLiveQuery<TContext extends Context>(
|
|
80
|
+
config: LiveQueryCollectionConfig<TContext>,
|
|
66
81
|
): InjectLiveQueryResult<GetResult<TContext>>
|
|
67
82
|
export function injectLiveQuery<
|
|
68
83
|
TResult extends object,
|
|
69
84
|
TKey extends string | number,
|
|
70
85
|
TUtils extends Record<string, any>,
|
|
71
86
|
>(
|
|
72
|
-
liveQueryCollection: Collection<TResult, TKey, TUtils
|
|
87
|
+
liveQueryCollection: Collection<TResult, TKey, TUtils>,
|
|
73
88
|
): InjectLiveQueryResult<TResult, TKey, TUtils>
|
|
74
89
|
export function injectLiveQuery(opts: any) {
|
|
75
90
|
assertInInjectionContext(injectLiveQuery)
|
|
@@ -89,6 +104,15 @@ export function injectLiveQuery(opts: any) {
|
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
if (typeof opts === `function`) {
|
|
107
|
+
// Check if query function returns null/undefined (disabled query)
|
|
108
|
+
const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder
|
|
109
|
+
const result = opts(queryBuilder)
|
|
110
|
+
|
|
111
|
+
if (result === undefined || result === null) {
|
|
112
|
+
// Disabled query - return null
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
|
|
92
116
|
return createLiveQueryCollection({
|
|
93
117
|
query: opts,
|
|
94
118
|
startSync: true,
|
|
@@ -106,6 +130,16 @@ export function injectLiveQuery(opts: any) {
|
|
|
106
130
|
if (isReactiveQueryOptions) {
|
|
107
131
|
const { params, query } = opts
|
|
108
132
|
const currentParams = params()
|
|
133
|
+
|
|
134
|
+
// Check if query function returns null/undefined (disabled query)
|
|
135
|
+
const queryBuilder = new BaseQueryBuilder() as InitialQueryBuilder
|
|
136
|
+
const result = query({ params: currentParams, q: queryBuilder })
|
|
137
|
+
|
|
138
|
+
if (result === undefined || result === null) {
|
|
139
|
+
// Disabled query - return null
|
|
140
|
+
return null
|
|
141
|
+
}
|
|
142
|
+
|
|
109
143
|
return createLiveQueryCollection({
|
|
110
144
|
query: (q) => query({ params: currentParams, q }),
|
|
111
145
|
startSync: true,
|
|
@@ -123,10 +157,12 @@ export function injectLiveQuery(opts: any) {
|
|
|
123
157
|
|
|
124
158
|
const state = signal(new Map<string | number, any>())
|
|
125
159
|
const data = signal<Array<any>>([])
|
|
126
|
-
const status = signal<CollectionStatus
|
|
160
|
+
const status = signal<CollectionStatus | `disabled`>(
|
|
161
|
+
collection() ? `idle` : `disabled`,
|
|
162
|
+
)
|
|
127
163
|
|
|
128
164
|
const syncDataFromCollection = (
|
|
129
|
-
currentCollection: Collection<any, any, any
|
|
165
|
+
currentCollection: Collection<any, any, any>,
|
|
130
166
|
) => {
|
|
131
167
|
const newState = new Map(currentCollection.entries())
|
|
132
168
|
const newData = Array.from(currentCollection.values())
|
|
@@ -145,7 +181,12 @@ export function injectLiveQuery(opts: any) {
|
|
|
145
181
|
effect((onCleanup) => {
|
|
146
182
|
const currentCollection = collection()
|
|
147
183
|
|
|
184
|
+
// Handle null collection (disabled query)
|
|
148
185
|
if (!currentCollection) {
|
|
186
|
+
status.set(`disabled` as const)
|
|
187
|
+
state.set(new Map())
|
|
188
|
+
data.set([])
|
|
189
|
+
cleanup()
|
|
149
190
|
return
|
|
150
191
|
}
|
|
151
192
|
|
|
@@ -165,7 +206,7 @@ export function injectLiveQuery(opts: any) {
|
|
|
165
206
|
const subscription = currentCollection.subscribeChanges(
|
|
166
207
|
(_: Array<ChangeMessage<any>>) => {
|
|
167
208
|
syncDataFromCollection(currentCollection)
|
|
168
|
-
}
|
|
209
|
+
},
|
|
169
210
|
)
|
|
170
211
|
unsub = subscription.unsubscribe.bind(subscription)
|
|
171
212
|
|
|
@@ -185,7 +226,7 @@ export function injectLiveQuery(opts: any) {
|
|
|
185
226
|
collection,
|
|
186
227
|
status,
|
|
187
228
|
isLoading: computed(() => status() === `loading`),
|
|
188
|
-
isReady: computed(() => status() === `ready`),
|
|
229
|
+
isReady: computed(() => status() === `ready` || status() === `disabled`),
|
|
189
230
|
isIdle: computed(() => status() === `idle`),
|
|
190
231
|
isError: computed(() => status() === `error`),
|
|
191
232
|
isCleanedUp: computed(() => status() === `cleaned-up`),
|