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

Contribution points with type guards #21

Open
forman opened this issue Nov 20, 2023 · 0 comments
Open

Contribution points with type guards #21

forman opened this issue Nov 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@forman
Copy link
Owner

forman commented Nov 20, 2023

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

  • We currently can only validate JSON entries against a given schema, but we cannot perform any integrity checks.
  • We currently cannot perform any validity/type checking on a code contribution c when registering it using registerCodeContribution<T>(c). We must rely on the user that c is valid and of type T.

Describe the solution you'd like

Allow for optional validators isEntryValid and isContributionValid to ManifestContributionInfo and CodeContributionInfo when defining a new ContributionPoint:

export interface ManifestContributionInfo<TM = unknown, TS = TM> {
  schema: JsonTypedSchema<TM> | JsonSchema;
  processEntry?: (entry: TM) => TS;
  isEntryValid(entry: unknown)?: entry is TM;  /* NEW */
}

export interface CodeContributionInfo<TS = unknown> {
  idKey?: KeyOfObjOrArrayItem<TS>;
  activationEvent?: string;
  isContributionValid<TC = unknown>(contrib: unknown)?: contrib is TC;  /* NEW */
}
@forman forman added the enhancement New feature or request label Nov 20, 2023
@forman forman self-assigned this Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant