Repository navigation
feat(form): add decoupled extension schema parser - #23
colinjlacy merged 3 commits into
Conversation
…nerator Signed-off-by: Abhinav Deval <abhinavkdeval08@gmail.com>
| export function formatFieldLabel(propName: string): string { | ||
| if (!propName) return ''; | ||
|
|
||
| const acronymMap: Record<string, string> = { |
There was a problem hiding this comment.
I'm not sure that we need this. We intentionally won't have environment-specific values in our forms (e.g. MiB, HTTPS, etc.) and we would never be able to get ahead of all possible acronyms anyway.
There was a problem hiding this comment.
Makes sense, removed it. Labels are plain Title Case now (so minMemoryMiB shows up as "Min Memory Mi B", which I'm fine with).
There was a problem hiding this comment.
@abhinavkdeval08-design does it need to be Title Case? I do feel a little weird suggesting this, but since our end users are most likely to be developers, can we just use the field names as they are?
There was a problem hiding this comment.
Makes complete sense. Punted on the blanket Title Case conversion.. formatFieldLabel now preserves the raw property name as-is so devs see the exact YAML/JSON fields they expect. Ready to go!
There was a problem hiding this comment.
This file is well written and will certainly be necessary. I'm just a little concerned that it may be premature to have this file written. Do we feel confident enough about what the form submission interface will look like that we can adequately create a generator script?
There was a problem hiding this comment.
Fair concern. I'm not sure the submission interface is settled: right now it takes the field descriptors plus a flat values map, and it doesn't cover persistence or prefill from the issue. Happy to pull generator.ts out of this PR and land the parser first, or keep it as a first cut. Whichever you prefer.
colinjlacy
left a comment
There was a problem hiding this comment.
@abhinavkdeval08-design Really great first pass. I do have a few changes requested, but don't be discouraged. You're doing something that's bonkers hard and will therefore have a lot of tweaks here and there.
The one thing that I was looking for and didn't see was how we would handle extensions that extend other extensions. the env-configuration extension extends common-integrations, partially because it should indeed be optional to declare env vars, but also as a way of proving that the chained extensions approach works. You can/should use that combo as a test case.
We also have examples of nested condition fields. You can find those in common-integrations as well, in the api.http kind/type.
… streamline type extraction
|
Thanks, and good call on the chained extensions. It's not handled yet. |
|
Pushed 466f8a3 addressing the inline comments. The generator and chaining threads are open questions for you. |
|
I would suggest removing the generator from this PR and stashing it for later. It looks like it would work as a baseline, but until we have chained extensions and object recursion figured out, it'll just be more to maintain. You can address chained dependencies an object recursion in the next PR if you like. Looking at the rest now... |
colinjlacy
left a comment
There was a problem hiding this comment.
Just the one open question on how the prop name is being formatted. I'm very curious about whether or not it's necessary. Same with how the values are presented. Devs are typically used to JSONing and YAMLing in lowercase and snake case, so I'm curious how it would be received if presented in a form.
People could legit hate it. But they could also end up disliking a blanket formatting approach.
There may be (or likely are) JS libs that help address this, and could be used for rendering. So maybe we punt on this one for now?
…s labels Signed-off-by: Abhinav Deval <abhinavkdeval08@gmail.com>
Refs #16
hey @colinjlacy — here's part 1 of #16 with the decoupled TypeScript schema parser under
src/form/(no Backstage UI dependencies, so we can reuse it directly in runtimeconditions/runtimeconditions.github.io#10 too).What's in here:
src/form/types.ts&src/form/catalog.ts: parsesRuntimeConditionsExtensionDefinitionmanifests, extracts bothinterface.*and condition-level fields (env,configuration), keeps raw field names as labels for developer familiarity, and capturesif/thenconditional rules.src/form/form.test.ts: unit tests covering schema parsing and condition form extraction.Scope notes (per review feedback):
stash/generator-draft.env-configurationextendingcommon-integrations, whichparseExtensionDefinitioncurrently rejects), recursion into nested object fields (e.g.api.http), and the generator.Thanks for the thorough review!