Skip to content
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

Added Capability Construct and strict schema for component style #116

Merged
merged 25 commits into from
Jul 30, 2024

Conversation

codeSafari10
Copy link
Contributor

@codeSafari10 codeSafari10 commented Jul 27, 2024

Notes for Reviewers

Title: Component Capabilities Schema

Description:

This PR introduces a significant refactoring of our component capabilities schema to improve scalability, flexibility, and clarity. The changes aim to flatten the capability structure and introduce a more generic, extensible approach to defining component capabilities to achieve that we are creating a new construct called capability

Key changes:

  1. Replaced the hierarchical object structure with a new, flattened capability construct.

  2. Introduced a new schema for capabilities with the following key fields:

    • kind: High-level category of the capability
    • type: More specific categorization within each kind
    • subType: (Optional) Most granular level of capability definition
    • state: Specifies whether the capability applies to "declaration" or "instance" state of an entity
    • status: Indicates if the capability is "enabled" or "disabled"
    • Additional fields: displayName, description, key for more detailed capability information
  3. Defined enum variants for kind , while type and subtype are flexible to cover a wide range of capabilities without frequent schema changes.

Benefits:

  • Increased scalability: New capabilities can be added without changing the core schema.
  • Improved clarity: Capabilities are now more precisely categorized and described.
  • Enhanced flexibility: The new structure allows for more detailed capability definitions.
  • Better organization: Capabilities are now consistently structured across different component states.

Example:

Old format:

"designer": {
  "capabilities": {
    "config": { "type": "boolean" },
    "label": { "type": "boolean" }
  }
}

New format:

{
  "kind": "configuration",
  "type": "edit",
  "subType": "component-config",
  "state": ["declaration"],
  "status": "enabled",
  "displayName": "Edit Configuration",
  "description": "Allows configuration of the component",
}

Example Component Capabilities

{
  kind : "mutate"
  type :  "configuration"
  subType : "config" | "labels" | "annotations" 
  description : "Gives the ability to edit a components configuration" 
}   // drives the configuration tooltip in extensions

{
  kind: "mutate"
  type: "style" 
  subtype : "shape" | "label"  ...  ( absence of a property means it is allowed ) 
} 

{
  kind : "interaction" 
  type: "graph"
  subtype: "allowsCompoundDragAndDrop" | "bubbleEvents" | "lock"  | "mouse-events"
} 

{
  kind: "view" 
  type: "configuration"
  subtype :  "config" | "labels" | "annotations"   // whether a readonly view is supported 
} 

{
  kind: "view" 
  type: "graph"
  subtype :  "labels" | "children" 
} 

Next Steps:

  • Update all existing component definitions to use the new capability schema.
  • Refactor related code to work with the new capability structure.

Would you like me to modify or expand on any part of this pull request description?

Signed commits

  • Yes, I signed my commits.

@aabidsofi19 aabidsofi19 changed the title V1beta1 Added Capability Construct and strict schema for component style Jul 27, 2024
@aabidsofi19
Copy link
Member

i tried to make the kind generic so the capabilty schema becomes generic for all entities . i think there is still some room for making them more generic ,less overlapping . and maybe reducing the number . i guess some of the kinds right now then might go into type .

@aabidsofi19
Copy link
Member

@codeSafari10 what do you think ?

@codeSafari10
Copy link
Contributor Author

codeSafari10 commented Jul 27, 2024

reduced kind to :

    "kind": {
      "$ref": "../core.json#/definitions/inputString",
      "description": "Kind of the capability",
      "anyOf": [
        {
          "const": "configuration",
          "description": "For capabilities related to entities configuration  like config, labels , annotations,etc"
        },
        {
          "const": "visualization",
          "description": "For capabilities related to visualization of entities like labels , styles"
        },
        {
          "const": "lifecycle",
          "description": "For capabilities related to lifecycle mamangement of entities like deploy, undeploy ,start, stop, restart, etc"
        },

        {
          "const": "action",
          "description": "Catch all for capabilities related to actions on entities like delete,run, execute, etc"
        }
      ]
    },

or more generic :

  {
          "const": "action",
          "description": "For capabilities related to executing actions on entities"
        },
        {
          "const": "mutate",
          "description": "For capabilities related to mutating an entity"
        },

        {
          "const": "interaction",
          "description": "Catch all for capabilities related to interaction with entities"
        }
      ]

@codeSafari10
Copy link
Contributor Author

ref to the key schema is missing here . i dont know if the openapi key schema works for a general key construct

@leecalcote
Copy link
Member

@Jougan-0, you're going to want to get your mind wrapped around this. // @Yashsharma1911 @humblenginr

@leecalcote
Copy link
Member

@Jougan-0, you're going to want to get your mind wrapped around this. // @Yashsharma1911 @humblenginr

And quickly pair a PR updating the Model Generator to reflect these changes.

schemas/constructs/v1beta1/component.json Outdated Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Outdated Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Outdated Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Outdated Show resolved Hide resolved
@leecalcote
Copy link
Member

A foreseeable possibility in the future is that Capabilities might have Selectors in the same way that Relationships have Selectors. Thank you for this discussion on this concept today, @codeSafari10.

schemas/constructs/v1alpha1/capability.json Outdated Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Show resolved Hide resolved
schemas/constructs/v1alpha1/capability.json Outdated Show resolved Hide resolved
"additionalProperties": false,
"type": "object",

"required": ["schemaVersion", "version", "displayName", "kind", "type", "state", "status"],
Copy link
Contributor

Choose a reason for hiding this comment

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

kind, type and subtype together should uniquely identify a capability. Hence subType should be required

Copy link
Member

Choose a reason for hiding this comment

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

@MUzairS15, my guess is the thinking here is that it's not always necessary to have this level specificity in order to identify a capability. Given this, that begs the idea that subtype is optional.

If we can put some forethought into a proposed set of classifications (a set of examples of how kind, type, subtype can be made to always be present), that exercise will lend itself to making it comfortable to require subtype.

schemas/constructs/v1alpha1/capability.json Show resolved Hide resolved
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Signed-off-by: codeSafari10 <[email protected]>
Copy link
Member

@leecalcote leecalcote left a comment

Choose a reason for hiding this comment

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

LGTM

"Edge",
"Sibling"
]
"enum": ["Hierarchical", "Edge", "Sibling"]
Copy link
Member

Choose a reason for hiding this comment

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

@MUzairS15, please confirm that lowercased versions of these enums are supported, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would mean intercepting the validation, so let's keep them lowercase. Clients can format it when needed to display, ok?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds great. I will rely upon you to ensure that our current clients are compatible with lowercase values. Please suggest a change here and let’s merge and release.

Copy link
Member

@leecalcote leecalcote Jul 30, 2024

Choose a reason for hiding this comment

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

Relationship policies are currently compatible with lowercase?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

"Edge",
"Sibling"
]
"enum": ["Hierarchical", "Edge", "Sibling"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"enum": ["Hierarchical", "Edge", "Sibling"]
"enum": ["hierarchical", "edge", "sibling"]

@aabidsofi19 aabidsofi19 merged commit 042b4ae into meshery:master Jul 30, 2024
1 of 2 checks passed
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.

4 participants