@fabrika/app 0.9.0-dev.11 → 0.9.0-dev.13

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.
Files changed (46) hide show
  1. package/package.json +10 -10
  2. package/skill/SKILL.md +7 -5
  3. package/skill/references/app-setup.md +8 -8
  4. package/skill/references/endpoint.md +12 -4
  5. package/skill/references/files.md +11 -1
  6. package/skill/references/relations.md +558 -0
  7. package/skill/references/table-and-migration.md +30 -0
  8. package/src/contract/artifact-schema.ts +94 -5
  9. package/src/contract/build.ts +127 -34
  10. package/src/contract/compile.ts +1 -0
  11. package/src/contract/declaration.ts +8 -2
  12. package/src/contract/define.ts +18 -1
  13. package/src/contract/group.ts +12 -10
  14. package/src/contract/index.ts +2 -0
  15. package/src/contract/kit.ts +1 -0
  16. package/src/contract/platform.ts +1 -0
  17. package/src/contract/vocabulary.ts +3 -0
  18. package/src/dev/launcher.ts +14 -15
  19. package/src/dev/output.ts +8 -11
  20. package/src/files/kinds.ts +1 -1
  21. package/src/files/sniff.ts +18 -1
  22. package/src/files/treatment.ts +12 -10
  23. package/src/implement/boot.ts +33 -2
  24. package/src/implement/capability.ts +19 -4
  25. package/src/implement/client-address.ts +5 -71
  26. package/src/implement/dispatch.ts +117 -14
  27. package/src/implement/egress.ts +30 -12
  28. package/src/implement/implement.ts +7 -0
  29. package/src/implement/public.ts +3 -3
  30. package/src/jobs/report.ts +32 -5
  31. package/src/jobs/scrub.ts +1 -1
  32. package/src/testing/caller.ts +9 -2
  33. package/src/testing/endpoint-access.ts +2 -1
  34. package/src/testing/sample-file.ts +4 -1
  35. package/types/src/contract/declaration.d.ts +9 -1
  36. package/types/src/contract/define.d.ts +20 -1
  37. package/types/src/contract/group.d.ts +5 -3
  38. package/types/src/contract/index.d.ts +1 -0
  39. package/types/src/contract/vocabulary.d.ts +4 -1
  40. package/types/src/dev/output.d.ts +7 -6
  41. package/types/src/files/treatment.d.ts +4 -3
  42. package/types/src/implement/capability.d.ts +4 -4
  43. package/types/src/implement/client-address.d.ts +0 -5
  44. package/types/src/implement/dispatch.d.ts +11 -0
  45. package/types/src/implement/implement.d.ts +7 -0
  46. package/types/src/testing/caller.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/app",
3
- "version": "0.9.0-dev.11",
3
+ "version": "0.9.0-dev.13",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -105,18 +105,18 @@
105
105
  }
106
106
  },
107
107
  "scripts": {
108
- "typecheck": "tsc --noEmit",
108
+ "typecheck": "tsrs --build tsconfig.test.json",
109
109
  "test": "bun test --path-ignore-patterns='src/react/**' && bun test --isolate src/react"
110
110
  },
111
111
  "dependencies": {
112
- "@fabrika/auth": "0.9.0-dev.11",
113
- "@fabrika/auth-core": "0.9.0-dev.11",
114
- "@fabrika/db": "0.9.0-dev.11",
115
- "@fabrika/email": "0.9.0-dev.11",
116
- "@fabrika/jwks": "0.9.0-dev.11",
117
- "@fabrika/platform": "0.9.0-dev.11",
118
- "@fabrika/platform-node": "0.9.0-dev.11",
119
- "@fabrika/proxy-core": "0.9.0-dev.11",
112
+ "@fabrika/auth": "0.9.0-dev.13",
113
+ "@fabrika/auth-core": "0.9.0-dev.13",
114
+ "@fabrika/db": "0.9.0-dev.13",
115
+ "@fabrika/email": "0.9.0-dev.13",
116
+ "@fabrika/jwks": "0.9.0-dev.13",
117
+ "@fabrika/platform": "0.9.0-dev.13",
118
+ "@fabrika/platform-node": "0.9.0-dev.13",
119
+ "@fabrika/proxy-core": "0.9.0-dev.13",
120
120
  "altcha-lib": "2.6.0",
121
121
  "jose": "^5.9.0"
122
122
  },
package/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: fabrika-app
3
- version: 0.9.0-dev.11
3
+ version: 0.9.0-dev.13
4
4
  description: >
5
5
  How to write and change a Fabrika application: src/vocabulary.ts, db/migrations/, src/db/tables.ts, the
