nextjs-cms 0.9.21 → 0.9.23
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 +65 -13
- package/dist/api/actions/files.d.ts +30 -0
- package/dist/api/actions/files.d.ts.map +1 -0
- package/dist/api/actions/files.js +234 -0
- package/dist/api/actions/index.d.ts +4 -0
- package/dist/api/actions/index.d.ts.map +1 -0
- package/dist/api/actions/index.js +3 -0
- package/dist/api/actions/pages.d.ts +297 -0
- package/dist/api/actions/pages.d.ts.map +1 -0
- package/dist/api/actions/pages.js +1215 -0
- package/dist/api/actions/privileges.d.ts +25 -0
- package/dist/api/actions/privileges.d.ts.map +1 -0
- package/dist/api/actions/privileges.js +98 -0
- package/dist/api/client/index.d.ts +4 -0
- package/dist/api/client/index.d.ts.map +1 -0
- package/dist/api/client/index.js +3 -0
- package/dist/api/client.d.ts +30 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +82 -0
- package/dist/api/index.d.ts +1 -938
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -13
- package/dist/api/lib/serverActions.d.ts +3 -3
- package/dist/api/plugin/index.d.ts +7 -0
- package/dist/api/plugin/index.d.ts.map +1 -0
- package/dist/api/plugin/index.js +5 -0
- package/dist/api/root.d.ts +18 -1844
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +18 -83
- package/dist/api/routers/navigation.d.ts +3 -3
- package/dist/api/server/index.d.ts +8 -0
- package/dist/api/server/index.d.ts.map +1 -0
- package/dist/api/server/index.js +3 -0
- package/dist/api/server.d.ts +2748 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +100 -0
- package/dist/api/trpc/client.d.ts +19 -3
- package/dist/api/trpc/client.d.ts.map +1 -1
- package/dist/api/trpc/client.js +55 -1
- package/dist/api/trpc/query-client.d.ts +3 -1
- package/dist/api/trpc/query-client.d.ts.map +1 -1
- package/dist/api/trpc/query-client.js +25 -20
- package/dist/api/trpc/root.d.ts +906 -0
- package/dist/api/trpc/root.d.ts.map +1 -0
- package/dist/api/trpc/root.js +47 -0
- package/dist/api/trpc/routers/accountSettings.d.ts +66 -0
- package/dist/api/trpc/routers/accountSettings.d.ts.map +1 -0
- package/dist/api/trpc/routers/accountSettings.js +200 -0
- package/dist/api/trpc/routers/admins.d.ts +112 -0
- package/dist/api/trpc/routers/admins.d.ts.map +1 -0
- package/dist/api/trpc/routers/admins.js +331 -0
- package/dist/api/trpc/routers/auth.d.ts +54 -0
- package/dist/api/trpc/routers/auth.d.ts.map +1 -0
- package/dist/api/trpc/routers/auth.js +50 -0
- package/dist/api/trpc/routers/categorySection.d.ts +105 -0
- package/dist/api/trpc/routers/categorySection.d.ts.map +1 -0
- package/dist/api/trpc/routers/categorySection.js +49 -0
- package/dist/api/trpc/routers/config.d.ts +48 -0
- package/dist/api/trpc/routers/config.d.ts.map +1 -0
- package/dist/api/trpc/routers/config.js +18 -0
- package/dist/api/trpc/routers/cpanel.d.ts +82 -0
- package/dist/api/trpc/routers/cpanel.d.ts.map +1 -0
- package/dist/api/trpc/routers/cpanel.js +216 -0
- package/dist/api/trpc/routers/fields.d.ts +35 -0
- package/dist/api/trpc/routers/fields.d.ts.map +1 -0
- package/dist/api/trpc/routers/fields.js +81 -0
- package/dist/api/trpc/routers/files.d.ts +34 -0
- package/dist/api/trpc/routers/files.d.ts.map +1 -0
- package/dist/api/trpc/routers/files.js +14 -0
- package/dist/api/trpc/routers/gallery.d.ts +35 -0
- package/dist/api/trpc/routers/gallery.d.ts.map +1 -0
- package/dist/api/trpc/routers/gallery.js +92 -0
- package/dist/api/trpc/routers/hasItemsSection.d.ts +194 -0
- package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -0
- package/dist/api/trpc/routers/hasItemsSection.js +86 -0
- package/dist/api/trpc/routers/logs.d.ts +59 -0
- package/dist/api/trpc/routers/logs.d.ts.map +1 -0
- package/dist/api/trpc/routers/logs.js +79 -0
- package/dist/api/trpc/routers/navigation.d.ts +65 -0
- package/dist/api/trpc/routers/navigation.d.ts.map +1 -0
- package/dist/api/trpc/routers/navigation.js +11 -0
- package/dist/api/trpc/routers/simpleSection.d.ts +93 -0
- package/dist/api/trpc/routers/simpleSection.d.ts.map +1 -0
- package/dist/api/trpc/routers/simpleSection.js +54 -0
- package/dist/api/trpc/server.d.ts +2789 -5
- package/dist/api/trpc/server.d.ts.map +1 -1
- package/dist/api/trpc/server.js +91 -52
- package/dist/api/trpc/trpc.d.ts +111 -0
- package/dist/api/trpc/trpc.d.ts.map +1 -0
- package/dist/api/trpc/trpc.js +99 -0
- package/dist/api/trpc/utils/async-caller-proxy.d.ts +2 -0
- package/dist/api/trpc/utils/async-caller-proxy.d.ts.map +1 -0
- package/dist/api/trpc/utils/async-caller-proxy.js +38 -0
- package/dist/api/trpc/utils/refresh-token-link.d.ts +6 -0
- package/dist/api/trpc/utils/refresh-token-link.d.ts.map +1 -0
- package/dist/api/trpc/utils/refresh-token-link.js +81 -0
- package/dist/api/trpc/utils/router-types.d.ts +7 -0
- package/dist/api/trpc/utils/router-types.d.ts.map +1 -0
- package/dist/api/trpc/utils/router-types.js +0 -0
- package/dist/api/use-axios-private.d.ts +6 -0
- package/dist/api/use-axios-private.d.ts.map +1 -0
- package/dist/api/use-axios-private.js +57 -0
- package/dist/api/utils/async-caller-proxy.d.ts +2 -0
- package/dist/api/utils/async-caller-proxy.d.ts.map +1 -0
- package/dist/api/utils/async-caller-proxy.js +36 -0
- package/dist/api/utils/lazy-caller-proxy.d.ts +2 -0
- package/dist/api/utils/lazy-caller-proxy.d.ts.map +1 -0
- package/dist/api/utils/lazy-caller-proxy.js +36 -0
- package/dist/api/utils/router-types.d.ts +7 -0
- package/dist/api/utils/router-types.d.ts.map +1 -0
- package/dist/api/utils/router-types.js +0 -0
- package/dist/auth/hooks/index.d.ts +1 -2
- package/dist/auth/hooks/index.d.ts.map +1 -1
- package/dist/auth/hooks/index.js +1 -2
- package/dist/auth/react.d.ts +1 -2
- package/dist/auth/react.d.ts.map +1 -1
- package/dist/auth/react.js +1 -2
- package/dist/auth/trpc.d.ts +1 -1
- package/dist/auth/trpc.d.ts.map +1 -1
- package/dist/auth/trpc.js +0 -1
- package/dist/cli/lib/fix-master-admin.d.ts.map +1 -1
- package/dist/cli/lib/fix-master-admin.js +12 -25
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +90 -46
- package/dist/core/config/config-loader.d.ts +23 -7
- package/dist/core/config/config-loader.d.ts.map +1 -1
- package/dist/core/config/config-loader.js +26 -9
- package/dist/core/db/table-checker/MysqlTable.d.ts.map +1 -1
- package/dist/core/db/table-checker/MysqlTable.js +3 -1
- package/dist/core/fields/date-range.d.ts +4 -4
- package/dist/core/fields/select.d.ts +1 -1
- package/dist/core/sections/category.d.ts +8 -8
- package/dist/core/sections/hasItems.d.ts +8 -8
- package/dist/core/sections/section.d.ts +5 -5
- package/dist/core/sections/simple.d.ts +4 -4
- package/dist/core/types/index.d.ts +17 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/plugins/client.d.ts +19 -0
- package/dist/plugins/client.d.ts.map +1 -0
- package/dist/plugins/client.js +24 -0
- package/dist/plugins/define.d.ts +4 -0
- package/dist/plugins/define.d.ts.map +1 -0
- package/dist/plugins/define.js +3 -0
- package/dist/plugins/derive.d.ts +32 -0
- package/dist/plugins/derive.d.ts.map +1 -0
- package/dist/plugins/derive.js +77 -0
- package/dist/plugins/loader.d.ts +51 -7
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +111 -51
- package/dist/plugins/manifest.d.ts +28 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +83 -0
- package/dist/plugins/prefetch.d.ts +16 -0
- package/dist/plugins/prefetch.d.ts.map +1 -0
- package/dist/plugins/prefetch.js +40 -0
- package/dist/plugins/registry.d.ts +22 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +25 -0
- package/dist/plugins/server.d.ts +2 -0
- package/dist/plugins/server.d.ts.map +1 -1
- package/dist/plugins/server.js +2 -0
- package/dist/plugins/types.d.ts +9 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +0 -0
- package/dist/translations/base/en.d.ts +5 -0
- package/dist/translations/base/en.d.ts.map +1 -1
- package/dist/translations/base/en.js +5 -0
- package/dist/translations/client.d.ts +64 -4
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/server.d.ts +64 -4
- package/dist/translations/server.d.ts.map +1 -1
- package/dist/utils/console-log.d.ts +18 -0
- package/dist/utils/console-log.d.ts.map +1 -0
- package/dist/utils/console-log.js +28 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/log.d.ts +18 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +28 -0
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +1 -0
- package/dist/validators/tags.d.ts +4 -0
- package/dist/validators/tags.d.ts.map +1 -0
- package/dist/validators/tags.js +8 -0
- package/package.json +36 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAUjE,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEvF,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,YAAY;IAC/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAxF10Z,OAAO,CAAC,SAAS,CAAC;EAqFvD;AAED,YAAY,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import { createHydrationHelpers } from '@trpc/react-query/rsc';
|
|
3
|
+
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
|
|
4
|
+
import { headers } from 'next/headers';
|
|
5
|
+
import { cache } from 'react';
|
|
6
|
+
import { getConfigImportVersion } from '../core/config/index.js';
|
|
7
|
+
import { loadPlugins } from '../plugins/loader.js';
|
|
8
|
+
import { coreRouters } from './root.js';
|
|
9
|
+
import { createCallerFactory, createTRPCContext, router } from './trpc.js';
|
|
10
|
+
import { createQueryClient } from './trpc/query-client.js';
|
|
11
|
+
import { createAsyncCallerProxy } from './utils/async-caller-proxy.js';
|
|
12
|
+
export function createTRPCRouter(opts = {}) {
|
|
13
|
+
const userRouters = (opts.routers ?? {});
|
|
14
|
+
for (const key of Object.keys(userRouters)) {
|
|
15
|
+
if (key in coreRouters) {
|
|
16
|
+
throw new Error(`[trpc] Router key "${key}" conflicts with a core router.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const appRouter = router({
|
|
20
|
+
...coreRouters,
|
|
21
|
+
...userRouters,
|
|
22
|
+
});
|
|
23
|
+
let cachedRouter = null;
|
|
24
|
+
let pendingRouter = null;
|
|
25
|
+
let cachedVersion = -1;
|
|
26
|
+
let pendingVersion = -1;
|
|
27
|
+
async function getMergedRouter() {
|
|
28
|
+
const currentVersion = getConfigImportVersion();
|
|
29
|
+
if (cachedRouter && cachedVersion === currentVersion) {
|
|
30
|
+
return cachedRouter;
|
|
31
|
+
}
|
|
32
|
+
if (pendingRouter && pendingVersion === currentVersion) {
|
|
33
|
+
return pendingRouter;
|
|
34
|
+
}
|
|
35
|
+
cachedRouter = null;
|
|
36
|
+
pendingVersion = currentVersion;
|
|
37
|
+
pendingRouter = (async () => {
|
|
38
|
+
const loadedPlugins = await loadPlugins();
|
|
39
|
+
const pluginRouters = {};
|
|
40
|
+
const seen = new Set([...Object.keys(coreRouters), ...Object.keys(userRouters)]);
|
|
41
|
+
for (const plugin of loadedPlugins) {
|
|
42
|
+
if (!plugin.plugin.router)
|
|
43
|
+
continue;
|
|
44
|
+
if (seen.has(plugin.routerKey)) {
|
|
45
|
+
const message = `[plugins] Router key "${plugin.routerKey}" conflicts with core/user router. Skipping.`;
|
|
46
|
+
throw new Error(message);
|
|
47
|
+
}
|
|
48
|
+
pluginRouters[plugin.routerKey] = plugin.plugin.router;
|
|
49
|
+
seen.add(plugin.routerKey);
|
|
50
|
+
}
|
|
51
|
+
const mergedRouter = router({
|
|
52
|
+
...coreRouters,
|
|
53
|
+
...pluginRouters,
|
|
54
|
+
...userRouters,
|
|
55
|
+
});
|
|
56
|
+
cachedRouter = mergedRouter;
|
|
57
|
+
cachedVersion = currentVersion;
|
|
58
|
+
return mergedRouter;
|
|
59
|
+
})();
|
|
60
|
+
try {
|
|
61
|
+
return await pendingRouter;
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
if (pendingVersion === currentVersion) {
|
|
65
|
+
pendingRouter = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const createContext = cache(async () => {
|
|
70
|
+
const heads = new Headers(await headers());
|
|
71
|
+
heads.set('x-trpc-source', 'rsc');
|
|
72
|
+
return createTRPCContext({
|
|
73
|
+
headers: heads,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const getQueryClient = cache(createQueryClient);
|
|
77
|
+
const getCaller = cache(async () => (await getMergedRouter()).createCaller(await createContext()));
|
|
78
|
+
const callerProxy = createAsyncCallerProxy(getCaller);
|
|
79
|
+
const helpers = createHydrationHelpers(callerProxy, getQueryClient);
|
|
80
|
+
const handler = async (req) => fetchRequestHandler({
|
|
81
|
+
endpoint: '/api/trpc',
|
|
82
|
+
req,
|
|
83
|
+
router: await getMergedRouter(),
|
|
84
|
+
createContext: () => createTRPCContext({ headers: req.headers }),
|
|
85
|
+
onError: opts.onError ??
|
|
86
|
+
(process.env.NODE_ENV === 'development'
|
|
87
|
+
? ({ path, error }) => {
|
|
88
|
+
console.error(`tRPC failed on ${path ?? '<no-path>'}: ${error.message}`);
|
|
89
|
+
}
|
|
90
|
+
: undefined),
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
appRouter,
|
|
94
|
+
handler: { GET: handler, POST: handler },
|
|
95
|
+
api: helpers.trpc,
|
|
96
|
+
HydrateClient: helpers.HydrateClient,
|
|
97
|
+
createCaller: createCallerFactory(appRouter),
|
|
98
|
+
getRouter: getMergedRouter,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { CreateTRPCReact } from '@trpc/react-query';
|
|
2
|
+
import type { AnyRouter } from '@trpc/server';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import type { Session } from '../../auth/index.js';
|
|
6
|
+
import type { SessionProviderProps } from '../../auth/react.js';
|
|
7
|
+
type SessionOptions = Omit<SessionProviderProps, 'children' | 'session'>;
|
|
8
|
+
export interface NextjsCmsProviderProps<TRouter extends AnyRouter> {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
session?: Session | null;
|
|
11
|
+
sessionOptions?: SessionOptions;
|
|
12
|
+
reactQueryDevTools?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NextjsCmsClient<TRouter extends AnyRouter> {
|
|
15
|
+
trpc: CreateTRPCReact<TRouter, unknown>;
|
|
16
|
+
NextjsCmsProvider: (props: NextjsCmsProviderProps<TRouter>) => React.JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export declare function createNextjsCmsClient<TRouter extends AnyRouter>(): NextjsCmsClient<TRouter>;
|
|
19
|
+
export {};
|
|
4
20
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/client.
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/client.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG/D,KAAK,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,SAAS,CAAC,CAAA;AAExE,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,SAAS;IAC7D,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,MAAM,WAAW,eAAe,CAAC,OAAO,SAAS,SAAS;IACtD,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvC,iBAAiB,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAA;CACnF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,KAAK,eAAe,CAAC,OAAO,CAAC,CA6D3F"}
|
package/dist/api/trpc/client.js
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
4
|
+
import { httpBatchLink, loggerLink } from '@trpc/client';
|
|
2
5
|
import { createTRPCReact } from '@trpc/react-query';
|
|
3
|
-
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import SuperJSON from 'superjson';
|
|
9
|
+
import { getCsrfToken, SessionProvider } from '../../auth/react.js';
|
|
10
|
+
import { createQueryClient } from './query-client.js';
|
|
11
|
+
import { refreshTokenLink } from './utils/refresh-token-link.js';
|
|
12
|
+
import { PluginTRPCProvider } from '../../plugins/client.js';
|
|
13
|
+
export function createNextjsCmsClient() {
|
|
14
|
+
const trpc = createTRPCReact();
|
|
15
|
+
const trpcBase = trpc;
|
|
16
|
+
let browserQueryClient;
|
|
17
|
+
function getQueryClient() {
|
|
18
|
+
if (typeof window === 'undefined') {
|
|
19
|
+
return createQueryClient();
|
|
20
|
+
}
|
|
21
|
+
if (!browserQueryClient)
|
|
22
|
+
browserQueryClient = createQueryClient();
|
|
23
|
+
return browserQueryClient;
|
|
24
|
+
}
|
|
25
|
+
function NextjsCmsProvider({ children, session, sessionOptions, reactQueryDevTools, }) {
|
|
26
|
+
const queryClient = getQueryClient();
|
|
27
|
+
const showReactQueryDevTools = reactQueryDevTools ?? process.env.NODE_ENV === 'development';
|
|
28
|
+
const [trpcClient] = useState(() => trpcBase.createClient({
|
|
29
|
+
links: [
|
|
30
|
+
refreshTokenLink(),
|
|
31
|
+
loggerLink({
|
|
32
|
+
enabled: (op) => process.env.NODE_ENV === 'development' ||
|
|
33
|
+
(op.direction === 'down' && op.result instanceof Error),
|
|
34
|
+
}),
|
|
35
|
+
httpBatchLink({
|
|
36
|
+
transformer: SuperJSON,
|
|
37
|
+
url: '/api/trpc',
|
|
38
|
+
async headers(op) {
|
|
39
|
+
const headers = new Headers();
|
|
40
|
+
if (op.opList.some((operation) => operation.type === 'mutation')) {
|
|
41
|
+
const csrfToken = await getCsrfToken();
|
|
42
|
+
headers.set('x-csrf-token', csrfToken);
|
|
43
|
+
}
|
|
44
|
+
headers.set('x-trpc-source', 'nextjs-react');
|
|
45
|
+
return headers;
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
}));
|
|
50
|
+
return (React.createElement(QueryClientProvider, { client: queryClient },
|
|
51
|
+
React.createElement(trpcBase.Provider, { client: trpcClient, queryClient: queryClient },
|
|
52
|
+
React.createElement(SessionProvider, { session: session, ...sessionOptions },
|
|
53
|
+
React.createElement(PluginTRPCProvider, { trpc: trpc }, children)),
|
|
54
|
+
showReactQueryDevTools ? React.createElement(ReactQueryDevtools, { initialIsOpen: false }) : null)));
|
|
55
|
+
}
|
|
56
|
+
return { trpc, NextjsCmsProvider };
|
|
57
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
|
|
2
|
+
import type { QueryClientConfig } from '@tanstack/react-query';
|
|
3
|
+
export declare function createQueryClientOptions(): QueryClientConfig;
|
|
4
|
+
export declare function createQueryClient(): QueryClient;
|
|
3
5
|
//# sourceMappingURL=query-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-client.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,WAAW,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"query-client.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAG9D,wBAAgB,wBAAwB,IAAI,iBAAiB,CAsB5D;AAED,wBAAgB,iBAAiB,gBAEhC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { defaultShouldDehydrateQuery, QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import SuperJSON from 'superjson';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
export function createQueryClientOptions() {
|
|
4
|
+
return {
|
|
5
|
+
defaultOptions: {
|
|
6
|
+
queries: {
|
|
7
|
+
// With SSR, we usually want to set some default staleTime
|
|
8
|
+
// above 0 to avoid refetching immediately on the client
|
|
9
|
+
/**
|
|
10
|
+
* We want to refetch on window focus in development only
|
|
11
|
+
*/
|
|
12
|
+
staleTime: 30 * 1000,
|
|
13
|
+
refetchOnWindowFocus: process.env.NODE_ENV === 'development' ? true : false,
|
|
14
|
+
retry: 1, // default: 3
|
|
15
|
+
},
|
|
16
|
+
dehydrate: {
|
|
17
|
+
serializeData: SuperJSON.serialize,
|
|
18
|
+
shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === 'pending',
|
|
19
|
+
},
|
|
20
|
+
hydrate: {
|
|
21
|
+
deserializeData: SuperJSON.deserialize,
|
|
22
|
+
},
|
|
14
23
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
deserializeData: SuperJSON.deserialize,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function createQueryClient() {
|
|
27
|
+
return new QueryClient(createQueryClientOptions());
|
|
28
|
+
}
|