Skip to content

refactor(jans-cedarling): enhance schema parser and entity creation implementation #10513

Open
@rmarinn

Description

Is your feature request related to a problem? Please describe.

The current Cedar Schema Parser and Entity Creation features lack some automation and validation capabilities. Specifically:

  1. Parsing schemas could be made more robust and efficient.
  2. Entity creation via Cedarling is hard to maintain since every time a new entity is introduced, a new custom function for that entity might be required depending on the entity shape.

Describe the solution you'd like

  1. Improve Cedar Schema Parser: Enhance the parser to handle edge cases, improve performance, and provide clearer error messages when schemas are invalid.
  2. Enhance Cedar Entity Creation: Update cedarling to:
    • Validate the schema against the supplied HashMap.
    • Automatically attempt to create entities based on the schema.
    • Return detailed error messages if the creation fails due to mismatches or missing data. For example, if the supplied HashMap includes a key "Access_token" with a corresponding struct, the entity builder should validate this against the schema and either create the entity or return a descriptive error.

Describe alternatives you've considered

  • Manually validating HashMap entries before invoking entity creation, which is error-prone and less efficient.
  • Writing custom logic for schema validation, which adds additional maintenance overhead and redundancy.

Additional context

Example usage:

// we define this struct which will hold all data gathered from the tokens
struct EntityBuilder;

// the creation here will probably not be as simple as calling `new` since we need to take
// note of the mappings but is initialized like this in the example for brevity.
let entity_builder = EntityBuilder::new();

entity_data.insert("Access_token", SomeStruct { /* fields */ });
match entity_builder.create_entity(&entity_data) {
    Ok(entity) => println!("Entity created: {:?}", entity),
    Err(e) => println!("Failed to create entity: {}", e),
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions