Skip to content

API Reference parrot_formdesigner.tools.services.networkninja

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

parrot_formdesigner.tools.services.networkninja

View source

NetworkninjaFormService — NetworkNinja PostgreSQL form-source service.

Migrated verbatim from DatabaseFormTool in tools/database_form.py. Owns the SQL query, field-type map, and all mapping helpers.

Alias AbstractFormService

Re-exported from parrot_formdesigner.tools.services.abstract.AbstractFormService.

Alias ConditionOperator

Re-exported from parrot_formdesigner.core.constraints.ConditionOperator.

Alias DependencyRule

Re-exported from parrot_formdesigner.core.constraints.DependencyRule.

Alias FieldCondition

Re-exported from parrot_formdesigner.core.constraints.FieldCondition.

Alias FieldConstraints

Re-exported from parrot_formdesigner.core.constraints.FieldConstraints.

Alias FieldOption

Re-exported from parrot_formdesigner.core.options.FieldOption.

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

Alias FormField

Re-exported from parrot_formdesigner.core.schema.FormField.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias FormSection

Re-exported from parrot_formdesigner.core.schema.FormSection.

Alias FormSubsection

Re-exported from parrot_formdesigner.core.schema.FormSubsection.

Alias FormType

Re-exported from parrot_formdesigner.core.schema.FormType.

Class ImportDiffEntry

Per-field entry in an ImportDiffReport.

Fields:

Field Type Default Description
column_name str The source column_name from form_metadata.
source_data_type str The raw data_type string from the source.
mapped_field_type str | None None The resolved FieldType.value string, or None when mapping failed.
status str One of "mapeado" (fully mapped), "aproximado" (approximate mapping with meta hint), or "requiere_intervencion" (manual review needed).
note str '' Human-readable note about the mapping decision.
options_source str | None None Provenance of the field's options — one of "metadata", "inline", "logic_groups", "none" for option-typed fields; None for non-option fields (FEAT-325).

Class ImportDiffReport

Aggregate report for a single networkninja form import.

Fields:

Field Type Default Description
form_id str The FormSchema.form_id produced by the import.
source str 'networkninja' Always "networkninja".
imported_at datetime UTC timestamp of the import.
fields list[ImportDiffEntry] [] One entry per imported field column.

Alias LogicGroup

Re-exported from parrot_formdesigner.core.constraints.LogicGroup.

Class NetworkninjaFormService

NetworkNinja PostgreSQL form-source service.

Owns the SQL query against networkninja.forms + networkninja.form_metadata and the question_blocks → FormSchema transformation pipeline.

Parameter Type Default Description
db Any | None None Optional pre-configured AsyncDB instance. When provided it is reused directly (supports connection pooling / test injection).
dsn str | None None PostgreSQL DSN. Falls back to PARROT_NETWORKNINJA_DSN env var, then parrot.conf.default_dsn.

Method NetworkninjaFormService.fetch

Run the parameterized SQL query and return the row dict.

fetch(*, formid: int, orgid: int, **_: Any) -> dict[str, Any]

Parameter Type Default Description
formid int Numeric form identifier.
orgid int Organization ID that owns the form.
**_ Any {} Additional kwargs are ignored.

Returns: dict[str, Any] — Row dict with form data.

Raises:

  • RuntimeError — When no row matches the (formid, orgid) pair, or on DB error.

Method NetworkninjaFormService.to_form_schema

Transform the row dict into a FormSchema.

to_form_schema(raw: dict[str, Any]) -> FormSchema

Parameter Type Default Description
raw dict[str, Any] Dict with keys: formid, form_name, description, orgid, question_blocks (JSON string or list), metadata (list of dicts).

Returns: FormSchema — Fully constructed FormSchema.

Method NetworkninjaFormService.import_with_report

Transform a raw row into a FormSchema plus an ImportDiffReport.

The form is always returned (never aborted). Unmappable fields are included in the report with status="requiere_intervencion" and the form is left as draft (published_version=None).

import_with_report(raw: dict[str, Any]) -> tuple[FormSchema, ImportDiffReport]

Parameter Type Default Description
raw dict[str, Any] Dict with keys: formid, form_name, description, orgid, question_blocks (JSON string or list), metadata (list of dicts).

Returns: tuple[FormSchema, ImportDiffReport] — Tuple of (FormSchema, ImportDiffReport).

Alias resolve_rule_references

Re-exported from parrot_formdesigner.core.resolution.resolve_rule_references.

Function stable_form_uid

Derive the deterministic form_uid for a networkninja source form.

The importer must be idempotent: re-importing the same source form has to yield the SAME form_uid, or FormRegistry.register rejects it as a new form claiming an already-owned slug (db-form-<formid>-<orgid>), and every field_uid-keyed answer, partial save, and resolved rule is orphaned.

stable_form_uid(formid: int | str, orgid: int | str) -> uuid.UUID

Parameter Type Default Description
formid int | str Numeric form identifier at the source.
orgid int | str Organization ID that owns the form.

Returns: uuid.UUID — A UUIDv5 that is a pure function of (formid, orgid).

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