wcz-layout 9.7.0 → 10.1.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-C7nAQyMO.mjs +510 -0
  2. package/dist/AggregatedCell-C7nAQyMO.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-BkrjgpW_.d.mts +758 -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-BYryxFOW.mjs +84 -0
  12. package/dist/approval-BYryxFOW.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 +813 -140
  18. package/dist/components.mjs.map +1 -1
  19. package/dist/createApi-DGJJ4I_R.mjs +27 -0
  20. package/dist/createApi-DGJJ4I_R.mjs.map +1 -0
  21. package/dist/data/client.d.mts +690 -1176
  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-DimNsRly.mjs → file-C14fhUeg.mjs} +6 -7
  28. package/dist/file-C14fhUeg.mjs.map +1 -0
  29. package/dist/{file-BWcNzq55.mjs → file-C5BOj1q8.mjs} +5 -24
  30. package/dist/file-C5BOj1q8.mjs.map +1 -0
  31. package/dist/hooks.d.mts +7 -46
  32. package/dist/hooks.mjs +2587 -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-BkJMCcHb.mjs} +24 -81
  44. package/dist/peoplesoft-BkJMCcHb.mjs.map +1 -0
  45. package/dist/providers-DrairEO2.mjs +74 -0
  46. package/dist/providers-DrairEO2.mjs.map +1 -0
  47. package/dist/tokens-BLRreL1j.mjs +143 -0
  48. package/dist/tokens-BLRreL1j.mjs.map +1 -0
  49. package/dist/{utils-DjdexspV.mjs → utils-BUpDoqme.mjs} +73 -51
  50. package/dist/utils-BUpDoqme.mjs.map +1 -0
  51. package/dist/{utils-5x4uNxsX.d.mts → utils-Bhi0KiBx.d.mts} +18 -6
  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 +130 -128
  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 +122 -94
  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 +582 -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 +114 -110
  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 +263 -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,27 +1,24 @@
1
1
  ---
2
2
  name: dialogs
3
- description: "Use when: creating or modifying alert, confirm, or custom dialogs."
3
+ description: "Use for acknowledgement alerts, confirmation prompts, or custom MUI Dialogs opened through useDialogs."
4
+ metadata:
5
+ type: convention
6
+ library: wcz-layout
4
7
  ---
5
8
 
6
9
  ## Rules
7
10
 
8
- - Always use `useDialogs()` for modal interactions.
11
+ - Use `useDialogs()` instead of mounting another provider. It returns `{ alert, confirm, open, close }`.
9
12
  - Use `confirm()` for destructive or user-confirmed actions.
10
13
  - Use `alert()` for informational or error messages that require acknowledgement.
11
14
  - Use `open()` for feature-specific custom dialogs with typed payloads.
12
- - Custom dialogs must receive `DialogProps<T>`.
13
- - Keep dialogs colocated inside `routes/feature/-components` when feature-specific.
14
- - Always use translation; add new keys for feature-specific messages.
15
-
16
- ## File Placement
17
-
18
- ```txt
19
- src/components/dialogs/ — shared dialogs used across features
20
- src/routes/<feature>s/-components/ — feature-scoped dialogs
21
- wcz-layout/hooks — useDialogs hook, DialogProps type, useTranslation
22
- src/lib/locales/ — translation keys
23
- @mui/material — MUI Dialog components
24
- ```
15
+ - Custom dialogs receive `DialogProps<TPayload, TResult>`. `open()` resolves with
16
+ whatever the dialog passes to `onClose(result)`, so a dialog that answers a
17
+ question declares its result type and the caller awaits it. Leave `TResult` off
18
+ only for dialogs that return nothing.
19
+ - Use `close(dialog, result)` only to close outside the dialog component, passing the
20
+ promise returned by `open()`. Custom dialogs normally call their injected `onClose(result)`.
21
+ - Colocate feature-specific dialogs in `routes/<feature>s/-components`; put dialogs used by more than one route in `src/components`.
25
22
 
26
23
  ## Examples
27
24
 
