wcz-layout 9.6.6 → 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.
- package/dist/AggregatedCell-BtKC5-m6.mjs +497 -0
- package/dist/AggregatedCell-BtKC5-m6.mjs.map +1 -0
- package/dist/Approval-C-hF4jbT.mjs.map +1 -1
- package/dist/DialogsContext-DLqA8RJ_.mjs.map +1 -1
- package/dist/Email-BzQQkbe9.mjs.map +1 -1
- package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
- package/dist/LayoutTable-4DLs-NI-.d.mts +752 -0
- package/dist/{QueryClientParam-Cbb0MIKg.d.mts → QueryClientParam-JcH0mJWl.d.mts} +2 -2
- package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
- package/dist/{User-1gKoYJvW.d.mts → User-D4__w1I1.d.mts} +4 -2
- package/dist/approval-DFExxyAJ.mjs +84 -0
- package/dist/approval-DFExxyAJ.mjs.map +1 -0
- package/dist/auth.d.mts +21 -11
- package/dist/auth.mjs +43 -26
- package/dist/auth.mjs.map +1 -1
- package/dist/components.d.mts +22 -30
- package/dist/components.mjs +792 -145
- package/dist/components.mjs.map +1 -1
- package/dist/createApi-CLYWCzR2.mjs +27 -0
- package/dist/createApi-CLYWCzR2.mjs.map +1 -0
- package/dist/data/client.d.mts +703 -1152
- package/dist/data/client.mjs +4 -3
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +3 -3
- package/dist/data/server.mjs +4 -2
- package/dist/data/server.mjs.map +1 -1
- package/dist/{file-BTFDDalH.mjs → file-CZwQfvTU.mjs} +8 -27
- package/dist/file-CZwQfvTU.mjs.map +1 -0
- package/dist/{file-CuvAmdJW.mjs → file-aSQto2rw.mjs} +7 -9
- package/dist/file-aSQto2rw.mjs.map +1 -0
- package/dist/hooks.d.mts +7 -46
- package/dist/hooks.mjs +2578 -239
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +29 -9
- package/dist/index.mjs +1257 -499
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +20 -19
- package/dist/middleware.mjs +47 -2
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +17 -10
- package/dist/models.mjs.map +1 -1
- package/dist/{peoplesoft-D4w8d4s1.d.mts → peoplesoft-BY_75WTS.d.mts} +3 -2
- package/dist/{peoplesoft-DGdM1bws.mjs → peoplesoft-CQnc01Hc.mjs} +24 -81
- package/dist/peoplesoft-CQnc01Hc.mjs.map +1 -0
- package/dist/providers-Dbl95AxR.mjs +74 -0
- package/dist/providers-Dbl95AxR.mjs.map +1 -0
- package/dist/tokens-D8CVIFTb.mjs +143 -0
- package/dist/tokens-D8CVIFTb.mjs.map +1 -0
- package/dist/{utils-5x4uNxsX.d.mts → utils-Bhi0KiBx.d.mts} +18 -6
- package/dist/{utils-DjdexspV.mjs → utils-KaM5VMTJ.mjs} +64 -42
- package/dist/utils-KaM5VMTJ.mjs.map +1 -0
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +2 -2
- package/dist/vite.d.mts +1 -2
- package/dist/vite.mjs +3 -3
- package/dist/vite.mjs.map +1 -1
- package/package.json +128 -127
- package/skills/client-db/SKILL.md +104 -96
- package/skills/db-schema/SKILL.md +46 -33
- package/skills/dialogs/SKILL.md +21 -27
- package/skills/forms/SKILL.md +60 -39
- package/skills/general/SKILL.md +125 -94
- package/skills/general/references/exports.md +106 -0
- package/skills/migrations/SKILL.md +57 -0
- package/skills/migrations/versions/migrate-v9-to-v10.md +581 -0
- package/skills/routing/SKILL.md +50 -60
- package/skills/server-functions/SKILL.md +36 -56
- package/skills/services/SKILL.md +34 -31
- package/skills/services/docs/approval.md +2 -2
- package/skills/services/docs/peoplesoft.md +1 -1
- package/skills/start/SKILL.md +51 -47
- package/skills/start/steps/01-git-setup.md +0 -1
- package/skills/start/steps/04-wicop-setup.md +105 -80
- package/skills/start/steps/05-database-setup.md +13 -5
- package/skills/start/steps/06-entra-setup.md +96 -98
- package/skills/start/steps/07-vault-setup.md +57 -24
- package/skills/table/SKILL.md +275 -0
- package/skills/unslop/SKILL.md +80 -0
- package/dist/NotificationContext-CgwUOeW0.mjs +0 -7
- package/dist/NotificationContext-CgwUOeW0.mjs.map +0 -1
- package/dist/authMiddleware-DPly0b_T.mjs +0 -48
- package/dist/authMiddleware-DPly0b_T.mjs.map +0 -1
- package/dist/entra-CJSyeQsx.mjs +0 -109
- package/dist/entra-CJSyeQsx.mjs.map +0 -1
- package/dist/file-BTFDDalH.mjs.map +0 -1
- package/dist/file-CuvAmdJW.mjs.map +0 -1
- package/dist/msalServer-DLwA7_ta.mjs +0 -30
- package/dist/msalServer-DLwA7_ta.mjs.map +0 -1
- package/dist/peoplesoft-DGdM1bws.mjs.map +0 -1
- package/dist/useDialogs-BUzVrTSP.mjs +0 -248
- package/dist/useDialogs-BUzVrTSP.mjs.map +0 -1
- package/dist/user-Dzv0N9fj.d.mts +0 -16
- package/dist/utils-DjdexspV.mjs.map +0 -1
- package/skills/data-grid/SKILL.md +0 -142
package/skills/dialogs/SKILL.md
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dialogs
|
|
3
|
-
description: "Use
|
|
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
|
-
-
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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
|
-
|
|
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
|
);
|
package/skills/forms/SKILL.md
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: forms
|
|
3
|
-
description: "Use when
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
29
|
-
// Form
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
```
|
package/skills/general/SKILL.md
CHANGED
|
@@ -1,94 +1,125 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: general
|
|
3
|
-
description: "Use ALWAYS for project
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
├──
|
|
53
|
-
│
|
|
54
|
-
│ ├──
|
|
55
|
-
│ └──
|
|
56
|
-
│
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
│
|
|
60
|
-
|
|
61
|
-
│
|
|
62
|
-
├──
|
|
63
|
-
│
|
|
64
|
-
│
|
|
65
|
-
│ ├──
|
|
66
|
-
│ │
|
|
67
|
-
│
|
|
68
|
-
│
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
│
|
|
72
|
-
│
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
├──
|
|
76
|
-
│ ├──
|
|
77
|
-
│ │ └──
|
|
78
|
-
│
|
|
79
|
-
│
|
|
80
|
-
│ │
|
|
81
|
-
│ └──
|
|
82
|
-
│
|
|
83
|
-
│
|
|
84
|
-
│
|
|
85
|
-
├──
|
|
86
|
-
│
|
|
87
|
-
│
|
|
88
|
-
│
|
|
89
|
-
|
|
90
|
-
│
|
|
91
|
-
└──
|
|
92
|
-
|
|
93
|
-
|
|
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`) 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
|
+
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.
|
|
20
|
+
|
|
21
|
+
When the requirement is not covered above and a well-maintained, popular library solves it, use that library instead of writing your own implementation.
|
|
22
|
+
|
|
23
|
+
## Coding Conventions
|
|
24
|
+
|
|
25
|
+
- Write strict ES2023 TypeScript. Preserve local inference, type public boundaries and never use explicit `any`.
|
|
26
|
+
- Stick to double quotes, semicolons, and the `~/` alias for `src/` imports.
|
|
27
|
+
- Avoid `useMemo` / `useCallback`; the React Compiler handles memoization.
|
|
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.
|
|
30
|
+
|
|
31
|
+
## User Interface
|
|
32
|
+
|
|
33
|
+
- Translate every user-facing string via `useTranslation` (or `t` outside components).
|
|
34
|
+
- Format all client-side dates with `"L LT"` or `"L"`.
|
|
35
|
+
- Build skeletons for loading states.
|
|
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).
|
|
43
|
+
|
|
44
|
+
## File Organization
|
|
45
|
+
|
|
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.
|
|
47
|
+
|
|
48
|
+
```txt
|
|
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
|
|
61
|
+
│ ├── auth/
|
|
62
|
+
│ │ ├── permissions.ts # as const satisfies Permissions
|
|
63
|
+
│ │ └── scopes.ts # as const satisfies Scopes
|
|
64
|
+
│ ├── locales/
|
|
65
|
+
│ │ ├── cs.json
|
|
66
|
+
│ │ └── en.json
|
|
67
|
+
│ └── schemas/ # shared Zod schemas
|
|
68
|
+
│ └── <table>.ts
|
|
69
|
+
├── router.tsx # QueryClient, DbClient, router options
|
|
70
|
+
├── routes/ # TanStack Router file-based routing
|
|
71
|
+
│ ├── __root.tsx
|
|
72
|
+
│ ├── index.tsx
|
|
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
|
|
85
|
+
│ ├── index.tsx
|
|
86
|
+
│ ├── create.tsx
|
|
87
|
+
│ ├── $id.tsx
|
|
88
|
+
│ └── edit.$id.tsx
|
|
89
|
+
├── server/ # server-only code, never imported from a component
|
|
90
|
+
│ ├── actions/
|
|
91
|
+
│ │ └── <table>.ts
|
|
92
|
+
│ ├── db/
|
|
93
|
+
│ │ ├── migrations/
|
|
94
|
+
│ │ ├── schemas/ # Drizzle schemas
|
|
95
|
+
│ │ │ ├── <table>.ts
|
|
96
|
+
│ │ │ └── relations.ts
|
|
97
|
+
│ │ └── index.ts # pool, search_path, auto-migrate
|
|
98
|
+
│ └── middleware/
|
|
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
|
|
104
|
+
tests/
|
|
105
|
+
├── unit/
|
|
106
|
+
│ ├── lib/
|
|
107
|
+
│ │ └── schemas/
|
|
108
|
+
│ │ └── <table>.test.ts
|
|
109
|
+
│ ├── hooks/
|
|
110
|
+
│ │ └── useX.test.ts
|
|
111
|
+
│ └── routes/
|
|
112
|
+
│ └── features/
|
|
113
|
+
│ └── -components/
|
|
114
|
+
│ └── XCard.test.tsx
|
|
115
|
+
├── integration/
|
|
116
|
+
│ ├── server/
|
|
117
|
+
│ │ └── actions/
|
|
118
|
+
│ │ └── <table>.test.ts
|
|
119
|
+
│ └── db/
|
|
120
|
+
│ └── collections/
|
|
121
|
+
│ └── <table>.test.ts
|
|
122
|
+
└── e2e/
|
|
123
|
+
└── features/
|
|
124
|
+
└── create.spec.ts
|
|
125
|
+
```
|
|
@@ -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.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrations
|
|
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"
|
|
8
|
+
---
|
|
9
|
+
|
|
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.
|