Skip to content

Field mapper functionality#60

Open
Chaymee wants to merge 5 commits intoSolaceLabs:mainfrom
Chaymee:field-mapper
Open

Field mapper functionality#60
Chaymee wants to merge 5 commits intoSolaceLabs:mainfrom
Chaymee:field-mapper

Conversation

@Chaymee
Copy link
Contributor

@Chaymee Chaymee commented Oct 23, 2025

PR contains functionality for the new field mapper. This feature has been added to the generate flow and the configure command. In the future we may wish to add it to the configure webUI.

The field mapper works by taking the async api spec file provided by the user at feed generation time and the generic feedrules file created from the spec file and leverages AI in an attempt to provide a better mapping to faker data generation. You can see the benefit of this when publishing events from an STM Feed that has been AI enhanced. Generated content in the payload and in topic fields will be more representative of the type of data that would be in those fields in a real world scenario.

The field mapper starts by assigning faker rule mappings to the payload elements for JSON payloads (currently the only payload type supported by STM). Then it checks if there are any of those same elements in the topic address and maps the payload value to the topic value. This ensures that things like account numbers match between payload and topic addresses.

Chaymee and others added 4 commits October 17, 2025 11:01
This commit addresses two issues with feed generation:

1. Fixed bug where 'undefined' directory was created during feed generation
   - Set feed.name when feedName is provided via CLI
   - Moved lastUpdated timestamp before createFeed() call
   - Removed redundant updateAndLoadFeedInfo() call that wrote feedinfo.json twice
   - Removed unused updateAndLoadFeedInfo import

2. Added hard-coded default AI field mapper endpoint
   - Set default to https://b0hv9uf5m8.execute-api.us-east-2.amazonaws.com/Prod/fieldmap
   - Priority order: CLI flag > env var > hard-coded default
   - Updated documentation with usage examples and configuration priority

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings October 23, 2025 19:15
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 introduces AI-powered field mapping functionality to automatically enhance feed generation with intelligent data rules and topic parameter mappings. The feature leverages an AWS Lambda endpoint that uses Google Gemini and Anthropic Claude models to analyze AsyncAPI specifications and generate realistic Faker.js mappings.

Key Changes:

  • Added --ai-enhance and --ai-mapper-endpoint CLI options to feed generate and feed configure commands
  • Implemented AI disclaimer acceptance workflow with persistent storage
  • Created field mapper client for AWS Lambda integration with automatic topic-to-payload field mapping

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/options.ts Added AI enhancement CLI options to generate and configure commands
src/utils/instances.ts Extended ManageFeedClientOptions with AI enhancement properties
src/utils/field-mapper-client.ts New client for AWS Lambda field mapping service with comprehensive error handling
src/utils/defaults.ts Added AI disclaimer file constant
src/utils/ai-disclaimer.ts New module for AI disclaimer acceptance workflow and persistence
src/lib/feed-generate.ts Integrated AI enhancement into feed generation workflow with disclaimer checks
src/lib/feed-configure.ts Added AI-powered auto-configuration mode for existing feeds
src/index.ts Captured AI option sources for command tracking
documentation/EVENT_FEEDS.md Documented AI enhancement feature usage and warnings
claude.md Added comprehensive AI field mapping documentation and implementation details
README.md Added AI enhancement feature announcement and data privacy warning

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -0,0 +1,183 @@
import { Logger } from './logger';
import chalk from 'chalk';

Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The hardcoded AWS Lambda endpoint URL should be documented more prominently with information about its ownership, SLA expectations, and what happens if it becomes unavailable. Consider adding a comment explaining this is a Solace-managed service endpoint.

Suggested change
/**
* Default endpoint for the AI Field Mapper Lambda function.
*
* This is a Solace-managed AWS Lambda service endpoint.
* Ownership: Solace Inc. (contact: support@solace.com)
* SLA: No formal SLA; availability and response times may vary.
* If this endpoint becomes unavailable, field mapping enhancements will fail and the function will return null.
* To use a different endpoint, set the STM_FIELD_MAPPER_ENDPOINT environment variable or pass a custom endpoint to the function.
*/

Copilot uses AI. Check for mistakes.
feedName = options.feedName;
fileName = options.fileName;
}
feed.name = feedName;
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

This assignment appears to be unrelated to AI enhancement and might be a bug fix that should be mentioned separately. The feed.name is being set here but the relationship to the AI feature is unclear from the PR description.

Copilot uses AI. Check for mistakes.
createFeed(fileName, feedName, feed, data, rules, schemas, sessionPropertiesJson, options.useDefaults ? true : false);
feed.lastUpdated = new Date().toISOString();
updateAndLoadFeedInfo(feed);
createFeed(fileName, feedName, feed, data, rules, schemas, sessionPropertiesJson, options.useDefaults ? true : false);
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The line order change (moving feed.lastUpdated before createFeed and removing updateAndLoadFeedInfo call) appears unrelated to AI enhancement functionality and may represent a separate bug fix that should be documented.

Copilot uses AI. Check for mistakes.
removed need for async api spec file and updated the codeflow
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