@ultimat3/action 31.31.0 → 31.33.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/action",
3
- "version": "31.31.0",
3
+ "version": "31.33.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.31.0",
52
- "@ultimat3/core": "31.31.0",
53
- "@ultimat3/db": "31.31.0",
54
- "@ultimat3/entity": "31.31.0",
55
- "@ultimat3/http": "31.31.0",
56
- "@ultimat3/policy": "31.31.0",
57
- "@ultimat3/schema": "31.31.0",
58
- "@ultimat3/storage": "31.31.0"
51
+ "@ultimat3/cache": "31.33.0",
52
+ "@ultimat3/core": "31.33.0",
53
+ "@ultimat3/db": "31.33.0",
54
+ "@ultimat3/entity": "31.33.0",
55
+ "@ultimat3/http": "31.33.0",
56
+ "@ultimat3/policy": "31.33.0",
57
+ "@ultimat3/schema": "31.33.0",
58
+ "@ultimat3/storage": "31.33.0"
59
59
  }
60
60
  }
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * What an app says about its API as a WHOLE, beside the primitives it registers: how action names
3
3
  * become URLs, which bearer-token mounts expose a cut of it, and what its OpenAPI document calls
4
- * itself. Declared in the one `defineApi()` call and held here, process-wide like the registries,
5
- * because every reader — the boot that mounts routes, `x manifest` writing `openapi.json` — runs
6
- * after that module was imported and never has the call's return value in hand.
4
+ * itself.
5
+ *
6
+ * Declared in the one `defineApi()` call and held here, process-wide like the registries, because
7
+ * every reader — the boot that mounts routes, `x manifest` writing `openapi.json` — runs after that
8
+ * module was imported and never has the call's return value in hand.
7
9
  */
8
10
 
9
11
  import type { ActionPathStyle } from '@ultimat3/core';
package/src/audit.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * The audit seam, as this package exposes it: THAT an action or mutator can be recorded at all.
3
+ *
3
4
  * The contract — the record, the sink, the one installed-sink slot — moved to `@ultimat3/core`'s
4
5
  * `audit.ts` so `@ultimat3/query` (a sibling this package cannot import) writes the same record
5
6
  * into the same sink. The TYPES are re-exported for this package's own modules; the slot's VALUES
6
7
  * (`getAuditSink`; the boot's `installAuditSink` is `@ultimat3/core/adapter`'s) are imported from
7
- * core and never re-exported — a second import path for one value is `X_HELPER_COPY` (`bun run flight-copies`).
8
+ * core and never re-exported — a second import path for one value is `X_HELPER_COPY`
9
+ * (`bun run flight-copies`).
8
10
  */
9
11
 
10
12
  export type { AuditFailure, AuditOutcome, AuditRecord, AuditSink } from '@ultimat3/core';
package/src/client.ts CHANGED
@@ -33,6 +33,8 @@ import {
33
33
  problemOf,
34
34
  remoteTitleOf,
35
35
  renderedActionPin,
36
+ renderFixShellArg,
37
+ trimTrailingSlashes,
36
38
  } from '@ultimat3/core/page';
37
39
  import type { InferInput, InferOutput, StandardSchemaV1 } from '@ultimat3/schema';
38
40
  import type { Action, StreamAction } from './action';
@@ -165,7 +167,7 @@ export function clientMethodFor<TInput extends StandardSchemaV1, TOutput extends
165
167
  const pin = pinned?.path === undefined ? renderedActionPin(name) : pinned;
166
168
  const path = pin?.path ?? actionPath(name, options.pathStyle);
167
169
  const method = pin?.method ?? pinned?.method ?? 'POST';
168
- const base = options.baseUrl.replace(/\/+$/, '');
170
+ const base = trimTrailingSlashes(options.baseUrl);
169
171
  const onResponse = (response: Response): void =>
170
172
  assertSameBuild(options.buildId, response.headers.get(BUILD_ID_HEADER), name);
