-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add typescript schema export utility #119
Conversation
abb51bc
to
b92bb11
Compare
b92bb11
to
8ffcd87
Compare
internal/exportTypescriptSchema.ts
Outdated
for (const schema of allSchemaNames) { | ||
indexTS += `export * from "./${schema.name}";\n`; | ||
} | ||
schemas["index"] = indexTS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this also needs to include TIME_TS
and DURATION_TS
.
Could we also use this new function here to reduce duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some final nits and suggestions but the main logic looks good to me. Thanks!
internal/exportTypescriptSchema.ts
Outdated
/** | ||
* Export typescript schema as source, keyed by the schema name. | ||
* | ||
* @returns a record of schema name => schema source. | ||
*/ | ||
export function exportTypescriptSchema(): Record<string, string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Export typescript schema as source, keyed by the schema name. | |
* | |
* @returns a record of schema name => schema source. | |
*/ | |
export function exportTypescriptSchema(): Record<string, string> { | |
/** | |
* Export typescript schemas as source, keyed by the file name. | |
* | |
* @returns a record of schema name => schema source. | |
*/ | |
export function exportTypeScriptSchemas(): Record<string, string> { |
I would go with "file name" because index
is not really a "schema name". This also makes me wonder if we should add ".ts"
suffix to the keys as well?
Maybe use a Map?
internal/exportTypescriptSchema.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think you'll need to export this from
internal/index.ts
- also would rename file to
exportTypeScriptSchemas.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think you'll need to export this from
internal/index.ts
👍
- also would rename file to
exportTypeScriptSchemas.ts
The other files in this directory use the singular so I stuck with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other functions also tend to operate on just 1 schema at a time
@foxymiles "schemata" is a cute spelling...but the name of this repo is foxglove/schemas, so I think we should probably stick with that plural form 😬 |
Follow-up from #119 - Replace "schemata" with "schemas" - Use "TypeScript" capitalization - Export generateTypeScript stuff in case we need it later - Return a Map instead of an object - Clarified documentation
Public-Facing Changes
None
Description
Add typescript schema export utility. This will be used in studio to import schema definitions in order to make them available for use in user scripts.