@astram/guide 0.2.15 → 0.2.17
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/CAPABILITIES.md +67 -0
- package/package.json +1 -1
package/CAPABILITIES.md
CHANGED
|
@@ -429,6 +429,73 @@ imports: [
|
|
|
429
429
|
- `actionsOf(reg)` (`@astram/guard`) returns a registration's vocabulary. `actionsFor(typeKey)`
|
|
430
430
|
is deprecated and returns only the CRUD verbs for every type.
|
|
431
431
|
|
|
432
|
+
## Permission labels and first-seen dates (G-027 step 1; engine 0.16, guard 0.23, identity 0.19)
|
|
433
|
+
- **Declare text for every action of your types**, CRUD included:
|
|
434
|
+
`@ObjectType({ ..., label: 'Weld repair rate value', permissions: { read: { label: 'Weld repair
|
|
435
|
+
rate: view', description: 'See the monthly repair rate per site.', caution: '…' }, … } })`.
|
|
436
|
+
`label` is the type's human name. Each `permissions` entry needs a `label`; `description` and
|
|
437
|
+
`caution` are optional (the caution is for a warning an administrator should read before
|
|
438
|
+
granting, e.g. "Give only to roles that see every site").
|
|
439
|
+
- Limits, checked at boot (`RegistrationError` naming the type, action and field): label 1–80
|
|
440
|
+
characters, description ≤ 255, caution ≤ 300 (after trimming), no control characters or line
|
|
441
|
+
breaks, and only actions the type declares (CRUD unless `crudActions: false`, plus `actions`).
|
|
442
|
+
An empty description or caution is refused: leave the field out instead.
|
|
443
|
+
- **No text ⇒ a generated label** `"<type label>: <verb>"` (read → view, create → create, update →
|
|
444
|
+
edit, delete → delete, a custom `manage_keys` → "manage keys"; the type label is `label` or the
|
|
445
|
+
type key with `_` → space), and boot logs ONE warning naming your keys with no declared label
|
|
446
|
+
and those with no description. The framework declares text for all of its own keys.
|
|
447
|
+
- **The catalog shows it**: `GET /identity/permission-catalog` rows carry `label`, `description`,
|
|
448
|
+
`caution`, `firstSeenAt` and `firstSeenVersion` (frontend-core `PermissionCatalogRow`; render
|
|
449
|
+
`label`, keep the raw `key` to a details view). `GET /identity/record-policies/schema` returns
|
|
450
|
+
the type `label`. The catalog reconcile (shortly after boot, then hourly) rewrites stored text
|
|
451
|
+
to match your code.
|
|
452
|
+
- **The text is visible to every tenant.** The catalog is one list for anyone who may read
|
|
453
|
+
roles, in every company. Never put customer, company or person names, or anything specific to
|
|
454
|
+
one tenant, in a label, description or caution.
|
|
455
|
+
- **First seen**: when the catalog first stores a key it records the date and `APP_RELEASE` (an
|
|
456
|
+
optional env value, 1–64 characters of letters, digits, `. _ + -`; a git tag or sha fits; an
|
|
457
|
+
invalid value stops boot; unset ⇒ date only). It is written once and never changed: a key
|
|
458
|
+
removed and added back keeps its first date. Keys already in the catalog when this release is
|
|
459
|
+
installed have no first-seen date. Set `APP_RELEASE` in your deploy (and `.env`).
|
|
460
|
+
- Two releases running side by side (a rolling deploy) each write their own text on reconcile,
|
|
461
|
+
so labels can alternate until the old instances stop. First-seen data is not affected.
|
|
462
|
+
- Text never grants anything: grants, the grant ceiling, wildcards and `decide()` are unchanged.
|
|
463
|
+
|
|
464
|
+
## In-app notifications (G-027 step 2; core 1.13, guard 0.24, identity 0.20)
|
|
465
|
+
- **One store, per user and company.** Each notice belongs to one user in one company. A user
|
|
466
|
+
reads only the notices of the company their session is in (`POST /auth/scope-switch` switches
|
|
467
|
+
the inbox). Read/unread state is kept per notice.
|
|
468
|
+
- **The user's own API** (session bearer, no grant needed; service-account keys get 401):
|
|
469
|
+
`GET /account/notifications?category=&unread=&page=&limit=` (newest first, `limit` ≤ 100,
|
|
470
|
+
`{ total, rows, page, limit }`), `GET /account/notifications/unread-count`
|
|
471
|
+
(`{ announcement, personal, total }`), `POST /account/notifications/:uuid/read` (204),
|
|
472
|
+
`POST /account/notifications/read-all?category=` (`{ updated }`). Another user's or company's
|
|
473
|
+
notice is a 404, like a missing one. Restricted sessions (re-enrolment, mandatory 2FA) get 403.
|
|
474
|
+
- **Register your kinds** once: `ShieldModule.forRoot({ notificationKinds: [{ kind:
|
|
475
|
+
'naes.import_review', category: 'personal' }] })`. A kind is dotted lower-case
|
|
476
|
+
(`^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$`, ≤ 64); `shield.` is reserved. A bad or duplicate entry
|
|
477
|
+
fails boot. `category` is `announcement` (release news, notices to many) or `personal`.
|
|
478
|
+
- **Post** with `NotificationService` (inject `SHIELD_NOTIFICATIONS` from `@astram/guard`):
|
|
479
|
+
`post({ tenantId, recipients, kind, title, body?, link?, dedupeKey? }, { query? })` ⇒
|
|
480
|
+
`{ created, skipped }`. `post` trusts its caller: take `tenantId` (and the recipients) from the
|
|
481
|
+
server side (the session, the record you just wrote), never from a request body or query.
|
|
482
|
+
Only active users with an active membership in `tenantId` receive it;
|
|
483
|
+
everyone else is skipped, not an error. `dedupeKey` (1–64 of `A–Z a–z 0–9 . _ : -`) makes a
|
|
484
|
+
retry safe: a repeat for the same user and company inserts nothing. Keys compare exactly (case
|
|
485
|
+
counts) and are shared by every kind, so put the kind in the key (`import_review:<id>`). Pass `{ query }` from an open
|
|
486
|
+
transaction to commit or roll back the notices with your write. An unregistered kind throws
|
|
487
|
+
`NotificationKindError`; bad text throws `NotificationValidationError` (names the field); a
|
|
488
|
+
database error throws `NotificationUnavailableError`.
|
|
489
|
+
- Limits: `title` 1–160 characters, `body` ≤ 1000 (line breaks allowed), `link` ≤ 512 and an
|
|
490
|
+
app-relative path (`/…`, no `//`, scheme or `\`), 1–1000 recipients per call; no control
|
|
491
|
+
characters. Notices are plain text: render them as text, never HTML.
|
|
492
|
+
- **Never put** passwords, tokens, keys, other users' data or full record payloads in a notice;
|
|
493
|
+
name only what concerns its recipient.
|
|
494
|
+
- Retention: read notices are deleted after `NOTIFICATION_READ_RETENTION_DAYS` (90), every notice
|
|
495
|
+
after `NOTIFICATION_MAX_RETENTION_DAYS` (365), counted from posting; an hourly job does it.
|
|
496
|
+
- Not yet: personal notices when a user's access changes (G-027 step 3), admin tasks for new
|
|
497
|
+
permissions (step 4), the frontend-core service and the scaffold bell (step 5), email delivery.
|
|
498
|
+
|
|
432
499
|
## Separation of duties (ADR-0048; core 1.12, engine 0.14, guard 0.21, identity 0.18)
|
|
433
500
|
- **Declare it on the type** when the people who started or asked about a record must not
|
|
434
501
|
approve it:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/guide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — the AI/dev GUIDE layer (ADR-0025). Ships the framework's hard rules + capabilities manifest as installed, upgrade-refreshed docs. A consumer app's CLAUDE.md references FRAMEWORK_RULES.md from this package; `npm update` replaces it wholesale so new rules arrive cleanly, while the app's own .astram/guide/ layer is never touched. This is the framework-owned FLOOR: an app rule may tighten it, never weaken it.",
|
|
6
6
|
"type": "commonjs",
|