Skip to content

feat(data-access): rework Site contentAiConfig (name + index) - #1917

Open
duynguyen wants to merge 2 commits into
mainfrom
feat/content-ai-config-name
Open

feat(data-access): rework Site contentAiConfig (name + index)#1917
duynguyen wants to merge 2 commits into
mainfrom
feat/content-ai-config-name

Conversation

@duynguyen

Copy link
Copy Markdown
Contributor

What

Reworks the Site contentAiConfig in spacecat-shared-data-access:

  • Adds an optional name (non-empty when present) to the contentAiConfig schema.
  • Keeps the legacy index field as an optional, first-class field so pre-existing configs validate without warnings.
  • Adds updateContentAiConfig({ name, index })name and index are equal citizens: both are independently writable and optional, each overwritten only when provided, so updating one never clobbers the other (and existing values are preserved via merge).
  • getContentAiConfig() and Config.toDynamoItem() serialization are unchanged (pass-through).

Contract

contentAiConfig, name, and index are all optional:

Input Result
omitted valid (getContentAiConfig() is undefined)
{} valid
{ name } valid
{ index } (legacy) valid
{ name, index } valid, both round-trip
{ name: ' ' } rejected (present but blank)
unknown field rejected

updateContentAiConfig(...):

Call Effect
{ name } sets/overwrites name, preserves existing index
{ index } sets/overwrites index, preserves existing name
{ name, index } sets/overwrites both
() (no args) leaves config unchanged

Notes

  • name is intentionally optional (not required) so existing persisted configs — including ones that only carry index — validate cleanly and emit no warnings. Downstream readers of getContentAiConfig().name must tolerate undefined.
  • No data backfill is included; legacy index-only records are preserved as-is.

Testing

  • Unit tests updated in test/unit/models/site/config.test.js covering the optional-field matrix, blank-name rejection, updateContentAiConfig name-only / index-only / both / no-arg cases, merge preservation, and toDynamoItem round-trip.
  • Full package suite passes; coverage thresholds met.

🤖 Generated with Claude Code

duynguyen and others added 2 commits September 7, 2026 14:49
Add an optional non-empty `name` to the Site `contentAiConfig` schema and a
new `updateContentAiConfig({ name })` setter that merges onto any existing
config, preserving a legacy `index`. `contentAiConfig`, `name`, and `index`
are all optional so pre-existing configs validate without warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make `name` and `index` equal citizens in `updateContentAiConfig` — both are
independently writable and optional, each overwritten only when provided so
updating one never clobbers the other.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant