Skip to content

feat: add ContactSalesLead entity (SITES-42069)#1475

Merged
tarunsinghdev merged 11 commits intomainfrom
feature/SITES-42069-contact-sales-api
Apr 2, 2026
Merged

feat: add ContactSalesLead entity (SITES-42069)#1475
tarunsinghdev merged 11 commits intomainfrom
feature/SITES-42069-contact-sales-api

Conversation

@tarunsinghdev
Copy link
Copy Markdown
Contributor

@tarunsinghdev tarunsinghdev commented Mar 27, 2026

Refer for description: https://github.com/OneAdobe/experience-success-studio-ui/pull/1675

SITES-42069

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

Copy link
Copy Markdown
Contributor

@sandsinh sandsinh left a comment

Choose a reason for hiding this comment

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

Review

1. siteId is a plain string attribute, not a reference

The PostgreSQL table has site_id UUID REFERENCES sites(id), but the schema defines siteId as a loose string rather than using .addReference(). This means no getSite() navigation method and no referential integrity at the data-access layer — inconsistent with how organizationId is handled via .addReference('belongs_to', 'Organization'). If the relationship is intentionally weak (optional, ON DELETE SET NULL), a comment in the schema explaining that choice would help.

2. No unit tests

Other entities in this package have dedicated test files. This PR adds a model, collection, and schema with none. Should include tests covering:

  • Model instantiation and STATUSES enum
  • Schema validation (required fields, default status)
  • Collection wiring and query methods

3. PR title doesn't follow conventional commits

Current: Feature/sites 42069 contact sales api
Should be: feat: add ContactSalesLead entity (SITES-42069)

Needed for semantic-release and changelog generation.

4. addAllIndex(['email']) — clarify the usage

What query patterns require looking up leads by email alone across all orgs? If leads are always queried within an org context, allByOrganizationId() (from the belongs_to reference) is sufficient. If cross-org email lookup is needed, what's the use case? This mirrors the same question on the standalone email index in the database migration (adobe/mysticat-data-service#238).

- Replace plain siteId string attribute with addReference('belongs_to', 'Site')
  for proper FK navigation (getSite()) and referential integrity
- Remove addAllIndex(['email']) as leads are queried within org context
- Add unit tests for model, collection, and schema with 100% coverage
- Remove stale ElectroDB comment from schema
- Update type declarations to include getSite() and allBySiteId()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tarunsinghdev tarunsinghdev changed the title Feature/sites 42069 contact sales api feat: add ContactSalesLead entity (SITES-42069) Apr 2, 2026
@tarunsinghdev
Copy link
Copy Markdown
Contributor Author

Review

1. siteId is a plain string attribute, not a reference

The PostgreSQL table has site_id UUID REFERENCES sites(id), but the schema defines siteId as a loose string rather than using .addReference(). This means no getSite() navigation method and no referential integrity at the data-access layer — inconsistent with how organizationId is handled via .addReference('belongs_to', 'Organization'). If the relationship is intentionally weak (optional, ON DELETE SET NULL), a comment in the schema explaining that choice would help.

2. No unit tests

Other entities in this package have dedicated test files. This PR adds a model, collection, and schema with none. Should include tests covering:

  • Model instantiation and STATUSES enum
  • Schema validation (required fields, default status)
  • Collection wiring and query methods

3. PR title doesn't follow conventional commits

Current: Feature/sites 42069 contact sales api Should be: feat: add ContactSalesLead entity (SITES-42069)

Needed for semantic-release and changelog generation.

4. addAllIndex(['email']) — clarify the usage

What query patterns require looking up leads by email alone across all orgs? If leads are always queried within an org context, allByOrganizationId() (from the belongs_to reference) is sufficient. If cross-org email lookup is needed, what's the use case? This mirrors the same question on the standalone email index in the database migration (adobe/mysticat-data-service#238).

@sandsinh Thanks for the thorough review! All 4 points addressed in 489691c:

  1. siteId → proper reference — Replaced the plain string attribute with .addReference('belongs_to', 'Site', [], { required: false
    }). This gives us getSite() navigation and FK integrity at the data-access layer. Marked optional since site association isn't
    always present for leads.

  2. Unit tests added — Full coverage across 3 test files + fixture:

  • Model test: instantiation, STATUSES enum, all getters/setters
  • Collection test: wiring and create
  • Schema test: attribute validation, required fields, default status, references

All at 100% coverage.

  1. PR title — Will update to feat: add ContactSalesLead entity (SITES-42069).

  2. Removed addAllIndex(['email']) — Agreed, leads are queried within org context via allByOrganizationId() from the belongs_to
    reference. No cross-org email lookup use case.

Also removed a stale ElectroDB comment from the schema and updated type declarations to include getSite() and allBySiteId().

@tarunsinghdev tarunsinghdev requested a review from sandsinh April 2, 2026 04:32
@tarunsinghdev tarunsinghdev merged commit d245781 into main Apr 2, 2026
6 of 7 checks passed
@tarunsinghdev tarunsinghdev deleted the feature/SITES-42069-contact-sales-api branch April 2, 2026 12:18
solaris007 pushed a commit that referenced this pull request Apr 2, 2026
## [@adobe/spacecat-shared-data-access-v3.44.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.43.0...@adobe/spacecat-shared-data-access-v3.44.0) (2026-04-02)

### Features

* add ContactSalesLead entity (SITES-42069) ([#1475](#1475)) ([d245781](d245781))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version @adobe/spacecat-shared-data-access-v3.44.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants