-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.
Description
We want to have a command to generate (currently only) TypeScript definitions for the input.json (and in the future from output schema, or dataset/key value store schemas)
For an idea of how such an implementation can be done, see https://github.com/apify-projects/types-from-schema-generator
The command name I'd say should be apify actor generate-types / actor generate-types (cc @B4nan)
It should have the following flags:
- output: path to a directory where the files generated should be outputted, default
./.generated/actor/(actual path in code is gonna beresolve(cwd(), output), followed by mkdir(), then storing in there). char:o - strict: whether generated interfaces should have an index definition (
[key: string]: unknownif this is set tofalse), defaulttrue. char:s - [can optionally be done] language: the language to generate the types for (currently only TypeScript, but ideally structure the code in a way where we can easily add in new languages). char:
l - [optional, nice to have, can be for future work] [input/output/dataset/key-value-store]-schema: path to a specific schema to generate types for
- [don't implement this until we discuss it] add-to-ignore: whether the cli should add the generated files to files like
.prettierignoreor thebiomeconfig, default:false. @B4nan lets discuss if we want this. char:i
When generating the files, the filename should ideally be the filename of the input schema, but with the appropriate language. So for example, if you're generating a file from ./my_schema.json, the result should be ./my_schema.ts
All generated files should have the following headers for TS:
// biome-ignore-all lint: Automatically generated file
/* eslint-disable -- Automatically generated file */
/**
* This file was automatically generated by the actor CLI.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run `actor generate-types` to regenerate this file.
*
* Don't forget to add this file to the ignore list of your formatters and linters.
*/l2ysho
Metadata
Metadata
Assignees
Labels
t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.