cloudflare-next-intl 0.9.9 → 0.9.11
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
CHANGED
|
@@ -940,9 +940,11 @@ allowed to see the rows; call `.transaction(...)` on the handle either one
|
|
|
940
940
|
hands your callback when a write needs more than one statement to succeed or
|
|
941
941
|
fail together (see [Multi-statement transactions](#multi-statement-transactions-dbtransaction) above):
|
|
942
942
|
|
|
943
|
-
- `withPublicDb(fn, dbOverride?)` — runs `fn` as the
|
|
944
|
-
connection
|
|
945
|
-
|
|
943
|
+
- `withPublicDb(fn, dbOverride?)` — runs `fn` as the `anon` Postgres role.
|
|
944
|
+
In connection-string mode (Hyperdrive) the connection-string user is
|
|
945
|
+
temporarily downgraded to `anon` via `SET LOCAL ROLE anon` before your
|
|
946
|
+
callback executes, so RLS policies apply identically to the Supabase-mode
|
|
947
|
+
path (where the anon key is the PostgREST bearer token). No user id is
|
|
946
948
|
attached either way, so RLS policies that test `auth.jwt()->>'sub'` will
|
|
947
949
|
deny access — use `withUserDb` for user-owned rows.
|
|
948
950
|
- `withUserDb(fn, uid?, dbOverride?)` — runs `fn` as the signed-in user. In
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Usage: cfni-check-dynamic-pages [--app-dir=src/app] [--mode=off|report|fix] [--skip=a/page.tsx,b/page.tsx]
|
|
3
|
-
// Env equivalents: CFNI_DYNAMIC_PAGES_APP_DIR, CFNI_DYNAMIC_PAGES_MODE, CFNI_DYNAMIC_PAGES_SKIP (comma-separated).
|
|
2
|
+
// Usage: cfni-check-dynamic-pages [--app-dir=src/app] [--mode=off|report|fix] [--target=next|vinext] [--skip=a/page.tsx,b/page.tsx]
|
|
3
|
+
// Env equivalents: CFNI_DYNAMIC_PAGES_APP_DIR, CFNI_DYNAMIC_PAGES_MODE, CFNI_DYNAMIC_PAGES_TARGET, CFNI_DYNAMIC_PAGES_SKIP (comma-separated).
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { checkDynamicPages } from '../dist/src/dynamic_pages_check/check_dynamic_pages.js';
|
|
6
6
|
|
|
@@ -12,10 +12,11 @@ function argValue(name) {
|
|
|
12
12
|
|
|
13
13
|
const appDir = resolve(argValue('app-dir') ?? process.env.CFNI_DYNAMIC_PAGES_APP_DIR ?? 'src/app');
|
|
14
14
|
const mode = argValue('mode') ?? process.env.CFNI_DYNAMIC_PAGES_MODE ?? 'report';
|
|
15
|
+
const target = argValue('target') ?? process.env.CFNI_DYNAMIC_PAGES_TARGET ?? 'next';
|
|
15
16
|
const skipRaw = argValue('skip') ?? process.env.CFNI_DYNAMIC_PAGES_SKIP ?? '';
|
|
16
17
|
const skip = skipRaw.split(',').map((s) => s.trim()).filter(Boolean).map((s) => resolve(s));
|
|
17
18
|
|
|
18
|
-
const reports = await checkDynamicPages({ appDir, mode, skip });
|
|
19
|
+
const reports = await checkDynamicPages({ appDir, mode, target, skip });
|
|
19
20
|
|
|
20
21
|
if (reports.length === 0) {
|
|
21
22
|
console.log(mode === 'off' ? 'checkDynamicPages: disabled (mode=off).' : `checkDynamicPages: no page/route files found under ${appDir}.`);
|
package/dist/src/db/context.js
CHANGED
|
@@ -108,6 +108,7 @@ export async function withPublicDb(fn, dbOverride) {
|
|
|
108
108
|
return await withDbClient(config, async (client) => {
|
|
109
109
|
const { drizzle } = await import('drizzle-orm/node-postgres');
|
|
110
110
|
const drizzleHandle = drizzle(client);
|
|
111
|
+
await client.query(`set local role anon`);
|
|
111
112
|
return await fn(await postgresDb(drizzleHandle, client));
|
|
112
113
|
});
|
|
113
114
|
}
|
|
@@ -2,11 +2,12 @@ export type DynamicPagesCheckMode = 'off' | 'report' | 'fix';
|
|
|
2
2
|
export interface CheckDynamicPagesOptions {
|
|
3
3
|
appDir: string;
|
|
4
4
|
mode?: DynamicPagesCheckMode;
|
|
5
|
+
target?: 'next' | 'vinext';
|
|
5
6
|
skip?: readonly string[];
|
|
6
7
|
}
|
|
7
8
|
export interface CheckDynamicPagesReport {
|
|
8
9
|
file: string;
|
|
9
|
-
action: 'added-force-dynamic' | 'would-add-force-dynamic' | 'already-declared' | 'no-dynamic-usage-detected' | 'skipped';
|
|
10
|
+
action: 'added-force-dynamic' | 'would-add-force-dynamic' | 'added-force-static' | 'would-add-force-static' | 'already-declared' | 'no-dynamic-usage-detected' | 'skipped';
|
|
10
11
|
}
|
|
11
12
|
export interface CheckDynamicPagesIo {
|
|
12
13
|
findPageFiles?: (appDir: string) => string[];
|
|
@@ -6,6 +6,7 @@ export async function checkDynamicPages(options, io = {}) {
|
|
|
6
6
|
const mode = options.mode ?? 'report';
|
|
7
7
|
if (mode === 'off')
|
|
8
8
|
return [];
|
|
9
|
+
const target = options.target ?? 'next';
|
|
9
10
|
const findPageFiles = io.findPageFiles ?? findPageFilesImpl;
|
|
10
11
|
const readFile = io.readFile ?? ((file) => readFileSync(file, 'utf8'));
|
|
11
12
|
const writeFile = io.writeFile ?? ((file, contents) => writeFileSync(file, contents, 'utf8'));
|
|
@@ -23,7 +24,17 @@ export async function checkDynamicPages(options, io = {}) {
|
|
|
23
24
|
continue;
|
|
24
25
|
}
|
|
25
26
|
if (detection.detectedDynamicApis.length === 0) {
|
|
26
|
-
|
|
27
|
+
if (target !== 'vinext') {
|
|
28
|
+
reports.push({ file, action: 'no-dynamic-usage-detected' });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (mode === 'fix') {
|
|
32
|
+
writeFile(file, insertDynamicExport(source, 'force-static'));
|
|
33
|
+
reports.push({ file, action: 'added-force-static' });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
reports.push({ file, action: 'would-add-force-static' });
|
|
37
|
+
}
|
|
27
38
|
continue;
|
|
28
39
|
}
|
|
29
40
|
if (mode === 'fix') {
|