@ultimat3/action 31.58.0 → 31.60.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/CLAUDE.md +1 -1
- package/README.md +7 -1
- package/package.json +9 -9
- package/src/action-answer.ts +16 -2
- package/src/index.ts +1 -1
- package/src/native-answer.ts +20 -1
package/CLAUDE.md
CHANGED
|
@@ -38,7 +38,7 @@ Owns the `action` + `mutator` primitives and five projections. Tier 3. The MCP t
|
|
|
38
38
|
| `audit-subject-target.ts` | `auditSubjectTarget()`: `x_audit` as a subject-erase target — overwrites who acted and the input, never deletes the row |
|
|
39
39
|
| `transition.ts` | `transition()`: a MUTATOR factory over one entity column's state machine. Declares no error code — entity's three propagate |
|
|
40
40
|
| `upload-flow.ts` | `uploadFlow()`: an ACTION factory, `{ request, confirm }` over storage's `grantUpload` (pending only) and `promoteAttachment`. No code of its own |
|
|
41
|
-
| `native-answer.ts`, `action-answer.ts` | `native:` — a form POST's 303 + one-read flash (`useActionAnswer`); HTTP projection only |
|
|
41
|
+
| `native-answer.ts`, `action-answer.ts` | `native:` — a form POST's 303 + one-read flash (`useActionAnswer`, `useSubmissionId`; the id is `ctx.submission.id` in the handler); HTTP projection only |
|
|
42
42
|
| — | opt-in flight control is **`@ultimat3/core`**'s `client-flight.ts` + `client-wire.ts`, imported from core — `src/index.ts` re-exports only the `ClientFlight`/`ClientRetry` types. There is no local copy and must not be one |
|
|
43
43
|
| `job-handle.ts` | the `.job()` projection: an action as a queueable payload. **Not** consumed by `@ultimat3/jobs` — see Invariants |
|
|
44
44
|
| `contract-test.ts` | assertions `x g action` emits |
|
package/README.md
CHANGED
|
@@ -242,7 +242,13 @@ the action, and for a refusal its `code` and each issue's `path`/`rule`/`params`
|
|
|
242
242
|
The next page reads it once, in `load`, with `useActionAnswer(action | name?)` — `null` with no
|
|
243
243
|
request at all (the `llms.txt` build runs `load` with none); inside a context derived from a
|
|
244
244
|
request it is `X_NO_REQUEST`, never a `null` that leaves the flash set. A `fetch`, the typed
|
|
245
|
-
client, MCP and `.job()` are answered exactly as before.
|
|
245
|
+
client, MCP and `.job()` are answered exactly as before. The post's id is handed on, so an app can
|
|
246
|
+
key its own per-submission state to it: `ctx.submission?.id` in `handle` (absent for any call that
|
|
247
|
+
is not a native post) and `refusal.submission` in `native.refusal`. When the post lands on a path on
|
|
248
|
+
this site the same id is the redirect's `?x_answer=<id>` and the flash cookie's suffix, and
|
|
249
|
+
`useSubmissionId()` reads it on the page, clearing nothing; a landing on another origin carries
|
|
250
|
+
neither the id nor a flash, so only the handler and the refusal see it. The page reader needs the
|
|
251
|
+
request's own context, as `useActionAnswer` does: inside a scope derived from it, it is `X_NO_REQUEST`. A `page.tsx` form posting to an action
|
|
246
252
|
with no `native` is an `X_NATIVE_FORM_UNANSWERED` warning on `main` at `x verify` (the
|
|
247
253
|
`manifest` step), a refusal planned for `next`.
|
|
248
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/action",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.60.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.
|
|
52
|
-
"@ultimat3/core": "31.
|
|
53
|
-
"@ultimat3/db": "31.
|
|
54
|
-
"@ultimat3/entity": "31.
|
|
55
|
-
"@ultimat3/http": "31.
|
|
56
|
-
"@ultimat3/policy": "31.
|
|
57
|
-
"@ultimat3/schema": "31.
|
|
58
|
-
"@ultimat3/storage": "31.
|
|
51
|
+
"@ultimat3/cache": "31.60.0",
|
|
52
|
+
"@ultimat3/core": "31.60.0",
|
|
53
|
+
"@ultimat3/db": "31.60.0",
|
|
54
|
+
"@ultimat3/entity": "31.60.0",
|
|
55
|
+
"@ultimat3/http": "31.60.0",
|
|
56
|
+
"@ultimat3/policy": "31.60.0",
|
|
57
|
+
"@ultimat3/schema": "31.60.0",
|
|
58
|
+
"@ultimat3/storage": "31.60.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/action-answer.ts
CHANGED
|
@@ -192,11 +192,25 @@ export function parseActionAnswer(raw: string | null): ActionAnswer | null {
|
|
|
192
192
|
* `null`. A scope derived inside a request is still that request, so it refuses (`X_NO_REQUEST`)
|
|
193
193
|
* rather than answer `null` and leave the flash set.
|
|
194
194
|
*/
|
|
195
|
-
|
|
195
|
+
function submissionOf(): string | null {
|
|
196
196
|
if (!hasRequest()) return null;
|
|
197
197
|
const id = useRequestContext().url.searchParams.get(ACTION_ANSWER_PARAM);
|
|
198
198
|
return id !== null && SUBMISSION_ID.test(id) ? id : null;
|
|
199
|
-
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The id of the native submission this page follows, or `null`: the `x_answer` its URL carries, the
|
|
203
|
+
* same value the handler saw as `ctx.submission.id` and `native.refusal` as `refusal.submission`.
|
|
204
|
+
* It is how a page reads app state keyed to a submission (a typed-values echo) without a second id
|
|
205
|
+
* or query parameter of its own. Unlike `useActionAnswer` it reads and clears nothing, so a page may
|
|
206
|
+
* ask any number of times. `null` for a URL with no id or one that is not an id's shape, and outside
|
|
207
|
+
* a request. It reads the request's URL, so like `useActionAnswer` it needs the request's own
|
|
208
|
+
* context: inside a scope derived from it (`withChildContext`) it is `X_NO_REQUEST`, not `null`. Nothing proves the framework minted the id (a URL can name any), so state keyed to it
|
|
209
|
+
* is a hint for the page to draw, never an authenticated fact.
|
|
210
|
+
*/
|
|
211
|
+
export function useSubmissionId(): string | null {
|
|
212
|
+
return submissionOf();
|
|
213
|
+
}
|
|
200
214
|
|
|
201
215
|
/**
|
|
202
216
|
* The answer the last native form submission left, read ONCE: the cookie is cleared on read.
|
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type {
|
|
|
41
41
|
} from './action';
|
|
42
42
|
export { action, describeAction, isAction } from './action';
|
|
43
43
|
export type { ActionAnswer, ActionAnswerIssue } from './action-answer';
|
|
44
|
-
export { ACTION_ANSWER_COOKIE, useActionAnswer } from './action-answer';
|
|
44
|
+
export { ACTION_ANSWER_COOKIE, useActionAnswer, useSubmissionId } from './action-answer';
|
|
45
45
|
export type { ActionDecide, ActionDecision, ActionRowDenial } from './action-decide';
|
|
46
46
|
export type {
|
|
47
47
|
ActionDecideArgs,
|
package/src/native-answer.ts
CHANGED
|
@@ -14,6 +14,15 @@ export interface ActionRefusal {
|
|
|
14
14
|
readonly code: string;
|
|
15
15
|
readonly status: number;
|
|
16
16
|
readonly issues: readonly ActionAnswerIssue[];
|
|
17
|
+
/**
|
|
18
|
+
* This post's submission id: the one `ctx.submission.id` holds in the handler, and, when the post
|
|
19
|
+
* lands on a path on this site, the redirect carries as `?x_answer=`, the flash cookie ends in,
|
|
20
|
+
* and `useSubmissionId()` reads on the page that follows (a landing on another origin carries
|
|
21
|
+
* neither the id nor a flash, and has no page of ours to read it). Always set by the framework; typed optional so an `ActionRefusal` built by hand
|
|
22
|
+
* (a test) need not carry one. A refusal by the input schema runs no handler, so this is the one
|
|
23
|
+
* place such a refusal can learn it.
|
|
24
|
+
*/
|
|
25
|
+
readonly submission?: string;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
/**
|
|
@@ -103,6 +112,11 @@ export async function answerNatively(
|
|
|
103
112
|
const id = newSubmissionId();
|
|
104
113
|
let output: unknown;
|
|
105
114
|
try {
|
|
115
|
+
// The handler runs as an answer to THIS post: `ctx.submission.id` is the id the redirect will
|
|
116
|
+
// carry. Set on the request's own context, which the handler reads, and not on a derived child:
|
|
117
|
+
// a child does not carry the request's slots, and `setRedirect()`, a cookie and a header read
|
|
118
|
+
// would all refuse inside one. Every call that is not a native post never reaches this line.
|
|
119
|
+
req.ctx.submission = { id };
|
|
106
120
|
output = await call();
|
|
107
121
|
} catch (error) {
|
|
108
122
|
const facts = factsOf(error);
|
|
@@ -111,7 +125,12 @@ export async function answerNatively(
|
|
|
111
125
|
takeRedirect(req.ctx);
|
|
112
126
|
const issues =
|
|
113
127
|
typeof error === 'object' && error !== null ? answerIssues(Reflect.get(error, 'issues')) : [];
|
|
114
|
-
const chosen = native.refusal?.({
|
|
128
|
+
const chosen = native.refusal?.({
|
|
129
|
+
code: facts.code,
|
|
130
|
+
status: facts.status,
|
|
131
|
+
issues,
|
|
132
|
+
submission: id,
|
|
133
|
+
});
|
|
115
134
|
const to = chosen === undefined ? formPage(req) : landing(chosen, req.url);
|
|
116
135
|
if (to === undefined) throw error;
|
|
117
136
|
return answered(to, id, 303, {
|