wcz-layout 9.7.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +786 -139
- 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 +702 -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-BWcNzq55.mjs → file-CZwQfvTU.mjs} +5 -24
- package/dist/file-CZwQfvTU.mjs.map +1 -0
- package/dist/{file-DimNsRly.mjs → file-aSQto2rw.mjs} +6 -7
- 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 +28 -9
- package/dist/index.mjs +1248 -500
- 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-CskGsqd6.d.mts → peoplesoft-BY_75WTS.d.mts} +2 -2
- package/dist/{peoplesoft-DTPGpN2h.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 +23 -23
- 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 +56 -25
- package/skills/general/references/exports.md +106 -0
- package/skills/migrations/SKILL.md +53 -2
- 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 +7 -4
- package/skills/services/docs/approval.md +2 -2
- package/skills/services/docs/peoplesoft.md +1 -1
- package/skills/start/SKILL.md +9 -5
- package/skills/start/steps/05-database-setup.md +52 -52
- package/skills/start/steps/06-entra-setup.md +1 -1
- package/skills/start/steps/07-vault-setup.md +5 -12
- 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-BWcNzq55.mjs.map +0 -1
- package/dist/file-DimNsRly.mjs.map +0 -1
- package/dist/msalServer-DLwA7_ta.mjs +0 -30
- package/dist/msalServer-DLwA7_ta.mjs.map +0 -1
- package/dist/peoplesoft-DTPGpN2h.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/migrations/versions/migrate-v9-to-v10.tsx +0 -9
package/skills/routing/SKILL.md
CHANGED
|
@@ -1,39 +1,62 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: routing
|
|
3
|
-
description: "Use when
|
|
3
|
+
description: "Use when adding or changing a page, route file, navigation entry, search params, or route-level access control. Covers createFileRoute, beforeLoad requireAuth, loader preloads, validateSearch, useSearch, src/routes/ naming and colocation, __root.tsx navigation, the auth and login routes, and the RouterLink/RouterButton link components."
|
|
4
|
+
metadata:
|
|
5
|
+
type: convention
|
|
6
|
+
library: wcz-layout
|
|
4
7
|
---
|
|
5
8
|
|
|
6
|
-
> Mechanics (
|
|
9
|
+
> Mechanics (route definitions, loaders, context, guards, navigation, search params,
|
|
10
|
+
> route-tree fundamentals) are covered by TanStack's own skills. List the skills shipped by
|
|
11
|
+
> `@tanstack/router-core` and `@tanstack/react-router` and load whichever cover the task at
|
|
12
|
+
> hand. This skill adds the wcz-layout conventions.
|
|
7
13
|
|
|
8
14
|
## Rules
|
|
9
15
|
|
|
10
|
-
- Include
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- Route
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
16
|
+
- Include `requireAuth(<permissionKey>)` in the route's `beforeLoad` to enforce access
|
|
17
|
+
control — pass a key defined in your app's `src/lib/auth/permissions.ts`. Use bare
|
|
18
|
+
`requireAuth()` when any signed-in user may enter, and omit it entirely only for
|
|
19
|
+
intentionally public routes.
|
|
20
|
+
- Route-level `requireAuth` only hides the UI. Every server function or server route that
|
|
21
|
+
accesses protected data still needs `authMiddleware`; see the `server-functions` skill.
|
|
22
|
+
- Use `Route.useRouteContext()` to access the authenticated user. `user` can be `null` if
|
|
23
|
+
the route doesn't include `requireAuth`.
|
|
24
|
+
- Preload the route's live queries in the loader and return the promise:
|
|
25
|
+
`loader: ({ context }) => context.dbClient.preloadLiveQuery(<x>QueryOptions)`.
|
|
26
|
+
- Literal URL segments and feature folders use kebab-case. Entity feature names are plural;
|
|
27
|
+
TanStack special route tokens retain their required syntax.
|
|
28
|
+
- If a feature contains only one route, create a single file route: `src/routes/<feature>s.tsx`
|
|
29
|
+
- If a feature contains multiple related routes, create a folder: `src/routes/<feature>s/index.tsx`
|
|
30
|
+
- Colocate route-specific components/hooks inside `routes/<feature>s/-components` or `-hooks`.
|
|
31
|
+
- When a route needs its own components/hooks that no sibling route uses, wrap it in a route
|
|
32
|
+
group folder named after the route and colocate them there: `routes/<feature>s/(index)/index.tsx` with `(index)/-components` and `(index)/-hooks`.
|
|
18
33
|
- Root-level `components/` and `hooks/` are only for code shared across multiple routes.
|
|
19
|
-
- After creating a new route, add
|
|
20
|
-
-
|
|
34
|
+
- After creating a new route, add a navigation item with a unique icon from
|
|
35
|
+
`@mui/icons-material` in `src/routes/__root.tsx`.
|
|
36
|
+
- For user-clickable in-app navigation, use the type-safe router components from
|
|
37
|
+
`wcz-layout/components` (`RouterButton`, `RouterIconButton`, `RouterLink`, `RouterFab`,
|
|
38
|
+
`RouterTab`, `RouterListItemButton`) rather than raw MUI with a manual `href` — they wrap
|
|
39
|
+
`createLink`, so `to`/`params`/`search` are type-checked.
|
|
21
40
|
|
|
22
41
|
## Examples
|
|
23
42
|
|
|
24
43
|
```ts
|
|
25
44
|
// imports
|
|
45
|
+
import AccountTree from "@mui/icons-material/AccountTree";
|
|
46
|
+
import Code from "@mui/icons-material/Code";
|
|
47
|
+
import Home from "@mui/icons-material/Home";
|
|
48
|
+
import Widgets from "@mui/icons-material/Widgets";
|
|
49
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
50
|
+
import { z } from "zod";
|
|
51
|
+
import type { Navigation } from "wcz-layout";
|
|
26
52
|
import { useDialogs, useTranslation } from "wcz-layout/hooks";
|
|
27
|
-
import {
|
|
53
|
+
import { hasPermission, requireAuth } from "wcz-layout/utils";
|
|
28
54
|
|
|
29
|
-
// src/routes/
|
|
30
|
-
export const Route = createFileRoute("/
|
|
55
|
+
// src/routes/<feature>s/index.tsx
|
|
56
|
+
export const Route = createFileRoute("/<feature>s/")({
|
|
31
57
|
component: RouteComponent,
|
|
32
|
-
beforeLoad:
|
|
33
|
-
|
|
34
|
-
loader: () => {
|
|
35
|
-
featureCollection.preload();
|
|
36
|
-
},
|
|
58
|
+
beforeLoad: requireAuth("admin"),
|
|
59
|
+
loader: ({ context }) => context.dbClient.preloadLiveQuery(featuresQueryOptions),
|
|
37
60
|
});
|
|
38
61
|
|
|
39
62
|
function RouteComponent() {
|
|
@@ -43,52 +66,19 @@ function RouteComponent() {
|
|
|
43
66
|
// route component code...
|
|
44
67
|
}
|
|
45
68
|
|
|
46
|
-
// __root.tsx
|
|
47
|
-
import { hasPermission } from "wcz-layout/utils";
|
|
48
|
-
|
|
49
|
-
const { user } = Route.useRouteContext();
|
|
50
|
-
|
|
69
|
+
// __root.tsx navigation
|
|
51
70
|
const navigation: Navigation = [
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
to: "/",
|
|
55
|
-
title: "Home",
|
|
56
|
-
icon: <Home />,
|
|
57
|
-
hidden: !hasPermission(user, "all"),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
kind: "header",
|
|
61
|
-
title: "Documentation",
|
|
62
|
-
},
|
|
71
|
+
{ kind: "item", to: "/", title: t("Home"), icon: <Home />, hidden: !hasPermission(user, "admin") },
|
|
72
|
+
{ kind: "header", title: t("Documentation") },
|
|
63
73
|
{
|
|
64
74
|
kind: "group",
|
|
65
|
-
title: "Components",
|
|
75
|
+
title: t("Components"),
|
|
66
76
|
icon: <Widgets />,
|
|
67
77
|
children: [
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
title: "Navigation",
|
|
72
|
-
icon: <AccountTree />,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
kind: "divider",
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
kind: "item",
|
|
79
|
-
to: "/components/forms",
|
|
80
|
-
title: "Forms",
|
|
81
|
-
icon: <Code />,
|
|
82
|
-
},
|
|
78
|
+
{ kind: "item", to: "/components/navigation", title: t("Navigation"), icon: <AccountTree /> },
|
|
79
|
+
{ kind: "divider" },
|
|
80
|
+
{ kind: "item", to: "/components/forms", title: t("Forms"), icon: <Code /> },
|
|
83
81
|
],
|
|
84
82
|
},
|
|
85
83
|
];
|
|
86
|
-
|
|
87
|
-
// Routes are public unless guarded. By convention, protect every route by adding
|
|
88
|
-
// requirePermission to its beforeLoad (omit only for intentionally public routes) —
|
|
89
|
-
// it redirects to login when signed out, then checks the permission group.
|
|
90
|
-
export const Route = createFileRoute("/feature-name")({
|
|
91
|
-
component: RouteComponent,
|
|
92
|
-
beforeLoad: requirePermission("admin"),
|
|
93
|
-
});
|
|
94
84
|
```
|
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: server-functions
|
|
3
|
-
description: "Use when
|
|
3
|
+
description: "Use when adding or changing server functions, REST/API routes, background-job endpoints, or server-side data access."
|
|
4
|
+
metadata:
|
|
5
|
+
type: convention
|
|
6
|
+
library: wcz-layout
|
|
4
7
|
---
|
|
5
8
|
|
|
6
|
-
> Mechanics (`createServerFn`, `.validator`, `createMiddleware`, `createHandlers`) are covered by TanStack's own skills
|
|
9
|
+
> Mechanics (`createServerFn`, `.validator`, `createMiddleware`, `createHandlers`) are covered by TanStack's own skills. List the skills shipped by `@tanstack/start-client-core` and `@tanstack/react-start` and load whichever cover the task at hand. This skill adds only the wcz-layout middleware conventions on top.
|
|
7
10
|
|
|
8
11
|
## Rules
|
|
9
12
|
|
|
10
13
|
- Before generating code, clarify whether the feature should be exposed as public REST API routes or implemented as internal TanStack Start server functions (recommended), and what permission should be required for access.
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
14
|
+
- Include `authMiddleware` in every server function by default — server functions are callable RPC endpoints, so a route-level `requireAuth` in `beforeLoad` only hides the UI and does not protect them. Omit it only for server functions backing intentionally public routes.
|
|
15
|
+
- Order inside a middleware **array** matters, because the array runs in order and the later entry wins the merged context type. Always `databaseMiddleware()` → `authMiddleware(<permissionKey>)` → `validationMiddleware(<schema>)`. `databaseMiddleware` declares `userMiddleware` and so contributes `user: User | null`; putting it first lets `authMiddleware` narrow `context.user` to `User` for the handler. `authMiddleware` still comes before `validationMiddleware` — otherwise an unauthenticated caller gets their body parsed and gets your validation errors back.
|
|
16
|
+
- The builder itself accepts its links in any order. Write them as `.validator()` → `.middleware()` → `.handler()` to match the reference app. Middleware always runs before the handler regardless of where it appears.
|
|
17
|
+
- `validationMiddleware` is for REST API routes only. Server functions use `.validator()`.
|
|
18
|
+
- `databaseMiddleware` is **app-local**, not a wcz-layout export. Every app writes it once (see below). It owns the transaction, so never open another one in a handler.
|
|
16
19
|
- Reuse schemas from `src/lib/schemas/`.
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
## File Placement
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
src/server/actions/ — server functions
|
|
23
|
-
src/routes/api/ — REST API routes
|
|
24
|
-
src/server/middleware/ — databaseMiddleware
|
|
25
|
-
wcz-layout/middleware/ — authorizationMiddleware, validationMiddleware
|
|
26
|
-
src/server/db/schemas/ — tables, enums, relations
|
|
27
|
-
src/lib/schemas/ — Zod schemas (shared between client and server)
|
|
28
|
-
src/lib/auth/permissions.ts — permission keys
|
|
29
|
-
```
|
|
20
|
+
- Everything under `src/server/**` is server-only, but Start's import protection only guards `**/*.server.*` filenames. Never import from `src/server/` in a component or route file. Import the server function, not what it uses.
|
|
21
|
+
- Background jobs are API routes using only `databaseMiddleware()` + `authMiddleware()` — cron runs in Kubernetes and authenticates via app token.
|
|
30
22
|
|
|
31
23
|
## Examples
|
|
32
24
|
|
|
33
25
|
```ts
|
|
34
|
-
// src/server/actions/<
|
|
26
|
+
// src/server/actions/<table>.ts
|
|
27
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
28
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
29
|
+
import { eq } from "drizzle-orm";
|
|
30
|
+
import { authMiddleware, validationMiddleware } from "wcz-layout/middleware";
|
|
31
|
+
import z from "zod";
|
|
32
|
+
import { FeatureSchema } from "~/lib/schemas/feature";
|
|
33
|
+
import { featureTable } from "../db/schemas/feature";
|
|
34
|
+
import { databaseMiddleware } from "../middleware/databaseMiddleware";
|
|
35
|
+
|
|
35
36
|
export const selectFeatures = createServerFn()
|
|
36
|
-
.middleware([
|
|
37
|
-
.handler(
|
|
38
|
-
return
|
|
37
|
+
.middleware([databaseMiddleware(), authMiddleware()])
|
|
38
|
+
.handler(({ context }) => {
|
|
39
|
+
return context.db.select().from(featureTable);
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export const insertFeature = createServerFn({ method: "POST" })
|
|
42
|
-
.middleware([authorizationMiddleware("admin"), databaseMiddleware()])
|
|
43
43
|
.validator(FeatureSchema)
|
|
44
|
+
.middleware([databaseMiddleware(), authMiddleware("admin")])
|
|
44
45
|
.handler(async ({ data, context }) => {
|
|
45
46
|
await context.db.insert(featureTable).values(data);
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
export const updateFeature = createServerFn({ method: "POST" })
|
|
49
|
-
.middleware([authorizationMiddleware("admin"), databaseMiddleware()])
|
|
50
50
|
.validator(FeatureSchema)
|
|
51
|
+
.middleware([databaseMiddleware(), authMiddleware("admin")])
|
|
51
52
|
.handler(async ({ data, context }) => {
|
|
52
53
|
await context.db.update(featureTable).set(data).where(eq(featureTable.id, data.id));
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
export const deleteFeature = createServerFn({ method: "POST" })
|
|
56
|
-
.
|
|
57
|
-
.
|
|
57
|
+
.validator(z.uuid())
|
|
58
|
+
.middleware([databaseMiddleware(), authMiddleware("admin")])
|
|
58
59
|
.handler(async ({ data, context }) => {
|
|
59
|
-
await context.db.delete(featureTable).where(eq(featureTable.id, data
|
|
60
|
+
await context.db.delete(featureTable).where(eq(featureTable.id, data));
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
// src/routes/api/<feature>s/index.ts
|
|
63
64
|
export const Route = createFileRoute("/api/features/")({
|
|
64
65
|
server: {
|
|
65
|
-
middleware: [databaseMiddleware()],
|
|
66
66
|
handlers: ({ createHandlers }) =>
|
|
67
67
|
createHandlers({
|
|
68
68
|
GET: {
|
|
69
|
-
middleware: [
|
|
69
|
+
middleware: [databaseMiddleware(), authMiddleware()],
|
|
70
70
|
handler: async ({ context }) => {
|
|
71
71
|
const items = await context.db.select().from(featureTable);
|
|
72
72
|
return Response.json(items);
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
75
|
POST: {
|
|
76
|
-
middleware: [
|
|
76
|
+
middleware: [
|
|
77
|
+
databaseMiddleware(),
|
|
78
|
+
authMiddleware("admin"),
|
|
79
|
+
validationMiddleware(FeatureSchema),
|
|
80
|
+
],
|
|
77
81
|
handler: async ({ context }) => {
|
|
78
82
|
const [response] = await context.db
|
|
79
83
|
.insert(featureTable)
|
|
@@ -85,28 +89,4 @@ export const Route = createFileRoute("/api/features/")({
|
|
|
85
89
|
}),
|
|
86
90
|
},
|
|
87
91
|
});
|
|
88
|
-
|
|
89
|
-
// src/routes/api/<feature>s/$id.ts
|
|
90
|
-
export const Route = createFileRoute("/api/features/$id")({
|
|
91
|
-
server: {
|
|
92
|
-
middleware: [authorizationMiddleware("admin"), databaseMiddleware()],
|
|
93
|
-
handlers: ({ createHandlers }) =>
|
|
94
|
-
createHandlers({
|
|
95
|
-
PUT: {
|
|
96
|
-
middleware: [validationMiddleware(FeatureSchema)],
|
|
97
|
-
handler: async ({ params, context }) => {
|
|
98
|
-
await context.db
|
|
99
|
-
.update(featureTable)
|
|
100
|
-
.set(context.data)
|
|
101
|
-
.where(eq(featureTable.id, params.id));
|
|
102
|
-
return new Response(null, { status: 204 });
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
DELETE: async ({ params, context }) => {
|
|
106
|
-
await context.db.delete(featureTable).where(eq(featureTable.id, params.id));
|
|
107
|
-
return new Response(null, { status: 204 });
|
|
108
|
-
},
|
|
109
|
-
}),
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
92
|
```
|
package/skills/services/SKILL.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: services
|
|
3
|
-
description: "Use when
|
|
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 sending email."
|
|
4
|
+
metadata:
|
|
5
|
+
type: integration
|
|
6
|
+
library: wcz-layout
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
## Info
|
|
7
10
|
|
|
8
11
|
You can read about each service in the links below. Services are categorized as either client or server exports, depending on their intended usage.
|
|
9
12
|
|
|
10
|
-
- **Client exports** —
|
|
11
|
-
- **Server exports** —
|
|
12
|
-
- Invalidating mutation
|
|
13
|
+
- **Client exports** — React Query option factories from `wcz-layout/data/client`.
|
|
14
|
+
- **Server exports** — Direct service operations from `wcz-layout/data/server`; import themonly in server code.
|
|
15
|
+
- Invalidating mutation factories take `{ queryClient }`.
|
|
13
16
|
- Access `queryClient` with `Route.useRouteContext()` in a route file, or `useRouteContext({ from: "path" })` in a component.
|
|
14
17
|
- To read about a service, open the linked file in the **File** column directly.
|
|
15
18
|
|
|
@@ -80,13 +80,13 @@ const ApprovalFlowSchema = z.object({
|
|
|
80
80
|
|
|
81
81
|
const ApprovalCoRequestorGroupSchema = z.object({
|
|
82
82
|
role: z.string().trim().min(1),
|
|
83
|
-
email: z.email()
|
|
83
|
+
email: z.email(),
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
const ApprovalCoRequestorEmployeeSchema = z.object({
|
|
87
87
|
employeeId: z.string().trim().min(1),
|
|
88
88
|
name: z.string().trim().min(1),
|
|
89
|
-
email: z.email()
|
|
89
|
+
email: z.email(),
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
const ApprovalCoRequestorPrincipalSchema = z.union([
|
|
@@ -49,7 +49,7 @@ const EmployeeSchema = z.object({
|
|
|
49
49
|
contactPhone: z.string().trim(),
|
|
50
50
|
departmentId: z.string().trim(),
|
|
51
51
|
departmentDescription: z.string().trim(),
|
|
52
|
-
emailString: z.string().trim(),
|
|
52
|
+
emailString: z.string().trim().nullable(),
|
|
53
53
|
employeeId: z.string().trim(),
|
|
54
54
|
extensionNumber: z.string().trim(),
|
|
55
55
|
firstName: z.string().trim(),
|
package/skills/start/SKILL.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: start
|
|
3
|
-
description: "Use when
|
|
3
|
+
description: "Use when bootstrapping a cloned template: git remote, project rename, APM and WiCOP registration, Postgres, Entra ID, Vault, favicon, GitLab CI, and first push."
|
|
4
|
+
metadata:
|
|
5
|
+
type: workflow
|
|
6
|
+
library: wcz-layout
|
|
7
|
+
disable-model-invocation: "true"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
|
-
# Project
|
|
10
|
+
# Project initialization
|
|
7
11
|
|
|
8
12
|
## Role
|
|
9
13
|
|
|
@@ -23,8 +27,8 @@ Begin every conversation with:
|
|
|
23
27
|
|
|
24
28
|
> To make initialization flexible, you can choose:
|
|
25
29
|
>
|
|
26
|
-
> -
|
|
27
|
-
> -
|
|
30
|
+
> - **Full initialization** for a new project
|
|
31
|
+
> - **Selected steps** from the list below
|
|
28
32
|
|
|
29
33
|
Then list all steps by name so the user can pick.
|
|
30
34
|
|
|
@@ -37,7 +41,7 @@ Then list all steps by name so the user can pick.
|
|
|
37
41
|
| 3 | [03-apm-setup.md](steps/03-apm-setup.md) | Register the app internally |
|
|
38
42
|
| 4 | [04-wicop-setup.md](steps/04-wicop-setup.md) | Request release management (CD) |
|
|
39
43
|
| 5 | [05-database-setup.md](steps/05-database-setup.md) | Postgres via Docker or existing |
|
|
40
|
-
| 6 | [06-entra-setup.md](steps/06-entra-setup.md) |
|
|
44
|
+
| 6 | [06-entra-setup.md](steps/06-entra-setup.md) | Entra ID app registration |
|
|
41
45
|
| 7 | [07-vault-setup.md](steps/07-vault-setup.md) | Vault secrets configuration |
|
|
42
46
|
| 8 | [08-generate-favicon.md](steps/08-generate-favicon.md) | Generate and replace favicon |
|
|
43
47
|
| 9 | [09-commit.md](steps/09-commit.md) | Commit and push to origin |
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
# Database Setup
|
|
2
|
-
|
|
3
|
-
> Create `.env.local` if it does not exist.
|
|
4
|
-
> The app pins `search_path` to the `DATABASE_URL` username, so a schema with that
|
|
5
|
-
> exact name must exist. `public` cannot be a username — it is a reserved role.
|
|
6
|
-
|
|
7
|
-
## User Input
|
|
8
|
-
|
|
9
|
-
Ask via **AskUserQuestion**: **"Do you already have a Postgres database created for this project?"** — options `Yes` / `No`.
|
|
10
|
-
|
|
11
|
-
## Branch A — Existing database
|
|
12
|
-
|
|
13
|
-
1. Ask: **"Please provide the database connection details"**.
|
|
14
|
-
|
|
15
|
-
Fill the host in automatically — QAS is always `10.82.36.60:5432`, PRD is always `10.82.36.50:5432`.
|
|
16
|
-
|
|
17
|
-
2. Update `.env.local`:
|
|
18
|
-
- Set `DATABASE_URL=postgres://<schema-username>:<password>@<server-address>:5432/<database-name>`.
|
|
19
|
-
|
|
20
|
-
## Branch B — No database
|
|
21
|
-
|
|
22
|
-
Ask via **AskUserQuestion**: **"Would you like me to create a local Postgres database using Docker?"** — options `Yes` / `No`.
|
|
23
|
-
|
|
24
|
-
- **No** → continue to next step.
|
|
25
|
-
- **Yes** → execute the Docker flow below.
|
|
26
|
-
|
|
27
|
-
### Docker flow
|
|
28
|
-
|
|
29
|
-
The container name is `<project-name>-postgres` where `<project-name>` is the kebab-case project name (read from the `name` field in `package.json`).
|
|
30
|
-
|
|
31
|
-
1. Ensure the Docker daemon is running. If not, start Docker Desktop via terminal automatically.
|
|
32
|
-
2. Auto-generate password.
|
|
33
|
-
3. Discover occupied ports by listing **all** containers (including stopped) and pick the first port in **5432 → 5450** that does **not** appear in the output. If all ports are occupied, stop and inform the user.
|
|
34
|
-
4. Run the container on the chosen port:
|
|
35
|
-
|
|
36
|
-
```powershell
|
|
37
|
-
docker run --name <project-name>-postgres -e POSTGRES_PASSWORD=<password> -d -p <PORT>:5432 postgres
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
- **Success** → continue.
|
|
41
|
-
- **Error** → stop and show the full error to the user.
|
|
42
|
-
|
|
43
|
-
5. Create the schema matching the username:
|
|
44
|
-
|
|
45
|
-
```powershell
|
|
46
|
-
docker exec <project-name>-postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS postgres AUTHORIZATION postgres;"
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
6. Update `.env.local`:
|
|
50
|
-
- Set `DATABASE_URL=postgres://postgres:<password>@localhost:<PORT>/postgres`.
|
|
51
|
-
7. Output exactly:
|
|
52
|
-
> ✅ Local Postgres database created successfully on port [PORT]
|
|
1
|
+
# Database Setup
|
|
2
|
+
|
|
3
|
+
> Create `.env.local` if it does not exist.
|
|
4
|
+
> The app pins `search_path` to the `DATABASE_URL` username, so a schema with that
|
|
5
|
+
> exact name must exist. `public` cannot be a username — it is a reserved role.
|
|
6
|
+
|
|
7
|
+
## User Input
|
|
8
|
+
|
|
9
|
+
Ask via **AskUserQuestion**: **"Do you already have a Postgres database created for this project?"** — options `Yes` / `No`.
|
|
10
|
+
|
|
11
|
+
## Branch A — Existing database
|
|
12
|
+
|
|
13
|
+
1. Ask: **"Please provide the database connection details"**.
|
|
14
|
+
|
|
15
|
+
Fill the host in automatically — QAS is always `10.82.36.60:5432`, PRD is always `10.82.36.50:5432`.
|
|
16
|
+
|
|
17
|
+
2. Update `.env.local`:
|
|
18
|
+
- Set `DATABASE_URL=postgres://<schema-username>:<password>@<server-address>:5432/<database-name>`.
|
|
19
|
+
|
|
20
|
+
## Branch B — No database
|
|
21
|
+
|
|
22
|
+
Ask via **AskUserQuestion**: **"Would you like me to create a local Postgres database using Docker?"** — options `Yes` / `No`.
|
|
23
|
+
|
|
24
|
+
- **No** → continue to next step.
|
|
25
|
+
- **Yes** → execute the Docker flow below.
|
|
26
|
+
|
|
27
|
+
### Docker flow
|
|
28
|
+
|
|
29
|
+
The container name is `<project-name>-postgres` where `<project-name>` is the kebab-case project name (read from the `name` field in `package.json`).
|
|
30
|
+
|
|
31
|
+
1. Ensure the Docker daemon is running. If not, start Docker Desktop via terminal automatically.
|
|
32
|
+
2. Auto-generate password.
|
|
33
|
+
3. Discover occupied ports by listing **all** containers (including stopped) and pick the first port in **5432 → 5450** that does **not** appear in the output. If all ports are occupied, stop and inform the user.
|
|
34
|
+
4. Run the container on the chosen port:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
docker run --name <project-name>-postgres -e POSTGRES_PASSWORD=<password> -d -p <PORT>:5432 postgres
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- **Success** → continue.
|
|
41
|
+
- **Error** → stop and show the full error to the user.
|
|
42
|
+
|
|
43
|
+
5. Create the schema matching the username:
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
docker exec <project-name>-postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS postgres AUTHORIZATION postgres;"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
6. Update `.env.local`:
|
|
50
|
+
- Set `DATABASE_URL=postgres://postgres:<password>@localhost:<PORT>/postgres`.
|
|
51
|
+
7. Output exactly:
|
|
52
|
+
> ✅ Local Postgres database created successfully on port [PORT]
|
|
@@ -74,7 +74,7 @@ SESSION_SECRET=<generated-64-char-hex>
|
|
|
74
74
|
|
|
75
75
|
3. **Certificates & secrets:** open the **Client secrets** tab → **+ New client secret**. Leave **Description** empty and set **Expires** to `730 days (24 months)` — always these values, never ask the user — then click **Add**. **CRITICAL — one chance only:** the new row's **Value** column holds the secret and is shown _only_ immediately after creation; once you leave or reload the blade it is masked forever and the app must get a brand-new secret. Read that **Value** from the row's textbox in the page snapshot, and write it into `ENTRA_CLIENT_SECRET` in `.env.local` as your very next action, before any other click or navigation. The neighbouring **Secret ID** column is a plain GUID and is _not_ the secret — writing it there is a silent, unrecoverable mistake. The cell renders truncated with `…`, so take the textbox's full value from the snapshot, and never print it in chat or a commit.
|
|
76
76
|
4. **Token configuration:** click **Add groups claim**. In the panel tick **Security groups** only, then expand each of **ID**, **Access**, and **SAML** in "Customize token properties by type" and switch the radio from `Group ID` to `sAMAccountName`. Click **Add**. The list should then show a `groups` claim with token type `ID, Access, SAML`.
|
|
77
|
-
5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**. Do not navigate away or report progress as complete until the saved `api://wistron.com/<app-name>` URI and enabled `access_as_user` scope are both visible in the portal. Then set the `api` key in `src/lib/auth/scopes.ts` to `
|
|
77
|
+
5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**. Do not navigate away or report progress as complete until the saved `api://wistron.com/<app-name>` URI and enabled `access_as_user` scope are both visible in the portal. Then set the `api` key in `src/lib/auth/scopes.ts` to the plain string `"api://wistron.com/<app-name>/access_as_user"` (`Scope` is `string | Partial<Record<ProviderId, string>>` — an array fails `satisfies Scopes`), matching the scope exactly as the portal lists it; leave the other keys untouched.
|
|
78
78
|
6. **Owners:** first read the current table once. Add only missing people from this fixed list: Radim Staworowski, Martin Husar, Dalibor Homola, Patrik Lorenc, Tien Thanh Tran, Sebastian Ondruska. In the picker, search each missing full name, wait for the exact name and Wistron UPN match, select it, then replace the search text with the next name without closing the picker. Submit the batch once and verify all six names in the refreshed table.
|
|
79
79
|
7. **Manifest:** the page opens the **Microsoft Graph App Manifest (New)** JSON in a Monaco editor. Do not retype the JSON — click into the editor, press `Ctrl+H`, and run Replace All twice: `"acceptMappedClaims": null` → `"acceptMappedClaims": true`, then `"requestedAccessTokenVersion": null` → `"requestedAccessTokenVersion": 2` (both live in the `api` object, one match each). Verify both edited lines, then click **Save**.
|
|
80
80
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Vault Setup
|
|
2
2
|
|
|
3
|
-
Move
|
|
4
|
-
`.env.local` down to the Vault connection only.
|
|
3
|
+
Move local-development secrets into Vault, then shrink `.env.local` to the Vault connection.
|
|
5
4
|
|
|
6
5
|
Before starting, ask the user via **AskUserQuestion** which environment(s) to
|
|
7
6
|
set up: **QAS**, **PRD** or **both**. Both environments follow the same steps —
|
|
@@ -17,17 +16,11 @@ expected state appears or ~5 minutes pass, then carry straight on. Never end
|
|
|
17
16
|
your turn while waiting; announcing "I'll continue once you have signed in"
|
|
18
17
|
and stopping ends the session, and nothing resumes it.
|
|
19
18
|
|
|
20
|
-
Do not print secret values into chat, logs, or a commit — reference them by
|
|
21
|
-
key name. Values move from `.env.local` into the browser and nowhere else.
|
|
22
|
-
|
|
23
19
|
## Part 1 — Collect the payload from `.env.local`
|
|
24
20
|
|
|
25
|
-
1.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
instead — include them in the payload too.
|
|
29
|
-
2. If `SESSION_SECRET` is empty or missing, generate one.
|
|
30
|
-
3. Build the JSON payload from every key in `.env.local` (except `DATABASE_AUTOMIGRATE`). A typical payload that goes to Vault.
|
|
21
|
+
1. Inspect key names and whether they are set without printing their values. Include keys from `.env` such as `*_BASE_URL`, etc.
|
|
22
|
+
2. If `SESSION_SECRET` is empty or missing, generate it without writing it to command output.
|
|
23
|
+
3. Build a JSON key skeleton from `.env.local`, excluding `DATABASE_AUTO_MIGRATE`.
|
|
31
24
|
|
|
32
25
|
```json
|
|
33
26
|
{
|
|
@@ -113,7 +106,7 @@ VAULT_USERNAME=<from Part 2>
|
|
|
113
106
|
VAULT_PASSWORD=<from Part 2>
|
|
114
107
|
|
|
115
108
|
DATABASE_URL=<kept — local dev DB or QAS, per user choice>
|
|
116
|
-
|
|
109
|
+
DATABASE_AUTO_MIGRATE=<kept>
|
|
117
110
|
```
|
|
118
111
|
|
|
119
112
|
After writing, verify end-to-end: start the dev server (or replicate the
|