wcz-layout 9.6.5 → 9.6.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wcz-layout",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tanstack-intent"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"i18next": "^26.3.6",
|
|
75
75
|
"i18next-browser-languagedetector": "^8.2.1",
|
|
76
76
|
"jose": "^6.2.8",
|
|
77
|
-
"react-dropzone": "^20.
|
|
77
|
+
"react-dropzone": "^20.1.0",
|
|
78
78
|
"react-i18next": "^17.0.11",
|
|
79
79
|
"react-intersection-observer": "^11.0.0",
|
|
80
80
|
"react-number-format": "^5.4.5",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@arethetypeswrong/core": "^0.18.5",
|
|
86
86
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
87
|
-
"@tanstack/ai": "^0.43.
|
|
88
|
-
"@tanstack/ai-client": "^0.23.
|
|
87
|
+
"@tanstack/ai": "^0.43.1",
|
|
88
|
+
"@tanstack/ai-client": "^0.23.1",
|
|
89
89
|
"@tanstack/ai-openai": "^0.18.0",
|
|
90
90
|
"@tanstack/highlight": "^0.0.10",
|
|
91
91
|
"@types/node": "^26.1.2",
|
|
@@ -7,12 +7,13 @@ description: "Use when: creating or modifying TanStack DB collections, live quer
|
|
|
7
7
|
|
|
8
8
|
## Rules
|
|
9
9
|
|
|
10
|
-
- Use `eager` syncMode for top-level collections, `on-demand` for child/relational data.
|
|
10
|
+
- Use `eager` syncMode for top-level collections, `on-demand` for child/relational data and for any collection expected to exceed ~10k rows.
|
|
11
11
|
- Always preload every `eager` collection used by a route, including collections used only by components rendered under that route. Do not preload `on-demand` collections.
|
|
12
|
+
- On detail routes keyed by a param, guard the loader with `queryOnce` (from `@tanstack/react-db`) — the route's `where` plus `.findOne()` — and `throw notFound()` (from `@tanstack/react-router`) when it resolves to `undefined`. It works for both sync modes, and for `on-demand` it warms the subset's query-cache entry. It is one-shot, so the component still needs `useLiveQuery`.
|
|
12
13
|
- Use `useLiveQuery` for list/grid pages and `useLiveSuspenseQuery` for detail components wrapped in suspense.
|
|
13
14
|
- Shape data in the collection query whenever possible: filter, order, group and aggregate only the fields the consumer needs. Do not load broad results and further filter or transform them in component code.
|
|
14
15
|
- For mutations use `createOptimisticAction` — mirror the server mutation in `onMutate`, then call the server function in `mutationFn` and await `utils.refetch()` on every collection the server function writes.
|
|
15
|
-
- For on-demand subset loading, convert `meta.loadSubsetOptions` with `fromTanDb()` (from `agnostic-query/tanstack-db`) before passing it to the server fn, and set `autoIndex: "eager"`
|
|
16
|
+
- For on-demand subset loading, convert `meta.loadSubsetOptions` with `fromTanDb()` (from `agnostic-query/tanstack-db`) before passing it to the server fn, and set `syncMode: "on-demand"`, `autoIndex: "eager"` and `defaultIndexType: BasicIndex` (from `@tanstack/react-db`).
|
|
16
17
|
|
|
17
18
|
## File Placement
|
|
18
19
|
|
|
@@ -38,7 +39,7 @@ export const librariesCollection = createCollection(
|
|
|
38
39
|
}),
|
|
39
40
|
);
|
|
40
41
|
|
|
41
|
-
// src/db-collections/<feature>.ts — child/relational (on-demand)
|
|
42
|
+
// src/db-collections/<feature>.ts — child/relational or >10k rows (on-demand)
|
|
42
43
|
import { BasicIndex } from "@tanstack/react-db";
|
|
43
44
|
import { fromTanDb } from "agnostic-query/tanstack-db";
|
|
44
45
|
|
|
@@ -62,6 +63,20 @@ export const Route = createFileRoute("/")({
|
|
|
62
63
|
},
|
|
63
64
|
});
|
|
64
65
|
|
|
66
|
+
// Detail route — not-found guard
|
|
67
|
+
export const Route = createFileRoute("/libraries/$libraryId")({
|
|
68
|
+
loader: async ({ params }) => {
|
|
69
|
+
const library = await queryOnce((q) =>
|
|
70
|
+
q
|
|
71
|
+
.from({ library: libraryCollection })
|
|
72
|
+
.where(({ library }) => eq(library.id, params.libraryId))
|
|
73
|
+
.findOne(),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (!library) throw notFound();
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
65
80
|
// simple query
|
|
66
81
|
const { data, isLoading } = useLiveQuery((q) =>
|
|
67
82
|
q.from({ library: libraryCollection }).orderBy(({ library }) => library.name, "asc"),
|
|
@@ -7,6 +7,7 @@ description: "Use when: defining or updating Drizzle ORM table schemas, relation
|
|
|
7
7
|
|
|
8
8
|
## Rules
|
|
9
9
|
|
|
10
|
+
- One table per file, named after the table (e.g. `bookTable` lives in `book.ts`). Never put multiple tables in one file, even when they are related — a parent and its children each get their own file.
|
|
10
11
|
- Always use `uuid` for primary keys, and `snakeCase` for generating tables.
|
|
11
12
|
- For `uuid` columns, do not generate random values in the schema. Client should generate UUIDs when creating new records.
|
|
12
13
|
- Always add `withTimezone: true` to timestamp columns.
|
|
@@ -24,7 +25,7 @@ drizzle-orm - defineRelations utility
|
|
|
24
25
|
drizzle-orm/pg-core - snakeCase table builder and column types
|
|
25
26
|
drizzle-orm/zod - createSelectSchema
|
|
26
27
|
zod - Zod
|
|
27
|
-
src/server/db/schemas/ - Drizzle table schemas
|
|
28
|
+
src/server/db/schemas/ - Drizzle table schemas, one table per file + relations.ts
|
|
28
29
|
src/server/db/migrations/ - Drizzle migration files
|
|
29
30
|
src/lib/schemas/ - Zod schemas (shared between client and server)
|
|
30
31
|
wcz-layout/utils - `t` translation function
|
|
@@ -33,7 +34,13 @@ wcz-layout/utils - `t` translation function
|
|
|
33
34
|
## Examples
|
|
34
35
|
|
|
35
36
|
```ts
|
|
36
|
-
// src/server/db/schemas
|
|
37
|
+
// src/server/db/schemas/library.ts
|
|
38
|
+
export const libraryTable = snakeCase.table("libraries", {
|
|
39
|
+
id: uuid().primaryKey(),
|
|
40
|
+
name: text().notNull(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/server/db/schemas/book.ts
|
|
37
44
|
export const bookTable = snakeCase.table("books", {
|
|
38
45
|
id: uuid().primaryKey(),
|
|
39
46
|
title: text().notNull(),
|
package/skills/general/SKILL.md
CHANGED
|
@@ -13,7 +13,9 @@ Favor the established platform before introducing custom code or a new dependenc
|
|
|
13
13
|
- **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
|
|
14
14
|
- **Material UI:** Use Material UI for interface components and icons. When an advanced capability is needed, consider MUI X Charts for data visualization, Tree View for hierarchical data, Scheduler for calendars and timelines, and Chat for AI-powered conversations.
|
|
15
15
|
|
|
16
|
-
Before implementing an external library feature, consult the current documentation through Context7 MCP. Do not add a dependency when one of these platform libraries already covers the requirement.
|
|
16
|
+
Before implementing an external library feature, consult the current documentation through Context7 MCP. Do not add a new dependency when one of these platform libraries already covers the requirement.
|
|
17
|
+
|
|
18
|
+
When the requirement is not covered above and a well-maintained, popular library solves it, use that library instead of writing your own implementation.
|
|
17
19
|
|
|
18
20
|
## Coding Conventions
|
|
19
21
|
|
|
@@ -50,13 +52,13 @@ src/ # client-first architecture
|
|
|
50
52
|
├── routes/ # TanStack Router file-based routing
|
|
51
53
|
│ ├── __root.tsx
|
|
52
54
|
│ ├── index.tsx
|
|
53
|
-
│ └── features/ #
|
|
55
|
+
│ └── features/ # feature folder with multiple routes (kebab-case, plural)
|
|
54
56
|
│ ├── -components/ # route-specific components
|
|
55
57
|
│ ├── -hooks/ # route-specific hooks
|
|
56
58
|
│ ├── index.tsx
|
|
57
59
|
│ ├── create.tsx
|
|
58
|
-
│ ├──
|
|
59
|
-
│ └──
|
|
60
|
+
│ ├── $id.tsx
|
|
61
|
+
│ └── edit.$id.tsx
|
|
60
62
|
├── server/ # server-only code
|
|
61
63
|
│ ├── actions/
|
|
62
64
|
│ │ └── <table>.ts
|
|
@@ -69,5 +71,24 @@ src/ # client-first architecture
|
|
|
69
71
|
│ └── middleware/
|
|
70
72
|
│ └── databaseMiddleware.ts
|
|
71
73
|
└── types/
|
|
72
|
-
tests/
|
|
74
|
+
tests/
|
|
75
|
+
├── unit/
|
|
76
|
+
│ ├── lib/
|
|
77
|
+
│ │ └── schemas/
|
|
78
|
+
│ │ └── <table>.test.ts
|
|
79
|
+
│ ├── hooks/
|
|
80
|
+
│ │ └── useX.test.ts
|
|
81
|
+
│ └── routes/
|
|
82
|
+
│ └── features/
|
|
83
|
+
│ └── -components/
|
|
84
|
+
│ └── XCard.test.tsx
|
|
85
|
+
├── integration/
|
|
86
|
+
│ ├── server/
|
|
87
|
+
│ │ └── actions/
|
|
88
|
+
│ │ └── <table>.test.ts
|
|
89
|
+
│ └── db-collections/
|
|
90
|
+
│ └── <table>Collection.test.ts
|
|
91
|
+
└── e2e/
|
|
92
|
+
└── features/
|
|
93
|
+
└── create.spec.ts
|
|
73
94
|
```
|
|
@@ -12,8 +12,9 @@ description: "Use when: creating or modifying TanStack Start server functions, A
|
|
|
12
12
|
- Follow the chain order for server functions: `middleware` → `validator` → `handler`.
|
|
13
13
|
- Follow the order for middleware arrays: `authorizationMiddleware(<permissionKey>)` → `databaseMiddleware()`.
|
|
14
14
|
- Use `validationMiddleware` only in REST API routes. Server functions use `.validator()`.
|
|
15
|
-
-
|
|
15
|
+
- Never create a transaction in the handler because `databaseMiddleware` already owns it.
|
|
16
16
|
- Reuse schemas from `src/lib/schemas/`.
|
|
17
|
+
- Background jobs are API routes using only `authenticationMiddleware()` + `databaseMiddleware()` — cron runs in Kubernetes and authenticates via app token.
|
|
17
18
|
|
|
18
19
|
## File Placement
|
|
19
20
|
|
|
@@ -1,69 +1,81 @@
|
|
|
1
1
|
# Vault Setup
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
3
|
+
Move the secrets that currently live in `.env.local` into Vault, then shrink
|
|
4
|
+
`.env.local` down to the Vault connection only.
|
|
5
|
+
|
|
6
|
+
Before starting, ask the user via **AskUserQuestion** which environment(s) to
|
|
7
|
+
set up: **QAS**, **PRD** or **both**. Both environments follow the exact same
|
|
8
|
+
steps — only the login credentials and the Vault path differ (QAS lives under
|
|
9
|
+
`sat-qas-01`, PRD under `sat-prd-01`; each has its own Vault account and
|
|
10
|
+
password). When doing both, run through Parts 1–2 once per environment. In
|
|
11
|
+
Part 3, always write the **QAS** connection into `.env.local` (if available).
|
|
12
|
+
|
|
13
|
+
To wait for something the user does in the browser — signing in, saving a
|
|
14
|
+
secret — poll in a tool loop: wait ~5 s, re-read the page, repeat until the
|
|
15
|
+
expected state appears or ~5 minutes pass, then carry straight on. Never end
|
|
16
|
+
your turn while waiting; announcing "I'll continue once you have signed in"
|
|
17
|
+
and stopping ends the session, and nothing resumes it.
|
|
18
|
+
|
|
19
|
+
Do not print secret values into chat, logs, or a commit — reference them by
|
|
20
|
+
key name. Values move from `.env.local` into the browser and nowhere else.
|
|
21
|
+
|
|
22
|
+
## Part 1 — Collect the payload from `.env.local`
|
|
23
|
+
|
|
24
|
+
1. Read `.env.local`. If it does not exist, create it.
|
|
25
|
+
2. If `SESSION_SECRET` is empty or missing, generate one.
|
|
26
|
+
3. Build the JSON payload from every key in `.env.local` (except `DATABASE_AUTOMIGRATE`). A typical payload that goes to Vault:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"ENTRA_CLIENT_ID": "...",
|
|
31
|
+
"ENTRA_TENANT_ID": "...",
|
|
32
|
+
"ENTRA_CLIENT_SECRET": "...",
|
|
33
|
+
"SESSION_SECRET": "...",
|
|
34
|
+
"DATABASE_URL": "...",
|
|
35
|
+
"DATABASE_SCHEMA": "..."
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Part 2 — Write the secrets in the Vault UI
|
|
40
|
+
|
|
41
|
+
Repeat this part once per selected environment (QAS and/or PRD) — same steps,
|
|
42
|
+
different credentials and path.
|
|
43
|
+
|
|
44
|
+
1. Ask for the screenshot of WiCOP email or the **Vault path**, **Vault Account** and **Vault Password** one-by-one.
|
|
45
|
+
2. Open the Vault address in the browser. Login with provided account and password and redirect to provided path:
|
|
46
|
+
- The URL already contains the secret path, so it redirects there after login.
|
|
47
|
+
- On the "Sign in to Vault" screen, open the **Method** dropdown and select **Userpass** (not the default Token).
|
|
48
|
+
- Enter the **Username** (Vault Account), then the **Password**, then click **Sign in**.
|
|
49
|
+
- You land on the secret list for the project path, e.g. `release/wcz/sat-<environment>-01/<project>-wcz`, containing a `default` secret.
|
|
50
|
+
3. Update the `default` secret with the `.env.local` payload:
|
|
51
|
+
- Click the `default` secret to open it, then open the **Secret** tab.
|
|
52
|
+
- Click **Create new version**.
|
|
53
|
+
- Toggle the **JSON** switch in the toolbar, select all in the JSON editor (`Ctrl+A`) and replace it with the payload JSON from Part 1 (this also removes any pre-existing keys like `cog_test`).
|
|
54
|
+
- Click **Save**. Verify the success toast "Successfully saved secret data" and that the new version lists every expected key.
|
|
55
|
+
4. Create the `harborvault` secret:
|
|
56
|
+
- In the breadcrumb, click `<projectname>-wcz` to go one level up.
|
|
57
|
+
- Click **Create secret**.
|
|
58
|
+
- In **Path for this secret**, append `harborvault` to the pre-filled project path (i.e. `wcz/<env>/<projectname>-wcz/harborvault`).
|
|
59
|
+
- Toggle the **JSON** switch, then ask the user to copy-paste the harborvault JSON from another project into the JSON editor (contains the `HARBOR_SECRET` key). Autonomously poll the editor until the content is there — do not end the session while waiting.
|
|
60
|
+
- Click **Save**. Verify the success toast.
|
|
61
|
+
5. Close the Vault browser session.
|
|
62
|
+
|
|
63
|
+
## Part 3 — Rewrite `.env.local`
|
|
64
|
+
|
|
65
|
+
Use the **QAS** credentials here when both environments were set up.
|
|
66
|
+
|
|
67
|
+
Rewrite the file so it contains **only** these keys. Every app secret is now
|
|
68
|
+
served by Vault, so its local value is removed — a leftover value would
|
|
69
|
+
override Vault. `DATABASE_URL` and `DATABASE_SCHEMA` stay filled because
|
|
70
|
+
drizzle-kit reads them directly and never goes through Vault.
|
|
39
71
|
|
|
40
72
|
```dotenv
|
|
41
|
-
VAULT_ADDRESS
|
|
42
|
-
VAULT_SECRET_PATH
|
|
43
|
-
VAULT_USERNAME
|
|
44
|
-
VAULT_PASSWORD
|
|
45
|
-
|
|
46
|
-
DATABASE_URL
|
|
47
|
-
DATABASE_SCHEMA
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Then ask the user to fill in the empty values directly in `.env.local` (not in chat), and confirm via **AskUserQuestion**: **"Are the `.env.local` values filled in?"** — options `Done` / `Not yet`. On `Not yet`, wait and ask again.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Branch B — No Vault
|
|
55
|
-
|
|
56
|
-
Create `.env.local` to contain exactly these keys — keep any values already set by earlier steps, fill `SESSION_SECRET` with a freshly generated value, and leave the rest empty:
|
|
57
|
-
|
|
58
|
-
```dotenv
|
|
59
|
-
ENTRA_CLIENT_ID=
|
|
60
|
-
ENTRA_TENANT_ID=
|
|
61
|
-
ENTRA_CLIENT_SECRET=
|
|
62
|
-
SESSION_SECRET=<generated-64-char-hex>
|
|
63
|
-
|
|
64
|
-
DATABASE_SCHEMA=
|
|
65
|
-
DATABASE_AUTO_MIGRATE=
|
|
66
|
-
DATABASE_URL=
|
|
73
|
+
VAULT_ADDRESS=<from Part 2>
|
|
74
|
+
VAULT_SECRET_PATH=<from Part 2>
|
|
75
|
+
VAULT_USERNAME=<from Part 2>
|
|
76
|
+
VAULT_PASSWORD=<from Part 2>
|
|
77
|
+
|
|
78
|
+
DATABASE_URL=<kept>
|
|
79
|
+
DATABASE_SCHEMA=<kept>
|
|
80
|
+
DATABASE_AUTOMIGRATE=<kept>
|
|
67
81
|
```
|
|
68
|
-
|
|
69
|
-
Then ask the user to fill in the empty values directly in `.env.local` (not in chat), and confirm via **AskUserQuestion**: **"Are the `.env.local` values filled in?"** — options `Done` / `Not yet`. On `Not yet`, wait and ask again.
|