@nextsparkjs/core 0.1.0-beta.140 → 0.1.0-beta.142
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/components/dashboard/layouts/DashboardAuthLayout.d.ts +7 -0
- package/dist/components/dashboard/layouts/DashboardAuthLayout.d.ts.map +1 -0
- package/dist/components/dashboard/layouts/DashboardAuthLayout.js +44 -0
- package/dist/components/dashboard/layouts/index.d.ts +1 -0
- package/dist/components/dashboard/layouts/index.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/index.js +2 -0
- package/dist/lib/api/entity/generic-handler.d.ts.map +1 -1
- package/dist/lib/api/entity/generic-handler.js +33 -0
- package/dist/styles/classes.json +1 -1
- package/package.json +2 -2
- package/scripts/build/registry/generators/translation-registry.mjs +19 -53
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardAuthLayout.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/DashboardAuthLayout.tsx"],"names":[],"mappings":"AA2EA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,2CAEA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useAuth } from "../../../hooks/useAuth.js";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { useEffect, Suspense } from "react";
|
|
6
|
+
import { Loader2 } from "lucide-react";
|
|
7
|
+
import { DashboardTranslationPreloader } from "../../../lib/i18n/DashboardTranslationPreloader.js";
|
|
8
|
+
import { TranslationDebugger } from "../../../utils/dev/TranslationDebugger.js";
|
|
9
|
+
import { useEnsureUserMetadata } from "../../../hooks/useEnsureUserMetadata.js";
|
|
10
|
+
import { useAuthMethodDetector } from "../../../hooks/useAuthMethodDetector.js";
|
|
11
|
+
function AuthMethodDetectorWrapper() {
|
|
12
|
+
useAuthMethodDetector();
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function DashboardLayoutContent({ children }) {
|
|
16
|
+
const { user, isLoading } = useAuth();
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
useEnsureUserMetadata();
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isLoading && !user) {
|
|
21
|
+
router.push("/login");
|
|
22
|
+
}
|
|
23
|
+
}, [user, isLoading, router]);
|
|
24
|
+
if (isLoading) {
|
|
25
|
+
return /* @__PURE__ */ jsx("div", { className: "min-h-screen flex items-center justify-center", children: /* @__PURE__ */ jsx(Loader2, { className: "h-8 w-8 animate-spin text-muted-foreground" }) });
|
|
26
|
+
}
|
|
27
|
+
if (!user) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx(DashboardTranslationPreloader, {}, "dashboard-translation-preloader"),
|
|
32
|
+
/* @__PURE__ */ jsx(TranslationDebugger, {}, "translation-debugger"),
|
|
33
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(AuthMethodDetectorWrapper, {}) }, "auth-method-detector"),
|
|
34
|
+
/* @__PURE__ */ jsx("div", { "data-cy": "dashboard-container", children }, "dashboard-children")
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
function DashboardAuthLayout({
|
|
38
|
+
children
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ jsx(DashboardLayoutContent, { children });
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
DashboardAuthLayout
|
|
44
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AuthGuard } from "./AuthGuard.js";
|
|
2
|
+
import { DashboardAuthLayout } from "./DashboardAuthLayout.js";
|
|
2
3
|
import { DashboardShell } from "./DashboardShell.js";
|
|
3
4
|
import { Sidebar } from "./Sidebar.js";
|
|
4
5
|
import { TopNavbar } from "./TopNavbar.js";
|
|
5
6
|
export {
|
|
6
7
|
AuthGuard,
|
|
8
|
+
DashboardAuthLayout,
|
|
7
9
|
DashboardShell,
|
|
8
10
|
Sidebar,
|
|
9
11
|
TopNavbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-handler.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/entity/generic-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAqYvD;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAwdnF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"generic-handler.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/entity/generic-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAqYvD;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAwdnF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CA+VrF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CA+KpJ;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAuTtJ;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAgJtJ;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAEtF"}
|
|
@@ -762,6 +762,17 @@ async function handleGenericCreate(request) {
|
|
|
762
762
|
return addCorsHeaders(response, request);
|
|
763
763
|
} catch (error) {
|
|
764
764
|
console.error("Error in generic create handler:", error);
|
|
765
|
+
if (error && typeof error === "object" && "code" in error && error.code === "23505") {
|
|
766
|
+
const detail = "detail" in error ? error.detail : void 0;
|
|
767
|
+
const constraint = "constraint" in error ? error.constraint : void 0;
|
|
768
|
+
const response2 = createApiError(
|
|
769
|
+
"A record with this value already exists",
|
|
770
|
+
409,
|
|
771
|
+
{ constraint, detail },
|
|
772
|
+
"UNIQUE_CONSTRAINT_VIOLATION"
|
|
773
|
+
);
|
|
774
|
+
return addCorsHeaders(response2, request);
|
|
775
|
+
}
|
|
765
776
|
const response = createApiError("Internal server error", 500);
|
|
766
777
|
return addCorsHeaders(response, request);
|
|
767
778
|
}
|
|
@@ -1091,6 +1102,17 @@ async function handleGenericUpdate(request, { params }) {
|
|
|
1091
1102
|
return addCorsHeaders(response, request);
|
|
1092
1103
|
} catch (error) {
|
|
1093
1104
|
console.error("Error in generic update handler:", error);
|
|
1105
|
+
if (error && typeof error === "object" && "code" in error && error.code === "23505") {
|
|
1106
|
+
const detail = "detail" in error ? error.detail : void 0;
|
|
1107
|
+
const constraint = "constraint" in error ? error.constraint : void 0;
|
|
1108
|
+
const response2 = createApiError(
|
|
1109
|
+
"A record with this value already exists",
|
|
1110
|
+
409,
|
|
1111
|
+
{ constraint, detail },
|
|
1112
|
+
"UNIQUE_CONSTRAINT_VIOLATION"
|
|
1113
|
+
);
|
|
1114
|
+
return addCorsHeaders(response2, request);
|
|
1115
|
+
}
|
|
1094
1116
|
const response = createApiError("Internal server error", 500);
|
|
1095
1117
|
return addCorsHeaders(response, request);
|
|
1096
1118
|
}
|
|
@@ -1189,6 +1211,17 @@ async function handleGenericDelete(request, { params }) {
|
|
|
1189
1211
|
return addCorsHeaders(response, request);
|
|
1190
1212
|
} catch (error) {
|
|
1191
1213
|
console.error("Error in generic delete handler:", error);
|
|
1214
|
+
if (error && typeof error === "object" && "code" in error && error.code === "23503") {
|
|
1215
|
+
const detail = "detail" in error ? error.detail : void 0;
|
|
1216
|
+
const constraint = "constraint" in error ? error.constraint : void 0;
|
|
1217
|
+
const response2 = createApiError(
|
|
1218
|
+
detail || "Cannot delete: this record is referenced by other records",
|
|
1219
|
+
409,
|
|
1220
|
+
{ constraint },
|
|
1221
|
+
"FOREIGN_KEY_VIOLATION"
|
|
1222
|
+
);
|
|
1223
|
+
return addCorsHeaders(response2, request);
|
|
1224
|
+
}
|
|
1192
1225
|
const response = createApiError("Internal server error", 500);
|
|
1193
1226
|
return addCorsHeaders(response, request);
|
|
1194
1227
|
}
|
package/dist/styles/classes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.142",
|
|
4
4
|
"description": "NextSpark - The complete SaaS framework for Next.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "NextSpark <hello@nextspark.dev>",
|
|
@@ -463,7 +463,7 @@
|
|
|
463
463
|
"tailwind-merge": "^3.3.1",
|
|
464
464
|
"uuid": "^13.0.0",
|
|
465
465
|
"zod": "^4.1.5",
|
|
466
|
-
"@nextsparkjs/testing": "0.1.0-beta.
|
|
466
|
+
"@nextsparkjs/testing": "0.1.0-beta.142"
|
|
467
467
|
},
|
|
468
468
|
"scripts": {
|
|
469
469
|
"postinstall": "node scripts/postinstall.mjs || true",
|
|
@@ -495,71 +495,37 @@ ${(() => {
|
|
|
495
495
|
|
|
496
496
|
console.log(`[TranslationRegistry] PPR enabled — generating static exports for locale '${defaultLocale}'`)
|
|
497
497
|
|
|
498
|
-
//
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
)
|
|
502
|
-
|
|
503
|
-
//
|
|
504
|
-
//
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
t => t.locale === defaultLocale && !themeEntityNames.has(t.entityName)
|
|
508
|
-
)
|
|
509
|
-
|
|
510
|
-
const allEntityTranslations = [...defaultLocaleEntityTranslations, ...defaultLocalePluginEntityTranslations]
|
|
511
|
-
|
|
512
|
-
// Generate import statements for entity translations
|
|
513
|
-
const entityImports = allEntityTranslations.map((t, i) => {
|
|
514
|
-
const varName = `_entity${i}Messages`
|
|
515
|
-
return `import ${varName} from '${t.filePath}'`
|
|
516
|
-
}).join('\n')
|
|
517
|
-
|
|
518
|
-
// Generate the entity messages object entries
|
|
519
|
-
const entityEntries = allEntityTranslations.map((t, i) => {
|
|
520
|
-
const varName = `_entity${i}Messages`
|
|
521
|
-
return ` '${t.entityName}': ${varName}`
|
|
522
|
-
}).join(',\n')
|
|
523
|
-
|
|
524
|
-
const hasEntities = allEntityTranslations.length > 0
|
|
525
|
-
const entityImportsBlock = hasEntities ? `\n// Entity and plugin entity translations (default locale)\n${entityImports}\n` : ''
|
|
526
|
-
const entityMergeBlock = hasEntities
|
|
527
|
-
? `
|
|
528
|
-
const _entityMessages: Record<string, unknown> = {
|
|
529
|
-
${entityEntries}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
export const STATIC_MESSAGES: Record<string, unknown> = _deepMerge(
|
|
533
|
-
_deepMerge(
|
|
534
|
-
_coreMessages as unknown as Record<string, unknown>,
|
|
535
|
-
(_themeMessages as { default?: Record<string, unknown> }).default ?? _themeMessages as unknown as Record<string, unknown>
|
|
536
|
-
),
|
|
537
|
-
_entityMessages
|
|
538
|
-
)`
|
|
539
|
-
: `
|
|
540
|
-
export const STATIC_MESSAGES: Record<string, unknown> = _deepMerge(
|
|
541
|
-
_coreMessages as unknown as Record<string, unknown>,
|
|
542
|
-
(_themeMessages as { default?: Record<string, unknown> }).default ?? _themeMessages as unknown as Record<string, unknown>
|
|
543
|
-
)`
|
|
544
|
-
|
|
545
|
-
if (hasEntities) {
|
|
546
|
-
console.log(`[TranslationRegistry] PPR static messages include ${allEntityTranslations.length} entity translations`)
|
|
547
|
-
}
|
|
498
|
+
// NOTE: Entity/plugin translations are NOT included in STATIC_MESSAGES.
|
|
499
|
+
// STATIC_MESSAGES is used by the root layout's StaticIntlProvider and gets
|
|
500
|
+
// serialized into the RSC payload of EVERY page (including public pages).
|
|
501
|
+
// Including entity translations (~500KB+) would bloat public page payloads
|
|
502
|
+
// and degrade PageSpeed scores significantly.
|
|
503
|
+
//
|
|
504
|
+
// Entity translations are loaded dynamically via loadMergedTranslations()
|
|
505
|
+
// for authenticated pages. Dashboard layouts should use NextIntlClientProvider
|
|
506
|
+
// with server-loaded messages to provide entity translations to client components.
|
|
548
507
|
|
|
549
508
|
return `/**
|
|
550
509
|
* PPR: Static messages for the default locale (pre-merged at build time)
|
|
551
510
|
*
|
|
552
511
|
* Used by the root layout's StaticIntlProvider to render content
|
|
553
512
|
* in the PPR static shell without accessing cookies/headers.
|
|
554
|
-
* Core messages are deep-merged with theme
|
|
513
|
+
* Core messages are deep-merged with theme messages only.
|
|
514
|
+
*
|
|
515
|
+
* NOTE: Entity/plugin translations are NOT included here to avoid bloating
|
|
516
|
+
* the RSC payload of public pages. Dashboard pages load entity translations
|
|
517
|
+
* via NextIntlClientProvider in the dashboard layout.
|
|
555
518
|
*/
|
|
556
519
|
import { deepMergeMessages as _deepMerge } from '@nextsparkjs/core/lib/translations/registry'
|
|
557
520
|
import _coreMessages from '@nextsparkjs/core/messages/${defaultLocale}/index.js'
|
|
558
521
|
import _themeMessages from '${defaultThemeTranslation.filePath}'
|
|
559
|
-
|
|
522
|
+
|
|
560
523
|
export const DEFAULT_LOCALE = '${defaultLocale}' as const
|
|
561
524
|
export const DEFAULT_THEME_MODE = '${defaultThemeMode}' as const
|
|
562
|
-
|
|
525
|
+
export const STATIC_MESSAGES: Record<string, unknown> = _deepMerge(
|
|
526
|
+
_coreMessages as unknown as Record<string, unknown>,
|
|
527
|
+
(_themeMessages as { default?: Record<string, unknown> }).default ?? _themeMessages as unknown as Record<string, unknown>
|
|
528
|
+
)`
|
|
563
529
|
})()}
|
|
564
530
|
`
|
|
565
531
|
}
|