-
Notifications
You must be signed in to change notification settings - Fork 25
feat: enable arbitrary json in the ingest apis #3047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: enable arbitrary json in the ingest apis #3047
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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 enables IngestApi and Stream resources to accept payloads with arbitrary additional fields beyond their defined schema using TypeScript index signatures and Python's extra='allow' configuration. The API validates known fields while gracefully accepting extra fields without validation errors.
Key Changes:
- Modified the TypeScript compiler to allow index signatures for IngestApi and Stream types while extracting only named properties as columns
- Added comprehensive test coverage including templates, transforms, and E2E tests
- Updated documentation for both TypeScript and Python implementations
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ts-moose-lib/src/dataModels/typeConvert.ts | Added ToColumnsOptions interface with allowIndexSignatures flag to conditionally permit index signatures |
| packages/ts-moose-lib/src/dmv2/dataModelMetadata.ts | Enabled allowIndexSignatures for IngestApi and Stream resource types |
| templates/typescript-tests/src/ingest/indexSignatureTests.ts | Created test types and resources demonstrating index signature usage with IngestApi |
| templates/typescript-tests/src/ingest/transforms.ts | Added transform mapping UserEventInput to UserEventOutput with logging |
| apps/framework-cli-e2e/test/utils/schema-definitions.ts | Added expected schema for UserEventOutput table |
| apps/framework-cli-e2e/test/templates.test.ts | Added E2E test validating ingestion and transform of payloads with extra fields |
| apps/framework-docs/src/pages/moose/apis/ingest-api.mdx | Added "Accepting Arbitrary Fields" documentation section |
| apps/framework-docs-v2/content/moosestack/apis/ingest-api.mdx | Added "Accepting Arbitrary Fields" documentation section |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| /** | ||
| * Input type with index signature allowing arbitrary additional fields. | ||
| * Known fields (timestamp, eventName, userId) will be validated by Rust. | ||
| * Unknown fields are passed through to the streaming function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unknown fields are skipped in rust.
| map.next_value::<serde::de::IgnoredAny>()?; |
908fa3a to
92b829a
Compare
Note
Enables IngestApi/Stream to accept arbitrary extra fields (index signatures), pass them through to streaming functions, and document/test the behavior.
allow_extra_fieldstoDataModel/PartialIngestApiand propagate into ingress routes.DataModelVisitor::new_with_extra_fieldswhen allowed;DataModelVisitornow optionally passes unknown keys through; nested/NamtTuples still strict.toColumnssupportsallowIndexSignaturesoption; compiler plugin permits index signatures forIngestApi,Stream, andIngestPipeline(when no table) and injectsallowExtraFields.TypedBase,Stream,IngestApi,IngestPipeline) constructors accept/propagateallowExtraFields; infra JSON includesallowExtraFields.propertiesJSON; addUserEventOutputtable schema.Written by Cursor Bugbot for commit 7634f0c. This will update automatically on new commits. Configure here.