Skip to content

Conversation

@Adi-204
Copy link
Member

@Adi-204 Adi-204 commented Nov 2, 2025

Description
Add message validation before sending messages using library ajv. Locally I change client_postman fixture by changing schema for sendEchoMessage operation it is just for testing purpose we will revert fixture changes.

Related issue(s)
Fixes #1665
In order to start working on #1548 I need a working validator.

Summary by CodeRabbit

  • New Features

    • Initial release of the Keeper package and publish configuration.
    • Client templates add optional AsyncAPI file directory support.
  • Improvements

    • Switched to an AJV-based validator with per-operation schema compilation and validation before sending.
    • Stricter message validation, clearer error reporting, and expanded test coverage.
  • Chores

    • Centralized Jest configuration into a shared base and bumped Keeper version.

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

@changeset-bot
Copy link

changeset-bot bot commented Nov 2, 2025

🦋 Changeset detected

Latest commit: b16dbb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/keeper Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@asyncapi-bot
Copy link
Contributor

What reviewer looks at during PR review

The following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.

  1. PR Title: Use a concise title that follows our Conventional Commits guidelines and clearly summarizes the change using imperative mood (it means spoken or written as if giving a command or instruction, like "add new helper for listing operations")

    Note - In Generator, prepend feat: or fix: in PR title only when PATCH/MINOR release must be triggered.

  2. PR Description: Clearly explain the issue being solved, summarize the changes made, and mention the related issue.

    Note - In Generator, we use Maintainers Work board to track progress. Ensure the PR Description includes Resolves #<issue-number> or Fixes #<issue-number> this will automatically close the linked issue when the PR is merged and helps automate the maintainers workflow.

  3. Documentation: Update the relevant Generator documentation to accurately reflect the changes introduced in the PR, ensuring users and contributors have up-to-date guidance.

  4. Comments and JSDoc: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions, so others can easily understand and use the code.

  5. DRY Code: Ensure the code follows the Don't Repeat Yourself principle. Look out for duplicate logic that can be reused.

  6. Test Coverage: Ensure the new code is well-tested with meaningful test cases that pass consistently and cover all relevant edge cases.

  7. Commit History: Contributors should avoid force-pushing as much as possible. It makes it harder to track incremental changes and review the latest updates.

  8. Template Design Principles Alignment: While reviewing template-related changes in the packages/ directory, ensure they align with the Assumptions and Principles. If any principle feels outdated or no longer applicable, start a discussion these principles are meant to evolve with the project.

  9. Reduce Scope When Needed: If an issue or PR feels too large or complex, consider splitting it and creating follow-up issues. Smaller, focused PRs are easier to review and merge.

  10. Bot Comments: As reviewers, check that contributors have appropriately addressed comments or suggestions made by automated bots. If there are bot comments the reviewer disagrees with, react to them or mark them as resolved, so the review history remains clear and accurate.

@coderabbitai
Copy link

coderabbitai bot commented Nov 2, 2025

Walkthrough

Replaces Hyperjump JSON Schema with AJV in the keeper app, removes structuredClone polyfill from Jest setup, centralizes Jest configuration into a shared jest.config.base.js with per-package jest.config.js files, and integrates @asyncapi/keeper into WebSocket JS client templates with per-operation schema compilation/validation wiring.

Changes

Cohort / File(s) Summary
Keeper app (validator + tests)
apps/keeper/jest.setup.js, apps/keeper/jest.config.js, apps/keeper/package.json, apps/keeper/src/index.js, apps/keeper/src/utils.js, apps/keeper/test/__fixtures__/asyncapi-message-validation.yml, apps/keeper/test/index.test.js
Move to AJV-based validation API (compileSchema, compileSchemas, compileSchemasByOperationId, validateMessage), remove structuredClone polyfill and generateSchemaURI/removeCompiledSchemas, update tests and fixture (use messageId), bump package metadata and publish config.
Shared Jest base & per-package configs
jest.config.base.js, apps/generator/jest.config.js, apps/keeper/jest.config.js, packages/components/jest.config.js, packages/helpers/jest.config.js, packages/templates/clients/kafka/java/quarkus/jest.config.js, packages/templates/clients/kafka/test/integration-test/jest.config.js, packages/templates/clients/websocket/dart/jest.config.js, packages/templates/clients/websocket/java/quarkus/jest.config.js, packages/templates/clients/websocket/javascript/jest.config.js, packages/templates/clients/websocket/python/jest.config.js, packages/templates/clients/websocket/test/integration-test/jest.config.js, packages/templates/clients/websocket/test/javascript/jest.config.js
Add jest.config.base.js helper and per-package jest.config.js files that spread the base config and set moduleFileExtensions/transform (use babel-jest); remove inline jest blocks from package.json files.
WebSocket JS client templates (keeper integration)
packages/templates/clients/websocket/javascript/package.json, packages/templates/clients/websocket/javascript/.ageneratorrc, packages/templates/clients/websocket/javascript/components/ClientClass.js, packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js, packages/templates/clients/websocket/javascript/components/Constructor.js, packages/templates/clients/websocket/javascript/template/client.js.js
Add @asyncapi/keeper dependency, new asyncapiFileDir parameter/hook, inject asyncapiFilepath into generated client, add CompileOperationSchemas component (documentation/code block), pass sendOperations into constructor and client wiring to support per-operation schema compilation.
SendOperations & DependencyProvider
packages/components/src/components/SendOperations.js, packages/components/src/components/DependencyProvider.js
Make send methods async; add per-operation schema compilation/validation flow before sending; emit keeper imports (compileSchemasByOperationId, validateMessage) in JS dependency provider.
Removed Jest blocks from package.json files
packages/components/package.json, packages/helpers/package.json, packages/templates/clients/kafka/java/quarkus/package.json, packages/templates/clients/kafka/test/integration-test/package.json, packages/templates/clients/websocket/dart/package.json, packages/templates/clients/websocket/java/quarkus/package.json, packages/templates/clients/websocket/python/package.json, packages/templates/clients/websocket/test/integration-test/package.json, packages/templates/clients/websocket/test/javascript/package.json, packages/templates/clients/websocket/test/integration-test/package.json
Remove top-level jest configuration objects from multiple package.json files to rely on the shared base + per-package jest.config.js.
Misc. template/config fixes & release
packages/templates/clients/kafka/java/quarkus/.ageneratorrc, .changeset/release-keeper.md
Minor YAML quote cleanup and add changeset to release @asyncapi/keeper.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

  • High-attention areas:
    • apps/keeper/src/index.js — AJV integration, public API changes, error/return shapes.
    • packages/components/src/components/SendOperations.js — async control flow and validation-before-send semantics.
    • Template wiring files (Constructor.js, ClientClass.js, CompileOperationSchemas.js, template/client.js.js) — ensure injected asyncapiFilepath, sendOperations and generated code consistency.
    • Jest base config (jest.config.base.js) — path resolution and moduleNameMapper correctness for existing packages.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: release @asyncapi/keeper and use for message validation in JS websocket client' directly describes the main changes: releasing the keeper package and integrating it for message validation in the JavaScript WebSocket client.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #1665 by integrating @asyncapi/keeper for message validation in the JS WebSocket client, with appropriate schema compilation and validation logic added throughout the codebase.
