@ultimat3/action 31.35.0 → 31.37.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.35.0",
3
+ "version": "31.37.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.35.0",
52
- "@ultimat3/core": "31.35.0",
53
- "@ultimat3/db": "31.35.0",
54
- "@ultimat3/entity": "31.35.0",
55
- "@ultimat3/http": "31.35.0",
56
- "@ultimat3/policy": "31.35.0",
57
- "@ultimat3/schema": "31.35.0",
58
- "@ultimat3/storage": "31.35.0"
51
+ "@ultimat3/cache": "31.37.0",
52
+ "@ultimat3/core": "31.37.0",
53
+ "@ultimat3/db": "31.37.0",
54
+ "@ultimat3/entity": "31.37.0",
55
+ "@ultimat3/http": "31.37.0",
56
+ "@ultimat3/policy": "31.37.0",
57
+ "@ultimat3/schema": "31.37.0",
58
+ "@ultimat3/storage": "31.37.0"
59
59
  }
60
60
  }
package/src/client.ts CHANGED
@@ -277,7 +277,7 @@ function assertSameBuild(
277
277
  if (clientBuild === serverBuild) return;
278
278
  throw new ContractDriftError(
279
279
  `client build ${clientBuild} called ${name} on server build ${serverBuild}`,
280
- 'reload the page to pick up the new client bundle',
280
+ 'location.reload() // picks up the new client bundle',
281
281
  );
282
282
  }
283
283
 
@@ -76,7 +76,7 @@ export function contractTestsFor(
76
76
  () => parseActionInput(target.input, garbage, name),
77
77
  'X_INPUT_INVALID',
78
78
  `${name} accepted the value this assertion sent as garbage`,
79
- `tighten \`input:\` in the ${name} definition`,
79
+ `input: t.object({ ... }) // tighten it in the ${name} definition until it refuses the garbage`,
80
80
  { action: name, garbage },
81
81
  );
82
82
  },
@@ -222,12 +222,12 @@ async function expectDenied(
222
222
  if (error.code !== 'X_INPUT_INVALID') throw error;
223
223
  throw new ContractDriftError(
224
224
  `${name} failed with ${error.code} before its policy decided, so the denial is unproven`,
225
- `pass \`input:\` to contractTestsFor(${name}) — x actions show ${name} --json prints the schema`,
225
+ `x actions show ${renderFixShellArg(name, '<action>')} --json # prints the schema: pass a matching \`input:\` to contractTestsFor(${name})`,
226
226
  );
227
227
  }
228
228
  throw new ContractDriftError(
229
229
  `${name} ran for an actor of null`,
230
- `make the ${name} policy require an authenticated actor`,
230
+ `policy: can('<resource>:<verb>') // in ${name}: a policy that requires an authenticated actor`,
231
231
  );
232
232
  }
233
233
 
@@ -69,7 +69,7 @@ export class ActionPathDerivedEarlyError extends UltimateError {
69
69
  super({
70
70
  code: 'X_ACTION_PATH_DERIVED_EARLY',
71
71
  cause: `pathStyle '${input.style}' was declared after a path was already derived under the previous style: ${shown}${more} — any module that kept that string holds a URL no route serves`,
72
- fix: 'derive the path where it is used — inside the component or function, never in a module-level const — or import the module that calls defineApi({ http: { pathStyle } }) before the one that derives it',
72
+ fix: 'defineApi({ http: { pathStyle } }) // import its module before the one that derives a path — or derive the path where it is used, inside the component or function, never in a module-level const',
73
73
  meta: { style: input.style, names: input.stale.map((row) => row.name) },
74
74
  });
75
75
  }
@@ -24,8 +24,8 @@ export class IdempotencyConflictError extends UltimateError {
24
24
  // are the CLIENT's to act on, and one header built two ways is two ways to get it wrong.
25
25
  fix:
26
26
  reason === 'payload-mismatch'
27
- ? 'set the Idempotency-Key header to a fresh crypto.randomUUID() — one key per payload, since this one already names a different request'
28
- : 'resend this request with the same Idempotency-Key once the first one settles — a fresh crypto.randomUUID() here would run the mutation twice',
27
+ ? '{ idempotencyKey: crypto.randomUUID() } // a fresh Idempotency-Key per payload: this one already names a different request'
28
+ : '{ idempotencyKey } // resend with the SAME Idempotency-Key once the first one settles — a fresh crypto.randomUUID() here would run the mutation twice',
29
29
  });
30
30
  }
31
31
  }
@@ -52,7 +52,7 @@ export class IdempotencyKeyInvalidError extends UltimateError {
52
52
  problem === 'empty'
53
53
  ? `action "${action}" was called with an empty Idempotency-Key, which every caller sending a blank header would share`
54
54
  : `action "${action}" was called with an Idempotency-Key of ${length} characters, past the 255 its OpenAPI operation publishes`,
55
- fix: 'set the Idempotency-Key header to a fresh crypto.randomUUID() on the client, one per request — or omit the header entirely to run this call without idempotency',
55
+ fix: '{ idempotencyKey: crypto.randomUUID() } // on the client, one Idempotency-Key per request — or omit the header entirely to run this call without idempotency',
56
56
  meta: { action, problem, length },
57
57
  });
58
58
  }
@@ -104,7 +104,7 @@ export class IdempotencyReplayedFailureError extends UltimateError {
104
104
  const recorded: IdempotencyFailure = failure ?? {
105
105
  code: 'X_IDEMPOTENCY_REPLAYED_FAILURE',
106
106
  cause: 'the first attempt under this key failed and the store kept no detail of it',
107
- fix: 'read the first attempt in the logs, then send a fresh Idempotency-Key once the cause is fixed',
107
+ fix: 'x logs tail --json # in dev; elsewhere your log index: find the first attempt, fix its cause, then send a fresh Idempotency-Key',
108
108
  };
109
109
  super({
110
110
  code: recorded.code,
@@ -152,7 +152,7 @@ export class MutatorNotIdempotentError extends UltimateError {
152
152
  code: 'X_MUTATOR_NOT_IDEMPOTENT',
153
153
  cause:
154
154
  'a mutator is declared without idempotent: true, so a replay of its write under the same Idempotency-Key would run the server half a second time',
155
- fix: 'add `idempotent: true` to the mutator definition',
155
+ fix: 'idempotent: true // in the mutator definition',
156
156
  });
157
157
  }
158
158
  }
@@ -168,7 +168,7 @@ export class IdempotencyReservationLostError extends UltimateError {
168
168
  super({
169
169
  code: 'X_IDEMPOTENCY_RESERVATION_LOST',
170
170
  cause: `idempotency key "${key}" was reclaimed by a retry while this attempt was still in flight past the request deadline, so its transaction is rolled back rather than committed beside the retry's`,
171
- fix: 'resend this request with the same Idempotency-Key — the attempt that took the key over answers it, and this one was rolled back',
171
+ fix: '{ idempotencyKey } // resend with the SAME Idempotency-Key — the attempt that took the key over answers it, and this one was rolled back',
172
172
  meta: { key },
173
173
  });
174
174
  }
package/src/errors.ts CHANGED
@@ -44,7 +44,7 @@ export class ActionUnregisteredError extends UltimateError {
44
44
  super({
45
45
  code: 'X_ACTION_UNREGISTERED',
46
46
  cause: 'an action was projected before it was registered, so it has no name',
47
- fix: "list the action's module in defineApi({ actions }) in apps/<app>/api/index.ts — the boot names it before mounting routes",
47
+ fix: "defineApi({ actions }) // list the action's module in it, in apps/<app>/api/index.ts — the boot names it before mounting routes",
48
48
  });
49
49
  }
50
50
  }
@@ -60,7 +60,7 @@ export class ActionForeignError extends UltimateError {
60
60
  super({
61
61
  code: 'X_ACTION_FOREIGN',
62
62
  cause: `"${name === '' ? 'anonymous' : name}" is not an action built by action()`,
63
- fix: "declare it as `export const name = action({ input, output, policy, handle })` from '@ultimat3/action'",
63
+ fix: "export const name = action({ input, output, policy, handle }) // action() from '@ultimat3/action'",
64
64
  });
65
65
  }
