wcz-layout 9.7.0 → 10.0.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 (93) hide show
  1. package/dist/AggregatedCell-BtKC5-m6.mjs +497 -0
  2. package/dist/AggregatedCell-BtKC5-m6.mjs.map +1 -0
  3. package/dist/Approval-C-hF4jbT.mjs.map +1 -1
  4. package/dist/DialogsContext-DLqA8RJ_.mjs.map +1 -1
  5. package/dist/Email-BzQQkbe9.mjs.map +1 -1
  6. package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
  7. package/dist/LayoutTable-4DLs-NI-.d.mts +752 -0
  8. package/dist/{QueryClientParam-Cbb0MIKg.d.mts → QueryClientParam-JcH0mJWl.d.mts} +2 -2
  9. package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
  10. package/dist/{User-1gKoYJvW.d.mts → User-D4__w1I1.d.mts} +4 -2
  11. package/dist/approval-DFExxyAJ.mjs +84 -0
  12. package/dist/approval-DFExxyAJ.mjs.map +1 -0
  13. package/dist/auth.d.mts +21 -11
  14. package/dist/auth.mjs +43 -26
  15. package/dist/auth.mjs.map +1 -1
  16. package/dist/components.d.mts +22 -30
  17. package/dist/components.mjs +786 -139
  18. package/dist/components.mjs.map +1 -1
  19. package/dist/createApi-CLYWCzR2.mjs +27 -0
  20. package/dist/createApi-CLYWCzR2.mjs.map +1 -0
  21. package/dist/data/client.d.mts +702 -1152
  22. package/dist/data/client.mjs +4 -3
  23. package/dist/data/client.mjs.map +1 -1
  24. package/dist/data/server.d.mts +3 -3
  25. package/dist/data/server.mjs +4 -2
  26. package/dist/data/server.mjs.map +1 -1
  27. package/dist/{file-BWcNzq55.mjs → file-CZwQfvTU.mjs} +5 -24
  28. package/dist/file-CZwQfvTU.mjs.map +1 -0
  29. package/dist/{file-DimNsRly.mjs → file-aSQto2rw.mjs} +6 -7
  30. package/dist/file-aSQto2rw.mjs.map +1 -0
  31. package/dist/hooks.d.mts +7 -46
  32. package/dist/hooks.mjs +2578 -239
  33. package/dist/hooks.mjs.map +1 -1
  34. package/dist/index.d.mts +28 -9
  35. package/dist/index.mjs +1248 -500
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/middleware.d.mts +20 -19
  38. package/dist/middleware.mjs +47 -2
  39. package/dist/middleware.mjs.map +1 -1
  40. package/dist/models.d.mts +17 -10
  41. package/dist/models.mjs.map +1 -1
  42. package/dist/{peoplesoft-CskGsqd6.d.mts → peoplesoft-BY_75WTS.d.mts} +2 -2
  43. package/dist/{peoplesoft-DTPGpN2h.mjs → peoplesoft-CQnc01Hc.mjs} +24 -81
  44. package/dist/peoplesoft-CQnc01Hc.mjs.map +1 -0
  45. package/dist/providers-Dbl95AxR.mjs +74 -0
  46. package/dist/providers-Dbl95AxR.mjs.map +1 -0
  47. package/dist/tokens-D8CVIFTb.mjs +143 -0
  48. package/dist/tokens-D8CVIFTb.mjs.map +1 -0
  49. package/dist/{utils-5x4uNxsX.d.mts → utils-Bhi0KiBx.d.mts} +18 -6
  50. package/dist/{utils-DjdexspV.mjs → utils-KaM5VMTJ.mjs} +64 -42
  51. package/dist/utils-KaM5VMTJ.mjs.map +1 -0
  52. package/dist/utils.d.mts +2 -2
  53. package/dist/utils.mjs +2 -2
  54. package/dist/vite.d.mts +1 -2
  55. package/dist/vite.mjs +3 -3
  56. package/dist/vite.mjs.map +1 -1
  57. package/package.json +23 -23
  58. package/skills/client-db/SKILL.md +104 -96
  59. package/skills/db-schema/SKILL.md +46 -33
  60. package/skills/dialogs/SKILL.md +21 -27
  61. package/skills/forms/SKILL.md +60 -39
  62. package/skills/general/SKILL.md +56 -25
  63. package/skills/general/references/exports.md +106 -0
  64. package/skills/migrations/SKILL.md +53 -2
  65. package/skills/migrations/versions/migrate-v9-to-v10.md +581 -0
  66. package/skills/routing/SKILL.md +50 -60
  67. package/skills/server-functions/SKILL.md +36 -56
  68. package/skills/services/SKILL.md +7 -4
  69. package/skills/services/docs/approval.md +2 -2
  70. package/skills/services/docs/peoplesoft.md +1 -1
  71. package/skills/start/SKILL.md +9 -5
  72. package/skills/start/steps/05-database-setup.md +52 -52
  73. package/skills/start/steps/06-entra-setup.md +1 -1
  74. package/skills/start/steps/07-vault-setup.md +5 -12
  75. package/skills/table/SKILL.md +275 -0
  76. package/skills/unslop/SKILL.md +80 -0
  77. package/dist/NotificationContext-CgwUOeW0.mjs +0 -7
  78. package/dist/NotificationContext-CgwUOeW0.mjs.map +0 -1
  79. package/dist/authMiddleware-DPly0b_T.mjs +0 -48
  80. package/dist/authMiddleware-DPly0b_T.mjs.map +0 -1
  81. package/dist/entra-CJSyeQsx.mjs +0 -109
  82. package/dist/entra-CJSyeQsx.mjs.map +0 -1
  83. package/dist/file-BWcNzq55.mjs.map +0 -1
  84. package/dist/file-DimNsRly.mjs.map +0 -1
  85. package/dist/msalServer-DLwA7_ta.mjs +0 -30
  86. package/dist/msalServer-DLwA7_ta.mjs.map +0 -1
  87. package/dist/peoplesoft-DTPGpN2h.mjs.map +0 -1
  88. package/dist/useDialogs-BUzVrTSP.mjs +0 -248
  89. package/dist/useDialogs-BUzVrTSP.mjs.map +0 -1
  90. package/dist/user-Dzv0N9fj.d.mts +0 -16
  91. package/dist/utils-DjdexspV.mjs.map +0 -1
  92. package/skills/data-grid/SKILL.md +0 -142
  93. package/skills/migrations/versions/migrate-v9-to-v10.tsx +0 -9
