Skip to content

API Reference parrot_formdesigner.core.persistence

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

parrot_formdesigner.core.persistence

View source

Per-form persistence configuration models.

This module defines the declarative, credential-free description of where a form's data (submissions) and definition (schema body) are stored. It mirrors the pattern already proven by :mod:parrot_formdesigner.core.auth: a Pydantic discriminated union whose members carry only the name of a credential source — here, a connection alias — never a secret, DSN, password or key.

No sink, storage, or aiohttp code is imported here. Resolution of a connection alias against an allowlist of credential sources happens server-side, in services/sink_aliases.py (a separate module).

Class AsyncDBTarget

Any other asyncdb-backed store (Mongo / BigQuery / Arango).

Fields:

Field Type Default Description
type Literal['asyncdb'] 'asyncdb' Discriminator literal, always "asyncdb".
connection str Alias resolved server-side to credentials — NEVER a raw DSN.
driver Literal['mongo', 'arango', 'bigquery'] The asyncdb driver name — restricted to the three v1 drivers this sink family actually supports (AsyncDBSink, TASK-2423). Constraining this at the Pydantic layer, rather than only in AsyncDBSink.ensure_target()'s if/elif/else, prevents a form from making the server dynamically load and connect through an arbitrary installed asyncdb driver name before that later check ever runs.
collection str Collection / dataset.table / document collection name. Document drivers (mongo, arango) store data NESTED, unflattened — see the submission mapper.

Class CsvFileTarget

One appended line per submission, inside an allowlisted base dir.

Fields:

Field Type Default Description
type Literal['csv_file'] 'csv_file' Discriminator literal, always "csv_file".
connection str Alias resolved server-side to an allowed base directory.
path str Relative path (inside the alias's base dir). Traversal segments (..) and absolute paths are rejected at construction.
delimiter str ',' CSV field delimiter, defaults to ",". Must be exactly one character — csv.writer raises TypeError for anything else, and that would otherwise surface as an unhandled 500 from CsvFileSink.write() instead of a clean 422 at schema-construction time.

Attribute DefinitionTarget

Class FileDefinitionTarget

A form definition body stored as a file, inside an allowlisted base dir.

Fields:

Field Type Default Description
type Literal['file'] 'file' Discriminator literal, always "file".
connection str Alias resolved server-side to an allowed base directory.
path str Relative path (inside the alias's base dir), e.g. "nps_2026.form.yaml". Traversal segments (..) and absolute paths are rejected at construction.

Class FormPersistenceConfig

Per-form persistence declaration. Absent on FormSchema -> today's behaviour.

Fields:

Field Type Default Description
data SubmissionTarget Where this form's submission data is written.
definition DefinitionTarget | None None Where this form's definition body is stored, if the registry's pointer-indexing decorator is in use. None means the definition body lives directly in the registry's own storage.

Class GoogleSheetTarget

A Google Sheets worksheet owned by this form.

Fields:

Field Type Default Description
type Literal['gsheet'] 'gsheet' Discriminator literal, always "gsheet".
connection str Alias resolved server-side to service-account credentials.
spreadsheet_id str The target spreadsheet's id.
worksheet str 'Sheet1' The target worksheet name, defaults to "Sheet1".

Class PostgresTableTarget

Arbitrary Postgres table owned by this form.

Fields:

Field Type Default Description
type Literal['postgres_table'] 'postgres_table' Discriminator literal, always "postgres_table".
connection str Alias resolved server-side to a DSN — NEVER a raw DSN.
schema_name str Postgres schema name (named schema_name because schema shadows :meth:pydantic.BaseModel.schema).
table str Postgres table name.

Class SinkCapability

Operations a submission sink may support.

Attributes:

Attribute Type Description
WRITE The sink can persist a new submission.
READ The sink can retrieve a single submission by id.
LIST The sink can list submission revisions.
PROVISION The sink can create its own destination on first use.
EXTEND The sink can additively extend its destination (new columns or headers) as a form gains fields.

Attribute SubmissionTarget

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