66
66
  }
@@ -93,7 +93,7 @@ export class ActionDuplicateError extends UltimateError {
93
93
  super({
94
94
  code: 'X_ACTION_DUPLICATE',
95
95
  cause: `two actions are registered under the name "${name}"`,
96
- fix: `rename one export — action names are globally unique: x actions list --json`,
96
+ fix: 'x actions list --json # action names are globally unique: rename one of the two exports',
97
97
  });
98
98
  }
99
99
  }
@@ -109,7 +109,7 @@ export class ActionPathDuplicateError extends UltimateError {
109
109
  super({
110
110
  code: 'X_ACTION_PATH_DUPLICATE',
111
111
  cause: `actions "${input.name}" and "${input.existing}" both derive ${input.path}`,
112
- fix: `rename one export so the two derive different paths — x actions list --json prints every derived route`,
112
+ fix: 'x actions list --json # prints every derived route: rename one export so the two differ',
113
113
  });
114
114
  }
115
115
  }
@@ -126,7 +126,7 @@ export class ActionPolicyMissingError extends UltimateError {
126
126
  super({
127
127
  code: 'X_ACTION_POLICY_MISSING',
128
128
  cause: `action "${name}" was registered without a policy`,
129
- fix: `add \`policy: can('<resource>:<verb>')\` to the action() that exports "${name}" — a permission your definePermissions() call declares, never the action's own name — or \`allow('<resource>:<verb>')\` if the operation is genuinely public`,
129
+ fix: `policy: can('<resource>:<verb>') // in the action() that exports "${name}": a permission your definePermissions() call declares, never the action's own name — or allow('<resource>:<verb>') if the operation is genuinely public`,
130
130
  });
131
131
  }
132
132
  }
@@ -215,7 +215,7 @@ export class ActionDeprecationInvalidError extends UltimateError {
215
215
  super({
216
216
  code: 'X_ACTION_DEPRECATION_INVALID',
217
217
  cause: `action "${action}" declares deprecated.${field} as "${value}", which is not a date`,
218
- fix: `edit \`deprecated: { ${field}: … }\` on ${action} to an ISO-8601 instant — e.g. '2026-12-31T23:59:59Z'`,
218
+ fix: `deprecated: { ${field}: '2026-12-31T23:59:59Z' } // on ${action}: an ISO-8601 instant`,
219
219
  meta: { action, field, value },
220
220
  });
221
221
  }
@@ -352,7 +352,7 @@ export class RpcFailedError extends UltimateError {
352
352
  super({
353
353
  code: 'X_RPC_FAILED',
354
354
  cause: `${name} returned HTTP ${status} without a problem+json body`,
355
- fix: "match X_CLIENT_TRANSPORT_FAILED instead: isUltimateError(e) && e.code === 'X_CLIENT_TRANSPORT_FAILED', with isUltimateError from @ultimat3/core",
355
+ fix: "isUltimateError(e) && e.code === 'X_CLIENT_TRANSPORT_FAILED' // match this instead; isUltimateError from @ultimat3/core",
356
356
  retry: retryForStatus('X_RPC_FAILED', status),
357
357
  });
358
358
  }
