Skip to content

API Reference parrot_formdesigner.api.routes

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.api.routes

View source

Route registration for the JSON REST surface of parrot-formdesigner.

Hard-imports navigator-auth: any consumer that does not have the package installed will fail at import time. This is intentional — see FEAT-152.

Public API:

setup_form_api(app, registry, *, client=None, submission_storage=None,
               forwarder=None, base_path="/api/v1",
               blob_storage=None, resolver=None) -> None

Lazy-init contract for REST field services (FEAT-170):

  • app["blob_storage"] — instance of AbstractBlobStorage, or None. When None, the upload handler (TASK-1170) constructs S3BlobStorage() on first use from environment variables (PARROT_BLOB_BUCKET, etc.).
  • app["rest_resolver"] — instance of RestFieldResolver, or None. When None, the upload handler creates a default instance on first use.

Callers that do not use FieldType.REST need not provide these kwargs; defaults are None and no exception is raised.

Autonomous FormSchema persistence (FEAT-457): passing alias_registry wires the connection-alias allowlist as the app["form_sink_aliases"] app key — an explicit, testable, deliberately NOT runtime-mutable security control (no route ever mutates it). A SinkFactory is built from it and injected into FormAPIHandler; a shutdown hook closes every cached sink. Omitting alias_registry (the default) leaves the feature entirely inactive — forms without a persistence block behave exactly as before this feature existed.

Alias AbstractBlobStorage

Re-exported from parrot_formdesigner.services.blob_storage.AbstractBlobStorage.

Alias AbstractFormRenderer

Re-exported from parrot_formdesigner.renderers.base.AbstractFormRenderer.

Alias FormAPIHandler

Re-exported from parrot_formdesigner.api.handlers.FormAPIHandler.

Alias FormRegistry

Re-exported from parrot_formdesigner.services.registry.FormRegistry.

Alias FormSubmissionStorage

Re-exported from parrot_formdesigner.services.submissions.FormSubmissionStorage.

Alias LLMQuota

Re-exported from parrot_formdesigner.services.llm_quota.LLMQuota.

Alias OrgGraphService

Re-exported from parrot_formdesigner.services.org_graph.OrgGraphService.

Alias PartialSaveStore

Re-exported from parrot_formdesigner.services.partial_saves.PartialSaveStore.

Alias PendingUploadStore

Re-exported from parrot_formdesigner.services.pending_uploads.PendingUploadStore.

Alias ProjectService

Re-exported from parrot_formdesigner.services.project_service.ProjectService.

Alias RBACService

Re-exported from parrot_formdesigner.services.rbac.RBACService.

Alias RestFieldResolver

Re-exported from parrot_formdesigner.services.rest_field_resolver.RestFieldResolver.

Alias SinkAliasRegistry

Re-exported from parrot_formdesigner.services.sink_aliases.SinkAliasRegistry.

Alias SinkFactory

Re-exported from parrot_formdesigner.services.sinks.factory.SinkFactory.

Alias SubmissionForwarder

Re-exported from parrot_formdesigner.services.forwarder.SubmissionForwarder.

Alias SubmittedCallback

Re-exported from parrot_formdesigner.api.submission_events.SubmittedCallback.

Alias VenueService

Re-exported from parrot_formdesigner.services.venue_service.VenueService.

Alias WorkdayIdentitySyncAdapter

Re-exported from parrot_formdesigner.services.workday_sync.WorkdayIdentitySyncAdapter.

Alias controls_module

Re-exported from parrot_formdesigner.api.controls.

Alias file_upload_module

Re-exported from parrot_formdesigner.api.file_upload.

Attribute logger

Alias operations_module

Re-exported from parrot_formdesigner.api.operations.

Alias public_form_paths

Re-exported from parrot_formdesigner.services.public_forms.public_form_paths.

Alias render_module

Re-exported from parrot_formdesigner.api.render.

Alias requires_tenant

Re-exported from parrot_formdesigner.api.tenant.requires_tenant.

Function setup_form_api

Mount the JSON REST surface on app under base_path.

Every route is wrapped with navigator-auth's is_authenticated + user_session decorators. Telegram webhook routes do NOT belong here — see parrot_formdesigner.ui.setup_form_ui for those.