6
6
  slices' endpoints.ts with their handlers, fabrika.contract.ts, jobs, files, webhooks, share links, connectors
@@ -231,7 +231,7 @@ the access check. `references/spa.md` shows the stack.
231
231
  | a share link | `issues: '<link mount>'` | `ctx.links.issue` |
232
232
  | e-mail (a cron job only) | `mailer: 'installation'` | `ctx.mail.send` |
233
233
  | a file from a public procedure | `file('<kind>')` input, `admission` with `bytesPerHour` | a reference the handler writes into a file column |
234
- | an outside HTTPS API | `egress: ['https://api.example.com']` | `fetch` to exactly those origins |
234
+ | an outside HTTPS API | `egress: ['https://api.example.com']` | `fetch` to those (`https://*.<domain>`: one label) |
235
235
  | a signed link (unsubscribe) | `signs: ['<purpose>']` | `ctx.tokens.sign` |
236
236
  | a webhook binding | `binds: '<webhook>'` | `ctx.webhooks('<webhook>').bind` and `.unbind` |
237
237
  | a job run after the commit | `kicks: ['<job>']` | `ctx.kick('<job>')`, `ctx.kick('<job>', { at })` |
@@ -349,10 +349,12 @@ their errors, the caller, the components, routing, theming, screen tests), `tabl
349
349
  `ctx.url`, a mount's `compatibility`, another origin, members and labels), `tests.md` (generated tests, seeds, `testKit`, a reused scope, a caller's label, confirming a file ran),
350
350
  `errors.md` (checker findings, type errors, runtime answers), `dev.md` (the seed and the preview), `jobs.md` (which dimension `ctx.within` names, the UTC
351
351
  day, queue tables and `claim`, e-mail through `ctx.mail` with attachments and unsubscribe, the outbox and `kicks`),
352
- `files.md` and `webhooks-links-connectors.md`, all under `references/`. Two are applications of their own:
352
+ `files.md` and `webhooks-links-connectors.md`, all under `references/`. Three are applications of their own:
353
353
  `start.md`, a new application before its first table (its first test, adding the first table, installing and updating
354
- this skill), and `public-intake.md`, a public page, public procedures, a job that claims their rows, issues links and
355
- e-mails them, a link holder's files, HR's review with its history.
354
+ this skill), `public-intake.md`, a public page, public procedures, a job that claims their rows, issues links and
355
+ e-mails them, a link holder's files, HR's review with its history, and `relations.md`, access that rows of the
356
+ application grant and narrow (a relation, a role's `via`, a source table's `confers` and `assign`, a table's `when`
357
+ conditions, `readThrough`, `reveals` and `memberReveals`).
356
358
 
357
359
  ## Not built yet
358
360
 
@@ -19,20 +19,20 @@ the SPA is added with it.
19
19
  "test": "bun test --isolate"
20
20
  },
21
21
  "dependencies": {
22
- "@fabrika/app": "0.9.0-dev.11",
23
- "@fabrika/db": "0.9.0-dev.11",
24
- "@fabrika/provider-zerops": "0.9.0-dev.11",
25
- "@fabrika/proxy-core": "0.9.0-dev.11",
26
- "@fabrika/ui": "0.9.0-dev.11",
22
+ "@fabrika/app": "0.9.0-dev.13",
23
+ "@fabrika/db": "0.9.0-dev.13",
24
+ "@fabrika/provider-zerops": "0.9.0-dev.13",
25
+ "@fabrika/proxy-core": "0.9.0-dev.13",
26
+ "@fabrika/ui": "0.9.0-dev.13",
27
27
  "kysely": "0.29.6",
28
28
  "react": "^19.0.0",
29
29
  "react-dom": "^19.0.0",
30
30
  "zod": "^3.25.76"
31
31
  },
32
32
  "devDependencies": {
33
- "@fabrika/check": "0.9.0-dev.11",
34
- "@fabrika/cli": "0.9.0-dev.11",
35
- "@fabrika/platform": "0.9.0-dev.11",
33
+ "@fabrika/check": "0.9.0-dev.13",
34
+ "@fabrika/cli": "0.9.0-dev.13",
35
+ "@fabrika/platform": "0.9.0-dev.13",
36
36
  "@happy-dom/global-registrator": "^20.11.2",
37
37
  "@types/bun": "^1.4.3",
38
38
  "@types/react": "^19.0.0",
@@ -654,10 +654,18 @@ export const app = defineApp(vocabulary, tables, {
654
654
  ## Outside calls: `egress`
655
655
 
656
656
  A credentialed procedure, a webhook or a job that calls an outside HTTPS API declares its origins:
657
- `egress: ['https://api.example.com']`, exact origins, no path or wildcard, at most 16. `fetch` to any other origin is
658
- refused while the site runs (`capability_refused: undeclared_egress`). A public, link or export procedure declares
659
- none. The checker's `cross-app-fetch` accepts an absolute URL only under an origin some site declares. The approver
660
- sees every origin. The guard stops mistakes; it is no sandbox.
657
+ `egress: ['https://api.example.com']`, exact origins, no path, at most 16. `fetch` to any other origin is refused
658
+ while the site runs (`capability_refused: undeclared_egress`). A public, link or export procedure declares none. The
659
+ checker's `cross-app-fetch` accepts an absolute URL only under an origin some site declares. The approver sees every
660
+ origin. The guard stops mistakes; it is no sandbox.
661
+
662
+ A provider with one host per customer is one pattern: `egress: ['https://*.tenants.example.com']` reaches
663
+ `https://acme.tenants.example.com`, exactly one label in front of the domain, over `https` on the default port
664
+ (`https://*.tenants.example.com:8443` for another). It does not reach `a.b.tenants.example.com`,
665
+ `tenants.example.com` or `evil-tenants.example.com`. Write it in lower case and punycode, without a trailing dot; the
666
+ build names the spelling it wants. It refuses `http`, a second wildcard, and a wildcard on a public suffix (`*.com`,
667
+ `*.co.uk`). The checker accepts ``fetch(`https://${tenant}.tenants.example.com/v1`)`` under it. The approver reads a
668
+ pattern as every host under that domain, so prefer exact origins when there are a few.
661
669
 
