Skip to content

feat(publish): add support for ajv dynamic defaults#2569

Open
fpotier wants to merge 1 commit intomasterfrom
feat/dynamic-defaults
Open

feat(publish): add support for ajv dynamic defaults#2569
fpotier wants to merge 1 commit intomasterfrom
feat/dynamic-defaults

Conversation

@fpotier
Copy link
Member

@fpotier fpotier commented Mar 2, 2026

Description

Implements this idea
Note: PublishedData.metadata.publicationYear is now set using the new dynamic default feature. This required a change in the schema that currently breaks the frontend. I can remove it if it's not desired but I thought it was an improvement as the previous behavior only set a default value on creation that could be overwritten with updates.

Motivation

See dedicated discussion

Fixes

  • Bug fixed (#X)

Changes:

  • changes made

Tests included

  • Included for each change/fix?
  • Passing?

Documentation

  • swagger documentation updated (required for API changes)
  • official documentation updated

official documentation info

@fpotier fpotier force-pushed the feat/dynamic-defaults branch from f9c0c5c to faab069 Compare March 11, 2026 16:36
@fpotier fpotier force-pushed the feat/dynamic-defaults branch from faab069 to db52a8a Compare March 11, 2026 16:55
@fpotier fpotier marked this pull request as ready for review March 11, 2026 16:58
@fpotier fpotier requested a review from a team as a code owner March 11, 2026 16:58
@Junjiequan
Copy link
Member

Looks good to me.
I guess we need to provide customized ajv on the frontend with correponding packages ajv-formats and ajv-keywords ? reading from https://jsonforms.io/docs/validation

Copy link
Member

@minottic minottic left a comment

Choose a reason for hiding this comment

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

can we add a file with an example of the js dynamic default files?

}
}

await this.validatorService.validate(updatePublishedDataDto);
Copy link
Member

Choose a reason for hiding this comment

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

don't we need to raise errors here if there are during the validation?

addKeywords(this.ajv);

const modulePath = this.configService.get<string>("ajvCustomDefinitions");
if (!isEmpty(modulePath)) {
Copy link
Member

Choose a reason for hiding this comment

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

minor:

if (isEmpty(modulePath)): return

| PartialUpdatePublishedDataV4Dto,
) {
await this.loadDynamicDefaultFunctions(publishedData);
const config = this.configService.get<Record<string, unknown>>(
Copy link
Member

Choose a reason for hiding this comment

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

this will be loaded on every validate, maybe better in the constructor?

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.

3 participants