@jskit-ai/agent-docs 0.1.324 → 0.1.326
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/guide/agent/app-setup/authentication.md +109 -1
- package/guide/agent/framework/data-pass.md +160 -0
- package/guide/agent/framework/quality-pass.md +99 -0
- package/guide/agent/framework/visual-identity.md +152 -0
- package/guide/agent/index.md +6 -0
- package/package.json +1 -1
- package/patterns/minimal-foundation/example/package.json +2 -2
- package/patterns/shell-foundation/example/package.json +3 -3
- package/reference/autogen/PATTERN_INDEX.md +19 -19
- package/reference/autogen/packages/auth-core.md +13 -0
- package/reference/autogen/packages/auth-provider-local-core.md +19 -1
- package/reference/autogen/packages/auth-provider-local-db-core.md +9 -0
- package/reference/autogen/packages/auth-web.md +6 -0
- package/skills/jskit/SKILL.md +5 -1
- package/skills/jskit/references/data-pass.md +155 -0
- package/skills/jskit/references/pattern-index.md +19 -19
- package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +2 -2
- package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +3 -3
- package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +1 -1
- package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
- package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
- package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +1 -1
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +2 -2
- package/skills/jskit/references/quality-pass.md +94 -0
- package/skills/jskit/references/visual-identity.md +147 -0
|
@@ -100,7 +100,7 @@ request over it is refused with status 429, the code `kernel.http.rateLimited`
|
|
|
100
100
|
defaults, per minute: `login`, `register`, `registerConfirm`,
|
|
101
101
|
`loginOtpRequest` and `loginOtpVerify` 10; `registerConfirmationResend` and
|
|
102
102
|
`passwordForgot` 5;
|
|
103
|
-
`oauthStart`, `oauthComplete`, `passwordRecovery` and `passwordReset` 20;
|
|
103
|
+
`oauthStart`, `oauthComplete`, `passSignIn`, `passwordRecovery` and `passwordReset` 20;
|
|
104
104
|
`devLoginAs` 30. Change one in the application's server configuration;
|
|
105
105
|
`false` removes it:
|
|
106
106
|
|
|
@@ -510,6 +510,114 @@ and on every server, writes no `first-account-setup-code` file, and logs only
|
|
|
510
510
|
that the code is in `AUTH_LOCAL_SETUP_CODE`, never the code itself. Outside
|
|
511
511
|
production the variable is ignored.
|
|
512
512
|
|
|
513
|
+
## One-time pass sign-in (local auth)
|
|
514
|
+
|
|
515
|
+
An application whose people already signed in somewhere else, such as a
|
|
516
|
+
hosting site that opens each person's own server, can let that site sign them
|
|
517
|
+
in with no second password. The site, the issuer, signs a pass with its
|
|
518
|
+
Ed25519 private key; the application holds only the public key. A pass names
|
|
519
|
+
one person (`sub`), the application it is for (`aud`), one resource of that
|
|
520
|
+
application (`resource`, such as the one server it runs on) and its own id
|
|
521
|
+
(`jti`), and lasts a minute. The person's browser posts it to the application,
|
|
522
|
+
which signs in the account the pass names, once.
|
|
523
|
+
|
|
524
|
+
Three settings turn it on; without the key nothing changes: there is no pass
|
|
525
|
+
route and password sign-in stays as it is.
|
|
526
|
+
|
|
527
|
+
| Env | Meaning |
|
|
528
|
+
| --- | --- |
|
|
529
|
+
| `AUTH_PASS_PUBLIC_KEY` | The issuer's Ed25519 public key: a PEM block, or its base64 DER on one line (the PEM body without its header lines). |
|
|
530
|
+
| `AUTH_PASS_AUDIENCE` | The application every pass must name, such as `editor`. Required with the key. |
|
|
531
|
+
| `AUTH_PASS_RESOURCE` | The one resource every pass must name, such as this server's name. Required with the key. |
|
|
532
|
+
|
|
533
|
+
The application says which account a pass signs in with the
|
|
534
|
+
`auth.local.pass-identity` capability, a function given the verified pass
|
|
535
|
+
(`{ id, subject, audience, resource, issuedAt, expiresAt, usableUntil }`) that
|
|
536
|
+
answers the local account's id, or null when its subject has none here. With
|
|
537
|
+
the key set and no mapping installed, startup stops saying so.
|
|
538
|
+
|
|
539
|
+
```js
|
|
540
|
+
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
541
|
+
|
|
542
|
+
export const PassIdentityProvider = defineProvider({
|
|
543
|
+
id: "app.pass-identity",
|
|
544
|
+
requires: { accounts: "auth.local.accounts" },
|
|
545
|
+
provides: { passIdentity: "auth.local.pass-identity" },
|
|
546
|
+
/** @param {{ accounts: import("@jskit-ai/auth-provider-local-db-core/server/types").AuthLocalAccounts }} capabilities */
|
|
547
|
+
setup({ accounts }) {
|
|
548
|
+
/** @type {import("@jskit-ai/auth-provider-local-core/server/types").AuthLocalPassIdentity} */
|
|
549
|
+
async function passIdentity(pass) {
|
|
550
|
+
// This issuer names each person by the email of their account here.
|
|
551
|
+
return (await accounts.findByEmail(pass.subject))?.id ?? null;
|
|
552
|
+
}
|
|
553
|
+
return { passIdentity };
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
For direct library composition, pass it as `passIdentity` to
|
|
559
|
+
`createLocalAuthService()`, whose `signInWithPass({ pass })` signs in and
|
|
560
|
+
answers as `login` does.
|
|
561
|
+
|
|
562
|
+
The browser posts the pass as the form field `pass` to `POST /api/login/pass`,
|
|
563
|
+
from a page of the issuer's that submits itself, so the pass never sits in an
|
|
564
|
+
address, a history or a log:
|
|
565
|
+
|
|
566
|
+
```html
|
|
567
|
+
<form method="post" action="https://app.example.com/api/login/pass">
|
|
568
|
+
<input type="hidden" name="pass" value="PASS">
|
|
569
|
+
</form>
|
|
570
|
+
<script>document.forms[0].submit();</script>
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
A pass that signs in sets the session cookies and answers `303` to `/`. The pass
|
|
574
|
+
authenticates the post, so the route takes no CSRF token, and it is limited per
|
|
575
|
+
client address like the other sign-in routes (`passSignIn`, 20 a minute). A
|
|
576
|
+
refused pass answers `303` to `/auth/login` with `error=sign_in_unavailable`,
|
|
577
|
+
the reason in `error_description` and its code in `error_code`, and the sign-in
|
|
578
|
+
page shows the reason:
|
|
579
|
+
|
|
580
|
+
| Code | Status | Reason |
|
|
581
|
+
| --- | --- | --- |
|
|
582
|
+
| `auth.pass.malformed` | 401 | Not a pass, issued over 30 seconds ahead of this server's clock, or meant to last over five minutes. |
|
|
583
|
+
| `auth.pass.badSignature` | 401 | Not signed by the issuer's key, or changed after signing. |
|
|
584
|
+
| `auth.pass.wrongAudience` | 401 | For another application. |
|
|
585
|
+
| `auth.pass.wrongResource` | 401 | For another resource. |
|
|
586
|
+
| `auth.pass.expired` | 401 | Expired (30 seconds of clock difference are allowed). |
|
|
587
|
+
| `auth.pass.replayed` | 401 | Already used, on this server or another sharing its store. |
|
|
588
|
+
| `auth.pass.unmapped` | 403 | The mapping names no account, or a disabled one. |
|
|
589
|
+
|
|
590
|
+
Each pass signs in once. Local auth records each pass it accepts, by the hash
|
|
591
|
+
of its id, until it could no longer be used anyway (30 seconds after it
|
|
592
|
+
expired), before it asks the mapping: an unmapped pass is used up too. The
|
|
593
|
+
database backend keeps them in `auth_local_used_passes` (run
|
|
594
|
+
`npm run db:migrate`), so every server on the database refuses a pass another
|
|
595
|
+
accepted; the file backend keeps them in `passes.passwd` in its store. A pass
|
|
596
|
+
signs in an ordinary session: it does not prove a second factor, which a route
|
|
597
|
+
that asks for one still asks for.
|
|
598
|
+
|
|
599
|
+
The issuer signs passes with `signPass` from
|
|
600
|
+
`@jskit-ai/auth-core/server/passSignIn`, or with any JOSE library: a pass is a
|
|
601
|
+
compact JWS with the header `{ "alg": "EdDSA", "typ": "pass+jwt" }` and the
|
|
602
|
+
claims above plus `iat` and `exp`, in seconds.
|
|
603
|
+
|
|
604
|
+
```js
|
|
605
|
+
import { signPass } from "@jskit-ai/auth-core/server/passSignIn";
|
|
606
|
+
|
|
607
|
+
// On the issuer's server, which alone holds the private key (a KeyObject or PEM).
|
|
608
|
+
const pass = signPass({ privateKey, subject: "ada@example.com", audience: "editor", resource: "machine-7" });
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
Make the key pair with
|
|
612
|
+
`openssl genpkey -algorithm ed25519 -out pass-issuer.pem`, and the public key
|
|
613
|
+
the application is given with
|
|
614
|
+
`openssl pkey -in pass-issuer.pem -pubout`. The application trusts one key: to
|
|
615
|
+
change it, the issuer starts signing with the new key as the application
|
|
616
|
+
starts with it, and passes signed with the old key are refused. A person who
|
|
617
|
+
holds a valid pass of their own could post it from another person's browser
|
|
618
|
+
and sign that browser in as themselves, as with any sign-in link, so an issuer
|
|
619
|
+
signs passes only for its signed-in person, just before posting them.
|
|
620
|
+
|
|
513
621
|
## Application-owned recovery email
|
|
514
622
|
|
|
515
623
|
Local auth owns recovery tokens, expiry and recovery-scoped sessions. The
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/framework/data-pass.md`. Do not edit manually. -->
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
title: Data pass
|
|
5
|
+
description: The owner layer, query counters, constraint tests, migration mechanics and PostgreSQL and MySQL differences a data pass uses in a JSKIT app.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Data pass
|
|
9
|
+
|
|
10
|
+
A data pass makes an app's data hold up at real sizes. Genesis's data pass
|
|
11
|
+
skill (`genesis-data-pass`) holds the method: map the data, measure each path
|
|
12
|
+
at a few rows and at a realistic size, then make counts follow the rows read,
|
|
13
|
+
narrow reads in the query, enforce and try every constraint, migrate safely,
|
|
14
|
+
index the real filters, and leave tests at realistic sizes. This page says
|
|
15
|
+
which JSKIT pieces each step uses. The rules themselves are in
|
|
16
|
+
[Data access](/guide/framework/data-access) and the [sanity checks](/guide/framework/sanity-checks);
|
|
17
|
+
read the sections each step names.
|
|
18
|
+
|
|
19
|
+
## Map the data
|
|
20
|
+
|
|
21
|
+
- Each table has one owner: the feature whose table resource (`own()`)
|
|
22
|
+
declares it ([The resource is the only door](/guide/framework/data-access#the-resource-is-the-only-door)).
|
|
23
|
+
Other features read it through that owner
|
|
24
|
+
([Tables you don't own](/guide/framework/data-access#tables-you-don-t-own)).
|
|
25
|
+
`expectEveryTableOwned()` fails on a table nobody owns.
|
|
26
|
+
- A table's constraints and indexes are in the migrations of the package that
|
|
27
|
+
owns it, and the foreign keys between packages in a `constraints/`
|
|
28
|
+
subdirectory ([Directory order comes before filenames](/guide/app-setup/database-layer#directory-order-comes-before-filenames)).
|
|
29
|
+
- The paths to measure are the CRUD lists and records, the feature's actions
|
|
30
|
+
and services, the [many-row writes](/guide/framework/data-access#layer-3-many-rows-at-once),
|
|
31
|
+
the [reports](/guide/framework/data-access#layer-5-reports-the-resource-cannot-express)
|
|
32
|
+
and the [background work](/guide/framework/data-access#background-work).
|
|
33
|
+
|
|
34
|
+
## Measure
|
|
35
|
+
|
|
36
|
+
Count each path's statements on `TEST_DB_NAME`, never `DB_NAME`, with
|
|
37
|
+
`expectFlatQueries()` from `@jskit-ai/resource-runtime/test`, or
|
|
38
|
+
`countQueries(knex, work)` from
|
|
39
|
+
`@jskit-ai/database-runtime/server/testDatabases` when you want the counts and
|
|
40
|
+
statements themselves ([Tests](/guide/framework/data-access#tests),
|
|
41
|
+
[Query counts and batches](/guide/framework/sanity-checks#query-counts-and-batches)).
|
|
42
|
+
Record each count at a few rows and at the realistic size before changing
|
|
43
|
+
anything; the report compares them.
|
|
44
|
+
|
|
45
|
+
## Fix the paths
|
|
46
|
+
|
|
47
|
+
- **Counts follow the rows read.** A handle's `get()` or `query()`, or a
|
|
48
|
+
service call, inside a loop becomes one id-list read through `queryAll()` or
|
|
49
|
+
`include`, grouped with `Map.groupBy()`
|
|
50
|
+
([Reads shaped for the screen](/guide/framework/data-access#reads-shaped-for-the-screen)).
|
|
51
|
+
A write that does not use its result passes `returning: "id"` or `"none"`; a
|
|
52
|
+
batch uses `createMany()` and `patchMany()`.
|
|
53
|
+
- **The query narrows.** Filters, sorts, limits, existence checks and counts go
|
|
54
|
+
in the read: the searchSchema's filters, `q` for typed text, `take: 1` for
|
|
55
|
+
one row, `aggregate()` for a count
|
|
56
|
+
([Narrow in the query](/guide/framework/data-access#narrow-in-the-query)).
|
|
57
|
+
The lint rules `jskit/narrow-in-query` and `jskit/search-on-server`, and
|
|
58
|
+
`jskit check`'s `data/search-q`, report what they can see.
|
|
59
|
+
- A fix that needs an API the owner does not have is asked of that owner, or
|
|
60
|
+
of JSKIT for its packages, never written around it
|
|
61
|
+
([Exceptions](/guide/framework/data-access#exceptions)).
|
|
62
|
+
|
|
63
|
+
## Constraints
|
|
64
|
+
|
|
65
|
+
- Required fields, enumerations and ranges are in the resource's schema, and
|
|
66
|
+
required, unique and foreign keys in the table's migration. A rule the
|
|
67
|
+
schema cannot express, such as a uniqueness within an owner or a check that
|
|
68
|
+
reads another row, belongs to the owner's service, inside its
|
|
69
|
+
[transaction](/guide/framework/data-access#transactions).
|
|
70
|
+
- Try each one: a server test sends one value that breaks it and asserts the
|
|
71
|
+
refusal's status and code, and that the message tells the person what to do
|
|
72
|
+
([Every refusal explained](/guide/framework/quality-pass#every-refusal-explained)).
|
|
73
|
+
A unique or foreign key the database enforces needs that test too, so its
|
|
74
|
+
error reaches the person as a sentence, not a 500.
|
|
75
|
+
- `addMissingForeignKey(knex, key)` from
|
|
76
|
+
`@jskit-ai/database-runtime/server/foreignKeyMigrations` adds a key on fresh
|
|
77
|
+
and already-migrated databases alike; it fails, naming the rows with no
|
|
78
|
+
parent, and deletes nothing. Before adding any constraint, count the rows
|
|
79
|
+
that break it; ask the person what they should say rather than rewrite them.
|
|
80
|
+
|
|
81
|
+
## Migrations
|
|
82
|
+
|
|
83
|
+
- Each change is a new `.cjs` Knex migration in the package that owns the
|
|
84
|
+
table; one that has run anywhere is never edited
|
|
85
|
+
([Authoring schema changes](/guide/app-setup/database-layer#authoring-schema-changes),
|
|
86
|
+
[Migration ownership](/guide/framework/crud-operations#migration-ownership)).
|
|
87
|
+
- Backfill large tables in bounded chunks with the many-row writes, from a job
|
|
88
|
+
or a script, not inside one migration statement that holds a lock for its
|
|
89
|
+
whole run. Seed data is not a migration
|
|
90
|
+
([Seed data is not a migration](/guide/app-setup/database-layer#seed-data-is-not-a-migration)).
|
|
91
|
+
- Prove a migration on the selected engine as the database layer's
|
|
92
|
+
[Verification](/guide/app-setup/database-layer#verification) describes: fresh
|
|
93
|
+
preparation, an upgrade that keeps rows, and a second preparation with
|
|
94
|
+
nothing pending. Changing a migration or seed source changes the test
|
|
95
|
+
databases' snapshot digest, so the next test run rebuilds them
|
|
96
|
+
([Integration test databases](/guide/app-setup/database-layer#integration-test-databases)).
|
|
97
|
+
|
|
98
|
+
## Indexes
|
|
99
|
+
|
|
100
|
+
- Take the filters, sorts and joins from the statements `countQueries()`
|
|
101
|
+
captured, and give each an index in a new migration, its columns in the order
|
|
102
|
+
the query uses them; the owner columns of a scoped table usually come first.
|
|
103
|
+
- A filter on another table's field needs that field declared `indexed: true`
|
|
104
|
+
on its own table resource, with a database index on its column; `own()`
|
|
105
|
+
refuses it at startup otherwise ([Layer 1: the table resource](/guide/framework/data-access#layer-1-the-table-resource)).
|
|
106
|
+
- `lockWhere` needs an index that starts with the ownership columns, and with
|
|
107
|
+
`sort` or `limit` one that reads rows in the lock's order; without it the
|
|
108
|
+
lock refuses and names the index ([Layer 4: locks](/guide/framework/data-access#layer-4-locks)).
|
|
109
|
+
- Read the plan on the test database at the realistic size (below, per engine)
|
|
110
|
+
and see each index used.
|
|
111
|
+
|
|
112
|
+
## Tests at realistic sizes
|
|
113
|
+
|
|
114
|
+
- Each list, batch and write path keeps a one-line `expectFlatQueries()` test
|
|
115
|
+
whose `seed` builds the realistic size; each scoped path keeps an
|
|
116
|
+
`expectScoped()` test proving another owner's rows stay unseen and unchanged
|
|
117
|
+
([Tests](/guide/framework/data-access#tests)).
|
|
118
|
+
- A capped read keeps a test that seeds past its cap and finds the row it
|
|
119
|
+
needs.
|
|
120
|
+
- Run `npm run lint`, `npx jskit check` and `npm run verify`.
|
|
121
|
+
|
|
122
|
+
## PostgreSQL
|
|
123
|
+
|
|
124
|
+
- `CREATE INDEX CONCURRENTLY` builds an index without blocking writes, but
|
|
125
|
+
cannot run in a transaction: give that migration `exports.config = {
|
|
126
|
+
transaction: false }` and nothing else, and use `DROP INDEX CONCURRENTLY` in
|
|
127
|
+
its `down()`. A failed concurrent build leaves an invalid index behind; drop
|
|
128
|
+
it before retrying.
|
|
129
|
+
- On a large table, add a foreign key or check `NOT VALID`, which takes only a
|
|
130
|
+
brief lock and enforces it for new rows, then `VALIDATE CONSTRAINT` in a
|
|
131
|
+
later migration, which reads the old rows without blocking writes.
|
|
132
|
+
- Adding a column with a constant default is instant; changing a column's type
|
|
133
|
+
rewrites the table and locks it for the whole rewrite.
|
|
134
|
+
- PostgreSQL does not index a foreign key's column for you: index it when the
|
|
135
|
+
app filters or joins by it, or deletes parent rows.
|
|
136
|
+
- A partial index (`WHERE archived_at IS NULL`) serves a filter the app always
|
|
137
|
+
applies, at a fraction of the size.
|
|
138
|
+
- Read plans with `EXPLAIN (ANALYZE, BUFFERS)`, after `ANALYZE` on freshly
|
|
139
|
+
seeded tables, so the planner sees the realistic size.
|
|
140
|
+
- Counts and sums come back as strings; compare them with `Number()` in tests.
|
|
141
|
+
|
|
142
|
+
## MySQL
|
|
143
|
+
|
|
144
|
+
- DDL commits as it goes, so a migration with several schema statements can
|
|
145
|
+
stop half-applied: one schema change per migration, written for its partial
|
|
146
|
+
states ([MySQL and MariaDB failures can leave partial schema](/guide/app-setup/database-layer#mysql-and-mariadb-failures-can-leave-partial-schema)).
|
|
147
|
+
- Ask for an online change explicitly, `ALGORITHM=INPLACE, LOCK=NONE` (or
|
|
148
|
+
`ALGORITHM=INSTANT` to add a column), so a change that would lock the table
|
|
149
|
+
fails instead of locking it.
|
|
150
|
+
- InnoDB indexes each foreign key's column itself; an index whose leading
|
|
151
|
+
columns match makes it a duplicate.
|
|
152
|
+
- MySQL has no partial indexes; an index on the filtered column plus the owner
|
|
153
|
+
columns serves the same filter.
|
|
154
|
+
- With the `utf8mb4_0900_ai_ci` collation a unique key ignores case and accents
|
|
155
|
+
(`Soup` and `soup` collide); try a value that differs only in case when such a
|
|
156
|
+
key is a constraint.
|
|
157
|
+
- Read plans with `EXPLAIN ANALYZE` (MySQL 8.0.18 and later; `EXPLAIN` on
|
|
158
|
+
MariaDB).
|
|
159
|
+
- `information_schema` reads are slow and lock metadata: keep them in
|
|
160
|
+
migrations and checks, never on a request path.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/framework/quality-pass.md`. Do not edit manually. -->
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
title: Quality pass
|
|
5
|
+
description: Where loading, empty, error and refused states live in a JSKIT app, how a refusal reaches the person, and how to force each state while using the app.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Quality pass
|
|
9
|
+
|
|
10
|
+
A quality pass makes an app hold up in use. Genesis's quality pass skill
|
|
11
|
+
(`genesis-quality-pass`) holds the method: list each screen's states, make each
|
|
12
|
+
one right, try the edge cases, explain every refusal, check accessibility
|
|
13
|
+
basics, and prove it by using the app. This page says where each of those lives
|
|
14
|
+
in a JSKIT app. The rules it applies are already in [Material 3](/guide/framework/material-3),
|
|
15
|
+
[UI operations](/guide/framework/ui-operations) and the [sanity checks](/guide/framework/sanity-checks).
|
|
16
|
+
|
|
17
|
+
## States on every screen
|
|
18
|
+
|
|
19
|
+
- **Loading:** Material skeletons with the geometry of the content they stand
|
|
20
|
+
for, never a spinner; an action keeps a stable label while it runs and
|
|
21
|
+
cannot be sent twice ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
|
|
22
|
+
Ordinary reads stop after 30 seconds, so a slow read ends in its error state.
|
|
23
|
+
- **Empty:** a list's empty state carries an icon, a line saying what would be
|
|
24
|
+
there and one action, such as New; with filters or a search applied it
|
|
25
|
+
offers clearing them instead. An app with an identity uses its
|
|
26
|
+
`EmptyArt.vue` ([Visual identity](/guide/framework/visual-identity)).
|
|
27
|
+
- **Errors** stay with their owner: a resource that cannot load shows a stable
|
|
28
|
+
in-page error with Retry; a field's error sits beside the field, from the
|
|
29
|
+
server's `details.fieldErrors`; a command's failure goes through the shell's
|
|
30
|
+
action feedback and snackbar path (`ShellErrorHost`), never as an alert that
|
|
31
|
+
pushes the page down. The person's input stays in the form.
|
|
32
|
+
- **Refused by permission:** a screen the person may not use says so and
|
|
33
|
+
offers a way out; an action the person may not take is not offered, or is
|
|
34
|
+
explained where it shows.
|
|
35
|
+
|
|
36
|
+
## Every refusal explained
|
|
37
|
+
|
|
38
|
+
- On the server, each refusal is `new AppError(status, message, { code, params
|
|
39
|
+
})` with a code of its own, one per sentence
|
|
40
|
+
([Refusals carry their own code](/guide/framework/typed-features#refusals-carry-their-own-code)).
|
|
41
|
+
Its English says what was refused, why, and what the person can do:
|
|
42
|
+
"That slug is taken. Choose another name.", not "Conflict.".
|
|
43
|
+
- On the client, `serverMessage(error)` and `fieldErrorMessages(error)` from
|
|
44
|
+
`useJskitText()` show it, translated by its code
|
|
45
|
+
([How errors are shown](/guide/framework/translation#how-errors-are-shown)).
|
|
46
|
+
A generic "Something went wrong" in place of a coded refusal is a defect.
|
|
47
|
+
- To find them, list every `AppError` (and subclass) the scope's actions,
|
|
48
|
+
services and routes throw, trigger each one from the screen, and read what
|
|
49
|
+
the person sees. A caller without permission gets a 403 with no field errors
|
|
50
|
+
([Inputs and access](/guide/framework/sanity-checks#inputs-and-access)).
|
|
51
|
+
- A CRUD list that sends a query key its feature does not declare is refused
|
|
52
|
+
with `crud.query.undeclaredKeys`, and the person sees only that nothing
|
|
53
|
+
loaded. Declare the filter
|
|
54
|
+
([Narrow in the query](/guide/framework/data-access#narrow-in-the-query)).
|
|
55
|
+
|
|
56
|
+
## Edge cases in a JSKIT app
|
|
57
|
+
|
|
58
|
+
- **Long text:** button labels end in an ellipsis with the full text as
|
|
59
|
+
`title`; table cells end in an ellipsis; a list never scrolls sideways at any
|
|
60
|
+
width.
|
|
61
|
+
- **Double submit:** click Save twice quickly; the command's pending state
|
|
62
|
+
must send one request.
|
|
63
|
+
- **Session and tabs:** sign out in another tab and come back; let the session
|
|
64
|
+
expire mid-form. The auth guard sends the person to sign-in and back.
|
|
65
|
+
- **Time:** dates follow [strict temporal values](/guide/framework/crud-operations#strict-temporal-values);
|
|
66
|
+
try a value near midnight and in another time zone.
|
|
67
|
+
- **Roles:** sign in as the least-privileged role and walk each flow; Up stays
|
|
68
|
+
inside the app on a page opened from a link.
|
|
69
|
+
|
|
70
|
+
## Accessibility in a JSKIT app
|
|
71
|
+
|
|
72
|
+
`@jskit-ai/material-web` ships 48dp touch targets, visible focus and reduced
|
|
73
|
+
motion. The app supplies the rest the [Material 3 rules](/guide/framework/material-3)
|
|
74
|
+
list: an accessible name for each icon control (a `ShellPageAction`'s `label`
|
|
75
|
+
is its name), labels on fields, `aria-pressed` filter chips,
|
|
76
|
+
`role="radiogroup"` choices, menu roles, badge labels, and status never shown
|
|
77
|
+
by colour alone. In Playwright, `getByRole(role, { name })` finds a control
|
|
78
|
+
only when it has a name, so a locator that needs a CSS selector points at an
|
|
79
|
+
unnamed control.
|
|
80
|
+
|
|
81
|
+
## Use the app
|
|
82
|
+
|
|
83
|
+
- Drive the app in the host's managed Preview, or with Playwright as
|
|
84
|
+
[UI operations](/guide/framework/ui-operations#browser-verification) describes;
|
|
85
|
+
the host's preview identity signs you in.
|
|
86
|
+
- Force each state from the browser test:
|
|
87
|
+
`page.route("**/api/orders**", (route) => route.fulfill({ status: 500, json: { error: "…", code: "…" } }))`
|
|
88
|
+
for a failure, `route.abort()` or `context.setOffline(true)` for a dropped
|
|
89
|
+
connection, a delayed `route.continue()` for a slow one, and a fresh
|
|
90
|
+
`BROWSER_TEST_DB_NAME` fixture with no rows for first use.
|
|
91
|
+
- Seed realistic data in the browser fixture database: hundreds of rows and
|
|
92
|
+
long names.
|
|
93
|
+
- Walk each flow once with the keyboard only (`page.keyboard.press("Tab")`).
|
|
94
|
+
- Take screenshots at 390, 768 and 1280 wide, in light and dark, as the
|
|
95
|
+
[UI pass](/guide/framework/ui-pass) shows, and look at each one.
|
|
96
|
+
- Lock each fix in at the cheapest level ([Tests](/guide/framework/sanity-checks#tests)):
|
|
97
|
+
a state or a message in a Vitest component test, a refusal's status and code
|
|
98
|
+
in a server test, a flow in the Playwright spec that already reaches that
|
|
99
|
+
screen. Then run `npm run verify`.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/framework/visual-identity.md`. Do not edit manually. -->
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
title: Visual identity
|
|
5
|
+
description: Where each piece of an identity pass lives in a JSKIT app, the Material 3 pieces it uses, and the checks that prove it.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Visual identity
|
|
9
|
+
|
|
10
|
+
An identity pass gives an app a look of its own. Genesis's identity pass skill
|
|
11
|
+
(`genesis-identity-pass`) holds the method: study the app's kinds of content,
|
|
12
|
+
choose a style option, then build the theme, the artwork, the logo, the loading
|
|
13
|
+
screen and sign-in, and prove them. This page says where each piece lives in a
|
|
14
|
+
JSKIT app and which checks prove it. Read the [Material 3 rules](/guide/framework/material-3)
|
|
15
|
+
first: the identity works inside them, never against them, and navigation stays
|
|
16
|
+
must-fix.
|
|
17
|
+
|
|
18
|
+
## Theme: one seed
|
|
19
|
+
|
|
20
|
+
- `src/theme/index.js` is the app's only theme file: `{ seed, colors, icons,
|
|
21
|
+
typography }`, passed to `createMaterialVuetifyOptions()` from
|
|
22
|
+
`@jskit-ai/material-web/client` ([Foundation](/guide/framework/material-3#foundation)).
|
|
23
|
+
The seed generates the light and dark schemes; change it and both follow.
|
|
24
|
+
- A colour role per kind of content goes in `colors` by camelCase name.
|
|
25
|
+
`colors: { soups: "#B5562B", breads: "#8A6A2F" }` gives `soups`, `on-soups`,
|
|
26
|
+
`soups-container` and `on-soups-container` (and the same for `breads`),
|
|
27
|
+
harmonized toward the seed in both schemes; `{ value: "#F5C518", blend:
|
|
28
|
+
false }` keeps a colour's own hue. Use them by name:
|
|
29
|
+
`<v-chip color="soups-container">`.
|
|
30
|
+
- Interface code uses roles only. `jskit check m3` fails a hex colour outside
|
|
31
|
+
`src/theme/` (`m3/raw-hex`).
|
|
32
|
+
|
|
33
|
+
## Content colours: `src/theme/palettes.js`
|
|
34
|
+
|
|
35
|
+
Every colour that is content rather than interface lives here: named exports
|
|
36
|
+
of frozen plain hex values, each with a comment saying where it is used, as the
|
|
37
|
+
Material 3 page's [exceptions](/guide/framework/material-3#exceptions) describe.
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
// src/theme/palettes.js
|
|
41
|
+
|
|
42
|
+
// Cover art, per kind of content: the gradient's two stops, the motif's accent and its light colour
|
|
43
|
+
// (src/components/art/CoverArt.vue). `brand` draws items without a kind.
|
|
44
|
+
export const coverPalettes = Object.freeze({
|
|
45
|
+
brand: Object.freeze({ from: "#1F3A5F", to: "#3E7C8C", accent: "#F2B544", light: "#F6EFE3" }),
|
|
46
|
+
soups: Object.freeze({ from: "#7A2E1C", to: "#C8642F", accent: "#F4C95D", light: "#FBEFE1" }),
|
|
47
|
+
breads: Object.freeze({ from: "#5B4320", to: "#A7803E", accent: "#E8D3A2", light: "#FFF8EA" })
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// The logo tile, favicon.svg and the app icons (src/components/BrandLogo.vue).
|
|
51
|
+
export const logoColours = Object.freeze({ from: "#1F3A5F", to: "#3E7C8C", mark: "#F2B544", markShade: "#E07A3F" });
|
|
52
|
+
|
|
53
|
+
// The sign-in brand pane's glow and ink (src/components/AppBrand.vue).
|
|
54
|
+
export const signInPane = Object.freeze({ glow: "#3E7C8C", ink: "#0E1A26" });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Components read them through bindings (`:fill`, `:stop-color`, or `v-bind()`
|
|
58
|
+
in a scoped `<style>`), never as literals.
|
|
59
|
+
|
|
60
|
+
## Cover art: `src/components/art/CoverArt.vue`
|
|
61
|
+
|
|
62
|
+
- Props `kind` and `seed` (strings) and `height` (a number), declared typed as
|
|
63
|
+
the [client features](/guide/framework/client-features) guide asks.
|
|
64
|
+
- The root is `<svg viewBox="0 0 400 200" preserveAspectRatio="xMidYMid slice"
|
|
65
|
+
aria-hidden="true" width="100%" :height="height">`: one 2:1 drawing serves a
|
|
66
|
+
card, a strip and a thumbnail.
|
|
67
|
+
- The motifs are data in `src/components/art/motifs.js`, one list of
|
|
68
|
+
`{ tag, ...attributes }` shapes per kind, drawn with `<component
|
|
69
|
+
:is="shape.tag" v-bind="shape.attributes" />`. A native SVG tag (`circle`,
|
|
70
|
+
`path`, `rect`) named as a string is fine; `ui/vuetify-by-name` concerns
|
|
71
|
+
Vuetify components only.
|
|
72
|
+
- The seeded generator from the Genesis skill lives once, in the component's
|
|
73
|
+
module, seeded with `` `${kind}:${seed}` ``; the item's id or slug is the seed.
|
|
74
|
+
- A gradient's `id` carries the kind and the seed (`cover-soups-42`), so two
|
|
75
|
+
covers on one page never share one.
|
|
76
|
+
- A Vitest component test renders one kind and seed twice and gets the same
|
|
77
|
+
markup, and two seeds of one kind and gets different markup.
|
|
78
|
+
|
|
79
|
+
## Where it appears
|
|
80
|
+
|
|
81
|
+
- **Cards:** a flat `v-card` whose first child is `<CoverArt :height="130">`;
|
|
82
|
+
the card's 12dp corners clip it, so the art has no radius of its own. Then
|
|
83
|
+
the title in `text-title-large` (a stretched link that opens the record),
|
|
84
|
+
"By …" in `text-body-medium text-on-surface-variant`, a short description,
|
|
85
|
+
`variant="tonal"` chips (the kind with its icon, the level), and one
|
|
86
|
+
`text-body-small` meta line with small icons
|
|
87
|
+
([Lists, records and forms](/guide/framework/material-3#lists-records-and-forms)).
|
|
88
|
+
- **Hero card and profile header:** a `CoverArt` strip, with the `v-avatar`
|
|
89
|
+
overlapping its lower edge.
|
|
90
|
+
- **Empty states:** `src/components/art/EmptyArt.vue`: a 224×112 `CoverArt`
|
|
91
|
+
in a wrapper with 28dp corners, the state's icon in a 64dp `v-avatar
|
|
92
|
+
color="surface"` with `<v-icon color="primary">` in its middle and an
|
|
93
|
+
`elevation` class for the soft shadow (a hand-made `box-shadow` fails
|
|
94
|
+
`m3/raw-hex`), then a `text-title-large` line, a `text-body-medium` hint and
|
|
95
|
+
one `variant="tonal"` button.
|
|
96
|
+
- **Logo:** `src/components/BrandLogo.vue` draws the 512×512 tile (`rx="112"`)
|
|
97
|
+
inline from `logoColours`. The app's `favicon.svg` (beside `index.html` in
|
|
98
|
+
the foundation) is the same drawing with its colours written in; its
|
|
99
|
+
comment names `palettes.js` as their source. An app with
|
|
100
|
+
`manifest.webmanifest` lists its icons from the same drawing, and an app with
|
|
101
|
+
a mobile target renders its 1024×1024 PNG `Icon` from it on an opaque
|
|
102
|
+
background.
|
|
103
|
+
- **Loading screen:** `index.html`'s `#startup-shell`, which shows before any
|
|
104
|
+
JavaScript runs. Put the logo inline, the name as `<title>` spells it, and
|
|
105
|
+
the tagline in it; keep its `role="status"` line, its `<noscript>` and its
|
|
106
|
+
Reload link. Its colours are literal because it runs before the theme: take
|
|
107
|
+
them from `palettes.js` and the seed's schemes, and say so in a comment. Its
|
|
108
|
+
rotation runs only inside `@media (prefers-reduced-motion: no-preference)`.
|
|
109
|
+
- **Sign-in:** `src/components/AppBrand.vue`, from the `auth/auth-surface`
|
|
110
|
+
pattern, fills the auth views' `brand` slot. Wide (`compact` false), it is the brand
|
|
111
|
+
pane: a radial glow from `signInPane.glow` into `signInPane.ink`, the logo,
|
|
112
|
+
the name, the tagline and three short lines on what the app does, a large
|
|
113
|
+
faint accent ring and a few soft light bubbles. On phones (`compact`), the
|
|
114
|
+
logo and the name over a `CoverArt` strip of kind `brand`. It holds no
|
|
115
|
+
heading: each auth screen's `h1` is its own.
|
|
116
|
+
|
|
117
|
+
## The Material 3 pieces it uses
|
|
118
|
+
|
|
119
|
+
- **Pages open onto content.** The shell's top app bar carries the page's
|
|
120
|
+
title and actions ([The top app bar carries the page](/guide/framework/material-3#the-top-app-bar-carries-the-page)):
|
|
121
|
+
no welcome heading or title block.
|
|
122
|
+
- **"New"** is `ShellPrimaryAction`: an extended FAB on compact and medium
|
|
123
|
+
widths, a filled bar button on expanded ones.
|
|
124
|
+
- **Bottom navigation** on phones is the shell's navigation bar, drawn from the
|
|
125
|
+
surface's destinations: keep five or fewer. A surface with fewer than two
|
|
126
|
+
destinations draws no navigation at all, so there is never an empty drawer.
|
|
127
|
+
- **Loading** uses Material skeletons with the content's geometry, never a
|
|
128
|
+
spinner ([Components, state, and feedback](/guide/framework/material-3#components-state-and-feedback)).
|
|
129
|
+
- **Changing numbers** use `font-variant-numeric: tabular-nums`.
|
|
130
|
+
- **New list items** pop in through a Vue `<TransitionGroup>` with a scoped
|
|
131
|
+
keyframe (from `scale(0.6)` and `opacity: 0` over 600 ms, easing
|
|
132
|
+
`var(--md-sys-motion-easing-emphasized-decelerate)`). `material.css` finishes
|
|
133
|
+
every animation at once under `prefers-reduced-motion: reduce`, so the app
|
|
134
|
+
adds no media query of its own.
|
|
135
|
+
- **Button and chip overlays** take their shape's corners from `material.css`
|
|
136
|
+
(`border-radius: inherit` on the overlay, underlay and ripple). If one still
|
|
137
|
+
spills past its shape, report it at `@jskit-ai/material-web`; never add app
|
|
138
|
+
CSS for it.
|
|
139
|
+
|
|
140
|
+
## Prove it
|
|
141
|
+
|
|
142
|
+
- `npx jskit check m3` reports nothing and `npx jskit check` passes.
|
|
143
|
+
- Take the screenshots with a temporary Playwright spec as the
|
|
144
|
+
[UI pass](/guide/framework/ui-pass) shows: the main list, a record, an empty
|
|
145
|
+
state, `/auth/login` at 390 and 1280, and the profile, at 390 and 1280 wide,
|
|
146
|
+
in light and dark. Look at every one.
|
|
147
|
+
- Contrast: compute the ratio of each writing colour over each identity colour,
|
|
148
|
+
from the `palettes.js` values and the generated roles
|
|
149
|
+
(`useTheme().current.value.colors`) in both schemes.
|
|
150
|
+
- Layout shift: in the same spec, collect `layout-shift` entries with a
|
|
151
|
+
`PerformanceObserver` while a list loads; their sum stays near zero.
|
|
152
|
+
- Run the Vitest test of `CoverArt.vue` and the affected screens' tests.
|
package/guide/agent/index.md
CHANGED
|
@@ -37,6 +37,12 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
|
|
|
37
37
|
- [Material 3](/guide/framework/material-3)
|
|
38
38
|
- [UI pass](/guide/framework/ui-pass): make a task's changes, a section or the
|
|
39
39
|
whole app exact Material 3
|
|
40
|
+
- [Visual identity](/guide/framework/visual-identity): where an identity pass's
|
|
41
|
+
theme, content colours, artwork, logo, loading screen and sign-in live
|
|
42
|
+
- [Quality pass](/guide/framework/quality-pass): loading, empty, error and
|
|
43
|
+
refused states, edge cases and accessibility, checked by using the app
|
|
44
|
+
- [Data pass](/guide/framework/data-pass): query counts, constraints,
|
|
45
|
+
migrations and indexes at realistic sizes, on PostgreSQL and MySQL
|
|
40
46
|
- [Sanity checks](/guide/framework/sanity-checks): JSKIT's own pitfalls, and
|
|
41
47
|
the JSKIT calls that check data access, tests, a refactor, a screen or a
|
|
42
48
|
deployment before calling it done
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@local/main": "0.1.0",
|
|
36
36
|
"@fastify/static": "^10.1.3",
|
|
37
37
|
"@jskit-ai/kernel": "0.2.26",
|
|
38
|
-
"@jskit-ai/material-web": "0.1.
|
|
38
|
+
"@jskit-ai/material-web": "0.1.7",
|
|
39
39
|
"@tanstack/vue-query": "^5.101.0",
|
|
40
40
|
"fastify": "^5.12.7",
|
|
41
41
|
"pino": "^10.3.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@jskit-ai/config-eslint": "0.1.252",
|
|
53
|
-
"@jskit-ai/jskit-catalog": "0.2.
|
|
53
|
+
"@jskit-ai/jskit-catalog": "0.2.78",
|
|
54
54
|
"@playwright/test": "1.61.1",
|
|
55
55
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
56
56
|
"eslint": "^10.8.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@local/main": "0.1.0",
|
|
36
36
|
"@fastify/static": "^10.1.3",
|
|
37
37
|
"@jskit-ai/kernel": "0.2.26",
|
|
38
|
-
"@jskit-ai/material-web": "0.1.
|
|
38
|
+
"@jskit-ai/material-web": "0.1.7",
|
|
39
39
|
"@tanstack/vue-query": "^5.101.0",
|
|
40
40
|
"fastify": "^5.12.7",
|
|
41
41
|
"pino": "^10.3.1",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"vue-router": "^5.3.1",
|
|
46
46
|
"vuetify": "^4.3.0",
|
|
47
47
|
"@jskit-ai/http-runtime": "0.2.26",
|
|
48
|
-
"@jskit-ai/shell-web": "0.2.
|
|
48
|
+
"@jskit-ai/shell-web": "0.2.36",
|
|
49
49
|
"@fastify/fast-json-stringify-compiler": "^5.1.0",
|
|
50
50
|
"@vue/devtools-api": "^8.2.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@jskit-ai/config-eslint": "0.1.252",
|
|
54
|
-
"@jskit-ai/jskit-catalog": "0.2.
|
|
54
|
+
"@jskit-ai/jskit-catalog": "0.2.78",
|
|
55
55
|
"@playwright/test": "1.61.1",
|
|
56
56
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
57
57
|
"eslint": "^10.8.0",
|