@@ -1,15 +1,18 @@
1
1
  ---
2
2
  name: general
3
- description: "Use ALWAYS for project-wide conventions and coding standards. It defines the default style, rules, and best practices that apply to every file and feature."
3
+ description: "Use ALWAYS, before any other skill here, for every code change in this project. Defines the approved stack (TanStack, Vite+, MUI), TypeScript and naming conventions, date formatting, light/dark theming, testing and the validation command, and the src/ and tests/ folder layout that decides where each new file goes."
4
+ metadata:
5
+ type: convention
6
+ library: wcz-layout
4
7
  ---
5
8
 
6
- > This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `data-grid`, `dialogs`) for targeted tasks.
9
+ > This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `table`, `dialogs`) for targeted tasks. For the full catalogue of every `wcz-layout` import subpath and what it exports, read [references/exports.md](references/exports.md).
7
10
 
8
11
  ## Preferred Technology Stack
9
12
 
10
13
  Favor the established platform before introducing custom code or a new dependency:
11
14
 
12
- - **TanStack ecosystem:** Use TanStack Start, Router, DB, Form, and Query for their respective application concerns. Consider adjacent TanStack libraries when they directly fit the feature: TanStack AI for AI interactions, TanStack Virtual for large virtualized lists, TanStack Pacer for debouncing, throttling, rate limiting, queuing, and batching, and TanStack Hotkeys for type-safe keyboard shortcuts.
15
+ - **TanStack ecosystem:** Reach for the TanStack library that owns the problem instead of hand-rolling it — Start for the full-stack app and server functions, Router for routing and route-level data loading, DB for client-side collections and live queries, AI for LLM-backed chat and streaming, Form for form state and validation, Hotkeys for keyboard shortcuts, Virtual for long lists and grids, Pacer for debouncing, throttling, rate limiting and queueing.
13
16
  - **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
