axigen 1.2.4 → 1.2.5
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/dist/cli/index.mjs +65 -56
- package/dist/index.js +65 -56
- package/dist/index.mjs +65 -56
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -282,87 +282,96 @@ ${closePad}}`;
|
|
|
282
282
|
}
|
|
283
283
|
function refToTypeName(ref) {
|
|
284
284
|
const parts = ref.split("/");
|
|
285
|
-
|
|
285
|
+
const raw = parts[parts.length - 1] ?? "unknown";
|
|
286
|
+
return toPascalCase(raw);
|
|
287
|
+
}
|
|
288
|
+
function toPascalCase(name) {
|
|
289
|
+
return name.split(/[-_]/).map((part) => part.length === 0 ? "" : part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
290
|
+
}
|
|
291
|
+
function registerType(registry, name, declaration, section) {
|
|
292
|
+
if (registry.has(name)) return;
|
|
293
|
+
registry.set(name, { declaration, section });
|
|
286
294
|
}
|
|
287
295
|
function generateTypesFile(endpoints, schemas = {}) {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
lines.push("");
|
|
296
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
297
|
-
if (schema.description) {
|
|
298
|
-
lines.push(`/** ${schema.description} */`);
|
|
299
|
-
}
|
|
300
|
-
lines.push(`export type ${name} = ${schemaToTSType(schema)}`);
|
|
301
|
-
lines.push("");
|
|
302
|
-
}
|
|
296
|
+
const registry = /* @__PURE__ */ new Map();
|
|
297
|
+
for (const [rawName, schema] of Object.entries(schemas)) {
|
|
298
|
+
const name = toPascalCase(rawName);
|
|
299
|
+
const jsDoc = schema.description ? `/** ${schema.description} */
|
|
300
|
+
` : "";
|
|
301
|
+
const declaration = `${jsDoc}export type ${name} = ${schemaToTSType(schema)}`;
|
|
302
|
+
registerType(registry, name, declaration, "component");
|
|
303
303
|
}
|
|
304
|
-
const endpointLines = [];
|
|
305
304
|
for (const ep of endpoints) {
|
|
306
305
|
const baseName = operationToTypeName(ep.operationId);
|
|
307
306
|
if (ep.pathParams.length > 0) {
|
|
308
|
-
|
|
309
|
-
for (const p of ep.pathParams) {
|
|
310
|
-
const type = schemaToTSType(p.schema);
|
|
307
|
+
const fields = ep.pathParams.map((p) => {
|
|
311
308
|
const comment = p.description ? ` /** ${p.description} */
|
|
312
309
|
` : "";
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
310
|
+
return `${comment} ${p.name}: ${schemaToTSType(p.schema)}`;
|
|
311
|
+
}).join("\n");
|
|
312
|
+
registerType(registry, `${baseName}PathParams`, `export interface ${baseName}PathParams {
|
|
313
|
+
${fields}
|
|
314
|
+
}`, "endpoint");
|
|
317
315
|
}
|
|
318
316
|
if (ep.queryParams.length > 0) {
|
|
319
|
-
|
|
320
|
-
for (const p of ep.queryParams) {
|
|
317
|
+
const fields = ep.queryParams.map((p) => {
|
|
321
318
|
const optional = !p.required ? "?" : "";
|
|
322
|
-
const type = schemaToTSType(p.schema);
|
|
323
319
|
const comment = p.description ? ` /** ${p.description} */
|
|
324
320
|
` : "";
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
321
|
+
return `${comment} ${p.name}${optional}: ${schemaToTSType(p.schema)}`;
|
|
322
|
+
}).join("\n");
|
|
323
|
+
registerType(registry, `${baseName}QueryParams`, `export interface ${baseName}QueryParams {
|
|
324
|
+
${fields}
|
|
325
|
+
}`, "endpoint");
|
|
329
326
|
}
|
|
330
327
|
if (ep.bodySchema) {
|
|
331
|
-
|
|
332
|
-
if (refName && declaredInComponents.has(refName)) {
|
|
333
|
-
if (`${baseName}Body` !== refName) {
|
|
334
|
-
endpointLines.push(`export type ${baseName}Body = ${refName}`);
|
|
335
|
-
endpointLines.push("");
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
endpointLines.push(`export type ${baseName}Body = ${schemaToTSType(ep.bodySchema)}`);
|
|
339
|
-
endpointLines.push("");
|
|
340
|
-
}
|
|
328
|
+
collectSchemaType(registry, ep.bodySchema, `${baseName}Body`);
|
|
341
329
|
}
|
|
342
330
|
if (ep.responseSchema) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
331
|
+
collectSchemaType(registry, ep.responseSchema, `${baseName}Response`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return emitRegistry(registry);
|
|
335
|
+
}
|
|
336
|
+
function collectSchemaType(registry, schema, aliasName) {
|
|
337
|
+
const refName = schema.$ref ? refToTypeName(schema.$ref) : void 0;
|
|
338
|
+
if (refName) {
|
|
339
|
+
if (registry.has(refName)) {
|
|
340
|
+
if (aliasName !== refName) {
|
|
341
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
352
342
|
}
|
|
343
|
+
} else {
|
|
344
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${schemaToTSType(schema)}`, "endpoint");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function emitRegistry(registry) {
|
|
351
|
+
const lines = [];
|
|
352
|
+
lines.push(`// This file is auto-generated by axigen. DO NOT EDIT.`);
|
|
353
|
+
lines.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
354
|
+
lines.push("");
|
|
355
|
+
const componentEntries = [...registry.values()].filter((e) => e.section === "component");
|
|
356
|
+
const endpointEntries = [...registry.values()].filter((e) => e.section === "endpoint");
|
|
357
|
+
if (componentEntries.length > 0) {
|
|
358
|
+
lines.push("// \u2500\u2500\u2500 Component Schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
359
|
+
lines.push("");
|
|
360
|
+
for (const entry of componentEntries) {
|
|
361
|
+
lines.push(entry.declaration);
|
|
362
|
+
lines.push("");
|
|
353
363
|
}
|
|
354
364
|
}
|
|
355
|
-
if (
|
|
365
|
+
if (endpointEntries.length > 0) {
|
|
356
366
|
lines.push("// \u2500\u2500\u2500 Endpoint Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
357
367
|
lines.push("");
|
|
358
|
-
|
|
368
|
+
for (const entry of endpointEntries) {
|
|
369
|
+
lines.push(entry.declaration);
|
|
370
|
+
lines.push("");
|
|
371
|
+
}
|
|
359
372
|
}
|
|
360
373
|
return lines.join("\n");
|
|
361
374
|
}
|
|
362
|
-
function getRefName(schema) {
|
|
363
|
-
if (schema.$ref) return refToTypeName(schema.$ref);
|
|
364
|
-
return void 0;
|
|
365
|
-
}
|
|
366
375
|
function operationToTypeName(operationId) {
|
|
367
376
|
return operationId.charAt(0).toUpperCase() + operationId.slice(1);
|
|
368
377
|
}
|
package/dist/index.js
CHANGED
|
@@ -208,87 +208,96 @@ ${closePad}}`;
|
|
|
208
208
|
}
|
|
209
209
|
function refToTypeName(ref) {
|
|
210
210
|
const parts = ref.split("/");
|
|
211
|
-
|
|
211
|
+
const raw = parts[parts.length - 1] ?? "unknown";
|
|
212
|
+
return toPascalCase(raw);
|
|
213
|
+
}
|
|
214
|
+
function toPascalCase(name) {
|
|
215
|
+
return name.split(/[-_]/).map((part) => part.length === 0 ? "" : part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
216
|
+
}
|
|
217
|
+
function registerType(registry, name, declaration, section) {
|
|
218
|
+
if (registry.has(name)) return;
|
|
219
|
+
registry.set(name, { declaration, section });
|
|
212
220
|
}
|
|
213
221
|
function generateTypesFile(endpoints, schemas = {}) {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
lines.push("");
|
|
222
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
223
|
-
if (schema.description) {
|
|
224
|
-
lines.push(`/** ${schema.description} */`);
|
|
225
|
-
}
|
|
226
|
-
lines.push(`export type ${name} = ${schemaToTSType(schema)}`);
|
|
227
|
-
lines.push("");
|
|
228
|
-
}
|
|
222
|
+
const registry = /* @__PURE__ */ new Map();
|
|
223
|
+
for (const [rawName, schema] of Object.entries(schemas)) {
|
|
224
|
+
const name = toPascalCase(rawName);
|
|
225
|
+
const jsDoc = schema.description ? `/** ${schema.description} */
|
|
226
|
+
` : "";
|
|
227
|
+
const declaration = `${jsDoc}export type ${name} = ${schemaToTSType(schema)}`;
|
|
228
|
+
registerType(registry, name, declaration, "component");
|
|
229
229
|
}
|
|
230
|
-
const endpointLines = [];
|
|
231
230
|
for (const ep of endpoints) {
|
|
232
231
|
const baseName = operationToTypeName(ep.operationId);
|
|
233
232
|
if (ep.pathParams.length > 0) {
|
|
234
|
-
|
|
235
|
-
for (const p of ep.pathParams) {
|
|
236
|
-
const type = schemaToTSType(p.schema);
|
|
233
|
+
const fields = ep.pathParams.map((p) => {
|
|
237
234
|
const comment = p.description ? ` /** ${p.description} */
|
|
238
235
|
` : "";
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
return `${comment} ${p.name}: ${schemaToTSType(p.schema)}`;
|
|
237
|
+
}).join("\n");
|
|
238
|
+
registerType(registry, `${baseName}PathParams`, `export interface ${baseName}PathParams {
|
|
239
|
+
${fields}
|
|
240
|
+
}`, "endpoint");
|
|
243
241
|
}
|
|
244
242
|
if (ep.queryParams.length > 0) {
|
|
245
|
-
|
|
246
|
-
for (const p of ep.queryParams) {
|
|
243
|
+
const fields = ep.queryParams.map((p) => {
|
|
247
244
|
const optional = !p.required ? "?" : "";
|
|
248
|
-
const type = schemaToTSType(p.schema);
|
|
249
245
|
const comment = p.description ? ` /** ${p.description} */
|
|
250
246
|
` : "";
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
247
|
+
return `${comment} ${p.name}${optional}: ${schemaToTSType(p.schema)}`;
|
|
248
|
+
}).join("\n");
|
|
249
|
+
registerType(registry, `${baseName}QueryParams`, `export interface ${baseName}QueryParams {
|
|
250
|
+
${fields}
|
|
251
|
+
}`, "endpoint");
|
|
255
252
|
}
|
|
256
253
|
if (ep.bodySchema) {
|
|
257
|
-
|
|
258
|
-
if (refName && declaredInComponents.has(refName)) {
|
|
259
|
-
if (`${baseName}Body` !== refName) {
|
|
260
|
-
endpointLines.push(`export type ${baseName}Body = ${refName}`);
|
|
261
|
-
endpointLines.push("");
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
endpointLines.push(`export type ${baseName}Body = ${schemaToTSType(ep.bodySchema)}`);
|
|
265
|
-
endpointLines.push("");
|
|
266
|
-
}
|
|
254
|
+
collectSchemaType(registry, ep.bodySchema, `${baseName}Body`);
|
|
267
255
|
}
|
|
268
256
|
if (ep.responseSchema) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
257
|
+
collectSchemaType(registry, ep.responseSchema, `${baseName}Response`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return emitRegistry(registry);
|
|
261
|
+
}
|
|
262
|
+
function collectSchemaType(registry, schema, aliasName) {
|
|
263
|
+
const refName = schema.$ref ? refToTypeName(schema.$ref) : void 0;
|
|
264
|
+
if (refName) {
|
|
265
|
+
if (registry.has(refName)) {
|
|
266
|
+
if (aliasName !== refName) {
|
|
267
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
278
268
|
}
|
|
269
|
+
} else {
|
|
270
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${schemaToTSType(schema)}`, "endpoint");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function emitRegistry(registry) {
|
|
277
|
+
const lines = [];
|
|
278
|
+
lines.push(`// This file is auto-generated by axigen. DO NOT EDIT.`);
|
|
279
|
+
lines.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
280
|
+
lines.push("");
|
|
281
|
+
const componentEntries = [...registry.values()].filter((e) => e.section === "component");
|
|
282
|
+
const endpointEntries = [...registry.values()].filter((e) => e.section === "endpoint");
|
|
283
|
+
if (componentEntries.length > 0) {
|
|
284
|
+
lines.push("// \u2500\u2500\u2500 Component Schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
285
|
+
lines.push("");
|
|
286
|
+
for (const entry of componentEntries) {
|
|
287
|
+
lines.push(entry.declaration);
|
|
288
|
+
lines.push("");
|
|
279
289
|
}
|
|
280
290
|
}
|
|
281
|
-
if (
|
|
291
|
+
if (endpointEntries.length > 0) {
|
|
282
292
|
lines.push("// \u2500\u2500\u2500 Endpoint Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
283
293
|
lines.push("");
|
|
284
|
-
|
|
294
|
+
for (const entry of endpointEntries) {
|
|
295
|
+
lines.push(entry.declaration);
|
|
296
|
+
lines.push("");
|
|
297
|
+
}
|
|
285
298
|
}
|
|
286
299
|
return lines.join("\n");
|
|
287
300
|
}
|
|
288
|
-
function getRefName(schema) {
|
|
289
|
-
if (schema.$ref) return refToTypeName(schema.$ref);
|
|
290
|
-
return void 0;
|
|
291
|
-
}
|
|
292
301
|
function operationToTypeName(operationId) {
|
|
293
302
|
return operationId.charAt(0).toUpperCase() + operationId.slice(1);
|
|
294
303
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -167,87 +167,96 @@ ${closePad}}`;
|
|
|
167
167
|
}
|
|
168
168
|
function refToTypeName(ref) {
|
|
169
169
|
const parts = ref.split("/");
|
|
170
|
-
|
|
170
|
+
const raw = parts[parts.length - 1] ?? "unknown";
|
|
171
|
+
return toPascalCase(raw);
|
|
172
|
+
}
|
|
173
|
+
function toPascalCase(name) {
|
|
174
|
+
return name.split(/[-_]/).map((part) => part.length === 0 ? "" : part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
175
|
+
}
|
|
176
|
+
function registerType(registry, name, declaration, section) {
|
|
177
|
+
if (registry.has(name)) return;
|
|
178
|
+
registry.set(name, { declaration, section });
|
|
171
179
|
}
|
|
172
180
|
function generateTypesFile(endpoints, schemas = {}) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
lines.push("");
|
|
181
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
182
|
-
if (schema.description) {
|
|
183
|
-
lines.push(`/** ${schema.description} */`);
|
|
184
|
-
}
|
|
185
|
-
lines.push(`export type ${name} = ${schemaToTSType(schema)}`);
|
|
186
|
-
lines.push("");
|
|
187
|
-
}
|
|
181
|
+
const registry = /* @__PURE__ */ new Map();
|
|
182
|
+
for (const [rawName, schema] of Object.entries(schemas)) {
|
|
183
|
+
const name = toPascalCase(rawName);
|
|
184
|
+
const jsDoc = schema.description ? `/** ${schema.description} */
|
|
185
|
+
` : "";
|
|
186
|
+
const declaration = `${jsDoc}export type ${name} = ${schemaToTSType(schema)}`;
|
|
187
|
+
registerType(registry, name, declaration, "component");
|
|
188
188
|
}
|
|
189
|
-
const endpointLines = [];
|
|
190
189
|
for (const ep of endpoints) {
|
|
191
190
|
const baseName = operationToTypeName(ep.operationId);
|
|
192
191
|
if (ep.pathParams.length > 0) {
|
|
193
|
-
|
|
194
|
-
for (const p of ep.pathParams) {
|
|
195
|
-
const type = schemaToTSType(p.schema);
|
|
192
|
+
const fields = ep.pathParams.map((p) => {
|
|
196
193
|
const comment = p.description ? ` /** ${p.description} */
|
|
197
194
|
` : "";
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
return `${comment} ${p.name}: ${schemaToTSType(p.schema)}`;
|
|
196
|
+
}).join("\n");
|
|
197
|
+
registerType(registry, `${baseName}PathParams`, `export interface ${baseName}PathParams {
|
|
198
|
+
${fields}
|
|
199
|
+
}`, "endpoint");
|
|
202
200
|
}
|
|
203
201
|
if (ep.queryParams.length > 0) {
|
|
204
|
-
|
|
205
|
-
for (const p of ep.queryParams) {
|
|
202
|
+
const fields = ep.queryParams.map((p) => {
|
|
206
203
|
const optional = !p.required ? "?" : "";
|
|
207
|
-
const type = schemaToTSType(p.schema);
|
|
208
204
|
const comment = p.description ? ` /** ${p.description} */
|
|
209
205
|
` : "";
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
return `${comment} ${p.name}${optional}: ${schemaToTSType(p.schema)}`;
|
|
207
|
+
}).join("\n");
|
|
208
|
+
registerType(registry, `${baseName}QueryParams`, `export interface ${baseName}QueryParams {
|
|
209
|
+
${fields}
|
|
210
|
+
}`, "endpoint");
|
|
214
211
|
}
|
|
215
212
|
if (ep.bodySchema) {
|
|
216
|
-
|
|
217
|
-
if (refName && declaredInComponents.has(refName)) {
|
|
218
|
-
if (`${baseName}Body` !== refName) {
|
|
219
|
-
endpointLines.push(`export type ${baseName}Body = ${refName}`);
|
|
220
|
-
endpointLines.push("");
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
endpointLines.push(`export type ${baseName}Body = ${schemaToTSType(ep.bodySchema)}`);
|
|
224
|
-
endpointLines.push("");
|
|
225
|
-
}
|
|
213
|
+
collectSchemaType(registry, ep.bodySchema, `${baseName}Body`);
|
|
226
214
|
}
|
|
227
215
|
if (ep.responseSchema) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
216
|
+
collectSchemaType(registry, ep.responseSchema, `${baseName}Response`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return emitRegistry(registry);
|
|
220
|
+
}
|
|
221
|
+
function collectSchemaType(registry, schema, aliasName) {
|
|
222
|
+
const refName = schema.$ref ? refToTypeName(schema.$ref) : void 0;
|
|
223
|
+
if (refName) {
|
|
224
|
+
if (registry.has(refName)) {
|
|
225
|
+
if (aliasName !== refName) {
|
|
226
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
237
227
|
}
|
|
228
|
+
} else {
|
|
229
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${refName}`, "endpoint");
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
registerType(registry, aliasName, `export type ${aliasName} = ${schemaToTSType(schema)}`, "endpoint");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function emitRegistry(registry) {
|
|
236
|
+
const lines = [];
|
|
237
|
+
lines.push(`// This file is auto-generated by axigen. DO NOT EDIT.`);
|
|
238
|
+
lines.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
239
|
+
lines.push("");
|
|
240
|
+
const componentEntries = [...registry.values()].filter((e) => e.section === "component");
|
|
241
|
+
const endpointEntries = [...registry.values()].filter((e) => e.section === "endpoint");
|
|
242
|
+
if (componentEntries.length > 0) {
|
|
243
|
+
lines.push("// \u2500\u2500\u2500 Component Schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
244
|
+
lines.push("");
|
|
245
|
+
for (const entry of componentEntries) {
|
|
246
|
+
lines.push(entry.declaration);
|
|
247
|
+
lines.push("");
|
|
238
248
|
}
|
|
239
249
|
}
|
|
240
|
-
if (
|
|
250
|
+
if (endpointEntries.length > 0) {
|
|
241
251
|
lines.push("// \u2500\u2500\u2500 Endpoint Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
242
252
|
lines.push("");
|
|
243
|
-
|
|
253
|
+
for (const entry of endpointEntries) {
|
|
254
|
+
lines.push(entry.declaration);
|
|
255
|
+
lines.push("");
|
|
256
|
+
}
|
|
244
257
|
}
|
|
245
258
|
return lines.join("\n");
|
|
246
259
|
}
|
|
247
|
-
function getRefName(schema) {
|
|
248
|
-
if (schema.$ref) return refToTypeName(schema.$ref);
|
|
249
|
-
return void 0;
|
|
250
|
-
}
|
|
251
260
|
function operationToTypeName(operationId) {
|
|
252
261
|
return operationId.charAt(0).toUpperCase() + operationId.slice(1);
|
|
253
262
|
}
|