Skip to content

Implement Heretto CMS uploader for screenshot synchronization#149

Merged
hawkeyexl merged 5 commits intomainfrom
heretto2
Jan 3, 2026
Merged

Implement Heretto CMS uploader for screenshot synchronization#149
hawkeyexl merged 5 commits intomainfrom
heretto2

Conversation

@hawkeyexl
Copy link
Contributor

@hawkeyexl hawkeyexl commented Jan 3, 2026

Introduce a HerettoUploader class to automate screenshot uploads to Heretto CMS, enhancing the existing upload process. Update path resolution to support heretto: URIs and improve error handling for upload operations. Add documentation and tests to ensure functionality and reliability. Upgrade dependencies as needed.

Summary by CodeRabbit

  • New Features

    • Added source integration metadata support across test steps, enabling file tracking and association with Heretto CMS systems.
    • Steps like screenshots, HTTP requests, and cookies now support source integration references.
    • New URI scheme support for resource path resolution.
  • Chores

    • Updated dev dependencies.

✏️ Tip: You can customize this high-level summary in your review settings.

…nization

- Added HerettoUploader class to handle file uploads to Heretto CMS.
- Integrated uploader into the existing upload process for changed screenshots.
- Enhanced screenshot saving logic to track changes and source integration metadata.
- Created documentation for Heretto screenshot sync feature, detailing the upload process and architecture.
- Updated resolver to build file mappings and handle Heretto-specific configurations.
- Introduced utility functions to find Heretto integrations based on file paths.
- Added error handling and logging for upload operations to improve reliability.
- Update `saveScreenshot.js` to mark new screenshots as changed for upload.
- Add a new test file `screenshot.test.js` to verify sourceIntegration preservation and changed status for screenshots.
- Create a new test file `upload.test.js` to validate the upload module, including collecting changed files and integration configuration.
- Modify `package-lock.json` to link to local `doc-detective-common` instead of a versioned package.
- Enhance `heretto.js` to retrieve resource dependencies from the Heretto REST API, including detailed logging and XML parsing.
- Modify resolve function to return heretto: URIs unchanged.
- Update comments to reflect new URI handling in path resolution.
- Upgrade chai from 6.2.1 to 6.2.2
- Upgrade sinon from 21.0.0 to 21.0.1
- Update sinon's fake-timers and samsam dependencies
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

This PR introduces Heretto CMS source integration support by adding a new sourceIntegration schema definition, integrating it across multiple output and source schemas, handling heretto: URI schemes in path resolution, and adding readOnly properties to track file mappings and resource dependencies in Heretto integration configurations.

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Bumps devDependencies: chai ^6.2.1 → ^6.2.2, sinon ^21.0.0 → ^21.0.1
Path Resolution Enhancement
src/resolvePaths.js
Adds handling for heretto: URI scheme alongside existing http:// and https:// schemes to prevent path resolution attempts on Heretto URIs
Schema Processing
src/schemas/dereferenceSchemas.js
Registers sourceIntegration_v3.schema.json in the v3 schemas list for inclusion in processing and publishing pipelines
New sourceIntegration Schema Definitions
src/schemas/src_schemas/sourceIntegration_v3.schema.json,
src/schemas/output_schemas/sourceIntegration_v3.schema.json
Adds new schema files defining sourceIntegration object with required fields (type enum: "heretto", integrationName) and optional fields (fileId, filePath, contentPath) with examples
Output Schema Enhancements
src/schemas/output_schemas/config_v3.schema.json,
src/schemas/output_schemas/report_v3.schema.json,
src/schemas/output_schemas/resolvedTests_v3.schema.json,
src/schemas/output_schemas/screenshot_v3.schema.json,
src/schemas/output_schemas/spec_v3.schema.json,
src/schemas/output_schemas/step_v3.schema.json,
src/schemas/output_schemas/test_v3.schema.json
Adds optional sourceIntegration property across multiple action/step schemas (screenshot, httpRequest, saveCookie, loadCookie, goTo, etc.) to support Heretto CMS metadata attachment
Source Schema Updates
src/schemas/src_schemas/config_v3.schema.json
Adds three readOnly properties to Heretto integration entries: fileMapping (local-to-Heretto file mappings), uploadOnChange (boolean flag), and resourceDependencies (Heretto file path to UUID mappings)
Source Schema Updates
src/schemas/src_schemas/screenshot_v3.schema.json
Adds sourceIntegration property reference via $ref to enable source CMS integration metadata on screenshots

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #148: Extends Heretto integration configuration schema with similar sourceIntegration property additions across multiple schemas
  • PR #141: Modifies src/resolvePaths.js to handle URL-like schemes; this PR builds on that pattern by adding heretto: scheme support
  • PR #133: Modifies src/schemas/dereferenceSchemas.js to register new v3 schema files; this PR adds sourceIntegration_v3.schema.json to the same processing list

Poem

🐰 Hoppity hop, a new path we trace,
Heretto: schemes find their rightful place,
Source integration blooms in schemas so bright,
CMS connections woven just right,
Integration magic, from sources to sight!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Implement Heretto CMS uploader for screenshot synchronization' clearly and specifically describes the main feature being added in this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
src/schemas/src_schemas/screenshot_v3.schema.json (1)

214-248: Consider adding an example demonstrating the sourceIntegration property.

While the existing examples are valid, adding one that includes the sourceIntegration property would help users understand its structure and usage, even though it's typically set automatically.

📝 Example with sourceIntegration
     {
       "path": "image.png",
       "directory": "static/images",
       "maxVariation": 0.1,
       "overwrite": "aboveVariation",
       "crop": {
         "selector": "#elementToScreenshot",
         "elementText": "Element text",
         "padding": {
           "top": 0,
           "right": 0,
           "bottom": 0,
           "left": 0
         }
-      }
+      },
+      "sourceIntegration": {
+        "type": "heretto",
+        "integrationName": "my-heretto",
+        "fileId": "8f3ed200-cbba-11e1-ac51-c82a1446d15c",
+        "filePath": "/db/organizations/example/repositories/docs/images/screenshot.png"
+      }
     }
src/schemas/src_schemas/sourceIntegration_v3.schema.json (1)

18-21: Consider adding UUID format validation for fileId.

The description indicates fileId should be a UUID, but the schema only validates it as a string. Adding format validation would ensure stricter compliance with the documented structure.

🔎 Proposed enhancement
     "fileId": {
       "type": "string",
+      "format": "uuid",
       "description": "The unique identifier (UUID) of the file in the source CMS. If not provided, the file will be looked up by path."
     },
src/schemas/output_schemas/step_v3.schema.json (2)

4802-4851: sourceIntegration object is well-structured; consider requiring a locator field

The new sourceIntegration schema looks coherent and aligned with the Heretto use case (clear type enum, integrationName, and optional IDs/paths). One thing to consider: as written, it's valid for all of fileId, filePath, and contentPath to be omitted, which may leave the uploader without a reliable way to locate the remote asset.

If, in practice, you always need at least a fileId or filePath to perform an upload, you could tighten this with an anyOf constraint:

Optional schema tightening for locator requirements
                       "properties": {
                         "type": {
                           "type": "string",
                           "description": "The type of integration. Currently supported: 'heretto'. Additional types may be added in the future.",
                           "enum": [
                             "heretto"
                           ]
                         },
                         "integrationName": {
                           "type": "string",
                           "description": "The name of the integration configuration in the config file. Used to look up authentication credentials."
                         },
                         "fileId": {
                           "type": "string",
                           "description": "The unique identifier (UUID) of the file in the source CMS. If not provided, the file will be looked up by path."
                         },
                         "filePath": {
                           "type": "string",
                           "description": "The path of the file in the source CMS. Used for lookup if fileId is not available."
                         },
                         "contentPath": {
                           "type": "string",
                           "description": "The local path to the file that references this source. Used for resolving relative paths."
                         }
-                      },
+                      },
+                      "anyOf": [
+                        {
+                          "required": [
+                            "fileId"
+                          ]
+                        },
+                        {
+                          "required": [
+                            "filePath"
+                          ]
+                        }
+                      ],
                       "examples": [

If you adopt this, mirror the same anyOf block in the second sourceIntegration definition below to keep them consistent.


5048-5097: Avoid future drift between duplicated sourceIntegration schemas

This second sourceIntegration block mirrors the one above under the main screenshot properties, which matches existing duplication patterns in this schema. However, with a dedicated sourceIntegration_v3.schema.json in the PR, you now have three places that must stay in sync.

To reduce future maintenance risk, consider (on a follow-up pass) refactoring these to reuse a shared definition (e.g., via a local components.schemas.sourceIntegration or a $ref to the shared schema before dereferencing), so changes to fields or examples only need to be made once.

src/schemas/src_schemas/config_v3.schema.json (1)

280-284: Consider adding an example demonstrating uploadOnChange: true.

The uploadOnChange property is correctly configured as a user-settable boolean with a sensible default. To improve discoverability and documentation, consider adding an example in the examples array that shows this property set to true, helping users understand how to enable automatic uploads of changed screenshots back to Heretto CMS.

📋 Suggested example addition

Add this example to the examples array (after line 631):

{
  "integrations": {
    "heretto": [
      {
        "name": "example-with-upload",
        "organizationId": "your-organization-id",
        "username": "your-username",
        "apiToken": "your-api-token",
        "uploadOnChange": true
      }
    ]
  }
}
src/schemas/output_schemas/report_v3.schema.json (1)

6021-6069: Schema additions look correct; consider consolidating with $ref.

The sourceIntegration schema is well-structured with appropriate required/optional fields, strict validation via additionalProperties: false, and helpful examples. The same ~50-line definition is repeated across all 4 hunks.

Since sourceIntegration_v3.schema.json exists per the PR summary, you could reduce duplication and simplify future maintenance by referencing it:

"sourceIntegration": {
  "$ref": "sourceIntegration_v3.schema.json"
}

This is optional—the current approach works correctly.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b48f601 and 534c41f.

⛔ Files ignored due to path filters (9)
  • dist/schemas/config_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/report_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/resolvedTests_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/screenshot_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/sourceIntegration_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/spec_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/step_v3.schema.json is excluded by !**/dist/**
  • dist/schemas/test_v3.schema.json is excluded by !**/dist/**
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • package.json
  • src/resolvePaths.js
  • src/schemas/dereferenceSchemas.js
  • src/schemas/output_schemas/config_v3.schema.json
  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
  • src/schemas/output_schemas/screenshot_v3.schema.json
  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/output_schemas/spec_v3.schema.json
  • src/schemas/output_schemas/step_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/schemas.json
  • src/schemas/src_schemas/config_v3.schema.json
  • src/schemas/src_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
🧰 Additional context used
📓 Path-based instructions (4)
src/schemas/src_schemas/*.json

📄 CodeRabbit inference engine (AGENTS.md)

src/schemas/src_schemas/*.json: Always include examples array in all schemas (required for test generation)
In source schemas, use relative $ref paths like "$ref": "context_v3.schema.json#/properties/example"

Files:

  • src/schemas/src_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/config_v3.schema.json
**/*.{js,ts}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts}: Always clone objects using JSON.parse(JSON.stringify(object)) before validation to avoid mutations
validate() returns { valid, errors, object } and never throws; handle errors via return object
transformToSchemaKey() throws on incompatible schemas or invalid results; catch exceptions when calling this function
readFile() returns null on errors and logs warnings to console; do not assume errors throw exceptions
resolvePaths() throws on invalid object types or missing nested object types; validate inputs before calling
Do not assume validation mutates objects; always handle the returned validated object

Files:

  • src/resolvePaths.js
  • src/schemas/dereferenceSchemas.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Use escapeRegExp() helper when converting user strings to regex patterns in transformToSchemaKey()

Files:

  • src/resolvePaths.js
  • src/schemas/dereferenceSchemas.js
src/resolvePaths.js

📄 CodeRabbit inference engine (AGENTS.md)

src/resolvePaths.js: Path resolution respects config.relativePathBase setting: 'file' (relative to file location) or 'cwd' (relative to working directory)
Skip path resolution for HTTP(S) URLs, already-absolute paths, and user data properties (e.g., requestData)
Resolve path property relative to directory if directory is absolute (special case in resolvePaths)
For new config path properties, add to configPaths in resolvePaths.js; for spec properties, add to specPaths

Files:

  • src/resolvePaths.js