14
17
  - **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
18
 
@@ -19,58 +22,85 @@ When the requirement is not covered above and a well-maintained, popular library
19
22
 
20
23
  ## Coding Conventions
21
24
 
22
- - Generate modern ES6+ TypeScript with explicit types and never use `any`.
25
+ - Write strict ES2023 TypeScript. Preserve local inference, type public boundaries and never use explicit `any`.
23
26
  - Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
24
27
  - Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
25
28
  - Keep code self-documenting; only add comments to clarify non-obvious intent.
29
+ - Run the narrow relevant test, then `vp check --fix`. It formats, lints and type-checks.
26
30
 
27
31
  ## User Interface
28
32
 
33
+ - Translate every user-facing string via `useTranslation` (or `t` outside components).
29
34
  - Format all client-side dates with `"L LT"` or `"L"`.
30
35
  - Build skeletons for loading states.
31
- - When building UI, always design for both light and dark mode; this app uses `colorSchemeSelector: "data-mui-color-scheme"`, so prefer `theme.applyStyles("dark", ...)` for mode-specific styling.
36
+ - When building UI, always design for both light and dark mode; this app uses
37
+ `colorSchemeSelector: "data-mui-color-scheme"`, so prefer `theme.applyStyles("dark", ...)`
38
+ for mode-specific styling.
39
+
40
+ ## Testing
41
+
42
+ - Tests run on `vp test` (bundled in vite-plus).
32
43
 
33
44
  ## File Organization
34
45
 
35
46
  Use this ownership model for new application code. Keep feature-specific code close to its route; promote it to a root directory only when it is shared across multiple features. One database table = one file per layer: every `<table>` slot below is the same singular camelCase table name, never grouped with its parent or child tables.
36
47
 
