Skip to content

feat(schemas): add MeshModel component and relationship summary filter schemas#616

Open
Amr-Shams wants to merge 2 commits intomeshery:masterfrom
Amr-Shams:feat/meshmodel-summary-filter-schemas
Open

feat(schemas): add MeshModel component and relationship summary filter schemas#616
Amr-Shams wants to merge 2 commits intomeshery:masterfrom
Amr-Shams:feat/meshmodel-summary-filter-schemas

Conversation

@Amr-Shams
Copy link
Copy Markdown

Description

Adds schema-first API shapes for MeshModel summary filters and summary responses.

Added schemas

  • ComponentSummaryFilter
  • ComponentSummary
  • ComponentGroupEntry
  • RelationshipSummaryFilter
  • RelationshipSummary
  • RelationshipGroupEntry

Enums

  • component include: by_model, by_category, by_registrant
  • relationship include: by_model, by_kind, by_type, by_subtype

Why

Moves filter/request/response types to schemas as the source of truth so downstream repos consume generated types.
Notes for Reviewers

This PR fixes #615

Signed commits

  • Yes, I signed my commits.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the MeshModel API by introducing dedicated schemas for summarizing and filtering components and relationships. By adopting a schema-first approach, it ensures consistency and facilitates automated type generation for downstream consumers. Additionally, it improves the robustness of the Go codebase by adding explicit validation methods for numerous enum types.

Highlights

  • New MeshModel Component Summary Schemas: Introduced new API schemas for ComponentSummaryFilter, ComponentSummary, and ComponentGroupEntry to enable filtering and summarizing MeshModel components.
  • New MeshModel Relationship Summary Schemas: Added new API schemas for RelationshipSummaryFilter, RelationshipSummary, and RelationshipGroupEntry to support filtering and summarizing MeshModel relationships.
  • Schema-First API Approach: Migrated component and relationship filter/request/response types to a schema-first approach, establishing OpenAPI schemas as the source of truth for generated types across various languages.
  • Automated Enum Validation: Updated generated Go code across multiple models to include Valid() methods for all enum types, enhancing type safety and validation.
Changelog
  • models/v1alpha1/capability/capability.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for CapabilityEntityState and CapabilityStatus enums.
  • models/v1alpha1/core/core.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for various component style, edge style, and relationship style enums, as well as IaCFileTypes and Shape.
  • models/v1alpha2/catalog/catalog.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for CatalogDataCompatibility and CatalogDataType enums.
  • models/v1alpha3/relationship/relationship.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for numerous relationship definition enums.
    • Introduced new types: RelationshipGroupEntry, RelationshipSummary, RelationshipSummaryFilter, and RelationshipSummaryFilterInclude.
  • models/v1beta1/academy/academy.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for various academy-related enums.
    • Updated Banner fields in ChildNode and CurriculaMetadata to be optional.
  • models/v1beta1/badge/badge.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/category/category.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() method for CategoryDefinitionName enum.
  • models/v1beta1/component/component.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for various component definition enums.
    • Introduced new types: ComponentGroupEntry, ComponentSummary, ComponentSummaryFilter, ComponentSummaryFilterAnnotations, and ComponentSummaryFilterInclude.
  • models/v1beta1/connection/connection.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for ConnectionStatus and ConnectionStatusValue enums.
  • models/v1beta1/environment/environment.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/evaluation/evaluation.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for various action operation enums.
  • models/v1beta1/feature/feature.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() method for FeatureName enum.
  • models/v1beta1/invitation/invitation.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() method for InvitationStatus enum.
  • models/v1beta1/key/key.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/keychain/keychain.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/model/model.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for ImportRequestUploadType, ModelDefinitionStatus, and ModelDefinitionMetadataShape enums.
  • models/v1beta1/organization/organization.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() method for OrgTeamActionPayloadAction enum.
    • Updated Domain field in Organization struct to be optional.
  • models/v1beta1/pattern/pattern.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/plan/plan.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for Currency, PlanCadence, PlanName, and PlanUnit enums.
  • models/v1beta1/subcategory/subcategory.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() method for SubCategoryDefinition enum.
  • models/v1beta1/subscription/subscription.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for various subscription-related enums.
  • models/v1beta1/team/team.go
    • Updated oapi-codegen version to v2.6.0.
  • models/v1beta1/user/user.go
    • Updated oapi-codegen version to v2.6.0.
    • Added Valid() methods for GetUserResponseRoleNames, GetUserResponseStatus, and UserStatus enums.
  • models/v1beta1/workspace/workspace.go
    • Updated oapi-codegen version to v2.6.0.
  • package-lock.json
    • Updated package version from 0.8.123 to 0.8.124.
    • Removed several unused peer dependencies and their associated types.
  • schemas/constructs/v1alpha3/relationship/api.yml
    • Added RelationshipSummaryFilter, RelationshipGroupEntry, and RelationshipSummary schemas.
  • schemas/constructs/v1beta1/component/api.yml
    • Added ComponentSummaryFilter, ComponentGroupEntry, and ComponentSummary schemas.
  • typescript/generated/v1alpha3/relationship/Relationship.ts
    • Generated TypeScript interfaces for RelationshipSummaryFilter, RelationshipGroupEntry, and RelationshipSummary.
  • typescript/generated/v1alpha3/relationship/RelationshipSchema.ts
    • Generated JSON schema definitions for RelationshipSummaryFilter, RelationshipGroupEntry, and RelationshipSummary.
  • typescript/generated/v1beta1/component/Component.ts
    • Generated TypeScript interfaces for ComponentSummaryFilter, ComponentGroupEntry, and ComponentSummary.
  • typescript/generated/v1beta1/component/ComponentSchema.ts
    • Generated JSON schema definitions for ComponentSummaryFilter, ComponentGroupEntry, and ComponentSummary.
