@pexis/core 0.1.2 → 0.1.3
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/AGENTS.md +53 -10
- package/API.md +6 -5
- package/README.md +1 -1
- package/api.json +5951 -0
- package/dist/app.d.ts +77 -3
- package/dist/app.js +207 -31
- package/dist/app.js.map +1 -1
- package/dist/components.d.ts +54 -4
- package/dist/components.js +34 -3
- package/dist/components.js.map +1 -1
- package/dist/context.d.ts +27 -2
- package/dist/context.js +18 -2
- package/dist/context.js.map +1 -1
- package/dist/cors.d.ts +14 -0
- package/dist/cors.js +8 -0
- package/dist/cors.js.map +1 -1
- package/dist/csrf.d.ts +9 -0
- package/dist/csrf.js +9 -0
- package/dist/csrf.js.map +1 -1
- package/dist/form.d.ts +21 -3
- package/dist/form.js +38 -4
- package/dist/form.js.map +1 -1
- package/dist/host.d.ts +6 -1
- package/dist/host.js +6 -1
- package/dist/host.js.map +1 -1
- package/dist/html.d.ts +46 -5
- package/dist/html.js +112 -5
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.d.ts +32 -0
- package/dist/jsx-runtime.js +16 -0
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/page.d.ts +74 -1
- package/dist/page.js +48 -5
- package/dist/page.js.map +1 -1
- package/dist/rate-limit.d.ts +46 -0
- package/dist/rate-limit.js +19 -0
- package/dist/rate-limit.js.map +1 -1
- package/dist/registry.d.ts +126 -3
- package/dist/registry.js +53 -1
- package/dist/registry.js.map +1 -1
- package/dist/schema.d.ts +129 -3
- package/dist/schema.js +80 -7
- package/dist/schema.js.map +1 -1
- package/dist/security.d.ts +38 -2
- package/dist/security.js +44 -9
- package/dist/security.js.map +1 -1
- package/dist/styles.d.ts +37 -2
- package/dist/styles.js +32 -2
- package/dist/styles.js.map +1 -1
- package/dist/types.d.ts +163 -19
- package/dist/urls.d.ts +8 -1
- package/dist/urls.js +8 -1
- package/dist/urls.js.map +1 -1
- package/package.json +2 -1
package/AGENTS.md
CHANGED
|
@@ -12,7 +12,7 @@ These keep a Pexis site correct for people, search engines and agents at once. C
|
|
|
12
12
|
2. **No React-style state.** There are no hooks, no `useState`, no client state library, and components are plain functions that return markup. Data lives on the server and is loaded in a page's `load`.
|
|
13
13
|
3. **Every change goes through an action.** Anything that writes data or has an effect is a `defineAction`, in its own file in `actions/`, and shown with `<ActionForm>`. Never handle a form post in a custom route: actions are what agents, MCP clients, the OpenAPI description, rate limits and the admin's log all see.
|
|
14
14
|
4. **Permissions live on the action.** Give every action that changes data either `permission: (ctx) => ...` or `public: true`. A read action without `permission` can be called by anyone, which suits a search; give it a permission if what it returns is private. Hiding a button is not a permission check.
|
|
15
|
-
5. **Say how risky an action is.** `risk: 'read'` (safe to repeat; a GET form), `'write'`, or `'irreversible'` (always needs the person's approval). Add `confirm: true` when an agent must show the person the values before sending. Know what that guarantees: browser agents using the Pexis client show an approval dialog, and MCP clients can only reach the action through `@pexis/approvals`, but the JSON endpoint itself cannot tell whether a person approved, so a script can call it directly, as it could submit the form. Where approval must be certain, give the action a permission that needs the signed-in person, so only their own browser session can call it.
|
|
15
|
+
5. **Say how risky an action is.** `risk: 'read'` (safe to repeat; a GET form), `'write'`, or `'irreversible'` (always needs the person's approval; its form asks people too: the button opens a "cannot be undone" step holding the real submit button, with no script, and Enter in a field cannot skip it). Add `confirm: true` when an agent must show the person the values before sending. Know what that guarantees: browser agents using the Pexis client show an approval dialog, and MCP clients can only reach the action through `@pexis/approvals`, but the JSON endpoint itself cannot tell whether a person approved, so a script can call it directly, as it could submit the form. Where approval must be certain, give the action a permission that needs the signed-in person, so only their own browser session can call it.
|
|
16
16
|
6. **Content written by users is untrusted.** Render reviews, comments, posts and anything from another site inside `<Untrusted>`. Never put it in an action's title or description.
|
|
17
17
|
7. **Never `alert()`, `confirm()` or `prompt()`.** Use `<Dialog>` from `@pexis/components`.
|
|
18
18
|
8. **Styles with `css` and `globalCss`.** They carry the Content Security Policy nonce for you. An inline `<script>` or `<style>` written another way needs `nonce={ctx.nonce}`.
|
|
@@ -100,7 +100,7 @@ export default defineConfig({
|
|
|
100
100
|
- The module's pages are served under `base` (`modules/bookings/pages/index.tsx` is `/bookings`), and its actions are registered like any other.
|
|
101
101
|
- The same import rules apply inside a module.
|
|
102
102
|
- Another module is used only through its `index.ts`. `pexis check` warns (`structure/modules`) when one module imports another's files directly. To use another team's action, export it from their `index.ts` and run it with `ctx.call` (see "Using another team's action" below).
|
|
103
|
-
- Each `.sql` file in `migrations/` becomes a migration with the id `<module>.<file name>`. `pexis.gen.ts` exports them as `migrations`; pass them on with `data({ db, migrations
|
|
103
|
+
- Each `.sql` file in a module's `migrations/` becomes a migration with the id `<module>.<file name>`. `pexis.gen.ts` exports them with the app's own, after them, as `migrations`; pass them on with `data({ db, migrations })`.
|
|
104
104
|
|
|
105
105
|
Give each module folder an owner in CODEOWNERS, and `pexis.config.ts` to whoever owns the app.
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ Give each module folder an owner in CODEOWNERS, and `pexis.config.ts` to whoever
|
|
|
108
108
|
|
|
109
109
|
| Command | What it does |
|
|
110
110
|
|---|---|
|
|
111
|
-
| `npx pexis dev` | Runs the site at http://localhost:3000. Saving a file rebuilds, restarts and reloads open pages |
|
|
111
|
+
| `npx pexis dev` | Runs the site at http://localhost:3000 with the dev toolbar (`@pexis/devtools`, a dev dependency). Saving a file rebuilds, restarts and reloads open pages |
|
|
112
112
|
| `npx pexis check` | Builds, then runs every check on every page; exits 1 on errors |
|
|
113
113
|
| `npx pexis check --browser` | Also loads each page in Chromium for Core Web Vitals and color contrast (warnings). Needs `npm install --save-dev playwright` and `npx playwright install chromium` |
|
|
114
114
|
| `npx pexis build` | Production build in `.pexis/build` (`--target bun` or `--target cloudflare` for other hosts) |
|
|
@@ -151,13 +151,13 @@ export default definePage({
|
|
|
151
151
|
- `stream: true` (experimental) sends the head and the top of the layout as soon as `load` finishes, while slow async components on the page are still working. Put slow data in an async component, not in `load`, to benefit. Once streaming starts the status is 200, so an error after that shows a short message in the page and is logged.
|
|
152
152
|
- A page or action that takes more than 30 seconds gets 503 (`security.timeoutSeconds` changes it). Pass `ctx.signal` to `fetch()` and database calls, so they stop when the request does.
|
|
153
153
|
- Each page has one address: `/menu/` redirects to `/menu`, and a wrong method gets 405 with the methods that work.
|
|
154
|
+
- Typed links: `import { to } from '../pexis.gen.js'` and write `<a href={to('/menu/:dish', { dish: d.slug })}>`. A link to a page that was renamed or removed, or one missing a parameter, fails to compile; values are encoded for you. `to` covers pages in `pages/` and modules; links in layouts stay plain strings, since layouts never import pages.
|
|
154
155
|
|
|
155
156
|
## Layout and styles
|
|
156
157
|
|
|
157
158
|
```tsx
|
|
158
159
|
// app.tsx
|
|
159
160
|
import { createApp, css, defineLayout, globalCss } from '@pexis/core';
|
|
160
|
-
import { devtools } from '@pexis/devtools';
|
|
161
161
|
import { markdown } from '@pexis/markdown';
|
|
162
162
|
import { openapi } from '@pexis/openapi';
|
|
163
163
|
import { siteFiles } from '@pexis/site-files';
|
|
@@ -195,12 +195,25 @@ export default createApp({
|
|
|
195
195
|
styles: [base],
|
|
196
196
|
pages,
|
|
197
197
|
actions,
|
|
198
|
-
plugins: [markdown(), openapi(), siteFiles()
|
|
198
|
+
plugins: [markdown(), openapi(), siteFiles()],
|
|
199
199
|
});
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
`css` styles are scoped to where they are used and only sent with pages that use them.
|
|
203
203
|
|
|
204
|
+
### Tailwind, or any stylesheet
|
|
205
|
+
|
|
206
|
+
`css` is one way to style, not the only one. Any CSS you build into a file in `public/` works, Tailwind included, and the Content Security Policy already allows stylesheets from your own site. Link it from every page with a three-line plugin:
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { definePlugin, html } from '@pexis/core';
|
|
210
|
+
|
|
211
|
+
// In plugins: [stylesheet('/app.css'), ...]
|
|
212
|
+
const stylesheet = (href: string) => definePlugin({ name: 'stylesheet', setup: (api) => api.head(() => html`<link rel="stylesheet" href="${href}">`) });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
With Tailwind, build `public/app.css` with its command, in a second terminal beside `pexis dev`, and use its classes in `class`: `npx @tailwindcss/cli -i styles/app.css -o public/app.css --watch`. Before deploying, build it once without `--watch`, so the file exists when `pexis build` copies `public/`. Inline `style="…"` attributes work too.
|
|
216
|
+
|
|
204
217
|
## Actions
|
|
205
218
|
|
|
206
219
|
```tsx
|
|
@@ -233,6 +246,8 @@ export default defineAction({
|
|
|
233
246
|
|
|
234
247
|
(`invalid` is imported from `@pexis/core` too.) A refused call gets 422 with the errors; a person sees the form again with each message under its field. A JSON call with a field the action does not have is refused the same way, so a misspelled optional field is never silently dropped.
|
|
235
248
|
|
|
249
|
+
A result can carry one link with its message, such as the page for what was just made: `return { message: 'Launched.', link: { href: `/launches/${id}`, text: 'See the launch report' } }`. People see it with the message, in place too; agents get it as an absolute URL. Only a path or a URL on the site's own origin is kept; anything else is dropped and logged.
|
|
250
|
+
|
|
236
251
|
By default a submitted form loads a new page: a simple page with the action's `message` and a link back to the page the form was on. That is deliberate, so every form works without JavaScript. For the result to appear in place, without leaving the page, wrap the form in a `<Region>`, give the form a `target` naming it, and add `inPlace()` (see [Updating part of the page](#updating-part-of-the-page)). The `agents/target-region` and `agents/in-place-script` checks warn when a target has no region around it, or the page has no script to use it.
|
|
237
252
|
|
|
238
253
|
| Field | Options (all take `label`, `description` for people and agents, and `optional`) |
|
|
@@ -241,9 +256,10 @@ By default a submitted form loads a new page: a simple page with the action's `m
|
|
|
241
256
|
| `field.integer`, `field.number` | `min`, `max` |
|
|
242
257
|
| `field.date` | `min`, `max` as `YYYY-MM-DD` |
|
|
243
258
|
| `field.choice` | `options: [{ value, label }]`; agents send the value |
|
|
259
|
+
| `field.choices` | any number of `options: [{ value, label }]`, as checkboxes; the value is a list of the checked values, `[]` when none is checked, so it is never required |
|
|
244
260
|
| `field.boolean` | a checkbox: unchecked is `false`, so it is never required |
|
|
245
261
|
|
|
246
|
-
Show it on a page with `import bookTable from '../actions/book_table.js'` and `<ActionForm action={bookTable} />`. The same definition is the HTML form, the agent tool at `/pexis/actions.json
|
|
262
|
+
Show it on a page with `import bookTable from '../actions/book_table.js'` and `<ActionForm action={bookTable} />`. The same definition is the HTML form, the agent tool at `/pexis/actions.json` (which every page names in a `Link` header, so agents find it without reading a page), the JSON endpoint `POST /actions/book_table`, and an OpenAPI operation. An action with `input: {}` is a single button. Field kinds: `field.text`, `integer`, `number`, `date`, `choice`, `choices`, `boolean`; more (time, radio, amount, color, range) in `@pexis/components` as `inputs.*`. Never ask for passwords or files in an action.
|
|
247
263
|
|
|
248
264
|
A search or lookup is `risk: 'read'`: it becomes a GET form, and agents may call it without asking.
|
|
249
265
|
|
|
@@ -271,7 +287,7 @@ On submit, a small script (sent only to pages with a region) sends the same form
|
|
|
271
287
|
- The region must contain the form, and a region id must be unique on the page. Regions belong in a page's `render`, not in a layout.
|
|
272
288
|
- The page renders again through the app's own `middleware`, as a visit to it would, so a page that middleware guards stays guarded. Plugin middleware is not run again: the session and the database are the ones the action used.
|
|
273
289
|
- While a request is out the region has `aria-busy="true"`: style `[aria-busy="true"]` to show it is working. The message has the class `px-result`.
|
|
274
|
-
- People-only actions (`agents: false`, staff actions included) refuse a target: they need a real page submission.
|
|
290
|
+
- People-only actions (`agents: false`, staff actions included) refuse a target: they need a real page submission. After one works, the person is sent back to the page the form was on, which shows the message (and the result's link) once at the top, focused, with no script. The message travels in a short-lived cookie, never the URL. Without a page of the site to go back to, the full result page is shown, as for other actions.
|
|
275
291
|
- The reply brings no styles of its own: use the same `css` classes as the page.
|
|
276
292
|
|
|
277
293
|
### Using another team's action: `ctx.call`
|
|
@@ -341,7 +357,6 @@ Add each to `plugins` in `createApp`. Each is one line, and none turns itself on
|
|
|
341
357
|
| Markdown copies of pages for AI readers | `markdown()` | `@pexis/markdown` |
|
|
342
358
|
| robots.txt and sitemap.xml | `siteFiles()` | `@pexis/site-files` |
|
|
343
359
|
| An OpenAPI description of the actions | `openapi()` | `@pexis/openapi` |
|
|
344
|
-
| The dev toolbar and reload on save | `devtools()` | `@pexis/devtools` |
|
|
345
360
|
| Sessions and `ctx.user` | `sessions()` | `@pexis/sessions` |
|
|
346
361
|
| Sign-in with Google, Microsoft, GitHub, Apple or any OpenID provider | `auth({ providers })`, after `sessions()` | `@pexis/auth` |
|
|
347
362
|
| A database at `ctx.db` | `data({ db, migrations })` | `@pexis/data` |
|
|
@@ -356,19 +371,24 @@ Add each to `plugins` in `createApp`. Each is one line, and none turns itself on
|
|
|
356
371
|
|
|
357
372
|
### Data
|
|
358
373
|
|
|
374
|
+
Migrations are SQL files in `migrations/`, such as `migrations/001-bookings.sql`. Each file is one migration, its id is the file name, and they run in name order, before modules' migrations. `pexis.gen.ts` exports them all as `migrations`. The database records each one it has run in a `pexis_migrations` table, by id, so each runs once, and two people adding migrations on separate branches don't collide. Never edit a migration that has run; add a new file. Another folder: `defineConfig({ migrations: 'db/migrations', sources: [...] })`.
|
|
375
|
+
|
|
359
376
|
```ts
|
|
360
377
|
import { data, sql } from '@pexis/data';
|
|
361
378
|
import { connect } from '@pexis/data/connect';
|
|
379
|
+
import { migrations } from './pexis.gen.js';
|
|
362
380
|
|
|
363
381
|
// file:data.db (SQLite, built in), postgres://, mysql:// or libsql://. Install only that database's client.
|
|
364
382
|
const db = await connect(process.env.DATABASE_URL ?? 'file:data.db');
|
|
365
|
-
// plugins: [data({ db, migrations
|
|
383
|
+
// plugins: [data({ db, migrations })]
|
|
366
384
|
|
|
367
385
|
// In load() or run(): every ${value} is a bound parameter, never pasted into the SQL.
|
|
368
386
|
await ctx.db.run(sql`INSERT INTO bookings (name) VALUES (${input.name})`);
|
|
369
387
|
const rows = await ctx.db.all(sql`SELECT name FROM bookings ORDER BY id DESC`);
|
|
370
388
|
```
|
|
371
389
|
|
|
390
|
+
**Another database library works too.** `load()` and `run()` are plain TypeScript, so Drizzle, Prisma, Kysely or any database client can do the queries: create the client once in `lib/`, import it, and call it, as in any Node app. Pexis's own `sql` is one option, not a requirement. The shared stores for sessions, rate limits, approvals and the rest still come from `@pexis/data`, so an app on several servers also gives `connect(process.env.DATABASE_URL)` to those stores; both can use the same database. On serverless hosts, use the library's HTTP or pooled driver, as you would elsewhere.
|
|
391
|
+
|
|
372
392
|
Search, experimental: `searchIndex(db, { name: 'menu' })` from `@pexis/data` finds documents by their words on every database. Give it an embedder (`await loadEmbedder(configFromEnv(process.env, 'PEXIS_AI_EMBED'))` from `@pexis/ai`) and it also finds by meaning ("something warm" finds the soup), falling back to words if the model is down. Each hit says whether it matched by words, meaning or both.
|
|
373
393
|
|
|
374
394
|
```ts
|
|
@@ -593,7 +613,30 @@ npx pexis build --target cloudflare # Workers: prints the wrangler.toml lines
|
|
|
593
613
|
- Behind a load balancer, set `PEXIS_TRUSTED_PROXIES` to the number of proxies, or rate limits see the proxy's address.
|
|
594
614
|
- Several servers share sessions, rate limits, approvals, model budgets and the audit log through `@pexis/data` stores (`sessionStore(db)` and the others). Lambda, Cloud Run, Workers and most containers run several servers, or replace them often. In production, the app warns at startup about anything still kept in one server's memory, and says which store to add. An app that really runs as one long-lived server can set `PEXIS_SINGLE_INSTANCE=1` to turn the warning off.
|
|
595
615
|
- Sign-in with `auth()` works on any number of servers: the sign-in in progress is kept in the browser's own cookie, not in a server's memory.
|
|
596
|
-
- Secrets (`PEXIS_ADMIN_PASSWORD`, provider keys) and the staff list (`PEXIS_ADMIN_STAFF`) come from the environment, never the code.
|
|
616
|
+
- Secrets (`PEXIS_ADMIN_PASSWORD`, provider keys) and the staff list (`PEXIS_ADMIN_STAFF`) come from the environment, never the code. In development, `pexis dev` and `pexis check` read `.env` and then `.env.local` from the app's folder (both are in the starter's `.gitignore`; a variable set in your shell wins). In production the host sets them; no file is read.
|
|
617
|
+
|
|
618
|
+
### Adding Pexis to an existing site
|
|
619
|
+
|
|
620
|
+
A site does not have to start over to use Pexis. Mount the Pexis app inside the server you already run: Pexis answers the requests it has a route for (its pages, `/actions/...`, `/pexis/...` and files in `public/`), and everything else goes on to your existing app.
|
|
621
|
+
|
|
622
|
+
```ts
|
|
623
|
+
// An existing Express (or Connect) server
|
|
624
|
+
import { toNodeHandler } from '@pexis/node';
|
|
625
|
+
import app from './pexis/app.js'; // createApp({ origin, pages, actions, ... })
|
|
626
|
+
|
|
627
|
+
server.use(toNodeHandler(app, { publicDir: 'pexis/public' })); // before any body parser
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
On a server built on web-standard requests (Hono, Bun, Deno, a Next.js route handler), ask the app first, then hand it the request:
|
|
631
|
+
|
|
632
|
+
```ts
|
|
633
|
+
// Hono
|
|
634
|
+
honoApp.all('*', (c, next) => (app.matches(c.req.raw) ? app.fetch(c.req.raw) : next()));
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
- Mount it before body parsers such as `express.json()`: Pexis reads the body itself, with its own limits.
|
|
638
|
+
- Give Pexis pages paths your site does not already use, such as `/book`; `files({ base: '/book' })` in `pexis.config.ts` puts a whole folder under one path. Actions are always at `/actions/<name>`, so keep that path free.
|
|
639
|
+
- `origin` in `createApp` is the site's public address. The Node handler answers only that host and localhost (add others with `allowedHosts`), and sets the client's address for rate limits, with `trustedProxies` behind a proxy as for `serve()`.
|
|
597
640
|
|
|
598
641
|
### Splitting a site into separately deployed areas
|
|
599
642
|
|
package/API.md
CHANGED
|
@@ -13,7 +13,7 @@ Every export of `@pexis/core`. For how to use them together, read the guide, `pa
|
|
|
13
13
|
| Export | What it is |
|
|
14
14
|
|---|---|
|
|
15
15
|
| `createApp(options)` | Builds the app: pages, actions, layout, plugins, security and navigation options, error pages. Returns an `App` with `fetch(request, connection?)`. |
|
|
16
|
-
| `App` | The app: `fetch`, `config`, `pages`, `actions`, `entries()`, `checkRules
|
|
16
|
+
| `App` | The app: `fetch`, `config`, `pages`, `actions`, `entries()`, `checkRules`, and `matches(request)`: whether one of its pages, actions or plugin routes answers the request, for mounting Pexis inside another server. |
|
|
17
17
|
| `AppOptions` | The options `createApp` takes. |
|
|
18
18
|
| `AppConfig` | The settings plugins and checks read: `origin`, `lang`, `checks`. |
|
|
19
19
|
| `NavigationOptions` | View Transitions and Speculation Rules (`prefetch`), both off by default. |
|
|
@@ -43,10 +43,11 @@ Every export of `@pexis/core`. For how to use them together, read the guide, `pa
|
|
|
43
43
|
|---|---|
|
|
44
44
|
| `defineAction(definition)` | An action: `name`, `title`, `description`, `input`, `risk`, `confirm`, `public` or `permission`, `agents`, `run`, and `undo` (experimental: how a person reverses this write when an agent made it). |
|
|
45
45
|
| `invalid(errors)` | From `run`: refuse values with a message per field (422, and the form shown again). |
|
|
46
|
-
| `field` | Field kinds: `field.text`, `integer`, `number`, `date`, `choice`, `boolean`. |
|
|
46
|
+
| `field` | Field kinds: `field.text`, `integer`, `number`, `date`, `choice`, `choices`, `boolean`. |
|
|
47
47
|
| `defineFieldKind(kind)` | A new kind of field that renders a standard control and parses its value. |
|
|
48
48
|
| `Action`, `ActionDefinition`, `ActionContext`, `ActionResult`, `Invalid`, `Risk` | The types of an action, what it receives and what `run` returns. |
|
|
49
|
-
| `
|
|
49
|
+
| `ResultLink` | `{ href, text }`: the one link a result may carry, shown with the message. Only a path or a URL on the app's own origin is kept; anything else is dropped and logged. |
|
|
50
|
+
| `Field`, `Fields`, `FieldBase`, `TextField`, `IntegerField`, `NumberField`, `DateField`, `ChoiceField`, `ChoicesField`, `ChoiceOption`, `BooleanField`, `CustomField`, `FieldKind`, `ControlProps` | The types of fields and field kinds. |
|
|
50
51
|
| `Infer` | The typed input an action's `run` receives, from its fields. |
|
|
51
52
|
| `validate(fields, input)` | Checks input against fields, as the server does on every call. |
|
|
52
53
|
| `ValidationResult` | What `validate` returns. |
|
|
@@ -66,7 +67,7 @@ Every export of `@pexis/core`. For how to use them together, read the guide, `pa
|
|
|
66
67
|
|
|
67
68
|
| Export | What it is |
|
|
68
69
|
|---|---|
|
|
69
|
-
| `html` | Tagged template for HTML without JSX; every value is escaped, and `javascript:` URLs are blocked. |
|
|
70
|
+
| `html` | Tagged template for HTML without JSX; every value is escaped, and `javascript:` URLs are blocked. Like JSX, it refuses values where escaping does not protect them: event handler attributes, unquoted attribute values, between attributes, inside `<script>` and `<style>`, and `srcdoc` (trusted markup from `raw()` or `html` is allowed except in event handlers). |
|
|
70
71
|
| `raw(html)` | Marks markup you wrote yourself as trusted. Never for user or model content. |
|
|
71
72
|
| `escapeHtml(text)` | Escapes text for HTML. |
|
|
72
73
|
| `SafeHtml`, `Markup`, `Child` | Trusted markup, what components return, and what JSX children can be. |
|
|
@@ -93,7 +94,7 @@ Every export of `@pexis/core`. For how to use them together, read the guide, `pa
|
|
|
93
94
|
| `agentRefusal(agent, action)` | Why an agent may not run an action (needs approval, people only, or outside its scopes), or null. The core applies it to every agent request; for plugins that list or stage actions. Experimental. |
|
|
94
95
|
| `UndoDefinition` | An action's `undo`: the registered `action` that reverses it, an `input(input, result)` function returning its input (or null when nothing changed), and `hours` (default 24, at most 168). Experimental. |
|
|
95
96
|
| `AgentWrite`, `AgentWriteRecorder` | An agent's undoable write, and the one recorder an app installs with `api.recordAgentWrites()` (`@pexis/approvals` does). Experimental. |
|
|
96
|
-
| `CallResult` | What `ctx.call(action, input)` returns: `{ ok: true, message, data }`, or `{ ok: false, outcome, message }` with `errors` when the outcome is `invalid`. Experimental. |
|
|
97
|
+
| `CallResult` | What `ctx.call(action, input)` returns: `{ ok: true, message, data, link? }`, or `{ ok: false, outcome, message }` with `errors` when the outcome is `invalid`. Experimental. |
|
|
97
98
|
| `peekContext()` | The current request's context, or undefined outside a request; never throws. For plugins such as telemetry that run code which may or may not be in a request. |
|
|
98
99
|
| `getContext()` | The current request's context, from anywhere in the request. |
|
|
99
100
|
| `RouteMatch` | What `ctx.route` holds: the page, action or route matched. |
|
package/README.md
CHANGED
|
@@ -37,4 +37,4 @@ Uses only web-standard APIs (`Request`, `Response`, `fetch`, streams), so it run
|
|
|
37
37
|
- The guide for building with Pexis: [`AGENTS.md` in the `@pexis/core` package](https://github.com/pexis-dev/pexis/blob/main/packages/core/AGENTS.md)
|
|
38
38
|
- Source, issues and the other packages: https://github.com/pexis-dev/pexis
|
|
39
39
|
|
|
40
|
-
MIT licensed. Part of [Pexis](https://github.com/pexis-dev/pexis/blob/main/README.md), by Intelligant AI.
|
|
40
|
+
MIT licensed. Part of [Pexis](https://github.com/pexis-dev/pexis/blob/main/README.md), by Intelligant AI.
|