You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<details>
<summary>"backlog"</summary>
- [ ] [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 .prettierignore or
the biome config, default: false.
</details>
### Draft summary
`apify actor generate-schema-types --help`
```
Generate TypeScript types from Actor schemas.
USAGE
$ actor generate-schema-types [path] [--all-optional] [-o <value>] [--strict]
ARGUMENTS
path Optional path to the input schema file. If not provided, searches default locations.
FLAGS
--all-optional Mark all properties as optional in generated types.
-o, --output=<value> Directory where the generated files should be outputted. Defaults to src/.generated/actor/ to stay within the typical tsconfig rootDir.
--strict Whether generated interfaces should be strict (no index signature [key: string]: unknown).
DESCRIPTION
Generate TypeScript types from Actor schemas.
Generates types from the input schema and, when no custom path is provided,
also from the dataset schema defined in '.actor/actor.json' under "storages.dataset".
Reads the input schema from one of these locations (in priority order):
1. Object in '.actor/actor.json' under "input" key
2. JSON file path in '.actor/actor.json' "input" key
3. .actor/INPUT_SCHEMA.json
4. INPUT_SCHEMA.json
Optionally specify custom schema path to use.
```
TO DO:
- [x] [slack-feedback] mention in docs that default output path is `src`
due to tsconfig
- [x] [slack-feedback] `actor generate-schema` ->
`generate-schema-types` to keep consistency with `actor
validate-schema`?
- [x] [slack-feedback] do not export the individual fields, not useful
as you can do Input['field']
- this must be done manually, `json-schema-to-typescript` does not
support this
- [x] [slack-feedback] inline primitive types to make it less verbose
(the comments above inlined fields still display in editor)
- this must be done manually, `json-schema-to-typescript` does not
support this
- [x] output types
- [x] key-value-store types
- [x] how to resolve unknown[] problem? (_As long as the items: { type:
string } propagates to string[] type, let's just go that way_.)
feedback from @B4nan
Must fix
- [x] Verify biome-ignore-all actually works or remove it
- [x] Handle Promise.all failure gracefully — partial success should
still produce output
Should fix
- [x] Extract schema transform functions to src/lib/schema-transforms.ts
- [x] Add unit tests for stripTitles
- [x] Handle missing JSON Schema keywords in stripTitles
Nice to have
- [x] ~~Reduce deep clone overhead~~ lets address this with
#1000 (comment)
- [x] Deduplicate readOutputSchema logic
- [x] Clean up import style, unused defaults
0 commit comments