37
48
  ```txt
38
- src/ # client-first architecture
39
- ├── components/ # shared components across multiple routes
40
- ├── db-collections/ # TanStack DB collections
41
- │ └── <table>Collection.ts
42
- ├── hooks/ # shared hooks across multiple routes
43
- ├── lib/ # isomorphic/shared logic usable by client and server
49
+ src/ # client-first architecture
50
+ ├── components/ # shared components across multiple routes
51
+ ├── db/ # TanStack DB
52
+ │ ├── collections/ # collection descriptors
53
+ │ │ └── <table>.ts
54
+ │ ├── queries/ # live query option objects
55
+ │ │ └── <table>.ts
56
+ │ └── persistence.ts # browser SQLite persistence
57
+ ├── env.ts # clientEnv + serverEnv via createEnv
58
+ ├── hooks/ # shared hooks across multiple routes
59
+ │ └── useTheme.ts # MUI theme + color schemes
60
+ ├── lib/ # isomorphic/shared logic usable by client and server
44
61
  │ ├── auth/
45
- │ │ ├── permissions.ts
46
- │ │ └── scopes.ts
62
+ │ │ ├── permissions.ts # as const satisfies Permissions
63
+ │ │ └── scopes.ts # as const satisfies Scopes
47
64
  │ ├── locales/
48
65
  │ │ ├── cs.json
49
66
  │ │ └── en.json
50
- │ └── schemas/ # shared Zod schemas
67
+ │ └── schemas/ # shared Zod schemas
51
68
  │ └── <table>.ts
52
- ├── routes/ # TanStack Router file-based routing
69
+ ├── router.tsx # QueryClient, DbClient, router options
70
+ ├── routes/ # TanStack Router file-based routing
53
71
  │ ├── __root.tsx
54
72
  │ ├── index.tsx
55
- │ └── features/ # feature folder with multiple routes (kebab-case, plural)
56
- │ ├── -components/ # route-specific components
57
- │ ├── -hooks/ # route-specific hooks
73
+ │ ├── login.tsx # required by requireAuth
74
+ │ ├── auth/ # OAuth handlers
75
+ │ │ ├── login.ts
76
+ │ │ ├── callback.ts
77
+ │ │ └── logout.ts
78
+ │ ├── api/ # REST API routes (only when a public API is required)
79
+ │ │ └── features/
80
+ │ │ ├── index.ts
81
+ │ │ └── $id.ts
82
+ │ └── features/ # feature folder with multiple routes (kebab-case, plural)
83
+ │ ├── -components/ # route-specific components
84
+ │ ├── -hooks/ # route-specific hooks
58
85
  │ ├── index.tsx
59
86
  │ ├── create.tsx
60
87
  │ ├── $id.tsx
61
88
  │ └── edit.$id.tsx
62
- ├── server/ # server-only code
89
+ ├── server/ # server-only code, never imported from a component
63
90
  │ ├── actions/
64
91
  │ │ └── <table>.ts
65
92
  │ ├── db/
66
93
  │ │ ├── migrations/
67
- │ │ ├── schemas/ # Drizzle schemas
94
+ │ │ ├── schemas/ # Drizzle schemas
68
95
  │ │ │ ├── <table>.ts
69
96
  │ │ │ └── relations.ts
70
- │ │ └── index.ts
97
+ │ │ └── index.ts # pool, search_path, auto-migrate
71
98
  │ └── middleware/
72
- │ └── databaseMiddleware.ts
73
- └── types/
99
+ │ └── databaseMiddleware.ts # app-local, not a library export
100
+ ├── start.ts # request middleware, incl. CSRF
101
+ ├── types/
102
+ │ ├── i18next.d.ts # types t() against en.json
103
+ │ └── wcz-layout.d.ts # declares virtual:wcz-layout
74
104
  tests/
75
105
  ├── unit/
76
106
  │ ├── lib/
@@ -86,8 +116,9 @@ tests/
86
116
  │ ├── server/
87
117
  │ │ └── actions/
88
118
  │ │ └── <table>.test.ts
89
- │ └── db-collections/
90
- │ └── <table>Collection.test.ts
119
+ │ └── db/
120
+ │ └── collections/
121
+ │ └── <table>.test.ts
91
122
  └── e2e/
92
123
  └── features/
93
124
  └── create.spec.ts
@@ -0,0 +1,106 @@
1
+ # wcz-layout exports
2
+
3
+ Public import subpaths and commonly used exports. Read this when you need to know where a
4
+ symbol lives; you do not need it loaded for ordinary feature work.
5
+
6
+ ## `wcz-layout`
7
+
8
+ The root subpath. Everything the application shell needs.
9
+
10
+ - `LayoutProvider` — root shell provider. Props: `theme` (required), `navigation?`,
11
+ `options?`. Installs the Emotion cache, MUI `ThemeProvider`, `LocalizationProvider`
12
+ (dayjs), i18next and the dialogs provider. Wrap `{children}` with it inside `<body>` in
13
+ `__root.tsx`. Do not install any of those yourself.
14
+ - `Navigation` — the type for the sidebar tree. Items are
15
+ `{ kind: "item" | "header" | "group" | "divider" }`; an item takes `to` or `href`,
16
+ `title`, `icon` and optional `search`; groups take `title`, `icon` and `children`; headers
17
+ take `title`; every kind accepts `hidden`.
18
+ - `rootRouteHead` — returns the root route's `head()` value (title, meta, links).
19
+ - `getUser({ queryClient })` — resolves the signed-in user. Call it in the root
20
+ `beforeLoad` and return `{ user }`; that is what makes `Route.useRouteContext().user`
21
+ available on every route.
22
+ - `loginProvidersQueryOptions` — query options for the configured OAuth providers. The
23
+ `/login` route loads it so the buttons server-render.
24
+ - `WISTRON_PRIMARY_COLOR`, `WISTRON_SECONDARY_COLOR` — brand colors for the app's theme.
25
+
26
+ ## `wcz-layout/vite`
27
+
28
+ - `viteWczLayout()` — **required** Vite plugin. Keep the template's plugin order after
29
+ `tanstackStart()`, `nitro()`, `viteReact()` and the React Compiler babel plugin. It
30
+ builds the `virtual:wcz-layout` module from the app's `src/lib/locales/*.json`,
31
+ `src/lib/auth/permissions.ts`, `src/lib/auth/scopes.ts`, `src/env.ts` and
32
+ `public/manifest.json`, and loads Vault secrets into `process.env` during `serve`.
33
+ Without it the build fails to resolve
34
+ `virtual:wcz-layout`. The app must also declare that module in
35
+ `src/types/wcz-layout.d.ts`.
36
+
37
+ ## `wcz-layout/components`
38
+
39
+ - `LayoutTable` — table renderer; see the `table` skill. Types: `LayoutTableProps`,
40
+ `RowAction`, `LayoutColumnMeta`, `FilterOperator`, `TableFilterOption`,
41
+ `TableFilterVariant`
42
+ - `AggregatedCell` — aggregated value cell for grouped rows
43
+ - `Fullscreen` — fills the viewport, for a page whose only content is a table
44
+ - `Dropzone`, `FileViewer` — file upload and preview; see the `services` skill
45
+ - `LoginForm` — provider buttons for the login route; takes no props and reads
46
+ `?returnTo` itself
47
+ - `RouterButton`, `RouterFab`, `RouterIconButton`, `RouterLink`, `RouterListItemButton`,
48
+ `RouterTab` — MUI components taking router `to` / `params` / `search`
49
+ - `RouterNotFound`, `RouterError` — default 404 and error components. Pass them to
50
+ `createRouter` as `defaultNotFoundComponent` and `defaultErrorComponent`.
51
+
52
+ ## `wcz-layout/hooks`
53
+
54
+ - `useLayoutForm`, `withLayoutForm`, `useFormContext`, `useFieldContext` — form instance,
55
+ reusable sub-forms, and the contexts custom field components read; see the `forms` skill
56
+ - `useLayoutTable`, `createLayoutColumnHelper`, `layoutTableFeatures`, `useTableContext`,
57
+ `useHeaderContext`, `useCellContext` — table instance, column helper and contexts, plus
58
+ type `LayoutTableFeatures`; see the `table` skill
59
+ - `useDialogs` — alert, confirm, custom dialogs and `close`, plus type `DialogProps`; see
60
+ the `dialogs` skill
61
+ - `useTranslation` — translation inside components
62
+ - `useInView` — element visibility observer
63
+ - `useScanDetection` — barcode scanner keystrokes
64
+
65
+ ## `wcz-layout/middleware`
66
+
67
+ - `authMiddleware` — rejects unauthenticated calls, optionally checks a permission key.
68
+ Goes in a server function's `.middleware([])`, **after** `databaseMiddleware` so it
69
+ narrows `context.user` to `User`. See the `server-functions` skill for the full order.
70
+ - `userMiddleware` — attaches the user without requiring one, as `User | null`
71
+ - `validationMiddleware` — validates API route input against a Zod schema. REST routes
72
+ only; server functions use `.validator()`.
73
+ - `csrfMiddleware` — CSRF protection. A **request** middleware: it goes in
74
+ `createStart(() => ({ requestMiddleware: [csrfMiddleware] }))` in `src/start.ts`, never in
75
+ a `.middleware([])` array. See the `server-functions` skill.
76
+
77
+ `databaseMiddleware` is **not** here. It is app-local; every app writes its own. See the
78
+ `server-functions` skill.
79
+
80
+ ## `wcz-layout/utils`
81
+
82
+ - `t`, `i18next` — translation outside components
83
+ - `uuidv7` — time-sortable id. Use it for every client-generated primary key.
84
+ - `requireAuth` — `beforeLoad` route guard, redirects to `/login`; see the `routing` skill
85
+ - `hasPermission` — permission check for a user
86
+ - `Platform` — OS detection from the user agent
87
+ - `createEnv` — typed environment schema
88
+
89
+ ## `wcz-layout/auth`
90
+
91
+ - `handleLogin`, `handleCallback`, `handleLogout` — OAuth route handlers. Mount each as a
92
+ server `GET` handler at `/auth/login`, `/auth/callback` and `/auth/logout`.
93
+ - `getAccessToken` — delegated token for the signed-in user, server-only
94
+ - `getAppToken` — app-only token for background jobs, server-only
95
+
96
+ ## `wcz-layout/models`
97
+
98
+ - Service types: `User`, `Permissions`, `Scopes`, `FileMeta`, `Email`, `EmailAttachment`,
99
+ `Employee`, `Department`, `EmployeeStatus`, `EmployeeCategoryGroup`, `Approval*`
100
+ - Matching Zod schemas: `FileMetaSchema`, `EmailSchema`, `EmailAttachmentSchema`,
101
+ `EmployeeSchema`, `DepartmentSchema` and the approval `*Schema`
102
+
103
+ ## `wcz-layout/data/client`, `wcz-layout/data/server`
104
+
105
+ - Client query and mutation option factories for file, approval and PeopleSoft services.
106
+ Server exports contain those operations plus `sendEmail`; see the `services` skill.
@@ -1,6 +1,57 @@
1
1
  ---
2
2
  name: migrations
3
- description: "Use when: when migrating the wcz-layout library to a newer version"
3
+ description: "Use when upgrading the wcz-layout package to a newer major version. Each major ships only its own inbound guide, versions/migrate-v<N-1>-to-v<N>.md, delivered by installing it. One major per pass."
4
+ metadata:
5
+ type: lifecycle
6
+ library: wcz-layout
7
+ disable-model-invocation: "true"
4
8
  ---
5
9
 
6
- //Read each migration one-by-one
10
+ # Upgrading wcz-layout
11
+
12
+ ## 1. Find the source major
13
+
14
+ ```bash
15
+ node -p "require('wcz-layout/package.json').version" # installed
16
+ npm view wcz-layout version # latest published
17
+ ls node_modules/wcz-layout/skills/migrations/versions/
18
+ ```
19
+
20
+ `package.json` names the installed major, not the one `src/` is written against.
21
+ Open the guide on disk and grep `src/` for the symbols on its `from` side —
22
+ `requirePermission`, `authenticationMiddleware`, `DataGridPremium`,
23
+ `useNotification` and the rest of the left-hand columns.
24
+
25
+ - Hits → `src/` is on that guide's `from` major. Apply that guide now, install nothing.
26
+ - No hits → the source major is the installed one. Go to step 2.
27
+
28
+ ## 2. One pass per major
29
+
30
+ For each major from source + 1 up to the latest, in order:
31
+
32
+ ```bash
33
+ npm install wcz-layout@<major>
34
+ ls node_modules/wcz-layout/skills/migrations/versions/
35
+ ```
36
+
37
+ Re-list after every install — it replaced `versions/` and this skill. Read the
38
+ whole `migrate-v<from>-to-v<major>.md` it delivered, and whatever that guide says
39
+ to read first, before editing anything. Then work through it top to bottom.
40
+
41
+ Never skip a major: only `@10` carries the v9→v10 guide, so v9 → v11 is two
42
+ passes — install 10, apply, verify, install 11, apply, verify.
43
+
44
+ ## 3. Verify before the next pass
45
+
46
+ ```bash
47
+ npx vp check --fix
48
+ ```
49
+
50
+ Formats, lints and type-checks. Fix everything it leaves behind, then:
51
+
52
+ ```bash
53
+ npx vp dev
54
+ ```
55
+
56
+ The app must start and render. Stop the dev server, then start the next pass.
57
+ Done when no guide is left unapplied and the installed version is the latest.