@ttt-productions/query-core 0.4.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain-events/cache-invalidation.d.ts +28 -0
- package/dist/domain-events/cache-invalidation.d.ts.map +1 -0
- package/dist/domain-events/cache-invalidation.js +45 -0
- package/dist/domain-events/cache-invalidation.js.map +1 -0
- package/dist/domain-events/create-domain-event-invalidator.d.ts +39 -0
- package/dist/domain-events/create-domain-event-invalidator.d.ts.map +1 -0
- package/dist/domain-events/create-domain-event-invalidator.js +31 -0
- package/dist/domain-events/create-domain-event-invalidator.js.map +1 -0
- package/dist/domain-events/index.d.ts +5 -0
- package/dist/domain-events/index.d.ts.map +1 -0
- package/dist/domain-events/index.js +3 -0
- package/dist/domain-events/index.js.map +1 -0
- package/dist/firestore/types.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +5 -5
- package/dist/react/firestore/use-firestore-collection.d.ts +5 -5
- package/dist/react/firestore/use-firestore-collection.js +5 -5
- package/dist/react/firestore/use-firestore-doc.d.ts +3 -3
- package/dist/react/firestore/use-firestore-doc.js +3 -3
- package/dist/react/firestore/useBatchFirestoreDocs.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Query, QueryClient, QueryKey } from "@tanstack/react-query";
|
|
2
|
+
export type RefetchType = "active" | "all" | "none";
|
|
3
|
+
export type CacheInvalidation = {
|
|
4
|
+
kind: "exact";
|
|
5
|
+
queryKey: QueryKey;
|
|
6
|
+
refetchType?: RefetchType;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "prefix";
|
|
9
|
+
queryKey: QueryKey;
|
|
10
|
+
refetchType?: RefetchType;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "predicate";
|
|
13
|
+
description: string;
|
|
14
|
+
match: (query: Query) => boolean;
|
|
15
|
+
refetchType?: RefetchType;
|
|
16
|
+
};
|
|
17
|
+
export declare function exact(queryKey: QueryKey, opts?: {
|
|
18
|
+
refetchType?: RefetchType;
|
|
19
|
+
}): CacheInvalidation;
|
|
20
|
+
export declare function prefix(queryKey: QueryKey, opts?: {
|
|
21
|
+
refetchType?: RefetchType;
|
|
22
|
+
}): CacheInvalidation;
|
|
23
|
+
export declare function predicate(description: string, match: (query: Query) => boolean, opts?: {
|
|
24
|
+
refetchType?: RefetchType;
|
|
25
|
+
}): CacheInvalidation;
|
|
26
|
+
export declare function serializeInvalidation(inv: CacheInvalidation): string;
|
|
27
|
+
export declare function applyInvalidations(queryClient: QueryClient, invalidations: ReadonlyArray<CacheInvalidation>): void;
|
|
28
|
+
//# sourceMappingURL=cache-invalidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-invalidation.d.ts","sourceRoot":"","sources":["../../src/domain-events/cache-invalidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GACjE;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEN,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,iBAAiB,CAEjG;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,iBAAiB,CAElG;AAED,wBAAgB,SAAS,CACvB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,EAChC,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GACnC,iBAAiB,CAEnB;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAGpE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAC9C,IAAI,CA4BN"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function exact(queryKey, opts) {
|
|
2
|
+
return { kind: "exact", queryKey, refetchType: opts?.refetchType };
|
|
3
|
+
}
|
|
4
|
+
export function prefix(queryKey, opts) {
|
|
5
|
+
return { kind: "prefix", queryKey, refetchType: opts?.refetchType };
|
|
6
|
+
}
|
|
7
|
+
export function predicate(description, match, opts) {
|
|
8
|
+
return { kind: "predicate", description, match, refetchType: opts?.refetchType };
|
|
9
|
+
}
|
|
10
|
+
export function serializeInvalidation(inv) {
|
|
11
|
+
if (inv.kind === "predicate")
|
|
12
|
+
return `predicate:${inv.description}`;
|
|
13
|
+
return `${inv.kind}:${JSON.stringify(inv.queryKey)}`;
|
|
14
|
+
}
|
|
15
|
+
export function applyInvalidations(queryClient, invalidations) {
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
for (const inv of invalidations) {
|
|
18
|
+
const sig = serializeInvalidation(inv);
|
|
19
|
+
if (seen.has(sig))
|
|
20
|
+
continue;
|
|
21
|
+
seen.add(sig);
|
|
22
|
+
const refetchType = inv.refetchType ?? "active";
|
|
23
|
+
if (inv.kind === "exact") {
|
|
24
|
+
void queryClient.invalidateQueries({
|
|
25
|
+
queryKey: inv.queryKey,
|
|
26
|
+
exact: true,
|
|
27
|
+
refetchType,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (inv.kind === "prefix") {
|
|
31
|
+
void queryClient.invalidateQueries({
|
|
32
|
+
queryKey: inv.queryKey,
|
|
33
|
+
exact: false,
|
|
34
|
+
refetchType,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
void queryClient.invalidateQueries({
|
|
39
|
+
predicate: inv.match,
|
|
40
|
+
refetchType,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=cache-invalidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-invalidation.js","sourceRoot":"","sources":["../../src/domain-events/cache-invalidation.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,KAAK,CAAC,QAAkB,EAAE,IAAoC;IAC5E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,QAAkB,EAAE,IAAoC;IAC7E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,WAAmB,EACnB,KAAgC,EAChC,IAAoC;IAEpC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAsB;IAC1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Invalidation } from "./cache-invalidation.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registry shape: each event type maps to a function from the event's `ids`
|
|
5
|
+
* payload to the list of cache invalidations that event should trigger.
|
|
6
|
+
*/
|
|
7
|
+
export type DomainEventInvalidationRegistry<TEvent extends {
|
|
8
|
+
type: string;
|
|
9
|
+
ids: unknown;
|
|
10
|
+
}> = {
|
|
11
|
+
[K in TEvent["type"]]: (ids: Extract<TEvent, {
|
|
12
|
+
type: K;
|
|
13
|
+
}>["ids"]) => ReadonlyArray<CacheInvalidation>;
|
|
14
|
+
};
|
|
15
|
+
export interface DomainEventInvalidator<TEvent extends {
|
|
16
|
+
type: string;
|
|
17
|
+
ids: unknown;
|
|
18
|
+
}> {
|
|
19
|
+
notify(queryClient: QueryClient, event: TEvent): void;
|
|
20
|
+
notifyAll(queryClient: QueryClient, events: ReadonlyArray<TEvent>): void;
|
|
21
|
+
/** Test/debug helpers. */
|
|
22
|
+
readonly helpers: {
|
|
23
|
+
exact: typeof exact;
|
|
24
|
+
prefix: typeof prefix;
|
|
25
|
+
predicate: typeof predicate;
|
|
26
|
+
};
|
|
27
|
+
/** Direct access to the registry, mainly for tests. */
|
|
28
|
+
readonly registry: DomainEventInvalidationRegistry<TEvent>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build a domain-event → cache-invalidation notifier from a typed registry.
|
|
32
|
+
* The registry's keys are statically tied to `TEvent["type"]`, so missing or
|
|
33
|
+
* extra entries are compile errors.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createDomainEventInvalidator<TEvent extends {
|
|
36
|
+
type: string;
|
|
37
|
+
ids: unknown;
|
|
38
|
+
}>(registry: DomainEventInvalidationRegistry<TEvent>): DomainEventInvalidator<TEvent>;
|
|
39
|
+
//# sourceMappingURL=create-domain-event-invalidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-domain-event-invalidator.d.ts","sourceRoot":"","sources":["../../src/domain-events/create-dom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AM,CAAC,CA4BhC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { applyInvalidations, exact, prefix, predicate, } from "./cache-invalidation.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build a domain-event → cache-invalidation notifier from a typed registry.
|
|
4
|
+
* The registry's keys are statically tied to `TEvent["type"]`, so missing or
|
|
5
|
+
* extra entries are compile errors.
|
|
6
|
+
*/
|
|
7
|
+
export function createDomainEventInvalidator(registry) {
|
|
8
|
+
function lookup(type) {
|
|
9
|
+
return registry[type];
|
|
10
|
+
}
|
|
11
|
+
function notify(queryClient, event) {
|
|
12
|
+
const fn = lookup(event.type);
|
|
13
|
+
const invalidations = fn(event.ids);
|
|
14
|
+
applyInvalidations(queryClient, invalidations);
|
|
15
|
+
}
|
|
16
|
+
function notifyAll(queryClient, events) {
|
|
17
|
+
const all = [];
|
|
18
|
+
for (const event of events) {
|
|
19
|
+
const fn = lookup(event.type);
|
|
20
|
+
all.push(...fn(event.ids));
|
|
21
|
+
}
|
|
22
|
+
applyInvalidations(queryClient, all);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
notify,
|
|
26
|
+
notifyAll,
|
|
27
|
+
helpers: { exact, prefix, predicate },
|
|
28
|
+
registry,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=create-domain-event-invalidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-domain-event-invalidator.js","sourceRoot":"","sources":["../../src/domain-events/create-domain-event-invalidator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,SAAS,GAEV,MAAM,yBAAyB,CAAC;AAyBjC;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAiD;IAEjD,SAAS,MAAM,CAA+B,IAAW;QACvD,OAAO,QAAQ,CAAC,IAAI,CAEiB,CAAC;IACxC,CAAC;IAED,SAAS,MAAM,CAAC,WAAwB,EAAE,KAAa;QACrD,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,IAAsB,CAAC,CAAC;QAChD,MAAM,aAAa,GAAG,EAAE,CAAC,KAAK,CAAC,GAAuD,CAAC,CAAC;QACxF,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAED,SAAS,SAAS,CAAC,WAAwB,EAAE,MAA6B;QACxE,MAAM,GAAG,GAAwB,EAAE,CAAC;QACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,IAAsB,CAAC,CAAC;YAChD,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAuD,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,kBAAkB,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,MAAM;QACN,SAAS;QACT,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE;QACrC,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { exact, prefix, predicate, serializeInvalidation, applyInvalidations, } from "./cache-invalidation.js";
|
|
2
|
+
export type { CacheInvalidation, RefetchType } from "./cache-invalidation.js";
|
|
3
|
+
export { createDomainEventInvalidator } from "./create-domain-event-invalidator.js";
|
|
4
|
+
export type { DomainEventInvalidator, DomainEventInvalidationRegistry, } from "./create-domain-event-invalidator.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain-events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,YAAY,EACV,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain-events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -39,7 +39,7 @@ export interface FirestoreDocOptions<T> extends FirestoreBaseOptions {
|
|
|
39
39
|
* Options for collection queries.
|
|
40
40
|
*/
|
|
41
41
|
export interface FirestoreCollectionOptions<T> extends FirestoreBaseOptions {
|
|
42
|
-
/** Collection path (e.g., 'users' or '
|
|
42
|
+
/** Collection path (e.g., 'users' or 'entities/abc/members') */
|
|
43
43
|
collectionPath: string;
|
|
44
44
|
/** Firestore query constraints (where, orderBy, etc.) */
|
|
45
45
|
constraints?: QueryConstraint[];
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export type { WithId, FirestoreBaseOptions, FirestoreDocOptions, FirestoreCollec
|
|
|
7
7
|
export { docWithId } from './firestore/types.js';
|
|
8
8
|
export { flattenInfiniteData, getInfiniteDataCount, } from './firestore/infinite-helpers.js';
|
|
9
9
|
export type { FirestoreSearchConfig, FirestoreSearchOptions, } from './search/types.js';
|
|
10
|
+
export { createDomainEventInvalidator, exact, prefix, predicate, serializeInvalidation, applyInvalidations, } from "./domain-events/index.js";
|
|
11
|
+
export type { DomainEventInvalidator, DomainEventInvalidationRegistry, CacheInvalidation, RefetchType, } from "./domain-events/index.js";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGzF,YAAY,EACV,MAAM,EACN,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAGzC,YAAY,EACV,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGzF,YAAY,EACV,MAAM,EACN,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAGzC,YAAY,EACV,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,4BAA4B,EAC5B,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,sBAAsB,EACtB,+BAA+B,EAC/B,iBAAiB,EACjB,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,6 @@ export { keys, createKeyScope } from './keys.js';
|
|
|
6
6
|
export { invalidateByPrefix, removeByPrefix, updateQueryData } from './cache-helpers.js';
|
|
7
7
|
export { docWithId } from './firestore/types.js';
|
|
8
8
|
export { flattenInfiniteData, getInfiniteDataCount, } from './firestore/infinite-helpers.js';
|
|
9
|
+
// Domain-event invalidator (mechanism — consumers register their event registry)
|
|
10
|
+
export { createDomainEventInvalidator, exact, prefix, predicate, serializeInvalidation, applyInvalidations, } from "./domain-events/index.js";
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjD,gBAAgB;AAChB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAgBzF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjD,gBAAgB;AAChB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAgBzF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAQzC,iFAAiF;AACjF,OAAO,EACL,4BAA4B,EAC5B,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/dist/keys.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const keys: {
|
|
|
37
37
|
readonly list: (param?: SerializedKeyPart) => QueryKey;
|
|
38
38
|
readonly custom: (...parts: SerializedKeyPart[]) => QueryKey;
|
|
39
39
|
};
|
|
40
|
-
readonly
|
|
40
|
+
readonly entities: {
|
|
41
41
|
readonly all: QueryKey;
|
|
42
42
|
readonly detail: (id: string) => QueryKey;
|
|
43
43
|
readonly list: (param?: SerializedKeyPart) => QueryKey;
|
package/dist/keys.js
CHANGED
|
@@ -21,11 +21,11 @@ export const keys = {
|
|
|
21
21
|
list: (param) => withScope('skills', 'list', param),
|
|
22
22
|
custom: (...parts) => withScope('skills', ...parts),
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
all: withScope('
|
|
26
|
-
detail: (id) => withScope('
|
|
27
|
-
list: (param) => withScope('
|
|
28
|
-
custom: (...parts) => withScope('
|
|
24
|
+
entities: {
|
|
25
|
+
all: withScope('entities'),
|
|
26
|
+
detail: (id) => withScope('entities', 'detail', id),
|
|
27
|
+
list: (param) => withScope('entities', 'list', param),
|
|
28
|
+
custom: (...parts) => withScope('entities', ...parts),
|
|
29
29
|
},
|
|
30
30
|
messages: {
|
|
31
31
|
all: withScope('messages'),
|
|
@@ -7,16 +7,16 @@ import type { FirestoreCollectionOptions, WithId } from '../../firestore/types.j
|
|
|
7
7
|
* For large collections, use useFirestoreInfinite or useFirestorePaginated.
|
|
8
8
|
* * @example
|
|
9
9
|
* ```tsx
|
|
10
|
-
* // Fetch all channels in
|
|
10
|
+
* // Fetch all channels in an entity
|
|
11
11
|
* const { data: channels } = useFirestoreCollection<Channel>({
|
|
12
|
-
* collectionPath: `
|
|
13
|
-
* queryKey: ['channels',
|
|
12
|
+
* collectionPath: `entities/${entityId}/channels`,
|
|
13
|
+
* queryKey: ['channels', entityId],
|
|
14
14
|
* constraints: [orderBy('createdAt', 'asc')],
|
|
15
15
|
* });
|
|
16
16
|
* * // With realtime updates
|
|
17
17
|
* const { data: members } = useFirestoreCollection<Member>({
|
|
18
|
-
* collectionPath: `
|
|
19
|
-
* queryKey: ['members',
|
|
18
|
+
* collectionPath: `entities/${entityId}/members`,
|
|
19
|
+
* queryKey: ['members', entityId],
|
|
20
20
|
* subscribe: true,
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
@@ -9,16 +9,16 @@ import { useFirestoreDb } from './context.js';
|
|
|
9
9
|
* For large collections, use useFirestoreInfinite or useFirestorePaginated.
|
|
10
10
|
* * @example
|
|
11
11
|
* ```tsx
|
|
12
|
-
* // Fetch all channels in
|
|
12
|
+
* // Fetch all channels in an entity
|
|
13
13
|
* const { data: channels } = useFirestoreCollection<Channel>({
|
|
14
|
-
* collectionPath: `
|
|
15
|
-
* queryKey: ['channels',
|
|
14
|
+
* collectionPath: `entities/${entityId}/channels`,
|
|
15
|
+
* queryKey: ['channels', entityId],
|
|
16
16
|
* constraints: [orderBy('createdAt', 'asc')],
|
|
17
17
|
* });
|
|
18
18
|
* * // With realtime updates
|
|
19
19
|
* const { data: members } = useFirestoreCollection<Member>({
|
|
20
|
-
* collectionPath: `
|
|
21
|
-
* queryKey: ['members',
|
|
20
|
+
* collectionPath: `entities/${entityId}/members`,
|
|
21
|
+
* queryKey: ['members', entityId],
|
|
22
22
|
* subscribe: true,
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
@@ -11,9 +11,9 @@ import type { FirestoreDocOptions, WithId } from '../../firestore/types.js';
|
|
|
11
11
|
* queryKey: ['user', userId],
|
|
12
12
|
* });
|
|
13
13
|
* * // With realtime updates
|
|
14
|
-
* const { data:
|
|
15
|
-
* docPath: `
|
|
16
|
-
* queryKey: ['
|
|
14
|
+
* const { data: entity } = useFirestoreDoc<Entity>({
|
|
15
|
+
* docPath: `entities/${entityId}`,
|
|
16
|
+
* queryKey: ['entity', entityId],
|
|
17
17
|
* subscribe: true,
|
|
18
18
|
* });
|
|
19
19
|
* * // Conditional fetch
|
|
@@ -13,9 +13,9 @@ import { useFirestoreDb } from './context.js';
|
|
|
13
13
|
* queryKey: ['user', userId],
|
|
14
14
|
* });
|
|
15
15
|
* * // With realtime updates
|
|
16
|
-
* const { data:
|
|
17
|
-
* docPath: `
|
|
18
|
-
* queryKey: ['
|
|
16
|
+
* const { data: entity } = useFirestoreDoc<Entity>({
|
|
17
|
+
* docPath: `entities/${entityId}`,
|
|
18
|
+
* queryKey: ['entity', entityId],
|
|
19
19
|
* subscribe: true,
|
|
20
20
|
* });
|
|
21
21
|
* * // Conditional fetch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/query-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Shared TanStack Query (React Query) client defaults, query key helpers, and Firestore integration hooks for TTT Productions apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|