aws / codecatalyst-blueprints

Apache License 2.0
48 stars 18 forks source link

feat(blueprint): add UI selectors for option schemas #549

Closed michaellandi closed 1 month ago

michaellandi commented 1 month ago

Issue

N/A

Description

This change implements dynamic option schemas. Option schemas are a new type which allow the blueprint wizard to load sections of the wizard from synthesis. This approach allows a blueprint itself, to control what options are shown in the wizard.

To accomplish this, we introduce several new types:

OptionsSchema<T>: Used to declare and register a new options schema. For now, schemas can be defined using the existing DynamicKVInput type. For example:

new OptionsSchema(this, 'my-options', [{
  key: 'region',
  value: 'us-east-1',
}, {
  key: 'mode',
  value: 'automatic',
}]

OptionsSchemaDefinition<Identifier extends string, SchemaType extends OptionsSchemaType, ReturnType extends any = any> = ReturnType?: Used to declare that a section of the wizard should be loaded dynamically. The Identifier must match the schema identifier declared when instantiation an OptionsSchema (i.e. my-options from the example above). For example:

export interface Options extends ParentOptions {
   embeddedParameters: OptionsSchemaDefinition<'my-options', KVSchema, { key: string, value: string }[]>;
}

Testing

Local testing using a consuming blueprint.

Additional context

Based on customer demand, we plan on releasing support for additional schemas, such as react-jsonschema. For schema support requests, please provide feedback through issues.

This change also includes an update to the AST parser to support inline array types that do not have a formal type. This is required to support the example OptionsSchemaDefinition above.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.