wcz-layout 9.6.4 → 9.6.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.
Files changed (54) hide show
  1. package/dist/Approval-C-hF4jbT.mjs.map +1 -1
  2. package/dist/DialogsContext-DLqA8RJ_.mjs.map +1 -1
  3. package/dist/Email-BzQQkbe9.mjs.map +1 -1
  4. package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
  5. package/dist/NotificationContext-CgwUOeW0.mjs.map +1 -1
  6. package/dist/{RouterListItemButton-owZVvuC_.mjs → RouterListItemButton-ULMlaQh6.mjs} +7 -5
  7. package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -0
  8. package/dist/auth.mjs +5 -5
  9. package/dist/auth.mjs.map +1 -1
  10. package/dist/{authMiddleware-CjKA7C0W.mjs → authMiddleware-DPly0b_T.mjs} +2 -2
  11. package/dist/authMiddleware-DPly0b_T.mjs.map +1 -0
  12. package/dist/components.mjs +46 -163
  13. package/dist/components.mjs.map +1 -1
  14. package/dist/data/client.d.mts +549 -1
  15. package/dist/data/client.mjs +32 -32
  16. package/dist/data/client.mjs.map +1 -1
  17. package/dist/data/server.mjs +2 -2
  18. package/dist/data/server.mjs.map +1 -1
  19. package/dist/{entra-DFhYO6Sj.mjs → entra-CJSyeQsx.mjs} +2 -2
  20. package/dist/entra-CJSyeQsx.mjs.map +1 -0
  21. package/dist/{file-BDeY2atB.mjs → file-BTFDDalH.mjs} +3 -3
  22. package/dist/file-BTFDDalH.mjs.map +1 -0
  23. package/dist/{file--l_efzg-.mjs → file-CuvAmdJW.mjs} +6 -6
  24. package/dist/file-CuvAmdJW.mjs.map +1 -0
  25. package/dist/hooks.mjs +1 -1
  26. package/dist/hooks.mjs.map +1 -1
  27. package/dist/index.mjs +124 -326
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/middleware.mjs +1 -1
  30. package/dist/middleware.mjs.map +1 -1
  31. package/dist/models.mjs.map +1 -1
  32. package/dist/{msalServer-CqLXgWpO.mjs → msalServer-DLwA7_ta.mjs} +2 -2
  33. package/dist/msalServer-DLwA7_ta.mjs.map +1 -0
  34. package/dist/{peoplesoft-DqO-9g-4.mjs → peoplesoft-DGdM1bws.mjs} +2 -2
  35. package/dist/peoplesoft-DGdM1bws.mjs.map +1 -0
  36. package/dist/useDialogs-BUzVrTSP.mjs.map +1 -1
  37. package/dist/{utils-A_Lzklis.mjs → utils-DjdexspV.mjs} +3 -3
  38. package/dist/utils-DjdexspV.mjs.map +1 -0
  39. package/dist/utils.mjs +1 -1
  40. package/dist/vite.mjs.map +1 -1
  41. package/package.json +11 -11
  42. package/skills/client-db/SKILL.md +18 -3
  43. package/skills/db-schema/SKILL.md +9 -2
  44. package/skills/general/SKILL.md +26 -5
  45. package/skills/server-functions/SKILL.md +2 -1
  46. package/skills/start/steps/07-vault-setup.md +76 -64
  47. package/dist/RouterListItemButton-owZVvuC_.mjs.map +0 -1
  48. package/dist/authMiddleware-CjKA7C0W.mjs.map +0 -1
  49. package/dist/entra-DFhYO6Sj.mjs.map +0 -1
  50. package/dist/file--l_efzg-.mjs.map +0 -1
  51. package/dist/file-BDeY2atB.mjs.map +0 -1
  52. package/dist/msalServer-CqLXgWpO.mjs.map +0 -1
  53. package/dist/peoplesoft-DqO-9g-4.mjs.map +0 -1
  54. package/dist/utils-A_Lzklis.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useDialogs-BUzVrTSP.mjs","names":["Button","Dialog","DialogActions","DialogContent","DialogTitle","useEventCallback","useContext","useTranslation","DialogsContext","ReactNode","OpenDialogOptions","onClose","result","TResult","Promise","AlertOptions","title","ConfirmOptions","cancelText","DialogProps","payload","TPayload","open","OpenAlertDialog","message","options","OpenConfirmDialog","DialogComponent","React","ComponentType","OpenDialog","Component","CloseDialog","dialog","AlertDialogPayload","AlertDialogProps","AlertDialog","t0","$","_c","$i","Symbol","for","t","t1","t2","t3","t4","t5","t6","t7","t8","ConfirmDialogPayload","ConfirmDialogProps","ConfirmDialog","t9","t10","t11","t12","DialogHook","alert","confirm","close","useDialogs","undefined","message_0","options_0"],"sources":["../src/hooks/useDialogs.tsx"],"sourcesContent":["import {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n useEventCallback,\n} from \"@mui/material\";\nimport { useContext } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { DialogsContext } from \"../contexts/DialogsContext\";\nimport type { ReactNode } from \"react\";\n\nexport interface OpenDialogOptions<TResult> {\n onClose?: (result: TResult) => Promise<void>;\n}\n\nexport interface AlertOptions {\n title?: ReactNode;\n}\n\nexport interface ConfirmOptions {\n title?: ReactNode;\n cancelText?: ReactNode;\n}\n\nexport interface DialogProps<TPayload = undefined, TResult = void> {\n payload: TPayload;\n open: boolean;\n onClose: (result: TResult) => Promise<void>;\n}\n\nexport type OpenAlertDialog = (message: ReactNode, options?: AlertOptions) => Promise<void>;\n\nexport type OpenConfirmDialog = (message: ReactNode, options?: ConfirmOptions) => Promise<boolean>;\n\nexport type DialogComponent<TPayload, TResult> = React.ComponentType<\n DialogProps<TPayload, TResult>\n>;\n\nexport interface OpenDialog {\n <TPayload extends undefined, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload?: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n <TPayload, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n}\n\nexport type CloseDialog = <TResult>(dialog: Promise<TResult>, result: TResult) => Promise<TResult>;\n\nexport interface AlertDialogPayload extends AlertOptions {\n message: ReactNode;\n}\n\nexport type AlertDialogProps = DialogProps<AlertDialogPayload, void>;\n\nexport function AlertDialog({ open, payload, onClose }: Readonly<AlertDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose()} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\nexport interface ConfirmDialogPayload extends ConfirmOptions {\n message: ReactNode;\n}\n\nexport type ConfirmDialogProps = DialogProps<ConfirmDialogPayload, boolean>;\n\nexport function ConfirmDialog({ open, payload, onClose }: Readonly<ConfirmDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose(false)} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\ninterface DialogHook {\n alert: OpenAlertDialog;\n confirm: OpenConfirmDialog;\n open: OpenDialog;\n close: CloseDialog;\n}\n\nexport function useDialogs(): DialogHook {\n const { open, close } = useContext(DialogsContext);\n\n const alert = useEventCallback<OpenAlertDialog>((message, { ...options } = {}) =>\n open(AlertDialog, { ...options, message }),\n );\n\n const confirm = useEventCallback<OpenConfirmDialog>((message, { ...options } = {}) =>\n open(ConfirmDialog, { ...options, message }),\n );\n\n return { alert, confirm, open, close };\n}\n"],"mappings":";;;;;;;AA6DA,SAAOoC,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAD,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAAE,KAAA,GAAAA,KAAA,IAAAA,MAAA,GAAAF,EAAAE,MAAAC,OAAAC,IAAA,2BAAA;EAAAJ,EAAA,KAAA;CAAA;CAAqB,MAAA,EAAAhB,MAAAF,SAAAT,YAAA0B;CAC1B,MAAA,E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B,YAAAmB,OAAAoB,KAAAA,IAAA,CAAkB,IAAlBpB;GAAmB,OAC3EtB,KAAKc,aAAa;IAAA,GAAKX;IAAOD;GAAU,CAAC;EAAC;EAAAc,EAAA,KAAAhB;EAAAgB,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAD5C,MAAAsB,QAAcvD,iBAAkCgC,EAEhD;CAAE,IAAAO;CAAA,IAAAN,EAAA,OAAAhB,MAAA;EAEkDsB,MAAAqB,WAAApB,OAAA;GAAU,MAAA,EAAA,GAAAqB,cAAArB,OAAAmB,KAAAA,IAAA,CAAkB,IAAlBnB;GAAmB,OAC/EvB,KAAKgC,eAAe;IAAA,GAAK7B;IAAOD,SAAEA;GAAQ,CAAC;EAAC;EAAAc,EAAA,KAAAhB;EAAAgB,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAD9C,MAAAuB,UAAgBxD,iBAAoCuC,EAEpD;CAAE,IAAAC;CAAA,IAAAP,EAAA,OAAAsB,SAAAtB,EAAA,OAAAwB,SAAAxB,EAAA,OAAAuB,WAAAvB,EAAA,OAAAhB,MAAA;EAEKuB,KAAA;GAAAe;GAAAC;GAAAvC;GAAAwC;EAA8B;EAACxB,EAAA,KAAAsB;EAAAtB,EAAA,KAAAwB;EAAAxB,EAAA,KAAAuB;EAAAvB,EAAA,KAAAhB;EAAAgB,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAA/BO;AAA+B"}
