@ttt-productions/query-core 0.14.30 → 0.14.31

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.
@@ -0,0 +1,38 @@
1
+ import { type ReactNode } from 'react';
2
+ export type AppConfigStatus = 'loading' | 'ready' | 'missing' | 'unavailable';
3
+ export type StoredAppConfig = Readonly<Record<string, unknown>>;
4
+ export type AppConfigLeverOf<TLevers extends object> = keyof TLevers & string;
5
+ export type AppConfigSnapshotState<TLevers extends object, TExtra extends object> = {
6
+ status: AppConfigStatus;
7
+ levers: TLevers;
8
+ refusedLevers: readonly AppConfigLeverOf<TLevers>[];
9
+ } & TExtra;
10
+ export type AppConfigState<TLevers extends object, TExtra extends object> = AppConfigSnapshotState<TLevers, TExtra> & {
11
+ retry: () => void;
12
+ retrying: boolean;
13
+ };
14
+ export interface AppConfigDefinition<TLevers extends object, TExtra extends object> {
15
+ path: string;
16
+ defaults: TLevers;
17
+ readLevers: (stored: StoredAppConfig) => TLevers;
18
+ isLeverRefused: (stored: StoredAppConfig, lever: AppConfigLeverOf<TLevers>) => boolean;
19
+ extra: {
20
+ read: (stored: StoredAppConfig | null) => TExtra;
21
+ whileUnknown: TExtra;
22
+ };
23
+ onLeverRefused?: (lever: AppConfigLeverOf<TLevers>, value: unknown) => void;
24
+ onUnavailable?: (error: unknown, attempts: number) => void;
25
+ }
26
+ export interface AppConfig<TLevers extends object, TExtra extends object> {
27
+ AppConfigProvider: (props: {
28
+ children: ReactNode;
29
+ }) => ReactNode;
30
+ useAppConfig: () => AppConfigState<TLevers, TExtra>;
31
+ readAppConfigSnapshot: (stored: StoredAppConfig | null) => AppConfigSnapshotState<TLevers, TExtra>;
32
+ LOADING_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra>;
33
+ UNAVAILABLE_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra>;
34
+ }
35
+ export declare const APP_CONFIG_MAX_QUICK_ATTEMPTS = 6;
36
+ export declare const APP_CONFIG_BACKGROUND_RETRY_MS = 60000;
37
+ export declare function createAppConfig<TLevers extends object, TExtra extends object>(definition: AppConfigDefinition<TLevers, TExtra>): AppConfig<TLevers, TExtra>;
38
+ //# sourceMappingURL=create-app-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-app-config.d.ts","sourceRoot":"","sources":["../../../src/react/app-config/create-app-config.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAE9E,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhE,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,MAAM,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC;AAE9E,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,IAAI;IAClF,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;CACrD,GAAG,MAAM,CAAC;AAEX,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,IAAI,sBAAsB,CAChG,OAAO,EACP,MAAM,CACP,GAAG;IACF,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC;IACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,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ect, useMemo, useRef, useState, } from 'react';
4
+ import { doc, onSnapshot } from 'firebase/firestore';
5
+ import { useFirestoreDb } from '../firestore/context.js';
6
+ // A permission-denied error ends a Firestore listener for good, and the first listen can lose a race
7
+ // with the first App Check token, so the listener re-subscribes on its own: a short backoff, then
8
+ // about once a minute for as long as the page is open.
9
+ export const APP_CONFIG_MAX_QUICK_ATTEMPTS = 6;
10
+ export const APP_CONFIG_BACKGROUND_RETRY_MS = 60_000;
11
+ function quickRetryDelayMs(attempt) {
12
+ return Math.min(1000 * 2 ** (attempt - 1), 10_000);
13
+ }
14
+ export function createAppConfig(definition) {
15
+ const leverKeys = Object.keys(definition.defaults);
16
+ const LOADING_APP_CONFIG = {
17
+ ...definition.extra.whileUnknown,
18
+ status: 'loading',
19
+ levers: definition.defaults,
20
+ refusedLevers: [],
21
+ };
22
+ const UNAVAILABLE_APP_CONFIG = {
23
+ ...LOADING_APP_CONFIG,
24
+ status: 'unavailable',
25
+ };
26
+ function readAppConfigSnapshot(stored) {
27
+ const extra = definition.extra.read(stored);
28
+ if (stored === null) {
29
+ return { ...extra, status: 'missing', levers: definition.defaults, refusedLevers: [] };
30
+ }
31
+ return {
32
+ ...extra,
33
+ status: 'ready',
34
+ levers: definition.readLevers(stored),
35
+ refusedLevers: leverKeys.filter((lever) => definition.isLeverRefused(stored, lever)),
36
+ };
37
+ }
38
+ const AppConfigContext = createContext({
39
+ ...LOADING_APP_CONFIG,
40
+ retry: () => { },
41
+ retrying: false,
42
+ });
43
+ function AppConfigProvider({ children }) {
44
+ const db = useFirestoreDb();
45
+ const [snapshot, setSnapshot] = useState(LOADING_APP_CONFIG);
46
+ const [subscription, setSubscription] = useState(0);
47
+ const [retrying, setRetrying] = useState(false);
48
+ const reportedRefusals = useRef(new Set());
49
+ useEffect(() => {
50
+ const ref = doc(db, definition.path);
51
+ let attempt = 0;
52
+ let retryTimer;
53
+ let unsubscribe;
54
+ let disposed = false;
55
+ const subscribe = () => {
56
+ if (disposed)
57
+ return;
58
+ unsubscribe = onSnapshot(ref, (snap) => {
59
+ attempt = 0;
60
+ const stored = snap.exists() ? snap.data() : null;
61
+ const next = readAppConfigSnapshot(stored);
62
+ for (const lever of next.refusedLevers) {
63
+ const value = stored?.[lever];
64
+ const key = `${lever}:${typeof value}:${JSON.stringify(value)}`;
65
+ if (reportedRefusals.current.has(key))
66
+ continue;
67
+ reportedRefusals.current.add(key);
68
+ definition.onLeverRefused?.(lever, value);
69
+ }
70
+ setSnapshot(next);
71
+ setRetrying(false);
72
+ }, (error) => {
73
+ unsubscribe?.();
74
+ unsubscribe = undefined;
75
+ attempt += 1;
76
+ if (attempt < APP_CONFIG_MAX_QUICK_ATTEMPTS) {
77
+ retryTimer = setTimeout(subscribe, quickRetryDelayMs(attempt));
78
+ return;
79
+ }
80
+ if (attempt === APP_CONFIG_MAX_QUICK_ATTEMPTS) {
81
+ definition.onUnavailable?.(error, attempt);
82
+ // A snapshot already read stays the best knowledge there is.
83
+ setSnapshot((current) => current.status === 'loading' ? UNAVAILABLE_APP_CONFIG : current);
84
+ setRetrying(false);
85
+ }
86
+ retryTimer = setTimeout(subscribe, APP_CONFIG_BACKGROUND_RETRY_MS);
87
+ });
88
+ };
89
+ subscribe();
90
+ return () => {
91
+ disposed = true;
92
+ if (retryTimer !== undefined)
93
+ clearTimeout(retryTimer);
94
+ unsubscribe?.();
95
+ };
96
+ }, [db, subscription]);
97
+ const retry = useCallback(() => {
98
+ setRetrying(true);
99
+ setSubscription((count) => count + 1);
100
+ }, []);
101
+ const value = useMemo(() => ({ ...snapshot, retry, retrying }), [snapshot, retry, retrying]);
102
+ return _jsx(AppConfigContext.Provider, { value: value, children: children });
103
+ }
104
+ function useAppConfig() {
105
+ return useContext(AppConfigContext);
106
+ }
107
+ return {
108
+ AppConfigProvider,
109
+ useAppConfig,
110
+ readAppConfigSnapshot,
111
+ LOADING_APP_CONFIG,
112
+ UNAVAILABLE_APP_CONFIG,
113
+ };
114
+ }
115
+ //# sourceMappingURL=create-app-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-app-config.js","sourceRoot":"","sources":["../../../src/react/app-config/create-app-config.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA6CzD,qGAAqG;AACrG,kGAAkG;AAClG,uDAAuD;AACvD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAErD,SAAS,iBAAiB,CAAC,OAAe;IACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,UAAgD;IAEhD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAgC,CAAC;IAElF,MAAM,kBAAkB,GAA4C;QAClE,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY;QAChC,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,UAAU,CAAC,QAAQ;QAC3B,aAAa,EAAE,EAAE;KAClB,CAAC;IACF,MAAM,sBAAsB,GAA4C;QACtE,GAAG,kBAAkB;QACrB,MAAM,EAAE,aAAa;KACtB,CAAC;IAEF,SAAS,qBAAqB,CAC5B,MAA8B;QAE9B,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAA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\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { doc, onSnapshot } from 'firebase/firestore';\nimport { useFirestoreDb } from '../firestore/context.js';\n\nexport type AppConfigStatus = 'loading' | 'ready' | 'missing' | 'unavailable';\n\nexport type StoredAppConfig = Readonly<Record<string, unknown>>;\n\nexport type AppConfigLeverOf<TLevers extends object> = keyof TLevers & string;\n\nexport type AppConfigSnapshotState<TLevers extends object, TExtra extends object> = {\n status: AppConfigStatus;\n levers: TLevers;\n refusedLevers: readonly AppConfigLeverOf<TLevers>[];\n} & TExtra;\n\nexport type AppConfigState<TLevers extends object, TExtra extends object> = AppConfigSnapshotState<\n TLevers,\n TExtra\n> & {\n retry: () => void;\n retrying: boolean;\n};\n\nexport interface AppConfigDefinition<TLevers extends object, TExtra extends object> {\n path: string;\n defaults: TLevers;\n readLevers: (stored: StoredAppConfig) => TLevers;\n isLeverRefused: (stored: StoredAppConfig, lever: AppConfigLeverOf<TLevers>) => boolean;\n extra: {\n read: (stored: StoredAppConfig | null) => TExtra;\n whileUnknown: TExtra;\n };\n onLeverRefused?: (lever: AppConfigLeverOf<TLevers>, value: unknown) => void;\n onUnavailable?: (error: unknown, attempts: number) => void;\n}\n\nexport interface AppConfig<TLevers extends object, TExtra extends object> {\n AppConfigProvider: (props: { children: ReactNode }) => ReactNode;\n useAppConfig: () => AppConfigState<TLevers, TExtra>;\n readAppConfigSnapshot: (\n stored: StoredAppConfig | null,\n ) => AppConfigSnapshotState<TLevers, TExtra>;\n LOADING_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra>;\n UNAVAILABLE_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra>;\n}\n\n// A permission-denied error ends a Firestore listener for good, and the first listen can lose a race\n// with the first App Check token, so the listener re-subscribes on its own: a short backoff, then\n// about once a minute for as long as the page is open.\nexport const APP_CONFIG_MAX_QUICK_ATTEMPTS = 6;\nexport const APP_CONFIG_BACKGROUND_RETRY_MS = 60_000;\n\nfunction quickRetryDelayMs(attempt: number): number {\n return Math.min(1000 * 2 ** (attempt - 1), 10_000);\n}\n\nexport function createAppConfig<TLevers extends object, TExtra extends object>(\n definition: AppConfigDefinition<TLevers, TExtra>,\n): AppConfig<TLevers, TExtra> {\n const leverKeys = Object.keys(definition.defaults) as AppConfigLeverOf<TLevers>[];\n\n const LOADING_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra> = {\n ...definition.extra.whileUnknown,\n status: 'loading',\n levers: definition.defaults,\n refusedLevers: [],\n };\n const UNAVAILABLE_APP_CONFIG: AppConfigSnapshotState<TLevers, TExtra> = {\n ...LOADING_APP_CONFIG,\n status: 'unavailable',\n };\n\n function readAppConfigSnapshot(\n stored: StoredAppConfig | null,\n ): AppConfigSnapshotState<TLevers, TExtra> {\n const extra = definition.extra.read(stored);\n if (stored === null) {\n return { ...extra, status: 'missing', levers: definition.defaults, refusedLevers: [] };\n }\n return {\n ...extra,\n status: 'ready',\n levers: definition.readLevers(stored),\n refusedLevers: leverKeys.filter((lever) => definition.isLeverRefused(stored, lever)),\n };\n }\n\n const AppConfigContext = createContext<AppConfigState<TLevers, TExtra>>({\n ...LOADING_APP_CONFIG,\n retry: () => {},\n retrying: false,\n });\n\n function AppConfigProvider({ children }: { children: ReactNode }) {\n const db = useFirestoreDb();\n const [snapshot, setSnapshot] =\n useState<AppConfigSnapshotState<TLevers, TExtra>>(LOADING_APP_CONFIG);\n const [subscription, setSubscription] = useState(0);\n const [retrying, setRetrying] = useState(false);\n const reportedRefusals = useRef(new Set<string>());\n\n useEffect(() => {\n const ref = doc(db, definition.path);\n let attempt = 0;\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n let unsubscribe: (() => void) | undefined;\n let disposed = false;\n\n const subscribe = () => {\n if (disposed) return;\n unsubscribe = onSnapshot(\n ref,\n (snap) => {\n attempt = 0;\n const stored: StoredAppConfig | null = snap.exists() ? snap.data() : null;\n const next = readAppConfigSnapshot(stored);\n for (const lever of next.refusedLevers) {\n const value: unknown = stored?.[lever];\n const key = `${lever}:${typeof value}:${JSON.stringify(value)}`;\n if (reportedRefusals.current.has(key)) continue;\n reportedRefusals.current.add(key);\n definition.onLeverRefused?.(lever, value);\n }\n setSnapshot(next);\n setRetrying(false);\n },\n (error) => {\n unsubscribe?.();\n unsubscribe = undefined;\n attempt += 1;\n if (attempt < APP_CONFIG_MAX_QUICK_ATTEMPTS) {\n retryTimer = setTimeout(subscribe, quickRetryDelayMs(attempt));\n return;\n }\n if (attempt === APP_CONFIG_MAX_QUICK_ATTEMPTS) {\n definition.onUnavailable?.(error, attempt);\n // A snapshot already read stays the best knowledge there is.\n setSnapshot((current) =>\n current.status === 'loading' ? UNAVAILABLE_APP_CONFIG : current,\n );\n setRetrying(false);\n }\n retryTimer = setTimeout(subscribe, APP_CONFIG_BACKGROUND_RETRY_MS);\n },\n );\n };\n\n subscribe();\n return () => {\n disposed = true;\n if (retryTimer !== undefined) clearTimeout(retryTimer);\n unsubscribe?.();\n };\n }, [db, subscription]);\n\n const retry = useCallback(() => {\n setRetrying(true);\n setSubscription((count) => count + 1);\n }, []);\n\n const value = useMemo<AppConfigState<TLevers, TExtra>>(\n () => ({ ...snapshot, retry, retrying }),\n [snapshot, retry, retrying],\n );\n\n return <AppConfigContext.Provider value={value}>{children}</AppConfigContext.Provider>;\n }\n\n function useAppConfig(): AppConfigState<TLevers, TExtra> {\n return useContext(AppConfigContext);\n }\n\n return {\n AppConfigProvider,\n useAppConfig,\n readAppConfigSnapshot,\n LOADING_APP_CONFIG,\n UNAVAILABLE_APP_CONFIG,\n };\n}\n"]}
@@ -35,4 +35,6 @@ export type { MutationSession, MutationSessionProviderProps, SessionMutateOption
35
35
  export { createCallables, MAX_RESUMABLE_CALLS } from './callables/create-callables.js';
36
36
  export type { CallableCaptureContext, CallableDeclaration, CallableErrorRouting, CallableMutationOptions, CallablePolicy, Callables, ResumableOutcome, } from './callables/create-callables.js';
37
37
  export { usePendingMutationVariables, pendingMutationVariables, usePendingMutationTargets, hasPendingMutation, duplicateSubmissionError, useDuplicateGuardedMutation, } from './pending-mutations.js';
38
+ export { APP_CONFIG_BACKGROUND_RETRY_MS, APP_CONFIG_MAX_QUICK_ATTEMPTS, createAppConfig, } from './app-config/create-app-config.js';
39
+ export type { AppConfig, AppConfigDefinition, AppConfigLeverOf, AppConfigSnapshotState, AppConfigState, AppConfigStatus, StoredAppConfig, } from './app-config/create-app-config.js';
38
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,YAAY,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,YAAY,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAE9F,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,qBAAqB,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AAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAClF,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAElF,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACvF,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,mCAAmC,CAAC"}
@@ -21,4 +21,5 @@ export { useReadRetryState, useReadRetryStates } from './use-read-retry-state.js
21
21
  export { MutationSessionProvider, MutationSessionEndedError, useSessionMutation, } from './session-mutation.js';
22
22
  export { createCallables, MAX_RESUMABLE_CALLS } from './callables/create-callables.js';
23
23
  export { usePendingMutationVariables, pendingMutationVariables, usePendingMutationTargets, hasPendingMutation, duplicateSubmissionError, useDuplicateGuardedMutation, } from './pending-mutations.js';
24
+ export { APP_CONFIG_BACKGROUND_RETRY_MS, APP_CONFIG_MAX_QUICK_ATTEMPTS, createAppConfig, } from './app-config/create-app-config.js';
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAGtF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAM7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAYjD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAG5F,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIlF,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAWvF,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC","sourcesContent":["'use client';\n\nexport { createQueryClient } from './query-client.js';\nexport type { CreateQueryClientOptions } from './query-client.js';\n\nexport { QueryProvider } from './provider.js';\nexport type { QueryProviderProps } from './provider.js';\n\nexport { FirestoreProvider, useFirestoreDb } from './firestore/context.js';\nexport type { FirestoreProviderProps } from './firestore/context.js';\n\nexport { useFirestoreDoc } from './firestore/use-firestore-doc.js';\nexport { useFirestoreCollection } from './firestore/use-firestore-collection.js';\nexport { useFirestoreInfinite } from './firestore/use-firestore-infinite.js';\nexport { useFirestorePaginated } from './firestore/use-firestore-paginated.js';\nexport type { UseFirestorePaginatedResult } from './firestore/use-firestore-paginated.js';\nexport { useFirestoreCount } from './firestore/use-firestore-count.js';\nexport { useFirestoreLiveInfinite } from './firestore/use-firestore-live-infinite.js';\nexport type { FirestoreLiveInfiniteResult } from './firestore/use-firestore-live-infinite.js';\n\nexport {\n useFirestoreSet,\n useFirestoreUpdate,\n useFirestoreDelete,\n useFirestoreBatch,\n} from './firestore/use-firestore-mutations.js';\n\nexport { useBatchFirestoreDocs } from './firestore/useBatchFirestoreDocs.js';\nexport type {\n BatchFirestoreDocsOptions,\n BatchFirestoreDocsResult,\n BatchFirestoreDocsTransport,\n} from './firestore/useBatchFirestoreDocs.js';\nexport { ABSENT_RETRY_DELAYS_MS } from './firestore/absence-scheduler.js';\n\nexport { useFirestoreSearch } from './search/use-firestore-search.js';\n\nexport {\n invalidateByPrefix,\n removeByPrefix,\n updateQueryData,\n paginatedPageKey,\n mapPaginatedItems,\n prependToFirstPaginatedPage,\n placeRowInPages,\n} from './cache-helpers.js';\nexport type { PagedRows } from './cache-helpers.js';\n\nexport { createDomainEventInvalidator } from './domain-events/create-domain-event-invalidator.js';\nexport {\n exact,\n prefix,\n predicate,\n serializeInvalidation,\n applyInvalidations,\n} from './domain-events/cache-invalidation.js';\nexport type {\n DomainEventInvalidator,\n DomainEventInvalidationRegistry,\n} from './domain-events/create-domain-event-invalidator.js';\nexport type {\n CacheAction,\n CacheInvalidation,\n RefetchType,\n} from './domain-events/cache-invalidation.js';\n\nexport { docWithId } from './firestore/types.js';\nexport type {\n FirestoreDocOptions,\n FirestoreCollectionOptions,\n FirestoreInfiniteOptions,\n FirestorePaginatedOptions,\n FirestoreCountOptions,\n FirestoreLiveInfiniteOptions,\n InfinitePage,\n PaginatedPage,\n MutationOperation,\n} from './firestore/types.js';\nexport { flattenInfiniteData, getInfiniteDataCount } from './firestore/infinite-helpers.js';\nexport type { FirestoreSearchOptions } from './search/types.js';\n\nexport { useReadRetryState, useReadRetryStates } from './use-read-retry-state.js';\nexport type { ReadRetryEntry } from './use-read-retry-state.js';\nexport type { ReadRetrySource, ReadRetryState } from './read-retry-derivation.js';\n\nexport {\n MutationSessionProvider,\n MutationSessionEndedError,\n useSessionMutation,\n} from './session-mutation.js';\nexport type {\n MutationSession,\n MutationSessionProviderProps,\n SessionMutateOptions,\n SessionMutationFunctionContext,\n SessionMutationOptions,\n SessionMutationResult,\n UnknownOutcomePolicy,\n} from './session-mutation.js';\n\nexport { createCallables, MAX_RESUMABLE_CALLS } from './callables/create-callables.js';\nexport type {\n CallableCaptureContext,\n CallableDeclaration,\n CallableErrorRouting,\n CallableMutationOptions,\n CallablePolicy,\n Callables,\n ResumableOutcome,\n} from './callables/create-callables.js';\n\nexport {\n usePendingMutationVariables,\n pendingMutationVariables,\n usePendingMutationTargets,\n hasPendingMutation,\n duplicateSubmissionError,\n useDuplicateGuardedMutation,\n} from './pending-mutations.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAGtF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAM7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAYjD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAG5F,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIlF,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAWvF,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,GAChB,MAAM,mCAAmC,CAAC","sourcesContent":["'use client';\n\nexport { createQueryClient } from './query-client.js';\nexport type { CreateQueryClientOptions } from './query-client.js';\n\nexport { QueryProvider } from './provider.js';\nexport type { QueryProviderProps } from './provider.js';\n\nexport { FirestoreProvider, useFirestoreDb } from './firestore/context.js';\nexport type { FirestoreProviderProps } from './firestore/context.js';\n\nexport { useFirestoreDoc } from './firestore/use-firestore-doc.js';\nexport { useFirestoreCollection } from './firestore/use-firestore-collection.js';\nexport { useFirestoreInfinite } from './firestore/use-firestore-infinite.js';\nexport { useFirestorePaginated } from './firestore/use-firestore-paginated.js';\nexport type { UseFirestorePaginatedResult } from './firestore/use-firestore-paginated.js';\nexport { useFirestoreCount } from './firestore/use-firestore-count.js';\nexport { useFirestoreLiveInfinite } from './firestore/use-firestore-live-infinite.js';\nexport type { FirestoreLiveInfiniteResult } from './firestore/use-firestore-live-infinite.js';\n\nexport {\n useFirestoreSet,\n useFirestoreUpdate,\n useFirestoreDelete,\n useFirestoreBatch,\n} from './firestore/use-firestore-mutations.js';\n\nexport { useBatchFirestoreDocs } from './firestore/useBatchFirestoreDocs.js';\nexport type {\n BatchFirestoreDocsOptions,\n BatchFirestoreDocsResult,\n BatchFirestoreDocsTransport,\n} from './firestore/useBatchFirestoreDocs.js';\nexport { ABSENT_RETRY_DELAYS_MS } from './firestore/absence-scheduler.js';\n\nexport { useFirestoreSearch } from './search/use-firestore-search.js';\n\nexport {\n invalidateByPrefix,\n removeByPrefix,\n updateQueryData,\n paginatedPageKey,\n mapPaginatedItems,\n prependToFirstPaginatedPage,\n placeRowInPages,\n} from './cache-helpers.js';\nexport type { PagedRows } from './cache-helpers.js';\n\nexport { createDomainEventInvalidator } from './domain-events/create-domain-event-invalidator.js';\nexport {\n exact,\n prefix,\n predicate,\n serializeInvalidation,\n applyInvalidations,\n} from './domain-events/cache-invalidation.js';\nexport type {\n DomainEventInvalidator,\n DomainEventInvalidationRegistry,\n} from './domain-events/create-domain-event-invalidator.js';\nexport type {\n CacheAction,\n CacheInvalidation,\n RefetchType,\n} from './domain-events/cache-invalidation.js';\n\nexport { docWithId } from './firestore/types.js';\nexport type {\n FirestoreDocOptions,\n FirestoreCollectionOptions,\n FirestoreInfiniteOptions,\n FirestorePaginatedOptions,\n FirestoreCountOptions,\n FirestoreLiveInfiniteOptions,\n InfinitePage,\n PaginatedPage,\n MutationOperation,\n} from './firestore/types.js';\nexport { flattenInfiniteData, getInfiniteDataCount } from './firestore/infinite-helpers.js';\nexport type { FirestoreSearchOptions } from './search/types.js';\n\nexport { useReadRetryState, useReadRetryStates } from './use-read-retry-state.js';\nexport type { ReadRetryEntry } from './use-read-retry-state.js';\nexport type { ReadRetrySource, ReadRetryState } from './read-retry-derivation.js';\n\nexport {\n MutationSessionProvider,\n MutationSessionEndedError,\n useSessionMutation,\n} from './session-mutation.js';\nexport type {\n MutationSession,\n MutationSessionProviderProps,\n SessionMutateOptions,\n SessionMutationFunctionContext,\n SessionMutationOptions,\n SessionMutationResult,\n UnknownOutcomePolicy,\n} from './session-mutation.js';\n\nexport { createCallables, MAX_RESUMABLE_CALLS } from './callables/create-callables.js';\nexport type {\n CallableCaptureContext,\n CallableDeclaration,\n CallableErrorRouting,\n CallableMutationOptions,\n CallablePolicy,\n Callables,\n ResumableOutcome,\n} from './callables/create-callables.js';\n\nexport {\n usePendingMutationVariables,\n pendingMutationVariables,\n usePendingMutationTargets,\n hasPendingMutation,\n duplicateSubmissionError,\n useDuplicateGuardedMutation,\n} from './pending-mutations.js';\n\nexport {\n APP_CONFIG_BACKGROUND_RETRY_MS,\n APP_CONFIG_MAX_QUICK_ATTEMPTS,\n createAppConfig,\n} from './app-config/create-app-config.js';\nexport type {\n AppConfig,\n AppConfigDefinition,\n AppConfigLeverOf,\n AppConfigSnapshotState,\n AppConfigState,\n AppConfigStatus,\n StoredAppConfig,\n} from './app-config/create-app-config.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/query-core",
3
- "version": "0.14.30",
3
+ "version": "0.14.31",
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",
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "@ttt-productions/firebase-helpers": "^0.12.22"
67
+ "@ttt-productions/firebase-helpers": "^0.12.23"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@tanstack/react-query": "^5.90.0",