setup_form_api(app: web.Application, registry: FormRegistry, *, client: 'AbstractClient | None' = None, submission_storage: 'FormSubmissionStorage | None' = None, forwarder: 'SubmissionForwarder | None' = None, base_path: str = '/api/v1', blob_storage: 'AbstractBlobStorage | None' = None, resolver: 'RestFieldResolver | None' = None, partial_store: 'PartialSaveStore | None' = None, synthesizer: 'VoiceSynthesizer | None' = None, transcriber: 'FasterWhisperBackend | None' = None, token_validator: 'TokenValidator | None' = None, org_graph_service: 'OrgGraphService | None' = None, project_service: 'ProjectService | None' = None, rbac_service: 'RBACService | None' = None, workday_adapter: 'WorkdayIdentitySyncAdapter | None' = None, venue_service: 'VenueService | None' = None, rbac_enforcing: bool = False, alias_registry: 'SinkAliasRegistry | None' = None, public_base_url: str | None = None, teams_renderer: 'AbstractFormRenderer | None' = None, teams_signing_secret: str | None = None, llm_quota: 'LLMQuota | None' = None, tenant_scoped_submissions: bool = False, on_submitted: 'SubmittedCallback | None' = None, pending_uploads: 'PendingUploadStore | None' = None) -> None

Parameter Type Default Description
app web.Application aiohttp application to register routes on.
registry FormRegistry Pre-built FormRegistry shared across requests.
client 'AbstractClient | None' None Optional LLM client for natural language form creation.
submission_storage 'FormSubmissionStorage | None' None Optional storage backend for submissions.
forwarder 'SubmissionForwarder | None' None Optional submission forwarder.
base_path str '/api/v1' URL prefix for all routes (default "/api/v1").
blob_storage 'AbstractBlobStorage | None' None Optional AbstractBlobStorage instance for REST field binary uploads. If None, the upload handler will construct an S3BlobStorage() lazily on first use from environment variables.
resolver 'RestFieldResolver | None' None Optional RestFieldResolver instance. If None, the upload handler will create a default instance on first use.
partial_store 'PartialSaveStore | None' None Optional Redis-backed PartialSaveStore for ephemeral partial form answer caching. When None, the partial save endpoints (POST/GET/DELETE /forms/{form_uid}/partial) will return 503.
synthesizer 'VoiceSynthesizer | None' None Optional VoiceSynthesizer for audio-form TTS. When provided it is used as-is (tests/overrides). When None but audio is intended (transcriber or token_validator given), the audio handler synthesizes lazily via the SuperTonic-first fallback (SuperTonic → Google → text-only). SuperTonic requires the ai-parrot-integrations[voice-supertonic] extra and the SUPERTONIC_MODEL_PATH env var pointing at the ONNX weights; when unavailable the session degrades gracefully to Google, then to text-only. No model is loaded at route-setup time (the backend loads lazily on first synthesis).
transcriber 'FasterWhisperBackend | None' None Optional FasterWhisperBackend for audio-form STT. Providing it (or token_validator) mounts the audio WS endpoint.
token_validator 'TokenValidator | None' None Optional TokenValidator for audio-form WebSocket JWT authentication. Providing it mounts the audio WS endpoint.
org_graph_service 'OrgGraphService | None' None Optional OrgGraphService for GET /org/graph.
project_service 'ProjectService | None' None Optional ProjectService for org project endpoints.
rbac_service 'RBACService | None' None Optional RBACService for RBAC policy endpoints.
workday_adapter 'WorkdayIdentitySyncAdapter | None' None Optional WorkdayIdentitySyncAdapter for POST /org/sync/workday.
venue_service 'VenueService | None' None
rbac_enforcing bool False When False (default), RBAC gate-keeping on existing form endpoints runs in shadow mode (log only, never block).
alias_registry 'SinkAliasRegistry | None' None Optional SinkAliasRegistry (FEAT-457). When provided, exposed as the app["form_sink_aliases"] app key and used to build a SinkFactory injected into FormAPIHandler — forms declaring persistence write to their own sink. None (default) leaves the feature entirely inactive; no route ever mutates this allowlist.
public_base_url str | None None Optional public-facing base URL for the FormDesigner UI. When provided (or via FORMDESIGNER_PUBLIC_URL env var), registers the teams renderer for MS Teams Adaptive Card rendering (FEAT-551 M3). None (default) leaves the teams format unregistered.
teams_renderer 'AbstractFormRenderer | None' None Optional pre-configured AbstractFormRenderer for the teams format. When provided, takes precedence over constructing a TeamsFormRenderer from public_base_url. None (default) defers to public_base_url / env var.
teams_signing_secret str | None None HMAC secret used to sign the _formdesigner routing envelope of each Teams card. Falls back to the FORMDESIGNER_TEAMS_SIGNING_SECRET environment variable. None (default) emits envelopes with sig: null, which a bot configured with formdesigner_submit_secret rejects. Ignored when teams_renderer is supplied; configure the secret on that renderer instead.
llm_quota 'LLMQuota | None' None
tenant_scoped_submissions bool False Store generic /data submissions under the URL tenant; default False.
on_submitted 'SubmittedCallback | None' None Optional async host hook (SubmittedEvent) -> None awaited after a successful REST /data store (errors are logged, never fail the submit).
pending_uploads 'PendingUploadStore | None' None

Alias uploads_module

Re-exported from parrot_formdesigner.api.uploads.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally