strapi-typed-client 2.3.2 → 2.4.0
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 +5 -0
- package/dist/cjs/plugin/server/src/services/endpoints.js +122 -0
- package/dist/cjs/shared/json-schema-to-ts.js +155 -0
- package/dist/cli/commands/generate.d.ts +5 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +34 -7
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +1 -0
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +13 -0
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/core/schema-transformer.js +6 -0
- package/dist/core/schema-transformer.js.map +1 -1
- package/dist/generator/auth-api-generator.d.ts.map +1 -1
- package/dist/generator/auth-api-generator.js +16 -5
- package/dist/generator/auth-api-generator.js.map +1 -1
- package/dist/generator/client-generator.d.ts +3 -0
- package/dist/generator/client-generator.d.ts.map +1 -1
- package/dist/generator/client-generator.js +274 -34
- package/dist/generator/client-generator.js.map +1 -1
- package/dist/generator/index.d.ts +5 -2
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +94 -19
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/input-fields.d.ts +2 -1
- package/dist/generator/input-fields.d.ts.map +1 -1
- package/dist/generator/input-fields.js +6 -1
- package/dist/generator/input-fields.js.map +1 -1
- package/dist/generator/plugin-routes-generator.d.ts +30 -0
- package/dist/generator/plugin-routes-generator.d.ts.map +1 -0
- package/dist/generator/plugin-routes-generator.js +145 -0
- package/dist/generator/plugin-routes-generator.js.map +1 -0
- package/dist/generator/types-generator.d.ts +10 -0
- package/dist/generator/types-generator.d.ts.map +1 -1
- package/dist/generator/types-generator.js +189 -40
- package/dist/generator/types-generator.js.map +1 -1
- package/dist/generator/validation-generator.d.ts.map +1 -1
- package/dist/generator/validation-generator.js +22 -1
- package/dist/generator/validation-generator.js.map +1 -1
- package/dist/next/index.d.ts +2 -0
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +13 -4
- package/dist/next/index.js.map +1 -1
- package/dist/plugin/server/src/index.d.ts +1 -0
- package/dist/plugin/server/src/index.d.ts.map +1 -1
- package/dist/plugin/server/src/services/endpoints.d.ts +7 -0
- package/dist/plugin/server/src/services/endpoints.d.ts.map +1 -1
- package/dist/plugin/server/src/services/endpoints.js +122 -0
- package/dist/plugin/server/src/services/endpoints.js.map +1 -1
- package/dist/shared/client-header.d.ts +8 -0
- package/dist/shared/client-header.d.ts.map +1 -1
- package/dist/shared/client-header.js +17 -0
- package/dist/shared/client-header.js.map +1 -1
- package/dist/shared/json-schema-to-ts.d.ts +9 -0
- package/dist/shared/json-schema-to-ts.d.ts.map +1 -0
- package/dist/shared/json-schema-to-ts.js +152 -0
- package/dist/shared/json-schema-to-ts.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ articles[0].category.name // fully typed
|
|
|
65
65
|
- Typed API client — `find`, `findOne`, `create`, `update`, `delete`
|
|
66
66
|
- Built-in upload plugin support — `client.upload.upload/find/findOne/destroy`
|
|
67
67
|
- Built-in i18n support — `client.i18n.locales()` for the configured locales
|
|
68
|
+
- Routes of other installed plugins — `client.navigation.render('main')`, typed from the route's Zod schemas where the plugin declares them
|
|
68
69
|
- Typed errors with `isStrapiErrorOf` for discriminated narrowing
|
|
69
70
|
- Session auth (Strapi 5.43+ `jwtManagement: 'refresh'`) — auto-detected, with transparent token refresh
|
|
70
71
|
- Automatic type inference for `populate` — no manual casting, relation counts included (`{ count: true }`)
|
|
@@ -79,6 +80,10 @@ articles[0].category.name // fully typed
|
|
|
79
80
|
- Schema hashing — skips regeneration when nothing changed
|
|
80
81
|
- Framework-agnostic — works with any TypeScript project
|
|
81
82
|
|
|
83
|
+
## Split types for large schemas
|
|
84
|
+
|
|
85
|
+
`--split-types` writes one types file per collection and component category (`base.ts`, `collections/*.ts`) behind the same `types` barrel, so existing imports keep working while editor performance, diffs and CODEOWNERS get finer-grained. See [Generated types](https://boxlab-ltd.github.io/strapi-typed-client/reference/generated-types#split-types).
|
|
86
|
+
|
|
82
87
|
## Runtime validation (Zod)
|
|
83
88
|
|
|
84
89
|
Add `--validation zod` and the generator also writes `validation.ts`: a [Zod 4](https://zod.dev) schema for every create/update input, generated from the same model as the TS types, so the two can't drift. Install `zod` in your app first:
|
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const endpoint_parser_js_1 = require("./endpoint-parser.js");
|
|
43
|
+
const json_schema_to_ts_js_1 = require("../../../../shared/json-schema-to-ts.js");
|
|
43
44
|
/**
|
|
44
45
|
* Parse handler string to extract controller and action
|
|
45
46
|
* Supports both short and full Strapi handler formats:
|
|
@@ -140,6 +141,79 @@ function findControllerFile(strapiDir, apiName, controllerName) {
|
|
|
140
141
|
}
|
|
141
142
|
return null;
|
|
142
143
|
}
|
|
144
|
+
// Plugins the client already covers with its own API, and this plugin's schema route
|
|
145
|
+
const PLUGINS_WITH_OWN_API = new Set([
|
|
146
|
+
'users-permissions',
|
|
147
|
+
'upload',
|
|
148
|
+
'i18n',
|
|
149
|
+
'strapi-typed-client',
|
|
150
|
+
]);
|
|
151
|
+
const HTTP_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
152
|
+
// Mirrors Strapi's own registration: a bare array is admin-only, a router defaults to
|
|
153
|
+
// type 'admin' and prefix `/<plugin>`. Matching on `type`, not the key, catches
|
|
154
|
+
// content-api routers registered under another name.
|
|
155
|
+
function contentApiRouters(routes, pluginName) {
|
|
156
|
+
if (!routes || typeof routes !== 'object' || Array.isArray(routes))
|
|
157
|
+
return [];
|
|
158
|
+
const routers = [];
|
|
159
|
+
for (const [key, value] of Object.entries(routes)) {
|
|
160
|
+
const router = Array.isArray(value)
|
|
161
|
+
? { routes: value }
|
|
162
|
+
: value;
|
|
163
|
+
const type = router?.type ?? (key === 'content-api' ? 'content-api' : 'admin');
|
|
164
|
+
if (type !== 'content-api' || !Array.isArray(router?.routes))
|
|
165
|
+
continue;
|
|
166
|
+
routers.push({
|
|
167
|
+
prefix: router.prefix ?? `/${pluginName}`,
|
|
168
|
+
routes: router.routes,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return routers;
|
|
172
|
+
}
|
|
173
|
+
// Same precedence as Strapi: a route's own `config.prefix` (even '') beats the router's
|
|
174
|
+
function pluginRoutePath(route, routerPrefix) {
|
|
175
|
+
const prefix = route.config &&
|
|
176
|
+
Object.prototype.hasOwnProperty.call(route.config, 'prefix')
|
|
177
|
+
? (route.config.prefix ?? '')
|
|
178
|
+
: routerPrefix;
|
|
179
|
+
return (`${prefix}${route.path}`.replace(/\/+/g, '/').replace(/\/$/, '') || '/');
|
|
180
|
+
}
|
|
181
|
+
function schemaToTs(schema, io) {
|
|
182
|
+
const zod = schema;
|
|
183
|
+
if (typeof zod?.toJSONSchema !== 'function')
|
|
184
|
+
return undefined;
|
|
185
|
+
try {
|
|
186
|
+
const type = (0, json_schema_to_ts_js_1.jsonSchemaToTs)(zod.toJSONSchema({ io, unrepresentable: 'any' }));
|
|
187
|
+
return type === 'unknown' ? undefined : type;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function acceptsUndefined(schema) {
|
|
194
|
+
try {
|
|
195
|
+
return schema.safeParse?.(undefined).success === true;
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function routeSchemaTypes(route) {
|
|
202
|
+
const types = {};
|
|
203
|
+
const query = route.request?.query;
|
|
204
|
+
if (query && typeof query === 'object') {
|
|
205
|
+
const members = Object.entries(query).map(([name, schema]) => `${(0, json_schema_to_ts_js_1.safeKey)(name)}${acceptsUndefined(schema) ? '?' : ''}: ${schemaToTs(schema, 'input') ?? 'unknown'}`);
|
|
206
|
+
if (members.length > 0)
|
|
207
|
+
types.query = `{ ${members.join('; ')} }`;
|
|
208
|
+
}
|
|
209
|
+
const body = schemaToTs(route.request?.body?.['application/json'], 'input');
|
|
210
|
+
if (body)
|
|
211
|
+
types.body = body;
|
|
212
|
+
const response = schemaToTs(route.response, 'output');
|
|
213
|
+
if (response)
|
|
214
|
+
types.response = response;
|
|
215
|
+
return Object.keys(types).length > 0 ? types : undefined;
|
|
216
|
+
}
|
|
143
217
|
exports.default = ({ strapi }) => {
|
|
144
218
|
const warnLog = (message) => strapi.log.warn(message);
|
|
145
219
|
return {
|
|
@@ -316,6 +390,7 @@ exports.default = ({ strapi }) => {
|
|
|
316
390
|
strapi.log.debug(`[strapi-types] Found ${fromFiles.endpoints.length} routes from files`);
|
|
317
391
|
// Also extract plugin routes
|
|
318
392
|
this.extractPluginRoutes(fromFiles.endpoints, 'users-permissions');
|
|
393
|
+
this.extractOtherPluginRoutes(fromFiles.endpoints);
|
|
319
394
|
return {
|
|
320
395
|
endpoints: fromFiles.endpoints,
|
|
321
396
|
extraTypes: fromFiles.extraTypes,
|
|
@@ -324,6 +399,7 @@ exports.default = ({ strapi }) => {
|
|
|
324
399
|
}
|
|
325
400
|
// Even with no API routes, extract plugin routes
|
|
326
401
|
this.extractPluginRoutes(endpoints, 'users-permissions');
|
|
402
|
+
this.extractOtherPluginRoutes(endpoints);
|
|
327
403
|
if (endpoints.length > 0) {
|
|
328
404
|
const extraTypes = await this.extractExtraTypes(strapiDir);
|
|
329
405
|
return {
|
|
@@ -424,6 +500,7 @@ exports.default = ({ strapi }) => {
|
|
|
424
500
|
}
|
|
425
501
|
// Extract routes from users-permissions plugin
|
|
426
502
|
this.extractPluginRoutes(endpoints, 'users-permissions');
|
|
503
|
+
this.extractOtherPluginRoutes(endpoints);
|
|
427
504
|
// Sort endpoints by path for consistent output
|
|
428
505
|
endpoints.sort((a, b) => {
|
|
429
506
|
const pathCompare = a.path.localeCompare(b.path);
|
|
@@ -487,6 +564,51 @@ exports.default = ({ strapi }) => {
|
|
|
487
564
|
strapi.log.debug(`[strapi-types] Error extracting plugin routes for ${pluginName}: ${error}`);
|
|
488
565
|
}
|
|
489
566
|
},
|
|
567
|
+
/**
|
|
568
|
+
* Content-API routes of every other installed plugin (e.g. navigation's
|
|
569
|
+
* `/render/:idOrSlug`). The path is final — prefix already applied, hence
|
|
570
|
+
* `prefix: ''` — and the types come from the route's Zod schemas when
|
|
571
|
+
* the plugin declares them.
|
|
572
|
+
*/
|
|
573
|
+
extractOtherPluginRoutes(endpoints) {
|
|
574
|
+
for (const pluginName of Object.keys(strapi.plugins ?? {}).sort()) {
|
|
575
|
+
if (PLUGINS_WITH_OWN_API.has(pluginName))
|
|
576
|
+
continue;
|
|
577
|
+
let routers;
|
|
578
|
+
try {
|
|
579
|
+
routers = contentApiRouters(strapi.plugin(pluginName)?.routes, pluginName);
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
strapi.log.debug(`[strapi-types] Error reading routes of plugin ${pluginName}: ${error}`);
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
for (const router of routers) {
|
|
586
|
+
for (const route of router.routes) {
|
|
587
|
+
const method = String(route.method ?? '').toUpperCase();
|
|
588
|
+
if (typeof route.handler !== 'string' ||
|
|
589
|
+
typeof route.path !== 'string' ||
|
|
590
|
+
!HTTP_METHODS.has(method)) {
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
const handler = route.handler.includes('::')
|
|
594
|
+
? route.handler
|
|
595
|
+
: `plugin::${pluginName}.${route.handler}`;
|
|
596
|
+
const { controller, action } = parseHandler(handler);
|
|
597
|
+
const types = routeSchemaTypes(route);
|
|
598
|
+
endpoints.push({
|
|
599
|
+
method,
|
|
600
|
+
path: pluginRoutePath(route, router.prefix),
|
|
601
|
+
handler,
|
|
602
|
+
controller,
|
|
603
|
+
action,
|
|
604
|
+
pluginName,
|
|
605
|
+
prefix: '',
|
|
606
|
+
...(types && { types }),
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
490
612
|
/**
|
|
491
613
|
* Get endpoints for a specific API
|
|
492
614
|
*/
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* JSON Schema → TypeScript type expression, for the request/response schemas
|
|
4
|
+
* Strapi routes carry (Zod 4, converted with `toJSONSchema`). Covers the subset
|
|
5
|
+
* Zod emits; anything it can't express precisely degrades to `unknown`.
|
|
6
|
+
* Deterministic: the output follows the schema's own key and member order.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.jsonSchemaToTs = jsonSchemaToTs;
|
|
10
|
+
exports.safeKey = safeKey;
|
|
11
|
+
const isSchema = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
12
|
+
function jsonSchemaToTs(schema) {
|
|
13
|
+
const root = isSchema(schema) ? schema : {};
|
|
14
|
+
const defs = {
|
|
15
|
+
...(isSchema(root.definitions) ? root.definitions : {}),
|
|
16
|
+
...(isSchema(root.$defs) ? root.$defs : {}),
|
|
17
|
+
};
|
|
18
|
+
return convert(schema, defs, new Set());
|
|
19
|
+
}
|
|
20
|
+
function convert(schema, defs, seen) {
|
|
21
|
+
if (schema === false)
|
|
22
|
+
return 'never';
|
|
23
|
+
if (!isSchema(schema))
|
|
24
|
+
return 'unknown';
|
|
25
|
+
const next = (s) => convert(s, defs, seen);
|
|
26
|
+
if (typeof schema.$ref === 'string') {
|
|
27
|
+
const match = /^#\/(?:\$defs|definitions)\/(.+)$/.exec(schema.$ref);
|
|
28
|
+
const name = match?.[1]?.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
29
|
+
// A recursive schema can't be inlined into one expression
|
|
30
|
+
if (!name || seen.has(name) || !(name in defs))
|
|
31
|
+
return 'unknown';
|
|
32
|
+
return convert(defs[name], defs, new Set([...seen, name]));
|
|
33
|
+
}
|
|
34
|
+
let type;
|
|
35
|
+
if ('const' in schema)
|
|
36
|
+
type = literal(schema.const);
|
|
37
|
+
else if (Array.isArray(schema.enum))
|
|
38
|
+
type = union(schema.enum.map(literal));
|
|
39
|
+
else if (Array.isArray(schema.anyOf))
|
|
40
|
+
type = union(schema.anyOf.map(next));
|
|
41
|
+
else if (Array.isArray(schema.oneOf))
|
|
42
|
+
type = union(schema.oneOf.map(next));
|
|
43
|
+
else if (Array.isArray(schema.allOf))
|
|
44
|
+
type = intersection(schema.allOf.map(next));
|
|
45
|
+
else if (Array.isArray(schema.type))
|
|
46
|
+
type = union(schema.type.map(t => fromType(String(t), schema, defs, seen)));
|
|
47
|
+
else if (typeof schema.type === 'string')
|
|
48
|
+
type = fromType(schema.type, schema, defs, seen);
|
|
49
|
+
else if (isSchema(schema.properties) || 'additionalProperties' in schema)
|
|
50
|
+
type = fromType('object', schema, defs, seen);
|
|
51
|
+
else if ('items' in schema || Array.isArray(schema.prefixItems))
|
|
52
|
+
type = fromType('array', schema, defs, seen);
|
|
53
|
+
else
|
|
54
|
+
type = 'unknown';
|
|
55
|
+
// OpenAPI 3.0 style
|
|
56
|
+
return schema.nullable === true ? union([type, 'null']) : type;
|
|
57
|
+
}
|
|
58
|
+
function fromType(type, schema, defs, seen) {
|
|
59
|
+
const next = (s) => convert(s, defs, seen);
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'string':
|
|
62
|
+
return 'string';
|
|
63
|
+
case 'number':
|
|
64
|
+
case 'integer':
|
|
65
|
+
return 'number';
|
|
66
|
+
case 'boolean':
|
|
67
|
+
return 'boolean';
|
|
68
|
+
case 'null':
|
|
69
|
+
return 'null';
|
|
70
|
+
case 'array': {
|
|
71
|
+
if (Array.isArray(schema.prefixItems)) {
|
|
72
|
+
const items = schema.prefixItems.map(next);
|
|
73
|
+
const rest = 'items' in schema && schema.items !== false
|
|
74
|
+
? [`...${arrayOf(next(schema.items))}`]
|
|
75
|
+
: [];
|
|
76
|
+
return `[${[...items, ...rest].join(', ')}]`;
|
|
77
|
+
}
|
|
78
|
+
return arrayOf('items' in schema ? next(schema.items) : 'unknown');
|
|
79
|
+
}
|
|
80
|
+
case 'object': {
|
|
81
|
+
const properties = isSchema(schema.properties)
|
|
82
|
+
? Object.entries(schema.properties)
|
|
83
|
+
: [];
|
|
84
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required : []);
|
|
85
|
+
const extra = schema.additionalProperties;
|
|
86
|
+
const extraType = extra === undefined || extra === true
|
|
87
|
+
? properties.length > 0 && extra === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: 'unknown'
|
|
90
|
+
: extra === false
|
|
91
|
+
? undefined
|
|
92
|
+
: next(extra);
|
|
93
|
+
if (properties.length === 0) {
|
|
94
|
+
return extraType === undefined
|
|
95
|
+
? 'Record<string, never>'
|
|
96
|
+
: `Record<string, ${extraType}>`;
|
|
97
|
+
}
|
|
98
|
+
const members = properties.map(([key, value]) => `${safeKey(key)}${required.has(key) ? '' : '?'}: ${next(value)}`);
|
|
99
|
+
// An index signature must admit every declared property type
|
|
100
|
+
if (extraType !== undefined)
|
|
101
|
+
members.push('[key: string]: unknown');
|
|
102
|
+
return `{ ${members.join('; ')} }`;
|
|
103
|
+
}
|
|
104
|
+
default:
|
|
105
|
+
return 'unknown';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function literal(value) {
|
|
109
|
+
return value === undefined ? 'undefined' : JSON.stringify(value);
|
|
110
|
+
}
|
|
111
|
+
function union(members) {
|
|
112
|
+
const unique = [...new Set(members)];
|
|
113
|
+
if (unique.includes('unknown'))
|
|
114
|
+
return 'unknown';
|
|
115
|
+
if (unique.length === 0)
|
|
116
|
+
return 'never';
|
|
117
|
+
return unique.join(' | ');
|
|
118
|
+
}
|
|
119
|
+
function intersection(members) {
|
|
120
|
+
const unique = [...new Set(members)].filter(m => m !== 'unknown');
|
|
121
|
+
if (unique.length === 0)
|
|
122
|
+
return 'unknown';
|
|
123
|
+
return unique.map(m => (hasTopLevel(m, '|') ? `(${m})` : m)).join(' & ');
|
|
124
|
+
}
|
|
125
|
+
function arrayOf(element) {
|
|
126
|
+
return hasTopLevel(element, '|') || hasTopLevel(element, '&')
|
|
127
|
+
? `(${element})[]`
|
|
128
|
+
: `${element}[]`;
|
|
129
|
+
}
|
|
130
|
+
// Whether `op` appears outside any brackets or string literals
|
|
131
|
+
function hasTopLevel(type, op) {
|
|
132
|
+
let depth = 0;
|
|
133
|
+
let quote = null;
|
|
134
|
+
for (let i = 0; i < type.length; i++) {
|
|
135
|
+
const ch = type[i];
|
|
136
|
+
if (quote) {
|
|
137
|
+
if (ch === '\\')
|
|
138
|
+
i++;
|
|
139
|
+
else if (ch === quote)
|
|
140
|
+
quote = null;
|
|
141
|
+
}
|
|
142
|
+
else if (ch === '"' || ch === "'")
|
|
143
|
+
quote = ch;
|
|
144
|
+
else if ('{[(<'.includes(ch))
|
|
145
|
+
depth++;
|
|
146
|
+
else if ('}])>'.includes(ch))
|
|
147
|
+
depth--;
|
|
148
|
+
else if (ch === op && depth === 0)
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
function safeKey(name) {
|
|
154
|
+
return /^[A-Za-z_$][\w$]*$/.test(name) ? name : JSON.stringify(name);
|
|
155
|
+
}
|
|
@@ -12,6 +12,8 @@ export interface GenerateOptions {
|
|
|
12
12
|
format?: 'js' | 'ts';
|
|
13
13
|
typecheck?: boolean;
|
|
14
14
|
validation?: ValidationMode;
|
|
15
|
+
/** Split types into per-collection files. Defaults to the layout already in --output, else a single file. */
|
|
16
|
+
splitTypes?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export interface GenerateResult {
|
|
17
19
|
success: boolean;
|
|
@@ -34,9 +36,11 @@ export declare function isGeneratedOutputFresh(params: {
|
|
|
34
36
|
allFilesExist: boolean;
|
|
35
37
|
localValidation?: ValidationMode | null;
|
|
36
38
|
validation?: ValidationMode;
|
|
39
|
+
localSplitTypes?: boolean;
|
|
40
|
+
splitTypes?: boolean;
|
|
37
41
|
}): boolean;
|
|
38
42
|
/** Files a generation in this format and validation mode leaves in the output dir. */
|
|
39
|
-
export declare function generatedFileNames(format: 'js' | 'ts', validation: ValidationMode): string[];
|
|
43
|
+
export declare function generatedFileNames(format: 'js' | 'ts', validation: ValidationMode, splitTypes?: boolean): string[];
|
|
40
44
|
/**
|
|
41
45
|
* Generate types from Strapi API
|
|
42
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUxC,OAAO,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUxC,OAAO,EAMH,KAAK,cAAc,EACtB,MAAM,+BAA+B,CAAA;AAGtC,MAAM,WAAW,eAAe;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,6GAA6G;IAC7G,UAAU,CAAC,EAAE,OAAO,CAAA;CACvB;AAID,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACvC,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,OAAO,CAWV;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,UAAU,EAAE,cAAc,EAC1B,UAAU,UAAQ,GACnB,MAAM,EAAE,CAoBV;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC1B,OAAO,EAAE,eAAe,GACzB,OAAO,CAAC,cAAc,CAAC,CA2MzB;AAeD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqF5D;AAED,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAC1B,KAAK,IAAI,cAAc,GAAG,SAAS,CAErC"}
|
|
@@ -6,7 +6,7 @@ import * as path from 'path';
|
|
|
6
6
|
import { createApiClient } from '../utils/api-client.js';
|
|
7
7
|
import { readLocalSchemaHash, readLocalGeneratorVersion, requireOutputDir, isInsideNodeModules, assertOutputDirForFormat, } from '../utils/file-writer.js';
|
|
8
8
|
import { transformSchema } from '../../core/schema-transformer.js';
|
|
9
|
-
import { detectOutputFormat, hasMixedFormatOutput, readValidationMode, validationFileNames, } from '../../shared/client-header.js';
|
|
9
|
+
import { detectOutputFormat, hasMixedFormatOutput, readValidationMode, isSplitTypesOutput, validationFileNames, } from '../../shared/client-header.js';
|
|
10
10
|
import { getGeneratorVersion } from '../../shared/version.js';
|
|
11
11
|
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
12
12
|
/**
|
|
@@ -26,10 +26,12 @@ export function isGeneratedOutputFresh(params) {
|
|
|
26
26
|
if ((params.localValidation ?? 'none') !== (params.validation ?? 'none')) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
|
+
if (!!params.localSplitTypes !== !!params.splitTypes)
|
|
30
|
+
return false;
|
|
29
31
|
return true;
|
|
30
32
|
}
|
|
31
33
|
/** Files a generation in this format and validation mode leaves in the output dir. */
|
|
32
|
-
export function generatedFileNames(format, validation) {
|
|
34
|
+
export function generatedFileNames(format, validation, splitTypes = false) {
|
|
33
35
|
const base = format === 'ts'
|
|
34
36
|
? ['types.ts', 'client.ts', 'index.ts']
|
|
35
37
|
: [
|
|
@@ -40,9 +42,14 @@ export function generatedFileNames(format, validation) {
|
|
|
40
42
|
'index.js',
|
|
41
43
|
'index.d.ts',
|
|
42
44
|
];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// Per-collection files depend on the schema, so only the fixed ones are listed
|
|
46
|
+
const split = splitTypes
|
|
47
|
+
? format === 'ts'
|
|
48
|
+
? ['base.ts']
|
|
49
|
+
: ['base.js', 'base.d.ts']
|
|
50
|
+
: [];
|
|
51
|
+
const all = [...base, ...split];
|
|
52
|
+
return validation === 'zod' ? [...all, ...validationFileNames(format)] : all;
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
48
55
|
* Generate types from Strapi API
|
|
@@ -55,6 +62,8 @@ export async function generate(options) {
|
|
|
55
62
|
assertOutputDirForFormat(outputDir, format);
|
|
56
63
|
const localValidation = readValidationMode(outputDir);
|
|
57
64
|
const validation = options.validation ?? localValidation ?? 'none';
|
|
65
|
+
const localSplitTypes = isSplitTypesOutput(outputDir);
|
|
66
|
+
const splitTypes = options.splitTypes ?? localSplitTypes;
|
|
58
67
|
if (!options.silent && hasMixedFormatOutput(outputDir)) {
|
|
59
68
|
console.log(dim(`Both .ts and .js clients found in ${outputDir} — regenerating as ${format}.\n` +
|
|
60
69
|
'Delete the other format once nothing imports it.'));
|
|
@@ -71,7 +80,7 @@ export async function generate(options) {
|
|
|
71
80
|
const localVersion = readLocalGeneratorVersion(outputDir);
|
|
72
81
|
const cliVersion = getGeneratorVersion();
|
|
73
82
|
// Verify generated files actually exist (they may be lost after package update)
|
|
74
|
-
const generatedFiles = generatedFileNames(format, validation).map(f => path.join(outputDir, f));
|
|
83
|
+
const generatedFiles = generatedFileNames(format, validation, splitTypes).map(f => path.join(outputDir, f));
|
|
75
84
|
const allFilesExist = generatedFiles.every(f => fs.existsSync(f));
|
|
76
85
|
if (localHash && allFilesExist) {
|
|
77
86
|
if (!options.silent) {
|
|
@@ -87,6 +96,8 @@ export async function generate(options) {
|
|
|
87
96
|
allFilesExist,
|
|
88
97
|
localValidation,
|
|
89
98
|
validation,
|
|
99
|
+
localSplitTypes,
|
|
100
|
+
splitTypes,
|
|
90
101
|
})) {
|
|
91
102
|
if (!options.silent) {
|
|
92
103
|
console.log(`Types are up to date (hash: ${localHash.substring(0, 8)}...)`);
|
|
@@ -102,6 +113,10 @@ export async function generate(options) {
|
|
|
102
113
|
if (localHash !== remoteHash) {
|
|
103
114
|
console.log(`Schema changed (${localHash.substring(0, 8)}... -> ${remoteHash.substring(0, 8)}...)`);
|
|
104
115
|
}
|
|
116
|
+
else if (localVersion === cliVersion &&
|
|
117
|
+
localSplitTypes !== splitTypes) {
|
|
118
|
+
console.log(`Types layout changed (${localSplitTypes ? 'split' : 'single file'} -> ${splitTypes ? 'split' : 'single file'}), regenerating...`);
|
|
119
|
+
}
|
|
105
120
|
else if (localVersion === cliVersion) {
|
|
106
121
|
console.log(`Validation changed (${localValidation ?? 'none'} -> ${validation}), regenerating...`);
|
|
107
122
|
}
|
|
@@ -161,8 +176,9 @@ export async function generate(options) {
|
|
|
161
176
|
typecheck: options.typecheck ?? true,
|
|
162
177
|
authMode: authMode ?? 'legacy',
|
|
163
178
|
validation,
|
|
179
|
+
splitTypes,
|
|
164
180
|
});
|
|
165
|
-
for (const f of generatedFileNames(format, validation)) {
|
|
181
|
+
for (const f of generatedFileNames(format, validation, splitTypes)) {
|
|
166
182
|
filesWritten.push(path.join(outputDir, f));
|
|
167
183
|
}
|
|
168
184
|
if (!options.silent && isInsideNodeModules(outputDir)) {
|
|
@@ -199,7 +215,13 @@ export function createGenerateCommand(program) {
|
|
|
199
215
|
.option('--format <js|ts>', 'Output format: js (compiled .js + .d.ts) or ts (raw .ts for monorepo/source-tree output). Defaults to the format already in --output, else js')
|
|
200
216
|
.option('--no-typecheck', 'Write the generated client even if it fails type-checking (escape hatch for strict-only false positives)')
|
|
201
217
|
.option('--validation <zod|none>', 'Also generate Zod validators for create/update inputs (needs zod 4 installed). Defaults to the mode already in --output, else none')
|
|
218
|
+
.option('--split-types', 'Write one types file per collection and component category (base.ts + collections/) instead of a single types.ts. Defaults to the layout already in --output')
|
|
219
|
+
.option('--single-file', 'Write a single types.ts (undo --split-types)')
|
|
202
220
|
.action(async (opts) => {
|
|
221
|
+
if (opts.splitTypes && opts.singleFile) {
|
|
222
|
+
console.error('--split-types and --single-file cannot be used together.');
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
203
225
|
if (opts.format && opts.format !== 'js' && opts.format !== 'ts') {
|
|
204
226
|
console.error(`Invalid --format value: ${opts.format}. Expected 'js' or 'ts'.`);
|
|
205
227
|
process.exit(1);
|
|
@@ -217,6 +239,11 @@ export function createGenerateCommand(program) {
|
|
|
217
239
|
format: opts.format,
|
|
218
240
|
typecheck: opts.typecheck,
|
|
219
241
|
validation: opts.validation,
|
|
242
|
+
splitTypes: opts.splitTypes
|
|
243
|
+
? true
|
|
244
|
+
: opts.singleFile
|
|
245
|
+
? false
|
|
246
|
+
: undefined,
|
|
220
247
|
});
|
|
221
248
|
if (!result.success) {
|
|
222
249
|
console.error('Generation failed:', result.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GAEtB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GAEtB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAe7D,MAAM,GAAG,GA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AAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/watch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEnE,MAAM,WAAW,YAAY;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgHhE;AAkBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4EzD"}
|
|
@@ -35,6 +35,7 @@ export async function watch(options) {
|
|
|
35
35
|
format: options.format,
|
|
36
36
|
typecheck: options.typecheck,
|
|
37
37
|
validation: options.validation,
|
|
38
|
+
splitTypes: options.splitTypes,
|
|
38
39
|
});
|
|
39
40
|
if (!initial.success) {
|
|
40
41
|
console.error('Failed to generate types:', initial.error);
|
|
@@ -65,6 +66,7 @@ export async function watch(options) {
|
|
|
65
66
|
format: options.format,
|
|
66
67
|
typecheck: options.typecheck,
|
|
67
68
|
validation: options.validation,
|
|
69
|
+
splitTypes: options.splitTypes,
|
|
68
70
|
});
|
|
69
71
|
if (result.success) {
|
|
70
72
|
console.log('Types regenerated successfully.\n');
|
|
@@ -114,7 +116,13 @@ export function createWatchCommand(program) {
|
|
|
114
116
|
.option('--format <js|ts>', 'Output format: js (compiled .js + .d.ts) or ts (raw .ts for monorepo/source-tree output). Defaults to the format already in --output, else js')
|
|
115
117
|
.option('--no-typecheck', 'Write regenerated types even if they fail type-checking (escape hatch for strict-only false positives)')
|
|
116
118
|
.option('--validation <zod|none>', 'Also generate Zod validators for create/update inputs (needs zod 4 installed). Defaults to the mode already in --output, else none')
|
|
119
|
+
.option('--split-types', 'Write one types file per collection and component category instead of a single types.ts. Defaults to the layout already in --output')
|
|
120
|
+
.option('--single-file', 'Write a single types.ts (undo --split-types)')
|
|
117
121
|
.action(async (opts) => {
|
|
122
|
+
if (opts.splitTypes && opts.singleFile) {
|
|
123
|
+
console.error('--split-types and --single-file cannot be used together.');
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
118
126
|
if (opts.format && opts.format !== 'js' && opts.format !== 'ts') {
|
|
119
127
|
console.error(`Invalid --format value: ${opts.format}. Expected 'js' or 'ts'.`);
|
|
120
128
|
process.exit(1);
|
|
@@ -132,6 +140,11 @@ export function createWatchCommand(program) {
|
|
|
132
140
|
format: opts.format,
|
|
133
141
|
typecheck: opts.typecheck,
|
|
134
142
|
validation: opts.validation,
|
|
143
|
+
splitTypes: opts.splitTypes
|
|
144
|
+
? true
|
|
145
|
+
: opts.singleFile
|
|
146
|
+
? false
|
|
147
|
+
: undefined,
|
|
135
148
|
});
|
|
136
149
|
}
|
|
137
150
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../../src/cli/commands/watch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,E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CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC9D,OAAO,CAAC,KAAK,CACT,2BAA2B,IAAI,CAAC,MAAM,0BAA0B,CACnE,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,KAAK,CACT,+BAA+B,IAAI,CAAC,UAAU,6BAA6B,CAC9E,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;QAED,IAAI,CAAC;YACD,MAAM,KAAK,CAAC;gBACR,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAiC;gBAC9C,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;oBACvB,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,IAAI,CAAC,UAAU;wBACf,CAAC,CAAC,KAAK;wBACP,CAAC,CAAC,SAAS;aACpB,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAE,GAAa,CAAC,OAAO,CAAC,CAAA;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -303,12 +303,18 @@ function normalizeRelationType(relation) {
|
|
|
303
303
|
const normalized = relation.toLowerCase().replace(/[^a-z]/g, '');
|
|
304
304
|
switch (normalized) {
|
|
305
305
|
case 'onetoone':
|
|
306
|
+
case 'oneway':
|
|
307
|
+
case 'morphtoone':
|
|
308
|
+
case 'morphone':
|
|
306
309
|
return 'oneToOne';
|
|
307
310
|
case 'onetomany':
|
|
308
311
|
return 'oneToMany';
|
|
309
312
|
case 'manytoone':
|
|
310
313
|
return 'manyToOne';
|
|
311
314
|
case 'manytomany':
|
|
315
|
+
case 'manyway':
|
|
316
|
+
case 'morphtomany':
|
|
317
|
+
case 'morphmany':
|
|
312
318
|
return 'manyToMany';
|
|
313
319
|
default:
|
|
314
320
|
// Default to manyToOne for unknown relation types
|