171
173
  const decodeError = (
@@ -315,7 +317,7 @@ function toUltimateError(
315
317
  meta: metaFromWire(body['meta']),
316
318
  requestId: body['requestId'],
317
319
  cause: stringOr(body['cause'] ?? body['detail'], `${name} failed with ${status}`),
318
- fix: stringOr(body['fix'], `x actions show ${name} --json`),
320
+ fix: stringOr(body['fix'], `x actions show ${renderFixShellArg(name, '<action-name>')} --json`),
319
321
  // RFC-9457's `type` IS a documentation URI, so a server that sends no `docs` extension has
320
322
  // still offered one. Both travel, in preference order: `??` picked `docs` on presence alone,
321
323
  // so a `javascript:` one hid a perfectly good `type` behind it. `remoteDocs` takes the first
@@ -1,8 +1,9 @@
1
1
  // @ultimat3/action's error TITLES, registered at import — the one module `sideEffects` names, so
2
- // `errors.ts` (the classes) is unlisted and a chunk carries it only where it constructs a class:
2
+ // `errors.ts` (the classes) is unlisted and a chunk carries it only where it constructs a class.
3
+ //
3
4
  // Bun >= 1.4.1 honours the array and keeps a listed module wherever the barrel reaches it.
4
- // `index.ts` imports this bare, because `problemError` rebuilds a server's refusal by code and reads
5
- // its title from the registry; `errors.ts` and its two siblings import it bare as well.
5
+ // `index.ts` imports this bare, because `problemError` rebuilds a server's refusal by code and
6
+ // reads its title from the registry; `errors.ts` and its two siblings import it bare as well.
6
7
 
7
8
  import { registerErrorCodes, registerErrorRetry } from '@ultimat3/core/page';
8
9
 
package/src/errors.ts CHANGED
@@ -81,7 +81,7 @@ export class ActionDeniedError extends UltimateError {
81
81
  super({
82
82
  code: refused.code,
83
83
  cause: `${refused.name} denied: ${refused.reason}`,
84
- fix: `x policy explain ${refused.name} --json # shows which clause decided and why`,
84
+ fix: `x policy explain ${renderFixShellArg(refused.name, '<permission>')} --json # shows which clause decided and why`,
85
85
  callerFix: deniedCallerFix(),
86
86
  });
87
87
  this.denial = refused.denial;
package/src/facade.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * The fluent surface: every projection this package owns reachable as a method on the action
3
- * itself, `publishPost.openapi()` rather than `toOpenApiOperation(publishPost)`, and every
4
- * declared field lifted off `def` so app code never reaches through `.def`. The projection
5
- * functions stay exported for the framework's own call sites — this file only binds them to the
6
- * action, it never re-implements one. There is no `.tool()`: the MCP tool is `@ultimat3/mcp`'s
7
- * one projection (`toolFrom(publishPost)`), a tier this package cannot import.
3
+ * itself, `publishPost.openapi()` rather than `toOpenApiOperation(publishPost)`, and every declared
4
+ * field lifted off `def` so app code never reaches through `.def`.
5
+ *
6
+ * The projection functions stay exported for the framework's own call sites — this file only binds
7
+ * them to the action, it never re-implements one. There is no `.tool()`: the MCP tool is
8
+ * `@ultimat3/mcp`'s one projection (`toolFrom(publishPost)`), a tier this package cannot import.
8
9
  */
9
10
 
10
11
  import type { InferOutput, StandardSchemaV1 } from '@ultimat3/schema';
@@ -221,7 +221,7 @@ export function postgresIdempotencyStore(
221
221
  };
222
222
  const now = options.now ?? ((): number => liveClock.now().getTime());
223
223
 
224
- const fetch = async (key: string): Promise<IdempotencyRecord | undefined> => {
224
+ const readRecord = async (key: string): Promise<IdempotencyRecord | undefined> => {
225
225
  const rows = await exec.query<IdempotencyRow>(SQL_IDEMPOTENCY_GET, [key, windowSecs]);
226
226
  const row = rows[0];
227
227
  return row === undefined ? undefined : toRecord(row);
@@ -250,7 +250,7 @@ export function postgresIdempotencyStore(
250
250
  ]);
251
251
  const row = claimed[0];
252
252
  if (row !== undefined) return { record: toRecord(row), created: true };
253
- const existing = await fetch(key);
253
+ const existing = await readRecord(key);
254
254
  if (existing !== undefined) return { record: existing, created: false };
255
255
  }
256
256
  // Reported as a fresh reservation rather than a throw would be wrong in the one direction
@@ -302,7 +302,7 @@ export function postgresIdempotencyStore(
302
302
  await exec.query(SQL_IDEMPOTENCY_RELEASE, [key, reservationId]);
303
303
  },
304
304
 
305
- get: fetch,
305
+ get: readRecord,
306
306
 
307
307
  async purgeExpired(): Promise<number> {
308
308
  const rows = await exec.query<{ readonly key: string }>(
@@ -14,6 +14,7 @@ import {
14
14
  logger,
15
15
  MAX_TIMER_MS,
16
16
  runToCompletion,
17
+ timingSafeEqual,
17
18
  tryUseContext,
18
19
  } from '@ultimat3/core';
19
20
  import { adapterSlot } from '@ultimat3/core/adapter';
@@ -296,7 +297,9 @@ export async function withIdempotency<T>(
296
297
  );
297
298
  const requestHash = keyedFingerprint(input, IDEMPOTENCY_FINGERPRINT_PURPOSE);
298
299
  const { record, created } = await store.reserve(key, requestHash);
299
- if (record.requestHash !== requestHash) assertSamePayload(key, record.requestHash, input);
300
+ // Keyed fingerprints, and the request side is the caller's to vary: compared in constant time.
301
+ if (!timingSafeEqual(record.requestHash, requestHash))
302
+ assertSamePayload(key, record.requestHash, input);
300
303
  if (!created) {
301
304
  if (record.status === 'in-flight') throw new IdempotencyConflictError(key, 'in-flight');
302
305
  if (record.status === 'failed') throw new IdempotencyReplayedFailureError(key, record.failure);
package/src/job-handle.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Projection 5: an action as durable work — its input schema, a payload-derived
3
- * idempotency key, and an `invoke` that runs the action's one execution path under
4
- * `surface: 'job'`, so a queued run takes the same validation and policy path as the HTTP call —
5
- * under the worker's system authority: the enqueuer is `enqueuedBy`, attribution only, and never
6
- * authorises the run. An action that acts for a user takes that user's id and re-authorises it.
2
+ * Projection 5: an action as durable work — its input schema, a payload-derived idempotency key,
3
+ * and an `invoke` that runs the action's one execution path under `surface: 'job'`.
4
+ *
5
+ * A queued run takes the same validation and policy path as the HTTP call — under the worker's
6
+ * system authority: the enqueuer is `enqueuedBy`, attribution only, and never authorises the run.
7
+ * An action that acts for a user takes that user's id and re-authorises it.
7
8
  * `@ultimat3/ai`'s `agentJob()` is the framework's one consumer — it takes any `Action` and
8
9
  * composes `job()` around this shape — and an app may write the same three lines.
9
10
  */
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * The COMPLETE document an app opts into with `defineApi({ openapi })`: its own `info` and
3
- * `servers`, the security schemes its routes are reached through, and the refusals an
4
- * authenticated, limited or metered operation can answer — 401 and 429, with `Retry-After` — which
5
- * the per-primitive projections cannot state: they do not know the route an operation is mounted
6
- * as. Plus the second document a bearer mount publishes: only the cut, at the mounted paths.
3
+ * `servers`, its security schemes, and the 401/429 refusals no per-primitive projection can state —
4
+ * none knows the route an operation is mounted as.
5
+ *
6
+ * The security schemes are the ones its routes are reached through; the refusals, the ones an
7
+ * authenticated, limited or metered operation can answer: 401, and 429 with `Retry-After`.
8
+ * Plus the second document a bearer mount publishes: only the cut, at the mounted paths.
7
9
  *
8
10
  * Built over the merged document (actions AND reads — `@ultimat3/cli` merges the two packages'
9
11
  * paths) and over the `Route`s that serve it, so "is this operation authenticated" is the answer
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * What the server says to a caller that derived an action's URL under the WRONG path style: a
3
3
  * script or another service passing `rpc({ pathStyle })` by hand, where matching build ids prove
4
- * nothing. Handed to `@ultimat3/http` as `hooks.explainMiss`, so it runs only when the router
5
- * matched nothing — and answers `X_CONTRACT_DRIFT` naming the style served, in place of a
4
+ * nothing.
5
+ *
6
+ * Handed to `@ultimat3/http` as `hooks.explainMiss`, so it runs only when the router matched
7
+ * nothing — and answers `X_CONTRACT_DRIFT` naming the style served, in place of a
6
8
  * `X_ROUTE_NOT_FOUND` that sends the caller looking for a route that exists.
7
9
  */
8
10