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

fix(framework): Remove only failing validation properties and simplify Slack schema #6160

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

rifont
Copy link
Contributor

@rifont rifont commented Jul 25, 2024

What changed? Why was the change needed?

  • Add tests for polymorphic schemas
  • Remove only failing validation properties in JsonSchema validator
  • simplify Slack schema to reduce bundle size.
    • Aside from runtime validation, these Slack blocks definitions were not actually providing any DX value due to use of the if/then style of JsonSchem syntax. We will need to revisit adding type support for Slack blocks by using explicitly generated Typescript typings from the Slack blocks JsonSchema to reduce the burden on Typescripts inference engine.

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@@ -20,7 +20,7 @@ export class JsonSchemaValidator implements Validator<JsonSchema> {
// https://ajv.js.org/options.html#usedefaults
useDefaults: true,
// https://ajv.js.org/options.html#removeadditional
removeAdditional: 'all',
removeAdditional: 'failing',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the important change to ensure that specifying additionalProperties: true on the schema is acted upon, maintaining the additional properties. Previously, all additional properties were being removed, ignoring this schema property.

@@ -36,7 +37,7 @@ export type ExecuteOutputOptions = {

export type ExecuteOutput = {
outputs: Record<string, unknown>;
providers?: Record<string, Record<string, unknown>>;
providers?: Record<string, WithPassthrough<Record<string, unknown>>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a missing type here.

@@ -40,7 +40,7 @@ describe('validators', () => {
title: 'should remove additional properties and successfully validate',
schemas: {
zod: z.object({ name: z.string() }),
json: { type: 'object', properties: { name: { type: 'string' } } } as const,
json: { type: 'object', properties: { name: { type: 'string' } }, additionalProperties: false } as const,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Necessary to fix the failing test after modifying the removeAdditional property in the JsonSchema validator.

@rifont rifont merged commit 0d45f66 into next Jul 30, 2024
26 checks passed
@rifont rifont deleted the unify-framework-providers-api branch July 30, 2024 08:34
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.

2 participants