662
670
  On Cloudflare a procedure waits for its outside call inside the object's transaction, so the whole environment waits
663
671
  with it (`SKILL.md`). A mutation records a row and kicks a job, which declares the `egress` and calls outside
@@ -70,7 +70,7 @@ task_attachments: {
70
70
  - A file column is `UUID REFERENCES fabrika_files (id)` with an index on it; the checker's `file-column-migration`
71
71
  verifies both for every column the policy names in `files`. `fabrika_files` is the framework's table: never write
72
72
  it.
73
- - A file kind (`c.files({ types, maxBytes, scan? })`) has no owner, no actions and no endpoint. The table's actions
73
+ - A file kind (`c.files({ types, maxBytes, scan?, inline? })`) has no owner, no actions and no endpoint. The table's actions
74
74
  are the file's authority, and the approver reads "`tasks.write` writes `task_attachments.file` (attachments)".
75
75
  - A file reaches what its row reaches, now: a moved task moves its files. Deleting the row (here with its task, by the
76
76
  cascade) or clearing a nullable column removes the reference; the framework's sweep deletes a file no column
@@ -159,6 +159,16 @@ export const attachments = app.group({ callers: ['human'] }, (r) => ({
159
159
  - A public image (a catalog picture in a page or an e-mail) is a public `GET` query with `http: { cache: 'immutable' }`
160
160
  whose input names the file as well as its row (`{ product, file }`), so a new image changes the URL. The handler
161
161
  refuses a file id that is not the row's.
162
+ - A download is an attachment (`Content-Disposition: attachment`); only `image/png`, `image/jpeg`, `image/gif` and
163
+ `image/webp` are shown inline. A file a machine reads at its URL (an RSS or Atom feed, a sitemap, an e-shop import)
164
+ is of a kind declared `inline: true`, e.g. `c.files({ types: ['application/rss+xml'], maxBytes: 1048576, inline: true })`,
165
+ served by a public `GET` query (`http: { path: '/feed.xml' }`). An inline kind admits only those images and
166
+ `application/xml`, `text/xml`, `application/rss+xml`, `application/atom+xml`; the build refuses SVG, HTML and every
167
+ other type there. Only `ctx.files.put` fills an inline kind, with a document the handler renders from checked data
168
+ (a feed built from rows, its text escaped), never bytes the caller sent or a file it opened: XML in the XHTML or SVG
169
+ namespace still renders as a page. The build refuses a procedure input of `file('<inline kind>')`; a user upload goes
170
+ into a kind without `inline`. An XML
171
+ file is UTF-8 whose bytes start with `<` (after a byte order mark and white space), or the upload is 415.
162
172
 
163
173
  The SPA calls them through the typed client, never a hand-written `fetch`. `api.attachments.download.url(input)` is
164
174
  the URL of a `GET` file procedure for a same-origin page (`<img src>`, `<a download>`), and