diff --git a/.changeset/37811-domain-501-languages.md b/.changeset/37811-domain-501-languages.md new file mode 100644 index 00000000000..a455313db0e --- /dev/null +++ b/.changeset/37811-domain-501-languages.md @@ -0,0 +1,14 @@ +--- +'@objectstack/runtime': patch +'@objectstack/spec': patch +--- + +fix(runtime): the dispatcher's remaining 501 answers follow the request's language + +Clause-②: yes (widening) +Metadata-protocol: none +Skills-docs: none (no page under `skills/**` quotes these 501 sentences or their headers) + +The `501 NOT_IMPLEMENTED` answers of `/auth`, `/i18n`, `/mcp`, `/meta`, `/packages`, `/automation` (the connector credential and connection doors, the run list, cancel, restore, resume, screen lookup and flow clone), the action and catalog activation doors, the permission-set clone door, the `/security` suggested-binding reopen and `/share-links` now answer in the request's top `Accept-Language` tag, as the own doors' `501`s do since #37721, and carry `Vary: Accept-Language`. Each sentence is a new key of the operation-message catalog in `en`, `zh-CN`, `ja-JP` and `es-ES`; the English is byte for byte the sentence the door answered before, and status and code are unchanged. + +Three `501`s stay English: the shared `capabilityUnavailable` answer, whose sentence is the discovery remedy (`services..message`) by contract; the MCP resume door's, which the calling agent reads beside the door's other English refusals; and the `/meta` save fallback that forwards the metadata service's own thrown message. diff --git a/packages/runtime/src/domains/action-activation-posture-gate.test.ts b/packages/runtime/src/domains/action-activation-posture-gate.test.ts index 5600cd278e9..22d3706255d 100644 --- a/packages/runtime/src/domains/action-activation-posture-gate.test.ts +++ b/packages/runtime/src/domains/action-activation-posture-gate.test.ts @@ -30,6 +30,7 @@ // was written would still be the leak commit 02b41232d measured, with persistence. import { describe, it, expect, vi } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext } from '../http-dispatcher.js'; @@ -463,3 +464,24 @@ describe('the activation write names the caller who asked for it', () => { expect(options?.context?.userId).toBe((ctx.executionContext as { userId: string }).userId); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the no-ledger 501 follows the request\'s language', () => { + it('action_activation_ledger_unsupported', async () => { + for (const [locale, extra] of LANGS_37811) { + const h = boot('single', { omitLedger: true }); + const res = await flip(h, { ...TENANT_ADMIN(), ...extra } as HttpProtocolContext); + expect(statusOf(res)).toBe(501); + expect(messageOf(res)).toBe(sentence37811(locale, 'action_activation_ledger_unsupported')); + expect(vary37811(res.response)).toBe('Accept-Language'); + } + }); +}); diff --git a/packages/runtime/src/domains/actions.ts b/packages/runtime/src/domains/actions.ts index c0ab330e751..14d0ac464bd 100644 --- a/packages/runtime/src/domains/actions.ts +++ b/packages/runtime/src/domains/actions.ts @@ -93,6 +93,7 @@ import { refusedNameAnswer } from './catalog-activation.js'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; import { readDispatchedBody } from '../deferred-request-body.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * [ADR-0126 §8 item 2] The reserved first segment of the activation door, @@ -273,14 +274,7 @@ async function handleActionActivationWrite( if (typeof ql.setActionActive !== 'function') { // An engine too old to carry the projection cannot make this durable, // and a 200 here would report a switch that never existed. - return { - handled: true, - response: deps.error( - `This deployment's data engine does not implement the packaged-metadata activation ledger ` + - `(ADR-0126 §8), so a packaged action cannot be switched off here.`, - 501, - ), - }; + return catalogNotImplemented(deps, context, 'action_activation_ledger_unsupported'); } try { // An action no package ships carries NO package key: absent is the diff --git a/packages/runtime/src/domains/auth.ts b/packages/runtime/src/domains/auth.ts index 221a8fa3468..1ed98055f4b 100644 --- a/packages/runtime/src/domains/auth.ts +++ b/packages/runtime/src/domains/auth.ts @@ -12,6 +12,7 @@ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types'; import { CoreServiceName } from '@objectstack/spec/system'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * The route this domain claims — `/auth` and its slash-separated sub-paths, @@ -188,7 +189,7 @@ export async function handleAuthRequest(deps: DomainHandlerDeps, _path: string, // faith with the one true observation the mock was built on — that a bare // 404 on sign-in sends the operator hunting for a routing bug — without // the lie it used to answer that concern. - return { handled: true, response: deps.error('Auth service not available — register @objectstack/plugin-auth to enable authentication', 501) }; + return catalogNotImplemented(deps, context, 'auth_service_unavailable'); } /** The transport's peer address (`IHttpRequest.remoteAddress`), when the request carries one. */ diff --git a/packages/runtime/src/domains/automation-connector-connection-door.test.ts b/packages/runtime/src/domains/automation-connector-connection-door.test.ts index 15ff4b29dde..adfdc3a2aaa 100644 --- a/packages/runtime/src/domains/automation-connector-connection-door.test.ts +++ b/packages/runtime/src/domains/automation-connector-connection-door.test.ts @@ -14,6 +14,7 @@ // (`connector-connection-door.test.ts`). import { describe, it, expect, vi } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; // The stack loads the metadata service lazily; pay that load at collection, never in a clocked case. import '@objectstack/metadata'; @@ -470,3 +471,32 @@ describe('ADR-0143 D2.1 — connector connection door: the begin leg takes the i expect(h.revoke).toHaveBeenCalledWith({ connector: 'crm', context: expect.objectContaining({ tenantId: 'org_a' }) }); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the absent-member 501 follows the request\'s language and names the member', () => { + it('automation_connector_connections_unsupported, on the read, begin, revoke and callback legs', async () => { + const h = boot({ service: { handlerReady: true } }); + for (const [locale, extra] of LANGS_37811) { + const ctx = { ...ADMIN(), ...extra } as HttpProtocolContext; + for (const [call, member] of [ + [() => connection(h, 'GET', ctx), 'getConnectorConnection'], + [() => connection(h, 'POST', ctx), 'beginConnectorConnection'], + [() => connection(h, 'DELETE', ctx), 'revokeConnectorConnection'], + [() => callback(h, ctx, { code: AUTH_CODE, state: 's' }), 'completeConnectorConnection'], + ] as const) { + const { response } = await call(); + expect(statusOf(response)).toBe(501); + expect(messageOf(response)).toBe(sentence37811(locale, 'automation_connector_connections_unsupported', { member })); + expect(vary37811(response)).toBe('Accept-Language'); + } + } + }); +}); diff --git a/packages/runtime/src/domains/automation-connector-credential-door.test.ts b/packages/runtime/src/domains/automation-connector-credential-door.test.ts index aed14537982..b749ba5e30e 100644 --- a/packages/runtime/src/domains/automation-connector-credential-door.test.ts +++ b/packages/runtime/src/domains/automation-connector-credential-door.test.ts @@ -13,6 +13,9 @@ // (`connector-credential-door.test.ts`). import { describe, it, expect, vi } from 'vitest'; +// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias). +import '@objectstack/metadata'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext } from '../http-dispatcher.js'; @@ -236,3 +239,31 @@ describe('[#27237] connector credential door — what it accepts', () => { } }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the absent-member 501 follows the request\'s language and names the member', () => { + it('automation_connector_credentials_unsupported, on the list, set and clear legs', async () => { + const h = boot({ service: { handlerReady: true } }); + for (const [locale, extra] of LANGS_37811) { + const ctx = { ...ADMIN(), ...extra } as HttpProtocolContext; + for (const [call, member] of [ + [() => get(h, ctx), 'listConnectorCredentialRefs'], + [() => put(h, ctx, { value: DUMMY_VALUE }), 'setConnectorCredential'], + [() => del(h, ctx), 'clearConnectorCredential'], + ] as const) { + const { response } = await call(); + expect(statusOf(response)).toBe(501); + expect(messageOf(response)).toBe(sentence37811(locale, 'automation_connector_credentials_unsupported', { member })); + expect(vary37811(response)).toBe('Accept-Language'); + } + } + }); +}); diff --git a/packages/runtime/src/domains/automation-run-lifecycle-door.test.ts b/packages/runtime/src/domains/automation-run-lifecycle-door.test.ts index 8c86f19c8cd..1fda542a023 100644 --- a/packages/runtime/src/domains/automation-run-lifecycle-door.test.ts +++ b/packages/runtime/src/domains/automation-run-lifecycle-door.test.ts @@ -44,6 +44,7 @@ */ import { describe, it, expect, vi } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import '@objectstack/metadata'; import { HttpDispatcher } from '../http-dispatcher.js'; @@ -579,3 +580,30 @@ describe('#13953 — the run-lifecycle doors require the platform operator', () }); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the absent-member 501s follow the request\'s language', () => { + for (const [path, options, key] of [ + [CANCEL_PATH, { cancel: 'absent' }, 'automation_run_cancel_unsupported'], + [RESTORE_PATH, { restore: 'absent' }, 'automation_run_restore_unsupported'], + ] as const) { + it(key, async () => { + for (const [locale, extra] of LANGS_37811) { + const { response } = await makeDispatcher(options as HarnessOptions).dispatcher.handleAutomation( + path, 'POST', undefined, { ...OPERATOR_CTX(), ...extra } as HttpProtocolContext, undefined, + ); + expect(statusOf(response)).toBe(501); + expect(messageOf(response)).toBe(sentence37811(locale, key)); + expect(vary37811(response)).toBe('Accept-Language'); + } + }); + } +}); diff --git a/packages/runtime/src/domains/automation-screen-read-gate.test.ts b/packages/runtime/src/domains/automation-screen-read-gate.test.ts index 77c9b750e57..f10e6ff88d7 100644 --- a/packages/runtime/src/domains/automation-screen-read-gate.test.ts +++ b/packages/runtime/src/domains/automation-screen-read-gate.test.ts @@ -52,6 +52,9 @@ */ import { describe, it, expect, vi } from 'vitest'; +// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias). +import '@objectstack/metadata'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext } from '../http-dispatcher.js'; @@ -527,3 +530,26 @@ describe('#7968 — the paused-run screen is gated to its trigger identity, or t }); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the screen-lookup 501 follows the request\'s language', () => { + it('automation_screen_lookup_unsupported', async () => { + for (const [locale, extra] of LANGS_37811) { + const h = makeDispatcher('refusing', { withoutScreenLookup: true }); + const { response } = await h.dispatcher.handleAutomation( + SCREEN_PATH, 'GET', undefined, { ...STRANGER(), ...extra } as HttpProtocolContext, undefined, + ); + expect((response as any).status).toBe(501); + expect((response as any).body?.error?.message).toBe(sentence37811(locale, 'automation_screen_lookup_unsupported')); + expect(vary37811(response)).toBe('Accept-Language'); + } + }); +}); diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index a534be5a840..b0e6cd7f966 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -120,6 +120,7 @@ import { carryForwardRedactedValues, redactMetadataItem } from '@objectstack/met // [#20679] Only the verdict's SIGNATURE — the locked-base refusal is asked of // the `protocol` service at request time, never re-derived here. import type { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * Translate a trigger request body into the canonical `AutomationContext` the @@ -891,10 +892,11 @@ async function refuseWalledConnectorCredentialAccess( }; } -/** [#27237] The verbs the mounted service must implement, named in the door's 501. */ -const CONNECTOR_CREDENTIAL_UNSUPPORTED_MESSAGE = (member: string): string => - 'Connector credentials are not supported by the automation service this deployment mounts — it does not ' - + `implement \`${member}\`, an optional member of \`IAutomationService\`. Nothing was read or changed.`; +/** + * [#27237] The verbs the mounted service must implement, named in the door's 501. [#37811] The catalog + * sentence names the missing member (`{{member}}`), in the request's language. + */ +const CONNECTOR_CREDENTIAL_UNSUPPORTED_KEY = 'automation_connector_credentials_unsupported'; /** * [#27237] The service's own refusals — `400` / `403` / `404` / `409` / `503`, @@ -937,7 +939,7 @@ async function respondToConnectorCredentialDoor( try { if (method === 'GET') { if (typeof svc.listConnectorCredentialRefs !== 'function') { - return { handled: true, response: deps.error(CONNECTOR_CREDENTIAL_UNSUPPORTED_MESSAGE('listConnectorCredentialRefs'), 501) }; + return catalogNotImplemented(deps, context, CONNECTOR_CREDENTIAL_UNSUPPORTED_KEY, { member: 'listConnectorCredentialRefs' }); } const credentialRefs = await svc.listConnectorCredentialRefs(); return { handled: true, response: deps.success({ credentialRefs, total: credentialRefs.length }) }; @@ -953,7 +955,7 @@ async function respondToConnectorCredentialDoor( } if (method === 'DELETE') { if (typeof svc.clearConnectorCredential !== 'function') { - return { handled: true, response: deps.error(CONNECTOR_CREDENTIAL_UNSUPPORTED_MESSAGE('clearConnectorCredential'), 501) }; + return catalogNotImplemented(deps, context, CONNECTOR_CREDENTIAL_UNSUPPORTED_KEY, { member: 'clearConnectorCredential' }); } const entry = await svc.clearConnectorCredential({ ref, context: executionContext }); return { handled: true, response: deps.success(entry) }; @@ -976,7 +978,7 @@ async function respondToConnectorCredentialDoor( }; } if (typeof svc.setConnectorCredential !== 'function') { - return { handled: true, response: deps.error(CONNECTOR_CREDENTIAL_UNSUPPORTED_MESSAGE('setConnectorCredential'), 501) }; + return catalogNotImplemented(deps, context, CONNECTOR_CREDENTIAL_UNSUPPORTED_KEY, { member: 'setConnectorCredential' }); } const entry = await svc.setConnectorCredential({ ref, @@ -1150,9 +1152,8 @@ function refuseUngrantedConnectorConnectionAccess( }; } -const CONNECTOR_CONNECTION_UNSUPPORTED_MESSAGE = (member: string): string => - 'Connector connections are not supported by the automation service this deployment mounts — it does not ' - + `implement \`${member}\`, an optional member of \`IAutomationService\`. Nothing was read or changed.`; +/** [#37811] As {@link CONNECTOR_CREDENTIAL_UNSUPPORTED_KEY}, for the connection doors. */ +const CONNECTOR_CONNECTION_UNSUPPORTED_KEY = 'automation_connector_connections_unsupported'; /** The callback's parameters, each one value: a repeated one is refused naming it, never read as either. */ function callbackQueryOf(query: unknown): { query: Record } | { refusal: string } { @@ -1202,7 +1203,7 @@ async function respondToConnectorConnectionDoor( const read = callbackQueryOf(query); if ('refusal' in read) return { handled: true, response: deps.error(read.refusal, 400, { code: 'VALIDATION_ERROR' }) }; if (typeof svc.completeConnectorConnection !== 'function') { - return { handled: true, response: deps.error(CONNECTOR_CONNECTION_UNSUPPORTED_MESSAGE('completeConnectorConnection'), 501) }; + return catalogNotImplemented(deps, context, CONNECTOR_CONNECTION_UNSUPPORTED_KEY, { member: 'completeConnectorConnection' }); } const state = await svc.completeConnectorConnection({ query: read.query, context: executionContext }); return { handled: true, response: deps.success(state) }; @@ -1219,7 +1220,7 @@ async function respondToConnectorConnectionDoor( const member = method === 'GET' ? 'getConnectorConnection' : method === 'POST' ? 'beginConnectorConnection' : 'revokeConnectorConnection'; const call = svc[member] as ((request: ConnectorConnectionRequest) => Promise) | undefined; if (typeof call !== 'function') { - return { handled: true, response: deps.error(CONNECTOR_CONNECTION_UNSUPPORTED_MESSAGE(member), 501) }; + return catalogNotImplemented(deps, context, CONNECTOR_CONNECTION_UNSUPPORTED_KEY, { member }); } // Only the begin leg reads a body (the installer's OAuth client); the // read and revoke legs read none, as before. @@ -1735,16 +1736,9 @@ const RESTORE_REFUSAL_UNKNOWN_STATUS = 500; * the condition — and it would be indistinguishable, on the wire, from a real * engine answering about a run it could not find. */ -const RUN_CANCEL_UNSUPPORTED_MESSAGE = - 'Cancelling a run is not supported by the automation service this deployment mounts — it does not implement ' - + '`cancelRun`, an optional member of `IAutomationService`. No run was cancelled.'; -const RUNS_LIST_UNSUPPORTED_MESSAGE = - 'Listing the runs of a flow is not supported by the automation service this deployment mounts — it does not ' - + 'implement `listRunsPage`, an optional member of `IAutomationService`. No runs were listed.'; -const RUN_RESTORE_UNSUPPORTED_MESSAGE = - 'Restoring a consumed suspension is not supported by the automation service this deployment mounts — it does ' - + 'not implement `restoreConsumedSuspension`, an optional member of `IAutomationService`. No suspension was ' - + 'restored.'; +const RUN_CANCEL_UNSUPPORTED_KEY = 'automation_run_cancel_unsupported'; +const RUNS_LIST_UNSUPPORTED_KEY = 'automation_runs_list_unsupported'; +const RUN_RESTORE_UNSUPPORTED_KEY = 'automation_run_restore_unsupported'; /** * [#13953] The message for a refusal this door could not classify — no @@ -2949,16 +2943,7 @@ async function resolveCloneTarget( if (typeof protocol?.ensureCustomizationPackage !== 'function' || typeof protocol.packagedArtifactOwner !== 'function' || typeof protocol.saveMetaItem !== 'function') { - return { - refused: { - handled: true, - response: deps.error( - 'Flow clone not supported: a copy lands in a package, and this deployment has no metadata ' - + 'protocol that can ensure a customization package and save a flow into it.', - 501, - ), - }, - }; + return { refused: catalogNotImplemented(deps, context, 'automation_flow_clone_unsupported') }; } const subject = `flow '${sourceName}'`; const owner = protocol.packagedArtifactOwner({ type: FLOW_METADATA_TYPE, name: sourceName }); @@ -5053,7 +5038,7 @@ export async function handleAutomationRequest(deps: DomainHandlerDeps, path: str } return { handled: true, response: deps.success(result) }; } - return { handled: true, response: deps.error('Resume not supported', 501) }; + return catalogNotImplemented(deps, context, 'automation_resume_unsupported'); } // POST /:name/runs/:runId/cancel → cancel a suspended run (ADR-0044). @@ -5109,7 +5094,7 @@ export async function handleAutomationRequest(deps: DomainHandlerDeps, path: str // while hiding the condition. if (isRunLifecycleWrite(parts, m) && parts[3] === RUN_CANCEL_SEGMENT) { if (typeof automationService.cancelRun !== 'function') { - return { handled: true, response: deps.error(RUN_CANCEL_UNSUPPORTED_MESSAGE, 501) }; + return catalogNotImplemented(deps, context, RUN_CANCEL_UNSUPPORTED_KEY); } const bodyRefusal = refuseInvalidRunLifecycleBody(deps, body, 'cancel'); if (bodyRefusal) return bodyRefusal; @@ -5169,7 +5154,7 @@ export async function handleAutomationRequest(deps: DomainHandlerDeps, path: str // unregistered members at a call site. if (isRunLifecycleWrite(parts, m) && parts[3] === RUN_RESTORE_SEGMENT) { if (typeof automationService.restoreConsumedSuspension !== 'function') { - return { handled: true, response: deps.error(RUN_RESTORE_UNSUPPORTED_MESSAGE, 501) }; + return catalogNotImplemented(deps, context, RUN_RESTORE_UNSUPPORTED_KEY); } const bodyRefusal = refuseInvalidRunLifecycleBody(deps, body, 'restore-suspension'); if (bodyRefusal) return bodyRefusal; @@ -5247,7 +5232,7 @@ export async function handleAutomationRequest(deps: DomainHandlerDeps, path: str if (refusal) return refusal; return { handled: true, response: deps.success({ runId: parts[2], screen }) }; } - return { handled: true, response: deps.error('Screen lookup not supported', 501) }; + return catalogNotImplemented(deps, context, 'automation_screen_lookup_unsupported'); } // GET /:name/runs/:runId → getRun @@ -5405,7 +5390,7 @@ export async function handleAutomationRequest(deps: DomainHandlerDeps, path: str // above runs first and is unaffected — its own note says a // 501-vs-403 must not be what tells an ungranted caller whether // automation is mounted here. - return { handled: true, response: deps.error(RUNS_LIST_UNSUPPORTED_MESSAGE, 501) }; + return catalogNotImplemented(deps, context, RUNS_LIST_UNSUPPORTED_KEY); } // GET /:name → getFlow (no sub-path) diff --git a/packages/runtime/src/domains/catalog-activation-door.test.ts b/packages/runtime/src/domains/catalog-activation-door.test.ts index 80c8fbef874..14277aa4031 100644 --- a/packages/runtime/src/domains/catalog-activation-door.test.ts +++ b/packages/runtime/src/domains/catalog-activation-door.test.ts @@ -17,6 +17,8 @@ // does not honour would be a switch that switches nothing. import { describe, it, expect } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; +import { METADATA_ACTIVATION_TABLE } from '@objectstack/core'; import { resolveUserAuthzGrants, securityCatalogReaderOf } from '@objectstack/core'; import { assertEngineUpdateDispatch } from '@objectstack/objectql'; // Paid at collection, not inside a case's clocked window: the dispatcher's @@ -1135,3 +1137,30 @@ describe('the catalog activation door — a declared assignment rule', () => { expect([...h.writes, ...bare.writes]).toEqual([]); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the no-ledger 501 follows the request\'s language, its noun included', () => { + it('catalog_activation_ledger_missing_off / _on, with the catalog\'s noun for a position', async () => { + for (const [locale, extra] of LANGS_37811) { + for (const [enabled, key] of [[false, 'catalog_activation_ledger_missing_off'], [true, 'catalog_activation_ledger_missing_on']] as const) { + const h = boot('single', { omitLedger: true }); + const res = await flip(h, { ...TENANT_ADMIN(), ...extra } as HttpProtocolContext, `/_activation/position/${POSITION}`, { enabled }); + expect(statusOf(res)).toBe(501); + expect(messageOf(res)).toBe(sentence37811(locale, key, { + table: METADATA_ACTIVATION_TABLE, + noun: sentence37811(locale, 'catalog_activation_noun_position'), + name: POSITION, + })); + expect(vary37811(res.response)).toBe('Accept-Language'); + } + } + }); +}); diff --git a/packages/runtime/src/domains/catalog-activation.ts b/packages/runtime/src/domains/catalog-activation.ts index 07bda1e81fa..83824b7fc9d 100644 --- a/packages/runtime/src/domains/catalog-activation.ts +++ b/packages/runtime/src/domains/catalog-activation.ts @@ -152,6 +152,8 @@ import { } from './activation-gate.js'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps } from '../domain-handler-registry.js'; +import { catalogNotImplemented, requestLocaleOf } from './own-door-bridge.js'; +import { operationUserMessage } from '@objectstack/core'; /** The reserved first segment of the door (see the module doc). */ export const CATALOG_ACTIVATION_SEGMENT = '_activation'; @@ -1102,14 +1104,14 @@ export async function handleCatalogActivationWrite( || typeof ql.update !== 'function') { // The resolver reads an absent ledger as "nothing switched off", so a // 200 here would report a switch that never existed. - return { - handled: true, - response: deps.error( - `This deployment does not carry the activation ledger (${METADATA_ACTIVATION_TABLE}, ADR-0126 §4), ` + - `so ${NOUN[type].toLowerCase()} '${name}' cannot be switched ${enabled ? 'on' : 'off'} here.`, - 501, - ), - }; + // [#37811] In the request's language; the noun is the catalog's own + // (`catalog_activation_noun_`), rendered in the same locale. + const locale = requestLocaleOf(context); + return catalogNotImplemented(deps, context, enabled ? 'catalog_activation_ledger_missing_on' : 'catalog_activation_ledger_missing_off', { + table: METADATA_ACTIVATION_TABLE, + noun: operationUserMessage(`catalog_activation_noun_${type}`, { locale }), + name, + }); } try { // [#22621 → A] The row carries the definition's package when it names diff --git a/packages/runtime/src/domains/domain-501-language-37811.test.ts b/packages/runtime/src/domains/domain-501-language-37811.test.ts new file mode 100644 index 00000000000..4992b7d629c --- /dev/null +++ b/packages/runtime/src/domains/domain-501-language-37811.test.ts @@ -0,0 +1,189 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#37811 — the dispatcher domains' remaining `501`s answer in the + * request's language. + * + * #37721 and #37737 localized the own doors' `501`s and gave them + * `Vary: Accept-Language`. The other domain modules still answered every + * reader in fixed English. Each of those sentences is now a key of the + * operation-message catalog (`@objectstack/spec/system`), rendered by + * `catalogNotImplemented` (`own-door-bridge.ts`) in the request's top + * `Accept-Language` tag, with the header. + * + * Most doors pin their language case beside their existing `501` test (the + * `[#37811]` blocks in the automation, activation, packages, `/meta`, clone + * and `/i18n` door tests). This file pins: + * + * 1. the doors that had no `501` fixture: `/auth`, `/mcp`, the `/meta` + * layered read and save, `/share-links`, the `/security` reopen, and the + * `/automation` run list, resume and flow clone; + * 2. a source walk over `src/domains/`: no `deps.error(…, 501)` is left + * outside the two modules that build one on purpose, so a new fixed-English + * `501` fails here and is written through the catalog instead. + */ + +import { describe, it, expect, vi } from 'vitest'; +// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias). +import '@objectstack/metadata'; +import { readFileSync, readdirSync } from 'node:fs'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; +import { HttpDispatcher } from '../http-dispatcher.js'; + +const LANGS = [ + ['en', {}], + ['ja-JP', { 'accept-language': 'ja-JP,ja;q=0.9' }], +] as const; + +const sentence = (locale: 'en' | 'ja-JP', key: string): string => BUILTIN_OPERATION_MESSAGES[locale][key]; + +function dispatcherWith(services: Record): HttpDispatcher { + const resolve = (name: string) => services[name]; + const kernel: any = { + getService: resolve, + getServiceAsync: async (name: string) => resolve(name), + context: { getService: resolve }, + }; + return new HttpDispatcher(kernel); +} + +const ADMIN = (headers: Record): any => ({ + request: { headers }, + executionContext: { + userId: 'u_admin', + positions: [], + systemPermissions: ['manage_metadata', 'studio.access', 'setup.access', 'manage_security', 'manage_automation'], + }, +}); + +function expectLocalized501(result: { response?: any }, locale: 'en' | 'ja-JP', key: string): void { + expect(result.response?.status, key).toBe(501); + expect(result.response?.body?.error?.code, key).toBe('NOT_IMPLEMENTED'); + expect(result.response?.body?.error?.message, key).toBe(sentence(locale, key)); + expect(result.response?.headers?.Vary, key).toBe('Accept-Language'); +} + +describe('#37811 · 1 · the doors with no 501 fixture of their own', () => { + it('/auth with no auth service: auth_service_unavailable', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({}).handleAuth('/sign-in/email', 'POST', {}, ADMIN(headers)); + expectLocalized501(result, locale, 'auth_service_unavailable'); + } + }); + + it('/mcp with no MCP server registered: mcp_server_unavailable', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({}).handleMcp({ jsonrpc: '2.0', id: 1, method: 'ping' }, ADMIN(headers)); + expectLocalized501(result, locale, 'mcp_server_unavailable'); + } + }); + + it('/meta/:type/:name/layers on a protocol without the layered read: meta_layered_view_unsupported', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({ protocol: { someUnrelatedVerb: () => undefined } }) + .handleMetadata('/page/home/layers', ADMIN(headers), 'GET', undefined, {}); + expectLocalized501(result, locale, 'meta_layered_view_unsupported'); + } + }); + + it('a conditional /meta save on a host with no protocol save: meta_save_conditions_unsupported', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({}) + .handleMetadata('/page/home', ADMIN({ ...headers, 'if-match': '"v1"' }), 'PUT', { name: 'home', label: 'Home' }, {}); + expectLocalized501(result, locale, 'meta_save_conditions_unsupported'); + } + }); + + it('a /meta save on a host with neither a protocol nor a metadata service save: meta_save_unsupported', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({}) + .handleMetadata('/page/home', ADMIN(headers), 'PUT', { name: 'home', label: 'Home' }, {}); + expectLocalized501(result, locale, 'meta_save_unsupported'); + } + }); + + it('/share-links with no share-link service: share_links_unconfigured', async () => { + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({}).handleShareLinks('', 'GET', undefined, {}, ADMIN(headers)); + expectLocalized501(result, locale, 'share_links_unconfigured'); + } + }); + + it('/security suggested-binding reopen on a service without it: security_audience_reopen_unsupported', async () => { + const security = { + listAudienceBindingSuggestions: vi.fn(), + confirmAudienceBindingSuggestion: vi.fn(), + dismissAudienceBindingSuggestion: vi.fn(), + }; + for (const [locale, headers] of LANGS) { + const result = await dispatcherWith({ security }) + .handleSecurity('/suggested-bindings/s_1/reopen', 'POST', undefined, {}, ADMIN(headers)); + expectLocalized501(result, locale, 'security_audience_reopen_unsupported'); + } + }); + + it('/automation on a service without the run list, resume or clone members', async () => { + const automation = { + handlerReady: true, + registerFlow: vi.fn(), + unregisterFlow: vi.fn(), + listFlows: async () => ['flow_a'], + getFlow: async (name: string) => + (name === 'flow_a' ? { name, label: 'Flow A', type: 'autolaunched', nodes: [{ id: 'start', type: 'start' }], edges: [] } : null), + }; + for (const [locale, headers] of LANGS) { + const d = dispatcherWith({ automation }); + expectLocalized501(await d.handleAutomation('/flow_a/runs', 'GET', undefined, ADMIN(headers), {}), locale, 'automation_runs_list_unsupported'); + expectLocalized501(await d.handleAutomation('/flow_a/runs/run_1/resume', 'POST', {}, ADMIN(headers)), locale, 'automation_resume_unsupported'); + expectLocalized501( + await d.handleAutomation('/flow_a/clone', 'POST', { name: 'flow_b', label: 'Flow B' }, ADMIN(headers)), + locale, + 'automation_flow_clone_unsupported', + ); + } + }); +}); + +/** Every `deps.error(` call in `source` whose status argument is the literal `501`. */ +function literal501Calls(source: string): string[] { + const out: string[] = []; + let from = 0; + for (;;) { + const at = source.indexOf('deps.error(', from); + if (at < 0) return out; + let depth = 0; + let end = at + 'deps.error'.length; + for (; end < source.length; end++) { + const c = source[end]; + if (c === '(') depth++; + else if (c === ')' && --depth === 0) break; + } + const call = source.slice(at, end + 1); + if (/,\s*501\s*[,)]/.test(call)) out.push(call.replace(/\s+/g, ' ').slice(0, 160)); + from = end + 1; + } +} + +describe('#37811 · 2 · no fixed-English 501 is left in the domain modules', () => { + // The two modules that build a 501 from `deps.error` on purpose: + // - `own-door-bridge.ts` is `localizedNotImplemented`, the builder every + // localized 501 goes through; + // - `unavailable.ts` is `capabilityUnavailable`, whose sentence is the + // discovery remedy (`serviceUnavailableMessage`, `services..message`) + // by contract, byte for byte: it stays English while discovery is English. + // The MCP resume door's `501` (`mcp.ts`, `resumeDoorError`) is not a + // `deps.error` call either: it is thrown into the resume tool's error + // mapping, read by the calling agent beside the door's other English + // refusals, and it stays English. + const BUILDERS = new Set(['own-door-bridge.ts', 'unavailable.ts']); + const dir = new URL('./', import.meta.url); + const modules = readdirSync(dir).filter((f) => f.endsWith('.ts') && !f.endsWith('.test.ts') && !BUILDERS.has(f)); + + it('walks the domain modules (a guard against an empty walk)', () => { + expect(modules).toEqual(expect.arrayContaining(['auth.ts', 'meta.ts', 'packages.ts', 'automation.ts', 'security.ts'])); + }); + + it.each(modules)('%s answers no deps.error(…, 501): its 501s go through catalogNotImplemented', (file) => { + expect(literal501Calls(readFileSync(new URL(file, dir), 'utf8'))).toEqual([]); + }); +}); diff --git a/packages/runtime/src/domains/domain-protocol-handle-typing.test.ts b/packages/runtime/src/domains/domain-protocol-handle-typing.test.ts index b43d61c2a30..325ddab97b1 100644 --- a/packages/runtime/src/domains/domain-protocol-handle-typing.test.ts +++ b/packages/runtime/src/domains/domain-protocol-handle-typing.test.ts @@ -58,6 +58,9 @@ * were never bought with a behaviour change. */ import { describe, expect, it } from 'vitest'; +// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias). +import '@objectstack/metadata'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { UiDomainProtocol } from './ui.js'; import type { MetaDomainProtocol } from './meta.js'; @@ -260,3 +263,28 @@ describe('#15238 · 2 · a PARTIAL protocol host is still answered, never crashe expect(result.response?.status).not.toBe(500); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the /meta probe 501s follow the request\'s language', () => { + for (const [path, method, key] of [ + ['/_drafts', 'GET', 'meta_draft_listing_unsupported'], + ['/_migrate-stored', 'POST', 'meta_stored_migration_unsupported'], + ] as const) { + it(key, async () => { + for (const [locale, extra] of LANGS_37811) { + const result = await partialProtocolDoor().handleMetadata(path, { ...META_ADMIN(), ...extra }, method, undefined, {}); + expect(result.response?.status).toBe(501); + expect(result.response?.body?.error?.message).toBe(sentence37811(locale, key)); + expect(vary37811(result.response)).toBe('Accept-Language'); + } + }); + } +}); diff --git a/packages/runtime/src/domains/i18n-anonymous-deny.test.ts b/packages/runtime/src/domains/i18n-anonymous-deny.test.ts index 2183b208c0d..3143c6f8af9 100644 --- a/packages/runtime/src/domains/i18n-anonymous-deny.test.ts +++ b/packages/runtime/src/domains/i18n-anonymous-deny.test.ts @@ -42,6 +42,7 @@ */ import { describe, it, expect, vi } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { ANONYMOUS_DENY_STATUS, ANONYMOUS_DENY_CODE, ANONYMOUS_DENY_MESSAGE, } from '@objectstack/core'; @@ -277,3 +278,24 @@ describe.each(FACES.filter((f) => f.malformed))('#22432 B — $face still answer expect(service.getTranslations).not.toHaveBeenCalled(); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the empty-slot 501 follows the request\'s language', () => { + it('i18n_service_unavailable', async () => { + for (const [locale, extra] of LANGS_37811) { + const { deps } = makeDeps(undefined); + const result: any = await call(deps, FACES[0], { ...member(), ...extra } as unknown as HttpProtocolContext); + expect(result.response.status).toBe(501); + expect(result.response.body.error.message).toBe(sentence37811(locale, 'i18n_service_unavailable')); + expect(vary37811(result.response)).toBe('Accept-Language'); + } + }); +}); diff --git a/packages/runtime/src/domains/i18n.ts b/packages/runtime/src/domains/i18n.ts index ca4e8bdd630..9b117e5a344 100644 --- a/packages/runtime/src/domains/i18n.ts +++ b/packages/runtime/src/domains/i18n.ts @@ -44,6 +44,7 @@ import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatch import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; // [#23214] The repo's one sentence for a repeated single-valued parameter. import { repeatedQueryParamMessage } from '@objectstack/rest'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * [#23214] `?locale=` on the two arms whose PATH names no locale @@ -222,7 +223,7 @@ export async function handleI18nRequest( // `degraded` (#4058 step 1 — `createMemoryI18n`, which plugin-dev also // wraps) and `handlerReady` defaults to `true` for them: they keep serving. // This gate is for an occupant that would answer with invented strings. - if (!isServiceServeable(i18nService)) return { handled: true, response: deps.error('i18n service not available', 501) }; + if (!isServiceServeable(i18nService)) return catalogNotImplemented(deps, context, 'i18n_service_unavailable'); const m = method.toUpperCase(); const parts = path.replace(/^\/+/, '').split('/').filter(Boolean); diff --git a/packages/runtime/src/domains/mcp.ts b/packages/runtime/src/domains/mcp.ts index 0721d914eb9..ec8fe99d149 100644 --- a/packages/runtime/src/domains/mcp.ts +++ b/packages/runtime/src/domains/mcp.ts @@ -72,6 +72,7 @@ import { automationAddressRegistryOf, bareNameRefusal } from './automation-addre import { maskObjectSchema, resolveObjectMasker } from './meta.js'; // [ADR-0106 D1] The run doors' visibility question, asked where an action is listed or run. import { actionRunFieldVisibilityRefusal, actionRunMasker, projectActionForCaller } from '../action-run-visibility.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** Typed as the registered vocabulary, so a misspelling fails to compile. */ const FIELD_VISIBILITY_UNRESOLVED: ErrorCode = 'FIELD_VISIBILITY_UNRESOLVED'; @@ -206,7 +207,7 @@ export async function handleMcpRequest(deps: DomainHandlerDeps, body: any, conte } const mcp: any = await deps.resolveService(context, 'mcp', context.environmentId); if (!mcp || typeof mcp.handleHttpRequest !== 'function') { - return { handled: true, response: deps.error('MCP server is not available', 501) }; + return catalogNotImplemented(deps, context, 'mcp_server_unavailable'); } // [#24151] The body is read once the anonymous decision above has admitted @@ -361,7 +362,7 @@ export async function handleMcpSkillRequest(deps: DomainHandlerDeps, method: str } const mcp: any = await deps.resolveService(context, 'mcp', context.environmentId); if (!mcp || typeof mcp.renderSkill !== 'function') { - return { handled: true, response: deps.error('MCP server is not available', 501) }; + return catalogNotImplemented(deps, context, 'mcp_server_unavailable'); } // Resolve this environment's MCP URL for the skill's Connect section: diff --git a/packages/runtime/src/domains/meta.ts b/packages/runtime/src/domains/meta.ts index 10da6116133..54018bfd582 100644 --- a/packages/runtime/src/domains/meta.ts +++ b/packages/runtime/src/domains/meta.ts @@ -121,6 +121,7 @@ import { buildApiError } from '../error-envelope.js'; import { readEffectiveTenancyPosture } from './activation-gate.js'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * [#15238] The `protocol` service slot **as this domain reaches it** — one @@ -1547,10 +1548,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin // A dedicated path cannot fall through to the plain read the way the // `?layers=` flag does — `RestServer`'s `501 NOT_IMPLEMENTED`, in this // transport's envelope. - return { - handled: true, - response: deps.error('Layered metadata view not supported by protocol implementation', 501), - }; + return catalogNotImplemented(deps, _context, 'meta_layered_view_unsupported'); } // [#22188] `RestServer`'s reading: `all` names no package. const packageId = metaItemPackageBinding(query?.package); @@ -2064,15 +2062,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin // `RestServer` gives any save its protocol cannot take — rather than // written unguarded or ACTIVE, the very drop just closed above. if (saveOptions.request.parentVersion !== undefined || saveOptions.request.mode !== undefined) { - return { - handled: true, - response: deps.error( - 'This host has no protocol saveMetaItem, so it cannot honour If-Match, If-None-Match ' - + 'or ?mode=draft on a save. Send the save without them, or save through a host whose ' - + 'protocol implements saveMetaItem.', - 501, - ), - }; + return catalogNotImplemented(deps, _context, 'meta_save_conditions_unsupported'); } // Fallback: try MetadataService directly @@ -2089,7 +2079,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 501) }; } } - return { handled: true, response: deps.error('Save not supported', 501) }; + return catalogNotImplemented(deps, _context, 'meta_save_unsupported'); } // [commit 4fc4a3c0b] The read `try` below is this block's default answer, and it @@ -2602,7 +2592,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Draft listing not supported', 501) }; + return catalogNotImplemented(deps, _context, 'meta_draft_listing_unsupported'); } // POST /metadata/_migrate-stored (#4327 / #4454 / #4498) @@ -2664,7 +2654,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin const protocol = await resolveProtocol(deps, _context); if (!protocol || typeof protocol.migrateStoredMetadata !== 'function') { - return { handled: true, response: deps.error('Stored-metadata migration not supported', 501) }; + return catalogNotImplemented(deps, _context, 'meta_stored_migration_unsupported'); } const types = Array.isArray(body?.types) ? body.types.filter((t: unknown): t is string => typeof t === 'string' && t.length > 0) diff --git a/packages/runtime/src/domains/own-door-bridge.ts b/packages/runtime/src/domains/own-door-bridge.ts index 2b3cd90b769..610652bcf06 100644 --- a/packages/runtime/src/domains/own-door-bridge.ts +++ b/packages/runtime/src/domains/own-door-bridge.ts @@ -270,10 +270,11 @@ function notImplementedSentence( /** * The request's top `Accept-Language` tag, from a fetch `Request` or a plain * header record: the language of an own door's `501`. The doors that are not - * bridges read it for their own `501`s too: the comment doors (`comments.ts`) - * and the webhook redelivery door (`webhooks.ts`, both #37610), the approval - * action-page door (`approvals.ts`) and the inbound automation hooks - * (`automation-hooks.ts`, both #37662). + * bridges reach it through {@link catalogNotImplemented} for their own `501`s: + * the comment doors (`comments.ts`) and the webhook redelivery door + * (`webhooks.ts`, both #37610), the approval action-page door (`approvals.ts`) + * and the inbound automation hooks (`automation-hooks.ts`, both #37662), and + * the other domain modules' `501`s (#37811). */ export function requestLocaleOf(context: HttpProtocolContext): string | undefined { const headers = (context.request as { headers?: unknown } | undefined)?.headers as diff --git a/packages/runtime/src/domains/packages-protocol-handle-typing.test.ts b/packages/runtime/src/domains/packages-protocol-handle-typing.test.ts index b1e5fc0f462..bd498c6d8f2 100644 --- a/packages/runtime/src/domains/packages-protocol-handle-typing.test.ts +++ b/packages/runtime/src/domains/packages-protocol-handle-typing.test.ts @@ -57,6 +57,9 @@ * bought with a behaviour change. */ import { describe, expect, it } from 'vitest'; +// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias). +import '@objectstack/metadata'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { PackagesDomainProtocol } from './packages.js'; @@ -197,3 +200,36 @@ describe('#13598 · 2 · a PARTIAL protocol host is still answered, never crashe expect(JSON.stringify(result.response?.body)).toContain('Customization package ensure not supported'); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] each probe 501 follows the request\'s language', () => { + const cases: Array<[string, string, string]> = [ + ['/crm/publish-drafts', 'POST', 'packages_draft_publish_unsupported'], + ['/crm/discard-drafts', 'POST', 'packages_draft_discard_unsupported'], + ['/crm/commits', 'GET', 'packages_commit_history_unsupported'], + ['/crm/commits/c1/revert', 'POST', 'packages_commit_revert_unsupported'], + ['/crm/rollback', 'POST', 'packages_commit_rollback_unsupported'], + ['/crm/adopt-orphans', 'POST', 'packages_orphan_adoption_unsupported'], + ['/crm/duplicate', 'POST', 'packages_duplication_unsupported'], + ['/crm/ensure-customization', 'POST', 'packages_customization_ensure_unsupported'], + ]; + for (const [path, method, key] of cases) { + it(key, async () => { + for (const [locale, extra] of LANGS_37811) { + const body = path.endsWith('/ensure-customization') ? undefined : { commitId: 'c1', targetPackageId: 'crm_copy' }; + const result = await partialProtocolDoor().handlePackages(path, method, body, {}, { ...PKG_ADMIN(), ...extra }); + expect(result.response?.status).toBe(501); + expect(result.response?.body?.error?.message).toBe(sentence37811(locale, key)); + expect(vary37811(result.response)).toBe('Accept-Language'); + } + }); + } +}); diff --git a/packages/runtime/src/domains/packages.ts b/packages/runtime/src/domains/packages.ts index 5f898d19778..1df5fc82640 100644 --- a/packages/runtime/src/domains/packages.ts +++ b/packages/runtime/src/domains/packages.ts @@ -194,6 +194,7 @@ import { getMetadataTypeRedactor } from '@objectstack/spec/kernel'; // the spec's one reference arbiter: never a second parser. import { analyzeRelationshipTraversals } from '@objectstack/formula'; import { referenceTargetOf } from '@objectstack/spec/data'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * [#13598] The `protocol` service slot **as this domain reaches it** — one @@ -3447,7 +3448,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Draft publishing not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_draft_publish_unsupported'); } // POST /packages/:id/discard-drafts → drop every pending DRAFT bound @@ -3486,7 +3487,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Draft discarding not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_draft_discard_unsupported'); } // ── ADR-0067: package-scoped commit history & rollback ────────── @@ -3514,7 +3515,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Commit history not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_commit_history_unsupported'); } // POST /packages/:id/commits/:commitId/revert → revert ONE commit @@ -3555,7 +3556,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Commit revert not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_commit_revert_unsupported'); } // POST /packages/:id/rollback body { commitId } → roll the package @@ -3588,7 +3589,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin return { handled: true, response: deps.errorFromThrown(e, 500) }; } } - return { handled: true, response: deps.error('Commit rollback not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_commit_rollback_unsupported'); } // POST /packages/:id/revert → revert package to last published state @@ -3737,7 +3738,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin const readOnly = requireWritablePackage(deps, qlService, id, 'adopt items into'); if (readOnly) return readOnly; const protocol = await resolveProtocol(deps, _context); if (!protocol || typeof protocol.reassignOrphanedMetadata !== 'function') { - return { handled: true, response: deps.error('Orphan adoption not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_orphan_adoption_unsupported'); } try { const actor = resolvePackageWriteActor(_context); @@ -3776,7 +3777,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin const queryRefused = refusePackageWriteDoorQuery(deps, query, PACKAGE_WRITE_NO_QUERY_PARAMS); if (queryRefused) return queryRefused; const protocol = await resolveProtocol(deps, _context); if (!protocol || typeof protocol.duplicatePackage !== 'function') { - return { handled: true, response: deps.error('Package duplication not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_duplication_unsupported'); } const targetPackageId = typeof body?.targetPackageId === 'string' ? body.targetPackageId.trim() : ''; if (!targetPackageId) { @@ -3842,7 +3843,7 @@ export async function handlePackagesRequest(deps: DomainHandlerDeps, path: strin } const protocol = await resolveProtocol(deps, _context); if (!protocol || typeof protocol.ensureCustomizationPackage !== 'function') { - return { handled: true, response: deps.error('Customization package ensure not supported', 501) }; + return catalogNotImplemented(deps, _context, 'packages_customization_ensure_unsupported'); } try { const result = await protocol.ensureCustomizationPackage({ basePackageId: id }); diff --git a/packages/runtime/src/domains/permission-set-clone.test.ts b/packages/runtime/src/domains/permission-set-clone.test.ts index 913959c20b4..7f8692b4761 100644 --- a/packages/runtime/src/domains/permission-set-clone.test.ts +++ b/packages/runtime/src/domains/permission-set-clone.test.ts @@ -24,6 +24,7 @@ // Pays `@objectstack/metadata`'s first load at collection, never inside a clocked case. import '@objectstack/metadata'; import { describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { MULTI_REPLICA_PACKAGE_CHANGE_REFUSED } from '@objectstack/service-cluster'; import { installedManifestsOf, pairOf } from '@objectstack/metadata-core'; @@ -759,3 +760,39 @@ describe('an explicit `package` naming an App member\'s pair — the target rule expect(h.saves).toHaveLength(0); }); }); + +// [#37811] This door's 501 sentence is the operation-message catalog's, in the +// request's top `Accept-Language` tag: byte-identical English with no header, +// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way. +const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } }; +const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const; +const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record = {}): string => + BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? ''); +const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary; + +describe('[#37811] the clone door\'s 501s follow the request\'s language', () => { + it('permission_set_clone_pair_unsupported names the set and its read-only package', async () => { + for (const [locale, extra] of LANGS_37811) { + const h = boot({ noEnsure: true }); + const res = await clone(h, { ...HOLDER(), ...extra } as HttpProtocolContext, PACKAGED.name, { name: 'x_copy', label: 'X' }); + expect(statusOf(res)).toBe(501); + expect(res.response?.body?.error?.code).toBe('NOT_IMPLEMENTED'); + expect(res.response?.body?.error?.message).toBe(sentence37811(locale, 'permission_set_clone_pair_unsupported', { + name: PACKAGED.name, + packageId: PACKAGED.packageId, + })); + expect(vary37811(res.response)).toBe('Accept-Language'); + expect(h.saves).toEqual([]); + } + }); + + it('permission_set_clone_no_protocol', async () => { + for (const [locale, extra] of LANGS_37811) { + const h = boot({ noProtocol: true }); + const res = await clone(h, { ...HOLDER(), ...extra } as HttpProtocolContext, PACKAGED.name, { name: 'x_copy', label: 'X' }); + expect(statusOf(res)).toBe(501); + expect(res.response?.body?.error?.message).toBe(sentence37811(locale, 'permission_set_clone_no_protocol')); + expect(vary37811(res.response)).toBe('Accept-Language'); + } + }); +}); diff --git a/packages/runtime/src/domains/permission-set-clone.ts b/packages/runtime/src/domains/permission-set-clone.ts index a54f70c1edd..bb006fc1547 100644 --- a/packages/runtime/src/domains/permission-set-clone.ts +++ b/packages/runtime/src/domains/permission-set-clone.ts @@ -145,6 +145,8 @@ import { validationFailure } from '../validation-failure.js'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import { multiReplicaPairCreationRefusal, multiReplicaPackageChangeError } from '../multi-replica-package-refusal.js'; import type { DomainHandlerDeps } from '../domain-handler-registry.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; +import { operationUserMessage } from '@objectstack/core'; /** The door's first path segment under `/security`. */ export const PERMISSION_SET_CLONE_SEGMENT = 'permission-sets'; @@ -324,6 +326,9 @@ export function permissionSetObjectNames(definition: Readonly> | undefined = await deps.resolveServiceOrLoud(context, 'protocol'); if (typeof protocol?.saveMetaItem !== 'function') { - return { - handled: true, - response: deps.error( - 'This deployment has no metadata protocol to save the copy through, so a permission set cannot be cloned here.', - 501, - ), - }; + return catalogNotImplemented(deps, context, 'permission_set_clone_no_protocol'); } // ── 6. landing ────────────────────────────────────────────────────── let landing: PermissionSetCloneLanding; @@ -595,12 +594,23 @@ export async function handlePermissionSetCloneWrite( if (refused) return newSimilarTargetRefusalAnswer(deps, refused); landing = { packageId: target.package, created: false }; } else { - landing = await resolveDefaultCloneLanding(ql, protocol, source, async (base) => { - // [cloud#3814 D1] Declared replicas on the Redis driver: creating - // the pair here would register a package on this replica alone. - const oneReplica = await multiReplicaPairCreationRefusal(deps, context, ql, base, `Cloning permission set '${source.name}'`); - if (oneReplica) throw multiReplicaPackageChangeError(oneReplica); - }); + try { + landing = await resolveDefaultCloneLanding(ql, protocol, source, async (base) => { + // [cloud#3814 D1] Declared replicas on the Redis driver: creating + // the pair here would register a package on this replica alone. + const oneReplica = await multiReplicaPairCreationRefusal(deps, context, ql, base, `Cloning permission set '${source.name}'`); + if (oneReplica) throw multiReplicaPackageChangeError(oneReplica); + }); + } catch (err: unknown) { + // [#37811] The landing's 501 (no paired customization package can + // be ensured, so nothing was written), in the request's language. + // Every other failure goes on to the catch below, as before. + const thrown = err as { statusCode?: unknown; messageKey?: unknown; params?: Record } | null; + if (thrown?.statusCode === 501 && thrown.messageKey === PAIR_UNSUPPORTED_KEY) { + return catalogNotImplemented(deps, context, PAIR_UNSUPPORTED_KEY, thrown.params); + } + throw err; + } } // ── 7. the save ───────────────────────────────────────────────────── diff --git a/packages/runtime/src/domains/security.ts b/packages/runtime/src/domains/security.ts index 6289a54f928..0f0a9f2164e 100644 --- a/packages/runtime/src/domains/security.ts +++ b/packages/runtime/src/domains/security.ts @@ -42,6 +42,7 @@ import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry. import { readDispatchedBody } from '../deferred-request-body.js'; // [#23214] The repo's one sentence for a repeated single-valued parameter. import { repeatedQueryParamMessage } from '@objectstack/rest'; +import { catalogNotImplemented } from './own-door-bridge.js'; export function createSecurityDomain(deps: DomainHandlerDeps): DomainRoute { return { @@ -200,14 +201,7 @@ export async function handleSecurityRequest( // door is answered as such, never as a 404 on a mounted route. if (parts[2] === 'reopen') { if (typeof service.reopenAudienceBindingSuggestion !== 'function') { - return { - handled: true, - response: deps.error( - 'This deployment\'s security service does not implement re-opening a dismissed ' + - 'audience-binding suggestion, so the dismissal stands.', - 501, - ), - }; + return catalogNotImplemented(deps, context, 'security_audience_reopen_unsupported'); } const result = await service.reopenAudienceBindingSuggestion(ec, id); return { handled: true, response: deps.success(result) }; diff --git a/packages/runtime/src/domains/share-links.ts b/packages/runtime/src/domains/share-links.ts index 7beda49d92b..757e573e726 100644 --- a/packages/runtime/src/domains/share-links.ts +++ b/packages/runtime/src/domains/share-links.ts @@ -82,6 +82,7 @@ import { buildShareLinkResolveAnswer, type ShareLinkLabelI18n, type ShareLinkLab import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; export function createShareLinksDomain(deps: DomainHandlerDeps): DomainRoute { return { @@ -181,7 +182,7 @@ async function handleShareLinksRequestBody( // is not configured" on an environment where it is. const svc = await deps.resolveService(context, SHARE_LINK_SERVICE, context.environmentId); if (!svc) { - return { handled: true, response: deps.error('Sharing is not configured', 501) }; + return catalogNotImplemented(deps, context, 'share_links_unconfigured'); } const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] } as const; diff --git a/packages/spec/src/system/operation-message.test.ts b/packages/spec/src/system/operation-message.test.ts index ca9810ebd56..5698f75f4e6 100644 --- a/packages/spec/src/system/operation-message.test.ts +++ b/packages/spec/src/system/operation-message.test.ts @@ -763,3 +763,28 @@ describe('operation message catalog — the print door\'s own 5xx sentences', () } }); }); + +// [#37811] The dispatcher domains' remaining `501`s: each key is translated in +// every locale (no English echo outside `en`) and keeps exactly the +// placeholders the English names, so no locale drops a member, table or name. +describe('operation message catalog — the domain modules\' 501 sentences (#37811)', () => { + const placeholders = (template: string): string[] => [...template.matchAll(/\{\{(\w+)\}\}/g)].map((m) => m[1]).sort(); + const KEYS = Object.keys(BUILTIN_OPERATION_MESSAGES.en).filter((key) => + /^(auth_service_unavailable|i18n_service_unavailable|mcp_server_unavailable|meta_|packages_|automation_(connector|flow|resume|run|screen)|action_activation_|catalog_activation_|permission_set_clone_|security_audience_|share_links_)/.test(key), + ); + + it('names the thirty-seven keys (thirty-one sentences, six activation nouns)', () => { + expect(KEYS).toHaveLength(37); + }); + + it.each(KEYS)('%s: every locale translates it and keeps the English placeholders', (key) => { + const en = BUILTIN_OPERATION_MESSAGES.en[key]; + for (const locale of ['zh-CN', 'ja-JP', 'es-ES']) { + const text = BUILTIN_OPERATION_MESSAGES[locale][key]; + expect(text, `${locale} ${key}`).toBeTruthy(); + expect(text, `${locale} ${key}`).not.toBe(en); + expect(placeholders(text), `${locale} ${key}`).toEqual(placeholders(en)); + } + }); +}); + diff --git a/packages/spec/src/system/operation-message.ts b/packages/spec/src/system/operation-message.ts index cafa9f899d2..2acc5b32062 100644 --- a/packages/spec/src/system/operation-message.ts +++ b/packages/spec/src/system/operation-message.ts @@ -387,6 +387,17 @@ export function operationMessageTranslationKey(messageKey: string): string { * `errors.approvals_act_*` or `errors.automation_hooks_*` override is * consulted. Their English is byte-identical to the fixed sentences the doors * answered before they were localized. + * + * The keys from `auth_service_unavailable` to `share_links_unconfigured` are + * the remaining `501`s of the dispatcher's domain modules (`auth.ts`, + * `i18n.ts`, `mcp.ts`, `meta.ts`, `packages.ts`, `automation.ts`, + * `actions.ts`, `catalog-activation.ts`, `permission-set-clone.ts`, + * `security.ts`, `share-links.ts`, #37811), read the same way: by the + * request's top `Accept-Language` tag, with no `errors.*` override consulted. + * Their English is byte-identical to the fixed sentences they replace. + * `{{member}}`, `{{table}}`, `{{name}}` and `{{packageId}}` are code, table, + * item and package names, never translated; `{{noun}}` is one of the + * `catalog_activation_noun_*` keys, rendered in the same locale. */ export const BUILTIN_OPERATION_MESSAGES: Record> = { en: { @@ -483,6 +494,56 @@ export const BUILTIN_OPERATION_MESSAGES: Record> 'Inbound automation hooks are not available: no trigger-api service is registered. The inbound-hook trigger (@objectstack/trigger-api) serves this route through that service; compose it on the environment that owns the flow.', automation_hooks_member_missing: 'Inbound automation hooks are not available: the registered trigger-api service does not implement handleInboundHook.', + auth_service_unavailable: 'Auth service not available — register @objectstack/plugin-auth to enable authentication', + i18n_service_unavailable: 'i18n service not available', + mcp_server_unavailable: 'MCP server is not available', + meta_layered_view_unsupported: 'Layered metadata view not supported by protocol implementation', + meta_save_conditions_unsupported: + 'This host has no protocol saveMetaItem, so it cannot honour If-Match, If-None-Match or ?mode=draft on a save. Send the save without them, or save through a host whose protocol implements saveMetaItem.', + meta_save_unsupported: 'Save not supported', + meta_draft_listing_unsupported: 'Draft listing not supported', + meta_stored_migration_unsupported: 'Stored-metadata migration not supported', + packages_draft_publish_unsupported: 'Draft publishing not supported', + packages_draft_discard_unsupported: 'Draft discarding not supported', + packages_commit_history_unsupported: 'Commit history not supported', + packages_commit_revert_unsupported: 'Commit revert not supported', + packages_commit_rollback_unsupported: 'Commit rollback not supported', + packages_orphan_adoption_unsupported: 'Orphan adoption not supported', + packages_duplication_unsupported: 'Package duplication not supported', + packages_customization_ensure_unsupported: 'Customization package ensure not supported', + automation_connector_credentials_unsupported: + 'Connector credentials are not supported by the automation service this deployment mounts — it does not implement `{{member}}`, an optional member of `IAutomationService`. Nothing was read or changed.', + automation_connector_connections_unsupported: + 'Connector connections are not supported by the automation service this deployment mounts — it does not implement `{{member}}`, an optional member of `IAutomationService`. Nothing was read or changed.', + automation_flow_clone_unsupported: + 'Flow clone not supported: a copy lands in a package, and this deployment has no metadata protocol that can ensure a customization package and save a flow into it.', + automation_resume_unsupported: 'Resume not supported', + automation_run_cancel_unsupported: + 'Cancelling a run is not supported by the automation service this deployment mounts — it does not implement `cancelRun`, an optional member of `IAutomationService`. No run was cancelled.', + automation_run_restore_unsupported: + 'Restoring a consumed suspension is not supported by the automation service this deployment mounts — it does not implement `restoreConsumedSuspension`, an optional member of `IAutomationService`. No suspension was restored.', + automation_screen_lookup_unsupported: 'Screen lookup not supported', + automation_runs_list_unsupported: + 'Listing the runs of a flow is not supported by the automation service this deployment mounts — it does not implement `listRunsPage`, an optional member of `IAutomationService`. No runs were listed.', + action_activation_ledger_unsupported: + "This deployment's data engine does not implement the packaged-metadata activation ledger (ADR-0126 §8), so a packaged action cannot be switched off here.", + catalog_activation_ledger_missing_on: + "This deployment does not carry the activation ledger ({{table}}, ADR-0126 §4), so {{noun}} '{{name}}' cannot be switched on here.", + catalog_activation_ledger_missing_off: + "This deployment does not carry the activation ledger ({{table}}, ADR-0126 §4), so {{noun}} '{{name}}' cannot be switched off here.", + catalog_activation_noun_position: 'position', + catalog_activation_noun_permission: 'permission set', + catalog_activation_noun_sharing_rule: 'declared sharing rule', + catalog_activation_noun_webhook: 'declared webhook', + catalog_activation_noun_queue: 'declared queue', + catalog_activation_noun_assignment_rule: 'declared assignment rule', + permission_set_clone_pair_unsupported: + "Permission set '{{name}}' is shipped by read-only package '{{packageId}}', so its copy belongs in that package's paired customization package, and this deployment's metadata protocol cannot ensure one.", + permission_set_clone_no_protocol: + 'This deployment has no metadata protocol to save the copy through, so a permission set cannot be cloned here.', + security_audience_reopen_unsupported: + "This deployment's security service does not implement re-opening a dismissed audience-binding suggestion, so the dismissal stands.", + share_links_unconfigured: 'Sharing is not configured', }, 'zh-CN': { permission_denied: '您没有执行此操作的权限,如需访问请联系管理员。', @@ -549,6 +610,48 @@ export const BUILTIN_OPERATION_MESSAGES: Record> automation_hooks_service_unregistered: '入站自动化钩子不可用:未注册 trigger-api 服务。入站钩子触发器(@objectstack/trigger-api)通过该服务提供此路由;请在拥有该流程的环境上组合它。', automation_hooks_member_missing: '入站自动化钩子不可用:已注册的 trigger-api 服务未实现 handleInboundHook。', + auth_service_unavailable: '认证服务不可用:请注册 @objectstack/plugin-auth 以启用认证。', + i18n_service_unavailable: 'i18n 服务不可用。', + mcp_server_unavailable: 'MCP 服务器不可用。', + meta_layered_view_unsupported: '不支持分层元数据视图:当前的协议实现未提供该功能。', + meta_save_conditions_unsupported: + '此主机的协议未提供 saveMetaItem,因此保存时无法遵循 If-Match、If-None-Match 或 ?mode=draft。请去掉这些条件后再保存,或通过协议实现了 saveMetaItem 的主机保存。', + meta_save_unsupported: '不支持保存。', + meta_draft_listing_unsupported: '不支持列出草稿。', + meta_stored_migration_unsupported: '不支持迁移已存储的元数据。', + packages_draft_publish_unsupported: '不支持发布草稿。', + packages_draft_discard_unsupported: '不支持丢弃草稿。', + packages_commit_history_unsupported: '不支持查看提交历史。', + packages_commit_revert_unsupported: '不支持撤销提交。', + packages_commit_rollback_unsupported: '不支持回滚到某次提交。', + packages_orphan_adoption_unsupported: '不支持认领孤立的元数据。', + packages_duplication_unsupported: '不支持复制软件包。', + packages_customization_ensure_unsupported: '不支持确保定制软件包存在。', + automation_connector_credentials_unsupported: + '此部署挂载的自动化服务不支持连接器凭据:它未实现 `IAutomationService` 的可选成员 `{{member}}`。未读取或更改任何内容。', + automation_connector_connections_unsupported: + '此部署挂载的自动化服务不支持连接器连接:它未实现 `IAutomationService` 的可选成员 `{{member}}`。未读取或更改任何内容。', + automation_flow_clone_unsupported: '不支持复制流程:副本要存入一个软件包,而此部署没有能够确保定制软件包存在并将流程保存进去的元数据协议。', + automation_resume_unsupported: '不支持恢复运行。', + automation_run_cancel_unsupported: '此部署挂载的自动化服务不支持取消运行:它未实现 `IAutomationService` 的可选成员 `cancelRun`。没有取消任何运行。', + automation_run_restore_unsupported: + '此部署挂载的自动化服务不支持恢复已消费的挂起:它未实现 `IAutomationService` 的可选成员 `restoreConsumedSuspension`。没有恢复任何挂起。', + automation_screen_lookup_unsupported: '不支持查询屏幕。', + automation_runs_list_unsupported: '此部署挂载的自动化服务不支持列出流程的运行:它未实现 `IAutomationService` 的可选成员 `listRunsPage`。没有列出任何运行。', + action_activation_ledger_unsupported: '此部署的数据引擎未实现软件包元数据的启用台账(ADR-0126 §8),因此无法在这里停用软件包中的动作。', + catalog_activation_ledger_missing_on: "此部署没有启用台账({{table}},ADR-0126 §4),因此无法在这里启用{{noun}} '{{name}}'。", + catalog_activation_ledger_missing_off: "此部署没有启用台账({{table}},ADR-0126 §4),因此无法在这里停用{{noun}} '{{name}}'。", + catalog_activation_noun_position: '岗位', + catalog_activation_noun_permission: '权限集', + catalog_activation_noun_sharing_rule: '声明的共享规则', + catalog_activation_noun_webhook: '声明的 webhook', + catalog_activation_noun_queue: '声明的队列', + catalog_activation_noun_assignment_rule: '声明的分配规则', + permission_set_clone_pair_unsupported: + "权限集 '{{name}}' 由只读软件包 '{{packageId}}' 提供,因此它的副本应存入该软件包配对的定制软件包,而此部署的元数据协议无法确保该定制软件包存在。", + permission_set_clone_no_protocol: '此部署没有可用于保存副本的元数据协议,因此无法在这里复制权限集。', + security_audience_reopen_unsupported: '此部署的安全服务未实现重新打开已忽略的受众绑定建议,因此该忽略保持有效。', + share_links_unconfigured: '未配置共享。', }, 'ja-JP': { permission_denied: 'この操作を実行する権限がありません。アクセスが必要な場合は管理者にお問い合わせください。', @@ -639,6 +742,54 @@ export const BUILTIN_OPERATION_MESSAGES: Record> '受信自動化フックは利用できません。trigger-api サービスが登録されていません。受信フックトリガー(@objectstack/trigger-api)がこのサービスを通じてこのルートを提供します。フローを所有する環境に組み込んでください。', automation_hooks_member_missing: '受信自動化フックは利用できません。登録されている trigger-api サービスは handleInboundHook を実装していません。', + auth_service_unavailable: '認証サービスは利用できません。認証を有効にするには @objectstack/plugin-auth を登録してください。', + i18n_service_unavailable: 'i18n サービスは利用できません。', + mcp_server_unavailable: 'MCP サーバーは利用できません。', + meta_layered_view_unsupported: 'レイヤー化されたメタデータビューはサポートされていません。プロトコル実装がこの機能を提供していません。', + meta_save_conditions_unsupported: + 'このホストのプロトコルには saveMetaItem がないため、保存時に If-Match、If-None-Match、?mode=draft を適用できません。これらを付けずに保存するか、プロトコルが saveMetaItem を実装しているホストを通じて保存してください。', + meta_save_unsupported: '保存はサポートされていません。', + meta_draft_listing_unsupported: '下書きの一覧表示はサポートされていません。', + meta_stored_migration_unsupported: '保存済みメタデータの移行はサポートされていません。', + packages_draft_publish_unsupported: '下書きの公開はサポートされていません。', + packages_draft_discard_unsupported: '下書きの破棄はサポートされていません。', + packages_commit_history_unsupported: 'コミット履歴はサポートされていません。', + packages_commit_revert_unsupported: 'コミットの取り消しはサポートされていません。', + packages_commit_rollback_unsupported: 'コミットへのロールバックはサポートされていません。', + packages_orphan_adoption_unsupported: '孤立したメタデータの引き取りはサポートされていません。', + packages_duplication_unsupported: 'パッケージの複製はサポートされていません。', + packages_customization_ensure_unsupported: 'カスタマイズパッケージの確保はサポートされていません。', + automation_connector_credentials_unsupported: + 'このデプロイメントに組み込まれた自動化サービスはコネクタ資格情報をサポートしていません。`IAutomationService` の任意メンバー `{{member}}` を実装していません。何も読み取り・変更されていません。', + automation_connector_connections_unsupported: + 'このデプロイメントに組み込まれた自動化サービスはコネクタ接続をサポートしていません。`IAutomationService` の任意メンバー `{{member}}` を実装していません。何も読み取り・変更されていません。', + automation_flow_clone_unsupported: + 'フローの複製はサポートされていません。コピーはパッケージに保存されますが、このデプロイメントにはカスタマイズパッケージを確保してフローを保存できるメタデータプロトコルがありません。', + automation_resume_unsupported: '再開はサポートされていません。', + automation_run_cancel_unsupported: + 'このデプロイメントに組み込まれた自動化サービスは実行のキャンセルをサポートしていません。`IAutomationService` の任意メンバー `cancelRun` を実装していません。実行はキャンセルされていません。', + automation_run_restore_unsupported: + 'このデプロイメントに組み込まれた自動化サービスは消費済みの一時停止の復元をサポートしていません。`IAutomationService` の任意メンバー `restoreConsumedSuspension` を実装していません。一時停止は復元されていません。', + automation_screen_lookup_unsupported: '画面の参照はサポートされていません。', + automation_runs_list_unsupported: + 'このデプロイメントに組み込まれた自動化サービスはフローの実行一覧をサポートしていません。`IAutomationService` の任意メンバー `listRunsPage` を実装していません。実行は一覧表示されていません。', + action_activation_ledger_unsupported: + 'このデプロイメントのデータエンジンはパッケージ化されたメタデータの有効化台帳(ADR-0126 §8)を実装していないため、ここではパッケージ化されたアクションを無効にできません。', + catalog_activation_ledger_missing_on: + "このデプロイメントには有効化台帳({{table}}、ADR-0126 §4)がないため、ここでは{{noun}} '{{name}}' を有効にできません。", + catalog_activation_ledger_missing_off: + "このデプロイメントには有効化台帳({{table}}、ADR-0126 §4)がないため、ここでは{{noun}} '{{name}}' を無効にできません。", + catalog_activation_noun_position: '役職', + catalog_activation_noun_permission: '権限セット', + catalog_activation_noun_sharing_rule: '宣言された共有ルール', + catalog_activation_noun_webhook: '宣言された Webhook', + catalog_activation_noun_queue: '宣言されたキュー', + catalog_activation_noun_assignment_rule: '宣言された割り当てルール', + permission_set_clone_pair_unsupported: + "権限セット '{{name}}' は読み取り専用パッケージ '{{packageId}}' が提供しているため、そのコピーはこのパッケージと対になるカスタマイズパッケージに属しますが、このデプロイメントのメタデータプロトコルはそれを確保できません。", + permission_set_clone_no_protocol: 'このデプロイメントにはコピーを保存するためのメタデータプロトコルがないため、ここでは権限セットを複製できません。', + security_audience_reopen_unsupported: 'このデプロイメントのセキュリティサービスは却下された対象者バインドの提案を再度開く機能を実装していないため、却下はそのまま有効です。', + share_links_unconfigured: '共有が構成されていません。', }, 'es-ES': { permission_denied: @@ -734,6 +885,58 @@ export const BUILTIN_OPERATION_MESSAGES: Record> 'Los ganchos de automatización entrantes no están disponibles: no hay ningún servicio trigger-api registrado. El disparador de ganchos entrantes (@objectstack/trigger-api) sirve esta ruta a través de ese servicio; compóngalo en el entorno al que pertenece el flujo.', automation_hooks_member_missing: 'Los ganchos de automatización entrantes no están disponibles: el servicio trigger-api registrado no implementa handleInboundHook.', + auth_service_unavailable: + 'El servicio de autenticación no está disponible: registre @objectstack/plugin-auth para habilitar la autenticación.', + i18n_service_unavailable: 'El servicio i18n no está disponible.', + mcp_server_unavailable: 'El servidor MCP no está disponible.', + meta_layered_view_unsupported: + 'La vista de metadatos por capas no está disponible: la implementación del protocolo no la admite.', + meta_save_conditions_unsupported: + 'Este host no tiene saveMetaItem en su protocolo, por lo que no puede respetar If-Match, If-None-Match ni ?mode=draft al guardar. Guarde sin ellos o guarde a través de un host cuyo protocolo implemente saveMetaItem.', + meta_save_unsupported: 'No se admite guardar.', + meta_draft_listing_unsupported: 'No se admite listar borradores.', + meta_stored_migration_unsupported: 'No se admite migrar los metadatos almacenados.', + packages_draft_publish_unsupported: 'No se admite publicar borradores.', + packages_draft_discard_unsupported: 'No se admite descartar borradores.', + packages_commit_history_unsupported: 'No se admite el historial de confirmaciones.', + packages_commit_revert_unsupported: 'No se admite revertir una confirmación.', + packages_commit_rollback_unsupported: 'No se admite restaurar una confirmación anterior.', + packages_orphan_adoption_unsupported: 'No se admite adoptar metadatos huérfanos.', + packages_duplication_unsupported: 'No se admite duplicar paquetes.', + packages_customization_ensure_unsupported: 'No se admite asegurar el paquete de personalización.', + automation_connector_credentials_unsupported: + 'El servicio de automatización que monta esta implementación no admite credenciales de conector: no implementa `{{member}}`, un miembro opcional de `IAutomationService`. No se leyó ni cambió nada.', + automation_connector_connections_unsupported: + 'El servicio de automatización que monta esta implementación no admite conexiones de conector: no implementa `{{member}}`, un miembro opcional de `IAutomationService`. No se leyó ni cambió nada.', + automation_flow_clone_unsupported: + 'No se admite clonar flujos: la copia se guarda en un paquete, y esta implementación no tiene un protocolo de metadatos que pueda asegurar un paquete de personalización y guardar en él un flujo.', + automation_resume_unsupported: 'No se admite reanudar.', + automation_run_cancel_unsupported: + 'El servicio de automatización que monta esta implementación no admite cancelar una ejecución: no implementa `cancelRun`, un miembro opcional de `IAutomationService`. No se canceló ninguna ejecución.', + automation_run_restore_unsupported: + 'El servicio de automatización que monta esta implementación no admite restaurar una suspensión consumida: no implementa `restoreConsumedSuspension`, un miembro opcional de `IAutomationService`. No se restauró ninguna suspensión.', + automation_screen_lookup_unsupported: 'No se admite consultar la pantalla.', + automation_runs_list_unsupported: + 'El servicio de automatización que monta esta implementación no admite listar las ejecuciones de un flujo: no implementa `listRunsPage`, un miembro opcional de `IAutomationService`. No se listó ninguna ejecución.', + action_activation_ledger_unsupported: + 'El motor de datos de esta implementación no implementa el registro de activación de metadatos empaquetados (ADR-0126 §8), por lo que aquí no se puede desactivar una acción empaquetada.', + catalog_activation_ledger_missing_on: + "Esta implementación no tiene el registro de activación ({{table}}, ADR-0126 §4), por lo que aquí no se puede activar {{noun}} '{{name}}'.", + catalog_activation_ledger_missing_off: + "Esta implementación no tiene el registro de activación ({{table}}, ADR-0126 §4), por lo que aquí no se puede desactivar {{noun}} '{{name}}'.", + catalog_activation_noun_position: 'el puesto', + catalog_activation_noun_permission: 'el conjunto de permisos', + catalog_activation_noun_sharing_rule: 'la regla de uso compartido declarada', + catalog_activation_noun_webhook: 'el webhook declarado', + catalog_activation_noun_queue: 'la cola declarada', + catalog_activation_noun_assignment_rule: 'la regla de asignación declarada', + permission_set_clone_pair_unsupported: + "El conjunto de permisos '{{name}}' lo proporciona el paquete de solo lectura '{{packageId}}', así que su copia pertenece al paquete de personalización emparejado con ese paquete, y el protocolo de metadatos de esta implementación no puede asegurarlo.", + permission_set_clone_no_protocol: + 'Esta implementación no tiene un protocolo de metadatos con el que guardar la copia, por lo que aquí no se puede clonar un conjunto de permisos.', + security_audience_reopen_unsupported: + 'El servicio de seguridad de esta implementación no implementa reabrir una sugerencia de vinculación de audiencia descartada, por lo que el descarte se mantiene.', + share_links_unconfigured: 'El uso compartido no está configurado.', }, }; diff --git a/scripts/check-route-envelope.mjs b/scripts/check-route-envelope.mjs index b8ce285426c..4729309e965 100644 --- a/scripts/check-route-envelope.mjs +++ b/scripts/check-route-envelope.mjs @@ -1096,8 +1096,9 @@ const DISPATCHER_DOMAINS = { 'analytics.ts': { handBuilt: 0 }, // [#22576] The `/approvals/act` bridge: the approvals member's own HTML // `Response` is handed back as `result` (the `/auth` shape), and every - // refusal it makes itself — the two 501s, the sanitised 500s — goes through - // `deps.error`. + // refusal it makes itself goes through `deps.error`: the sanitised 500s + // directly, the two 501s through `own-door-bridge.ts`'s + // `catalogNotImplemented` (#37737), which adds their `Vary`. 'approvals.ts': { handBuilt: 0 }, // [#36506] The `/attachments` bridge: two lines naming what // `own-door-bridge.ts` forwards; it builds no answer of its own. @@ -1116,8 +1117,8 @@ const DISPATCHER_DOMAINS = { // [#22773] The inbound-hook door the `/automation` domain hands its one // admitted route to: the trigger-api member's own JSON `Response` is handed // back as `result` (the `/webhooks/redeliver` shape), and every refusal it - // makes itself — the two 501s, the sanitised 500s — goes through - // `deps.error`. + // makes itself goes through `deps.error`: the sanitised 500s directly, the + // two 501s through `own-door-bridge.ts`'s `catalogNotImplemented` (#37737). 'automation-hooks.ts': { handBuilt: 0 }, // The `/security` domain's catalog activation door (ADR-0126 §3 regime C, // ADR-0131 D6), split out of `security.ts` beside the gate it calls. Every @@ -1126,8 +1127,9 @@ const DISPATCHER_DOMAINS = { // [#36469] The `/comments` bridge: the comments member's own JSON `Response` // is handed back as `result` (the `/webhooks/redeliver` shape), and every // answer the domain makes itself — the ordinary miss for a shape it does not - // serve, the two 501s, the sanitised 500s — goes through `deps.routeNotFound` - // / `deps.error`. + // serve, the sanitised 500s — goes through `deps.routeNotFound` / + // `deps.error`, and the two 501s through `own-door-bridge.ts`'s + // `catalogNotImplemented` (#37737). 'comments.ts': { handBuilt: 0 }, 'data.ts': { handBuilt: 0 }, // [#25785] Was 0. Kind 1: the translation bundle is the one `/i18n` face a @@ -1178,8 +1180,9 @@ const DISPATCHER_DOMAINS = { 'unavailable.ts': { handBuilt: 0 }, // [#22755] The `/webhooks/redeliver` bridge: the webhooks member's own JSON // `Response` is handed back as `result` (the `/approvals/act` shape), and - // every refusal it makes itself — the two 501s, the sanitised 500s — goes - // through `deps.error`. + // every refusal it makes itself goes through `deps.error`: the sanitised + // 500s directly, the two 501s through `own-door-bridge.ts`'s + // `catalogNotImplemented` (#37737). 'webhooks.ts': { handBuilt: 0 }, // Kind 1 — enveloped, hand-built only because the helper cannot say it.