wcz-layout 10.2.2 → 11.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/{ChatLayout-CkS9oyPp.mjs → ChatLayout-B0MBrI-Y.mjs} +839 -371
- package/dist/ChatLayout-B0MBrI-Y.mjs.map +1 -0
- package/dist/{ExtractFile-ClTc-e1H.d.mts → ExtractFile-BQUXpuBS.d.mts} +27 -3
- package/dist/FileMeta-B5VU-eCi.d.mts +55 -0
- package/dist/FileMeta-BexXC_45.mjs +35 -0
- package/dist/FileMeta-BexXC_45.mjs.map +1 -0
- package/dist/QueryClientParam-BG9Q_9XU.d.mts +6 -0
- package/dist/{Translate-BiCjnlyx.mjs → Translate-C43AmXYW.mjs} +25 -37
- package/dist/Translate-C43AmXYW.mjs.map +1 -0
- package/dist/User-CvLutatT.d.mts +10 -0
- package/dist/ai.d.mts +1 -1
- package/dist/ai.mjs +2 -2
- package/dist/ai.mjs.map +1 -1
- package/dist/auth.d.mts +6 -14
- package/dist/auth.mjs +15 -38
- package/dist/auth.mjs.map +1 -1
- package/dist/{authMiddleware-D4GSt7m9.mjs → authMiddleware-ANa9Tlmp.mjs} +10 -15
- package/dist/authMiddleware-ANa9Tlmp.mjs.map +1 -0
- package/dist/{ChatLayout-BmLySLXy.d.mts → components-2HKj8GpC.d.mts} +219 -255
- package/dist/components.d.mts +2 -126
- package/dist/components.mjs +871 -919
- package/dist/components.mjs.map +1 -1
- package/dist/data/client.d.mts +299 -57
- package/dist/data/client.mjs +5 -6
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +6 -5
- package/dist/data/server.mjs +3 -5
- package/dist/data/server.mjs.map +1 -1
- package/dist/env-C4WLVJMm.mjs +32 -0
- package/dist/env-C4WLVJMm.mjs.map +1 -0
- package/dist/file-DBqTibcr.mjs +176 -0
- package/dist/file-DBqTibcr.mjs.map +1 -0
- package/dist/file-hecCQszp.mjs +114 -0
- package/dist/file-hecCQszp.mjs.map +1 -0
- package/dist/hooks.d.mts +11 -91
- package/dist/hooks.mjs +152 -960
- package/dist/hooks.mjs.map +1 -1
- package/dist/i18n-ZRiIIdpb.mjs +563 -0
- package/dist/i18n-ZRiIIdpb.mjs.map +1 -0
- package/dist/index.d.mts +3 -35
- package/dist/index.mjs +409 -510
- package/dist/index.mjs.map +1 -1
- package/dist/layout-DeTB6Ai1.mjs +224 -0
- package/dist/layout-DeTB6Ai1.mjs.map +1 -0
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.mjs +2 -2
- package/dist/models.d.mts +34 -42
- package/dist/models.mjs +4 -6
- package/dist/models.mjs.map +1 -1
- package/dist/oidc--D2ox365.mjs +97 -0
- package/dist/oidc--D2ox365.mjs.map +1 -0
- package/dist/peoplesoft-DhwB8jrM.d.mts +204 -0
- package/dist/tokens-C4djIAhl.mjs +97 -0
- package/dist/tokens-C4djIAhl.mjs.map +1 -0
- package/dist/useDialogs-QER-2rVG.mjs +297 -0
- package/dist/useDialogs-QER-2rVG.mjs.map +1 -0
- package/dist/{user-Bc2nLjAG.mjs → user-DQx1BanQ.mjs} +4 -20
- package/dist/user-DQx1BanQ.mjs.map +1 -0
- package/dist/{utils-CNYCSgip.d.mts → utils-BnyAEKW7.d.mts} +7 -9
- package/dist/{utils-CgabUlDD.mjs → utils-H4BskGF8.mjs} +21 -20
- package/dist/utils-H4BskGF8.mjs.map +1 -0
- package/dist/utils.d.mts +21 -4
- package/dist/utils.mjs +5 -4
- package/dist/vite.mjs +98 -32
- package/dist/vite.mjs.map +1 -1
- package/package.json +16 -43
- package/skills/ai/SKILL.md +1 -4
- package/skills/general/SKILL.md +15 -8
- package/skills/general/references/auth.md +10 -16
- package/skills/general/references/languages.md +56 -0
- package/skills/migrations/versions/migrate-v10-to-v11.md +98 -22
- package/skills/migrations/versions/migrate-v9-to-v10.md +22 -22
- package/skills/services/SKILL.md +1 -1
- package/skills/services/docs/email.md +2 -2
- package/skills/services/docs/file.md +100 -85
- package/skills/services/docs/layout.md +2 -3
- package/skills/start/steps/02-project-name-setup.md +1 -1
- package/skills/start/steps/06-entra-setup.md +1 -1
- package/skills/start/steps/08-generate-favicon.md +1 -1
- package/skills/table/SKILL.md +18 -5
- package/src/lib/locales/cs.json +120 -0
- package/src/lib/locales/en.json +119 -0
- package/src/lib/locales/uk.json +121 -0
- package/src/lib/locales/zh-TW.json +118 -0
- package/dist/ChatLayout-CkS9oyPp.mjs.map +0 -1
- package/dist/DialogsContext-D23fJjYR.mjs +0 -6
- package/dist/DialogsContext-D23fJjYR.mjs.map +0 -1
- package/dist/FileMeta-B39e2FLC.d.mts +0 -17
- package/dist/FileMeta-CPBWI_jA.mjs +0 -18
- package/dist/FileMeta-CPBWI_jA.mjs.map +0 -1
- package/dist/QueryClientParam-CTV1vj76.d.mts +0 -8
- package/dist/RouterListItemButton-CF-8w-08.mjs +0 -62
- package/dist/RouterListItemButton-CF-8w-08.mjs.map +0 -1
- package/dist/Translate-BiCjnlyx.mjs.map +0 -1
- package/dist/User-aJksXItw.d.mts +0 -12
- package/dist/authMiddleware-D4GSt7m9.mjs.map +0 -1
- package/dist/createApi-CF4ZL82B.mjs +0 -24
- package/dist/createApi-CF4ZL82B.mjs.map +0 -1
- package/dist/env-Cddts_dn.mjs +0 -49
- package/dist/env-Cddts_dn.mjs.map +0 -1
- package/dist/file-D4kSR_lC.mjs +0 -149
- package/dist/file-D4kSR_lC.mjs.map +0 -1
- package/dist/file-DcwYjofa.mjs +0 -150
- package/dist/file-DcwYjofa.mjs.map +0 -1
- package/dist/layout-6We_KFgN.mjs +0 -107
- package/dist/layout-6We_KFgN.mjs.map +0 -1
- package/dist/peoplesoft-DH31FCMC.mjs +0 -125
- package/dist/peoplesoft-DH31FCMC.mjs.map +0 -1
- package/dist/peoplesoft-DXukeeFr.d.mts +0 -161
- package/dist/providers-DOFje2P6.mjs +0 -56
- package/dist/providers-DOFje2P6.mjs.map +0 -1
- package/dist/tokens-DNe_Qifk.mjs +0 -204
- package/dist/tokens-DNe_Qifk.mjs.map +0 -1
- package/dist/user-Bc2nLjAG.mjs.map +0 -1
- package/dist/utils-CgabUlDD.mjs.map +0 -1
package/skills/ai/SKILL.md
CHANGED
|
@@ -13,10 +13,7 @@ metadata:
|
|
|
13
13
|
|
|
14
14
|
- Install `@tanstack/ai` and `@tanstack/ai-openai` in the app (if missing). An app with the
|
|
15
15
|
assistant also installs `@tanstack/ai-code-mode`, `@tanstack/ai-isolate-quickjs` and
|
|
16
|
-
`@tanstack/ai-compaction`: `layoutChat` loads them on its first call.
|
|
17
|
-
peers ask for an older vitest than vite-plus brings, so npm refuses to install it until the
|
|
18
|
-
app's `package.json` has `"overrides": { "@tanstack/ai-persistence": { "vitest": "<version>" } }`,
|
|
19
|
-
with the version `npm ls vitest` shows. `@tanstack/charts` is a peer of wcz-layout, which npm
|
|
16
|
+
`@tanstack/ai-compaction`: `layoutChat` loads them on its first call. `@tanstack/charts` is a peer of wcz-layout, which npm
|
|
20
17
|
installs with it; the chat loads it with the first chart the model draws.
|
|
21
18
|
- Code mode runs the model's programs in QuickJS, whose WebAssembly a production bundle leaves
|
|
22
19
|
behind: give the app's `nitro()` plugin `traceDeps: ["quickjs-emscripten"]` in `vite.config.ts`.
|
package/skills/general/SKILL.md
CHANGED
|
@@ -32,7 +32,9 @@ the wcz-layout skill wins. Permissions, scopes, the signed-in user and downstrea
|
|
|
32
32
|
|
|
33
33
|
- Every screen works in light and dark (`theme.applyStyles("dark", …)`; the theme sets
|
|
34
34
|
`colorSchemeSelector: "data-mui-color-scheme"`) and on desktop and mobile (breakpoints).
|
|
35
|
-
- Dates: `dayjs(value).format("L LT")`, or `"L"` for a date alone
|
|
35
|
+
- Dates: `dayjs(value).locale(i18n.language).format("L LT")`, or `"L"` for a date alone, with
|
|
36
|
+
`i18n` from `useTranslation()`. The React Compiler caches a bare `dayjs(value).format()`, so
|
|
37
|
+
without the locale a date keeps its old format after a language switch.
|
|
36
38
|
- Loading states are skeletons of the final layout.
|
|
37
39
|
- A component fetching its own `useQuery` waits until visible:
|
|
38
40
|
`const { ref, inView } = useInView({ triggerOnce: true })` (`wcz-layout/hooks`),
|
|
@@ -51,9 +53,14 @@ the wcz-layout skill wins. Permissions, scopes, the signed-in user and downstrea
|
|
|
51
53
|
- Every user-facing string goes through `t`: `useTranslation()` from `wcz-layout/hooks` in
|
|
52
54
|
components, `t` from `wcz-layout/utils`. `t()` translates when called, so never at module scope (Zod messages: see
|
|
53
55
|
db-schema).
|
|
54
|
-
- Add each key to `src/lib/locales/*.json
|
|
56
|
+
- Add each key to every `src/lib/locales/*.json`; the type-check names a key a locale lacks.
|
|
55
57
|
Feature keys go under the feature's namespace (`"Feature": { "Name": "Name" }`), shared ones at the root.
|
|
56
|
-
Counts use plural keys: `_one`, `_other`,
|
|
58
|
+
Counts use plural keys: `_one`, `_other`, plus `_few` in Czech and `_few`, `_many` in
|
|
59
|
+
Ukrainian; Traditional Chinese (`zh-TW`) has only `_other`.
|
|
60
|
+
- On the server `t` translates into the language of the request; `getLanguage()`
|
|
61
|
+
(`wcz-layout/utils`) returns it for anything else, e.g. dates in an email.
|
|
62
|
+
- Adding a language, how the language is chosen and server-side translations:
|
|
63
|
+
[references/languages.md](references/languages.md).
|
|
57
64
|
|
|
58
65
|
## Building a feature
|
|
59
66
|
|
|
@@ -84,20 +91,20 @@ src/
|
|
|
84
91
|
│ └── queries/<entity>.ts # live query options
|
|
85
92
|
├── lib/ # isomorphic: client and server
|
|
86
93
|
│ ├── auth/ # permissions.ts, scopes.ts
|
|
87
|
-
│ ├── locales/ # en.json, cs.json
|
|
94
|
+
│ ├── locales/ # en.json, cs.json, uk.json, zh-TW.json
|
|
88
95
|
│ └── schemas/<entity>.ts # Zod schema + type
|
|
89
96
|
├── routes/
|
|
90
97
|
│ ├── __root.tsx # shell, navigation, root beforeLoad
|
|
91
|
-
│ ├── index.tsx,
|
|
98
|
+
│ ├── index.tsx, health.ts, auth/ # from the template, keep
|
|
92
99
|
│ ├── api/<entities>/ # REST routes, only for a requested public API
|
|
93
100
|
│ └── <entities>/ # feature pages; -components/, -hooks/
|
|
94
101
|
├── server/ # server-only
|
|
95
102
|
│ ├── actions/<entity>.ts # server functions
|
|
96
103
|
│ ├── db/ # index.ts, schemas/<entity>.ts, schemas/relations.ts, migrations/
|
|
97
104
|
│ └── middleware/databaseMiddleware.ts
|
|
98
|
-
├── env.ts #
|
|
105
|
+
├── env.ts # Zod shapes server, client (VITE_)
|
|
99
106
|
├── router.tsx # QueryClient, DbClient, router defaults
|
|
100
|
-
└── types/ # i18next.
|
|
107
|
+
└── types/ # i18next.gen.ts, wcz-layout.d.ts
|
|
101
108
|
```
|
|
102
109
|
|
|
103
110
|
## Tests
|
|
@@ -108,7 +115,7 @@ bug), not coverage. `vp test` runs `tests/unit` and `tests/integration`, paths m
|
|
|
108
115
|
|
|
109
116
|
- No globals: import from `vite-plus/test`. Component tests start with
|
|
110
117
|
`// @vitest-environment jsdom` and call `afterEach(cleanup)`.
|
|
111
|
-
-
|
|
118
|
+
- Assert Zod issue `path` and `code`, not messages: messages follow the language.
|
|
112
119
|
- Collection tests mock the select server function, not TanStack DB. Use a fresh `DbClient`
|
|
113
120
|
per case; for one query, await `preloadLiveQuery(q)` and read
|
|
114
121
|
`dehydrate().liveQueries?.[0]?.snapshot?.rows.map(({ value }) => value)`.
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
- Permissions are evaluated per request, so moving an existing group between keys applies
|
|
15
15
|
immediately. A group name new to `permissions.ts` applies only after the user signs in
|
|
16
16
|
again (the cookie keeps only groups listed there).
|
|
17
|
-
|
|
18
|
-
Use the bare form for routes AWS users must reach.
|
|
17
|
+
|
|
19
18
|
- Offline, guards use a cached user snapshot from `localStorage` — UI state only, the server still authorizes every call.
|
|
20
19
|
|
|
21
20
|
```ts
|
|
@@ -30,21 +29,18 @@ export const permissions = {
|
|
|
30
29
|
import type { Scopes } from "wcz-layout/models";
|
|
31
30
|
|
|
32
31
|
export const scopes = {
|
|
33
|
-
graph: "User.Read",
|
|
34
|
-
file:
|
|
35
|
-
entra: "api://wistron.com/file-api/access_as_user",
|
|
36
|
-
aws: "https://file-api.wistron.com/access_as_user",
|
|
37
|
-
},
|
|
32
|
+
graph: "User.Read",
|
|
33
|
+
file: "api://wistron.com/file-api/access_as_user",
|
|
38
34
|
} as const satisfies Scopes;
|
|
39
35
|
```
|
|
40
36
|
|
|
41
37
|
## Gates
|
|
42
38
|
|
|
43
|
-
| Gate
|
|
44
|
-
|
|
|
45
|
-
| Anyone (default)
|
|
46
|
-
| Signed in
|
|
47
|
-
| Signed in + permission
|
|
39
|
+
| Gate | Route `beforeLoad` | Server function / API route |
|
|
40
|
+
| ---------------------- | ------------------ | --------------------------- |
|
|
41
|
+
| Anyone (default) | — | — or `userMiddleware` |
|
|
42
|
+
| Signed in | `requireAuth()` | `authMiddleware()` |
|
|
43
|
+
| Signed in + permission | `requireAuth(key)` | `authMiddleware(key)` |
|
|
48
44
|
|
|
49
45
|
## Tokens for downstream APIs
|
|
50
46
|
|
|
@@ -53,14 +49,12 @@ From `wcz-layout/auth`, server-only (call inside a server function or server rou
|
|
|
53
49
|
- `getAccessToken(scopeKey)` — delegated token for the user behind the request: minted from
|
|
54
50
|
their session, or, when a sibling service calls with an Entra user token as Bearer, exchanged
|
|
55
51
|
for it on behalf of that user (OBO). OBO needs this app's registration to hold the delegated
|
|
56
|
-
permission for the downstream API, with admin consent;
|
|
57
|
-
|
|
52
|
+
permission for the downstream API, with admin consent; an app token as Bearer counts as no
|
|
53
|
+
user and throws. An expired session clears the cookie and
|
|
58
54
|
throws a 401 `Response`. `createApi` services use it whenever there is a user, and fall back
|
|
59
55
|
to `getAppToken` otherwise.
|
|
60
56
|
- `getAppToken(scopeKey)` — app-only Entra token (client credentials, `<resource>/.default`),
|
|
61
57
|
cached in memory. For background jobs and calls with no user.
|
|
62
|
-
- Downstream APIs must trust both issuers to accept AWS users; Cognito tokens have no `aud`
|
|
63
|
-
and are authorized by the `scope` claim.
|
|
64
58
|
|
|
65
59
|
## Example
|
|
66
60
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# wcz-layout languages
|
|
2
|
+
|
|
3
|
+
## Rules
|
|
4
|
+
|
|
5
|
+
- A language is a file: `src/lib/locales/<code>.json`, `<code>` a BCP 47 tag (`de`, `zh-TW`).
|
|
6
|
+
The language menu lists exactly these files; `en.json` is the fallback for missing keys.
|
|
7
|
+
- The server renders the `i18next` cookie the menu writes, else the browser's
|
|
8
|
+
`Accept-Language`. A switch re-renders in place: typed form values stay, while texts, MUI
|
|
9
|
+
components, pickers, Zod messages and shown errors change language.
|
|
10
|
+
- `src/types/i18next.gen.ts` is generated from the locale files on `vp dev` and `vp build`;
|
|
11
|
+
commit it, never edit it. It types `t()` from `en.json` and fails the type-check, naming the
|
|
12
|
+
key, when another locale lacks one of `en.json`'s keys.
|
|
13
|
+
- wcz-layout's own strings (`Layout.*`) ship with the package in `en`, `cs`, `uk` and `zh-TW`;
|
|
14
|
+
never copy them into an app. For another language they show in English until that locale has its own
|
|
15
|
+
`"Layout"` object, which overrides wcz-layout's key by key.
|
|
16
|
+
|
|
17
|
+
## Adding a language
|
|
18
|
+
|
|
19
|
+
1. Create `src/lib/locales/<code>.json` with every key of `en.json`, translated. Plurals use
|
|
20
|
+
the suffixes that language needs (`_one`, `_few`, `_many`, `_other`, ...), not English's.
|
|
21
|
+
2. For wcz-layout's own strings in that language, add a `"Layout"` object: copy it from
|
|
22
|
+
`node_modules/wcz-layout/src/lib/locales/en.json` and translate it.
|
|
23
|
+
3. Nothing else: the running dev server picks the file up and reloads, and wcz-layout loads
|
|
24
|
+
the dayjs, Zod and MUI locales for it.
|
|
25
|
+
|
|
26
|
+
Removing a language is deleting its file.
|
|
27
|
+
|
|
28
|
+
## Server
|
|
29
|
+
|
|
30
|
+
`t` from `wcz-layout/utils` translates into the language of the request it runs in, and
|
|
31
|
+
`getLanguage()` returns that language, for anything `t` does not cover. Outside a request
|
|
32
|
+
(startup, background jobs) both use `en`.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
36
|
+
import dayjs from "dayjs";
|
|
37
|
+
import { sendEmail } from "wcz-layout/data/server";
|
|
38
|
+
import { authMiddleware } from "wcz-layout/middleware";
|
|
39
|
+
import { getLanguage, t } from "wcz-layout/utils";
|
|
40
|
+
|
|
41
|
+
export const sendReminder = createServerFn({ method: "POST" })
|
|
42
|
+
.middleware([authMiddleware()])
|
|
43
|
+
.handler(async ({ context }) => {
|
|
44
|
+
const due = dayjs().add(1, "day").locale(getLanguage()).format("L");
|
|
45
|
+
await sendEmail({
|
|
46
|
+
data: {
|
|
47
|
+
subject: t("Reminder.Subject"),
|
|
48
|
+
body: `<p>${t("Reminder.Body", { due })}</p>`,
|
|
49
|
+
to: [context.user.email],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A message for someone other than the caller needs the recipient's language, stored with
|
|
56
|
+
them: `i18next.getFixedT(language)` (`i18next` from `wcz-layout/utils`) is a `t` in it.
|
|
@@ -1,34 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
# Files: signed URLs, direct chunked upload
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The file service is the new Rust one (same `FILE_BASE_URL` variable, now the bare host: drop a trailing `/file`). Browsers read files through
|
|
4
|
+
URLs it signs (2-3 hours, one file each) and upload straight to it in 1 MiB chunks, so no Entra
|
|
5
|
+
token reaches the browser any more. `tus-js-client` and `getFileUploadToken` are gone. Files live
|
|
6
|
+
under the app's `package.json` name, which wcz-layout now sets itself: `appName` is gone from
|
|
7
|
+
every file call and from `FileViewer`. Grep `src/` for every name on the left.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
| v10 | v11 |
|
|
10
|
+
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `fileThumbnailQueryOptions({ appName, id })` (object URL) | `meta.urls.thumbnail` |
|
|
12
|
+
| `fileQueryOptions({ appName, id })` (object URL) | `meta.urls.view`; with only an id: `useQuery(fileMetaQueryOptions({ id }))` |
|
|
13
|
+
| `downloadFileMutationOptions()` + `download({ … })` | `<a href={meta.urls.download}>` (or `href` on a MUI `Button`/`MenuItem`) |
|
|
14
|
+
| `openFileMutationOptions({ target })` + `window.open("about:blank")` | `window.open(meta.urls.view, "_blank", "noopener")` in the click handler |
|
|
15
|
+
| server `getFile`, `downloadFile`, `getFileThumbnail` (`Response`) | `fetch(meta.urls.view / .download / .thumbnail)` |
|
|
16
|
+
| `fileMetasQueryOptions({ appName, subId })`, `batchDelete…` likewise | `({ subId })` |
|
|
17
|
+
| `deleteFile…({ appName, id })`, `FileSchema` with `appName` | `({ id })` |
|
|
18
|
+
| `<FileViewer appName={…} subId={…}>` | `<FileViewer subId={…}>` |
|
|
19
|
+
| `updateFileMeta…({ …wholeFileMeta, fileName })` | `({ id, fileName?, subId?, public?, permissions? })` → updated `FileMeta`; `fileName` without the extension |
|
|
20
|
+
| `uploadFile…({ appName, subId, file })` → `{ id, appName, … }` | `({ subId, file })` → the created `FileMeta`; also takes `public`, `permissions`, `signal` |
|
|
21
|
+
| `meta.createdBy`, `meta.createdDate` | gone: the file service keeps who and when in its audit log |
|
|
22
|
+
| hand-built iOS `.plist` + no-auth `/na/file/…` URL | `meta.urls.install` of the `.ipa` (manifest generated from its `Info.plist`) |
|
|
6
23
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
1. Apply the table. `FileMeta` gained `public`, `permissions`, `canWrite` and `urls`; `subId` is
|
|
25
|
+
any 1-255 character string, no longer only a UUID. The type of a file now comes from its
|
|
26
|
+
extension.
|
|
27
|
+
2. Never store `urls` (state, database, email body): they expire. Store the file `id` and read
|
|
28
|
+
the URLs from `fileMetasQueryOptions` / `fileMetaQueryOptions`, which refresh them hourly.
|
|
29
|
+
3. Show rename and delete only where `meta.canWrite`.
|
|
30
|
+
4. Restricting a file: pass `permissions: { read, write }` (see `skills/services/docs/file.md`).
|
|
31
|
+
Without it everyone the app serves reads and changes the file, as before. Public routes keep
|
|
32
|
+
working without a user, through the app token, which reaches only files without a list: on a
|
|
33
|
+
public route, restrict `write` to keep anonymous visitors from deleting files.
|
|
10
34
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
# Internationalization
|
|
36
|
+
|
|
37
|
+
The server now renders the language of each request (the `i18next` cookie, else
|
|
38
|
+
`Accept-Language`), wcz-layout ships its own `Layout.*` strings, and a language switch
|
|
39
|
+
re-renders in place instead of remounting the page, so typed form values survive it.
|
|
40
|
+
|
|
41
|
+
1. `src/routes/__root.tsx`: delete `setLanguageFromRequest` (the import and the `await` in
|
|
42
|
+
`beforeLoad`) and every `import "dayjs/locale/…"`. Call `useTheme()` without the language.
|
|
43
|
+
`useTranslation` there must come from `wcz-layout/hooks`: react-i18next's own renders the
|
|
44
|
+
server's default language above `LayoutProvider`.
|
|
45
|
+
2. `src/hooks/useTheme.ts`: delete the `@mui/material/locale` and `@mui/x-date-pickers/locales`
|
|
46
|
+
imports, `MUI_LOCALE_MAP`, its type guard and the `locale` parameter. `LayoutProvider`
|
|
47
|
+
applies the MUI locales of every app language.
|
|
48
|
+
3. `src/lib/locales/en.json`, `cs.json`, `uk.json` and `zh-TW.json`: delete the `"Layout"`
|
|
49
|
+
object; a copy would hide wcz-layout's later changes. In any other language's file keep it:
|
|
50
|
+
it now overrides wcz-layout's English key by key.
|
|
51
|
+
4. Every app ships Ukrainian and Traditional Chinese (Taiwan). Where `src/lib/locales/uk.json`
|
|
52
|
+
or `zh-TW.json` is missing, create it next to the existing files with every key of the
|
|
53
|
+
app's `en.json`, translated into that language yourself as part of this step; do not ask
|
|
54
|
+
and do not leave English values. Plurals: `uk` needs `_one`, `_few`, `_many` and
|
|
55
|
+
`_other`; `zh-TW` has only `_other`. Keep `{{placeholders}}` and `<tags>` as they are. No
|
|
56
|
+
`"Layout"` object: wcz-layout ships both.
|
|
57
|
+
5. Delete `src/types/i18next.d.ts`. `vp dev` writes `src/types/i18next.gen.ts`, which also
|
|
58
|
+
checks every locale against `en.json`; commit it and add the keys the type-check reports
|
|
59
|
+
missing.
|
|
60
|
+
6. Dates formatted in components: `dayjs(value).format(…)` becomes
|
|
61
|
+
`dayjs(value).locale(i18n.language).format(…)`, `i18n` from `useTranslation()`, or the date
|
|
62
|
+
keeps its old format after a language switch.
|
|
63
|
+
|
|
64
|
+
Server code needs no change: `t` from `wcz-layout/utils` now translates into the request's
|
|
65
|
+
language, and `getLanguage()` is new there.
|
|
19
66
|
|
|
20
67
|
# Environment variables
|
|
21
68
|
|
|
22
|
-
|
|
69
|
+
`@t3-oss/env-core` is gone. `src/env.ts` now only names variables: wcz-layout validates them
|
|
70
|
+
(empty values count as unset) and serves the values as `serverEnv` and `clientEnv` from
|
|
71
|
+
`wcz-layout/utils`. wcz-layout reads only what the app names, its own variables included.
|
|
23
72
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
73
|
+
1. Rewrite `src/env.ts` like `scopes.ts`: `export const env = { server: { … }, client: { … } }
|
|
74
|
+
satisfies Env;`, `Env` from `wcz-layout/models`. `server` takes the old `server` block,
|
|
75
|
+
`client` the old `client` block (`VITE_` only, `{}` when empty): UPPER_SNAKE_CASE keys, Zod
|
|
76
|
+
schemas as values. Only `import type` from wcz-layout there; a runtime import is a cycle.
|
|
77
|
+
2. Name in `server` every variable the app reads, wcz-layout's too: `ENTRA_CLIENT_ID`,
|
|
78
|
+
`ENTRA_TENANT_ID`, `ENTRA_CLIENT_SECRET` and `SESSION_SECRET` (`z.string().min(32)`) always,
|
|
79
|
+
the `*_BASE_URL` of each wcz-layout service it uses (file, approval, PeopleSoft, email,
|
|
80
|
+
layout), `AI_BASE_URL` and `AI_SUBSCRIPTION_KEY` for AI. An unnamed variable stays
|
|
81
|
+
`undefined` to wcz-layout even when it is set.
|
|
82
|
+
3. Import `serverEnv` and `clientEnv` from `wcz-layout/utils` instead of `~/env`.
|
|
83
|
+
4. `src/types/wcz-layout.d.ts`: replace the `serverEnv` line with
|
|
84
|
+
`export const env: typeof import("~/env").env;`.
|
|
27
85
|
|
|
28
|
-
#
|
|
86
|
+
# Sign-in
|
|
29
87
|
|
|
30
|
-
|
|
88
|
+
Entra is the only sign-in: `/auth/login` redirects straight to it, so the provider chooser is
|
|
89
|
+
gone. Delete `src/routes/login.tsx` (`LoginForm` and `loginProvidersQueryOptions` no longer
|
|
90
|
+
exist) and any `AWS_*` variables.
|
|
91
|
+
|
|
92
|
+
# Web app manifest
|
|
31
93
|
|
|
32
|
-
|
|
94
|
+
`viteWczLayout()` and `rootRouteHead()` now use `public/manifest.webmanifest` instead of
|
|
95
|
+
`public/manifest.json`.
|
|
33
96
|
|
|
34
|
-
|
|
97
|
+
Rename `public/manifest.json` to `public/manifest.webmanifest`.
|
|
98
|
+
`rootRouteHead()` now also emits `<meta name="theme-color">` from `theme_color` in the
|
|
99
|
+
manifest when present.
|
|
100
|
+
|
|
101
|
+
# package.json overrides
|
|
102
|
+
|
|
103
|
+
v11 needs no `overrides` for wcz-layout. Delete the `"wcz-layout"` entry (such as
|
|
104
|
+
`{ "@tanstack/react-db": "$@tanstack/react-db" }`) and add none. If `npm install wcz-layout@11`
|
|
105
|
+
then fails with `ERESOLVE` on a peer of the new AI packages, the old lockfile is in the way:
|
|
106
|
+
delete `package-lock.json` and install again instead of adding an override.
|
|
107
|
+
|
|
108
|
+
# Material UI 10
|
|
109
|
+
|
|
110
|
+
One of the changes (instead of "react-number-format"): https://mui.com/material-ui/react-number-field/
|
|
@@ -286,26 +286,28 @@ Delete `src/components/DataGridToolbar.tsx`; `LayoutTable` renders the toolbar,
|
|
|
286
286
|
quick filter, columns panel and filter panel itself. In `useTheme.ts`, drop
|
|
287
287
|
`import { csCZ, enUS } from "@mui/x-data-grid/locales"` and its two entries.
|
|
288
288
|
|
|
289
|
-
| DataGridPremium | LayoutTable
|
|
290
|
-
| --------------------------------------------------- |
|
|
291
|
-
| `Array<GridColDef<Row>>` | `columnHelper.columns([...])` from `createLayoutColumnHelper`
|
|
292
|
-
| `field` / `headerName` | the accessor key / `header`
|
|
293
|
-
| `width`, `flex`, `minWidth` | `size`
|
|
294
|
-
| `renderCell` | `cell: ({ cell }) => <cell.ValueCell />`
|
|
295
|
-
| `valueGetter: (_v, row) => row.x.y` | `columnHelper.accessor((row) => row.x.y, { id: "..." })`
|
|
296
|
-
| `align` / `headerAlign` | `meta: { align }`
|
|
297
|
-
| `initialState.pinnedColumns.left` / `.right` | `initialState.columnPinning.start` / `.end`
|
|
298
|
-
| `initialState.sorting.sortModel` `{field, sort}` | `initialState.sorting` `[{ id, desc }]`
|
|
299
|
-
| `valueFormatter` on a date column | `cell.DateCell` or `cell.DateTimeCell`
|
|
300
|
-
| `valueFormatter` with an `Intl.NumberFormat` | `cell.NumberCell options={...}`, same options object
|
|
301
|
-
| `type: "singleSelect"` with `valueOptions` | `meta: { variant: "select", options }`
|
|
302
|
-
| `type: "number"` / `"date"` / `"boolean"` | `meta: { variant: "number" \| "date" \| "boolean" }`
|
|
303
|
-
| `rows` and `columns` props | `useLayoutTable({ data, columns })`, then `table={table}`
|
|
304
|
-
| `showToolbar` with `slots.toolbar` | `showToolbar` with `title` and `actions` on `LayoutTable`
|
|
305
|
-
| `ignoreDiacritics` | always on
|
|
306
|
-
| `rowSelectionModel` state | `table.getSelectedRowIds()`, `table.resetRowSelection()`
|
|
307
|
-
| `cellSelection` | always on, `Mod+C` copies the range as TSV
|
|
308
|
-
| `GridActionsCellItem` in a `type: "actions"` column | a `display` column rendering `cell.ActionsCell`, `showInMenu` kept
|
|
289
|
+
| DataGridPremium | LayoutTable |
|
|
290
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
291
|
+
| `Array<GridColDef<Row>>` | `columnHelper.columns([...])` from `createLayoutColumnHelper` |
|
|
292
|
+
| `field` / `headerName` | the accessor key / `header` |
|
|
293
|
+
| `width`, `flex`, `minWidth` | `size` |
|
|
294
|
+
| `renderCell` | `cell: ({ cell }) => <cell.ValueCell />` |
|
|
295
|
+
| `valueGetter: (_v, row) => row.x.y` | `columnHelper.accessor((row) => row.x.y, { id: "..." })` |
|
|
296
|
+
| `align` / `headerAlign` | `meta: { align }` |
|
|
297
|
+
| `initialState.pinnedColumns.left` / `.right` | `initialState.columnPinning.start` / `.end` |
|
|
298
|
+
| `initialState.sorting.sortModel` `{field, sort}` | `initialState.sorting` `[{ id, desc }]` |
|
|
299
|
+
| `valueFormatter` on a date column | `cell.DateCell` or `cell.DateTimeCell` |
|
|
300
|
+
| `valueFormatter` with an `Intl.NumberFormat` | `cell.NumberCell options={...}`, same options object |
|
|
301
|
+
| `type: "singleSelect"` with `valueOptions` | `meta: { variant: "select", options }` |
|
|
302
|
+
| `type: "number"` / `"date"` / `"boolean"` | `meta: { variant: "number" \| "date" \| "boolean" }` |
|
|
303
|
+
| `rows` and `columns` props | `useLayoutTable({ data, columns })`, then `table={table}` |
|
|
304
|
+
| `showToolbar` with `slots.toolbar` | `showToolbar` with `title` and `actions` on `LayoutTable` |
|
|
305
|
+
| `ignoreDiacritics` | always on |
|
|
306
|
+
| `rowSelectionModel` state | `table.getSelectedRowIds()`, `table.resetRowSelection()` |
|
|
307
|
+
| `cellSelection` | always on, `Mod+C` copies the range as TSV |
|
|
308
|
+
| `GridActionsCellItem` in a `type: "actions"` column | a `display` column rendering `cell.ActionsCell`, `showInMenu` kept |
|
|
309
|
+
| `pagination`, `pageSizeOptions`, `paginationModel` | `pagination` only: always 25 rows per page, drop the sizes |
|
|
310
|
+
| `paginationMode="server"` with `rowCount` | `manualPagination: true` and `rowCount` on `useLayoutTable` (table skill) |
|
|
309
311
|
|
|
310
312
|
**Every row needs an `id`.** `getRowId` is not an option — the library hardcodes
|
|
311
313
|
`row.id`. A table over a view or a natural-key table without an `id` column must add
|
|
@@ -455,7 +457,6 @@ it over the app's block. For any other language, translate the English block.
|
|
|
455
457
|
"SelectedCount_other": "{{count}} selected",
|
|
456
458
|
"MoveLeft": "Move left",
|
|
457
459
|
"MoveRight": "Move right",
|
|
458
|
-
"All": "All",
|
|
459
460
|
"Columns": "Columns",
|
|
460
461
|
"ShowHideAll": "Show/Hide all",
|
|
461
462
|
"HideColumn": "Hide column",
|
|
@@ -548,7 +549,6 @@ it over the app's block. For any other language, translate the English block.
|
|
|
548
549
|
"SelectedCount_other": "{{count}} vybraných",
|
|
549
550
|
"MoveLeft": "Posunout doleva",
|
|
550
551
|
"MoveRight": "Posunout doprava",
|
|
551
|
-
"All": "Vše",
|
|
552
552
|
"Columns": "Sloupce",
|
|
553
553
|
"ShowHideAll": "Zobrazit/skrýt vše",
|
|
554
554
|
"HideColumn": "Skrýt sloupec",
|
package/skills/services/SKILL.md
CHANGED
|
@@ -41,7 +41,7 @@ When the app needs a downstream REST API that no service above covers, build the
|
|
|
41
41
|
signed-in user's token for the scope and turns error responses into `Error(message)`. It is
|
|
42
42
|
server-only: call it inside a server function handler, never at module scope.
|
|
43
43
|
|
|
44
|
-
1. `src/env.ts`: add `MY_API_BASE_URL: z.url()` to `
|
|
44
|
+
1. `src/env.ts`: add `MY_API_BASE_URL: z.url()` to `server` (`createApi` takes only `z.url()` variables).
|
|
45
45
|
2. `src/lib/auth/scopes.ts`: add `myApi: "api://wistron.com/my-api/access_as_user"`.
|
|
46
46
|
3. `src/lib/schemas/<name>.ts`: Zod input schemas and response models.
|
|
47
47
|
4. `src/server/actions/<name>.ts`: one server function per endpoint, gated with `authMiddleware`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- `sendEmail({ data: EmailSchema })` → `void` // server-only, call inside another server function
|
|
8
8
|
- `body` // HTML string
|
|
9
|
-
- `attachments` // `appName` + `subId` used when uploading
|
|
9
|
+
- `attachments` // `appName` (the app's package.json name, under which wcz-layout stores its files) + the `subId` used when uploading them (see [file.md](file.md)); the email service attaches all files stored under that `subId`
|
|
10
10
|
|
|
11
11
|
## Schemas/Models
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ await sendEmail({
|
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// with cc and attachments (files previously uploaded with uploadFileMutationOptions({
|
|
43
|
+
// with cc and attachments (files previously uploaded with uploadFileMutationOptions({ subId, file }))
|
|
44
44
|
await sendEmail({
|
|
45
45
|
data: {
|
|
46
46
|
subject: "Document Submission",
|