[Protocol] generate:typescript: snake_case fields, slim publishable lib#3464
Merged
Conversation
Switches `generate:typescript` to `-g typescript` (plain) with `modelPropertyNaming=original` so schema field names stay snake_case (e.g. `created_at`, `pair_settings`). Adds a post-processor (`scripts/postprocess-protocol-typescript.mjs`) that strips the now-broken `HttpFile` import emitted under `--global-property models` (no `http/` supporting dir generated) and writes a `models/index.ts` barrel re-exporting every model. The `octobot_protocol_ts/` shell package is slimmed to a types-only npm package: `types: "./models/index.ts"`, `files: ["models"]`, no runtime `index.js`. Clean script keep-set narrowed to `package.json` only — `index.js`, `index.d.ts`, `schema.d.ts` no longer needed. Resulting package: ~12 kB packed, 86 files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5d1bcb7 to
87123b4
Compare
openapi-generator types each variant's discriminator field as the shared enum union (e.g. ActionConfigurationType), losing per-variant narrowing on the TypeScript side. Fix in post-process, no schema changes: - scripts/postprocess-protocol-typescript.mjs already strips the broken HttpFile import, rewrites Date typings to string, and converts string enums to literal unions. Add a narrowing pass that walks openapi.json for any property with both \$ref and description, and rewrites the variant TS file so that field's type becomes the description literal (which is the wire value for each variant in this spec). - Logic factored into scripts/postprocess-protocol-typescript.lib.mjs so it is unit-testable. - Tests live in the test/ folder next to the auto-generated Python tests (different extension so unittest ignores them): * test/postprocess-typescript.test.mjs — 14 unit tests * test/postprocess-typescript.codegen.test.mjs — 8 integration - Update clean-protocol-codegen-output.mjs to preserve \`.mjs\` test files in test/ while still wiping the auto-generated Python tests on each codegen run. - \`npm test\` runs postprocess unit + codegen integration + python model tests. Bumps @drakkar.software/octobot-protocol to 0.3.0. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
87123b4 to
6eea6b9
Compare
GuillaumeDSM
approved these changes
May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.