1
+ {"version":3,"file":"useDialogs-BUzVrTSP.mjs","names":["open","options","message"],"sources":["../src/hooks/useDialogs.tsx"],"sourcesContent":["import {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n useEventCallback,\n} from \"@mui/material\";\nimport { useContext } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { DialogsContext } from \"../contexts/DialogsContext\";\nimport type { ReactNode } from \"react\";\n\nexport interface OpenDialogOptions<TResult> {\n onClose?: (result: TResult) => Promise<void>;\n}\n\nexport interface AlertOptions {\n title?: ReactNode;\n}\n\nexport interface ConfirmOptions {\n title?: ReactNode;\n cancelText?: ReactNode;\n}\n\nexport interface DialogProps<TPayload = undefined, TResult = void> {\n payload: TPayload;\n open: boolean;\n onClose: (result: TResult) => Promise<void>;\n}\n\nexport type OpenAlertDialog = (message: ReactNode, options?: AlertOptions) => Promise<void>;\n\nexport type OpenConfirmDialog = (message: ReactNode, options?: ConfirmOptions) => Promise<boolean>;\n\nexport type DialogComponent<TPayload, TResult> = React.ComponentType<\n DialogProps<TPayload, TResult>\n>;\n\nexport interface OpenDialog {\n <TPayload extends undefined, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload?: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n <TPayload, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n}\n\nexport type CloseDialog = <TResult>(dialog: Promise<TResult>, result: TResult) => Promise<TResult>;\n\nexport interface AlertDialogPayload extends AlertOptions {\n message: ReactNode;\n}\n\nexport type AlertDialogProps = DialogProps<AlertDialogPayload, void>;\n\nexport function AlertDialog({ open, payload, onClose }: Readonly<AlertDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose()} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\nexport interface ConfirmDialogPayload extends ConfirmOptions {\n message: ReactNode;\n}\n\nexport type ConfirmDialogProps = DialogProps<ConfirmDialogPayload, boolean>;\n\nexport function ConfirmDialog({ open, payload, onClose }: Readonly<ConfirmDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose(false)} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\ninterface DialogHook {\n alert: OpenAlertDialog;\n confirm: OpenConfirmDialog;\n open: OpenDialog;\n close: CloseDialog;\n}\n\nexport function useDialogs(): DialogHook {\n const { open, close } = useContext(DialogsContext);\n\n const alert = useEventCallback<OpenAlertDialog>((message, { ...options } = {}) =>\n open(AlertDialog, { ...options, message }),\n );\n\n const confirm = useEventCallback<OpenConfirmDialog>((message, { ...options } = {}) =>\n open(ConfirmDialog, { ...options, message }),\n );\n\n return { alert, confirm, open, close };\n}\n"],"mappings":";;;;;;;AA6DA,SAAO,YAAA,IAAA;CAAA,MAAA,IAAA,EAAA,EAAA;CAAA,IAAA,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAA,KAAA,GAAA,KAAA,IAAA,MAAA,GAAA,EAAA,MAAA,OAAA,IAAA,2BAAA;EAAA,EAAA,KAAA;CAAA;CAAqB,MAAA,EAAA,MAAA,SAAA,YAAA;CAC1B,MAAA,EAAA,MAAc,eAAe;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA;EAGwB,WAAM,QAAQ;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,QAAA,SAAA,EAAA,OAAA,GAAA;EACpD,KAAA,QAAO,SAAU,EAAE,qBAAqB;EAAC,EAAA,KAAA,QAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,IAAA;EAAvD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AA,IAAA,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAA,KAAA,GAAA,KAAA,IAAA,MAAA,GAAA,EAAA,MAAA,OAAA,IAAA,2BAAA;EAAA,EAAA,KAAA;CAAA;CACL,MAAA,EAAA,MAAA,UAAwB,WAAW,cAAc;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA;EAEH,MAAA,SAAA,OAAA;GAAU,MAAA,EAAA,GAAA,YAAA,OAAA,KAAA,IAAA,CAAkB,IAAlB;GAAmB,OAC3E,KAAK,aAAa;IAAA,GAAK;IAAO;GAAU,CAAC;EAAC;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAD5C,MAAA,QAAc,iBAAkC,EAEhD;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA;EAEkD,MAAA,WAAA,OAAA;GAAU,MAAA,EAAA,GAAA,cAAA,OAAA,KAAA,IAAA,CAAkB,IAAlB;GAAmB,OAC/E,KAAK,eAAe;IAAA,GAAKC;IAAO,SAAEC;GAAQ,CAAC;EAAC;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAD9C,MAAA,UAAgB,iBAAoC,EAEpD;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA,EAAA,OAAA,SAAA,EAAA,OAAA,WAAA,EAAA,OAAA,MAAA;EAEK,KAAA;GAAA;GAAA;GAAA;GAAA;EAA8B;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAA/B;AAA+B"}
@@ -15,7 +15,7 @@ import { createEnv } from "@t3-oss/env-core";
15
15
  const OFFLINE_USER_KEY = "wcz-auth-user";
16
16
  const OFFLINE_PHOTO_KEY = "wcz-auth-photo";
17
17
  /** One shift — matches Intune's default offline grace period. */
18
- const GRACE_PERIOD = 720 * 60 * 1e3;
18
+ const GRACE_PERIOD = 432e5;
19
19
  const recall = (key) => {
20
20
  if (typeof localStorage === "undefined") return null;
21
21
  try {
@@ -140,7 +140,7 @@ const getUser = ({ queryClient }) => {
140
140
  const getAccessToken = createServerOnlyFn(async (scopeKey) => {
141
141
  const session = await getAppSession();
142
142
  if (!session.data.refreshToken) throw new Error("No active session. User not signed in.");
143
- const { acquireDelegatedToken, SessionExpiredError } = await import("./entra-DFhYO6Sj.mjs");
143
+ const { acquireDelegatedToken, SessionExpiredError } = await import("./entra-CJSyeQsx.mjs");
144
144
  try {
145
145
  const { accessToken, refreshToken } = await acquireDelegatedToken({
146
146
  refreshToken: session.data.refreshToken,
@@ -258,4 +258,4 @@ const hasPermission = (user, key) => user ? permissions[key].some((group) => use
258
258
  //#endregion
259
259
  export { withOfflineFallback as _, getFieldStatus as a, rootRouteHead as c, getUser as d, userQueryOptions as f, clearSessionSnapshot as g, OFFLINE_PHOTO_KEY as h, buildUser as i, getAccessToken as l, serverEnv as m, WISTRON_PRIMARY_COLOR as n, hasPermission as o, getAppSession as p, WISTRON_SECONDARY_COLOR as r, requirePermission as s, Platform as t, getSessionUser as u };
260
260
 
261
- //# sourceMappingURL=utils-A_Lzklis.mjs.map
261
+ //# sourceMappingURL=utils-DjdexspV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DjdexspV.mjs","names":[],"sources":["../src/lib/auth/offline.ts","../src/env.ts","../src/lib/auth/session.ts","../src/lib/auth/user.ts","../src/lib/utils.ts"],"sourcesContent":["/**\n * Offline fallback for identity. The refresh token never leaves the sealed\n * httpOnly cookie — what is cached here is only the display snapshot (user\n * claims and avatar) so the UI and offline route permissions can still work\n * while the server is unreachable. Server requests remain independently\n * authorized. At-rest protection is the device's OS login and disk encryption.\n */\n\nexport const OFFLINE_USER_KEY = \"wcz-auth-user\";\nexport const OFFLINE_PHOTO_KEY = \"wcz-auth-photo\";\n\n/** One shift — matches Intune's default offline grace period. */\nconst GRACE_PERIOD = 12 * 60 * 60 * 1000;\n\ntype Cached<T> = { value: T; savedAt: number };\n\nconst recall = <T>(key: string): T | null => {\n if (typeof localStorage === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const { value, savedAt } = JSON.parse(raw) as Cached<T>;\n if (Date.now() - savedAt > GRACE_PERIOD) {\n localStorage.removeItem(key);\n return null;\n }\n return value;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n};\n\nconst remember = (key: string, value: unknown): void => {\n if (typeof localStorage === \"undefined\") return;\n try {\n if (value === null || value === undefined) localStorage.removeItem(key);\n else localStorage.setItem(key, JSON.stringify({ value, savedAt: Date.now() }));\n } catch {\n // Storage full or blocked — the offline fallback is best-effort.\n }\n};\n\nconst isOfflineFailure = (error: unknown): boolean =>\n (typeof navigator !== \"undefined\" && !navigator.onLine) || error instanceof TypeError;\n\n/**\n * Answers from the server when reachable, remembering the result; when the call\n * has a transport failure, replays the last result instead, for up to\n * {@link GRACE_PERIOD} since it was last confirmed.\n *\n * Cached values are untrusted client state. Server authorization must never\n * depend on them.\n */\nexport const withOfflineFallback = async <T>(\n key: string,\n fetchFresh: () => Promise<T>,\n): Promise<T | null> => {\n try {\n const fresh = await fetchFresh();\n remember(key, fresh);\n return fresh;\n } catch (error) {\n if (!isOfflineFailure(error)) throw error;\n return recall<T>(key);\n }\n};\n\n/** Drops the cached identity. Call on logout, before leaving the page. */\nexport const clearSessionSnapshot = (): void => {\n if (typeof localStorage === \"undefined\") return;\n localStorage.removeItem(OFFLINE_USER_KEY);\n localStorage.removeItem(OFFLINE_PHOTO_KEY);\n localStorage.setItem(\"wcz-auth-logout\", String(Date.now()));\n};\n\nif (typeof window !== \"undefined\")\n window.addEventListener(\"storage\", (event) => {\n if (event.key === \"wcz-auth-logout\") location.href = \"/auth/logout\";\n });\n","import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {\n VITE_MUI_LICENSE_KEY: z.string(),\n },\n runtimeEnv: import.meta.env,\n emptyStringAsUndefined: true,\n});\n\nexport const serverEnv = createEnv({\n server: {\n ENTRA_CLIENT_ID: z.string().min(1),\n ENTRA_TENANT_ID: z.string().min(1),\n ENTRA_CLIENT_SECRET: z.string().min(1),\n SESSION_SECRET: z.string().min(32),\n FILE_BASE_URL: z.string().min(1).optional(),\n APPROVAL_BASE_URL: z.string().min(1).optional(),\n PEOPLESOFT_BASE_URL: z.string().min(1).optional(),\n EMAIL_BASE_URL: z.string().min(1).optional(),\n AI_BASE_URL: z.string().min(1).optional(),\n AI_SUBSCRIPTION_KEY: z.string().min(1).optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n","import { serverEnv } from \"~/env\";\r\n\r\nexport const getAppSession = async () => {\r\n // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\r\n // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\r\n // this helper is only ever called server-side, and all callers already await it.\r\n // Aliased off the `use*` name so it isn't mistaken for a React hook (it's a\r\n // server session helper, not a hook).\r\n const { useSession: getSession } = await import(\"@tanstack/react-start/server\");\r\n\r\n return getSession({\r\n name: \"session\",\r\n password: serverEnv.SESSION_SECRET,\r\n });\r\n};\r\n","import { queryOptions } from \"@tanstack/react-query\";\r\nimport { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\r\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\r\nimport type { User } from \"~/models/User\";\r\nimport { OFFLINE_USER_KEY, withOfflineFallback } from \"./offline\";\r\nimport { getAppSession } from \"./session\";\r\n\r\n/**\r\n * Reads the signed-in user from the session cookie, or null. As a server function\r\n * it runs in-process when called on the server (SSR, middleware) and as an RPC\r\n * when called from the client — so it doubles as the client `queryFn`.\r\n */\r\nexport const getSessionUser = createServerFn({ method: \"GET\" }).handler(\r\n async (): Promise<User | null> => {\r\n const session = await getAppSession();\r\n return session.data.user ?? null;\r\n },\r\n);\r\n\r\n/**\r\n * Client-side query for the signed-in user. Shared between `getUser` (route\r\n * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the\r\n * observer is what seeds the offline snapshot on the very first page load\r\n * (`beforeLoad` does not re-run after SSR hydration) and what makes\r\n * `refetchOnReconnect` fire once connectivity returns.\r\n */\r\nexport const userQueryOptions = queryOptions({\r\n queryKey: [\"auth\", \"user\"],\r\n queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),\r\n staleTime: Infinity,\r\n // Default \"online\" pauses the query (never calling queryFn) once the browser\r\n // reports no connection — which is exactly when the fallback is needed.\r\n networkMode: \"offlineFirst\",\r\n // Back online: re-confirm the session and re-stamp the snapshot's grace period.\r\n refetchOnReconnect: \"always\",\r\n});\r\n\r\nexport const getUser = ({ queryClient }: QueryClientParam): Promise<User | null> => {\r\n if (import.meta.env.SSR) return getSessionUser();\r\n\r\n return queryClient.ensureQueryData(userQueryOptions);\r\n};\r\n\r\n/**\r\n * Server-only token acquisition: a delegated access token for the given API\r\n * scope, minted from the user's session refresh token. Entra rotates the refresh\r\n * token on each use, so the rotated token is persisted back to the session. Use\r\n * inside server functions and middleware — it is stripped from the client bundle\r\n * and throws if called there.\r\n */\r\nexport const getAccessToken = createServerOnlyFn(\r\n async (scopeKey: keyof typeof definedScopes): Promise<string> => {\r\n const session = await getAppSession();\r\n if (!session.data.refreshToken) throw new Error(\"No active session. User not signed in.\");\r\n\r\n // Dynamic import so `entra` (and its `@azure/msal-node` dependency) stays out\r\n // of the client graph — this module also exports the isomorphic `getUser`.\r\n const { acquireDelegatedToken, SessionExpiredError } = await import(\"./entra\");\r\n try {\r\n const { accessToken, refreshToken } = await acquireDelegatedToken({\r\n refreshToken: session.data.refreshToken,\r\n scopes: definedScopes[scopeKey],\r\n });\r\n\r\n if (refreshToken !== session.data.refreshToken) await session.update({ refreshToken });\r\n return accessToken;\r\n } catch (error) {\r\n // Revoked/expired refresh token: clear the dead session and answer 401 so\r\n // the client can redirect to /auth/login, instead of surfacing a 500.\r\n if (error instanceof SessionExpiredError) {\r\n await session.clear();\r\n throw Response.json(\r\n { message: \"Unauthorized: Session expired, sign in again\" },\r\n { status: 401 },\r\n );\r\n }\r\n throw error;\r\n }\r\n },\r\n);\r\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\r\nimport { redirect } from \"@tanstack/react-router\";\r\nimport type { ParsedLocation } from \"@tanstack/react-router\";\r\nimport { manifest, permissions } from \"virtual:wcz-layout\";\r\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\r\nimport type { TokenPayload } from \"~/models/TokenPayload\";\r\nimport type { User } from \"~/models/User\";\r\nimport { getUser } from \"./auth/user\";\r\n\r\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\r\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\r\n\r\nexport class Platform {\r\n static get isAndroid() {\r\n return /android/i.test(this.userAgent);\r\n }\r\n static get isIOS() {\r\n return /iPad|iPhone|iPod/.test(this.userAgent);\r\n }\r\n static get isWindows() {\r\n return /windows/i.test(this.userAgent);\r\n }\r\n static get isMacOS() {\r\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\r\n }\r\n\r\n private static get userAgent() {\r\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\r\n }\r\n}\r\n\r\ninterface RootRouteHeadOptions {\r\n manifest?: string;\r\n}\r\n\r\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\r\n meta: [\r\n { charSet: \"utf-8\" },\r\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\r\n { title: manifest.name },\r\n { name: \"og:type\", content: \"website\" },\r\n { name: \"og:title\", content: manifest.name },\r\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\r\n ],\r\n links: [\r\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\r\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\r\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\r\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\r\n { rel: \"icon\", href: \"/favicon.ico\" },\r\n ],\r\n});\r\n\r\nexport const requirePermission = (permissionKey: keyof typeof permissions) => {\r\n return async ({ location, context }: { location: ParsedLocation; context: QueryClientParam }) => {\r\n const user = await getUser({ queryClient: context.queryClient });\r\n\r\n if (!user)\r\n throw redirect({\r\n href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,\r\n reloadDocument: true,\r\n });\r\n\r\n if (!hasPermission(user, permissionKey))\r\n throw new Error(\"You do not have permission to access this page.\");\r\n\r\n return { user };\r\n };\r\n};\r\n\r\n/* Internal Utils */\r\nexport type FormOmittedProps =\r\n | \"name\"\r\n | \"value\"\r\n | \"onChange\"\r\n | \"onBlur\"\r\n | \"error\"\r\n | \"helperText\"\r\n | \"renderInput\"\r\n | \"type\"\r\n | \"aria-label\";\r\n\r\nexport const getFieldStatus = (field: AnyFieldApi) => {\r\n const { meta } = field.state;\r\n\r\n const isTouched = meta.isTouched;\r\n const hasError = !!meta.errors.length;\r\n const helperText = meta.errors[0]?.message;\r\n\r\n return { isTouched, hasError, helperText };\r\n};\r\n\r\nexport const toKebabCase = (str: string): string => {\r\n return str\r\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\r\n .replaceAll(/[\\s_]+/g, \"-\")\r\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\r\n .toLowerCase()\r\n .replaceAll(/-+/g, \"-\")\r\n .replaceAll(/(^-|-$)/g, \"\");\r\n};\r\n\r\nconst permissionGroups = new Set<string>(Object.values(permissions).flat());\r\n\r\nexport const buildUser = (payload: TokenPayload): User => ({\r\n name: payload.name?.split(\"/\")[0],\r\n email: payload.preferred_username?.toLowerCase(),\r\n department: payload.department?.toUpperCase() || \"\",\r\n employeeId: payload.employeeId?.toUpperCase() || \"\",\r\n companyName: payload.companyName || \"\",\r\n groups: payload.groups?.filter((group) => permissionGroups.has(group)) ?? [],\r\n});\r\n\r\nexport const hasPermission = (user: User | null, key: keyof typeof permissions): boolean =>\r\n user ? permissions[key].some((group) => user.groups.includes(group)) : false;\r\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;;AAGjC,MAAM,eAAe;AAIrB,MAAM,UAAa,QAA0B;CAC3C,IAAI,OAAO,iBAAiB,aAAa,OAAO;CAChD,IAAI;EACF,MAAM,MAAM,aAAa,QAAQ,GAAG;EACpC,IAAI,CAAC,KAAK,OAAO;EACjB,MAAM,EAAE,OAAO,YAAY,KAAK,MAAM,GAAG;EACzC,IAAI,KAAK,IAAI,IAAI,UAAU,cAAc;GACvC,aAAa,WAAW,GAAG;GAC3B,OAAO;EACT;EACA,OAAO;CACT,QAAQ;EACN,aAAa,WAAW,GAAG;EAC3B,OAAO;CACT;AACF;AAEA,MAAM,YAAY,KAAa,UAAyB;CACtD,IAAI,OAAO,iBAAiB,aAAa;CACzC,IAAI;EACF,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,aAAa,WAAW,GAAG;OACjE,aAAa,QAAQ,KAAK,KAAK,UAAU;GAAE;GAAO,SAAS,KAAK,IAAI;EAAE,CAAC,CAAC;CAC/E,QAAQ,CACN;AAEJ;AAEA,MAAM,oBAAoB,UACvB,OAAO,cAAc,eAAe,CAAC,UAAU,UAAW,iBAAiB;;;;;;;;;AAU9E,MAAa,sBAAsB,OACjC,KACA,eACsB;CACtB,IAAI;EACF,MAAM,QAAQ,MAAM,WAAW;EAC/B,SAAS,KAAK,KAAK;EACnB,OAAO;CACT,SAAS,OAAO;EACd,IAAI,CAAC,iBAAiB,KAAK,GAAG,MAAM;EACpC,OAAO,OAAU,GAAG;CACtB;AACF;;AAGA,MAAa,6BAAmC;CAC9C,IAAI,OAAO,iBAAiB,aAAa;CACzC,aAAa,WAAW,gBAAgB;CACxC,aAAa,WAAW,iBAAiB;CAC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MAAM,MAAM,GAAG,CAAC,CAAC;CAC/B,OAAO,QAAQ,oBAAoB,YAAY;CAC/C,YAAY,QAAQ,YAAY,YAAY,KAAK;CACjD,YAAY,QAAQ,YAAY,YAAY,KAAK;CACjD,aAAa,QAAQ,eAAe;CACpC,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,iBAAiB,IAAI,KAAK,CAAC,KAAK,CAAA;AAC5E;AAEA,MAAa,iBAAiB,MAAmB,QAC/C,OAAO,YAAY,IAAI,CAAC,MAAM,UAAU,KAAK,OAAO,SAAS,KAAK,CAAC,IAAI"}
package/dist/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { o as hasPermission, s as requirePermission, t as Platform } from "./utils-A_Lzklis.mjs";
1
+ import { o as hasPermission, s as requirePermission, t as Platform } from "./utils-DjdexspV.mjs";
2
2
  import i18next, { t } from "i18next";
3
3
  import { createEnv } from "@t3-oss/env-core";
4
4
  import { uuidv7 } from "uuidv7";
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["z","VaultConfigSchema","object","VAULT_ADDRESS","url","VAULT_USERNAME","string","min","VAULT_PASSWORD","VAULT_SECRET_PATH","VAULT_MOUNT_POINT","default","VaultConfig","infer","fs","https","createRequire","path","axios","loadEnv","VaultConfigSchema","Resource","Plugin","fetchVaultSecrets","env","Record","Promise","config","parse","VAULT_ADDRESS","VAULT_USERNAME","VAULT_PASSWORD","VAULT_SECRET_PATH","VAULT_MOUNT_POINT","client","create","baseURL","httpsAgent","Agent","rejectUnauthorized","data","loginData","post","password","secretData","get","headers","auth","client_token","secrets","Error","Object","fromEntries","entries","map","key","value","JSON","stringify","loadVaultSecrets","command","process","cwd","forEach","trim","e","console","warn","message","loadLocaleResources","localesPath","addWatchFile","existsSync","mkdirSync","recursive","enPath","join","writeFileSync","files","readdirSync","resources","file","filter","f","endsWith","lang","basename","filePath","translation","readFileSync","require","import","meta","url","dayjsLocaleImports","keys","toLowerCase","resolve","ensurePermissionsFile","permissionsPath","dir","dirname","ensureScopesFile","scopesPath","loadManifest","manifestPath","name","viteWczLayout","virtualModuleId","resolvedVirtualModuleId","envPath","enforce","configResolved","resolvedConfig","root","_","configureServer","server","refresh","includes","module","moduleGraph","getModuleById","invalidateModule","ws","send","type","watcher","add","on","resolveId","id","load","bind","manifest","normalizedPermissionsPath","split","sep","posix","normalizedScopesPath","normalizedEnvPath"],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\r\nimport https from \"node:https\";\r\nimport { createRequire } from \"node:module\";\r\nimport path from \"node:path\";\r\nimport axios from \"axios\";\r\nimport { loadEnv } from \"vite\";\r\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\r\nimport type { Resource } from \"i18next\";\r\nimport type { Plugin } from \"vite\";\r\n\r\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\r\n const config = VaultConfigSchema.parse(env);\r\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\r\n config;\r\n\r\n const client = axios.create({\r\n baseURL: VAULT_ADDRESS,\r\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\r\n });\r\n\r\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\r\n password: VAULT_PASSWORD,\r\n });\r\n\r\n const { data: secretData } = await client.get(\r\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\r\n {\r\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\r\n },\r\n );\r\n\r\n const secrets = secretData?.data?.data;\r\n if (!secrets) throw new Error(\"No secrets found\");\r\n\r\n return Object.fromEntries(\r\n Object.entries(secrets).map(([key, value]) => [\r\n key,\r\n typeof value === \"string\" ? value : JSON.stringify(value),\r\n ]),\r\n );\r\n}\r\n\r\nasync function loadVaultSecrets(command: string): Promise<void> {\r\n if (command !== \"serve\") return;\r\n\r\n const env = loadEnv(\"development\", process.cwd(), \"\");\r\n if (!env.VAULT_ADDRESS) return;\r\n\r\n try {\r\n const secrets = await fetchVaultSecrets(env);\r\n Object.entries(secrets).forEach(([key, value]) => {\r\n process.env[key] = env[key]?.trim() ? env[key] : value;\r\n });\r\n } catch (e) {\r\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\r\n }\r\n}\r\n\r\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\r\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\r\n\r\n const enPath = path.join(localesPath, \"en.json\");\r\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\r\n\r\n const files = fs.readdirSync(localesPath);\r\n const resources: Resource = {};\r\n\r\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\r\n const lang = path.basename(file, \".json\");\r\n const filePath = path.join(localesPath, file);\r\n try {\r\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\r\n } catch {\r\n resources[lang] = { translation: {} };\r\n }\r\n addWatchFile(filePath);\r\n }\r\n\r\n return resources;\r\n}\r\n\r\nconst require = createRequire(import.meta.url);\r\n\r\nfunction dayjsLocaleImports(resources: Resource): string {\r\n return Object.keys(resources)\r\n .map((lang) => lang.toLowerCase())\r\n .filter((lang) => {\r\n try {\r\n require.resolve(`dayjs/locale/${lang}.js`);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n })\r\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\r\n .join(\"\\n\");\r\n}\r\n\r\nfunction ensurePermissionsFile(\r\n permissionsPath: string,\r\n addWatchFile: (path: string) => void,\r\n): void {\r\n const dir = path.dirname(permissionsPath);\r\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\r\n if (!fs.existsSync(permissionsPath)) {\r\n fs.writeFileSync(\r\n permissionsPath,\r\n 'export const permissions = {\\n admin: [\"wcz-developers\"]\\n} as const;',\r\n );\r\n }\r\n addWatchFile(permissionsPath);\r\n}\r\n\r\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\r\n const dir = path.dirname(scopesPath);\r\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\r\n if (!fs.existsSync(scopesPath)) {\r\n fs.writeFileSync(scopesPath, \"export const scopes = {\\n} as const;\");\r\n }\r\n addWatchFile(scopesPath);\r\n}\r\n\r\nfunction loadManifest(\r\n manifestPath: string,\r\n addWatchFile: (path: string) => void,\r\n): { name: string } & Record<string, unknown> {\r\n addWatchFile(manifestPath);\r\n try {\r\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\r\n } catch {\r\n return { name: \"\" };\r\n }\r\n}\r\n\r\nexport function viteWczLayout(): Plugin {\r\n const virtualModuleId = \"virtual:wcz-layout\";\r\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\r\n\r\n let localesPath: string;\r\n let permissionsPath: string;\r\n let scopesPath: string;\r\n let envPath: string;\r\n let manifestPath: string;\r\n\r\n return {\r\n name: \"vite:wcz-layout\",\r\n enforce: \"pre\",\r\n configResolved(resolvedConfig) {\r\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\r\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\r\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\r\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\r\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\r\n },\r\n async config(_, { command }) {\r\n await loadVaultSecrets(command);\r\n },\r\n configureServer(server) {\r\n const refresh = (filePath: string) => {\r\n if (\r\n filePath.includes(localesPath) ||\r\n filePath === permissionsPath ||\r\n filePath === scopesPath ||\r\n filePath === envPath ||\r\n filePath === manifestPath\r\n ) {\r\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\r\n if (module) server.moduleGraph.invalidateModule(module);\r\n server.ws.send({ type: \"full-reload\", path: \"*\" });\r\n }\r\n };\r\n\r\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\r\n server.watcher.on(\"add\", refresh);\r\n server.watcher.on(\"change\", refresh);\r\n server.watcher.on(\"unlink\", refresh);\r\n },\r\n resolveId(id) {\r\n if (id === virtualModuleId) return resolvedVirtualModuleId;\r\n return null;\r\n },\r\n load(id) {\r\n if (id !== resolvedVirtualModuleId) return null;\r\n\r\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\r\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\r\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\r\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\r\n\r\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\r\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\r\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\r\n return `\r\n ${dayjsLocaleImports(resources)}\r\n export const resources = ${JSON.stringify(resources)};\r\n export const manifest = ${JSON.stringify(manifest)};\r\n export { permissions } from \"${normalizedPermissionsPath}\";\r\n export { scopes } from \"${normalizedScopesPath}\";\r\n export { serverEnv } from \"${normalizedEnvPath}\";\r\n `;\r\n },\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAEA,MAAaC,oBAAoBD,EAAEE,OAAO;CACxCC,eAAeH,EAAEI,IAAI;CACrBC,gBAAgBL,EAAEM,OAAO,CAAC,CAACC,IAAI,CAAC;CAChCC,gBAAgBR,EAAEM,OAAO,CAAC,CAACC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GAC3E,MAAMG,oBAAoB9B,QAAQ0B,MAAMvH,KAAKwH,GAAG,CAAC,CAAC7D,KAAK3D,KAAKyH,MAAMD,GAAG;GACrE,OAAO;cACC3C,mBAAmBd,SAAS,EAAC;uCACJvB,KAAKC,UAAUsB,SAAS,EAAC;sCAC1BvB,KAAKC,UAAU4E,QAAQ,EAAC;2CACnBC,0BAAyB;sCAC9BI,qBAAoB;yCACjBC,kBAAiB;;EAEtD;CACF;AACF"}
1
+ {"version":3,"file":"vite.mjs","names":[],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\r\nimport https from \"node:https\";\r\nimport { createRequire } from \"node:module\";\r\nimport path from \"node:path\";\r\nimport axios from \"axios\";\r\nimport { loadEnv } from \"vite\";\r\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\r\nimport type { Resource } from \"i18next\";\r\nimport type { Plugin } from \"vite\";\r\n\r\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\r\n const config = VaultConfigSchema.parse(env);\r\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\r\n config;\r\n\r\n const client = axios.create({\r\n baseURL: VAULT_ADDRESS,\r\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\r\n });\r\n\r\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\r\n password: VAULT_PASSWORD,\r\n });\r\n\r\n const { data: secretData } = await client.get(\r\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\r\n {\r\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\r\n },\r\n );\r\n\r\n const secrets = secretData?.data?.data;\r\n if (!secrets) throw new Error(\"No secrets found\");\r\n\r\n return Object.fromEntries(\r\n Object.entries(secrets).map(([key, value]) => [\r\n key,\r\n typeof value === \"string\" ? value : JSON.stringify(value),\r\n ]),\r\n );\r\n}\r\n\r\nasync function loadVaultSecrets(command: string): Promise<void> {\r\n if (command !== \"serve\") return;\r\n\r\n const env = loadEnv(\"development\", process.cwd(), \"\");\r\n if (!env.VAULT_ADDRESS) return;\r\n\r\n try {\r\n const secrets = await fetchVaultSecrets(env);\r\n Object.entries(secrets).forEach(([key, value]) => {\r\n process.env[key] = env[key]?.trim() ? env[key] : value;\r\n });\r\n } catch (e) {\r\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\r\n }\r\n}\r\n\r\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\r\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\r\n\r\n const enPath = path.join(localesPath, \"en.json\");\r\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\r\n\r\n const files = fs.readdirSync(localesPath);\r\n const resources: Resource = {};\r\n\r\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\r\n const lang = path.basename(file, \".json\");\r\n const filePath = path.join(localesPath, file);\r\n try {\r\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\r\n } catch {\r\n resources[lang] = { translation: {} };\r\n }\r\n addWatchFile(filePath);\r\n }\r\n\r\n return resources;\r\n}\r\n\r\nconst require = createRequire(import.meta.url);\r\n\r\nfunction dayjsLocaleImports(resources: Resource): string {\r\n return Object.keys(resources)\r\n .map((lang) => lang.toLowerCase())\r\n .filter((lang) => {\r\n try {\r\n require.resolve(`dayjs/locale/${lang}.js`);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n })\r\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\r\n .join(\"\\n\");\r\n}\r\n\r\nfunction ensurePermissionsFile(\r\n permissionsPath: string,\r\n addWatchFile: (path: string) => void,\r\n): void {\r\n const dir = path.dirname(permissionsPath);\r\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\r\n if (!fs.existsSync(permissionsPath)) {\r\n fs.writeFileSync(\r\n permissionsPath,\r\n 'export const permissions = {\\n admin: [\"wcz-developers\"]\\n} as const;',\r\n );\r\n }\r\n addWatchFile(permissionsPath);\r\n}\r\n\r\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\r\n const dir = path.dirname(scopesPath);\r\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\r\n if (!fs.existsSync(scopesPath)) {\r\n fs.writeFileSync(scopesPath, \"export const scopes = {\\n} as const;\");\r\n }\r\n addWatchFile(scopesPath);\r\n}\r\n\r\nfunction loadManifest(\r\n manifestPath: string,\r\n addWatchFile: (path: string) => void,\r\n): { name: string } & Record<string, unknown> {\r\n addWatchFile(manifestPath);\r\n try {\r\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\r\n } catch {\r\n return { name: \"\" };\r\n }\r\n}\r\n\r\nexport function viteWczLayout(): Plugin {\r\n const virtualModuleId = \"virtual:wcz-layout\";\r\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\r\n\r\n let localesPath: string;\r\n let permissionsPath: string;\r\n let scopesPath: string;\r\n let envPath: string;\r\n let manifestPath: string;\r\n\r\n return {\r\n name: \"vite:wcz-layout\",\r\n enforce: \"pre\",\r\n configResolved(resolvedConfig) {\r\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\r\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\r\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\r\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\r\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\r\n },\r\n async config(_, { command }) {\r\n await loadVaultSecrets(command);\r\n },\r\n configureServer(server) {\r\n const refresh = (filePath: string) => {\r\n if (\r\n filePath.includes(localesPath) ||\r\n filePath === permissionsPath ||\r\n filePath === scopesPath ||\r\n filePath === envPath ||\r\n filePath === manifestPath\r\n ) {\r\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\r\n if (module) server.moduleGraph.invalidateModule(module);\r\n server.ws.send({ type: \"full-reload\", path: \"*\" });\r\n }\r\n };\r\n\r\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\r\n server.watcher.on(\"add\", refresh);\r\n server.watcher.on(\"change\", refresh);\r\n server.watcher.on(\"unlink\", refresh);\r\n },\r\n resolveId(id) {\r\n if (id === virtualModuleId) return resolvedVirtualModuleId;\r\n return null;\r\n },\r\n load(id) {\r\n if (id !== resolvedVirtualModuleId) return null;\r\n\r\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\r\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\r\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\r\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\r\n\r\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\r\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\r\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\r\n return `\r\n ${dayjsLocaleImports(resources)}\r\n export const resources = ${JSON.stringify(resources)};\r\n export const manifest = ${JSON.stringify(manifest)};\r\n export { permissions } from \"${normalizedPermissionsPath}\";\r\n export { scopes } from \"${normalizedScopesPath}\";\r\n export { serverEnv } from \"${normalizedEnvPath}\";\r\n `;\r\n },\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAEA,MAAa,oBAAoB,EAAE,OAAO;CACxC,eAAe,EAAE,IAAI;CACrB,gBAAgB,EAAE,OAAO,CAAC,CAAC,I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AAC;IACnD;GACF;GAEA,OAAO,QAAQ,IAAI;IAAC;IAAa;IAAiB;IAAY;IAAS;GAAY,CAAC;GACpF,OAAO,QAAQ,GAAG,OAAO,OAAO;GAChC,OAAO,QAAQ,GAAG,UAAU,OAAO;GACnC,OAAO,QAAQ,GAAG,UAAU,OAAO;EACrC;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,iBAAiB,OAAO;GACnC,OAAO;EACT;EACA,KAAK,IAAI;GACP,IAAI,OAAO,yBAAyB,OAAO;GAE3C,MAAM,YAAY,oBAAoB,aAAa,KAAK,aAAa,KAAK,IAAI,CAAC;GAC/E,sBAAsB,iBAAiB,KAAK,aAAa,KAAK,IAAI,CAAC;GACnE,iBAAiB,YAAY,KAAK,aAAa,KAAK,IAAI,CAAC;GACzD,MAAM,WAAW,aAAa,cAAc,KAAK,aAAa,KAAK,IAAI,CAAC;GAExE,MAAM,4BAA4B,gBAAgB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GACrF,MAAM,uBAAuB,WAAW,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GAC3E,MAAM,oBAAoB,QAAQ,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GACrE,OAAO;cACC,mBAAmB,SAAS,EAAC;uCACJ,KAAK,UAAU,SAAS,EAAC;sCAC1B,KAAK,UAAU,QAAQ,EAAC;2CACnB,0BAAyB;sCAC9B,qBAAoB;yCACjB,kBAAiB;;EAEtD;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wcz-layout",
3
- "version": "9.6.4",
3
+ "version": "9.6.6",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "tanstack-intent"
@@ -69,12 +69,12 @@
69
69
  "prepublishOnly": "npm run build"
70
70
  },
71
71
  "dependencies": {
72
- "@azure/msal-node": "^5.4.3",
72
+ "@azure/msal-node": "^5.5.0",
73
73
  "@t3-oss/env-core": "^0.13.11",
74
74
  "i18next": "^26.3.6",
75
75
  "i18next-browser-languagedetector": "^8.2.1",
76
76
  "jose": "^6.2.8",
77
- "react-dropzone": "^20.0.0",
77
+ "react-dropzone": "^20.1.0",
78
78
  "react-i18next": "^17.0.11",
79
79
  "react-intersection-observer": "^11.0.0",
80
80
  "react-number-format": "^5.4.5",
@@ -84,20 +84,20 @@
84
84
  "devDependencies": {
85
85
  "@arethetypeswrong/core": "^0.18.5",
86
86
  "@rolldown/plugin-babel": "^0.2.3",
87
- "@tanstack/ai": "^0.42.0",
88
- "@tanstack/ai-client": "^0.22.1",
89
- "@tanstack/ai-openai": "^0.17.1",
90
- "@tanstack/highlight": "^0.0.9",
87
+ "@tanstack/ai": "^0.43.1",
88
+ "@tanstack/ai-client": "^0.23.1",
89
+ "@tanstack/ai-openai": "^0.18.0",
90
+ "@tanstack/highlight": "^0.0.10",
91
91
  "@types/node": "^26.1.2",
92
92
  "@types/react": "^19.2.18",
93
93
  "@types/react-dom": "^19.2.4",
94
94
  "@vitejs/plugin-react": "^6.0.5",
95
95
  "babel-plugin-react-compiler": "^1.0.0",
96
96
  "nitro": "npm:nitro-nightly@latest",
97
- "publint": "^0.3.22",
97
+ "publint": "^0.3.23",
98
98
  "typescript": "^7.0.2",
99
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.7",
100
- "vite-plus": "0.2.7"
99
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.8",
100
+ "vite-plus": "0.2.8"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "@emotion/cache": "11.x",
@@ -121,7 +121,7 @@
121
121
  "zod": "4.x"
122
122
  },
123
123
  "overrides": {
124
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.7"
124
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.8"
125
125
  },
126
126
  "packageManager": "npm@12.0.2"
127
127
  }
@@ -7,12 +7,13 @@ description: "Use when: creating or modifying TanStack DB collections, live quer
7
7
 
8
8
  ## Rules
9
9
 
10
- - Use `eager` syncMode for top-level collections, `on-demand` for child/relational data.
10
+ - Use `eager` syncMode for top-level collections, `on-demand` for child/relational data and for any collection expected to exceed ~10k rows.
11
11
  - Always preload every `eager` collection used by a route, including collections used only by components rendered under that route. Do not preload `on-demand` collections.
12
+ - On detail routes keyed by a param, guard the loader with `queryOnce` (from `@tanstack/react-db`) — the route's `where` plus `.findOne()` — and `throw notFound()` (from `@tanstack/react-router`) when it resolves to `undefined`. It works for both sync modes, and for `on-demand` it warms the subset's query-cache entry. It is one-shot, so the component still needs `useLiveQuery`.
12
13
  - Use `useLiveQuery` for list/grid pages and `useLiveSuspenseQuery` for detail components wrapped in suspense.
13
14
  - Shape data in the collection query whenever possible: filter, order, group and aggregate only the fields the consumer needs. Do not load broad results and further filter or transform them in component code.
14
15
  - For mutations use `createOptimisticAction` — mirror the server mutation in `onMutate`, then call the server function in `mutationFn` and await `utils.refetch()` on every collection the server function writes.
15
- - For on-demand subset loading, convert `meta.loadSubsetOptions` with `fromTanDb()` (from `agnostic-query/tanstack-db`) before passing it to the server fn, and set `autoIndex: "eager"` with `defaultIndexType: BasicIndex` (from `@tanstack/react-db`).
16
+ - For on-demand subset loading, convert `meta.loadSubsetOptions` with `fromTanDb()` (from `agnostic-query/tanstack-db`) before passing it to the server fn, and set `syncMode: "on-demand"`, `autoIndex: "eager"` and `defaultIndexType: BasicIndex` (from `@tanstack/react-db`).
16
17
 
17
18
  ## File Placement
18
19
 
@@ -38,7 +39,7 @@ export const librariesCollection = createCollection(
38
39
  }),
39
40
  );
40
41
 
41
- // src/db-collections/<feature>.ts — child/relational (on-demand)
42
+ // src/db-collections/<feature>.ts — child/relational or >10k rows (on-demand)
42
43
  import { BasicIndex } from "@tanstack/react-db";
43
44
  import { fromTanDb } from "agnostic-query/tanstack-db";
44
45
 
@@ -62,6 +63,20 @@ export const Route = createFileRoute("/")({
62
63
  },
63
64
  });
64
65
 
66
+ // Detail route — not-found guard
67
+ export const Route = createFileRoute("/libraries/$libraryId")({
68
+ loader: async ({ params }) => {
69
+ const library = await queryOnce((q) =>
70
+ q
71
+ .from({ library: libraryCollection })
72
+ .where(({ library }) => eq(library.id, params.libraryId))
73
+ .findOne(),
74
+ );
75
+
76
+ if (!library) throw notFound();
77
+ },
78
+ });
79
+
65
80
  // simple query
66
81
  const { data, isLoading } = useLiveQuery((q) =>
67
82
  q.from({ library: libraryCollection }).orderBy(({ library }) => library.name, "asc"),
@@ -7,6 +7,7 @@ description: "Use when: defining or updating Drizzle ORM table schemas, relation
7
7
 
8
8
  ## Rules
9
9
 
10
+ - One table per file, named after the table (e.g. `bookTable` lives in `book.ts`). Never put multiple tables in one file, even when they are related — a parent and its children each get their own file.
10
11
  - Always use `uuid` for primary keys, and `snakeCase` for generating tables.
11
12
  - For `uuid` columns, do not generate random values in the schema. Client should generate UUIDs when creating new records.
12
13
  - Always add `withTimezone: true` to timestamp columns.
@@ -24,7 +25,7 @@ drizzle-orm - defineRelations utility
24
25
  drizzle-orm/pg-core - snakeCase table builder and column types
25
26
  drizzle-orm/zod - createSelectSchema
26
27
  zod - Zod
27
- src/server/db/schemas/ - Drizzle table schemas and relations
28
+ src/server/db/schemas/ - Drizzle table schemas, one table per file + relations.ts
28
29
  src/server/db/migrations/ - Drizzle migration files
29
30
  src/lib/schemas/ - Zod schemas (shared between client and server)
30
31
  wcz-layout/utils - `t` translation function
@@ -33,7 +34,13 @@ wcz-layout/utils - `t` translation function
33
34
  ## Examples
34
35
 
35
36
  ```ts
36
- // src/server/db/schemas/<feature>.ts
37
+ // src/server/db/schemas/library.ts
38
+ export const libraryTable = snakeCase.table("libraries", {
39
+ id: uuid().primaryKey(),
40
+ name: text().notNull(),
41
+ });
42
+
43
+ // src/server/db/schemas/book.ts
37
44
  export const bookTable = snakeCase.table("books", {
38
45
  id: uuid().primaryKey(),
39
46
  title: text().notNull(),
@@ -13,7 +13,9 @@ Favor the established platform before introducing custom code or a new dependenc
13
13
  - **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
14
14
  - **Material UI:** Use Material UI for interface components and icons. When an advanced capability is needed, consider MUI X Charts for data visualization, Tree View for hierarchical data, Scheduler for calendars and timelines, and Chat for AI-powered conversations.
15
15
 
16
- Before implementing an external library feature, consult the current documentation through Context7 MCP. Do not add a dependency when one of these platform libraries already covers the requirement.
16
+ Before implementing an external library feature, consult the current documentation through Context7 MCP. Do not add a new dependency when one of these platform libraries already covers the requirement.
17
+
18
+ When the requirement is not covered above and a well-maintained, popular library solves it, use that library instead of writing your own implementation.
17
19
 
18
20
  ## Coding Conventions
19
21
 
@@ -50,13 +52,13 @@ src/ # client-first architecture
50
52
  ├── routes/ # TanStack Router file-based routing
51
53
  │ ├── __root.tsx
52
54
  │ ├── index.tsx
53
- │ └── features/ # route group with multiple pages
55
+ │ └── features/ # feature folder with multiple routes (kebab-case, plural)
54
56
  │ ├── -components/ # route-specific components
55
57
  │ ├── -hooks/ # route-specific hooks
56
58
  │ ├── index.tsx
57
59
  │ ├── create.tsx
58
- │ ├── edit.$id.tsx
59
- │ └── $id.tsx
60
+ │ ├── $id.tsx
61
+ │ └── edit.$id.tsx
60
62
  ├── server/ # server-only code
61
63
  │ ├── actions/
62
64
  │ │ └── <table>.ts
@@ -69,5 +71,24 @@ src/ # client-first architecture
69
71
  │ └── middleware/
70
72
  │ └── databaseMiddleware.ts
71
73
  └── types/
72
- tests/ # test files
74
+ tests/
75
+ ├── unit/
76
+ │ ├── lib/
77
+ │ │ └── schemas/
78
+ │ │ └── <table>.test.ts
79
+ │ ├── hooks/
80
+ │ │ └── useX.test.ts
81
+ │ └── routes/
82
+ │ └── features/
83
+ │ └── -components/
84
+ │ └── XCard.test.tsx
85
+ ├── integration/
86
+ │ ├── server/
87
+ │ │ └── actions/
88
+ │ │ └── <table>.test.ts
89
+ │ └── db-collections/
90
+ │ └── <table>Collection.test.ts
91
+ └── e2e/
92
+ └── features/
93
+ └── create.spec.ts
73
94
  ```
@@ -12,8 +12,9 @@ description: "Use when: creating or modifying TanStack Start server functions, A
12
12
  - Follow the chain order for server functions: `middleware` → `validator` → `handler`.
13
13
  - Follow the order for middleware arrays: `authorizationMiddleware(<permissionKey>)` → `databaseMiddleware()`.
14
14
  - Use `validationMiddleware` only in REST API routes. Server functions use `.validator()`.
15
- - `databaseMiddleware` wraps the handler in a DB transaction and sets `app.user_name` so audit triggers can record who made the change.
15
+ - Never create a transaction in the handler because `databaseMiddleware` already owns it.
16
16
  - Reuse schemas from `src/lib/schemas/`.
17
+ - Background jobs are API routes using only `authenticationMiddleware()` + `databaseMiddleware()` — cron runs in Kubernetes and authenticates via app token.
17
18
 
18
19
  ## File Placement
19
20
 
@@ -1,69 +1,81 @@
1
1
  # Vault Setup
2
2
 
3
- Never print user-provided secret values into chat, files, or logs — reference only the env keys and where each value lives. The one value the AI generates itself is `SESSION_SECRET`: a fresh 64-char hex string via `node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"`. The template ships only `VITE_MUI_LICENSE_KEY` in `.env`; all project configuration goes into the gitignored `.env.local`, which may have been created by an earlier setup step and is normalized in this step.
4
-
5
- ## User Input
6
-
7
- Ask via **AskUserQuestion**: **"Do you use Vault for this project?"** — options `Yes` / `No`.
8
-
9
- - **Yes** → Branch A.
10
- - **No** → Branch B.
11
-
12
- ---
13
-
14
- ## Branch A — Vault
15
-
16
- ### Part 1 — Vault secrets (user fills these in the Vault UI)
17
-
18
- Output:
19
-
20
- > 1. Navigate to your Vault UI and log in.
21
- > 2. In your app's root path, create a secret named exactly `harborvault`: toggle 'JSON' mode, then copy-paste the JSON values from another app's `harborvault` secret and save.
22
- > 3. Open your app's `default` secret, click 'Edit' (toggle 'View as JSON'), fill in these keys, then save. Provide user this in JSON to copy-paste — empty string values, except `SESSION_SECRET`, which you pre-fill with a freshly generated value:
23
- >
24
- > | Key | Value source |
25
- > | ----------------------- | ----------------------------------------------------- |
26
- > | `ENTRA_CLIENT_ID` | the Entra ID step |
27
- > | `ENTRA_TENANT_ID` | same for all Wistron apps — copy from another project |
28
- > | `ENTRA_CLIENT_SECRET` | your Entra ID application |
29
- > | `SESSION_SECRET` | already pre-filled in the JSON — generated by the AI |
30
- > | `DATABASE_SCHEMA` | the database step |
31
- > | `DATABASE_AUTO_MIGRATE` | `true` unless you manage migrations manually |
32
- > | `DATABASE_URL` | the database step |
33
- >
34
- Then ask via **AskUserQuestion**: **"Are the Vault secrets filled in and saved?"** — options `Done` / `Not yet`. On `Not yet`, wait and ask again.
35
-
36
- ### Part 2 — Normalize `.env.local`
37
-
38
- Rewrite `.env.local` so it contains **only** the keys below. Never fill in secret values yourself — keep values empty except `DATABASE_URL` and `DATABASE_SCHEMA`, where you keep the values if the database step already set them (drizzle-kit reads both):
3
+ Move the secrets that currently live in `.env.local` into Vault, then shrink
4
+ `.env.local` down to the Vault connection only.
5
+
6
+ Before starting, ask the user via **AskUserQuestion** which environment(s) to
7
+ set up: **QAS**, **PRD** or **both**. Both environments follow the exact same
8
+ steps — only the login credentials and the Vault path differ (QAS lives under
9
+ `sat-qas-01`, PRD under `sat-prd-01`; each has its own Vault account and
10
+ password). When doing both, run through Parts 1–2 once per environment. In
11
+ Part 3, always write the **QAS** connection into `.env.local` (if available).
12
+
13
+ To wait for something the user does in the browser — signing in, saving a
14
+ secret — poll in a tool loop: wait ~5 s, re-read the page, repeat until the
15
+ expected state appears or ~5 minutes pass, then carry straight on. Never end
16
+ your turn while waiting; announcing "I'll continue once you have signed in"
17
+ and stopping ends the session, and nothing resumes it.
18
+
19
+ Do not print secret values into chat, logs, or a commit — reference them by
20
+ key name. Values move from `.env.local` into the browser and nowhere else.
21
+
22
+ ## Part 1 — Collect the payload from `.env.local`
23
+
24
+ 1. Read `.env.local`. If it does not exist, create it.
25
+ 2. If `SESSION_SECRET` is empty or missing, generate one.
26
+ 3. Build the JSON payload from every key in `.env.local` (except `DATABASE_AUTOMIGRATE`). A typical payload that goes to Vault:
27
+
28
+ ```json
29
+ {
30
+ "ENTRA_CLIENT_ID": "...",
31
+ "ENTRA_TENANT_ID": "...",
32
+ "ENTRA_CLIENT_SECRET": "...",
33
+ "SESSION_SECRET": "...",
34
+ "DATABASE_URL": "...",
35
+ "DATABASE_SCHEMA": "..."
36
+ }
37
+ ```
38
+
39
+ ## Part 2 — Write the secrets in the Vault UI
40
+
41
+ Repeat this part once per selected environment (QAS and/or PRD) — same steps,
42
+ different credentials and path.
43
+
44
+ 1. Ask for the screenshot of WiCOP email or the **Vault path**, **Vault Account** and **Vault Password** one-by-one.
45
+ 2. Open the Vault address in the browser. Login with provided account and password and redirect to provided path:
46
+ - The URL already contains the secret path, so it redirects there after login.
47
+ - On the "Sign in to Vault" screen, open the **Method** dropdown and select **Userpass** (not the default Token).
48
+ - Enter the **Username** (Vault Account), then the **Password**, then click **Sign in**.
49
+ - You land on the secret list for the project path, e.g. `release/wcz/sat-<environment>-01/<project>-wcz`, containing a `default` secret.
50
+ 3. Update the `default` secret with the `.env.local` payload:
51
+ - Click the `default` secret to open it, then open the **Secret** tab.
52
+ - Click **Create new version**.
53
+ - Toggle the **JSON** switch in the toolbar, select all in the JSON editor (`Ctrl+A`) and replace it with the payload JSON from Part 1 (this also removes any pre-existing keys like `cog_test`).
54
+ - Click **Save**. Verify the success toast "Successfully saved secret data" and that the new version lists every expected key.
55
+ 4. Create the `harborvault` secret:
56
+ - In the breadcrumb, click `<projectname>-wcz` to go one level up.
57
+ - Click **Create secret**.
58
+ - In **Path for this secret**, append `harborvault` to the pre-filled project path (i.e. `wcz/<env>/<projectname>-wcz/harborvault`).
59
+ - Toggle the **JSON** switch, then ask the user to copy-paste the harborvault JSON from another project into the JSON editor (contains the `HARBOR_SECRET` key). Autonomously poll the editor until the content is there — do not end the session while waiting.
60
+ - Click **Save**. Verify the success toast.
61
+ 5. Close the Vault browser session.
62
+
63
+ ## Part 3 — Rewrite `.env.local`
64
+
65
+ Use the **QAS** credentials here when both environments were set up.
66
+
67
+ Rewrite the file so it contains **only** these keys. Every app secret is now
68
+ served by Vault, so its local value is removed — a leftover value would
69
+ override Vault. `DATABASE_URL` and `DATABASE_SCHEMA` stay filled because
70
+ drizzle-kit reads them directly and never goes through Vault.
39
71
 
40
72
  ```dotenv
41
- VAULT_ADDRESS=
42
- VAULT_SECRET_PATH=
43
- VAULT_USERNAME=
44
- VAULT_PASSWORD=
45
-
46
- DATABASE_URL=
47
- DATABASE_SCHEMA=
48
- ```
49
-
50
- Then ask the user to fill in the empty values directly in `.env.local` (not in chat), and confirm via **AskUserQuestion**: **"Are the `.env.local` values filled in?"** — options `Done` / `Not yet`. On `Not yet`, wait and ask again.
51
-
52
- ---
53
-
54
- ## Branch B — No Vault
55
-
56
- Create `.env.local` to contain exactly these keys — keep any values already set by earlier steps, fill `SESSION_SECRET` with a freshly generated value, and leave the rest empty:
57
-
58
- ```dotenv
59
- ENTRA_CLIENT_ID=
60
- ENTRA_TENANT_ID=
61
- ENTRA_CLIENT_SECRET=
62
- SESSION_SECRET=<generated-64-char-hex>
63
-
64
- DATABASE_SCHEMA=
65
- DATABASE_AUTO_MIGRATE=
66
- DATABASE_URL=
73
+ VAULT_ADDRESS=<from Part 2>
74
+ VAULT_SECRET_PATH=<from Part 2>
75
+ VAULT_USERNAME=<from Part 2>
76
+ VAULT_PASSWORD=<from Part 2>
77
+
78
+ DATABASE_URL=<kept>
79
+ DATABASE_SCHEMA=<kept>
80
+ DATABASE_AUTOMIGRATE=<kept>
67
81
  ```
68
-
69
- Then ask the user to fill in the empty values directly in `.env.local` (not in chat), and confirm via **AskUserQuestion**: **"Are the `.env.local` values filled in?"** — options `Done` / `Not yet`. On `Not yet`, wait and ask again.
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouterListItemButton-owZVvuC_.mjs","names":["IconButton","createLink","React","IconButtonProps","LinkComponent","Component","forwardRef","HTMLAnchorElement","IconButtonComponent","props","reference","$","_c","$i","Symbol","for","t0","CreatedComponent","RouterIconButton","ListItemButton","createLink","React","ListItemButtonProps","LinkComponent","Component","forwardRef","HTMLAnchorElement","ButtonComponent","props","reference","$","_c","$i","Symbol","for","t0","CreatedComponent","RouterListItemButton"],"sources":["../src/components/router/RouterIconButton.tsx","../src/components/router/RouterListItemButton.tsx"],"sourcesContent":["import { IconButton } from \"@mui/material\";\nimport { createLink } from \"@tanstack/react-router\";\nimport React from \"react\";\nimport type { IconButtonProps } from \"@mui/material\";\nimport type { LinkComponent } from \"@tanstack/react-router\";\n\nconst Component = React.forwardRef<HTMLAnchorElement, IconButtonProps<\"a\">>(\n function IconButtonComponent(props, reference) {\n return <IconButton ref={reference} component=\"a\" {...props} />;\n },\n);\n\nconst CreatedComponent = createLink(Component);\n\nexport const RouterIconButton: LinkComponent<typeof Component> = (props) => {\n return <CreatedComponent {...props} />;\n};\n","import { ListItemButton } from \"@mui/material\";\nimport { createLink } from \"@tanstack/react-router\";\nimport React from \"react\";\nimport type { ListItemButtonProps } from \"@mui/material\";\nimport type { LinkComponent } from \"@tanstack/react-router\";\n\nconst Component = React.forwardRef<HTMLAnchorElement, ListItemButtonProps<\"a\">>(\n function ButtonComponent(props, reference) {\n return <ListItemButton ref={reference} component=\"a\" {...props} />;\n },\n);\n\nconst CreatedComponent = createLink(Component);\n\nexport const RouterListItemButton: LinkComponent<typeof Component> = (props) => {\n return <CreatedComponent {...props} />;\n};\n"],"mappings":";;;;;;AAYA,MAAMiB,qBAAmBhB,WANPC,MAAMI,WACtB,SAAAE,oBAAAC,OAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAD,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAAE,KAAA,GAAAA,KAAA,GAAAA,MAAA,GAAAF,EAAAE,MAAAC,OAAAC,IAAA,2BAAA;EAAAJ,EAAA,KAAA;CAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,WAAA;EACSM,KAAA,oBAAC,YAAD;GAAiBN,KAAAA;GAAqB,WAAA;GAAG,GAAKD;EAAK,CAAA;EAAIE,EAAA,KAAAF;EAAAE,EAAA,K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AA;CAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAF,OAAA;EAC5DO,KAAA,oBAAC,kBAAD,EAAiB,GAAKP,MAAK,CAAA;EAAIE,EAAA,KAAAF;EAAAE,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAA/BK;AAA+B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"authMiddleware-CjKA7C0W.mjs","names":["createMiddleware","jose","permissions","serverEnv","getSessionUser","buildUser","hasPermission","TokenPayload","User","resolveUser","request","Request","Promise","authHeader","headers","get","startsWith","payload","verifyToken","substring","length","error","Response","json","message","Error","status","requiredAuthenticationMiddleware","server","user","next","context","publicAuthenticationMiddleware","authenticationMiddleware","options","optional","authorizationMiddleware","permissionKey","middleware","name","token","jwtVerify","getJWKS","issuer","ENTRA_TENANT_ID","audience","ENTRA_CLIENT_ID","jwksCache","ReturnType","createRemoteJWKSet","URL"],"sources":["../src/middleware/authMiddleware.ts"],"sourcesContent":["import { createMiddleware } from \"@tanstack/react-start\";\nimport * as jose from \"jose\";\nimport type { permissions } from \"virtual:wcz-layout\";\nimport { serverEnv } from \"~/env\";\nimport { getSessionUser } from \"~/lib/auth/user\";\nimport { buildUser, hasPermission } from \"~/lib/utils\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\n\nasync function resolveUser(request: Request): Promise<User | null> {\n const authHeader = request.headers.get(\"Authorization\");\n\n if (authHeader?.startsWith(\"Bearer \")) {\n let payload: TokenPayload;\n try {\n payload = await verifyToken(authHeader.substring(\"Bearer \".length));\n } catch (error) {\n throw Response.json(\n { message: error instanceof Error ? error.message : \"Unauthorized: Invalid access token\" },\n { status: 401 },\n );\n }\n return buildUser(payload);\n }\n\n return getSessionUser();\n}\n\nconst requiredAuthenticationMiddleware = createMiddleware().server<{ user: User }>(\n async ({ next, request }) => {\n const user = await resolveUser(request);\n\n if (!user)\n throw Response.json({ message: \"Unauthorized: User not signed in\" }, { status: 401 });\n\n return next({ context: { user } });\n },\n);\n\nconst publicAuthenticationMiddleware = createMiddleware().server<{ user: User | null }>(\n async ({ next, request }) => {\n const user = await resolveUser(request);\n return next({ context: { user } });\n },\n);\n\nexport function authenticationMiddleware(options?: {\n optional?: false;\n}): typeof requiredAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options: {\n optional: true;\n}): typeof publicAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options: {\n optional: boolean;\n}): typeof requiredAuthenticationMiddleware | typeof publicAuthenticationMiddleware;\n\nexport function authenticationMiddleware(options?: { optional?: boolean }) {\n return options?.optional ? publicAuthenticationMiddleware : requiredAuthenticationMiddleware;\n}\n\nexport const authorizationMiddleware = (permissionKey: keyof typeof permissions) =>\n createMiddleware()\n .middleware([authenticationMiddleware()])\n .server(async ({ next, context }) => {\n if (hasPermission(context.user, permissionKey)) return next();\n throw Response.json(\n {\n message: `Forbidden: User ${context.user.name} is not authorized to access this resource`,\n },\n { status: 403 },\n );\n });\n\nasync function verifyToken(token: string): Promise<TokenPayload> {\n const { payload } = await jose.jwtVerify(token, getJWKS(), {\n issuer: `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/v2.0`,\n audience: serverEnv.ENTRA_CLIENT_ID,\n });\n return payload as unknown as TokenPayload;\n}\n\nlet jwksCache: ReturnType<typeof jose.createRemoteJWKSet> | null = null;\n\nfunction getJWKS() {\n jwksCache ??= jose.createRemoteJWKSet(\n new URL(`https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}/discovery/v2.0/keys`),\n );\n return jwksCache;\n}\n"],"mappings":";;;;AASA,eAAeS,YAAYC,SAAwC;CACjE,MAAMG,aAAaH,QAAQI,QAAQC,IAAI,eAAe;CAEtD,IAAIF,YAAYG,WAAW,SAAS,GAAG;EACrC,IAAIC;EACJ,IAAI;GACFA,UAAU,MAAMC,YAAYL,WAAWM,UAAU,CAAgB,CAAC;EACpE,SAASE,OAAO;GACd,MAAMC,SAASC,KACb,EAAEC,SA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