🧠 Learnings (19)
📚 Learning: 2025-05-29T16:54:47.192Z
Learnt from: hawkeyexl
Repo: doc-detective/common PR: 117
File: src/schemas/output_schemas/resolvedTests_v3.schema.json:24-30
Timestamp: 2025-05-29T16:54:47.192Z
Learning: In doc-detective/common schemas, `$schema` properties within object definitions are intentionally added to allow described JSON objects to be self-describing for linting purposes. This enables JSON linters and validators to automatically validate objects against the referenced schema. The version information is embedded in the filename using the pattern `<schema>_v3.schema.json`.

Applied to files:

  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/output_schemas/spec_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/config_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/output_schemas/step_v3.schema.json
  • src/schemas/output_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/config_v3.schema.json
  • src/schemas/dereferenceSchemas.js
  • package.json
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/schemas/src_schemas/*.json : Always include examples array in all schemas (required for test generation)

Applied to files:

  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: When adding new schemas, update the files array in dereferenceSchemas.js and add to published list if creating v3 schema

Applied to files:

  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/config_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/schemas/src_schemas/*.json : In source schemas, use relative $ref paths like "$ref": "context_v3.schema.json#/properties/example"

Applied to files:

  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/config_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-08-22T20:01:21.087Z
Learnt from: hawkeyexl
Repo: doc-detective/common PR: 134
File: src/schemas/output_schemas/report_v3.schema.json:5695-5921
Timestamp: 2025-08-22T20:01:21.087Z
Learning: The report_v3.schema.json includes dragAndDrop via inclusion in the spec schema, which includes the test and step schemas, creating a chain of schema inclusions.

Applied to files:

  • src/schemas/output_schemas/sourceIntegration_v3.schema.json
  • src/schemas/src_schemas/screenshot_v3.schema.json
  • src/schemas/src_schemas/sourceIntegration_v3.schema.json
  • src/schemas/output_schemas/spec_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/config_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/output_schemas/step_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/validate.js : All step_v3 schemas must accept 12 different v2 action schemas (checkLink_v2, find_v2, etc.) via compatibleSchemas map

Applied to files:

  • src/schemas/output_schemas/spec_v3.schema.json
  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/validate.js : Handle schema property transformations: typeKeys.delay → type.inputDelay, maxVariation (0-100) → (0-1), and app → browsers structure changes

Applied to files:

  • src/schemas/output_schemas/test_v3.schema.json
  • src/schemas/output_schemas/resolvedTests_v3.schema.json
📚 Learning: 2025-08-22T20:01:21.087Z
Learnt from: hawkeyexl
Repo: doc-detective/common PR: 134
File: src/schemas/output_schemas/report_v3.schema.json:5695-5921
Timestamp: 2025-08-22T20:01:21.087Z
Learning: In the doc-detective/common project, dragAndDrop schema doesn't need to be explicitly added to report_v3.schema.json because all schemas in schema.json are dynamically loaded and dragAndDrop is included through that mechanism.

Applied to files:

  • src/schemas/output_schemas/report_v3.schema.json
  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/resolvePaths.js : Skip path resolution for HTTP(S) URLs, already-absolute paths, and user data properties (e.g., requestData)

Applied to files:

  • src/resolvePaths.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/resolvePaths.js : Resolve path property relative to directory if directory is absolute (special case in resolvePaths)

Applied to files:

  • src/resolvePaths.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/resolvePaths.js : For new config path properties, add to configPaths in resolvePaths.js; for spec properties, add to specPaths

Applied to files:

  • src/resolvePaths.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/resolvePaths.js : Path resolution respects config.relativePathBase setting: 'file' (relative to file location) or 'cwd' (relative to working directory)

Applied to files:

  • src/resolvePaths.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to **/*.{js,ts} : resolvePaths() throws on invalid object types or missing nested object types; validate inputs before calling

Applied to files:

  • src/resolvePaths.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Do not add schemas without updating the files array in dereferenceSchemas.js

Applied to files:

  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to src/validate.js : When creating new schema version (e.g., v4), update compatibleSchemas map and add transformation logic in transformToSchemaKey()

Applied to files:

  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Do not edit generated files directly: build/, output_schemas/, or schemas.json (regenerated on npm run build)

Applied to files:

  • src/schemas/dereferenceSchemas.js
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Do not modify package.json version in PRs; auto-dev-release workflow handles version bumps automatically

Applied to files:

  • package.json
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to test/*.test.js : Test structure uses Mocha + Chai; validate schema examples in test/schema.test.js (auto-generated from schemas)

Applied to files:

  • package.json
📚 Learning: 2025-11-25T23:59:43.235Z
Learnt from: CR
Repo: doc-detective/common PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T23:59:43.235Z
Learning: Applies to test/*.test.js : Use dynamic import for Chai in test files for ESM compatibility

Applied to files:

  • package.json
🔇 Additional comments (16)
src/resolvePaths.js (2)

81-85: LGTM! Heretto URI handling follows the established pattern.

The implementation correctly treats heretto: URIs the same way as HTTP(S) URLs, returning them unchanged during path resolution. This is consistent with the existing pattern and appropriate for CMS URI schemes.


192-200: LGTM! Consistent handling in string property skip logic.

The heretto: prefix is correctly added to the skip list for string properties, ensuring these URIs are preserved as-is throughout the resolution process.

src/schemas/dereferenceSchemas.js (1)

47-47: LGTM! Schema correctly registered for processing.

The sourceIntegration_v3.schema.json is properly added to the v3 schemas list and will be automatically included in the dereferencing and publishing pipelines. Based on learnings, this follows the required pattern for new schema registration.

src/schemas/src_schemas/screenshot_v3.schema.json (1)

72-75: LGTM! SourceIntegration property correctly integrated.

The property uses a relative $ref path as required by coding guidelines for source schemas. The description clearly explains its automatic population during test resolution.

src/schemas/src_schemas/sourceIntegration_v3.schema.json (1)

1-30: LGTM! Schema structure is well-defined.

The schema correctly:

  • Includes the $schema property for self-describing JSON (per project patterns)
  • Defines required and optional properties appropriately
  • Sets additionalProperties: false to prevent invalid fields
  • Includes comprehensive property descriptions
  • Has examples demonstrating valid usage (required per coding guidelines)
package.json (1)

23-25: The package versions are valid and free from known security vulnerabilities. Both chai@6.2.2 and sinon@21.0.1 are current versions with no reported security advisories.

src/schemas/output_schemas/sourceIntegration_v3.schema.json (1)

1-50: Well-structured schema with comprehensive examples.

The sourceIntegration schema is well-designed with:

  • Clear required vs. optional fields
  • Strict validation via additionalProperties: false
  • Two examples demonstrating different lookup strategies (UUID-based vs. path-based)
  • Future-proof design acknowledging additional integration types

The schema correctly follows the project conventions with $schema for linting and includes examples as required.

src/schemas/output_schemas/screenshot_v3.schema.json (1)

191-240: The source schema src/schemas/src_schemas/screenshot_v3.schema.json correctly uses $ref": "sourceIntegration_v3.schema.json#" at line 72-74. The duplication in the output schema src/schemas/output_schemas/screenshot_v3.schema.json is expected behavior from the dereferencing process, which expands all $ref references into full inline definitions. Both schemas are properly configured in the dereferenceSchemas.js files array. No action needed.

Likely an incorrect or invalid review comment.

src/schemas/output_schemas/resolvedTests_v3.schema.json (3)

5600-5650: Schema structure is well-defined.

The sourceIntegration schema appropriately:

  • Requires type and integrationName as essential identifiers
  • Provides examples covering both UUID-based (fileId) and path-based lookup scenarios
  • Uses additionalProperties: false for strict validation
  • Includes $schema for self-describing JSON objects (consistent with project conventions)

The same schema is correctly inlined across all "Capture screenshot (detailed)" contexts as part of the dereferencing process.


8643-8692: Heretto integration schema extensions are appropriate.

Good design choices:

  • readOnly: true correctly marks auto-populated fields (fileMapping, resourceDependencies)
  • uploadOnChange defaults to false, requiring explicit opt-in for the upload feature
  • The additionalProperties schemas provide clear structure for the metadata mappings

The nested object schemas within fileMapping and resourceDependencies don't specify required or additionalProperties: false, allowing flexibility for partial metadata. This is acceptable for auto-generated content, though you may want to tighten validation if stricter guarantees are needed.


5846-5896: Duplicate schema definitions expected from dereferencing.

The remaining sourceIntegration definitions in hunks 2, 4–9 are identical copies inlined at different "Capture screenshot (detailed)" contexts. This duplication is the expected result of the dereferencing process from the source schema.

Also applies to: 13703-13753, 13949-13999, 22495-22545, 22741-22791, 30072-30122, 30318-30368

src/schemas/output_schemas/test_v3.schema.json (2)

5401-5451: Well-structured sourceIntegration schema addition.

The sourceIntegration property is correctly defined with:

  • Required type (restricted to "heretto" enum) and integrationName for integration identification
  • Optional fileId, filePath, and contentPath for flexible file lookup strategies
  • Clear descriptions and representative examples covering both UUID-based and path-based lookups
  • additionalProperties: false for strict validation

The embedded $schema property aligns with the project's convention for self-describing JSON objects. Based on learnings, this enables JSON linters to automatically validate objects against the referenced schema.


5647-5697: Consistent sourceIntegration definitions across step contexts.

The identical sourceIntegration definitions at these locations maintain consistency across all screenshot step types in the dereferenced output schema. This duplication is expected: the source schemas (screenshot_v3.schema.json, etc.) properly use $ref": "sourceIntegration_v3.schema.json#" to avoid manual duplication, and the dereference build process inlines these references into the final output schemas.

Also applies to: 12978-13028, 13224-13274

src/schemas/output_schemas/spec_v3.schema.json (1)

6002-6052: LGTM! Well-structured sourceIntegration schema.

The sourceIntegration property is consistently added across all screenshot action variants with a well-defined schema. The structure appropriately requires type and integrationName while keeping fileId, filePath, and contentPath optional for flexibility. The examples clearly demonstrate both identification patterns (UUID-based with fileId and path-based with relative resolution via contentPath).

The inline duplication across all four hunks is expected for a dereferenced schema file. The inclusion of the $schema property is intentional for self-describing JSON objects, as per project conventions.

Also applies to: 6248-6298, 13579-13629, 13825-13875

src/schemas/output_schemas/config_v3.schema.json (2)

5588-5636: Well-designed sourceIntegration schema.

The sourceIntegration schema is consistently defined across all locations with appropriate required fields (type, integrationName) and flexible optional fields (fileId, filePath, contentPath). The examples clearly demonstrate usage patterns, and the description accurately explains the automatic population during test resolution. The enum restriction to "heretto" with extensibility notes is forward-thinking.

Also applies to: 5834-5882, 13691-13739, 13937-13985


8631-8678: Solid Heretto integration enhancements.

The new properties for the Heretto integration config are well-structured. The readOnly markers on fileMapping and resourceDependencies correctly indicate they're auto-populated, and the uploadOnChange flag with a safe default of false provides appropriate control. The additionalProperties patterns accurately define the structure of mapped values, and descriptions clearly explain when each property is populated.

Comment on lines +262 to +279
"fileMapping": {
"type": "object",
"description": "Mapping of local file paths to Heretto file metadata. Set automatically during content loading.",
"readOnly": true,
"additionalProperties": {
"type": "object",
"properties": {
"fileId": {
"type": "string",
"description": "The UUID of the file in Heretto."
},
"filePath": {
"type": "string",
"description": "The path of the file in Heretto."
}
}
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for fileMapping usage patterns in the codebase
rg -nP -C5 'fileMapping\s*[=:]' --type=js --type=ts

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check if dereferenceSchemas.js was updated for this new schema
git ls-files | grep -i dereference

Repository: doc-detective/common

Length of output: 97


🏁 Script executed:

#!/bin/bash
# Verify the examples array in config_v3.schema.json includes the new properties
sed -n '519,632p' src/schemas/src_schemas/config_v3.schema.json | head -150

Repository: doc-detective/common

Length of output: 2340


🏁 Script executed:

#!/bin/bash
# Check if config_v3.schema.json is in dereferenceSchemas.js files array
cat src/schemas/dereferenceSchemas.js

Repository: doc-detective/common

Length of output: 7023


🏁 Script executed:

#!/bin/bash
# Search for where fileMapping is actually assigned (broader pattern)
rg -nP 'fileMapping' --type=js --type=ts -C3

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check if uploadOnChange appears in examples (user-configurable property)
rg -n 'uploadOnChange' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 101


🏁 Script executed:

#!/bin/bash
# Get the full Heretto example entry to see what's documented
sed -n '604,632p' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 575


🏁 Script executed:

#!/bin/bash
# Verify uploadOnChange is NOT marked readOnly (user-configurable)
sed -n '280,290p' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 682


Add uploadOnChange property to the Heretto integration example.

The new uploadOnChange property is user-configurable (not readOnly) with a default value, but it's missing from the Heretto integration example in the schema's examples array. Update the example to include uploadOnChange to align with the coding guideline that all schemas must include examples (required for test generation).

The fileMapping and resourceDependencies properties are correctly marked readOnly as system-generated, so they don't require examples.

🤖 Prompt for AI Agents
In src/schemas/src_schemas/config_v3.schema.json around lines 262 to 279, the
Heretto integration example in the schema's "examples" array is missing the
user-configurable uploadOnChange property (which is not readOnly and has a
default), so update the relevant example object to include "uploadOnChange":
<defaultValue> (use the schema's default, e.g., true or false as appropriate for
this project) alongside the existing fields; keep fileMapping and
resourceDependencies as-is (readOnly) and ensure the examples array remains
valid JSON after the addition.

Comment on lines +285 to 310
"resourceDependencies": {
"type": "object",
"description": "Mapping of Heretto file paths to their UUIDs and metadata. Set automatically during content loading by fetching ditamap resource dependencies.",
"readOnly": true,
"additionalProperties": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"description": "The UUID of the file in Heretto."
},
"fullPath": {
"type": "string",
"description": "The full xmldb path of the file in Heretto."
},
"name": {
"type": "string",
"description": "The file name."
},
"parentFolderId": {
"type": "string",
"description": "The UUID of the parent folder in Heretto."
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, find and examine the schema file
find . -name "config_v3.schema.json" -type f

Repository: doc-detective/common

Length of output: 199


🏁 Script executed:

# Read the schema file to check current state, especially around resourceDependencies
# and verify if examples array exists
cat -n src/schemas/src_schemas/config_v3.schema.json | head -320 | tail -100

Repository: doc-detective/common

Length of output: 5105


🏁 Script executed:

# Search for resourceDependencies usage in the codebase
rg -n "resourceDependencies" --type=js --type=ts -A3 -B3

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Search more broadly for resourceDependencies in all file types
rg -n "resourceDependencies" --type=json

Repository: doc-detective/common

Length of output: 672


🏁 Script executed:

# Read the full schema file to see structure and check for examples array
wc -l src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 113


🏁 Script executed:

# Read the beginning of the schema file to understand structure
head -50 src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 1912


🏁 Script executed:

# Check if examples array exists anywhere in the config_v3 schema
rg -n "examples" src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 83


🏁 Script executed:

# Check the examples array location and structure
sed -n '519,570p' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 1315


🏁 Script executed:

# Check if the schema follows the coding guideline about examples
# Look at the end of the file to see the structure
tail -100 src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 2023


🏁 Script executed:

# Search for code that actually populates resourceDependencies
rg -n "resourceDependencies" --type=js --type=ts

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Broader search for resourceDependencies in all files
rg -n "resourceDependencies" --type=ts

Repository: doc-detective/common

Length of output: 212


🏁 Script executed:

# Check if there's a heretto integration module that sets resourceDependencies
find . -name "*heretto*" -type f

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Look for any code that mentions ditamap or resource dependencies
rg -n "ditamap|resource.*depend" --type=ts --type=js -i

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Look at the heretto section structure in examples to see if resourceDependencies is shown
grep -n "heretto" -A 20 src/schemas/src_schemas/config_v3.schema.json | grep -A 20 "examples"

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Check the heretto items schema definition more carefully
sed -n '226,312p' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 3990


🏁 Script executed:

# Look for any TypeScript/JavaScript files in src directory (check actual type)
find src -type f \( -name "*.ts" -o -name "*.js" \) | head -20

Repository: doc-detective/common

Length of output: 180


🏁 Script executed:

# Check if there's implementation code that populates resourceDependencies
rg -n "resourceDependencies" src/files.js -A 5 -B 5

Repository: doc-detective/common

Length of output: 46


🏁 Script executed:

# Also check if there's a need for required fields in nested objects
# Look at fileMapping to compare - does it have a required array?
sed -n '262,279p' src/schemas/src_schemas/config_v3.schema.json

Repository: doc-detective/common

Length of output: 794


🏁 Script executed:

# Check the actual heretto integration usage/implementation
cat src/files.js | head -100

Repository: doc-detective/common

Length of output: 2533


🏁 Script executed:

# Check if there are other source schemas and if they have examples arrays
find src/schemas/src_schemas -name "*.json" -type f -exec basename {} \;

Repository: doc-detective/common

Length of output: 1446


🏁 Script executed:

# Verify examples array presence in another source schema
rg -l "examples" src/schemas/src_schemas/

Repository: doc-detective/common

Length of output: 2838


🏁 Script executed:

# Check the output schema to see if it's different from source schema
diff src/schemas/src_schemas/config_v3.schema.json src/schemas/output_schemas/config_v3.schema.json | head -50

Repository: doc-detective/common

Length of output: 1308


🏁 Script executed:

# Check if the coding guideline about examples applies - look at a simpler schema
cat src/schemas/src_schemas/wait_v3.schema.json | head -40

Repository: doc-detective/common

Length of output: 750


🏁 Script executed:

# Check context_v3.schema.json to understand the examples pattern
cat src/schemas/src_schemas/context_v3.schema.json | head -80

Repository: doc-detective/common

Length of output: 2556


🏁 Script executed:

# Verify the exact coding guideline - look for any schema-level references to examples
rg -n "examples" src/schemas/src_schemas/wait_v3.schema.json

Repository: doc-detective/common

Length of output: 82


Add examples for resourceDependencies and verify if nested properties require explicit required array.

The resourceDependencies structure lacks examples in the schema. Per coding guidelines, all schemas must include examples for test generation. Add an example showing a populated resourceDependencies object (e.g., with a uuid, fullPath, name, and parentFolderId entry).

Additionally, since resourceDependencies is automatically populated during content loading by fetching ditamap resource dependencies, verify whether all four nested properties (uuid, fullPath, name, parentFolderId) are always present. If they are, add a required array to the nested object definition to improve schema validation accuracy.

🤖 Prompt for AI Agents
In src/schemas/src_schemas/config_v3.schema.json around lines 285-310, the
resourceDependencies schema is missing an example and may lack an explicit
required array for its nested properties; add an "examples" (or "example") entry
showing a sample mapping (e.g., a file path key mapping to an object with uuid,
fullPath, name, parentFolderId populated) directly under the
resourceDependencies definition, and if those four nested properties are always
present at runtime, add a "required":
["uuid","fullPath","name","parentFolderId"] to the nested object definition
inside additionalProperties so validation reflects that all fields must exist.

@promptless
Copy link

promptless bot commented Jan 3, 2026

📝 Documentation updates detected!

Updated existing suggestion: Document Heretto CMS integration for DITA content testing

Copy link
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

This PR implements a Heretto CMS uploader feature to enable screenshot synchronization with an external CMS. The changes add metadata tracking for source integration through new JSON schemas and update path resolution logic to handle Heretto-specific URI schemes.

  • Introduces a new sourceIntegration_v3 schema to track file metadata from CMS integrations
  • Extends screenshot and config schemas to support source integration metadata
  • Updates path resolution to recognize and preserve heretto: URI schemes
  • Upgrades development dependencies (chai, sinon) to latest versions

Reviewed changes

Copilot reviewed 14 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/schemas/src_schemas/sourceIntegration_v3.schema.json Defines new schema for CMS source integration metadata
src/schemas/src_schemas/screenshot_v3.schema.json Adds sourceIntegration property to screenshot schema
src/schemas/src_schemas/config_v3.schema.json Adds Heretto configuration properties for file mapping and upload settings
src/schemas/schemas.json Consolidated schema file with sourceIntegration additions
src/schemas/output_schemas/*.json Output versions of updated schemas with sourceIntegration support
src/schemas/dereferenceSchemas.js Registers new sourceIntegration schema for dereferencing
src/resolvePaths.js Updates path resolution to handle heretto: URI scheme
package.json Updates chai and sinon dev dependencies
package-lock.json Dependency lock file updates with transitive dependency changes
dist/schemas/*.json Distribution versions of updated schemas

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

@hawkeyexl hawkeyexl merged commit 8ad7460 into main Jan 3, 2026
20 checks passed
@hawkeyexl hawkeyexl deleted the heretto2 branch January 3, 2026 21:47
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.

2 participants