@ttt-productions/query-core 0.1.6
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/README.md +10 -0
- package/dist/cache-helpers.d.ts +11 -0
- package/dist/cache-helpers.d.ts.map +1 -0
- package/dist/cache-helpers.js +16 -0
- package/dist/cache-helpers.js.map +1 -0
- package/dist/defaults.d.ts +8 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +21 -0
- package/dist/defaults.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +34 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +37 -0
- package/dist/keys.js.map +1 -0
- package/dist/provider.d.ts +12 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +14 -0
- package/dist/provider.js.map +1 -0
- package/dist/query-client.d.ts +8 -0
- package/dist/query-client.d.ts.map +1 -0
- package/dist/query-client.js +25 -0
- package/dist/query-client.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @ttt-productions/query-core
|
|
2
|
+
|
|
3
|
+
Shared TanStack Query (React Query) setup for TTT Productions apps.
|
|
4
|
+
|
|
5
|
+
- `createTTTQueryClient()` factory with safe defaults
|
|
6
|
+
- `keys` query key helpers
|
|
7
|
+
- invalidation + cache update helpers
|
|
8
|
+
- `TTTQueryProvider` for Next.js/React apps
|
|
9
|
+
|
|
10
|
+
No app business logic. No Firebase.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { QueryClient, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
/** Invalidate everything that matches a key prefix. */
|
|
3
|
+
export declare function invalidateByPrefix(client: QueryClient, prefix: QueryKey): Promise<void>;
|
|
4
|
+
/** Remove everything that matches a key prefix (drops cached data). */
|
|
5
|
+
export declare function removeByPrefix(client: QueryClient, prefix: QueryKey): void;
|
|
6
|
+
/**
|
|
7
|
+
* Generic cache update helper.
|
|
8
|
+
* Useful for optimistic updates without baking in business logic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateQueryData<T>(client: QueryClient, key: QueryKey, updater: (prev: T | undefined) => T): void;
|
|
11
|
+
//# sourceMappingURL=cache-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-helpers.d.ts","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnE,uDAAuD;AACvD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,iBAE7E;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,QAEnE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,QAGpC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Invalidate everything that matches a key prefix. */
|
|
2
|
+
export async function invalidateByPrefix(client, prefix) {
|
|
3
|
+
return client.invalidateQueries({ queryKey: prefix, exact: false });
|
|
4
|
+
}
|
|
5
|
+
/** Remove everything that matches a key prefix (drops cached data). */
|
|
6
|
+
export function removeByPrefix(client, prefix) {
|
|
7
|
+
return client.removeQueries({ queryKey: prefix, exact: false });
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generic cache update helper.
|
|
11
|
+
* Useful for optimistic updates without baking in business logic.
|
|
12
|
+
*/
|
|
13
|
+
export function updateQueryData(client, key, updater) {
|
|
14
|
+
client.setQueryData(key, (prev) => updater(prev));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=cache-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-helpers.js","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAmB,EAAE,MAAgB;IAC5E,OAAO,MAAM,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,MAAgB;IAClE,OAAO,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAmB,EACnB,GAAa,EACb,OAAmC;IAEnC,MAAM,CAAC,YAAY,CAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DefaultOptions, QueryClientConfig } from '@tanstack/react-query';
|
|
2
|
+
/**
|
|
3
|
+
* Small, conservative defaults intended to work well across apps.
|
|
4
|
+
* Apps can override via `createTTTQueryClient({ defaultOptions: ... })`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tttDefaultOptions: DefaultOptions;
|
|
7
|
+
export declare const tttQueryClientConfig: QueryClientConfig;
|
|
8
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,cAc/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,iBAElC,CAAC"}
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small, conservative defaults intended to work well across apps.
|
|
3
|
+
* Apps can override via `createTTTQueryClient({ defaultOptions: ... })`.
|
|
4
|
+
*/
|
|
5
|
+
export const tttDefaultOptions = {
|
|
6
|
+
queries: {
|
|
7
|
+
refetchOnWindowFocus: false,
|
|
8
|
+
refetchOnReconnect: true,
|
|
9
|
+
refetchOnMount: false,
|
|
10
|
+
staleTime: 30_000, // 30s
|
|
11
|
+
gcTime: 5 * 60_000, // 5m
|
|
12
|
+
retry: (failureCount) => failureCount < 2,
|
|
13
|
+
},
|
|
14
|
+
mutations: {
|
|
15
|
+
retry: 0,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const tttQueryClientConfig = {
|
|
19
|
+
defaultOptions: tttDefaultOptions,
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,OAAO,EAAE;QACP,oBAAoB,EAAE,KAAK;QAC3B,kBAAkB,EAAE,IAAI;QACxB,cAAc,EAAE,KAAK;QAErB,SAAS,EAAE,MAAM,EAAE,MAAM;QACzB,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,KAAK;QAEzB,KAAK,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,GAAG,CAAC;KAC1C;IACD,SAAS,EAAE;QACT,KAAK,EAAE,CAAC;KACT;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,cAAc,EAAE,iBAAiB;CAClC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createTTTQueryClient } from './query-client';
|
|
2
|
+
export type { CreateTTTQueryClientOptions } from './query-client';
|
|
3
|
+
export { keys, createKeyScope } from './keys';
|
|
4
|
+
export type { QueryKey } from './keys';
|
|
5
|
+
export { invalidateByPrefix, removeByPrefix, updateQueryData } from './cache-helpers';
|
|
6
|
+
export { TTTQueryProvider } from './provider';
|
|
7
|
+
export type { TTTQueryProviderProps } from './provider';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createTTTQueryClient } from './query-client';
|
|
2
|
+
export { keys, createKeyScope } from './keys';
|
|
3
|
+
export { invalidateByPrefix, removeByPrefix, updateQueryData } from './cache-helpers';
|
|
4
|
+
export { TTTQueryProvider } from './provider';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight, stable query key helpers.
|
|
3
|
+
*
|
|
4
|
+
* Convention:
|
|
5
|
+
* - `keys.user.all` => ['user']
|
|
6
|
+
* - `keys.user.detail(id)` => ['user', 'detail', id]
|
|
7
|
+
* - `keys.user.list(filters?)` => ['user', 'list', filters]
|
|
8
|
+
*/
|
|
9
|
+
type KeyPart = string | number | boolean | null | undefined | Record<string, unknown>;
|
|
10
|
+
export type QueryKey = readonly unknown[];
|
|
11
|
+
export declare const keys: {
|
|
12
|
+
readonly user: {
|
|
13
|
+
readonly all: QueryKey;
|
|
14
|
+
readonly detail: (id: string) => QueryKey;
|
|
15
|
+
readonly list: (params?: Record<string, unknown>) => QueryKey;
|
|
16
|
+
};
|
|
17
|
+
readonly project: {
|
|
18
|
+
readonly all: QueryKey;
|
|
19
|
+
readonly detail: (id: string) => QueryKey;
|
|
20
|
+
readonly list: (params?: Record<string, unknown>) => QueryKey;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Utility for apps that want to define their own scoped key sets
|
|
25
|
+
* while following the same conventions.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createKeyScope(scope: string): {
|
|
28
|
+
readonly all: QueryKey;
|
|
29
|
+
readonly detail: (id: string) => QueryKey;
|
|
30
|
+
readonly list: (params?: Record<string, unknown>) => QueryKey;
|
|
31
|
+
readonly custom: (...parts: KeyPart[]) => QueryKey;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtF,MAAM,MAAM,QAAQ,GAAG,SAAS,OAAO,EAAE,CAAC;AAO1C,eAAO,MAAM,IAAI;;;8BAGA,MAAM;iCACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;8BAI1B,MAAM;iCACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAEjC,CAAC;AAEX;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM;;0BAG3B,MAAM;6BACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gCACpB,OAAO,EAAE;EAE/B"}
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight, stable query key helpers.
|
|
3
|
+
*
|
|
4
|
+
* Convention:
|
|
5
|
+
* - `keys.user.all` => ['user']
|
|
6
|
+
* - `keys.user.detail(id)` => ['user', 'detail', id]
|
|
7
|
+
* - `keys.user.list(filters?)` => ['user', 'list', filters]
|
|
8
|
+
*/
|
|
9
|
+
function withScope(scope, ...parts) {
|
|
10
|
+
const cleaned = parts.filter((p) => p !== undefined);
|
|
11
|
+
return [scope, ...cleaned];
|
|
12
|
+
}
|
|
13
|
+
export const keys = {
|
|
14
|
+
user: {
|
|
15
|
+
all: withScope('user'),
|
|
16
|
+
detail: (id) => withScope('user', 'detail', id),
|
|
17
|
+
list: (params) => withScope('user', 'list', params),
|
|
18
|
+
},
|
|
19
|
+
project: {
|
|
20
|
+
all: withScope('project'),
|
|
21
|
+
detail: (id) => withScope('project', 'detail', id),
|
|
22
|
+
list: (params) => withScope('project', 'list', params),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Utility for apps that want to define their own scoped key sets
|
|
27
|
+
* while following the same conventions.
|
|
28
|
+
*/
|
|
29
|
+
export function createKeyScope(scope) {
|
|
30
|
+
return {
|
|
31
|
+
all: withScope(scope),
|
|
32
|
+
detail: (id) => withScope(scope, 'detail', id),
|
|
33
|
+
list: (params) => withScope(scope, 'list', params),
|
|
34
|
+
custom: (...parts) => withScope(scope, ...parts),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,SAAS,SAAS,CAAC,KAAa,EAAE,GAAG,KAAgB;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACrD,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,CAAU,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE;QACJ,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC;QACtB,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QACvD,IAAI,EAAE,CAAC,MAAgC,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KAC9E;IACD,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC;QACzB,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC1D,IAAI,EAAE,CAAC,MAAgC,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;KACjF;CACO,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO;QACL,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC;QACrB,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;QACtD,IAAI,EAAE,CAAC,MAAgC,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;QAC5E,MAAM,EAAE,CAAC,GAAG,KAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC;KACnD,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CreateTTTQueryClientOptions } from './query-client';
|
|
3
|
+
export type TTTQueryProviderProps = React.PropsWithChildren<{
|
|
4
|
+
/** Optional overrides applied when the client is first created. */
|
|
5
|
+
clientOptions?: CreateTTTQueryClientOptions;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Client component wrapper for Next.js / React apps.
|
|
9
|
+
* Creates a single QueryClient per browser session.
|
|
10
|
+
*/
|
|
11
|
+
export declare function TTTQueryProvider({ children, clientOptions }: TTTQueryProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAwB,KAAK,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAExF,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAC1D,mEAAmE;IACnE,aAAa,CAAC,EAAE,2BAA2B,CAAC;CAC7C,CAAC,CAAC;AAEH;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,qBAAqB,2CAGlF"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
5
|
+
import { createTTTQueryClient } from './query-client';
|
|
6
|
+
/**
|
|
7
|
+
* Client component wrapper for Next.js / React apps.
|
|
8
|
+
* Creates a single QueryClient per browser session.
|
|
9
|
+
*/
|
|
10
|
+
export function TTTQueryProvider({ children, clientOptions }) {
|
|
11
|
+
const [client] = React.useState(() => createTTTQueryClient(clientOptions));
|
|
12
|
+
return _jsx(QueryClientProvider, { client: client, children: children });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAoC,MAAM,gBAAgB,CAAC;AAOxF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAyB;IACjF,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3E,OAAO,KAAC,mBAAmB,IAAC,MAAM,EAAE,MAAM,YAAG,QAAQ,GAAuB,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QueryClient, type QueryClientConfig } from '@tanstack/react-query';
|
|
2
|
+
export type CreateTTTQueryClientOptions = QueryClientConfig;
|
|
3
|
+
/**
|
|
4
|
+
* Factory so every app uses the same baseline behavior.
|
|
5
|
+
* Pass overrides to adjust defaults without forking.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTTTQueryClient(overrides?: CreateTTTQueryClientOptions): QueryClient;
|
|
8
|
+
//# sourceMappingURL=query-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-client.d.ts","sourceRoot":"","sources":["../src/query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,GAAE,2BAAgC,eAiB/E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { tttQueryClientConfig } from './defaults';
|
|
3
|
+
/**
|
|
4
|
+
* Factory so every app uses the same baseline behavior.
|
|
5
|
+
* Pass overrides to adjust defaults without forking.
|
|
6
|
+
*/
|
|
7
|
+
export function createTTTQueryClient(overrides = {}) {
|
|
8
|
+
return new QueryClient({
|
|
9
|
+
...tttQueryClientConfig,
|
|
10
|
+
...overrides,
|
|
11
|
+
defaultOptions: {
|
|
12
|
+
...tttQueryClientConfig.defaultOptions,
|
|
13
|
+
...overrides.defaultOptions,
|
|
14
|
+
queries: {
|
|
15
|
+
...tttQueryClientConfig.defaultOptions?.queries,
|
|
16
|
+
...overrides.defaultOptions?.queries,
|
|
17
|
+
},
|
|
18
|
+
mutations: {
|
|
19
|
+
...tttQueryClientConfig.defaultOptions?.mutations,
|
|
20
|
+
...overrides.defaultOptions?.mutations,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=query-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-client.js","sourceRoot":"","sources":["../src/query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA0B,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIlD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAyC,EAAE;IAC9E,OAAO,IAAI,WAAW,CAAC;QACrB,GAAG,oBAAoB;QACvB,GAAG,SAAS;QACZ,cAAc,EAAE;YACd,GAAG,oBAAoB,CAAC,cAAc;YACtC,GAAG,SAAS,CAAC,cAAc;YAC3B,OAAO,EAAE;gBACP,GAAG,oBAAoB,CAAC,cAAc,EAAE,OAAO;gBAC/C,GAAG,SAAS,CAAC,cAAc,EAAE,OAAO;aACrC;YACD,SAAS,EAAE;gBACT,GAAG,oBAAoB,CAAC,cAAc,EAAE,SAAS;gBACjD,GAAG,SAAS,CAAC,cAAc,EAAE,SAAS;aACvC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ttt-productions/query-core",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "Shared TanStack Query (React Query) client defaults + query key helpers for TTT Productions apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@tanstack/react-query": "^5.0.0",
|
|
25
|
+
"react": "^19.0.0",
|
|
26
|
+
"react-dom": "^19.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@tanstack/react-query": "^5.0.0",
|
|
30
|
+
"@types/react": "^19.0.0",
|
|
31
|
+
"@types/react-dom": "^19.0.0",
|
|
32
|
+
"react": "^19.2.0",
|
|
33
|
+
"react-dom": "^19.2.0",
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
|
+
},
|
|
36
|
+
"author": "DJ (TTT Productions)",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
41
|
+
"directory": "packages/query-core"
|
|
42
|
+
}
|
|
43
|
+
}
|