/** * Shared validation and fault mapping for the five `weft.workflows.revisions.*` * / `weft.workflows.active.*` operations (WFT-11): `install-workflow-revision.ts`, * `activate-workflow-revision.ts`, `get-workflow-revision.ts`, * `list-workflow-revisions.ts`, `get-active-workflow-revision.ts`. * * @module server/operations/workflow-catalog-operation-helpers */ import { type WorkflowCatalogActivationResult } from '../../core/catalog/index.ts'; import type { WorkflowCompatibilityPolicy } from '../../core/contract/compatibility.ts'; import type { WorkflowRevisionManifest } from '../../core/contract/types.ts'; import type { AccessPolicy } from '../authorization.ts'; import type { OperationFault } from '../operation-fault.ts'; import type { RestInputContext } from '../rest-binding.ts'; /** `workflows:admin` — required by `install` and `activate` (mutating). */ export declare const workflowsAdminAccess: AccessPolicy; /** `workflows:read` — required by `get`/`list`/`active.get` (read-only). */ export declare const workflowsReadAccess: AccessPolicy; /** * Validate one `name` field per the wire-safe name grammar, raising the * same `InvalidParams` fault both REST and JSON-RPC callers see for every * other malformed identifier in this operation family. Bounded by * `validateWorkflowOrActivityName` itself (`MAX_CONTRACT_IDENTIFIER_BYTES`). */ export declare function validateWorkflowNameField(name: unknown): string; /** Validate one `revision` field: a non-empty, bounded opaque string. */ export declare function validateWorkflowRevisionField(revision: unknown): string; /** Validate an optional `expectedGeneration` field: a non-negative safe integer. */ export declare function validateExpectedGenerationField(value: unknown): number | undefined; /** Validate an optional `policy` field against the one tunable compatibility axis. */ export declare function validatePolicyField(value: unknown): WorkflowCompatibilityPolicy | undefined; /** * Validate an untrusted `manifest` field via {@link parseWorkflowRevisionManifest} — * the same hostile-input validation path (bounded sizes, recomputed * `contractHash`) every other manifest consumer in this codebase uses. */ export declare function validateManifestField(value: unknown): Promise; /** * Map one `applied: false` {@link WorkflowCatalogActivationResult} variant to * the canonical `Conflict` fault. Exhaustive over all four refusal reasons — * adding a fifth is a compile error here, forcing a deliberate wire mapping. */ export declare function activationRefusalToFault(result: Extract): OperationFault; /** * Map an error thrown by `engine.workflows.install()`/`activate()` to the * canonical operation fault, or rethrow unchanged when it is neither typed * error this family can produce (letting the operation pipeline's generic * `EngineFailure` wrapping handle anything else). * * Checked first, via {@link mapRevisionUnavailableToFault}: `WorkflowRevisionUnavailableError` * (WFT-21, Codex review round 14, P2 item S-QK) — `weft.workflows.revisions.install()`'s * own internal `WorkflowRevisionTombstonedError` is translated to this * public error BEFORE it ever reaches here (`installWorkflowRevision()`, * `engine-workflows-namespace.ts`), and `weft.workflows.revisions.preload()` * (`engine.workflows.preload()` → `resolveWorkflowSource()` → * `runSharedSourceLoad()`) throws it directly for the identical * tombstoned-revision case after source loading. Without this branch, both * operations had no typed mapping for it at all and it escaped as a masked * `EngineFailure`/500 instead of the operation's declared retryable * Conflict. */ export declare function throwWorkflowCatalogOperationFault(error: unknown): never; /** * Read a REST request body as a JSON object, raising `InvalidParams` for * malformed JSON or a non-object top-level value — shared by * `install-workflow-revision.ts` (body-only) and * `activate-workflow-revision.ts` (path `name` plus body fields). */ export declare function readWorkflowCatalogRestBody(request: Request, context: RestInputContext): Promise>;