wcz-layout 9.6.5 → 9.7.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.
Files changed (36) hide show
  1. package/dist/components.mjs +7 -7
  2. package/dist/components.mjs.map +1 -1
  3. package/dist/data/client.d.mts +2 -1
  4. package/dist/data/client.mjs +2 -2
  5. package/dist/data/client.mjs.map +1 -1
  6. package/dist/data/server.d.mts +1 -1
  7. package/dist/data/server.mjs +2 -2
  8. package/dist/entra-CJSyeQsx.mjs.map +1 -1
  9. package/dist/{file-BTFDDalH.mjs → file-BWcNzq55.mjs} +4 -4
  10. package/dist/file-BWcNzq55.mjs.map +1 -0
  11. package/dist/{file-CuvAmdJW.mjs → file-DimNsRly.mjs} +3 -4
  12. package/dist/{file-CuvAmdJW.mjs.map → file-DimNsRly.mjs.map} +1 -1
  13. package/dist/index.d.mts +1 -0
  14. package/dist/index.mjs +53 -43
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/{peoplesoft-D4w8d4s1.d.mts → peoplesoft-CskGsqd6.d.mts} +2 -1
  17. package/dist/{peoplesoft-DGdM1bws.mjs → peoplesoft-DTPGpN2h.mjs} +2 -2
  18. package/dist/{peoplesoft-DGdM1bws.mjs.map → peoplesoft-DTPGpN2h.mjs.map} +1 -1
  19. package/dist/utils-DjdexspV.mjs.map +1 -1
  20. package/dist/vite.mjs.map +1 -1
  21. package/package.json +128 -127
  22. package/skills/client-db/SKILL.md +18 -3
  23. package/skills/data-grid/SKILL.md +142 -142
  24. package/skills/db-schema/SKILL.md +9 -2
  25. package/skills/general/SKILL.md +94 -73
  26. package/skills/migrations/SKILL.md +6 -0
  27. package/skills/migrations/versions/migrate-v9-to-v10.tsx +9 -0
  28. package/skills/server-functions/SKILL.md +2 -1
  29. package/skills/services/SKILL.md +31 -31
  30. package/skills/start/SKILL.md +47 -47
  31. package/skills/start/steps/01-git-setup.md +0 -1
  32. package/skills/start/steps/04-wicop-setup.md +105 -80
  33. package/skills/start/steps/05-database-setup.md +52 -44
  34. package/skills/start/steps/06-entra-setup.md +96 -98
  35. package/skills/start/steps/07-vault-setup.md +114 -62
  36. package/dist/file-BTFDDalH.mjs.map +0 -1
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
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,IAAI,CAAC;CAChC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAChC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACnC,mBAAmB,EA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AAO,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"}
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\";\nimport https from \"node:https\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport axios from \"axios\";\nimport { loadEnv } from \"vite\";\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\nimport type { Resource } from \"i18next\";\nimport type { Plugin } from \"vite\";\n\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\n const config = VaultConfigSchema.parse(env);\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\n config;\n\n const client = axios.create({\n baseURL: VAULT_ADDRESS,\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\n });\n\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\n password: VAULT_PASSWORD,\n });\n\n const { data: secretData } = await client.get(\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\n {\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\n },\n );\n\n const secrets = secretData?.data?.data;\n if (!secrets) throw new Error(\"No secrets found\");\n\n return Object.fromEntries(\n Object.entries(secrets).map(([key, value]) => [\n key,\n typeof value === \"string\" ? value : JSON.stringify(value),\n ]),\n );\n}\n\nasync function loadVaultSecrets(command: string): Promise<void> {\n if (command !== \"serve\") return;\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n if (!env.VAULT_ADDRESS) return;\n\n try {\n const secrets = await fetchVaultSecrets(env);\n Object.entries(secrets).forEach(([key, value]) => {\n process.env[key] = env[key]?.trim() ? env[key] : value;\n });\n } catch (e) {\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\n }\n}\n\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\n\n const enPath = path.join(localesPath, \"en.json\");\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\n\n const files = fs.readdirSync(localesPath);\n const resources: Resource = {};\n\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n const lang = path.basename(file, \".json\");\n const filePath = path.join(localesPath, file);\n try {\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\n } catch {\n resources[lang] = { translation: {} };\n }\n addWatchFile(filePath);\n }\n\n return resources;\n}\n\nconst require = createRequire(import.meta.url);\n\nfunction dayjsLocaleImports(resources: Resource): string {\n return Object.keys(resources)\n .map((lang) => lang.toLowerCase())\n .filter((lang) => {\n try {\n require.resolve(`dayjs/locale/${lang}.js`);\n return true;\n } catch {\n return false;\n }\n })\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\n .join(\"\\n\");\n}\n\nfunction ensurePermissionsFile(\n permissionsPath: string,\n addWatchFile: (path: string) => void,\n): void {\n const dir = path.dirname(permissionsPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(permissionsPath)) {\n fs.writeFileSync(\n permissionsPath,\n 'export const permissions = {\\n admin: [\"wcz-developers\"]\\n} as const;',\n );\n }\n addWatchFile(permissionsPath);\n}\n\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\n const dir = path.dirname(scopesPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(scopesPath)) {\n fs.writeFileSync(scopesPath, \"export const scopes = {\\n} as const;\");\n }\n addWatchFile(scopesPath);\n}\n\nfunction loadManifest(\n manifestPath: string,\n addWatchFile: (path: string) => void,\n): { name: string } & Record<string, unknown> {\n addWatchFile(manifestPath);\n try {\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n } catch {\n return { name: \"\" };\n }\n}\n\nexport function viteWczLayout(): Plugin {\n const virtualModuleId = \"virtual:wcz-layout\";\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n let localesPath: string;\n let permissionsPath: string;\n let scopesPath: string;\n let envPath: string;\n let manifestPath: string;\n\n return {\n name: \"vite:wcz-layout\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\n },\n async config(_, { command }) {\n await loadVaultSecrets(command);\n },\n configureServer(server) {\n const refresh = (filePath: string) => {\n if (\n filePath.includes(localesPath) ||\n filePath === permissionsPath ||\n filePath === scopesPath ||\n filePath === envPath ||\n filePath === manifestPath\n ) {\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\n if (module) server.moduleGraph.invalidateModule(module);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n }\n };\n\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\n server.watcher.on(\"add\", refresh);\n server.watcher.on(\"change\", refresh);\n server.watcher.on(\"unlink\", refresh);\n },\n resolveId(id) {\n if (id === virtualModuleId) return resolvedVirtualModuleId;\n return null;\n },\n load(id) {\n if (id !== resolvedVirtualModuleId) return null;\n\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\n\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\n return `\n ${dayjsLocaleImports(resources)}\n export const resources = ${JSON.stringify(resources)};\n export const manifest = ${JSON.stringify(manifest)};\n export { permissions } from \"${normalizedPermissionsPath}\";\n export { scopes } from \"${normalizedScopesPath}\";\n export { serverEnv } from \"${normalizedEnvPath}\";\n `;\n },\n };\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,oBAAoB,EAAE,OAAO;CACxC,eAA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ACtD,OAAO,GAAG,KAAK;MAAE,MAAM;MAAe,MAAM;KAAI,CAAC;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,127 +1,128 @@
1
- {
2
- "name": "wcz-layout",
3
- "version": "9.6.5",
4
- "private": false,
5
- "keywords": [
6
- "tanstack-intent"
7
- ],
8
- "repository": {
9
- "type": "git",
10
- "url": "https://gitlab.wistron.com/wcz/it-developers/layout/tanstack.git"
11
- },
12
- "files": [
13
- "dist",
14
- "skills",
15
- "!skills/_artifacts"
16
- ],
17
- "type": "module",
18
- "sideEffects": [
19
- "./dist/index.mjs"
20
- ],
21
- "exports": {
22
- "./package.json": "./package.json",
23
- ".": {
24
- "types": "./dist/index.d.mts",
25
- "import": "./dist/index.mjs"
26
- },
27
- "./components": {
28
- "types": "./dist/components.d.mts",
29
- "import": "./dist/components.mjs"
30
- },
31
- "./hooks": {
32
- "types": "./dist/hooks.d.mts",
33
- "import": "./dist/hooks.mjs"
34
- },
35
- "./middleware": {
36
- "types": "./dist/middleware.d.mts",
37
- "import": "./dist/middleware.mjs"
38
- },
39
- "./models": {
40
- "types": "./dist/models.d.mts",
41
- "import": "./dist/models.mjs"
42
- },
43
- "./data/client": {
44
- "types": "./dist/data/client.d.mts",
45
- "import": "./dist/data/client.mjs"
46
- },
47
- "./data/server": {
48
- "types": "./dist/data/server.d.mts",
49
- "import": "./dist/data/server.mjs"
50
- },
51
- "./utils": {
52
- "types": "./dist/utils.d.mts",
53
- "import": "./dist/utils.mjs"
54
- },
55
- "./auth": {
56
- "types": "./dist/auth.d.mts",
57
- "import": "./dist/auth.mjs"
58
- },
59
- "./vite": {
60
- "types": "./dist/vite.d.mts",
61
- "import": "./dist/vite.mjs"
62
- }
63
- },
64
- "scripts": {
65
- "dev": "vp dev",
66
- "check": "vp check",
67
- "typecheck": "tsc --noEmit --watch --preserveWatchOutput",
68
- "build": "vp pack",
69
- "prepublishOnly": "npm run build"
70
- },
71
- "dependencies": {
72
- "@azure/msal-node": "^5.5.0",
73
- "@t3-oss/env-core": "^0.13.11",
74
- "i18next": "^26.3.6",
75
- "i18next-browser-languagedetector": "^8.2.1",
76
- "jose": "^6.2.8",
77
- "react-dropzone": "^20.0.0",
78
- "react-i18next": "^17.0.11",
79
- "react-intersection-observer": "^11.0.0",
80
- "react-number-format": "^5.4.5",
81
- "tus-js-client": "^4.3.1",
82
- "uuidv7": "^1.2.1"
83
- },
84
- "devDependencies": {
85
- "@arethetypeswrong/core": "^0.18.5",
86
- "@rolldown/plugin-babel": "^0.2.3",
87
- "@tanstack/ai": "^0.43.0",
88
- "@tanstack/ai-client": "^0.23.0",
89
- "@tanstack/ai-openai": "^0.18.0",
90
- "@tanstack/highlight": "^0.0.10",
91
- "@types/node": "^26.1.2",
92
- "@types/react": "^19.2.18",
93
- "@types/react-dom": "^19.2.4",
94
- "@vitejs/plugin-react": "^6.0.5",
95
- "babel-plugin-react-compiler": "^1.0.0",
96
- "nitro": "npm:nitro-nightly@latest",
97
- "publint": "^0.3.23",
98
- "typescript": "^7.0.2",
99
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.8",
100
- "vite-plus": "0.2.8"
101
- },
102
- "peerDependencies": {
103
- "@emotion/cache": "11.x",
104
- "@emotion/react": "11.x",
105
- "@emotion/styled": "11.x",
106
- "@mui/icons-material": "9.x",
107
- "@mui/material": "9.x",
108
- "@mui/x-data-grid-premium": "9.x",
109
- "@mui/x-date-pickers-pro": "9.x",
110
- "@tanstack/query-db-collection": "1.x",
111
- "@tanstack/react-db": "0.x",
112
- "@tanstack/react-form": "1.x",
113
- "@tanstack/react-query": "5.x",
114
- "@tanstack/react-router": "1.x",
115
- "@tanstack/react-router-ssr-query": "1.x",
116
- "@tanstack/react-start": "1.x",
117
- "axios": "1.x",
118
- "dayjs": "1.x",
119
- "react": "19.x",
120
- "react-dom": "19.x",
121
- "zod": "4.x"
122
- },
123
- "overrides": {
124
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.8"
125
- },
126
- "packageManager": "npm@12.0.2"
127
- }
1
+ {
2
+ "name": "wcz-layout",
3
+ "version": "9.7.0",
4
+ "private": false,
5
+ "keywords": [
6
+ "tanstack-intent"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://gitlab.wistron.com/wcz/it-developers/layout/tanstack.git"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "skills",
15
+ "!skills/_artifacts"
16
+ ],
17
+ "type": "module",
18
+ "sideEffects": [
19
+ "./dist/index.mjs"
20
+ ],
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "types": "./dist/index.d.mts",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "./components": {
28
+ "types": "./dist/components.d.mts",
29
+ "import": "./dist/components.mjs"
30
+ },
31
+ "./hooks": {
32
+ "types": "./dist/hooks.d.mts",
33
+ "import": "./dist/hooks.mjs"
34
+ },
35
+ "./middleware": {
36
+ "types": "./dist/middleware.d.mts",
37
+ "import": "./dist/middleware.mjs"
38
+ },
39
+ "./models": {
40
+ "types": "./dist/models.d.mts",
41
+ "import": "./dist/models.mjs"
42
+ },
43
+ "./data/client": {
44
+ "types": "./dist/data/client.d.mts",
45
+ "import": "./dist/data/client.mjs"
46
+ },
47
+ "./data/server": {
48
+ "types": "./dist/data/server.d.mts",
49
+ "import": "./dist/data/server.mjs"
50
+ },
51
+ "./utils": {
52
+ "types": "./dist/utils.d.mts",
53
+ "import": "./dist/utils.mjs"
54
+ },
55
+ "./auth": {
56
+ "types": "./dist/auth.d.mts",
57
+ "import": "./dist/auth.mjs"
58
+ },
59
+ "./vite": {
60
+ "types": "./dist/vite.d.mts",
61
+ "import": "./dist/vite.mjs"
62
+ }
63
+ },
64
+ "scripts": {
65
+ "dev": "vp dev",
66
+ "check": "vp check",
67
+ "typecheck": "tsc --noEmit --watch --preserveWatchOutput",
68
+ "build": "vp pack",
69
+ "prepublishOnly": "npm run build"
70
+ },
71
+ "dependencies": {
72
+ "@azure/msal-node": "^5.5.0",
73
+ "@t3-oss/env-core": "^0.13.11",
74
+ "i18next": "^26.3.6",
75
+ "i18next-browser-languagedetector": "^8.2.1",
76
+ "jose": "^6.2.9",
77
+ "react-dropzone": "^20.1.0",
78
+ "react-i18next": "^17.0.11",
79
+ "react-intersection-observer": "^11.0.0",
80
+ "react-number-format": "^5.4.5",
81
+ "tus-js-client": "^4.3.1",
82
+ "uuidv7": "^1.2.1"
83
+ },
84
+ "devDependencies": {
85
+ "@arethetypeswrong/core": "^0.18.5",
86
+ "@rolldown/plugin-babel": "^0.2.3",
87
+ "@tanstack/ai": "^0.44.1",
88
+ "@tanstack/ai-client": "^0.23.2",
89
+ "@tanstack/ai-openai": "^0.19.0",
90
+ "@tanstack/highlight": "^0.0.10",
91
+ "@tanstack/react-table": "^9.1.2",
92
+ "@types/node": "^24.10.13",
93
+ "@types/react": "^19.2.18",
94
+ "@types/react-dom": "^19.2.4",
95
+ "@vitejs/plugin-react": "^6.0.5",
96
+ "babel-plugin-react-compiler": "^1.0.0",
97
+ "nitro": "npm:nitro-nightly@latest",
98
+ "publint": "^0.3.23",
99
+ "typescript": "^7.0.2",
100
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.9",
101
+ "vite-plus": "0.2.9"
102
+ },
103
+ "peerDependencies": {
104
+ "@emotion/cache": "11.x",
105
+ "@emotion/react": "11.x",
106
+ "@emotion/styled": "11.x",
107
+ "@mui/icons-material": "9.x",
108
+ "@mui/material": "9.x",
109
+ "@mui/x-data-grid-premium": "9.x",
110
+ "@mui/x-date-pickers-pro": "9.x",
111
+ "@tanstack/query-db-collection": "1.x",
112
+ "@tanstack/react-db": "0.x",
113
+ "@tanstack/react-form": "1.x",
114
+ "@tanstack/react-query": "5.x",
115
+ "@tanstack/react-router": "1.x",
116
+ "@tanstack/react-router-ssr-query": "1.x",
117
+ "@tanstack/react-start": "1.x",
118
+ "axios": "1.x",
119
+ "dayjs": "1.x",
120
+ "react": "19.x",
121
+ "react-dom": "19.x",
122
+ "zod": "4.x"
123
+ },
124
+ "overrides": {
125
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.9"
126
+ },
127
+ "packageManager": "npm@12.0.2"
128
+ }
@@ -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"),
@@ -1,142 +1,142 @@
1
- ---
2
- name: data-grid
3
- description: "Use when: building or configuring MUI X DataGrid tables."
4
- ---
5
-
6
- ## Rules
7
-
8
- - Wrap DataGrid in `Fullscreen` when it is the only content on the page.
9
- - Type columns as `Array<GridColDef<RowType>>` with the row interface.
10
- - Use translation for all `headerName` values.
11
- - Use `rows`, `columns`, `showToolbar`, `loading`, `ignoreDiacritics`, `cellSelection`, and `disableRowSelectionOnClick` on grids.
12
- - For enums use `type: "singleSelect"` with `{ value, label }` options array used from enumObject.
13
- - For editable columns, pair `editable: true` with `renderHeader: EditableColumnHeader`.
14
- - Use `EditableColumnHeader`, and router button/grid action components from `wcz-layout/components` when they fit.
15
- - Always apply a `valueFormatter` for columns with type `dateTime` or `date`.
16
-
17
- ## File Placement
18
-
19
- ```
20
- @mui/x-data-grid-premium — GridColDef, DataGridPremium
21
- src/db-collections/ - TanStack DB collections to get data
22
- @tanstack/react-db - useLiveQuery, useLiveSuspenseQuery
23
- src/server/actions/ - server functions and enums
24
- wcz-layout/components - EditableColumnHeader, Fullscreen
25
- wcz-layout/hooks - useTranslation
26
- ```
27
-
28
- ## Examples
29
-
30
- ```tsx
31
- // src/routes/<feature>s/index.tsx
32
- const { t } = useTranslation();
33
- const { confirm, alert } = useDialogs();
34
- const navigate = useNavigate();
35
- const [cellSelectionModel, setCellSelectionModel] = useState<GridCellSelectionModel>({});
36
-
37
- const { data, isLoading } = useLiveQuery((q) =>
38
- q.from({ feature: featureCollection }).orderBy(({ feature }) => feature.name, "asc"),
39
- );
40
-
41
- const columns: Array<GridColDef<Feature>> = [
42
- {
43
- field: "name",
44
- headerName: t("Feature.Name"),
45
- width: 200,
46
- editable: true,
47
- renderHeader: EditableColumnHeader,
48
- },
49
- {
50
- field: "status",
51
- headerName: t("Feature.Status"),
52
- width: 200,
53
- type: "singleSelect",
54
- valueOptions: featureStatusEnum.enumValues.map((status) => ({
55
- value: status,
56
- label: t(`FeatureStatus.${status}`),
57
- })),
58
- },
59
- ];
60
-
61
- const handleOnDelete = createOptimisticAction<Array<string>>({
62
- onMutate: (ids) => {
63
- ids.forEach((id) => {
64
- featureCollection.delete(id);
65
- });
66
- },
67
- mutationFn: async (ids) => {
68
- deleteFeatures({ data: ids });
69
- await featureCollection.utils.refetch();
70
- },
71
- });
72
-
73
- return (
74
- <Fullscreen>
75
- <DataGridPremium
76
- rows={data}
77
- columns={columns}
78
- showToolbar
79
- loading={isLoading}
80
- ignoreDiacritics
81
- onRowDoubleClick={({ row }) => navigate({ to: "/features/$id", params: { id: row.id } })}
82
- cellSelection
83
- disableRowSelectionOnClick
84
- cellSelectionModel={cellSelectionModel}
85
- onCellSelectionModelChange={(newModel) => setCellSelectionModel(newModel)}
86
- slots={{ toolbar: DataGridToolbar }}
87
- slotProps={{
88
- toolbar: {
89
- title: t("Feature.Features"),
90
- actions: [
91
- <Tooltip key="create" title={t("Create")}>
92
- <RouterIconButton to="/features/create">
93
- <Add fontSize="small" />
94
- </RouterIconButton>
95
- </Tooltip>,
96
- Object.keys(cellSelectionModel).length === 1 && (
97
- <Tooltip key="edit" title={t("Edit")}>
98
- <RouterIconButton
99
- to="/features/edit/$id"
100
- params={{ id: Object.keys(cellSelectionModel)[0].toString() }}
101
- >
102
- <Edit fontSize="small" />
103
- </RouterIconButton>
104
- </Tooltip>
105
- ),
106
- Object.keys(cellSelectionModel).length > 0 && (
107
- <Tooltip key="delete" title={t("Delete")}>
108
- <IconButton
109
- onClick={async () => {
110
- const confirmed = await confirm(
111
- t("DeleteConfirmation", { count: Object.keys(cellSelectionModel).length }),
112
- );
113
- if (confirmed) {
114
- try {
115
- const transaction = handleOnDelete(
116
- Object.keys(cellSelectionModel).map((id) => id.toString()),
117
- );
118
- await transaction.isPersisted.promise;
119
- setCellSelectionModel({});
120
- } catch (error) {
121
- if (error instanceof Error) await alert(error.message);
122
- }
123
- }
124
- }}
125
- >
126
- <Badge
127
- badgeContent={Object.keys(cellSelectionModel).length}
128
- invisible={Object.keys(cellSelectionModel).length <= 1}
129
- color="error"
130
- >
131
- <Delete fontSize="small" />
132
- </Badge>
133
- </IconButton>
134
- </Tooltip>
135
- ),
136
- ],
137
- },
138
- }}
139
- />
140
- </Fullscreen>
141
- );
142
- ```
1
+ ---
2
+ name: data-grid
3
+ description: "Use when: building or configuring MUI X DataGrid tables."
4
+ ---
5
+
6
+ ## Rules
7
+
8
+ - Wrap DataGrid in `Fullscreen` when it is the only content on the page.
9
+ - Type columns as `Array<GridColDef<RowType>>` with the row interface.
10
+ - Use translation for all `headerName` values.
11
+ - Use `rows`, `columns`, `showToolbar`, `loading`, `ignoreDiacritics`, `cellSelection`, and `disableRowSelectionOnClick` on grids.
12
+ - For enums use `type: "singleSelect"` with `{ value, label }` options array used from enumObject.
13
+ - For editable columns, pair `editable: true` with `renderHeader: EditableColumnHeader`.
14
+ - Use `EditableColumnHeader`, and router button/grid action components from `wcz-layout/components` when they fit.
15
+ - Always apply a `valueFormatter` for columns with type `dateTime` or `date`.
16
+
17
+ ## File Placement
18
+
19
+ ```
20
+ @mui/x-data-grid-premium — GridColDef, DataGridPremium
21
+ src/db-collections/ - TanStack DB collections to get data
22
+ @tanstack/react-db - useLiveQuery, useLiveSuspenseQuery
23
+ src/server/actions/ - server functions and enums
24
+ wcz-layout/components - EditableColumnHeader, Fullscreen
25
+ wcz-layout/hooks - useTranslation
26
+ ```
27
+
28
+ ## Examples
29
+
30
+ ```tsx
31
+ // src/routes/<feature>s/index.tsx
32
+ const { t } = useTranslation();
33
+ const { confirm, alert } = useDialogs();
34
+ const navigate = useNavigate();
35
+ const [cellSelectionModel, setCellSelectionModel] = useState<GridCellSelectionModel>({});
36
+
37
+ const { data, isLoading } = useLiveQuery((q) =>
38
+ q.from({ feature: featureCollection }).orderBy(({ feature }) => feature.name, "asc"),
39
+ );
40
+
41
+ const columns: Array<GridColDef<Feature>> = [
42
+ {
43
+ field: "name",
44
+ headerName: t("Feature.Name"),
45
+ width: 200,
46
+ editable: true,
47
+ renderHeader: EditableColumnHeader,
48
+ },
49
+ {
50
+ field: "status",
51
+ headerName: t("Feature.Status"),
52
+ width: 200,
53
+ type: "singleSelect",
54
+ valueOptions: featureStatusEnum.enumValues.map((status) => ({
55
+ value: status,
56
+ label: t(`FeatureStatus.${status}`),
57
+ })),
58
+ },
59
+ ];
60
+
61
+ const handleOnDelete = createOptimisticAction<Array<string>>({
62
+ onMutate: (ids) => {
63
+ ids.forEach((id) => {
64
+ featureCollection.delete(id);
65
+ });
66
+ },
67
+ mutationFn: async (ids) => {
68
+ deleteFeatures({ data: ids });
69
+ await featureCollection.utils.refetch();
70
+ },
71
+ });
72
+
73
+ return (
74
+ <Fullscreen>
75
+ <DataGridPremium
76
+ rows={data}
77
+ columns={columns}
78
+ showToolbar
79
+ loading={isLoading}
80
+ ignoreDiacritics
81
+ onRowDoubleClick={({ row }) => navigate({ to: "/features/$id", params: { id: row.id } })}
82
+ cellSelection
83
+ disableRowSelectionOnClick
84
+ cellSelectionModel={cellSelectionModel}
85
+ onCellSelectionModelChange={(newModel) => setCellSelectionModel(newModel)}
86
+ slots={{ toolbar: DataGridToolbar }}
87
+ slotProps={{
88
+ toolbar: {
89
+ title: t("Feature.Features"),
90
+ actions: [
91
+ <Tooltip key="create" title={t("Create")}>
92
+ <RouterIconButton to="/features/create">
93
+ <Add fontSize="small" />
94
+ </RouterIconButton>
95
+ </Tooltip>,
96
+ Object.keys(cellSelectionModel).length === 1 && (
97
+ <Tooltip key="edit" title={t("Edit")}>
98
+ <RouterIconButton
99
+ to="/features/edit/$id"
100
+ params={{ id: Object.keys(cellSelectionModel)[0].toString() }}
101
+ >
102
+ <Edit fontSize="small" />
103
+ </RouterIconButton>
104
+ </Tooltip>
105
+ ),
106
+ Object.keys(cellSelectionModel).length > 0 && (
107
+ <Tooltip key="delete" title={t("Delete")}>
108
+ <IconButton
109
+ onClick={async () => {
110
+ const confirmed = await confirm(
111
+ t("DeleteConfirmation", { count: Object.keys(cellSelectionModel).length }),
112
+ );
113
+ if (confirmed) {
114
+ try {
115
+ const transaction = handleOnDelete(
116
+ Object.keys(cellSelectionModel).map((id) => id.toString()),
117
+ );
118
+ await transaction.isPersisted.promise;
119
+ setCellSelectionModel({});
120
+ } catch (error) {
121
+ if (error instanceof Error) await alert(error.message);
122
+ }
123
+ }
124
+ }}
125
+ >
126
+ <Badge
127
+ badgeContent={Object.keys(cellSelectionModel).length}
128
+ invisible={Object.keys(cellSelectionModel).length <= 1}
129
+ color="error"
130
+ >
131
+ <Delete fontSize="small" />
132
+ </Badge>
133
+ </IconButton>
134
+ </Tooltip>
135
+ ),
136
+ ],
137
+ },
138
+ }}
139
+ />
140
+ </Fullscreen>
141
+ );
142
+ ```