Activity
  • The pull request author, Amr-Shams, created this pull request to introduce new schema definitions for MeshModel component and relationship summary filters and responses.
  • The changes include updates to numerous generated Go model files, incorporating new Valid() methods for enum types and updating the oapi-codegen version.
  • New YAML schema definitions were added for component and relationship summaries and filters, which subsequently triggered updates in the generated TypeScript files.
  • The package-lock.json file was updated to reflect changes in dependencies and versioning.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new schemas for component and relationship summaries, and subsequently regenerates the corresponding Go and TypeScript models. The changes are predominantly auto-generated. My review has identified a recurring issue with code duplication in the generated ...Summary structs across both Go and TypeScript. Specifically, anonymous structs are being generated instead of reusing the already defined ...GroupEntry structs. This impacts the maintainability of the code. The review comments below provide specific suggestions to rectify this, which will likely necessitate adjustments in the code generation process or the source schema definitions.

Comment on lines +1204 to +1222
type RelationshipSummary struct {
ByKind *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byKind,omitempty" yaml:"byKind,omitempty"`
ByModel *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byModel,omitempty" yaml:"byModel,omitempty"`
BySubType *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"bySubType,omitempty" yaml:"bySubType,omitempty"`
ByType *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byType,omitempty" yaml:"byType,omitempty"`
Total int64 `json:"total" yaml:"total"`
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The anonymous structs used for ByKind, ByModel, BySubType, and ByType are identical to the RelationshipGroupEntry struct. To improve code reuse and maintainability, consider using the named RelationshipGroupEntry struct here. This would make the RelationshipSummary struct definition cleaner and avoid code duplication.

type RelationshipSummary struct {
	ByKind    *[]RelationshipGroupEntry `json:"byKind,omitempty" yaml:"byKind,omitempty"`
	ByModel   *[]RelationshipGroupEntry `json:"byModel,omitempty" yaml:"byModel,omitempty"`
	BySubType *[]RelationshipGroupEntry `json:"bySubType,omitempty" yaml:"bySubType,omitempty"`
	ByType    *[]RelationshipGroupEntry `json:"byType,omitempty" yaml:"byType,omitempty"`
	Total     int64                     `json:"total" yaml:"total"`
}

Comment on lines +617 to +632
// ComponentSummary defines model for ComponentSummary.
type ComponentSummary struct {
ByCategory *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byCategory,omitempty" yaml:"byCategory,omitempty"`
ByModel *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byModel,omitempty" yaml:"byModel,omitempty"`
ByRegistrant *[]struct {
Count int32 `json:"count" yaml:"count"`
Key string `json:"key" yaml:"key"`
} `json:"byRegistrant,omitempty" yaml:"byRegistrant,omitempty"`
Total int64 `json:"total" yaml:"total"`
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The anonymous structs used for ByCategory, ByModel, and ByRegistrant are identical to the ComponentGroupEntry struct. To improve code reuse and maintainability, consider using the named ComponentGroupEntry struct here. This would make the ComponentSummary struct definition cleaner and avoid code duplication.

type ComponentSummary struct {
	ByCategory   *[]ComponentGroupEntry `json:"byCategory,omitempty" yaml:"byCategory,omitempty"`
	ByModel      *[]ComponentGroupEntry `json:"byModel,omitempty" yaml:"byModel,omitempty"`
	ByRegistrant *[]ComponentGroupEntry `json:"byRegistrant,omitempty" yaml:"byRegistrant,omitempty"`
	Total        int64                 `json:"total" yaml:"total"`
}

Comment on lines +740 to +763
RelationshipSummary: {
/** Format: int64 */
total: number;
byModel?: {
key: string;
/** Format: int32 */
count: number;
}[];
byKind?: {
key: string;
/** Format: int32 */
count: number;
}[];
byType?: {
key: string;
/** Format: int32 */
count: number;
}[];
bySubType?: {
key: string;
/** Format: int32 */
count: number;
}[];
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The inline type definitions for byModel, byKind, byType, and bySubType are identical to RelationshipGroupEntry. To improve type safety and maintainability, you should reuse the RelationshipGroupEntry type here.

    RelationshipSummary: {
      /** Format: int64 */
      total: number;
      byModel?: components["schemas"]["RelationshipGroupEntry"][];
      byKind?: components["schemas"]["RelationshipGroupEntry"][];
      byType?: components["schemas"]["RelationshipGroupEntry"][];
      bySubType?: components["schemas"]["RelationshipGroupEntry"][];
    };

Comment on lines +846 to +864
ComponentSummary: {
/** Format: int64 */
total: number;
byModel?: {
key: string;
/** Format: int32 */
count: number;
}[];
byCategory?: {
key: string;
/** Format: int32 */
count: number;
}[];
byRegistrant?: {
key: string;
/** Format: int32 */
count: number;
}[];
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The inline type definitions for byModel, byCategory, and byRegistrant are identical to ComponentGroupEntry. To improve type safety and maintainability, you should reuse the ComponentGroupEntry type here.

    ComponentSummary: {
      /** Format: int64 */
      total: number;
      byModel?: components["schemas"]["ComponentGroupEntry"][];
      byCategory?: components["schemas"]["ComponentGroupEntry"][];
      byRegistrant?: components["schemas"]["ComponentGroupEntry"][];
    };

@leecalcote
Copy link
Copy Markdown
Member

Good work! You might like to present your work in the upcoming, weekly Meshery development meeting (meshery.io/calendar). If so, I encourage you to add this item in the meeting agenda (meet.meshery.io/dev-minutes), attend, present, and receive feedback.

@leecalcote
Copy link
Copy Markdown
Member

@Amr-Shams merge conflict need to be addressed.

@Amr-Shams
Copy link
Copy Markdown
Author

Good work! You might like to present your work in the upcoming, weekly Meshery development meeting (meshery.io/calendar). If so, I encourage you to add this item in the meeting agenda (meet.meshery.io/dev-minutes), attend, present, and receive feedback.

well do my best there, thanks 🥇

…r schemas

Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
@Amr-Shams Amr-Shams force-pushed the feat/meshmodel-summary-filter-schemas branch from 4c40070 to 39e5453 Compare March 12, 2026 18:56
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.

feat(schemas): add MeshModel component and relationship summary filter/response schemas

2 participants