@@ -31,7 +28,7 @@ const { confirm } = useDialogs();
31
28
  const { t } = useTranslation();
32
29
 
33
30
  const confirmed = await confirm(t("DeleteConfirmation", { count: selectedIds.length }));
34
- if (confirmed) await deleteFeature({ data: id });
31
+ if (confirmed) await deleteFeatures({ data: selectedIds });
35
32
 
36
33
  // alert dialog
37
34
  const { alert } = useDialogs();
@@ -39,15 +36,15 @@ const { t } = useTranslation();
39
36
 
40
37
  try {
41
38
  await saveFeature(values);
42
- await alert(t("FeatureSavedSuccessfully"));
43
39
  } catch (error) {
44
40
  await alert(error instanceof Error ? error.message : t("UnknownError"));
45
41
  }
46
42
 
47
- // custom dialog
43
+ // custom dialog that returns a result
48
44
  const { open } = useDialogs();
49
45
 
50
- await open(EditFeatureDialog, { id });
46
+ const saved = await open(EditFeatureDialog, { id });
47
+ if (saved) await features.utils.refetch({ throwOnError: true });
51
48
 
52
49
  // custom dialog component
53
50
  interface Payload {
@@ -58,19 +55,16 @@ export const EditFeatureDialog = ({
58
55
  payload,
59
56
  open,
60
57
  onClose,
61
- }: DialogProps<Payload>) => {
58
+ }: DialogProps<Payload, boolean>) => {
62
59
  const { t } = useTranslation();
63
60
 
64
61
  return (
65
- <Dialog fullWidth open={open} onClose={() => onClose()}>
62
+ <Dialog fullWidth open={open} onClose={() => onClose(false)}>
66
63
  <DialogTitle>{t("EditFeature")}</DialogTitle>
67
- <DialogContent>
68
- {payload.id}
69
- </DialogContent>
64
+ <DialogContent>{payload.id}</DialogContent>
70
65
  <DialogActions>
71
- <Button onClick={() => onClose()}>
72
- Close
73
- </Button>
66
+ <Button onClick={() => onClose(false)}>{t("Cancel")}</Button>
67
+ <Button onClick={() => onClose(true)}>{t("Save")}</Button>
74
68
  </DialogActions>
75
69
  </Dialog>
76
70
  );
@@ -1,32 +1,47 @@
1
1
  ---
2
2
  name: forms
3
- description: "Use when: creating or modifying TanStack Form components, field layouts, validation schemas, submit handling, or custom form controls."
3
+ description: "Use when building or changing forms, including fields, validation, submission, reset, date values, async initial values, or reusable subforms."
4
+ metadata:
5
+ type: convention
6
+ library: wcz-layout
4
7
  ---
5
8
 
6
- # Form Patterns
9
+ # Form patterns
10
+
11
+ > Mechanics (`createFormHook`, `withForm`, field API, validation lifecycle) belong to
12
+ > TanStack Form v1. `useLayoutForm` is its `useAppForm` and `withLayoutForm` its `withForm`,
13
+ > pre-bound to the MUI field set below.
7
14
 
8
15
  ## Rules
9
16
 
10
- - Always use `useLayoutForm` with pre-defined components.
17
+ - Always use `useLayoutForm` with the pre-defined components.
18
+ - Fields are not importable; reach them through render props. `form.AppField` yields
19
+ `field.Autocomplete`, `field.Checkbox`, `field.DatePicker`, `field.DateTimePicker`,
20
+ `field.NumberField`, `field.RadioGroup`, `field.Slider`, `field.Switch`, `field.TextField`
21
+ and `field.TimePicker`. `form.AppForm` yields `form.SubmitButton`, and nothing else. Pick
22
+ the field that matches the value.
11
23
  - Define `width` for all form fields based on the expected content length.
12
- - Reuse Zod schemas from `src/lib/schemas/` which are derived from Drizzle schemas with `createSelectSchema` from table schemas.
24
+ - Reuse Zod schemas from `src/lib/schemas/`, derived from Drizzle tables with `createSelectSchema`.
25
+ - `field.DatePicker`, `field.TimePicker` and `field.DateTimePicker` hold `Dayjs`, not `Date`.
26
+ A Drizzle `timestamp` column gives you a `Date`, so convert at both boundaries:
27
+ `dayjs(row.dueAt)` into `defaultValues`, `.toDate()` on the way out in `onSubmit`.
13
28
  - Use translation for labels, helper text, validation messages and submit.
14
- - Reset the form after successful create.
15
- - Use one of the following field based on the use case: `Autocomplete`, `Checkbox`, `DatePicker`, `DateRangePicker`, `DateTimePicker`, `DateTimeRangePicker`, `NumberField`, `RadioGroup`, `Slider`, `SubmitButton`, `Switch`, `TextField`, `TimePicker`, or `TimeRangePicker`.
29
+ - Reset the form after a successful create, and let the submit handler reject on failure so
30
+ a failed save keeps what the user typed.
31
+ - `SubmitButton` calls `form.handleSubmit()` and owns its loading and disabled state.
32
+ - `reset()` restores the `defaultValues` captured when the form was constructed. If those
33
+ contain a generated `uuidv7()` id, pass a fresh one to `reset({ ...defaults, id: uuidv7() })`
34
+ or the second create collides on the primary key.
35
+ - `defaultValues` only re-syncs into a mounted form while it is still untouched. On edit
36
+ routes, preload the query in the loader so the row is there before the form mounts.
16
37
  - When fetching data for a form, always use a suspense query.
17
-
18
- ## File Placement
19
-
20
- ```
21
- src/routes/<feature>s/-components/ - route-scoped forms
22
- src/lib/schemas/ — Zod schemas (shared between client and server)
23
- wcz-layout/hooks - useLayoutForm hook, useTranslation
24
- ```
38
+ - Split a long form with `withLayoutForm`, which binds a sub-form to the same
39
+ `defaultValues` shape as the parent. Custom field components read `useFieldContext<T>()`.
25
40
 
26
41
  ## Examples
27
42
 
28
- ```ts
29
- // Form Component
43
+ ```tsx
44
+ // Form component
30
45
  interface FormProps {
31
46
  defaultValues: Feature;
32
47
  onSubmit: (value: Feature) => Promise<void>;
@@ -46,38 +61,44 @@ export const Form: FC<FormProps> = ({ defaultValues, onSubmit }) => {
46
61
 
47
62
  return (
48
63
  <form
49
- onSubmit={(event) => {
64
+ onSubmit={async (event) => {
50
65
  event.preventDefault();
51
66
  event.stopPropagation();
52
- form.handleSubmit();
67
+ await form.handleSubmit();
53
68
  }}
54
69
  >
55
- {/* some styling */}
56
- <form.AppField name="name">
57
- {(field) => <field.TextField label={t("Feature.Name")} required sx={{ width: 420 }} />}
70
+ <form.AppField name="property1">
71
+ {(field) => <field.TextField label={t("Feature.Property1")} required sx={{ width: 420 }} />}
72
+ </form.AppField>
73
+
74
+ <form.AppField name="property2">
75
+ {(field) => (
76
+ <field.Autocomplete
77
+ options={options}
78
+ autoHighlight
79
+ autoSelect
80
+ autoComplete
81
+ loading={isLoading}
82
+ sx={{ width: 250 }}
83
+ textFieldProps={{ label: t("Feature.Property2"), required: true }}
84
+ />
85
+ )}
58
86
  </form.AppField>
59
- {/* some styling */}
87
+
88
+ <form.AppField name="property3">
89
+ {(field) => (
90
+ <field.NumberField label={t("Feature.Property3")} required sx={{ width: 120 }} />
91
+ )}
92
+ </form.AppField>
93
+
94
+ <form.AppField name="property4">
95
+ {(field) => <field.Switch label={t("Feature.Property4")} />}
96
+ </form.AppField>
97
+
60
98
  <form.AppForm>
61
99
  <form.SubmitButton variant="contained">{t("Submit")}</form.SubmitButton>
62
100
  </form.AppForm>
63
101
  </form>
64
102
  );
65
103
  };
66
-
67
- // Autocomplete
68
- <field.Autocomplete
69
- options={options}
70
- sx={{ width: 250 }}
71
- autoHighlight
72
- autoSelect
73
- autoComplete
74
- loading={isLoading}
75
- textFieldProps={{
76
- label: t("Customer"),
77
- required: true,
78
- }}
79
- />
80
-
81
- // Checkbox
82
- <field.Checkbox label={t("IsThisTrue")} />
83
104
  ```
@@ -1,94 +1,122 @@
1
- ---
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."
4
- ---
5
-
6
- > This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `data-grid`, `dialogs`) for targeted tasks.
7
-
8
- ## Preferred Technology Stack
9
-
10
- Favor the established platform before introducing custom code or a new dependency:
11
-
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.
13
- - **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
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
-
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.
19
-
20
- ## Coding Conventions
21
-
22
- - Generate modern ES6+ TypeScript with explicit types and never use `any`.
23
- - Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
24
- - Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
25
- - Keep code self-documenting; only add comments to clarify non-obvious intent.
26
-
27
- ## User Interface
28
-
29
- - Format all client-side dates with `"L LT"` or `"L"`.
30
- - 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.
32
-
33
- ## File Organization
34
-
35
- 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
-
37
- ```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
44
- │ ├── auth/
45
- │ │ ├── permissions.ts
46
- │ │ └── scopes.ts
47
- │ ├── locales/
48
- │ │ ├── cs.json
49
- │ │ └── en.json
50
- │ └── schemas/ # shared Zod schemas
51
- │ └── <table>.ts
52
- ├── routes/ # TanStack Router file-based routing
53
- │ ├── __root.tsx
54
- │ ├── index.tsx
55
- │ └── features/ # feature folder with multiple routes (kebab-case, plural)
56
- │ ├── -components/ # route-specific components
57
- │ ├── -hooks/ # route-specific hooks
58
- │ ├── index.tsx
59
- │ ├── create.tsx
60
- │ ├── $id.tsx
61
- │ └── edit.$id.tsx
62
- ├── server/ # server-only code
63
- │ ├── actions/
64
- │ │ └── <table>.ts
65
- │ ├── db/
66
- │ │ ├── migrations/
67
- │ │ ├── schemas/ # Drizzle schemas
68
- │ │ │ ├── <table>.ts
69
- │ │ │ └── relations.ts
70
- │ │ └── index.ts
71
- │ └── middleware/
72
- │ └── databaseMiddleware.ts
73
- └── types/
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
94
- ```
1
+ ---
2
+ name: general
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
7
+ ---
8
+
9
+ > This is the default skill. Reference it in combination with more specific skills (e.g., `forms`, `table`, `dialogs`, etc.) for targeted tasks. For the full catalogue of every `wcz-layout` import subpath and what it exports, read [references/exports.md](references/exports.md).
10
+
11
+ ## Preferred Technology Stack
12
+
13
+ Favor the established platform before introducing custom code or a new dependency:
14
+
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.
16
+ - **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
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.
18
+
19
+ When the requirement is not covered above, look for an existing library before writing any logic. Prefer a well-maintained, widely adopted, typed library over custom implementations, even for seemingly simple functionality where a library can reduce edge cases and bugs. If a suitable library exists, install it and use it. Only implement the functionality yourself when it takes a few lines or no suitable library exists.
20
+
21
+ ## Coding Conventions
22
+
23
+ - Write strict ES2023 TypeScript. Preserve local inference, type public boundaries and never use explicit `any`.
24
+ - Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
25
+ - Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
26
+ - Keep code self-documenting; only add comments to clarify non-obvious intent.
27
+ - Run the narrow relevant test, then `vp check --fix`. It formats, lints and type-checks.
28
+
29
+ ## User Interface
30
+
31
+ - Translate every user-facing string via `useTranslation` (or `t` outside components).
32
+ - Format all client-side dates with `"L LT"` or `"L"`.
33
+ - Build skeletons for loading states.
34
+ - 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.
35
+ - Always design for desktop and mobile, using responsive layouts and breakpoints to keep the UI usable on any screen.
36
+
37
+ ## Testing
38
+
39
+ - Tests run on `vp test` (bundled in vite-plus).
40
+
41
+ ## File Organization
42
+
43
+ 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.
44
+
45
+ ```txt
46
+ src/ # client-first architecture
47
+ ├── components/ # shared components across multiple routes
48
+ ├── db/ # TanStack DB
49
+ │ ├── collections/ # collection descriptors
50
+ │ │ └── <table>.ts
51
+ │ ├── queries/ # live query option objects
52
+ │ │ └── <table>.ts
53
+ │ └── persistence.ts # browser SQLite persistence
54
+ ├── env.ts # clientEnv + serverEnv via createEnv
55
+ ├── hooks/ # shared hooks across multiple routes
56
+ │ └── useTheme.ts # MUI theme + color schemes
57
+ ├── lib/ # isomorphic/shared logic usable by client and server
58
+ │ ├── auth/
59
+ │ │ ├── permissions.ts # as const satisfies Permissions
60
+ │ │ └── scopes.ts # as const satisfies Scopes
61
+ │ ├── locales/
62
+ │ │ ├── cs.json
63
+ │ │ └── en.json
64
+ │ └── schemas/ # shared Zod schemas
65
+ │ └── <table>.ts
66
+ ├── router.tsx # QueryClient, DbClient, router options
67
+ ├── routes/ # TanStack Router file-based routing
68
+ │ ├── __root.tsx
69
+ │ ├── index.tsx
70
+ │ ├── login.tsx # required by requireAuth
71
+ │ ├── auth/ # OAuth handlers
72
+ │ │ ├── login.ts
73
+ │ │ ├── callback.ts
74
+ │ │ └── logout.ts
75
+ │ ├── api/ # REST API routes (only when a public API is required)
76
+ │ │ └── features/
77
+ │ │ ├── index.ts
78
+ │ │ └── $id.ts
79
+ │ └── features/ # feature folder with multiple routes (kebab-case, plural)
80
+ │ ├── -components/ # route-specific components
81
+ │ ├── -hooks/ # route-specific hooks
82
+ │ ├── index.tsx
83
+ │ ├── create.tsx
84
+ │ ├── $id.tsx
85
+ │ └── edit.$id.tsx
86
+ ├── server/ # server-only code, never imported from a component
87
+ │ ├── actions/
88
+ │ │ └── <table>.ts
89
+ │ ├── db/
90
+ │ │ ├── migrations/
91
+ │ │ ├── schemas/ # Drizzle schemas
92
+ │ │ │ ├── <table>.ts
93
+ │ │ │ └── relations.ts
94
+ │ │ └── index.ts # pool, search_path, auto-migrate
95
+ │ └── middleware/
96
+ │ └── databaseMiddleware.ts # app-local, not a library export
97
+ ├── start.ts # request middleware, incl. CSRF
98
+ ├── types/
99
+ │ ├── i18next.d.ts # types t() against en.json
100
+ │ └── wcz-layout.d.ts # declares virtual:wcz-layout
101
+ tests/
102
+ ├── unit/
103
+ │ ├── lib/
104
+ │ │ └── schemas/
105
+ │ │ └── <table>.test.ts
106
+ │ ├── hooks/
107
+ │ │ └── useX.test.ts
108
+ │ └── routes/
109
+ │ └── features/
110
+ │ └── -components/
111
+ │ └── XCard.test.tsx
112
+ ├── integration/
113
+ │ ├── server/
114
+ │ │ └── actions/
115
+ │ │ └── <table>.test.ts
116
+ │ └── db/
117
+ │ └── collections/
118
+ │ └── <table>.test.ts
119
+ └── e2e/
120
+ └── features/
121
+ └── create.spec.ts
122
+ ```
@@ -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.