@holo-js/cli 0.1.8 → 0.2.0
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/bin/holo.mjs +167 -81
- package/dist/broadcast-WI6PJS5P.mjs +203 -0
- package/dist/broadcast-YWS4N5QU.mjs +203 -0
- package/dist/{cache-JGGCYQQG.mjs → cache-KWNQECAA.mjs} +6 -6
- package/dist/cache-QARFSW4F.mjs +66 -0
- package/dist/{cache-migrations-3V7LI4CC.mjs → cache-migrations-3OXR4FN5.mjs} +50 -30
- package/dist/cache-migrations-MDFMDVTK.mjs +173 -0
- package/dist/{chunk-O6AXHL7Z.mjs → chunk-2DKQKZML.mjs} +230 -126
- package/dist/{chunk-D4NXGVV4.mjs → chunk-2RGJTPYF.mjs} +36 -25
- package/dist/{chunk-2NUEWM2P.mjs → chunk-EWYXSN2C.mjs} +82 -119
- package/dist/{chunk-F4MT6GBK.mjs → chunk-FGQ2I2YH.mjs} +1 -1
- package/dist/chunk-I7QBCEV7.mjs +33 -0
- package/dist/{chunk-R6BWRY3E.mjs → chunk-ILU426CF.mjs} +3 -1
- package/dist/{chunk-QIOHKKXP.mjs → chunk-IUDD5FYL.mjs} +28 -273
- package/dist/{chunk-SABHUOON.mjs → chunk-KWRIBHC3.mjs} +229 -142
- package/dist/{chunk-57SJ566R.mjs → chunk-LBJAJLKU.mjs} +1 -1
- package/dist/{chunk-BAFQ2GOA.mjs → chunk-LXGQCG56.mjs} +1 -1
- package/dist/{chunk-DFKX4YT4.mjs → chunk-ONKESAQA.mjs} +2 -2
- package/dist/chunk-QA7TP5EO.mjs +448 -0
- package/dist/chunk-UPZH6KCF.mjs +3306 -0
- package/dist/{chunk-5EU32E7X.mjs → chunk-VRGB6DIS.mjs} +116 -12
- package/dist/{config-K7SBKT2C.mjs → config-TWEO2R4N.mjs} +3 -3
- package/dist/{dev-RZLZX75U.mjs → dev-2OULECTU.mjs} +7 -7
- package/dist/dev-PJMEGTAC.mjs +42 -0
- package/dist/{discovery-SFRDA4VX.mjs → discovery-7FXND7Y6.mjs} +3 -3
- package/dist/{generators-UJA6WP7J.mjs → generators-4BP7B47W.mjs} +11 -34
- package/dist/generators-Z4XLSMC7.mjs +520 -0
- package/dist/index.mjs +169 -83
- package/dist/{media-migrations-76KFHA2U.mjs → media-migrations-BFEL7NFG.mjs} +9 -20
- package/dist/media-migrations-VR7DLLR6.mjs +106 -0
- package/dist/{queue-JGVKSPUM.mjs → queue-SVOJPTRO.mjs} +10 -10
- package/dist/queue-YCBQTCYI.mjs +625 -0
- package/dist/{queue-migrations-3TYOTL45.mjs → queue-migrations-HPXOO3NA.mjs} +13 -12
- package/dist/queue-migrations-X4P7FZKJ.mjs +167 -0
- package/dist/{runtime-4AAMJI34.mjs → runtime-CPKR663Y.mjs} +9 -9
- package/dist/runtime-GIE56H47.mjs +57 -0
- package/dist/{runtime-ZKD6URAV.mjs → runtime-GSXF4NB3.mjs} +1 -1
- package/dist/runtime-worker.d.ts +2 -0
- package/dist/runtime-worker.mjs +242 -0
- package/dist/{scaffold-TMP7PWOA.mjs → scaffold-3QPGYQEQ.mjs} +9 -5
- package/dist/scaffold-RGAAHC6I.mjs +139 -0
- package/dist/{security-ILU74RIZ.mjs → security-7H5TNHZY.mjs} +6 -6
- package/dist/security-BZGD6ONY.mjs +71 -0
- package/package.json +9 -7
- package/dist/broadcast-3VPGBNCR.mjs +0 -84
- package/dist/chunk-ZXDU7RHU.mjs +0 -9
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
GENERATED_BROADCAST_PATH,
|
|
8
8
|
GENERATED_BROADCAST_TYPES_PATH,
|
|
9
9
|
GENERATED_CHANNELS_PATH,
|
|
10
|
+
GENERATED_CHANNEL_IMPORTER_PATH,
|
|
10
11
|
GENERATED_COMMANDS_PATH,
|
|
11
12
|
GENERATED_CONFIG_TYPES_PATH,
|
|
12
13
|
GENERATED_EVENTS_PATH,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
isRecord,
|
|
33
34
|
makeProjectRelativePath,
|
|
34
35
|
normalizeScaffoldOptionalPackages
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ILU426CF.mjs";
|
|
36
37
|
|
|
37
38
|
// src/templates.ts
|
|
38
39
|
import { dirname, relative, resolve } from "path";
|
|
@@ -415,31 +416,10 @@ function renderNuxtHostedAuthCallbackRoute(spec) {
|
|
|
415
416
|
}
|
|
416
417
|
function renderNuxtHostedAuthLogoutRoute(spec) {
|
|
417
418
|
return [
|
|
418
|
-
"import { provider } from '@holo-js/auth'",
|
|
419
419
|
`import { ${spec.logoutFunction} } from '${spec.packageName}'`,
|
|
420
|
-
"import { createError, sendRedirect } from 'h3'",
|
|
421
420
|
"",
|
|
422
421
|
"export default defineEventHandler(async (event) => {",
|
|
423
|
-
|
|
424
|
-
" try {",
|
|
425
|
-
" currentProvider = await provider()",
|
|
426
|
-
" } catch {",
|
|
427
|
-
" return await sendRedirect(event, '/', 303)",
|
|
428
|
-
" }",
|
|
429
|
-
"",
|
|
430
|
-
` if (currentProvider !== '${spec.provider}') {`,
|
|
431
|
-
" return await sendRedirect(event, '/', 303)",
|
|
432
|
-
" }",
|
|
433
|
-
"",
|
|
434
|
-
` const { data, error } = await ${spec.logoutFunction}(event)`,
|
|
435
|
-
" if (error) {",
|
|
436
|
-
" throw createError({",
|
|
437
|
-
" statusCode: error.status,",
|
|
438
|
-
" statusMessage: error.message,",
|
|
439
|
-
" })",
|
|
440
|
-
" }",
|
|
441
|
-
"",
|
|
442
|
-
" return await sendRedirect(event, data.url, 303)",
|
|
422
|
+
` return await ${spec.logoutFunction}(event)`,
|
|
443
423
|
"})",
|
|
444
424
|
""
|
|
445
425
|
].join("\n");
|
|
@@ -529,17 +509,24 @@ function renderNextHoloHelper() {
|
|
|
529
509
|
""
|
|
530
510
|
].join("\n");
|
|
531
511
|
}
|
|
532
|
-
function
|
|
533
|
-
return
|
|
512
|
+
function renderNextRuntimeBootstrap() {
|
|
513
|
+
return [
|
|
514
|
+
"import { dirname, resolve } from 'node:path'",
|
|
515
|
+
"import { fileURLToPath } from 'node:url'",
|
|
516
|
+
"import { createNextHoloHelpers } from '@holo-js/adapter-next/runtime'",
|
|
517
|
+
"",
|
|
518
|
+
"const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')",
|
|
519
|
+
"const holo = createNextHoloHelpers({ projectRoot })",
|
|
520
|
+
"",
|
|
521
|
+
"await holo.getApp()",
|
|
522
|
+
""
|
|
523
|
+
].join("\n");
|
|
534
524
|
}
|
|
535
|
-
function
|
|
525
|
+
function renderNextCurrentAuthRoute() {
|
|
536
526
|
return [
|
|
537
527
|
"import auth, { check, isAuthError, provider, user } from '@holo-js/auth'",
|
|
538
|
-
"import { holo } from './holo'",
|
|
539
528
|
"",
|
|
540
529
|
"export async function GET(request: Request) {",
|
|
541
|
-
" await holo.getApp()",
|
|
542
|
-
"",
|
|
543
530
|
" const guard = new URL(request.url).searchParams.get('guard') ?? undefined",
|
|
544
531
|
" try {",
|
|
545
532
|
" const guardAuth = guard ? auth.guard(guard) : undefined",
|
|
@@ -624,30 +611,13 @@ function renderNextHostedAuthLogoutRoute(spec) {
|
|
|
624
611
|
}
|
|
625
612
|
function renderNextGeneratedHostedAuthLogoutRoute(spec) {
|
|
626
613
|
return [
|
|
627
|
-
"import { provider } from '@holo-js/auth'",
|
|
628
614
|
`import { ${spec.logoutFunction} } from '${spec.packageName}'`,
|
|
629
615
|
"import { holo } from './holo'",
|
|
630
616
|
"",
|
|
631
617
|
"export async function POST(request: Request) {",
|
|
632
618
|
" await holo.getApp()",
|
|
633
619
|
"",
|
|
634
|
-
|
|
635
|
-
" try {",
|
|
636
|
-
" currentProvider = await provider()",
|
|
637
|
-
" } catch {",
|
|
638
|
-
" return Response.redirect(new URL('/', request.url), 303)",
|
|
639
|
-
" }",
|
|
640
|
-
"",
|
|
641
|
-
` if (currentProvider !== '${spec.provider}') {`,
|
|
642
|
-
" return Response.redirect(new URL('/', request.url), 303)",
|
|
643
|
-
" }",
|
|
644
|
-
"",
|
|
645
|
-
` const { data, error } = await ${spec.logoutFunction}(request)`,
|
|
646
|
-
" if (error) {",
|
|
647
|
-
" return Response.json({ data, error }, { status: error.status })",
|
|
648
|
-
" }",
|
|
649
|
-
"",
|
|
650
|
-
" return Response.redirect(data.url, 303)",
|
|
620
|
+
` return await ${spec.logoutFunction}(request)`,
|
|
651
621
|
"}",
|
|
652
622
|
""
|
|
653
623
|
].join("\n");
|
|
@@ -679,47 +649,94 @@ function renderNextGeneratedStorageRoute() {
|
|
|
679
649
|
function renderNextBroadcastAuthRoute() {
|
|
680
650
|
return renderNextRouteBridge("../../../.holo-js/generated/next/broadcast-auth-route", ["POST"]);
|
|
681
651
|
}
|
|
652
|
+
function renderNextBroadcastConfigRoute() {
|
|
653
|
+
return renderNextRouteBridge("../../../.holo-js/generated/next/broadcast-config-route", ["GET"]);
|
|
654
|
+
}
|
|
655
|
+
function renderNextGeneratedBroadcastConfigRoute() {
|
|
656
|
+
return [
|
|
657
|
+
"import { renderBroadcastClientConfigResponse } from '@holo-js/broadcast/client-config'",
|
|
658
|
+
"import { holo } from './holo'",
|
|
659
|
+
"",
|
|
660
|
+
"export async function GET() {",
|
|
661
|
+
" const app = await holo.getApp()",
|
|
662
|
+
" return renderBroadcastClientConfigResponse(app.config.broadcast)",
|
|
663
|
+
"}",
|
|
664
|
+
""
|
|
665
|
+
].join("\n");
|
|
666
|
+
}
|
|
682
667
|
function renderNextGeneratedBroadcastAuthRoute() {
|
|
683
668
|
return [
|
|
684
669
|
"import { renderBroadcastAuthResponse } from '@holo-js/broadcast/auth'",
|
|
670
|
+
"import { importBroadcastChannelModule } from '../channel-importer'",
|
|
685
671
|
"import { holo } from './holo'",
|
|
686
672
|
"",
|
|
687
673
|
"export async function POST(request: Request) {",
|
|
688
674
|
" const app = await holo.getApp()",
|
|
689
675
|
" const auth = await holo.getAuth()",
|
|
676
|
+
" const connection = app.config.broadcast.connections[app.config.broadcast.default]",
|
|
677
|
+
" const signing = connection?.driver === 'holo' && 'key' in connection && 'secret' in connection",
|
|
678
|
+
" ? {",
|
|
679
|
+
" appKey: connection.key,",
|
|
680
|
+
" appSecret: connection.secret,",
|
|
681
|
+
" }",
|
|
682
|
+
" : {}",
|
|
690
683
|
"",
|
|
691
684
|
" return await renderBroadcastAuthResponse(request, {",
|
|
692
|
-
"
|
|
685
|
+
" ...signing,",
|
|
686
|
+
" resolveUser: async (_request, context) => {",
|
|
687
|
+
" const guardAuth = context.guard ? auth?.guard(context.guard) : undefined",
|
|
688
|
+
" return guardAuth ? await guardAuth.user() : await auth?.user()",
|
|
689
|
+
" },",
|
|
693
690
|
" channelAuth: {",
|
|
694
691
|
" registry: {",
|
|
695
692
|
" projectRoot: app.projectRoot,",
|
|
696
693
|
" channels: app.registry?.channels ?? [],",
|
|
697
694
|
" },",
|
|
695
|
+
" importModule: importBroadcastChannelModule,",
|
|
698
696
|
" },",
|
|
699
697
|
" })",
|
|
700
698
|
"}",
|
|
701
699
|
""
|
|
702
700
|
].join("\n");
|
|
703
701
|
}
|
|
702
|
+
function renderNextGeneratedRealtimeDefinitions(importPaths = []) {
|
|
703
|
+
const imports = importPaths.map((importPath, index) => `import * as realtimeModule${index} from ${JSON.stringify(importPath)}`);
|
|
704
|
+
const values = importPaths.map((_importPath, index) => `...Object.values(realtimeModule${index})`);
|
|
705
|
+
return [
|
|
706
|
+
...imports,
|
|
707
|
+
"",
|
|
708
|
+
`export const realtimeDefinitions = [${values.join(", ")}] as const`,
|
|
709
|
+
""
|
|
710
|
+
].join("\n");
|
|
711
|
+
}
|
|
704
712
|
function renderNextManagedRouteFiles(options = {}) {
|
|
705
713
|
return [
|
|
706
714
|
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
707
|
-
|
|
715
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() },
|
|
708
716
|
...options.storageEnabled ? [{ path: ".holo-js/generated/next/storage-route.ts", contents: renderNextGeneratedStorageRoute() }] : [],
|
|
709
|
-
...options.
|
|
717
|
+
...options.broadcastEnabled ? [{ path: ".holo-js/generated/next/broadcast-config-route.ts", contents: renderNextGeneratedBroadcastConfigRoute() }] : [],
|
|
718
|
+
...options.broadcastAuthEnabled ? [{ path: ".holo-js/generated/next/broadcast-auth-route.ts", contents: renderNextGeneratedBroadcastAuthRoute() }] : [],
|
|
719
|
+
...options.realtimeEnabled ? [{ path: ".holo-js/generated/next/realtime-definitions.ts", contents: renderNextGeneratedRealtimeDefinitions() }] : []
|
|
710
720
|
];
|
|
711
721
|
}
|
|
712
722
|
function renderNextManagedHostedAuthRouteFiles(features) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
return [
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
+
const providers = getRequestedHostedAuthProviders(features);
|
|
724
|
+
if (providers.length === 0) {
|
|
725
|
+
return [];
|
|
726
|
+
}
|
|
727
|
+
return [
|
|
728
|
+
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
729
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() },
|
|
730
|
+
...providers.flatMap((provider) => {
|
|
731
|
+
const spec = HOSTED_AUTH_PROVIDERS[provider];
|
|
732
|
+
return [
|
|
733
|
+
{ path: `.holo-js/generated/next/auth-${provider}-login-route.ts`, contents: renderNextGeneratedHostedAuthLoginRoute(spec) },
|
|
734
|
+
{ path: `.holo-js/generated/next/auth-${provider}-register-route.ts`, contents: renderNextGeneratedHostedAuthRegisterRoute(spec) },
|
|
735
|
+
{ path: `.holo-js/generated/next/auth-${provider}-callback-route.ts`, contents: renderNextGeneratedHostedAuthCallbackRoute(spec) },
|
|
736
|
+
{ path: `.holo-js/generated/next/auth-${provider}-logout-route.ts`, contents: renderNextGeneratedHostedAuthLogoutRoute(spec) }
|
|
737
|
+
];
|
|
738
|
+
})
|
|
739
|
+
];
|
|
723
740
|
}
|
|
724
741
|
function renderSvelteManagedRuntimeFiles() {
|
|
725
742
|
return [
|
|
@@ -756,7 +773,7 @@ function renderSvelteServerUserHooks() {
|
|
|
756
773
|
""
|
|
757
774
|
].join("\n");
|
|
758
775
|
}
|
|
759
|
-
function renderSvelteViteConfig(_storageEnabled) {
|
|
776
|
+
function renderSvelteViteConfig(_storageEnabled, realtimeEnabled = false) {
|
|
760
777
|
const externals = [
|
|
761
778
|
" '@holo-js/adapter-sveltekit',",
|
|
762
779
|
" '@holo-js/auth',",
|
|
@@ -784,6 +801,7 @@ function renderSvelteViteConfig(_storageEnabled) {
|
|
|
784
801
|
" '@holo-js/queue',",
|
|
785
802
|
" '@holo-js/queue-db',",
|
|
786
803
|
" '@holo-js/queue-redis',",
|
|
804
|
+
" '@holo-js/realtime',",
|
|
787
805
|
" '@holo-js/security',",
|
|
788
806
|
" '@holo-js/session',",
|
|
789
807
|
" '@holo-js/storage',",
|
|
@@ -797,10 +815,11 @@ function renderSvelteViteConfig(_storageEnabled) {
|
|
|
797
815
|
];
|
|
798
816
|
return [
|
|
799
817
|
"import { sveltekit } from '@sveltejs/kit/vite'",
|
|
818
|
+
...realtimeEnabled ? ["import { holoSvelteKitRealtime } from '@holo-js/adapter-sveltekit/vite'"] : [],
|
|
800
819
|
"import { defineConfig } from 'vite'",
|
|
801
820
|
"",
|
|
802
821
|
"export default defineConfig({",
|
|
803
|
-
|
|
822
|
+
` plugins: [${realtimeEnabled ? "holoSvelteKitRealtime(), " : ""}sveltekit()],`,
|
|
804
823
|
" server: {",
|
|
805
824
|
" fs: {",
|
|
806
825
|
" allow: ['.holo-js/generated'],",
|
|
@@ -919,28 +938,11 @@ function renderSvelteHostedAuthCallbackRoute(spec) {
|
|
|
919
938
|
}
|
|
920
939
|
function renderSvelteHostedAuthLogoutRoute(spec) {
|
|
921
940
|
return [
|
|
922
|
-
"import {
|
|
923
|
-
"import { provider } from '@holo-js/auth'",
|
|
941
|
+
"import { type RequestEvent } from '@sveltejs/kit'",
|
|
924
942
|
`import { ${spec.logoutFunction} } from '${spec.packageName}'`,
|
|
925
943
|
"",
|
|
926
944
|
"export async function POST(event: RequestEvent) {",
|
|
927
|
-
|
|
928
|
-
" try {",
|
|
929
|
-
" currentProvider = await provider()",
|
|
930
|
-
" } catch {",
|
|
931
|
-
" throw redirect(303, '/')",
|
|
932
|
-
" }",
|
|
933
|
-
"",
|
|
934
|
-
` if (currentProvider !== '${spec.provider}') {`,
|
|
935
|
-
" throw redirect(303, '/')",
|
|
936
|
-
" }",
|
|
937
|
-
"",
|
|
938
|
-
` const { data, error } = await ${spec.logoutFunction}(event)`,
|
|
939
|
-
" if (error) {",
|
|
940
|
-
" return Response.json({ data, error }, { status: error.status })",
|
|
941
|
-
" }",
|
|
942
|
-
"",
|
|
943
|
-
" throw redirect(303, data.url)",
|
|
945
|
+
` return await ${spec.logoutFunction}(event)`,
|
|
944
946
|
"}",
|
|
945
947
|
""
|
|
946
948
|
].join("\n");
|
|
@@ -951,8 +953,7 @@ function renderSvelteHostedAuthRouteFiles(provider) {
|
|
|
951
953
|
{ path: `src/routes/api/auth/${provider}/login/+server.ts`, contents: renderSvelteHostedAuthLoginRoute(spec) },
|
|
952
954
|
{ path: `src/routes/api/auth/${provider}/register/+server.ts`, contents: renderSvelteHostedAuthRegisterRoute(spec) },
|
|
953
955
|
{ path: `src/routes/api/auth/${provider}/callback/+server.ts`, contents: renderSvelteHostedAuthCallbackRoute(spec) },
|
|
954
|
-
{ path: `src/routes/api/auth/${provider}/logout/+server.ts`, contents: renderSvelteHostedAuthLogoutRoute(spec) }
|
|
955
|
-
...renderSvelteManagedRuntimeFiles()
|
|
956
|
+
{ path: `src/routes/api/auth/${provider}/logout/+server.ts`, contents: renderSvelteHostedAuthLogoutRoute(spec) }
|
|
956
957
|
];
|
|
957
958
|
}
|
|
958
959
|
function renderAuthProviderRouteFiles(framework, features) {
|
|
@@ -971,7 +972,7 @@ function renderAuthRouteFiles(framework) {
|
|
|
971
972
|
return [
|
|
972
973
|
{ path: "app/api/auth/user/route.ts", contents: renderNextCurrentAuthRoute() },
|
|
973
974
|
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
974
|
-
{ path: ".holo-js/generated/next/
|
|
975
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() }
|
|
975
976
|
];
|
|
976
977
|
}
|
|
977
978
|
if (framework === "nuxt") {
|
|
@@ -979,14 +980,14 @@ function renderAuthRouteFiles(framework) {
|
|
|
979
980
|
{ path: "server/api/auth/user.get.ts", contents: renderNuxtCurrentAuthRoute() }
|
|
980
981
|
];
|
|
981
982
|
}
|
|
982
|
-
return [
|
|
983
|
-
...renderSvelteManagedRuntimeFiles()
|
|
984
|
-
];
|
|
983
|
+
return [];
|
|
985
984
|
}
|
|
986
985
|
function renderFrameworkFiles(options) {
|
|
987
986
|
const optionalPackages = normalizeScaffoldOptionalPackages(options.optionalPackages);
|
|
988
987
|
const storageEnabled = optionalPackages.includes("storage");
|
|
989
988
|
const authEnabled = optionalPackages.includes("auth");
|
|
989
|
+
const broadcastEnabled = optionalPackages.includes("broadcast");
|
|
990
|
+
const realtimeEnabled = optionalPackages.includes("realtime");
|
|
990
991
|
if (options.framework === "nuxt") {
|
|
991
992
|
return [
|
|
992
993
|
{ path: "app/app.vue", contents: renderNuxtAppVue(options.projectName) },
|
|
@@ -1003,12 +1004,13 @@ function renderFrameworkFiles(options) {
|
|
|
1003
1004
|
{ path: "app/page.tsx", contents: renderNextPage(options.projectName) },
|
|
1004
1005
|
...authEnabled ? [{ path: "app/api/auth/user/route.ts", contents: renderNextCurrentAuthRoute() }] : [],
|
|
1005
1006
|
...storageEnabled ? [{ path: "app/storage/[[...path]]/route.ts", contents: renderNextStorageRoute() }] : [],
|
|
1006
|
-
...
|
|
1007
|
+
...broadcastEnabled ? [{ path: "app/broadcasting/config/route.ts", contents: renderNextBroadcastConfigRoute() }] : [],
|
|
1008
|
+
...renderNextManagedRouteFiles({ authEnabled, broadcastEnabled, storageEnabled, realtimeEnabled })
|
|
1007
1009
|
];
|
|
1008
1010
|
}
|
|
1009
1011
|
return [
|
|
1010
1012
|
{ path: "svelte.config.js", contents: renderSvelteConfig() },
|
|
1011
|
-
{ path: "vite.config.ts", contents: renderSvelteViteConfig(storageEnabled) },
|
|
1013
|
+
{ path: "vite.config.ts", contents: renderSvelteViteConfig(storageEnabled, realtimeEnabled) },
|
|
1012
1014
|
{ path: "src/hooks.ts", contents: renderSvelteUserHooks() },
|
|
1013
1015
|
{ path: "src/hooks.server.ts", contents: renderSvelteServerUserHooks() },
|
|
1014
1016
|
{ path: "src/app.html", contents: renderSvelteAppHtml() },
|
|
@@ -1029,6 +1031,7 @@ function renderFrameworkRunner(options) {
|
|
|
1029
1031
|
"const manifestPath = fileURLToPath(new URL('./project.json', import.meta.url))",
|
|
1030
1032
|
"const projectRoot = resolve(dirname(manifestPath), '../..')",
|
|
1031
1033
|
"const runtimeSchemaPath = resolve(projectRoot, '.holo-js/generated/schema.mjs')",
|
|
1034
|
+
"const nextRuntimeBootstrapPath = resolve(projectRoot, '.holo-js/generated/next/bootstrap.mjs')",
|
|
1032
1035
|
"const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))",
|
|
1033
1036
|
"const framework = String(manifest.framework ?? '')",
|
|
1034
1037
|
`const commandName = ${JSON.stringify(commandName)}`,
|
|
@@ -1248,8 +1251,18 @@ function renderFrameworkRunner(options) {
|
|
|
1248
1251
|
" while (true) {",
|
|
1249
1252
|
" const stderrLines = []",
|
|
1250
1253
|
" const childEnv = { ...process.env }",
|
|
1251
|
-
" if (
|
|
1252
|
-
"
|
|
1254
|
+
" if (mode === 'build') {",
|
|
1255
|
+
" childEnv.HOLO_INTERNAL_FRAMEWORK_BUILD = '1'",
|
|
1256
|
+
" }",
|
|
1257
|
+
" const preloads = [runtimeSchemaPath]",
|
|
1258
|
+
" if (framework === 'next') {",
|
|
1259
|
+
" preloads.push(nextRuntimeBootstrapPath)",
|
|
1260
|
+
" }",
|
|
1261
|
+
" const preloadOptions = preloads",
|
|
1262
|
+
" .filter(path => existsSync(path))",
|
|
1263
|
+
" .map(path => `--import=${pathToFileURL(path).href}`)",
|
|
1264
|
+
" if (preloadOptions.length > 0) {",
|
|
1265
|
+
" const preload = preloadOptions.join(' ')",
|
|
1253
1266
|
" childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS",
|
|
1254
1267
|
" ? `${childEnv.NODE_OPTIONS} ${preload}`",
|
|
1255
1268
|
" : preload",
|
|
@@ -1313,13 +1326,13 @@ function renderFrameworkRunner(options) {
|
|
|
1313
1326
|
// src/project/registry.ts
|
|
1314
1327
|
import { constants as fsConstants } from "fs";
|
|
1315
1328
|
import { access, mkdir as mkdir2, readFile as readFile2, readdir as readdir2, writeFile as writeFile2 } from "fs/promises";
|
|
1316
|
-
import { dirname as dirname3, extname, join, resolve as resolve3 } from "path";
|
|
1329
|
+
import { dirname as dirname3, extname as extname2, join, resolve as resolve3 } from "path";
|
|
1317
1330
|
import { loadConfigDirectory } from "@holo-js/config";
|
|
1318
1331
|
import { DEFAULT_HOLO_PROJECT_PATHS, renderGeneratedSchemaRuntimeModule } from "@holo-js/db";
|
|
1319
1332
|
|
|
1320
1333
|
// src/project/registry-svelte.ts
|
|
1321
|
-
import { mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
|
|
1322
|
-
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
1334
|
+
import { mkdir, readdir, readFile, rm, stat, writeFile } from "fs/promises";
|
|
1335
|
+
import { dirname as dirname2, extname, relative as relative2, resolve as resolve2, sep } from "path";
|
|
1323
1336
|
function renderManagedSvelteHooksModule() {
|
|
1324
1337
|
return [
|
|
1325
1338
|
"// Generated by holo prepare. Do not edit.",
|
|
@@ -1373,7 +1386,10 @@ function renderManagedSvelteServerHooksModule(features) {
|
|
|
1373
1386
|
"import { adapterSvelteKitInternals, runWithSvelteKitRequestEvent } from '@holo-js/adapter-sveltekit'",
|
|
1374
1387
|
"import { sequence } from '@sveltejs/kit/hooks'",
|
|
1375
1388
|
...features.authEnabled ? ["import auth, { check, isAuthError, provider, user } from '@holo-js/auth'"] : [],
|
|
1376
|
-
...features.broadcastEnabled ? [
|
|
1389
|
+
...features.broadcastEnabled ? [
|
|
1390
|
+
"import { renderBroadcastAuthResponse } from '@holo-js/broadcast/auth'",
|
|
1391
|
+
"import { renderBroadcastClientConfigResponse } from '@holo-js/broadcast/client-config'"
|
|
1392
|
+
] : [],
|
|
1377
1393
|
...features.storageEnabled ? ["import { createPublicStorageResponse } from '@holo-js/storage'"] : [],
|
|
1378
1394
|
...features.clerkEnabled ? ["import { completeClerkAuth, loginWithClerk, logoutWithClerk, registerWithClerk } from '@holo-js/auth-clerk'"] : [],
|
|
1379
1395
|
...features.workosEnabled ? ["import { completeWorkosAuth, loginWithWorkos, logoutWithWorkos, registerWithWorkos } from '@holo-js/auth-workos'"] : [],
|
|
@@ -1384,7 +1400,7 @@ function renderManagedSvelteServerHooksModule(features) {
|
|
|
1384
1400
|
const routeHandlers = [
|
|
1385
1401
|
...features.authEnabled ? ["handleHoloCurrentAuthRoute"] : [],
|
|
1386
1402
|
...features.storageEnabled ? ["handleHoloStorageRoute"] : [],
|
|
1387
|
-
...features.broadcastEnabled ? ["handleHoloBroadcastAuthRoute"] : [],
|
|
1403
|
+
...features.broadcastEnabled ? ["handleHoloBroadcastConfigRoute", "handleHoloBroadcastAuthRoute"] : [],
|
|
1388
1404
|
...features.clerkEnabled ? [
|
|
1389
1405
|
"handleHoloClerkLoginRoute",
|
|
1390
1406
|
"handleHoloClerkRegisterRoute",
|
|
@@ -1477,14 +1493,33 @@ function renderManagedSvelteServerHooksModule(features) {
|
|
|
1477
1493
|
""
|
|
1478
1494
|
] : [],
|
|
1479
1495
|
...features.broadcastEnabled ? [
|
|
1496
|
+
"async function handleHoloBroadcastConfigRoute(event: RequestEvent, app: HoloApp): Promise<Response | undefined> {",
|
|
1497
|
+
" if (!isRoute(event, 'GET', ['/broadcasting/config'])) {",
|
|
1498
|
+
" return undefined",
|
|
1499
|
+
" }",
|
|
1500
|
+
"",
|
|
1501
|
+
" return renderBroadcastClientConfigResponse(app.config.broadcast)",
|
|
1502
|
+
"}",
|
|
1503
|
+
"",
|
|
1480
1504
|
"async function handleHoloBroadcastAuthRoute(event: RequestEvent, app: HoloApp): Promise<Response | undefined> {",
|
|
1481
1505
|
" if (!isRoute(event, 'POST', ['/broadcasting/auth'])) {",
|
|
1482
1506
|
" return undefined",
|
|
1483
1507
|
" }",
|
|
1484
1508
|
"",
|
|
1485
1509
|
" const auth = await holo.getAuth()",
|
|
1510
|
+
" const connection = app.config.broadcast.connections[app.config.broadcast.default]",
|
|
1511
|
+
" const signing = connection?.driver === 'holo' && 'key' in connection && 'secret' in connection",
|
|
1512
|
+
" ? {",
|
|
1513
|
+
" appKey: connection.key,",
|
|
1514
|
+
" appSecret: connection.secret,",
|
|
1515
|
+
" }",
|
|
1516
|
+
" : {}",
|
|
1486
1517
|
" return await renderBroadcastAuthResponse(event.request, {",
|
|
1487
|
-
"
|
|
1518
|
+
" ...signing,",
|
|
1519
|
+
" resolveUser: async (_request, context) => {",
|
|
1520
|
+
" const guardAuth = context.guard ? auth?.guard(context.guard) : undefined",
|
|
1521
|
+
" return guardAuth ? await guardAuth.user() : await auth?.user()",
|
|
1522
|
+
" },",
|
|
1488
1523
|
" channelAuth: {",
|
|
1489
1524
|
" registry: {",
|
|
1490
1525
|
" projectRoot: app.projectRoot,",
|
|
@@ -1612,23 +1647,7 @@ function renderSvelteHostedAuthHookRoutes(providerName, functionSuffix) {
|
|
|
1612
1647
|
" return undefined",
|
|
1613
1648
|
" }",
|
|
1614
1649
|
"",
|
|
1615
|
-
|
|
1616
|
-
" try {",
|
|
1617
|
-
" currentProvider = await provider()",
|
|
1618
|
-
" } catch {",
|
|
1619
|
-
" return redirectResponse(event, '/')",
|
|
1620
|
-
" }",
|
|
1621
|
-
"",
|
|
1622
|
-
` if (currentProvider !== '${providerName}') {`,
|
|
1623
|
-
" return redirectResponse(event, '/')",
|
|
1624
|
-
" }",
|
|
1625
|
-
"",
|
|
1626
|
-
` const { data, error } = await logoutWith${functionSuffix}(event)`,
|
|
1627
|
-
" if (error) {",
|
|
1628
|
-
" return Response.json({ data, error }, { status: error.status })",
|
|
1629
|
-
" }",
|
|
1630
|
-
"",
|
|
1631
|
-
" return redirectResponse(event, data.url)",
|
|
1650
|
+
` return await logoutWith${functionSuffix}(event)`,
|
|
1632
1651
|
"}",
|
|
1633
1652
|
""
|
|
1634
1653
|
];
|
|
@@ -1701,6 +1720,9 @@ async function unlinkIfPresent(path) {
|
|
|
1701
1720
|
async function pathExists(path) {
|
|
1702
1721
|
return await readFileIfPresent(path) !== void 0;
|
|
1703
1722
|
}
|
|
1723
|
+
async function directoryExists(path) {
|
|
1724
|
+
return await stat(path).then((entry) => entry.isDirectory(), () => false);
|
|
1725
|
+
}
|
|
1704
1726
|
var SVELTE_HOOKS_OVERRIDE_BLOCK = [
|
|
1705
1727
|
" files: {",
|
|
1706
1728
|
" hooks: {",
|
|
@@ -1861,17 +1883,43 @@ async function directoryContainsText(path, pattern) {
|
|
|
1861
1883
|
}
|
|
1862
1884
|
return false;
|
|
1863
1885
|
}
|
|
1886
|
+
var realtimeDefinitionExtensions = /* @__PURE__ */ new Set([".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"]);
|
|
1887
|
+
async function collectRealtimeDefinitionFiles(root) {
|
|
1888
|
+
const entries = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
1889
|
+
const files = await Promise.all(entries.map(async (entry) => {
|
|
1890
|
+
const entryPath = resolve2(root, entry.name);
|
|
1891
|
+
if (entry.isDirectory()) {
|
|
1892
|
+
return await collectRealtimeDefinitionFiles(entryPath);
|
|
1893
|
+
}
|
|
1894
|
+
return realtimeDefinitionExtensions.has(extname(entry.name)) ? [entryPath] : [];
|
|
1895
|
+
}));
|
|
1896
|
+
return files.flat().sort((left, right) => left.localeCompare(right));
|
|
1897
|
+
}
|
|
1898
|
+
async function renderNextRealtimeDefinitions(projectRoot) {
|
|
1899
|
+
const generatedRoot = resolve2(projectRoot, ".holo-js/generated/next");
|
|
1900
|
+
const files = await collectRealtimeDefinitionFiles(resolve2(projectRoot, "server/realtime"));
|
|
1901
|
+
const importPaths = files.map((filePath) => {
|
|
1902
|
+
const withoutExtension = filePath.slice(0, -extname(filePath).length);
|
|
1903
|
+
const importPath = relative2(generatedRoot, withoutExtension).split(sep).join("/");
|
|
1904
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1905
|
+
});
|
|
1906
|
+
return renderNextGeneratedRealtimeDefinitions(importPaths);
|
|
1907
|
+
}
|
|
1864
1908
|
async function ensureNextManagedRoutes(projectRoot) {
|
|
1865
1909
|
const authEnabled = await pathExists(resolve2(projectRoot, "app/api/auth/user/route.ts"));
|
|
1866
1910
|
const storageEnabled = await pathExists(resolve2(projectRoot, "app/storage/[[...path]]/route.ts"));
|
|
1911
|
+
const broadcastEnabled = await pathExists(resolve2(projectRoot, "app/broadcasting/config/route.ts"));
|
|
1867
1912
|
const broadcastAuthEnabled = await pathExists(resolve2(projectRoot, "app/broadcasting/auth/route.ts"));
|
|
1913
|
+
const realtimeEnabled = await directoryExists(resolve2(projectRoot, "server/realtime"));
|
|
1868
1914
|
const clerkEnabled = await pathExists(resolve2(projectRoot, "app/api/auth/clerk/login/route.ts"));
|
|
1869
1915
|
const workosEnabled = await pathExists(resolve2(projectRoot, "app/api/auth/workos/login/route.ts"));
|
|
1870
1916
|
const files = [
|
|
1871
1917
|
...renderNextManagedRouteFiles({
|
|
1872
1918
|
authEnabled,
|
|
1919
|
+
broadcastEnabled,
|
|
1873
1920
|
storageEnabled,
|
|
1874
|
-
broadcastAuthEnabled
|
|
1921
|
+
broadcastAuthEnabled,
|
|
1922
|
+
realtimeEnabled
|
|
1875
1923
|
}),
|
|
1876
1924
|
...renderNextManagedHostedAuthRouteFiles({
|
|
1877
1925
|
clerk: clerkEnabled,
|
|
@@ -1881,6 +1929,12 @@ async function ensureNextManagedRoutes(projectRoot) {
|
|
|
1881
1929
|
for (const file of files) {
|
|
1882
1930
|
await writeFileIfChanged(resolve2(projectRoot, file.path), file.contents);
|
|
1883
1931
|
}
|
|
1932
|
+
if (realtimeEnabled) {
|
|
1933
|
+
await writeFileIfChanged(
|
|
1934
|
+
resolve2(projectRoot, ".holo-js/generated/next/realtime-definitions.ts"),
|
|
1935
|
+
await renderNextRealtimeDefinitions(projectRoot)
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1884
1938
|
await removeLegacyManagedHoloHelper(resolve2(projectRoot, "server/holo.ts"), renderNextHoloHelper());
|
|
1885
1939
|
}
|
|
1886
1940
|
function isRecord2(value) {
|
|
@@ -2115,8 +2169,8 @@ function renderAugmentationInterface(name, members) {
|
|
|
2115
2169
|
];
|
|
2116
2170
|
}
|
|
2117
2171
|
function renderGeneratedBroadcastTypes(broadcast, channels) {
|
|
2118
|
-
const typedBroadcastEntries = broadcast.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2119
|
-
const typedChannelEntries = channels.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2172
|
+
const typedBroadcastEntries = broadcast.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2173
|
+
const typedChannelEntries = channels.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2120
2174
|
const broadcastImportNameByName = new Map(typedBroadcastEntries.map((entry, index) => [entry.name, `holoBroadcastModule${index}`]));
|
|
2121
2175
|
const channelImportNameByPattern = new Map(typedChannelEntries.map((entry, index) => [entry.pattern, `holoChannelModule${index}`]));
|
|
2122
2176
|
const broadcastNeedsDefinitionType = broadcast.some((entry) => !broadcastImportNameByName.get(entry.name) || !entry.exportName);
|
|
@@ -2198,6 +2252,7 @@ function renderGeneratedBroadcastManifest(registry) {
|
|
|
2198
2252
|
` name: ${JSON.stringify(entry.pattern)},`,
|
|
2199
2253
|
` pattern: ${JSON.stringify(entry.pattern)},`,
|
|
2200
2254
|
` type: ${JSON.stringify(entry.type)},`,
|
|
2255
|
+
...typeof entry.guard === "undefined" ? [] : [` guard: ${JSON.stringify(entry.guard)},`],
|
|
2201
2256
|
` params: ${JSON.stringify(entry.params)},`,
|
|
2202
2257
|
` whispers: ${JSON.stringify(entry.whispers)},`
|
|
2203
2258
|
];
|
|
@@ -2223,6 +2278,7 @@ function renderGeneratedBroadcastManifest(registry) {
|
|
|
2223
2278
|
"type GeneratedBroadcastManifestChannel = {",
|
|
2224
2279
|
" readonly name: string",
|
|
2225
2280
|
" readonly pattern: string",
|
|
2281
|
+
" readonly guard?: string",
|
|
2226
2282
|
" readonly type: 'private' | 'presence'",
|
|
2227
2283
|
" readonly params: readonly string[]",
|
|
2228
2284
|
" readonly whispers: readonly string[]",
|
|
@@ -2251,9 +2307,33 @@ function renderGeneratedBroadcastManifest(registry) {
|
|
|
2251
2307
|
""
|
|
2252
2308
|
].join("\n");
|
|
2253
2309
|
}
|
|
2310
|
+
function renderGeneratedChannelImporter(channels) {
|
|
2311
|
+
const importableChannels = channels.filter((entry) => [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"].includes(extname2(entry.sourcePath)));
|
|
2312
|
+
const imports = importableChannels.map((entry, index) => {
|
|
2313
|
+
return `import * as holoChannelModule${index} from '${relativeImportPath(GENERATED_CHANNEL_IMPORTER_PATH, entry.sourcePath)}'`;
|
|
2314
|
+
});
|
|
2315
|
+
const cases = importableChannels.flatMap((entry, index) => [
|
|
2316
|
+
` if (normalizedPath.endsWith(${JSON.stringify(`/${entry.sourcePath}`)})) {`,
|
|
2317
|
+
` return holoChannelModule${index}`,
|
|
2318
|
+
" }"
|
|
2319
|
+
]);
|
|
2320
|
+
return [
|
|
2321
|
+
"// Generated by holo prepare. Do not edit.",
|
|
2322
|
+
"",
|
|
2323
|
+
...imports,
|
|
2324
|
+
...imports.length > 0 ? [""] : [],
|
|
2325
|
+
"export async function importBroadcastChannelModule(absolutePath: string): Promise<unknown> {",
|
|
2326
|
+
" const normalizedPath = absolutePath.replaceAll('\\\\', '/')",
|
|
2327
|
+
...cases,
|
|
2328
|
+
"",
|
|
2329
|
+
' throw new Error(`[@holo-js/broadcast] Broadcast channel module "${absolutePath}" was not generated for this app.`)',
|
|
2330
|
+
"}",
|
|
2331
|
+
""
|
|
2332
|
+
].join("\n");
|
|
2333
|
+
}
|
|
2254
2334
|
function renderGeneratedEventTypes(events, listeners) {
|
|
2255
|
-
const typedEventEntries = events.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2256
|
-
const typedListenerEntries = listeners.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2335
|
+
const typedEventEntries = events.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2336
|
+
const typedListenerEntries = listeners.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2257
2337
|
const eventImportNameByName = new Map(typedEventEntries.map((entry, index) => [entry.name, `holoEventModule${index}`]));
|
|
2258
2338
|
const listenerImportNameById = new Map(typedListenerEntries.map((entry, index) => [entry.id, `holoListenerModule${index}`]));
|
|
2259
2339
|
const needsEventDefinitionType = events.some((entry) => !eventImportNameByName.get(entry.name) || !entry.exportName);
|
|
@@ -2306,7 +2386,7 @@ function renderGeneratedEventTypes(events, listeners) {
|
|
|
2306
2386
|
].join("\n");
|
|
2307
2387
|
}
|
|
2308
2388
|
function renderGeneratedQueueTypes(jobs) {
|
|
2309
|
-
const typedJobs = jobs.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2389
|
+
const typedJobs = jobs.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2310
2390
|
const typeImportNameByJob = new Map(
|
|
2311
2391
|
typedJobs.map((entry, index) => {
|
|
2312
2392
|
return [entry.name, `holoQueueJobModule${index}`];
|
|
@@ -2342,7 +2422,23 @@ function renderGeneratedQueueTypes(jobs) {
|
|
|
2342
2422
|
""
|
|
2343
2423
|
].join("\n");
|
|
2344
2424
|
}
|
|
2345
|
-
function
|
|
2425
|
+
function getAuthProviderModelNames(auth) {
|
|
2426
|
+
if (!auth) {
|
|
2427
|
+
return [];
|
|
2428
|
+
}
|
|
2429
|
+
return [...new Set(Object.values(auth.guards).map((guard) => auth.providers[guard.provider]?.model).filter((model) => typeof model === "string" && model.length > 0))].sort((left, right) => left.localeCompare(right));
|
|
2430
|
+
}
|
|
2431
|
+
function renderGeneratedAuthTypes(auth, models = []) {
|
|
2432
|
+
const guards = auth?.guards ?? {};
|
|
2433
|
+
const modelByName = new Map(models.map((model) => [model.name, model]));
|
|
2434
|
+
const userModels = getAuthProviderModelNames(auth).map((modelName) => modelByName.get(modelName)).filter((model) => Boolean(model));
|
|
2435
|
+
const userTableNames = [...new Set(userModels.map((model) => model.tableName))];
|
|
2436
|
+
const userType = userModels.length > 0 ? userTableNames.map((tableName) => `InferSelect<GeneratedSchemaTable<${JSON.stringify(tableName)}>>`).join(" | ") : void 0;
|
|
2437
|
+
const imports = userType ? [
|
|
2438
|
+
"import type { AuthUserLike } from '@holo-js/auth'",
|
|
2439
|
+
"import type { GeneratedSchemaTable, InferSelect } from '@holo-js/db'",
|
|
2440
|
+
""
|
|
2441
|
+
] : [];
|
|
2346
2442
|
const members = Object.entries(guards).sort(([left], [right]) => left.localeCompare(right)).filter((entry) => {
|
|
2347
2443
|
return entry[1].driver === "session" || entry[1].driver === "token";
|
|
2348
2444
|
}).map(([name, guard]) => {
|
|
@@ -2359,12 +2455,14 @@ function renderGeneratedAuthTypes(guards) {
|
|
|
2359
2455
|
"// Generated by holo prepare. Do not edit.",
|
|
2360
2456
|
"",
|
|
2361
2457
|
"import '@holo-js/auth'",
|
|
2458
|
+
...imports,
|
|
2362
2459
|
"",
|
|
2363
2460
|
"declare global {",
|
|
2364
2461
|
" // eslint-disable-next-line @typescript-eslint/no-namespace",
|
|
2365
2462
|
" namespace HoloAuth {",
|
|
2366
2463
|
" interface TypeRegistry {",
|
|
2367
2464
|
...guardsMember,
|
|
2465
|
+
...userType ? [` user: (${userType}) & AuthUserLike`] : [],
|
|
2368
2466
|
" }",
|
|
2369
2467
|
" }",
|
|
2370
2468
|
"}",
|
|
@@ -2411,8 +2509,8 @@ function renderGeneratedAuthorizationRegistry(registry) {
|
|
|
2411
2509
|
].join("\n");
|
|
2412
2510
|
}
|
|
2413
2511
|
function renderGeneratedAuthorizationTypes(authorizationPolicies, authorizationAbilities, guardNames) {
|
|
2414
|
-
const typedPolicyEntries = authorizationPolicies.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2415
|
-
const typedAbilityEntries = authorizationAbilities.filter((entry) => [".ts", ".mts", ".cts"].includes(
|
|
2512
|
+
const typedPolicyEntries = authorizationPolicies.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2513
|
+
const typedAbilityEntries = authorizationAbilities.filter((entry) => [".ts", ".mts", ".cts"].includes(extname2(entry.sourcePath)));
|
|
2416
2514
|
const policyImportNameByName = new Map(typedPolicyEntries.map((entry, index) => [entry.name, `holoAuthorizationPolicyModule${index}`]));
|
|
2417
2515
|
const abilityImportNameByName = new Map(typedAbilityEntries.map((entry, index) => [entry.name, `holoAuthorizationAbilityModule${index}`]));
|
|
2418
2516
|
const usesHoloAuthUser = authorizationPolicies.length > 0 || authorizationAbilities.length > 0 || guardNames.length > 0;
|
|
@@ -2504,7 +2602,7 @@ async function resolveGeneratedTsconfigBase(_projectRoot) {
|
|
|
2504
2602
|
return "../../tsconfig.json";
|
|
2505
2603
|
}
|
|
2506
2604
|
function getConfigExtensionPriority(fileName) {
|
|
2507
|
-
const extension =
|
|
2605
|
+
const extension = extname2(fileName);
|
|
2508
2606
|
const index = CONFIG_EXTENSION_PRIORITY.indexOf(extension);
|
|
2509
2607
|
return index >= 0 ? index : Number.MAX_SAFE_INTEGER;
|
|
2510
2608
|
}
|
|
@@ -2516,7 +2614,7 @@ async function collectProjectConfigEntries(projectRoot) {
|
|
|
2516
2614
|
if (!entry.isFile()) {
|
|
2517
2615
|
continue;
|
|
2518
2616
|
}
|
|
2519
|
-
const extension =
|
|
2617
|
+
const extension = extname2(entry.name);
|
|
2520
2618
|
if (!SUPPORTED_CONFIG_EXTENSIONS.has(extension)) {
|
|
2521
2619
|
continue;
|
|
2522
2620
|
}
|
|
@@ -2613,9 +2711,10 @@ async function writeGeneratedProjectRegistry(projectRoot, registry) {
|
|
|
2613
2711
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_LISTENERS_PATH), renderGeneratedModule("listeners", nextRegistry.listeners));
|
|
2614
2712
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_BROADCAST_PATH), renderGeneratedModule("broadcast", nextRegistry.broadcast));
|
|
2615
2713
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_CHANNELS_PATH), renderGeneratedModule("channels", nextRegistry.channels));
|
|
2714
|
+
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_CHANNEL_IMPORTER_PATH), renderGeneratedChannelImporter(nextRegistry.channels));
|
|
2616
2715
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_BROADCAST_MANIFEST_PATH), renderGeneratedBroadcastManifest(nextRegistry));
|
|
2617
2716
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_BROADCAST_TYPES_PATH), renderGeneratedBroadcastTypes(nextRegistry.broadcast, nextRegistry.channels));
|
|
2618
|
-
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_AUTH_TYPES_PATH), renderGeneratedAuthTypes(loadedConfig?.auth
|
|
2717
|
+
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_AUTH_TYPES_PATH), renderGeneratedAuthTypes(loadedConfig?.auth, nextRegistry.models));
|
|
2619
2718
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_CONFIG_TYPES_PATH), renderGeneratedConfigTypes(projectRoot, configEntries));
|
|
2620
2719
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_EVENT_TYPES_PATH), renderGeneratedEventTypes(nextRegistry.events, nextRegistry.listeners));
|
|
2621
2720
|
await writeFileIfChanged2(resolve3(projectRoot, GENERATED_QUEUE_TYPES_PATH), renderGeneratedQueueTypes(nextRegistry.jobs));
|
|
@@ -2697,9 +2796,14 @@ export {
|
|
|
2697
2796
|
resolveNameInfo,
|
|
2698
2797
|
resolveArtifactPath,
|
|
2699
2798
|
renderNextHoloHelper,
|
|
2799
|
+
renderNextRuntimeBootstrap,
|
|
2700
2800
|
renderNextBroadcastAuthRoute,
|
|
2801
|
+
renderNextBroadcastConfigRoute,
|
|
2802
|
+
renderNextGeneratedBroadcastConfigRoute,
|
|
2701
2803
|
renderNextGeneratedBroadcastAuthRoute,
|
|
2804
|
+
renderNextGeneratedRealtimeDefinitions,
|
|
2702
2805
|
renderNextManagedHostedAuthRouteFiles,
|
|
2806
|
+
renderSvelteViteConfig,
|
|
2703
2807
|
renderSvelteHoloHelper,
|
|
2704
2808
|
renderAuthProviderRouteFiles,
|
|
2705
2809
|
renderAuthRouteFiles,
|