Skip to content

feat: added support for schemaId in config ref#103

Merged
CptSchnitz merged 2 commits intomasterfrom
ref-schema-id
Jul 7, 2025
Merged

feat: added support for schemaId in config ref#103
CptSchnitz merged 2 commits intomasterfrom
ref-schema-id

Conversation

@CptSchnitz
Copy link
Copy Markdown
Collaborator

This pull request introduces enhancements to the configuration validation system by adding schema ID support, improving schema reference handling, and ensuring unique configuration names across schemas. The changes primarily focus on improving schema validation logic and updating configuration files to include schema IDs.

Configuration Schema Enhancements:

  • Updated configuration files (schemas/common/db/full/v1.configs.json, schemas/common/s3/full/v1.configs.json, schemas/infra/opala/cron/v2.configs.json, and schemas/infra/opala/manager/v1.configs.json) to include the schemaId field in $ref entries, ensuring that references are tied to specific schema versions. [1] [2] [3] [4]

Validation Logic Improvements:

  • Extended the ConfigReference type in scripts/validate/core.mts to include a schemaId property, and updated the configRefSchema to require this property.
  • Enhanced the validateConfigs.mts script by:
    • Adding functions to construct and parse schema IDs (constructSchemaId and removeSchemaVersion).
    • Modifying the listAllRefs function to validate references against schema IDs and ensure they match the expected schema. [1] [2]
    • Updating the validateConfigNames function to enforce unique configuration names across different schemas while allowing name reuse within the same schema.

Codebase Updates for Schema Handling:

  • Replaced assert { type: 'json' } with with { type: 'json' } in JSON schema imports to align with updated module syntax in scripts/validate/validate.mts and scripts/validate/validateConfigs.mts. [1] [2]
  • Added schema ID handling to the fileAsyncStorage context and adjusted related logic in forEachConfigFileWithContext. [1] [2]

@CptSchnitz CptSchnitz requested review from Copilot and syncush July 6, 2025 11:52
Copy link
Copy Markdown
Contributor

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

Enhances configuration validation by introducing schema ID support and enforcing unique config names across schemas.

  • Adds schemaId property to ConfigReference and config schema validation
  • Updates JSON schemas to include schemaId in $ref entries
  • Implements constructSchemaId/removeSchemaVersion helpers and augments reference listing/validation logic
  • Enforces cross-schema name uniqueness and updates module import syntax

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

File Description
scripts/validate/validateConfigs.mts Added schemaId context, helper functions, and ref logic
scripts/validate/validate.mts Updated JSON import syntax to with { type: 'json' }
scripts/validate/core.mts Extended ConfigReference and JSON schema to include schemaId
schemas/**/*.configs.json Added schemaId field to all $ref entries
Comments suppressed due to low confidence (2)

scripts/validate/validateConfigs.mts:173

  • The module-level seenConfigs map persists between validation runs; consider calling seenConfigs.clear() at the start of this function to avoid stale entries when validating multiple sets.
  }

scripts/validate/validateConfigs.mts:113

  • New error branch for missing schemaId references should be covered by tests; add a case where a ref’s schemaId doesn’t match any available configs.
      if (!matchingConfigEntry) {

Comment thread scripts/validate/validateConfigs.mts Outdated
Comment thread scripts/validate/validateConfigs.mts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 6, 2025

Hi it is me, your friendly bot helper! 👋
I've packed this commit for you 😊
You can install it like this:

{
  "dependencies": {
      "@map-colonies/schemas": "https://ghatmpstorage.blob.core.windows.net/npm-packages/schemas-7538e455b38d9a31979d02d7fe2857033f7fd1aa.tgz"
  }
}

The link will expire in a week ⌛

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 6, 2025

Hi it is me, your friendly bot helper! 👋
I've packed this commit for you 😊
You can install it like this:

{
  "dependencies": {
      "@map-colonies/schemas": "https://ghatmpstorage.blob.core.windows.net/npm-packages/schemas-816216bb9208347b43b11204e4129bf8186871cb.tgz"
  }
}

The link will expire in a week ⌛

@CptSchnitz CptSchnitz merged commit f6a6379 into master Jul 7, 2025
3 checks passed
NatalieShaked pushed a commit that referenced this pull request Jul 7, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.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.

3 participants