Out of Scope Changes check ✅ Passed All changes align with the linked issue #1665 objectives. The PR consolidates validation logic into @asyncapi/keeper, updates the JS WebSocket client to use it, and includes necessary Jest configuration refactoring to support the new structure.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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 0d99db2 and b16dbb4.

📒 Files selected for processing (1)
  • .changeset/release-keeper.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/release-keeper.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test NodeJS PR - windows-latest

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

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/src/components/SendOperations.js (1)

74-99: Critical: Validation logic has multiple issues.

The validation implementation has several problems:

  1. Line 77: Early return { isValid: true } when no schemas provided bypasses validation silently. This should at least log a warning or be explicitly documented as intended behavior.

  2. Lines 92-95: The if (!isValid) check is inside the for loop, so it executes on every iteration. It should be moved outside the loop to check the final validation result.

  3. Logic flaw: When validation fails, the code logs errors but doesn't prevent the message from being sent (if it was sent in a previous iteration) and doesn't throw an error as documented in the JSDoc (@throws).

  4. Missing final validation check: After the loop, if !isValid, the function should throw an error rather than silently returning.

Here's a corrected implementation:

 static async ${methodName}(message, socket, schemas) {
   try {
     if (!schemas || schemas.length === 0) {
-      return { isValid: true }; 
+      console.warn('No schemas provided for validation. Skipping validation.');
+      socket.send(JSON.stringify(message));
+      return;
     }
     const allValidationErrors = [];
     let isValid = false;
     for(const compiledSchema of schemas){
       const validationResult = validateMessage(compiledSchema, message);
       if (validationResult.isValid) {
         isValid = true;
         socket.send(JSON.stringify(message));
-        break;
+        return;  // Successfully validated and sent
       } else {
         if (validationResult.validationErrors) {
           allValidationErrors.push(...validationResult.validationErrors);
         }
       }
-      if (!isValid) {
-        console.error('Validation errors:', JSON.stringify(allValidationErrors, null, 2));
-      }
     }
+    // If we reach here, validation failed against all schemas
+    console.error('Validation errors:', JSON.stringify(allValidationErrors, null, 2));
+    throw new Error(\`Message validation failed for ${methodName}: \${JSON.stringify(allValidationErrors)}\`);
   } catch (error) {
     console.error('Error sending ${methodName} message:', error);
+    throw error;  // Re-throw to match JSDoc
   }
 }
📜 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 7e0823a and 600f77a.

⛔ Files ignored due to path filters (4)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/components/test/components/__snapshots__/DependencyProvider.test.js.snap is excluded by !**/*.snap
  • packages/components/test/components/__snapshots__/SendOperations.test.js.snap is excluded by !**/*.snap
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • apps/keeper/jest.setup.js (0 hunks)
  • apps/keeper/package.json (1 hunks)
  • apps/keeper/src/index.js (2 hunks)
  • apps/keeper/src/utils.js (0 hunks)
  • apps/keeper/test/__fixtures__/asyncapi-message-validation.yml (1 hunks)
  • apps/keeper/test/index.test.js (2 hunks)
  • packages/components/src/components/DependencyProvider.js (1 hunks)
  • packages/components/src/components/SendOperations.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/ClientClass.js (2 hunks)
  • packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/Constructor.js (2 hunks)
  • packages/templates/clients/websocket/javascript/example.js (2 hunks)
  • packages/templates/clients/websocket/javascript/package.json (1 hunks)
  • packages/templates/clients/websocket/javascript/template/client.js.js (1 hunks)
  • packages/templates/clients/websocket/test/__fixtures__/asyncapi-postman-echo.yml (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/keeper/src/utils.js
  • apps/keeper/jest.setup.js
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with action property (send/receive) and references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe operations
3. Messages are defined under a 'messages' container in channels
4. The specification decouples operations, channels and messages to improve reusability
5. Servers can use a 'host' property

Applied to files:

  • packages/templates/clients/websocket/test/__fixtures__/asyncapi-postman-echo.yml
  • packages/templates/clients/websocket/javascript/components/Constructor.js
  • apps/keeper/test/__fixtures__/asyncapi-message-validation.yml
  • packages/components/src/components/SendOperations.js
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe
3. Messages are defined under a 'messages' container in channels
4. Servers can use a 'host' property

Applied to files:

  • packages/templates/clients/websocket/test/__fixtures__/asyncapi-postman-echo.yml
  • apps/keeper/test/__fixtures__/asyncapi-message-validation.yml
  • packages/components/src/components/SendOperations.js
📚 Learning: 2025-05-12T14:57:35.024Z
Learnt from: Adi-204
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:21-21
Timestamp: 2025-05-12T14:57:35.024Z
Learning: In the AsyncAPI generator templates, particularly in the JavaScript WebSocket client, single quotes are used for string literals inside template-generated code (which is itself inside backticks) to preserve template placeholders like ${variable} as literal text in the generated code output.

Applied to files:

  • packages/templates/clients/websocket/javascript/template/client.js.js
  • packages/templates/clients/websocket/javascript/example.js
  • packages/templates/clients/websocket/javascript/package.json
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.

Applied to files:

  • packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js
🧬 Code graph analysis (8)
packages/templates/clients/websocket/javascript/components/Constructor.js (2)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
  • sendOperations (12-12)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
  • sendOperations (16-16)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
packages/components/src/components/DependencyProvider.js (1)
  • DependencyProvider (106-116)
packages/templates/clients/websocket/javascript/components/ClientClass.js (2)
packages/templates/clients/websocket/javascript/components/Constructor.js (1)
  • Constructor (3-28)
packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js (1)
  • CompileOperationSchemas (3-40)
apps/keeper/test/index.test.js (1)
apps/keeper/src/index.js (5)
  • compileSchema (12-14)
  • validateMessage (70-85)
  • compiledSchemas (26-26)
  • compileSchemas (22-31)
  • compileSchemasByOperationId (41-59)
apps/keeper/src/index.js (2)
apps/generator/lib/templates/config/validator.js (1)
  • Ajv (2-2)
apps/keeper/src/utils.js (3)
  • asyncapi (16-16)
  • parseAsyncAPIDocumentFromFile (12-24)
  • parseAsyncAPIDocumentFromFile (12-24)
packages/components/src/components/SendOperations.js (2)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
  • clientName (10-10)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
  • clientName (13-13)
packages/templates/clients/websocket/javascript/example.js (1)
packages/templates/clients/websocket/test/javascript/acceptance.test.js (2)
  • WSClient (5-5)
  • require (6-6)
packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js (1)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
  • sendOperations (12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest
  • GitHub Check: Test NodeJS PR - macos-13
🔇 Additional comments (6)
packages/templates/clients/websocket/javascript/example.js (1)

26-28: Change verified as correct.

The message format { content: 'Hello!' } correctly matches the sendEchoMessage schema defined in the AsyncAPI 3.0.0 fixture. The object includes the required content property (string type) and properly omits the optional messageId field. This structure aligns with the schema validation approach and will pass validation.

apps/keeper/test/__fixtures__/asyncapi-message-validation.yml (1)

34-36: LGTM!

The schema update from timestamp to messageId is clean and appropriate for test fixture usage.

packages/templates/clients/websocket/javascript/components/ClientClass.js (1)

5-5: LGTM!

The integration of CompileOperationSchemas is properly structured, with correct imports, prop passing, and render order (before SendOperations).

Also applies to: 13-13, 27-27

packages/templates/clients/websocket/javascript/components/Constructor.js (1)

3-6: LGTM!

The constructor properly initializes the schema compilation state (compiledSchemas, schemasCompiled, sendOperationsId), enabling per-operation schema handling.

Also applies to: 20-22

apps/keeper/test/index.test.js (1)

4-4: LGTM!

Test suite properly updated to use the new API (compileSchema, compileSchemas, validateMessage). Good coverage of validation scenarios, error cases, and operation-specific validation.

Also applies to: 15-23, 25-90, 92-129

packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js (1)

3-39: Component structure is sound, but depends on hardcoded path.

The generated compileOperationSchemas() method is well-structured with proper guards (schemasCompiled check) and error handling. However, it references asyncapiFilepath which is currently hardcoded to a test fixture path in client.js.js (see my comment on that file).

Once the asyncapiFilepath issue is resolved, this component will function correctly.

Copy link

@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

♻️ Duplicate comments (1)
apps/keeper/src/index.js (1)

70-85: Update error message to reflect that null is allowed.

The validation logic correctly only checks for undefined (not null), allowing schemas that permit null payloads to work as intended. However, the error message on line 72 still mentions "non-null object", which is misleading.

Apply this diff to clarify the error message:

-    throw new Error(`Invalid "message" parameter: expected a non-null object to validate, but received ${message}`);
+    throw new Error(`Invalid "message" parameter: expected a value to validate, but received ${message}`);

This aligns with the suggested fix from the previous review comment and accurately reflects that null is now a valid input for validation.

📜 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 600f77a and 02119bb.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/components/test/components/__snapshots__/SendOperations.test.js.snap is excluded by !**/*.snap
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • apps/keeper/package.json (1 hunks)
  • apps/keeper/src/index.js (2 hunks)
  • apps/keeper/test/index.test.js (2 hunks)
  • packages/components/src/components/SendOperations.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/Constructor.js (2 hunks)
  • packages/templates/clients/websocket/javascript/example.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/templates/clients/websocket/javascript/example.js
  • packages/templates/clients/websocket/javascript/components/Constructor.js
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with action property (send/receive) and references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe operations
3. Messages are defined under a 'messages' container in channels
4. The specification decouples operations, channels and messages to improve reusability
5. Servers can use a 'host' property

Applied to files:

  • packages/components/src/components/SendOperations.js
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe
3. Messages are defined under a 'messages' container in channels
4. Servers can use a 'host' property

Applied to files:

  • packages/components/src/components/SendOperations.js
🧬 Code graph analysis (3)
apps/keeper/test/index.test.js (2)
apps/keeper/src/utils.js (2)
  • parser (2-2)
  • parseResult (18-18)
apps/keeper/src/index.js (5)
  • compileSchema (12-14)
  • validateMessage (70-85)
  • compiledSchemas (26-26)
  • compileSchemas (22-31)
  • compileSchemasByOperationId (41-59)
packages/components/src/components/SendOperations.js (2)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
  • clientName (10-10)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
  • clientName (13-13)
apps/keeper/src/index.js (2)
apps/generator/lib/templates/config/validator.js (1)
  • Ajv (2-2)
apps/keeper/src/utils.js (3)
  • asyncapi (16-16)
  • parseAsyncAPIDocumentFromFile (12-24)
  • parseAsyncAPIDocumentFromFile (12-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test NodeJS PR - macos-13
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest
🔇 Additional comments (11)
apps/keeper/package.json (3)

21-21: AJV dependency addition aligns with migration goals.

The addition of ajv for JSON schema validation is correct and directly supports the PR objective to migrate from Hyperjump JSON Schema to AJV-based validation.


27-27: Critical issue resolved: babel-jest dependency added.

The previous review flagged that babel-jest was referenced in Jest's transform config but missing from devDependencies. This has now been correctly added at version ^27.3.1, which aligns with the installed Jest version and should be compatible.


38-42: Module mappings correctly updated for dependency migration.

The moduleNameMapper updates appropriately remove mappings for the deprecated Hyperjump packages and retain only the necessary nimma mappings, reflecting the migration from @hyperjump/json-schema to ajv.

apps/keeper/test/index.test.js (4)

13-17: LGTM! Helper simplifies test setup.

The parseAsyncAPIFile helper centralizes the parsing logic and makes tests cleaner.


19-71: LGTM! Comprehensive coverage of basic validation scenarios.

The tests properly exercise the new single-schema validation flow, including success cases, validation failures, and error conditions.


73-90: LGTM! Good coverage for compileSchemas.

The tests validate both the happy path (multiple schema compilation) and error handling (invalid parameter type).


92-129: LGTM! Thorough coverage of operation-specific validation.

The tests properly exercise compileSchemasByOperationId including error cases for invalid and empty operation IDs.

apps/keeper/src/index.js (4)

1-4: LGTM! Appropriate AJV configuration.

The AJV instance is configured with strict: false for flexibility and allErrors: true to capture all validation errors.


6-14: LGTM! Clean wrapper for AJV compilation.

The function properly delegates to AJV's compile method and returns a validator function.


16-31: LGTM! Proper input validation and delegation.

The function validates the input parameter type and correctly delegates to compileSchema for each schema.


33-59: LGTM! Enhanced validation and error handling.

The function now includes stronger input validation, proper operation existence checks, and gracefully handles missing messages with a warning.

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/src/components/SendOperations.js (1)

74-100: Fix validation logic bugs and error handling.

The static method has several critical issues:

  1. Logic bug (lines 93-95): The if (!isValid) check is inside the for loop, so validation errors are logged on every failed schema instead of once after exhausting all schemas. Move this check outside the loop.

  2. Missing throw on validation failure: The JSDoc promises @throws {Error} If message validation fails against all schemas (line 72), but when all schemas fail the method only logs errors—it never throws. Callers have no way to detect validation failure.

  3. Silent error swallowing (lines 97-99): The try-catch logs errors but doesn't rethrow, so JSON serialization failures, socket errors, and validation errors are all swallowed silently.

  4. Inconsistent return values: The no-schema path returns { isValid: true } (line 78), but the validation-success path (line 86-87) doesn't return anything.

Apply this diff to fix the logic and error handling:

 static ${methodName}(message, socket, schemas) {
   try {
     if (!schemas || schemas.length === 0) {
       socket.send(JSON.stringify(message));
       return { isValid: true }; 
     }
     const allValidationErrors = [];
     let isValid = false;
     for(const compiledSchema of schemas){
       const validationResult = validateMessage(compiledSchema, message);
       if (validationResult.isValid) {
         isValid = true;
         socket.send(JSON.stringify(message));
-        break;
+        return { isValid: true };
       } else {
         if (validationResult.validationErrors) {
           allValidationErrors.push(...validationResult.validationErrors);
         }
       }
-      if (!isValid) {
-        console.error('Validation errors:', JSON.stringify(allValidationErrors, null, 2));
-      }
     }
+    // If we reach here, validation failed against all schemas
+    console.error('Validation errors for ${methodName}:', JSON.stringify(allValidationErrors, null, 2));
+    const error = new Error('Message validation failed for ${methodName} against all schemas.');
+    error.validationErrors = allValidationErrors;
+    throw error;
   } catch (error) {
-    console.error('Error sending ${methodName} message:', error);
+    // Re-throw validation errors and other errors so callers can handle them
+    throw error;
   }
 }
♻️ Duplicate comments (1)
packages/components/src/components/SendOperations.js (1)

56-62: Return the validation result from the static method call.

The instance method delegates to the static method but ignores its return value. The static method returns { isValid: true } when successful (line 78) and can throw validation errors. Either return the result to the caller or explicitly handle/document that this method has no return value and relies solely on exceptions for failure signaling.

Apply this diff if you want to surface the validation result:

 async ${methodName}(message){
   if(!this.websocket){
     throw new Error('WebSocket connection not established. Call connect() first.');
   }
   await this.compileOperationSchemas();
   const schemas = this.compiledSchemas['${methodName}'];
-  ${clientName}.${methodName}(message, this.websocket, schemas);
+  return ${clientName}.${methodName}(message, this.websocket, schemas);
 }
🧹 Nitpick comments (3)
apps/keeper/src/index.js (3)

6-14: Consider adding input validation for consistency.

While ajv.compile will throw for invalid inputs, other functions in this file validate their parameters upfront. For consistency and clearer error messages, consider validating that schema is an object.

 export function compileSchema(schema) {
+  if (!schema || typeof schema !== 'object') {
+    throw new Error('Invalid "schema" parameter: must be a non-null object.');
+  }
   return ajv.compile(schema);
 }

77-84: Rename validate variable to isValid for clarity.

The variable validate holds a boolean validation result, not a validator function. Renaming it to isValid would improve readability and prevent confusion.

- const validate = compiledSchema(message);
- if (validate) {
+ const isValid = compiledSchema(message);
+ if (isValid) {
    return { isValid: true };
  }

65-65: Update JSDoc type annotation to reflect that null is allowed.

The JSDoc declares @param {object} message, but the code correctly allows null values (line 71 only throws for undefined). Update the type annotation to reflect this flexibility.

- * @param {object} message - The message payload to validate.
+ * @param {*} message - The message payload to validate (null allowed if schema permits).
📜 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 02119bb and efd780f.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/components/test/components/__snapshots__/SendOperations.test.js.snap is excluded by !**/*.snap
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • apps/keeper/package.json (1 hunks)
  • apps/keeper/src/index.js (2 hunks)
  • packages/components/src/components/SendOperations.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/keeper/package.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with action property (send/receive) and references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe operations
3. Messages are defined under a 'messages' container in channels
4. The specification decouples operations, channels and messages to improve reusability
5. Servers can use a 'host' property

Applied to files:

  • packages/components/src/components/SendOperations.js
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe
3. Messages are defined under a 'messages' container in channels
4. Servers can use a 'host' property

Applied to files:

  • packages/components/src/components/SendOperations.js
🧬 Code graph analysis (2)
packages/components/src/components/SendOperations.js (2)
packages/templates/clients/websocket/javascript/template/client.js.js (1)
  • clientName (10-10)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
  • clientName (13-13)
apps/keeper/src/index.js (2)
apps/generator/lib/templates/config/validator.js (1)
  • Ajv (2-2)
apps/keeper/src/utils.js (3)
  • asyncapi (16-16)
  • parseAsyncAPIDocumentFromFile (12-24)
  • parseAsyncAPIDocumentFromFile (12-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - ubuntu-latest
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - macos-13
🔇 Additional comments (3)
apps/keeper/src/index.js (3)

1-4: LGTM! Good Ajv configuration.

The shared Ajv instance with allErrors: true ensures comprehensive validation feedback, and strict: false provides flexibility for various schema patterns.


16-31: LGTM! Clean implementation.

The function properly validates the input array and delegates to compileSchema for individual schema compilation. The synchronous approach simplifies the API.


33-59: LGTM! Comprehensive error handling.

The function properly validates inputs, handles missing operations with clear errors, and gracefully handles the no-messages case with a warning. The filter-map pattern for extracting payloads is clean and efficient.

Copy link

@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

📜 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 8261cc6 and 92bf100.

⛔ Files ignored due to path filters (1)
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/templates/clients/websocket/javascript/package.json (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-12T14:57:35.024Z
Learnt from: Adi-204
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:21-21
Timestamp: 2025-05-12T14:57:35.024Z
Learning: In the AsyncAPI generator templates, particularly in the JavaScript WebSocket client, single quotes are used for string literals inside template-generated code (which is itself inside backticks) to preserve template placeholders like ${variable} as literal text in the generated code output.

Applied to files:

  • packages/templates/clients/websocket/javascript/package.json
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.

Applied to files:

  • packages/templates/clients/websocket/javascript/package.json
🪛 GitHub Actions: Test using test project
packages/templates/clients/websocket/javascript/package.json

[error] 1-1: npm JSON.parse error: Invalid JSON syntax in package.json (Expected ',' or '}' after property value). The log indicates a parsing error near a property value.

🔇 Additional comments (1)
packages/templates/clients/websocket/javascript/package.json (1)

13-17: Critical: @asyncapi/keeper dependency is not integrated into the template code.

The dependency was added to package.json but verification reveals no actual integration:

  1. No keeper imports: Zero imports of @asyncapi/keeper exist in any template files
  2. Undefined function: compileSchemasByOperationId is called in CompileOperationSchemas.js:28 but is not defined anywhere—this will cause a runtime error
  3. No keeper API usage: Neither compileSchema nor validateMessage from keeper are invoked anywhere in the template
  4. No SendOperation validation: No validation logic exists to use keeper with SendOperation

Fixes required:

  • Add keeper import to appropriate component(s)
  • Define or import compileSchemasByOperationId (or replace with keeper's actual API)
  • Implement message validation logic using keeper's APIs in SendOperation context
⛔ Skipped due to learnings
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.

Comment on lines 39 to 50
payload:
type: object
properties:
content:
type: string
description: The content to be echoed back
example: "test message"
messageId:
type: number
description: Unique identifier for the message
required:
- content
Copy link
Member Author

Choose a reason for hiding this comment

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

This changes is just for testing purpose and needs to revert before merging.

this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
}
this.schemasCompiled = true;
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
Copy link
Member Author

Choose a reason for hiding this comment

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

This log is also for debugging can be removed before merging.

Copy link

@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: 1

📜 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 b41d81c and f52f6d8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • apps/generator/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - ubuntu-latest
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - windows-latest

"@asyncapi/generator-helpers": "*",
"@asyncapi/generator-hooks": "*",
"@asyncapi/generator-react-sdk": "*",
"@asyncapi/keeper": "*",
Copy link

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

Verify package availability and consider tightening version constraint.

The new dependency uses a wildcard version ("*"), which permits any version including breaking changes. While this pattern is consistent with other internal @asyncapi/* packages in this file, it introduces supply chain risk and makes builds non-reproducible.

Consider the following verification steps:

  1. Confirm that @asyncapi/keeper is properly published and accessible.
  2. Verify the version constraint aligns with your project's dependency management standards.
  3. If possible, tighten the constraint to at least "^<version>" (e.g., "^1.0.0") to prevent accidental breaking changes during installation.

🏁 Script executed:

#!/bin/bash
# Description: Verify @asyncapi/keeper package availability and fetch latest version info

# Check if @asyncapi/keeper exists on npm and retrieve version details
curl -s "https://registry.npmjs.org/@asyncapi/keeper" | jq '{name: .name, "latest-version": .["dist-tags"].latest, versions: (.versions | keys | sort | .[-5:])}'

Length of output: 94



Tighten version constraint to prevent unexpected updates from unstable package.

The new dependency uses a wildcard version ("*"), which is problematic for @asyncapi/keeper since it's a brand-new package (currently at 0.0.1 only). This allows any future version—including breaking changes in upcoming 0.1.0 or 1.0.0 releases—to install automatically without lockfile protection, breaking reproducible builds.

Change:

-    "@asyncapi/keeper": "*",
+    "@asyncapi/keeper": "0.0.1",

Once @asyncapi/keeper reaches a stable 1.0.0 release, consider updating to "^1.0.0" to allow patch updates while preventing breaking changes.

🤖 Prompt for AI Agents
In apps/generator/package.json around line 59, the dependency "@asyncapi/keeper"
is using a wildcard version "*" which permits any future release (including
breaking changes) and undermines reproducible installs; change the version
string to the current specific release "0.0.1" to pin it, and later consider
switching to a caret range like "^1.0.0" once the package reaches stable 1.0.0
to allow safe updates.

Copy link

@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: 1

📜 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 f52f6d8 and 99d602b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • packages/templates/clients/websocket/javascript/package.json (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with action property (send/receive) and references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe operations
3. Messages are defined under a 'messages' container in channels
4. The specification decouples operations, channels and messages to improve reusability
5. Servers can use a 'host' property
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe
3. Messages are defined under a 'messages' container in channels
4. Servers can use a 'host' property
📚 Learning: 2025-05-12T14:57:35.024Z
Learnt from: Adi-204
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:21-21
Timestamp: 2025-05-12T14:57:35.024Z
Learning: In the AsyncAPI generator templates, particularly in the JavaScript WebSocket client, single quotes are used for string literals inside template-generated code (which is itself inside backticks) to preserve template placeholders like ${variable} as literal text in the generated code output.

Applied to files:

  • packages/templates/clients/websocket/javascript/package.json
📚 Learning: 2025-05-12T17:29:03.886Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:7-7
Timestamp: 2025-05-12T17:29:03.886Z
Learning: Do not suggest adding key props to mapped React elements in the asyncapi/generator repository, even when linters like Biome flag them as missing.

Applied to files:

  • packages/templates/clients/websocket/javascript/package.json
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.

Applied to files:

  • packages/templates/clients/websocket/javascript/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest
  • GitHub Check: Test NodeJS PR - windows-latest
🔇 Additional comments (1)
packages/templates/clients/websocket/javascript/package.json (1)

13-17: Keeper is not a template dependency; generated client would manage its own dependencies.

The verification shows this PR only reorders dependencies alphabetically—no semantic changes. Keeper is generated by DependencyProvider as output code in the client template, not as a template-generation requirement. Template package.json only needs the tools to render the template (React SDK, helpers, components), not the dependencies of the generated output.

Keeper was recently removed (commit 99d602b: "remove keeper from js"), and no keeper imports exist in the template code itself—only in the generated code strings that DependencyProvider outputs. The generated client would have its own package.json declaring keeper as a dependency, separate from this template's metadata.

Likely an incorrect or invalid review comment.

"eslint-plugin-react": "^7.34.1",
"eslint-plugin-sonarjs": "^0.5.0"
"eslint-plugin-sonarjs": "^0.5.0",
"jest-esm-transformer": "^1.0.0"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused jest-esm-transformer or integrate it into Jest configuration.

The jest-esm-transformer@^1.0.0 dependency (line 28) is added but not configured in the Jest setup. The transform config (line 37) still uses only babel-jest. Either remove the unused dependency or replace the babel-jest transformer with jest-esm-transformer. Babel already includes ESM handling via @babel/preset-env, so clarify the intent before keeping unused dependencies.

🤖 Prompt for AI Agents
In packages/templates/clients/websocket/javascript/package.json around line 28,
the dependency "jest-esm-transformer" is present but not referenced in the Jest
transform config (around line 37) so it is unused; either remove the
"jest-esm-transformer" entry from package.json (and run install/update lockfile)
or update the Jest config to replace or add the transformer (e.g., change the
transform entry to reference "jest-esm-transformer" instead of "babel-jest" and
remove "babel-jest" if no longer needed), and ensure any Babel vs ESM handling
is consistent (update other Jest settings or presets accordingly).

Copy link

@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: 0

♻️ Duplicate comments (1)
packages/templates/clients/websocket/java/quarkus/jest.config.js (1)

1-13: Matches the shared Jest pattern; same optional DRY opportunity

This config correctly extends baseConfig(__dirname) and applies the expected moduleFileExtensions and babel-jest transform. It shares the same optional “centralize these common Jest options” refactor noted in the websocket dart Jest config.

🧹 Nitpick comments (5)
packages/templates/clients/websocket/dart/jest.config.js (1)

1-13: Config is fine; consider centralizing repeated Jest options

This setup (baseConfig + moduleFileExtensions + babel-jest transform) is correct and consistent. Since the exact same pattern appears in multiple template Jest configs, you could optionally pull moduleFileExtensions and the '^.+\\.jsx?$'babel-jest transform into a small shared helper or into jest.config.base.js (if all consumers need it) to avoid repetition.

packages/templates/clients/websocket/test/javascript/jest.config.js (1)

1-13: Consistent Jest setup for websocket JS tests

Configuration is in line with the other template Jest configs and should work as expected. The only (optional) improvement is the same one already mentioned: consider centralizing the repeated moduleFileExtensions/babel-jest transform if you find more suites need the exact same settings.

packages/templates/clients/websocket/test/integration-test/jest.config.js (1)

1-13: Integration-test Jest config is correct and aligned

Extending baseConfig(__dirname) and adding the standard JS/JSX babel-jest transform is appropriate here. This file also fits the same optional “factor out shared Jest options” refactor discussed for the other websocket template configs.

packages/templates/clients/kafka/java/quarkus/jest.config.js (1)

1-13: Kafka Quarkus Jest config follows the shared pattern

This is consistent with the other client template Jest configs and should work fine. As with the others, you could optionally extract the common moduleFileExtensions and babel-jest transform into shared config if you want to reduce repetition.

packages/templates/clients/kafka/test/integration-test/jest.config.js (1)

1-13: Configuration looks correct, but consider consolidating duplicated settings.

This Jest config correctly extends the base configuration. However, the moduleFileExtensions and transform settings are duplicated identically across multiple packages (components, websocket/javascript, and keeper). Consider moving these common settings to the base config or creating a shared preset.

If consolidation is desired, the base config could accept an options parameter to enable JavaScript/JSX support:

// Example consolidation in jest.config.base.js
module.exports = (dirname, options = {}) => {
  const config = { /* base config */ };
  
  if (options.enableJavaScript) {
    config.moduleFileExtensions = ['js', 'json', 'jsx'];
    config.transform = { '^.+\\.jsx?$': 'babel-jest' };
  }
  
  return config;
};

Then simplify per-package configs:

module.exports = baseConfig(__dirname, { enableJavaScript: true });
📜 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 6a7fd07 and 1501fac.

📒 Files selected for processing (26)
  • apps/generator/jest.config.js (1 hunks)
  • apps/generator/test/test-project/jest.config.js (1 hunks)
  • apps/generator/test/test-project/package.json (0 hunks)
  • apps/keeper/jest.config.js (1 hunks)
  • apps/keeper/package.json (1 hunks)
  • jest.config.base.js (1 hunks)
  • packages/components/jest.config.js (1 hunks)
  • packages/components/package.json (0 hunks)
  • packages/helpers/jest.config.js (1 hunks)
  • packages/helpers/package.json (0 hunks)
  • packages/templates/clients/kafka/java/quarkus/jest.config.js (1 hunks)
  • packages/templates/clients/kafka/java/quarkus/package.json (0 hunks)
  • packages/templates/clients/kafka/test/integration-test/jest.config.js (1 hunks)
  • packages/templates/clients/kafka/test/integration-test/package.json (0 hunks)
  • packages/templates/clients/websocket/dart/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/dart/package.json (0 hunks)
  • packages/templates/clients/websocket/java/quarkus/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/java/quarkus/package.json (0 hunks)
  • packages/templates/clients/websocket/javascript/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/javascript/package.json (1 hunks)
  • packages/templates/clients/websocket/python/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/python/package.json (0 hunks)
  • packages/templates/clients/websocket/test/integration-test/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/test/integration-test/package.json (0 hunks)
  • packages/templates/clients/websocket/test/javascript/jest.config.js (1 hunks)
  • packages/templates/clients/websocket/test/javascript/package.json (0 hunks)
💤 Files with no reviewable changes (10)
  • packages/helpers/package.json
  • packages/components/package.json
  • packages/templates/clients/websocket/java/quarkus/package.json
  • packages/templates/clients/kafka/test/integration-test/package.json
  • packages/templates/clients/websocket/test/integration-test/package.json
  • packages/templates/clients/websocket/python/package.json
  • packages/templates/clients/kafka/java/quarkus/package.json
  • packages/templates/clients/websocket/test/javascript/package.json
  • packages/templates/clients/websocket/dart/package.json
  • apps/generator/test/test-project/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/templates/clients/websocket/javascript/package.json
  • apps/keeper/package.json
🧰 Additional context used
🧬 Code graph analysis (14)
packages/components/jest.config.js (3)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/keeper/jest.config.js (1)
  • baseConfig (1-1)
packages/helpers/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (2)
packages/templates/clients/websocket/dart/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/python/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/java/quarkus/jest.config.js (8)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/generator/test/test-project/jest.config.js (1)
  • baseConfig (2-2)
apps/keeper/jest.config.js (1)
  • baseConfig (1-1)
packages/components/jest.config.js (1)
  • baseConfig (1-1)
packages/helpers/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/dart/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/python/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (3)
packages/templates/clients/websocket/dart/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
apps/generator/test/test-project/jest.config.js (2)
apps/generator/jest.config.js (2)
  • path (1-1)
  • baseConfig (2-2)
jest.config.base.js (1)
  • path (1-1)
packages/templates/clients/websocket/python/jest.config.js (4)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/generator/test/test-project/jest.config.js (1)
  • baseConfig (2-2)
packages/templates/clients/websocket/dart/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (2)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/kafka/java/quarkus/jest.config.js (4)
packages/templates/clients/kafka/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/helpers/jest.config.js (12)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/generator/test/test-project/jest.config.js (1)
  • baseConfig (2-2)
apps/keeper/jest.config.js (1)
  • baseConfig (1-1)
packages/components/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/kafka/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/kafka/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/dart/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/python/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
jest.config.base.js (3)
apps/generator/jest.config.js (1)
  • path (1-1)
apps/generator/test/test-project/jest.config.js (1)
  • path (1-1)
apps/generator/lib/parser.js (1)
  • options (24-24)
packages/templates/clients/websocket/dart/jest.config.js (5)
packages/templates/clients/websocket/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/python/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
apps/keeper/jest.config.js (6)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/generator/test/test-project/jest.config.js (1)
  • baseConfig (2-2)
packages/components/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/kafka/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/javascript/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
apps/generator/jest.config.js (1)
jest.config.base.js (1)
  • path (1-1)
packages/templates/clients/kafka/test/integration-test/jest.config.js (6)
apps/generator/jest.config.js (1)
  • baseConfig (2-2)
apps/generator/test/test-project/jest.config.js (1)
  • baseConfig (2-2)
packages/templates/clients/kafka/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/java/quarkus/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/integration-test/jest.config.js (1)
  • baseConfig (1-1)
packages/templates/clients/websocket/test/javascript/jest.config.js (1)
  • baseConfig (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest
🔇 Additional comments (8)
packages/templates/clients/websocket/python/jest.config.js (1)

1-13: ****

The file location is correct. The python directory name refers to the target language being generated (Python client), not the language of the template files. The directory contains JavaScript template files and components that generate Python output—this is a standard pattern for code generators. The jest.config.js correctly configures testing for the JavaScript template components in this directory.

The multiple .js files in packages/templates/clients/websocket/python/components/, template/, and test/ confirm the templates are written in JavaScript, and the jest.config.js appropriately tests them.

Likely an incorrect or invalid review comment.

apps/generator/test/test-project/jest.config.js (1)

1-11: Jest config and path aliases look correct

The base config usage and the relative paths for the local @asyncapi/* packages line up with the directory depth of this test project; I don’t see any issues here.

jest.config.base.js (1)

1-24: Base Jest config and nimma mappings look sound

The relative-path calculation back to the repo root and the resulting nimma moduleNameMapper entries are correct, and merging caller-specific mappings after the defaults gives a sensible override mechanism. I don’t see any functional problems with this base config.

packages/helpers/jest.config.js (1)

1-5: Helpers Jest config correctly delegates to the base config

Using baseConfig(__dirname) without extra overrides keeps this package’s tests aligned with the shared defaults; looks good.

apps/generator/jest.config.js (1)

2-9: LGTM!

The refactoring to extend the base Jest config while preserving the package-specific moduleNameMapper is clean and maintains the necessary local path resolution for nunjucks-filters.

packages/components/jest.config.js (1)

1-13: LGTM!

The Jest configuration correctly extends the base config with appropriate JavaScript/JSX support.

packages/templates/clients/websocket/javascript/jest.config.js (1)

1-13: LGTM!

The configuration correctly extends the base config with appropriate settings for JavaScript template testing.

apps/keeper/jest.config.js (1)

1-13: LGTM!

The Keeper Jest configuration correctly extends the base config and aligns with the broader refactoring to centralize Jest setup across the monorepo.

@derberg
Copy link
Member

derberg commented Nov 22, 2025

all looks good, you can remove changes that were there just for testing

the only problem I see that when I run locally integration tests, snapshot fail and update removes your functionality. Did I miss something?

Screenshot 2025-11-22 at 22 21 00

@Adi-204
Copy link
Member Author

Adi-204 commented Nov 23, 2025

@derberg that is weird because in PR integration test snapshot we can see my changes are added and also CI would have failed but all are passing. Probably it is your local machine issue 😉

Copy link

@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: 1

📜 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 9915b8f and 0b707b7.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/templates/clients/kafka/java/quarkus/.ageneratorrc (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Acceptance tests for generated templates
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - ubuntu-latest
  • GitHub Check: Test NodeJS PR - windows-latest

@derberg
Copy link
Member

derberg commented Nov 24, 2025

one last thing, why chore and no changeset to release it?

@Adi-204 Adi-204 changed the title chore: use @asyncapi/keeper for message validation in JS websocket client feat: release @asyncapi/keeper and use for message validation in JS websocket client Nov 25, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

@derberg
Copy link
Member

derberg commented Dec 1, 2025

/rtm

@asyncapi-bot asyncapi-bot merged commit 2bd801e into asyncapi:master Dec 1, 2025
19 checks passed
lightning-sagar pushed a commit to lightning-sagar/generator that referenced this pull request Dec 7, 2025
…S` websocket client (asyncapi#1747)

Co-authored-by: Adi-204 <[email protected]>
Co-authored-by: Adi Boghawala <[email protected]>
Co-authored-by: Chan <[email protected]>
Co-authored-by: Lukasz Gornicki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start using @asyncapi/keeper for message validation in JS websocket client

3 participants