@ultimat3/action 31.22.1 → 31.23.0

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/README.md CHANGED
@@ -198,7 +198,9 @@ A `<form method="post">` (scripting off, or the client router's submit) to an ac
198
198
  `X_UNAUTHENTICATED`, which keeps the sign-in redirect — to
199
199
  `refusal(refusal)`, else a `Referer` on this host. The outcome rides in a one-read flash cookie:
200
200
  the action, and for a refusal its `code` and each issue's `path`/`rule`/`params`, never a value.
201
- The next page reads it once, in `load`, with `useActionAnswer(action | name?)`. A `fetch`, the typed
201
+ The next page reads it once, in `load`, with `useActionAnswer(action | name?)` — `null` with no
202
+ request at all (the `llms.txt` build runs `load` with none); inside a context derived from a
203
+ request it is `X_NO_REQUEST`, never a `null` that leaves the flash set. A `fetch`, the typed
202
204
  client, MCP and `.job()` are answered exactly as before. A `page.tsx` form posting to an action
203
205
  with no `native` is an `X_NATIVE_FORM_UNANSWERED` warning on `main` at `x verify` (the
204
206
  `manifest` step), a refusal planned for `next`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/action",
3
- "version": "31.22.1",
3
+ "version": "31.23.0",
4
4
  "description": "The action primitive: one declaration projected to route, OpenAPI, client, MCP tool, job handle, tests",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -48,13 +48,13 @@
48
48
  "test": "bun test"
49
49
  },
50
50
  "dependencies": {
51
- "@ultimat3/cache": "31.22.1",
52
- "@ultimat3/core": "31.22.1",
53
- "@ultimat3/db": "31.22.1",
54
- "@ultimat3/entity": "31.22.1",
55
- "@ultimat3/http": "31.22.1",
56
- "@ultimat3/policy": "31.22.1",
57
- "@ultimat3/schema": "31.22.1",
58
- "@ultimat3/storage": "31.22.1"
51
+ "@ultimat3/cache": "31.23.0",
52
+ "@ultimat3/core": "31.23.0",
53
+ "@ultimat3/db": "31.23.0",
54
+ "@ultimat3/entity": "31.23.0",
55
+ "@ultimat3/http": "31.23.0",
56
+ "@ultimat3/policy": "31.23.0",
57
+ "@ultimat3/schema": "31.23.0",
58
+ "@ultimat3/storage": "31.23.0"
59
59
  }
60
60
  }
@@ -2,7 +2,7 @@
2
2
  // projection (`native-answer.ts`) and read once by the page that follows (`useActionAnswer`). Both
3
3
  // halves live here so the wire shape has one owner: the writer and the reader cannot drift.
4
4
 
5
- import { deleteCookie, setCookie, useRequestCookie } from '@ultimat3/http';
5
+ import { deleteCookie, hasRequest, setCookie, useRequestCookie } from '@ultimat3/http';
6
6
  import type { SchemaIssueParams } from '@ultimat3/schema';
7
7
  import { issueRuleFacts } from '@ultimat3/schema';
8
8
  import type { AnyAction } from './action';
@@ -90,15 +90,24 @@ export function parseActionAnswer(raw: string | null): ActionAnswer | null {
90
90
  return { action, outcome, code, issues, truncated: Reflect.get(value, 'truncated') === true };
91
91
  }
92
92
 
93
+ /**
94
+ * The flash cookie of the request in scope. With no request at all (the `llms.txt` pass running a
95
+ * `load`, a job, a task) nobody submitted a form: `null`. A scope derived inside a request is still
96
+ * that request, so it refuses (`X_NO_REQUEST`) rather than answer `null` and leave the flash set.
97
+ */
98
+ const answerCookie = (): string | null =>
99
+ hasRequest() ? useRequestCookie(ACTION_ANSWER_COOKIE) : null;
100
+
93
101
  /**
94
102
  * The answer the last native form submission left, read ONCE: the cookie is cleared on read.
95
103
  * Call it from a route's `load` — a header after a stream's first flush is refused. Given an
96
104
  * action, only that action's answer: two forms on one page do not read each other's outcome. A
97
105
  * page that may not import the action (`app/` → `api/`) names it: `'createPost' satisfies keyof
98
- * Api['actions']`. `null` on a `static`/`isr` page, which is rendered as nobody and sees no cookie.
106
+ * Api['actions']`. `null` on a `static`/`isr` page, which is rendered as nobody and sees no cookie,
107
+ * and `null` outside a request: nobody submitted a form there.
99
108
  */
100
109
  export function useActionAnswer(target?: AnyAction | string): ActionAnswer | null {
101
- const answer = parseActionAnswer(useRequestCookie(ACTION_ANSWER_COOKIE));
110
+ const answer = parseActionAnswer(answerCookie());
102
111
  if (answer === null) return null;
103
112
  const name = typeof target === 'string' || target === undefined ? target : actionName(target);
104
113
  if (name !== undefined && answer.action !== name) return null;