Skip to content

Pandadoc form mapping#209

Open
ostepan8 wants to merge 17 commits intomainfrom
pandadoc-form-mapping
Open

Pandadoc form mapping#209
ostepan8 wants to merge 17 commits intomainfrom
pandadoc-form-mapping

Conversation

@ostepan8
Copy link
Copy Markdown

ℹ️ Issue

Closes #78

📝 Description

added a mapping layer that takes the raw pandadoc form submission and routes each field to the right database table. the pandadoc form has like 40+ fields across four different tables so without this theres no clean way to get form data into our db

  1. created panda-field-map.ts which is the big constants file that maps every pandadoc field key to its backend column name and target table. includes transforms for stuff like splitting full name into first and last, parsing dates, converting yes/no strings to booleans, and parsing hours as a number

  2. wrote the pandadoc mapper function that iterates over the field map and buckets everything into the right table. handles optional fields by falling back to a default value or null, and collects all missing required fields into one error so you dont have to fix them one at a time

  3. interest area checkboxes are each their own pandadoc field but they all need to end up in a single array column so the mapper auto detects when multiple pandadoc keys point to the same backend field and aggregates them into an array instead of overwriting

  4. added 12 unit tests covering the full mapping, name splitting, number parsing, boolean transforms, array aggregation for interest checkboxes, default values for blank optional fields, and required field validation

✔️ Verification

ran the test suite and all 12 tests pass. tests cover the happy path with a full form submission, missing optional fields falling back correctly, and missing required fields throwing descriptive errors. also verified that fields like school and license that map to multiple tables end up in both places

@ostepan8 ostepan8 requested a review from SamNie2027 March 18, 2026 19:58
@SamNie2027
Copy link
Copy Markdown
Collaborator

Sorry I just refactored the backend - do you mind helping and updating this to use the current backend shape? Thank you

Copy link
Copy Markdown
Collaborator

@SamNie2027 SamNie2027 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a PandaDoc submission mapping layer in the backend to route raw PandaDoc field keys into per-table “buckets” aligned to the backend schema, with unit tests to validate key transforms and required-field handling.

Changes:

  • Introduces PANDADOC_FIELD_MAP constants describing PandaDoc key → backend field/table mappings (with basic transforms/defaults).
  • Implements pandadocMapper to iterate the map, populate table buckets, aggregate multi-key fields into arrays, and report missing required fields in one error.
  • Adds unit tests covering common mapping behavior (dates, numbers, booleans, array aggregation, defaults, required validation).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
apps/backend/src/pandadoc-mapper.ts Core mapper implementation that buckets mapped values by target table and aggregates array-backed fields.
apps/backend/src/panda-field-map.ts Central mapping configuration (PandaDoc keys, target tables, backend fields, transforms, defaults).
apps/backend/src/pandadoc-mapper.spec.ts Unit tests for mapper behavior and key transforms/validation expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SamNie2027
Copy link
Copy Markdown
Collaborator

I'm seeing that these end fields are missing: referred, referredEmail, desiredExperience, elaborateOtherDiscipline, heardAboutFrom

@SamNie2027
Copy link
Copy Markdown
Collaborator

heardAboutFrom would use the same approach to the InterestArea enums

@SamNie2027 SamNie2027 requested review from Copilot and removed request for Copilot April 3, 2026 00:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map PandaDoc Fields to Database Schema

3 participants