@accelbyte/codegen 0.0.0-dev-20250519035357 → 0.0.0-dev-20260320085237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  AccelByte Code Generator is a CLI tool that facilitates creating an AccelByte TypeScript SDK from AccelByte OpenAPI definitions.
4
4
 
5
+ ## Requirements
6
+
7
+ - **Node.js >= 22.18.0** (LTS) — required for native TypeScript type stripping, used to load `abcodegen.config.ts` at runtime.
8
+
5
9
  ## CLI
6
10
  This codegen build a CLI called `accelbyte-codegen` that will be used to generate code from given config.
7
11
 
@@ -33,9 +37,11 @@ Provide swaggers url you wish to generate, store it in .json format file.
33
37
 
34
38
  ## How to Generate
35
39
 
36
- **Step 1: Set Up Your Node.js Environment** Make sure you have Node.js and npm (Node Package Manager) installed on your system. You can download and install them from the official website: https://nodejs.org/en/
40
+ **Step 1: Set Up Your Node.js Environment** Make sure you have **Node.js >= 22.18.0** (LTS) and npm (Node Package Manager) installed on your system. You can download and install them from the official website: https://nodejs.org/en/
37
41
 
38
- __*It is recommended__ to use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install Node.js so you can switch between Node versions more easily
42
+ This minimum version is required because the codegen loads `abcodegen.config.ts` at runtime using Node.js native TypeScript type stripping, which was unflagged in Node.js 22.18.0.
43
+
44
+ __*It is recommended__ to use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install Node.js so you can switch between Node versions more easily
39
45
 
40
46
  **Step 2: Create a New Node.js Project (if needed)** If you are starting a new project, create a new directory and initialize it as a Node.js project. You can do this using the following commands:
41
47
  ```
@@ -110,4 +116,44 @@ after installing, execute prettier as below
110
116
  npm exec prettier --write swaggers/*.json && prettier --write sdk/**/*
111
117
  # Or, with yarn:
112
118
  yarn prettier --write swaggers/*.json && prettier --write sdk/**/*
119
+ ```
120
+
121
+ ## Configuration
122
+
123
+ Place an `abcodegen.config.ts` file next to your `swaggers.json` to customize codegen behavior. All options are optional — if the file is absent, defaults apply.
124
+
125
+ ```typescript
126
+ // abcodegen.config.ts
127
+ export default {
128
+ // Override the base path prepended to all API routes.
129
+ // Default: uses basePath from the swagger spec.
130
+ basePath: '/custom',
131
+
132
+ // Skip generation of barrel index files (index.ts, all-query-imports.ts).
133
+ // Default: true
134
+ unstable_shouldProduceIndexFile: false,
135
+
136
+ // Force specific definitions to emit `z.any()` instead of a full schema.
137
+ // Keyed by definition file name. Value can be `true` or a function receiving the schema.
138
+ unstable_overrideAsAny: {
139
+ ProtobufAny: true,
140
+ SomeOther: (schema) => schema.properties?.['@type'] !== undefined
141
+ }
142
+ }
143
+ ```
144
+
145
+ ## Design Decisions
146
+
147
+ ### Zod definitions use `interface`, not `type`
148
+
149
+ Generated definitions use `interface Foo extends z.TypeOf<typeof Foo> {}` rather than a `type` alias. This makes editors display the object shape directly on hover instead of showing the `z.TypeOf<...>` indirection.
150
+
151
+ This triggers `@typescript-eslint/no-empty-object-type`. That rule guards against the `{}` gotcha in hand-written code, which does not apply to generated output. Consumers can disable it for generated files:
152
+
153
+ ```js
154
+ // eslint.config.js
155
+ {
156
+ files: ['src/generated-definitions/**'],
157
+ rules: { '@typescript-eslint/no-empty-object-type': 'off' }
158
+ }
113
159
  ```