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

feat(ui): better field types #6396

Merged
merged 5 commits into from
May 20, 2024
Merged

Conversation

psychedelicious
Copy link
Collaborator

Summary

While working on #6386, I was reminded of some awkwardness around field types and cardinality (single vs collection). I've been meaning to make this change for some time but was afraid to do it without good tests in place. Now that we have solid test coverage for schema parsing and connection validation, this is no longer scary.

From one of the commits:

Thanks to a change a couple months back in which the workflows schema was revised, field types are internal implementation details. Changes to them are non-breaking.

That means this PR doesn't include any user-facing changes and doesn't change the workflow schema or structure. It only changes the templates format (templates are generated at runtime).

I did need to fix a past mistake with some type annotations for workflow migration. These are type annotations only, there's no change to runtime workflow migration behaviour.

Related Issues / Discussions

n/a

QA Instructions

Give 'er a whirl.

Merge Plan

n/a

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)

@github-actions github-actions bot added frontend PRs that change frontend files docs PRs that change docs labels May 19, 2024
@psychedelicious psychedelicious enabled auto-merge (rebase) May 20, 2024 01:26
Replace the `isCollection` and `isCollectionOrScalar` flags with a single enum value `cardinality`. Valid values are `SINGLE`, `COLLECTION` and `SINGLE_OR_COLLECTION`.

Why:
- The two flags were mutually exclusive, but this wasn't enforce. You could create a field type that had both `isCollection` and `isCollectionOrScalar` set to true, whuch makes no sense.
- There was no explicit declaration for scalar/single types.
- Checking if a type had only a single flag was tedious.

Thanks to a change a couple months back in which the workflows schema was revised, field types are internal implementation details. Changes to them are non-breaking.
At some point, I made a mistake and imported the wrong types to some files for the old v1 and v2 workflow schema migration data.

The relevant zod schemas and inferred types have been restored.

This change doesn't alter runtime behaviour. Only type annotations.
@psychedelicious psychedelicious force-pushed the psyche/feat/ui/better-field-types branch from fb51e9e to f1206c6 Compare May 20, 2024 01:26
@psychedelicious psychedelicious merged commit 1c29b3b into main May 20, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/ui/better-field-types branch May 20, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs that change docs frontend PRs that change frontend files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants