wcz-layout 10.2.1 → 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-B0MBrI-Y.mjs +2394 -0
- package/dist/ChatLayout-B0MBrI-Y.mjs.map +1 -0
- package/dist/{Employee-C8xIlBxY.d.mts → ExtractFile-BQUXpuBS.d.mts} +44 -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-Ad784Dps.d.mts +24 -0
- package/dist/{Approval-D1TfISUL.mjs → Translate-C43AmXYW.mjs} +44 -36
- package/dist/Translate-C43AmXYW.mjs.map +1 -0
- package/dist/User-CvLutatT.d.mts +10 -0
- package/dist/ai.d.mts +31 -4
- package/dist/ai.mjs +154 -10
- package/dist/ai.mjs.map +1 -1
- package/dist/auth.d.mts +7 -14
- package/dist/auth.mjs +15 -38
- package/dist/auth.mjs.map +1 -1
- package/dist/authMiddleware-ANa9Tlmp.mjs +45 -0
- 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 +876 -916
- package/dist/components.mjs.map +1 -1
- package/dist/data/client.d.mts +313 -55
- package/dist/data/client.mjs +10 -5
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +19 -3
- 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/generatedChart-k7NEdi5Z.mjs.map +1 -1
- package/dist/hooks.d.mts +13 -93
- package/dist/hooks.mjs +353 -1059
- 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 +630 -680
- 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 -46
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +35 -43
- 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-DQx1BanQ.mjs +120 -0
- package/dist/user-DQx1BanQ.mjs.map +1 -0
- package/dist/{utils-CNYCSgip.d.mts → utils-BnyAEKW7.d.mts} +7 -9
- package/dist/utils-H4BskGF8.mjs +132 -0
- 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 +23 -29
- package/skills/ai/SKILL.md +105 -75
- package/skills/general/SKILL.md +15 -8
- package/skills/general/references/auth.md +15 -17
- 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 +41 -7
- package/skills/services/docs/email.md +2 -2
- package/skills/services/docs/file.md +100 -85
- package/skills/services/docs/layout.md +129 -0
- package/skills/start/steps/02-project-name-setup.md +1 -1
- package/skills/start/steps/03-apm-setup.md +8 -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/Approval-D1TfISUL.mjs.map +0 -1
- package/dist/ChatLayout-BpRj5rlH.mjs +0 -1639
- package/dist/ChatLayout-BpRj5rlH.mjs.map +0 -1
- package/dist/DialogsContext-D23fJjYR.mjs +0 -6
- package/dist/DialogsContext-D23fJjYR.mjs.map +0 -1
- package/dist/Email-Dz5k0UWE.d.mts +0 -15
- 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/User-aJksXItw.d.mts +0 -12
- package/dist/approval-B3ZQn9aH.mjs +0 -83
- package/dist/approval-B3ZQn9aH.mjs.map +0 -1
- package/dist/createApi-BXjkj4fM.mjs +0 -25
- package/dist/createApi-BXjkj4fM.mjs.map +0 -1
- package/dist/env-BwFl7nWc.mjs +0 -48
- package/dist/env-BwFl7nWc.mjs.map +0 -1
- package/dist/file-BQ-Bu2g8.mjs +0 -150
- package/dist/file-BQ-Bu2g8.mjs.map +0 -1
- package/dist/file-DZ0KYhoB.mjs +0 -151
- package/dist/file-DZ0KYhoB.mjs.map +0 -1
- package/dist/peoplesoft-C-zPdRVj.d.mts +0 -161
- package/dist/peoplesoft-CvwdApCK.mjs +0 -125
- package/dist/peoplesoft-CvwdApCK.mjs.map +0 -1
- package/dist/providers-BfFg_3eo.mjs +0 -56
- package/dist/providers-BfFg_3eo.mjs.map +0 -1
- package/dist/session-B_jK90RC.mjs +0 -23
- package/dist/session-B_jK90RC.mjs.map +0 -1
- package/dist/tokens-CkWpu7Qp.mjs +0 -150
- package/dist/tokens-CkWpu7Qp.mjs.map +0 -1
- package/dist/utils-DJx-7b4M.mjs +0 -244
- package/dist/utils-DJx-7b4M.mjs.map +0 -1
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: services
|
|
3
|
-
description: "Use when a feature needs a built-in wcz-layout backend service: file upload, download, thumbnails; approval requests, approvers and flows; PeopleSoft employee, manager, department lookups; or
|
|
3
|
+
description: "Use when a feature needs a built-in wcz-layout backend service: file upload, download, thumbnails; approval requests, approvers and flows; PeopleSoft employee, manager, department lookups; sending email; or AI features: translating text into several languages with language detection, and extracting fields from an uploaded PDF or image. Also when an app calls another downstream REST API that wcz-layout has no service for."
|
|
4
4
|
metadata:
|
|
5
5
|
type: integration
|
|
6
6
|
library: wcz-layout
|
|
@@ -26,9 +26,43 @@ You can read about each service in the links below. Services are categorized as
|
|
|
26
26
|
|
|
27
27
|
## Services
|
|
28
28
|
|
|
29
|
-
| Service | File | Summary
|
|
30
|
-
| ---------- | ----------------------------------- |
|
|
31
|
-
| file | [file.md](docs/file.md) | File metadata, thumbnails, binary download/open, upload, update, delete
|
|
32
|
-
| approval | [approval.md](docs/approval.md) | Approval request lifecycle, approvers, flows, statuses, step results
|
|
33
|
-
| peoplesoft | [peoplesoft.md](docs/peoplesoft.md) | Employee, manager, department, and company general manager lookups
|
|
34
|
-
| email | [email.md](docs/email.md) | Server-only email sending with optional file attachment references
|
|
29
|
+
| Service | File | Summary |
|
|
30
|
+
| ---------- | ----------------------------------- | ------------------------------------------------------------------------ |
|
|
31
|
+
| file | [file.md](docs/file.md) | File metadata, thumbnails, binary download/open, upload, update, delete |
|
|
32
|
+
| approval | [approval.md](docs/approval.md) | Approval request lifecycle, approvers, flows, statuses, step results |
|
|
33
|
+
| peoplesoft | [peoplesoft.md](docs/peoplesoft.md) | Employee, manager, department, and company general manager lookups |
|
|
34
|
+
| email | [email.md](docs/email.md) | Server-only email sending with optional file attachment references |
|
|
35
|
+
| layout | [layout.md](docs/layout.md) | Layout app AI: translation with language detection, file data extraction |
|
|
36
|
+
|
|
37
|
+
## Custom API
|
|
38
|
+
|
|
39
|
+
When the app needs a downstream REST API that no service above covers, build the client with
|
|
40
|
+
`createApi` from `wcz-layout/data/server`. It resolves the base URL from env, attaches the
|
|
41
|
+
signed-in user's token for the scope and turns error responses into `Error(message)`. It is
|
|
42
|
+
server-only: call it inside a server function handler, never at module scope.
|
|
43
|
+
|
|
44
|
+
1. `src/env.ts`: add `MY_API_BASE_URL: z.url()` to `server` (`createApi` takes only `z.url()` variables).
|
|
45
|
+
2. `src/lib/auth/scopes.ts`: add `myApi: "api://wistron.com/my-api/access_as_user"`.
|
|
46
|
+
3. `src/lib/schemas/<name>.ts`: Zod input schemas and response models.
|
|
47
|
+
4. `src/server/actions/<name>.ts`: one server function per endpoint, gated with `authMiddleware`
|
|
48
|
+
(the token belongs to the signed-in user); see **server-functions**.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
52
|
+
import { createApi } from "wcz-layout/data/server";
|
|
53
|
+
import { authMiddleware } from "wcz-layout/middleware";
|
|
54
|
+
import { MyModelSchema, type MyModel } from "~/lib/schemas/inventory";
|
|
55
|
+
|
|
56
|
+
const myApi = () => createApi({ baseURL: "MY_API_BASE_URL", scopeKey: "myApi" });
|
|
57
|
+
|
|
58
|
+
export const getItem = createServerFn({ method: "GET" })
|
|
59
|
+
.validator(MyModelSchema)
|
|
60
|
+
.middleware([authMiddleware()])
|
|
61
|
+
.handler(async ({ data }) => {
|
|
62
|
+
const api = await myApi();
|
|
63
|
+
const { data: item } = await api.get<MyModel>(`/items/${encodeURIComponent(data.id)}`);
|
|
64
|
+
return item;
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Wrap reads in `queryOptions` and writes in `mutationOptions`, the same shape as the built-in client exports.
|
|
@@ -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",
|
|
@@ -1,43 +1,60 @@
|
|
|
1
1
|
# file
|
|
2
2
|
|
|
3
|
+
Files live in the WCZ file service, under the app's `package.json` name (set automatically; never
|
|
4
|
+
passed). App servers call it with the signed-in user's Entra token, or with the app token when
|
|
5
|
+
nobody is signed in (public routes, jobs). Browsers use the URLs it returns (`<img src>`,
|
|
6
|
+
`<a href>`, `window.open`) and upload straight to it. No token ever reaches the browser: every URL
|
|
7
|
+
is signed for one file, for 2-3 hours, unless the file is `public`.
|
|
8
|
+
|
|
3
9
|
## Client
|
|
4
10
|
|
|
5
11
|
`import { ... } from "wcz-layout/data/client";`
|
|
6
12
|
|
|
7
|
-
- Query:
|
|
8
|
-
`fileMetasQueryOptions(
|
|
9
|
-
`
|
|
10
|
-
`fileQueryOptions(FileSchema)` → `string` // file content as object URL for preview, disabled while `id` is empty
|
|
13
|
+
- Query (refreshed hourly so their URLs never expire; read URLs from the query, never store them):
|
|
14
|
+
`fileMetasQueryOptions({ subId })` → `FileMeta[]` // files under `subId` the caller can read
|
|
15
|
+
`fileMetaQueryOptions({ id })` → `FileMeta` // one file, disabled while `id` is empty
|
|
11
16
|
- Mutation:
|
|
12
|
-
`
|
|
13
|
-
`
|
|
14
|
-
`
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
`uploadFileMutationOptions({ queryClient })` → `mutate({ subId, file, id?, public?, permissions?, setProgress?, signal? })` → `FileMeta` // 1 MiB chunks straight to the file service; retries network failures for ~2 min and resumes; `setProgress(percent)`; `signal` cancels; the type comes from the extension; invalidates metas of `subId`
|
|
18
|
+
`updateFileMetaMutationOptions({ queryClient })` → `mutate(UpdateFileMetaSchema)` → `FileMeta` // rename (base name), move to another `subId`, change `public` / `permissions`; needs write
|
|
19
|
+
`deleteFileMutationOptions({ queryClient })` → `mutate({ id })` // needs write
|
|
20
|
+
`batchDeleteFilesMutationOptions({ queryClient })` → `mutate({ subId })` // every file under `subId`, or none when the caller can't delete one of them
|
|
21
|
+
|
|
22
|
+
Open, show and download with the URLs: `window.open(meta.urls.view)` (Office files open as PDF,
|
|
23
|
+
types the browser can't show download), `<img src={meta.urls.thumbnail}>` (default icon for
|
|
24
|
+
non-images), `<a href={meta.urls.download}>` (always the original, as an attachment).
|
|
18
25
|
|
|
19
26
|
## Server
|
|
20
27
|
|
|
21
28
|
`import { ... } from "wcz-layout/data/server";`
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
`getFileMetas`, `getFileMeta`, `updateFileMeta`, `deleteFile`, `batchDeleteFiles` take
|
|
31
|
+
`{ data }` like the client ones.
|
|
32
|
+
`uploadFile({ data: UploadFileSchema })` → `FileMeta` // server-originated files, e.g. a generated report
|
|
33
|
+
File bytes on the server: `fetch(meta.urls.download)`.
|
|
34
|
+
|
|
35
|
+
## Permissions
|
|
36
|
+
|
|
37
|
+
`public` and `permissions` decide access; omitted, everyone the app serves reads and changes the
|
|
38
|
+
file: every employee, and anonymous visitors of a public route.
|
|
39
|
+
|
|
40
|
+
- `public: true` — anyone reads it without signing in (stable, unsigned URLs). Never grants write.
|
|
41
|
+
- `permissions: { read, write }` — both required when sent. Each is `null` (no restriction:
|
|
42
|
+
read = everyone, write = whoever can read) or a non-empty list of
|
|
43
|
+
`{ group: "<sAMAccountName>" }` / `{ employeeId: "<id>" }`. Write implies read.
|
|
44
|
+
- Anonymous visitors (the app token) have no groups and no employee ID: they reach only files
|
|
45
|
+
without a list, so restrict `write` (e.g. to an admin group) to keep them from changing or
|
|
46
|
+
deleting files, and `read` to hide files from them.
|
|
47
|
+
- A group must reach the File API token: with "Groups assigned to the application" it has to be
|
|
48
|
+
assigned to the File API registration. Employee entries have no such limit.
|
|
49
|
+
- `meta.canWrite` tells whether the caller may rename or delete it; hide those actions otherwise.
|
|
33
50
|
|
|
34
51
|
## Components
|
|
35
52
|
|
|
36
53
|
`import { Dropzone, FileViewer } from "wcz-layout/components";`
|
|
37
54
|
|
|
38
55
|
- `<Dropzone onDrop progress? sx? {...DropzoneOptions} />` // react-dropzone area (`accept`, `maxFiles`, `disabled`, `onDropAccepted`, …), `progress` (0-100) shows upload progress
|
|
39
|
-
- `<FileViewer
|
|
40
|
-
- `actions?: { download?: boolean, delete?: boolean }` // both enabled by default
|
|
56
|
+
- `<FileViewer subId actions? onDelete?>{(component) => <component.Grid /> | <component.List />}</FileViewer>` // fetches metas itself, renders nothing when there are no files; thumbnails load lazily, and hovering a file (up to 20 MB) prefetches it so it opens instantly
|
|
57
|
+
- `actions?: { download?: boolean, delete?: boolean }` // both enabled by default; delete shows only where `canWrite`
|
|
41
58
|
- `onDelete?: ({ remainingFileMetas: FileMeta[], deletedFileMeta: FileMeta }) => void`
|
|
42
59
|
- `component.Grid` props: `size?: number` (default 150), `itemBar?: "hidden" | "always" | "onMouseEnter"` (default on hover), `sx?`
|
|
43
60
|
- `component.List` props: `sx?`
|
|
@@ -45,81 +62,83 @@
|
|
|
45
62
|
## Schemas/Models
|
|
46
63
|
|
|
47
64
|
```ts
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
mediaSubType: z.string().trim().min(1).max(255),
|
|
56
|
-
mediaType: z.string().trim().min(1).max(255),
|
|
57
|
-
mimeType: z.string().trim().min(1).max(255),
|
|
58
|
-
createdBy: z.string().trim().min(1).max(255),
|
|
59
|
-
createdDate: z.date(),
|
|
65
|
+
const FilePrincipalSchema = z.union([
|
|
66
|
+
z.strictObject({ group: z.string().trim().min(1) }),
|
|
67
|
+
z.strictObject({ employeeId: z.string().trim().min(1) }),
|
|
68
|
+
]);
|
|
69
|
+
const FilePermissionsSchema = z.object({
|
|
70
|
+
read: z.array(FilePrincipalSchema).min(1).nullable(),
|
|
71
|
+
write: z.array(FilePrincipalSchema).min(1).nullable(),
|
|
60
72
|
});
|
|
61
73
|
|
|
62
|
-
const
|
|
63
|
-
appName: z.string().min(1).max(255),
|
|
64
|
-
subId: z.uuid(),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const FileSchema = z.object({
|
|
68
|
-
appName: z.string().min(1).max(255),
|
|
74
|
+
const FileMetaSchema = z.object({
|
|
69
75
|
id: z.uuid(),
|
|
76
|
+
appName: z.string(),
|
|
77
|
+
subId: z.string(),
|
|
78
|
+
fileName: z.string(), // without the extension
|
|
79
|
+
fileExtension: z.string(),
|
|
80
|
+
fileSize: z.number(),
|
|
81
|
+
mimeType: z.string(), // from the extension
|
|
82
|
+
mediaType: z.string(), // "image", "video", "application", …
|
|
83
|
+
mediaSubType: z.string(),
|
|
84
|
+
public: z.boolean(),
|
|
85
|
+
permissions: FilePermissionsSchema,
|
|
86
|
+
canWrite: z.boolean(),
|
|
87
|
+
urls: z.object({
|
|
88
|
+
view: z.url(),
|
|
89
|
+
download: z.url(),
|
|
90
|
+
thumbnail: z.url(),
|
|
91
|
+
install: z.string().optional(), // .ipa only: itms-services:// install link
|
|
92
|
+
}),
|
|
70
93
|
});
|
|
71
94
|
|
|
72
|
-
const
|
|
73
|
-
|
|
95
|
+
const GetFileMetasSchema = z.object({ subId: z.string().min(1).max(255) });
|
|
96
|
+
const FileSchema = z.object({ id: z.uuid() });
|
|
97
|
+
const UpdateFileMetaSchema = FileSchema.extend({
|
|
98
|
+
fileName: z.string().trim().min(1).max(255).optional(),
|
|
99
|
+
subId: z.string().min(1).max(255).optional(),
|
|
100
|
+
public: z.boolean().optional(),
|
|
101
|
+
permissions: FilePermissionsSchema.optional(),
|
|
74
102
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
appName: z.string().min(1).max(255),
|
|
79
|
-
subId: z.uuid(),
|
|
103
|
+
const UploadFileSchema = z.object({
|
|
104
|
+
id: z.uuidv7().default(uuidv7),
|
|
105
|
+
subId: z.string().min(1).max(255),
|
|
80
106
|
file: z.instanceof(File),
|
|
107
|
+
public: z.boolean().optional(),
|
|
108
|
+
permissions: FilePermissionsSchema.optional(),
|
|
81
109
|
});
|
|
82
110
|
```
|
|
83
111
|
|
|
84
112
|
## Examples
|
|
85
113
|
|
|
86
114
|
```tsx
|
|
87
|
-
import {
|
|
115
|
+
import { useState } from "react";
|
|
88
116
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
89
117
|
import {
|
|
90
118
|
deleteFileMutationOptions,
|
|
91
|
-
downloadFileMutationOptions,
|
|
92
119
|
fileMetasQueryOptions,
|
|
93
|
-
fileQueryOptions,
|
|
94
|
-
openFileMutationOptions,
|
|
95
120
|
uploadFileMutationOptions,
|
|
96
121
|
} from "wcz-layout/data/client";
|
|
97
122
|
import { Dropzone, FileViewer } from "wcz-layout/components";
|
|
98
|
-
import { useInView } from "wcz-layout/hooks";
|
|
99
|
-
|
|
100
|
-
const { queryClient } = Route.useRouteContext();
|
|
101
123
|
|
|
102
|
-
|
|
103
|
-
const { ref, inView } = useInView({ triggerOnce: true });
|
|
124
|
+
const { queryClient, user } = Route.useRouteContext();
|
|
104
125
|
|
|
105
|
-
|
|
106
|
-
...fileMetasQueryOptions({ appName: packageJson.name, subId }),
|
|
107
|
-
enabled: inView,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const { data: file } = useQuery({
|
|
111
|
-
...fileQueryOptions({ appName: packageJson.name, id: fileMetas[0]?.id ?? "" }),
|
|
112
|
-
enabled: !!fileMetas[0],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// upload via Dropzone
|
|
126
|
+
// upload via Dropzone; only the uploader and HR may read, only HR may change
|
|
116
127
|
const [progress, setProgress] = useState(0);
|
|
117
128
|
const { mutateAsync: uploadFile } = useMutation(uploadFileMutationOptions({ queryClient }));
|
|
118
129
|
|
|
119
130
|
const onDrop = async (acceptedFiles: File[]) => {
|
|
120
131
|
await Promise.allSettled(
|
|
121
132
|
acceptedFiles.map((file) =>
|
|
122
|
-
uploadFile({
|
|
133
|
+
uploadFile({
|
|
134
|
+
subId,
|
|
135
|
+
file,
|
|
136
|
+
setProgress,
|
|
137
|
+
permissions: {
|
|
138
|
+
read: [{ employeeId: user.employeeId }, { group: "hr" }],
|
|
139
|
+
write: [{ group: "hr" }],
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
123
142
|
),
|
|
124
143
|
);
|
|
125
144
|
setProgress(0);
|
|
@@ -127,24 +146,20 @@ const onDrop = async (acceptedFiles: File[]) => {
|
|
|
127
146
|
|
|
128
147
|
<Dropzone onDrop={onDrop} progress={progress} />;
|
|
129
148
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
const { mutate: remove } = useMutation(deleteFileMutationOptions({ queryClient }));
|
|
149
|
+
// public route (no requireAuth): anonymous visitors add photos only admins may delete
|
|
150
|
+
uploadFile({ subId, file, permissions: { read: null, write: [{ group: "canteen-admins" }] } });
|
|
133
151
|
|
|
134
|
-
download
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
fileName: meta.fileName,
|
|
138
|
-
fileExtension: meta.fileExtension,
|
|
139
|
-
});
|
|
140
|
-
remove({ appName: packageJson.name, id: meta.id });
|
|
152
|
+
// own list: open, show, download, delete
|
|
153
|
+
const { data: fileMetas = [] } = useQuery(fileMetasQueryOptions({ subId }));
|
|
154
|
+
const { mutate: remove } = useMutation(deleteFileMutationOptions({ queryClient }));
|
|
141
155
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
<img src={meta.urls.thumbnail} alt="" loading="lazy" />;
|
|
157
|
+
<Button onClick={() => window.open(meta.urls.view, "_blank", "noopener")}>Open</Button>;
|
|
158
|
+
<Button href={meta.urls.download}>Download</Button>;
|
|
159
|
+
{
|
|
160
|
+
meta.canWrite && <Button onClick={() => remove({ id: meta.id })}>Delete</Button>;
|
|
161
|
+
}
|
|
145
162
|
|
|
146
163
|
// File Viewer - no manual fetch of metas needed
|
|
147
|
-
<FileViewer
|
|
148
|
-
{(component) => <component.Grid />} // or component.List
|
|
149
|
-
</FileViewer>;
|
|
164
|
+
<FileViewer subId={subId}>{(component) => <component.Grid />} // or component.List</FileViewer>;
|
|
150
165
|
```
|