@@ -401,8 +401,8 @@ export class AuditSinkFailedError extends UltimateError {
401
401
  code: 'X_AUDIT_SINK_FAILED',
402
402
  cause: `"${action}" ran and its audit sink refused the record, so the change is unrecorded — the handler had already committed`,
403
403
  fix: replayable
404
- ? `fix the sink runtime.ts installs as auditSink (apps/<app>/runtime.ts), then retry with the same Idempotency-Key — the replay re-records without re-running the handler`
405
- : `fix the sink runtime.ts installs as auditSink (apps/<app>/runtime.ts), then reconcile this one change by hand — do NOT retry: ${action} ran with no Idempotency-Key, so a second call runs the committed handler again. Add \`idempotent: true\` and send the header to make retries safe`,
404
+ ? `export const runtime = { auditSink } // apps/<app>/runtime.ts: fix the sink it installs, then retry with the same Idempotency-Key — the replay re-records without re-running the handler`
405
+ : `export const runtime = { auditSink } // apps/<app>/runtime.ts: fix the sink it installs, then reconcile this one change by hand — do NOT retry: ${action} ran with no Idempotency-Key, so a second call runs the committed handler again. Add \`idempotent: true\` and send the header to make retries safe`,
406
406
  // Read by `--json` and the error reporter: whether a retry is safe is the one decision an
407
407
  // operator makes here, so it is a field and not only a sentence.
408
408
  meta: { action, replayable },
@@ -422,13 +422,13 @@ export class MutatorClockMissingError extends UltimateError {
422
422
  ? {
423
423
  code: 'X_MUTATOR_CLOCK_MISSING',
424
424
  cause: `a mutator declares conflict: 'last-write-wins' and its output carries no entity row, so there is no ${clock} to compare`,
425
- fix: "return the entity row from the mutator's output, or declare conflict: 'server-wins'",
425
+ fix: "conflict: 'server-wins' // or return the entity row from the mutator's output",
426
426
  meta: { clock },
427
427
  }
428
428
  : {
429
429
  code: 'X_MUTATOR_CLOCK_MISSING',
430
430
  cause: `a mutator declares conflict: 'last-write-wins' and entity ${entity} has no number ${clock} column the server writes, so the server row would win every time`,
431
- fix: `add ${clock} (a number, epoch ms, written by the server) to ${renderFixShellArg(entity, '<entity>')}, or declare conflict: 'server-wins'`,
431
+ fix: `conflict: 'server-wins' // or add ${clock} (a number, epoch ms, written by the server) to ${renderFixShellArg(entity, '<entity>')}`,
432
432
  meta: { entity, clock },
433
433
  },
434
434
  );
@@ -464,7 +464,7 @@ function failureOf(error: unknown): IdempotencyFailure {
464
464
  return {
465
465
  code: 'X_IDEMPOTENCY_REPLAYED_FAILURE',
466
466
  cause: 'the first attempt under this key threw a value that is not an UltimateError',
467
- fix: 'read the first attempt in the logs, then send a fresh Idempotency-Key once the cause is fixed',
467
+ fix: 'x logs tail --json # in dev; elsewhere your log index: find the first attempt, fix its cause, then send a fresh Idempotency-Key',
468
468
  };
469
469
  }
470
470
  return {
@@ -42,7 +42,7 @@ export function normalizeJsonSchema(convert: () => unknown): JsonSchemaObject {
42
42
  if (isJsonObject(raw)) return raw;
43
43
  throw new SchemaUnsupportedError({
44
44
  cause: `the schema converted to ${raw === null ? 'null' : typeof raw}, not a JSON Schema object`,
45
- fix: 'declare the schema with `t` from @ultimat3/action, or add an introspect() returning a SchemaNode to the object passed to configureSchemaProvider()',
45
+ fix: 'configureSchemaProvider({ vendor, t, introspect }) // introspect() returning a SchemaNode — or declare the schema with `t` from @ultimat3/action',
46
46
  });
47
47
  }
48
48
 
package/src/registry.ts CHANGED
@@ -139,7 +139,7 @@ function assertProjectable(name: string, target: AnyAction): void {
139
139
  // ones a reader acts on.
140
140
  throw new SchemaUnsupportedError({
141
141
  cause: `${name}: \`${field}:\` cannot be projected to JSON Schema`,
142
- fix: `declare ${name}'s \`${field}:\` with t.object({ ... }) from @ultimat3/action or an entity's $view([...]) — both introspect — or call configureSchemaProvider() with a provider that can introspect it`,
142
+ fix: `t.object({ ... }) // ${name}'s \`${field}:\`, from @ultimat3/action — or an entity's $view([...]); both introspect — or call configureSchemaProvider() with a provider that can introspect it`,
143
143
  meta: { action: name, field },
144
144
  });
145
145
  }