/** * The protocol engine's declared operation surface (#707/#738). * * An engine declaring its operations is what lets a VERTICAL bind them to its * own URLs without restating them. Before this, a vertical mounting * `protocol/get` wrote its own `z.object({ instanceId })` — a second * description of a shape this engine already owned — and the operation NAME was * an unchecked string, because `ModuleRegistration` erases its keys. * * What is deliberately NOT here: * * - **`http`.** This engine is entity-agnostic and owns no URL shape: Callout * hangs protocols off work orders and Handlebar off bikes, and both are right. * The path is the composing vertical's decision, declared with * `defineEngineRoutes` against these names. * - **`emits`.** The manifest still declares the nine event types by hand, as * engine-workorder's does. Deriving them needs `entityIdFrom` to name an * OUTPUT field carrying the protocol's id, and three of these operations * answer with a composite whose instance sits one level down * (`{ instance, signature }`). Declaring the events would mean either * flattening returns to suit the declaration or guessing the id — and #695's * eighteen `entityId: undefined` events are what guessing that field looks * like. It stays hand-declared until the model can say `instance.id`. * - **The in-scope functions.** `defineTemplate`, `instantiateProtocol`, * `fillProtocol` and the rest are composed by call, inside a vertical's own * transaction. These fourteen names are their default HTTP-reachable * bindings, not a second way in. * * ## Inputs are the handler's own schemas, with three deliberate exceptions * * Every `input` below is the same Zod object the in-scope function parses — * that identity is the reason the model is TypeScript, and it is what makes a * transcribed argument name impossible. The exceptions are the operations whose * REGISTERED shape has always differed from the function's: `instantiate` * takes a flattened `entityType`/`entityId` pair where `instantiateProtocol` * takes an `EntityRef`, and `sign`/`countersign`/`get`/`void` take an id where * the functions take richer arguments. Those shapes are declared here because * here is where they are true. */ import { z } from '@substrat-run/contracts'; /** The keys these operations check. Mirrors `PROTOCOL_PERM` in index.ts. */ export declare const PROTOCOL_PERMISSIONS: readonly ['protocol:create', 'protocol:fill', 'protocol:bind', 'protocol:request-signature', 'protocol:record-signature', 'protocol:sign', 'protocol:countersign', 'protocol:read', 'protocol:attach', 'protocol:void']; export declare const protocolOperations: { readonly 'protocol/define-template': { readonly summary: "Define a protocol template, or version an existing one"; readonly permission: "protocol:create"; readonly input: z.ZodObject<{ key: z.ZodString; title: z.ZodString; content: z.ZodPreprocess; sections: z.ZodArray; unit: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"document">; documentType: z.ZodString; hashRecipe: z.ZodString; description: z.ZodOptional; }, z.core.$strip>], "kind">>; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; key: z.ZodString; version: z.ZodNumber; title: z.ZodString; content_json: z.ZodString; created_at: z.ZodString; }, z.core.$strip>; }; readonly 'protocol/list-templates': { readonly summary: "The latest version of every template — the instantiation picker"; readonly permission: "protocol:read"; readonly output: z.ZodObject<{ id: z.ZodString; key: z.ZodString; version: z.ZodNumber; title: z.ZodString; content_json: z.ZodString; created_at: z.ZodString; }, z.core.$strip>; readonly paged: { readonly sortKey: "key"; }; }; readonly 'protocol/instantiate': { readonly summary: "Start a protocol instance on an entity, pinning the template version"; readonly permission: "protocol:create"; readonly input: z.ZodObject<{ templateKey: z.ZodString; entityType: z.ZodString; entityId: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; }; readonly 'protocol/fill': { readonly summary: "Record a response on an open checklist protocol (append-only)"; readonly permission: { readonly key: "protocol:fill"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; itemKey: z.ZodString; value: z.ZodUnion; note: z.ZodOptional; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; instance_id: z.ZodString; item_key: z.ZodString; value_json: z.ZodString; note: z.ZodNullable; responded_by: z.ZodString; responded_at: z.ZodString; }, z.core.$strip>; }; readonly 'protocol/bind-document': { readonly summary: "Bind vertical-owned document content and its hash to an open document protocol"; readonly permission: { readonly key: "protocol:bind"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; contentRef: z.ZodObject<{ entityType: z.ZodString; entityId: z.ZodString; }, z.core.$strip>; contentHash: z.ZodString; documentAttachmentId: z.ZodOptional>; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; }; readonly 'protocol/request-signatures': { readonly summary: "Freeze the content and request signatures from named parties"; readonly permission: { readonly key: "protocol:request-signature"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; method: z.ZodString; parties: z.ZodArray; ref: z.ZodOptional; signatureKind: z.ZodOptional>; authLevel: z.ZodOptional>; contact: z.ZodOptional; mobile: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; contentHash: z.ZodString; requests: z.ZodArray; party_ref: z.ZodNullable; signature_kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; auth_level: z.ZodNullable>; contact_key_id: z.ZodNullable; contact_ciphertext: z.ZodNullable; status: z.ZodEnum<{ cancelled: "cancelled"; declined: "declined"; expired: "expired"; pending: "pending"; signed: "signed"; }>; content_hash: z.ZodString; external_ref: z.ZodNullable; resolved_note: z.ZodNullable; requested_by: z.ZodString; requested_at: z.ZodString; resolved_at: z.ZodNullable; }, z.core.$strip>>; }, z.core.$strip>; }; readonly 'protocol/cancel-signatures': { readonly summary: "Withdraw an outstanding request set and thaw the instance"; readonly permission: { readonly key: "protocol:request-signature"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; reason: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; }; readonly 'protocol/record-signature': { readonly summary: "Record a signature reported by an external signing provider"; readonly permission: "protocol:record-signature"; readonly input: z.ZodObject<{ requestId: z.ZodString; signatory: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"principal">; ref: z.core.$ZodBranded; label: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"external">; ref: z.core.$ZodBranded; label: z.ZodOptional; }, z.core.$strip>], "kind">; signedAt: z.core.$ZodBranded; contentHash: z.ZodString; evidenceRef: z.ZodOptional; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; signature: z.ZodObject<{ id: z.ZodString; instance_id: z.ZodString; signed_by: z.ZodString; kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; content_hash: z.ZodString; evidence_ref: z.ZodNullable; signed_at: z.ZodString; request_id: z.ZodNullable; signatory_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; signatory_label: z.ZodNullable; }, z.core.$strip>; }, z.core.$strip>; }; readonly 'protocol/decline-signature': { readonly summary: "Record that a party declined, or that the provider’s window expired"; readonly permission: "protocol:record-signature"; readonly input: z.ZodObject<{ requestId: z.ZodString; reason: z.ZodString; outcome: z.ZodDefault>; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; instance_id: z.ZodString; party_label: z.ZodString; party_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; party_ref: z.ZodNullable; signature_kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; auth_level: z.ZodNullable>; contact_key_id: z.ZodNullable; contact_ciphertext: z.ZodNullable; status: z.ZodEnum<{ cancelled: "cancelled"; declined: "declined"; expired: "expired"; pending: "pending"; signed: "signed"; }>; content_hash: z.ZodString; external_ref: z.ZodNullable; resolved_note: z.ZodNullable; requested_by: z.ZodString; requested_at: z.ZodString; resolved_at: z.ZodNullable; }, z.core.$strip>; }; readonly 'protocol/sign': { readonly summary: "Sign a protocol in-app — freezes its content forever"; readonly permission: { readonly key: "protocol:sign"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; signature: z.ZodObject<{ id: z.ZodString; instance_id: z.ZodString; signed_by: z.ZodString; kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; content_hash: z.ZodString; evidence_ref: z.ZodNullable; signed_at: z.ZodString; request_id: z.ZodNullable; signatory_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; signatory_label: z.ZodNullable; }, z.core.$strip>; }, z.core.$strip>; }; readonly 'protocol/countersign': { readonly summary: "Counter-sign an already-signed protocol, on the same frozen content"; readonly permission: { readonly key: "protocol:countersign"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; signature: z.ZodObject<{ id: z.ZodString; instance_id: z.ZodString; signed_by: z.ZodString; kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; content_hash: z.ZodString; evidence_ref: z.ZodNullable; signed_at: z.ZodString; request_id: z.ZodNullable; signatory_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; signatory_label: z.ZodNullable; }, z.core.$strip>; }, z.core.$strip>; }; readonly 'protocol/void': { readonly summary: "Void (supersede) a protocol — never deletes"; readonly permission: { readonly key: "protocol:void"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; reason: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; }; readonly 'protocol/get': { readonly summary: "One protocol with its template, responses, signatures and requests"; readonly permission: { readonly key: "protocol:read"; readonly entity: "protocol"; readonly idFrom: "instanceId"; }; readonly input: z.ZodObject<{ instanceId: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; template: z.ZodObject<{ key: z.ZodString; version: z.ZodNumber; title: z.ZodString; content: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"checklist">; sections: z.ZodArray; unit: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"document">; documentType: z.ZodString; hashRecipe: z.ZodString; description: z.ZodOptional; }, z.core.$strip>], "kind">; }, z.core.$strip>; responses: z.ZodArray; responded_by: z.ZodString; responded_at: z.ZodString; }, z.core.$strip>>; latest: z.ZodRecord; responded_by: z.ZodString; responded_at: z.ZodString; }, z.core.$strip>>; signature: z.ZodNullable; method: z.ZodString; content_hash: z.ZodString; evidence_ref: z.ZodNullable; signed_at: z.ZodString; request_id: z.ZodNullable; signatory_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; signatory_label: z.ZodNullable; }, z.core.$strip>>; signatures: z.ZodArray; method: z.ZodString; content_hash: z.ZodString; evidence_ref: z.ZodNullable; signed_at: z.ZodString; request_id: z.ZodNullable; signatory_kind: z.ZodEnum<{ external: "external"; principal: "principal"; }>; signatory_label: z.ZodNullable; }, z.core.$strip>>; requests: z.ZodArray; party_ref: z.ZodNullable; signature_kind: z.ZodEnum<{ counter: "counter"; primary: "primary"; }>; method: z.ZodString; auth_level: z.ZodNullable>; contact_key_id: z.ZodNullable; contact_ciphertext: z.ZodNullable; status: z.ZodEnum<{ cancelled: "cancelled"; declined: "declined"; expired: "expired"; pending: "pending"; signed: "signed"; }>; content_hash: z.ZodString; external_ref: z.ZodNullable; resolved_note: z.ZodNullable; requested_by: z.ZodString; requested_at: z.ZodString; resolved_at: z.ZodNullable; }, z.core.$strip>>; }, z.core.$strip>; }; /** * The check is `protocol:read` against the entity the protocols hang on — a * work order in Callout, a bike in Handlebar — so the entity's TYPE arrives as * data, and `entity` must name a type known at declaration time. * * This declared `narrows` until #896, for want of anywhere else to put it, and * the note here said what was lost was "the entity type, which was never * available to lose". That was true and it was not the whole cost: `narrows` * describes a per-row PROOF WALK, and this is one check against one parent * before a single query. An operation set is read to find out what is checked * where, so a shape that says "asks per row" about an operation that asks once * is the artifact being wrong in a quieter way than being incomplete. * * `entityFrom` (#890) says what actually happens: narrowed to the entity named * by these two fields. The conformance kit cannot drive it — the types come * from an open `z.string()`, because an engine cannot enumerate its callers' * nouns — so it is reported as UNCOVERED with that reason, which is the correct * outcome and a louder one than being out of scope. Contrast * `engines/absence`, whose subject arrives as a whole `EntityRef` in one field * and is therefore drivable through `refFrom`. */ readonly 'protocol/list-for-entity': { readonly summary: "Every protocol on one entity, with its progress and signatures"; readonly permission: { readonly key: "protocol:read"; readonly entityFrom: "entityType"; readonly idFrom: "entityId"; }; readonly input: z.ZodObject<{ entityType: z.ZodString; entityId: z.ZodString; }, z.core.$strip>; readonly output: z.ZodObject<{ instance: z.ZodObject<{ id: z.ZodString; template_key: z.ZodString; template_version: z.ZodNumber; entity_type: z.ZodString; entity_id: z.ZodString; status: z.ZodEnum<{ open: "open"; pending_signature: "pending_signature"; signed: "signed"; voided: "voided"; }>; created_by: z.ZodString; created_at: z.ZodString; voided_by: z.ZodNullable; voided_reason: z.ZodNullable; voided_at: z.ZodNullable; content_ref_type: z.ZodNullable; content_ref_id: z.ZodNullable; bound_hash: z.ZodNullable; document_attachment_id: z.ZodNullable; frozen_hash: z.ZodNullable; frozen_at: z.ZodNullable; }, z.core.$strip>; title: z.ZodString; contentKind: z.ZodEnum<{ checklist: "checklist"; document: "document"; }>; answered: z.ZodNumber; total: z.ZodNumber; signedBy: z.ZodNullable; signedAt: z.ZodNullable; countersignedBy: z.ZodNullable; countersignedAt: z.ZodNullable; pendingSignatures: z.ZodNumber; }, z.core.$strip>; readonly paged: { readonly over: { readonly entity: "protocol"; readonly sortable: readonly ["id", "status", "created_at"]; readonly filterable: readonly ["entity_type", "entity_id", "status", "template_key"]; }; }; }; }; //# sourceMappingURL=operations.d.ts.map