@rexeus/typeweaver-gen 0.11.0 → 0.12.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/dist/index.cjs +266 -39
- package/dist/index.d.cts +25 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +25 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +266 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -124,6 +124,175 @@ var PathParameterMismatchError = class extends Error {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
//#endregion
|
|
127
|
+
//#region src/bodyNormalization.ts
|
|
128
|
+
const JSON_BODY_SCHEMA_TYPES = new Set([
|
|
129
|
+
"array",
|
|
130
|
+
"boolean",
|
|
131
|
+
"enum",
|
|
132
|
+
"intersection",
|
|
133
|
+
"literal",
|
|
134
|
+
"null",
|
|
135
|
+
"number",
|
|
136
|
+
"object",
|
|
137
|
+
"record",
|
|
138
|
+
"tuple",
|
|
139
|
+
"union"
|
|
140
|
+
]);
|
|
141
|
+
const normalizeBody = (input) => {
|
|
142
|
+
if (input.bodySchema === void 0) return { warnings: [] };
|
|
143
|
+
const warnings = [];
|
|
144
|
+
const contentTypeHeader = extractContentTypeHeader(input.headerSchema);
|
|
145
|
+
if (contentTypeHeader.kind === "literal") return {
|
|
146
|
+
body: createNormalizedBody({
|
|
147
|
+
schema: input.bodySchema,
|
|
148
|
+
mediaType: contentTypeHeader.value,
|
|
149
|
+
mediaTypeSource: "content-type-header"
|
|
150
|
+
}),
|
|
151
|
+
warnings
|
|
152
|
+
};
|
|
153
|
+
if (contentTypeHeader.kind === "ambiguous") warnings.push({
|
|
154
|
+
code: "ambiguous-content-type-header",
|
|
155
|
+
message: "Content-Type header is present but does not have one unambiguous literal value; inferred body media type instead.",
|
|
156
|
+
location: input.location
|
|
157
|
+
});
|
|
158
|
+
else warnings.push({
|
|
159
|
+
code: "missing-content-type-header",
|
|
160
|
+
message: "Body schema is present without a Content-Type header; inferred body media type from schema.",
|
|
161
|
+
location: input.location
|
|
162
|
+
});
|
|
163
|
+
const inferred = inferBodyMediaType(input.bodySchema);
|
|
164
|
+
if (inferred.mediaTypeSource === "raw-fallback") warnings.push({
|
|
165
|
+
code: "raw-body-media-type-fallback",
|
|
166
|
+
message: "Body schema does not imply a concrete media type; used application/octet-stream raw transport fallback.",
|
|
167
|
+
location: input.location
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
body: createNormalizedBody({
|
|
171
|
+
schema: input.bodySchema,
|
|
172
|
+
...inferred
|
|
173
|
+
}),
|
|
174
|
+
warnings
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
const createNormalizedBody = (input) => {
|
|
178
|
+
return {
|
|
179
|
+
schema: input.schema,
|
|
180
|
+
mediaType: input.mediaType,
|
|
181
|
+
mediaTypeSource: input.mediaTypeSource,
|
|
182
|
+
transport: resolveTransport(input.mediaType)
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
const extractContentTypeHeader = (headerSchema) => {
|
|
186
|
+
const headerObject = unwrapOptional(headerSchema);
|
|
187
|
+
if (headerObject === void 0 || !isZodObject$1(headerObject)) return { kind: "absent" };
|
|
188
|
+
const contentTypeEntries = Object.entries(headerObject.shape).filter(([headerName]) => headerName.toLowerCase() === "content-type");
|
|
189
|
+
if (contentTypeEntries.length === 0) return { kind: "absent" };
|
|
190
|
+
const literalValues = contentTypeEntries.flatMap(([, schema]) => extractStringLiteralValues(schema));
|
|
191
|
+
const distinctValues = new Set(literalValues);
|
|
192
|
+
if (contentTypeEntries.length === 1 && distinctValues.size === 1) {
|
|
193
|
+
const [value] = distinctValues;
|
|
194
|
+
return value === void 0 ? { kind: "ambiguous" } : {
|
|
195
|
+
kind: "literal",
|
|
196
|
+
value
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return { kind: "ambiguous" };
|
|
200
|
+
};
|
|
201
|
+
const inferBodyMediaType = (schema) => {
|
|
202
|
+
const inferenceSchema = unwrapMediaInferenceSchema(schema);
|
|
203
|
+
const schemaType = getSchemaType(inferenceSchema);
|
|
204
|
+
if (isTextBodySchema(inferenceSchema)) return {
|
|
205
|
+
mediaType: "text/plain",
|
|
206
|
+
mediaTypeSource: "body-schema"
|
|
207
|
+
};
|
|
208
|
+
if (schemaType === "any" || schemaType === "unknown") return {
|
|
209
|
+
mediaType: "application/octet-stream",
|
|
210
|
+
mediaTypeSource: "raw-fallback"
|
|
211
|
+
};
|
|
212
|
+
if (schemaType !== void 0 && JSON_BODY_SCHEMA_TYPES.has(schemaType)) return {
|
|
213
|
+
mediaType: "application/json",
|
|
214
|
+
mediaTypeSource: "body-schema"
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
mediaType: "application/octet-stream",
|
|
218
|
+
mediaTypeSource: "raw-fallback"
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
const isTextBodySchema = (schema) => {
|
|
222
|
+
const schemaType = getSchemaType(schema);
|
|
223
|
+
if (schemaType === "string") return true;
|
|
224
|
+
if (schemaType === "literal") {
|
|
225
|
+
const values = literalSchemaValues(schema);
|
|
226
|
+
return values.length > 0 && values.every((value) => typeof value === "string");
|
|
227
|
+
}
|
|
228
|
+
if (schemaType === "enum") {
|
|
229
|
+
const values = enumSchemaValues(schema);
|
|
230
|
+
return values.length > 0 && values.every((value) => typeof value === "string");
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
};
|
|
234
|
+
const resolveTransport = (mediaType) => {
|
|
235
|
+
const normalizedMediaType = mediaType.split(";")[0]?.trim().toLowerCase();
|
|
236
|
+
if (normalizedMediaType === "application/json" || normalizedMediaType?.endsWith("+json") === true) return "json";
|
|
237
|
+
if (normalizedMediaType?.startsWith("text/") === true) return "text";
|
|
238
|
+
if (normalizedMediaType === "application/x-www-form-urlencoded") return "form-url-encoded";
|
|
239
|
+
if (normalizedMediaType === "multipart/form-data") return "multipart";
|
|
240
|
+
return "raw";
|
|
241
|
+
};
|
|
242
|
+
const unwrapMediaInferenceSchema = (schema) => {
|
|
243
|
+
const visitedSchemas = /* @__PURE__ */ new Set();
|
|
244
|
+
let current = schema;
|
|
245
|
+
while (current !== void 0 && !visitedSchemas.has(current)) {
|
|
246
|
+
visitedSchemas.add(current);
|
|
247
|
+
const definition = getSchemaDefinition(current);
|
|
248
|
+
const schemaType = definition?.type;
|
|
249
|
+
if (schemaType === "optional" || schemaType === "nullable" || schemaType === "default" || schemaType === "catch" || schemaType === "prefault" || schemaType === "readonly") {
|
|
250
|
+
current = definition?.innerType;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (schemaType === "pipe") {
|
|
254
|
+
const outputType = getSchemaType(definition?.out);
|
|
255
|
+
if (outputType === void 0 || outputType === "transform") return;
|
|
256
|
+
current = definition?.out;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (schemaType === "effects") {
|
|
260
|
+
current = definition?.schema;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
return current;
|
|
264
|
+
}
|
|
265
|
+
return current;
|
|
266
|
+
};
|
|
267
|
+
const unwrapOptional = (schema) => {
|
|
268
|
+
return schema instanceof zod.z.ZodOptional ? schema.unwrap() : schema;
|
|
269
|
+
};
|
|
270
|
+
const isZodObject$1 = (schema) => {
|
|
271
|
+
return getSchemaType(schema) === "object" && "shape" in schema;
|
|
272
|
+
};
|
|
273
|
+
const extractStringLiteralValues = (schema) => {
|
|
274
|
+
const unwrappedSchema = unwrapOptional(schema);
|
|
275
|
+
if (unwrappedSchema === void 0) return [];
|
|
276
|
+
if (getSchemaType(unwrappedSchema) === "literal") return literalSchemaValues(unwrappedSchema).filter((value) => typeof value === "string");
|
|
277
|
+
if (getSchemaType(unwrappedSchema) === "enum") return enumSchemaValues(unwrappedSchema).filter((value) => typeof value === "string");
|
|
278
|
+
return [];
|
|
279
|
+
};
|
|
280
|
+
const literalSchemaValues = (schema) => {
|
|
281
|
+
const literalSchema = schema;
|
|
282
|
+
return Array.from(literalSchema?.values ?? []);
|
|
283
|
+
};
|
|
284
|
+
const enumSchemaValues = (schema) => {
|
|
285
|
+
const enumSchema = schema;
|
|
286
|
+
return enumSchema?.options ?? enumSchema?.def?.values ?? Object.values(enumSchema?.def?.entries ?? enumSchema?.enum ?? {});
|
|
287
|
+
};
|
|
288
|
+
const getSchemaType = (schema) => {
|
|
289
|
+
return getSchemaDefinition(schema)?.type;
|
|
290
|
+
};
|
|
291
|
+
const getSchemaDefinition = (schema) => {
|
|
292
|
+
const schemaWithDefinition = schema;
|
|
293
|
+
return schemaWithDefinition?.def ?? schemaWithDefinition?._def;
|
|
294
|
+
};
|
|
295
|
+
//#endregion
|
|
127
296
|
//#region src/helpers/namingUtils.ts
|
|
128
297
|
const startsWithDigit = (value) => /^[0-9]/u.test(value);
|
|
129
298
|
const isSupportedIdentifierName = (value) => {
|
|
@@ -198,25 +367,49 @@ const validateInlineDerivedResponses = (definition, canonicalResponses) => {
|
|
|
198
367
|
validateDerivedResponseAgainstCanonicalGraph(response, canonicalResponses);
|
|
199
368
|
}
|
|
200
369
|
};
|
|
201
|
-
const normalizeResponseDefinition = (response) => {
|
|
370
|
+
const normalizeResponseDefinition = (response, location) => {
|
|
371
|
+
const body = normalizeBody({
|
|
372
|
+
bodySchema: response.body,
|
|
373
|
+
headerSchema: response.header,
|
|
374
|
+
location: {
|
|
375
|
+
...location,
|
|
376
|
+
part: "response.body"
|
|
377
|
+
}
|
|
378
|
+
});
|
|
202
379
|
return {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
380
|
+
response: {
|
|
381
|
+
name: response.name,
|
|
382
|
+
statusCode: response.statusCode,
|
|
383
|
+
statusCodeName: _rexeus_typeweaver_core.HttpStatusCodeNameMap[response.statusCode],
|
|
384
|
+
description: response.description,
|
|
385
|
+
header: response.header,
|
|
386
|
+
body: body.body,
|
|
387
|
+
kind: response.derived === void 0 ? "response" : "derived-response",
|
|
388
|
+
derivedFrom: response.derived?.parentName,
|
|
389
|
+
lineage: response.derived?.lineage,
|
|
390
|
+
depth: response.derived?.depth
|
|
391
|
+
},
|
|
392
|
+
warnings: body.warnings
|
|
213
393
|
};
|
|
214
394
|
};
|
|
215
395
|
const collectCanonicalResponses = (definition) => {
|
|
216
396
|
const canonicalResponseDefinitions = collectCanonicalResponseDefinitions(definition);
|
|
397
|
+
const warnings = [];
|
|
217
398
|
validateDerivedResponseGraph(canonicalResponseDefinitions);
|
|
218
399
|
validateInlineDerivedResponses(definition, canonicalResponseDefinitions);
|
|
219
|
-
|
|
400
|
+
const responses = /* @__PURE__ */ new Map();
|
|
401
|
+
for (const [responseName, response] of canonicalResponseDefinitions) {
|
|
402
|
+
const normalized = normalizeResponseDefinition(response, {
|
|
403
|
+
responseName,
|
|
404
|
+
statusCode: response.statusCode
|
|
405
|
+
});
|
|
406
|
+
responses.set(responseName, normalized.response);
|
|
407
|
+
warnings.push(...normalized.warnings);
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
responses,
|
|
411
|
+
warnings
|
|
412
|
+
};
|
|
220
413
|
};
|
|
221
414
|
//#endregion
|
|
222
415
|
//#region src/normalizeSpec.ts
|
|
@@ -230,7 +423,7 @@ const validateRequestSchema = (operationId, requestPart, schema) => {
|
|
|
230
423
|
if (!isZodType(schema)) throw new InvalidRequestSchemaError(operationId, requestPart);
|
|
231
424
|
if (requestPart === "param" && !isZodObject(schema)) throw new InvalidRequestSchemaError(operationId, requestPart);
|
|
232
425
|
};
|
|
233
|
-
const validateRequest = (operationId, path, request) => {
|
|
426
|
+
const validateRequest = (resourceName, operationId, path, request) => {
|
|
234
427
|
if (request.header !== void 0) validateRequestSchema(operationId, "header", request.header);
|
|
235
428
|
if (request.param !== void 0) validateRequestSchema(operationId, "param", request.param);
|
|
236
429
|
if (request.query !== void 0) validateRequestSchema(operationId, "query", request.query);
|
|
@@ -238,28 +431,51 @@ const validateRequest = (operationId, path, request) => {
|
|
|
238
431
|
const pathParams = getPathParameterNames(path);
|
|
239
432
|
const requestParams = request.param === void 0 ? [] : Object.keys(request.param.shape);
|
|
240
433
|
if (pathParams.length !== requestParams.length || pathParams.some((pathParam) => !requestParams.includes(pathParam))) throw new PathParameterMismatchError(operationId, path, pathParams, requestParams);
|
|
241
|
-
if (request.header === void 0 && request.param === void 0 && request.query === void 0 && request.body === void 0) return;
|
|
434
|
+
if (request.header === void 0 && request.param === void 0 && request.query === void 0 && request.body === void 0) return { warnings: [] };
|
|
435
|
+
const body = normalizeBody({
|
|
436
|
+
bodySchema: request.body,
|
|
437
|
+
headerSchema: request.header,
|
|
438
|
+
location: {
|
|
439
|
+
resourceName,
|
|
440
|
+
operationId,
|
|
441
|
+
part: "request.body"
|
|
442
|
+
}
|
|
443
|
+
});
|
|
242
444
|
return {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
445
|
+
request: {
|
|
446
|
+
header: request.header,
|
|
447
|
+
param: request.param,
|
|
448
|
+
query: request.query,
|
|
449
|
+
body: body.body
|
|
450
|
+
},
|
|
451
|
+
warnings: body.warnings
|
|
247
452
|
};
|
|
248
453
|
};
|
|
249
|
-
const normalizeOperationResponses = (responses) => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
454
|
+
const normalizeOperationResponses = (resourceName, operationId, responses) => {
|
|
455
|
+
const warnings = [];
|
|
456
|
+
return {
|
|
457
|
+
responses: responses.map((response) => {
|
|
458
|
+
if ((0, _rexeus_typeweaver_core.isNamedResponseDefinition)(response)) return {
|
|
459
|
+
responseName: response.name,
|
|
460
|
+
source: "canonical"
|
|
461
|
+
};
|
|
462
|
+
const normalized = normalizeResponseDefinition(response, {
|
|
463
|
+
resourceName,
|
|
464
|
+
operationId,
|
|
465
|
+
responseName: response.name,
|
|
466
|
+
statusCode: response.statusCode
|
|
467
|
+
});
|
|
468
|
+
warnings.push(...normalized.warnings);
|
|
469
|
+
return {
|
|
470
|
+
responseName: response.name,
|
|
471
|
+
source: "inline",
|
|
472
|
+
response: normalized.response
|
|
473
|
+
};
|
|
474
|
+
}),
|
|
475
|
+
warnings
|
|
476
|
+
};
|
|
261
477
|
};
|
|
262
|
-
const normalizeOperation = (operationIds, routeKeys, operation) => {
|
|
478
|
+
const normalizeOperation = (resourceName, operationIds, routeKeys, operation) => {
|
|
263
479
|
if (!isSupportedOperationId(operation.operationId)) throw new InvalidOperationIdError(operation.operationId);
|
|
264
480
|
if (operationIds.has(operation.operationId)) throw new DuplicateOperationIdError(operation.operationId);
|
|
265
481
|
operationIds.add(operation.operationId);
|
|
@@ -268,13 +484,18 @@ const normalizeOperation = (operationIds, routeKeys, operation) => {
|
|
|
268
484
|
if (routeKeys.has(routeKey)) throw new DuplicateRouteError(operation.method, operation.path, normalizedPath);
|
|
269
485
|
routeKeys.add(routeKey);
|
|
270
486
|
if (operation.responses.length === 0) throw new EmptyOperationResponsesError(operation.operationId);
|
|
487
|
+
const request = validateRequest(resourceName, operation.operationId, operation.path, operation.request);
|
|
488
|
+
const responses = normalizeOperationResponses(resourceName, operation.operationId, operation.responses);
|
|
271
489
|
return {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
490
|
+
operation: {
|
|
491
|
+
operationId: operation.operationId,
|
|
492
|
+
method: operation.method,
|
|
493
|
+
path: operation.path,
|
|
494
|
+
summary: operation.summary,
|
|
495
|
+
request: request.request,
|
|
496
|
+
responses: responses.responses
|
|
497
|
+
},
|
|
498
|
+
warnings: [...request.warnings, ...responses.warnings]
|
|
278
499
|
};
|
|
279
500
|
};
|
|
280
501
|
const normalizeSpec = (definition) => {
|
|
@@ -284,16 +505,22 @@ const normalizeSpec = (definition) => {
|
|
|
284
505
|
const canonicalResponses = collectCanonicalResponses(definition);
|
|
285
506
|
const operationIds = /* @__PURE__ */ new Set();
|
|
286
507
|
const routeKeys = /* @__PURE__ */ new Set();
|
|
508
|
+
const warnings = [...canonicalResponses.warnings];
|
|
287
509
|
return {
|
|
288
510
|
resources: resourceEntries.map(([resourceName, resource]) => {
|
|
289
511
|
if (!isSupportedResourceName(resourceName)) throw new InvalidResourceNameError(resourceName);
|
|
290
512
|
if (resource.operations.length === 0) throw new EmptyResourceOperationsError(resourceName);
|
|
291
513
|
return {
|
|
292
514
|
name: resourceName,
|
|
293
|
-
operations: resource.operations.map((operation) =>
|
|
515
|
+
operations: resource.operations.map((operation) => {
|
|
516
|
+
const normalized = normalizeOperation(resourceName, operationIds, routeKeys, operation);
|
|
517
|
+
warnings.push(...normalized.warnings);
|
|
518
|
+
return normalized.operation;
|
|
519
|
+
})
|
|
294
520
|
};
|
|
295
521
|
}),
|
|
296
|
-
responses: Array.from(canonicalResponses.values())
|
|
522
|
+
responses: Array.from(canonicalResponses.responses.values()),
|
|
523
|
+
warnings
|
|
297
524
|
};
|
|
298
525
|
};
|
|
299
526
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -44,6 +44,28 @@ declare class InvalidOperationIdError extends Error {
|
|
|
44
44
|
type NormalizedSpec = {
|
|
45
45
|
readonly resources: readonly NormalizedResource[];
|
|
46
46
|
readonly responses: readonly NormalizedResponse[];
|
|
47
|
+
readonly warnings: readonly NormalizedSpecWarning[];
|
|
48
|
+
};
|
|
49
|
+
type NormalizedBodyMediaTypeSource = "content-type-header" | "body-schema" | "raw-fallback";
|
|
50
|
+
type NormalizedBodyTransport = "json" | "text" | "form-url-encoded" | "multipart" | "raw";
|
|
51
|
+
type NormalizedHttpBody = {
|
|
52
|
+
readonly schema: HttpBodySchema;
|
|
53
|
+
readonly mediaType: string;
|
|
54
|
+
readonly mediaTypeSource: NormalizedBodyMediaTypeSource;
|
|
55
|
+
readonly transport: NormalizedBodyTransport;
|
|
56
|
+
};
|
|
57
|
+
type NormalizedSpecWarningCode = "ambiguous-content-type-header" | "missing-content-type-header" | "raw-body-media-type-fallback";
|
|
58
|
+
type NormalizedSpecWarningLocation = {
|
|
59
|
+
readonly part: "request.body" | "response.body";
|
|
60
|
+
readonly resourceName?: string;
|
|
61
|
+
readonly operationId?: string;
|
|
62
|
+
readonly responseName?: string;
|
|
63
|
+
readonly statusCode?: HttpStatusCode;
|
|
64
|
+
};
|
|
65
|
+
type NormalizedSpecWarning = {
|
|
66
|
+
readonly code: NormalizedSpecWarningCode;
|
|
67
|
+
readonly message: string;
|
|
68
|
+
readonly location: NormalizedSpecWarningLocation;
|
|
47
69
|
};
|
|
48
70
|
type NormalizedResource = {
|
|
49
71
|
readonly name: string;
|
|
@@ -61,7 +83,7 @@ type NormalizedRequest = {
|
|
|
61
83
|
readonly header?: HttpHeaderSchema;
|
|
62
84
|
readonly param?: HttpParamSchema;
|
|
63
85
|
readonly query?: HttpQuerySchema;
|
|
64
|
-
readonly body?:
|
|
86
|
+
readonly body?: NormalizedHttpBody;
|
|
65
87
|
};
|
|
66
88
|
type NormalizedResponse = {
|
|
67
89
|
readonly name: string;
|
|
@@ -69,7 +91,7 @@ type NormalizedResponse = {
|
|
|
69
91
|
readonly statusCodeName: string;
|
|
70
92
|
readonly description: string;
|
|
71
93
|
readonly header?: HttpHeaderSchema;
|
|
72
|
-
readonly body?:
|
|
94
|
+
readonly body?: NormalizedHttpBody;
|
|
73
95
|
readonly kind: "response" | "derived-response";
|
|
74
96
|
readonly derivedFrom?: string;
|
|
75
97
|
readonly lineage?: readonly string[];
|
|
@@ -347,5 +369,5 @@ declare const compareRoutes: (a: {
|
|
|
347
369
|
//#region src/helpers/templateEngine.d.ts
|
|
348
370
|
declare function renderTemplate(template: string, data: Record<string, unknown>): string;
|
|
349
371
|
//#endregion
|
|
350
|
-
export { BasePlugin, CreateJSDocCommentOptions, DerivedResponseCycleError, DuplicateOperationIdError, DuplicateRouteError, EmptyOperationResponsesError, EmptyResourceOperationsError, EmptySpecResourcesError, GeneratorContext, InvalidDerivedResponseError, InvalidOperationIdError, InvalidRequestSchemaError, InvalidResourceNameError, MissingDerivedResponseParentError, NormalizedCanonicalResponseUsage, NormalizedInlineResponseUsage, NormalizedOperation, NormalizedRequest, NormalizedResource, NormalizedResponse, NormalizedResponseUsage, NormalizedSpec, OperationOutputPaths, PathParameterMismatchError, PluginConfig, PluginConstructor, PluginContext, type PluginContextBuilderApi, PluginDependencyError, PluginLoadError, PluginMetadata, PluginModule, PluginRegistration, type PluginRegistryApi, TypeweaverConfig, TypeweaverPlugin, compareRoutes, createJSDocComment, createPluginContextBuilder, createPluginRegistry, getMethodPriority, getPathParameterNames, isSupportedOperationId, isSupportedResourceName, normalizeRoutePath, normalizeSpec, relative, renderTemplate };
|
|
372
|
+
export { BasePlugin, CreateJSDocCommentOptions, DerivedResponseCycleError, DuplicateOperationIdError, DuplicateRouteError, EmptyOperationResponsesError, EmptyResourceOperationsError, EmptySpecResourcesError, GeneratorContext, InvalidDerivedResponseError, InvalidOperationIdError, InvalidRequestSchemaError, InvalidResourceNameError, MissingDerivedResponseParentError, NormalizedBodyMediaTypeSource, NormalizedBodyTransport, NormalizedCanonicalResponseUsage, NormalizedHttpBody, NormalizedInlineResponseUsage, NormalizedOperation, NormalizedRequest, NormalizedResource, NormalizedResponse, NormalizedResponseUsage, NormalizedSpec, NormalizedSpecWarning, NormalizedSpecWarningCode, NormalizedSpecWarningLocation, OperationOutputPaths, PathParameterMismatchError, PluginConfig, PluginConstructor, PluginContext, type PluginContextBuilderApi, PluginDependencyError, PluginLoadError, PluginMetadata, PluginModule, PluginRegistration, type PluginRegistryApi, TypeweaverConfig, TypeweaverPlugin, compareRoutes, createJSDocComment, createPluginContextBuilder, createPluginRegistry, getMethodPriority, getPathParameterNames, isSupportedOperationId, isSupportedResourceName, normalizeRoutePath, normalizeSpec, relative, renderTemplate };
|
|
351
373
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/NormalizedSpec.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/plugins/pluginContext.ts","../src/helpers/namingUtils.ts","../src/helpers/jsdoc.ts","../src/helpers/path.ts","../src/helpers/routePath.ts","../src/helpers/routeSort.ts","../src/helpers/templateEngine.ts"],"mappings":";;;cAAa,yBAAA,SAAkC,KAAA;cAC1B,YAAA;AAAA;;;cCDR,yBAAA,SAAkC,KAAA;cAC1B,WAAA;AAAA;;;cCDR,mBAAA,SAA4B,KAAA;cACpB,MAAA,UAAgB,IAAA,UAAc,cAAA;AAAA;;;cCDtC,4BAAA,SAAqC,KAAA;cAC7B,WAAA;AAAA;;;cCDR,4BAAA,SAAqC,KAAA;cAC7B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;EAAA,WAAA,CAAA;AAAA;;;cCAhC,2BAAA,SAAoC,KAAA;cAC5B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;cACxB,WAAA;AAAA;;;KCQT,cAAA;EAAA,SACD,SAAA,WAAoB,kBAAA;EAAA,SACpB,SAAA,WAAoB,kBAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/NormalizedSpec.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/plugins/pluginContext.ts","../src/helpers/namingUtils.ts","../src/helpers/jsdoc.ts","../src/helpers/path.ts","../src/helpers/routePath.ts","../src/helpers/routeSort.ts","../src/helpers/templateEngine.ts"],"mappings":";;;cAAa,yBAAA,SAAkC,KAAA;cAC1B,YAAA;AAAA;;;cCDR,yBAAA,SAAkC,KAAA;cAC1B,WAAA;AAAA;;;cCDR,mBAAA,SAA4B,KAAA;cACpB,MAAA,UAAgB,IAAA,UAAc,cAAA;AAAA;;;cCDtC,4BAAA,SAAqC,KAAA;cAC7B,WAAA;AAAA;;;cCDR,4BAAA,SAAqC,KAAA;cAC7B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;EAAA,WAAA,CAAA;AAAA;;;cCAhC,2BAAA,SAAoC,KAAA;cAC5B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;cACxB,WAAA;AAAA;;;KCQT,cAAA;EAAA,SACD,SAAA,WAAoB,kBAAA;EAAA,SACpB,SAAA,WAAoB,kBAAA;EAAA,SACpB,QAAA,WAAmB,qBAAA;AAAA;AAAA,KAGlB,6BAAA;AAAA,KAKA,uBAAA;AAAA,KAOA,kBAAA;EAAA,SACD,MAAA,EAAQ,cAAA;EAAA,SACR,SAAA;EAAA,SACA,eAAA,EAAiB,6BAAA;EAAA,SACjB,SAAA,EAAW,uBAAA;AAAA;AAAA,KAGV,yBAAA;AAA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GAAW,MAAA,EAAQ,gBAAA,EAAkB,MAAA;EAAA,SACrC,GAAA,GAAM,IAAA,aAAiB,kBAAA;EAAA,SACvB,MAAA,QAAc,kBAAA;EAAA,SACd,GAAA,GAAM,IAAA;EAAA,SACN,KAAA;AAAA;AAAA,iBAGK,oBAAA,CAAA,GAAwB,iBAAA;;;KC6P5B,uBAAA;EAAA,SACD,mBAAA,GAAsB,MAAA;IAC7B,SAAA;IACA,QAAA;IACA,MAAA,EAAQ,YAAA;EAAA,MACJ,aAAA;EAAA,SACG,sBAAA,GAAyB,MAAA;IAAA,SACvB,SAAA;IAAA,SACA,QAAA;IAAA,SACA,MAAA,EAAQ,YAAA;IAAA,SACR,cAAA,EAAgB,cAAA;IAAA,SAChB,WAAA;IAAA,SACA,OAAA;IAAA,SACA,kBAAA;IAAA,SACA,aAAA;EAAA,MACL,gBAAA;EAAA,SACG,iBAAA;EAAA,SACA,mBAAA;AAAA;AAAA,iBAGK,0BAAA,CAAA,GAA8B,uBAAA;;;cChRjC,sBAAA,GAA0B,KAAA;AAAA,cAI1B,uBAAA,GAA2B,KAAA;;;KChB5B,yBAAA;EAAA,SACD,WAAA;AAAA;AAAA,iBAMK,kBAAA,CACd,IAAA,sBACA,OAAA,GAAS,yBAAA;;;iBCPK,QAAA,CAAS,IAAA,UAAc,EAAA;;;cCA1B,kBAAA,GAAsB,IAAA;AAAA,cAUtB,qBAAA,GAAyB,IAAA;;;;;;ArBZtC;csBoBa,iBAAA,GAAqB,MAAA;;;;;;;;;cA4BrB,aAAA,GACX,CAAA;EAAK,MAAA;EAAgB,IAAA;AAAA,GACrB,CAAA;EAAK,MAAA;EAAgB,IAAA;AAAA;;;iBCjCP,cAAA,CACd,QAAA,UACA,IAAA,EAAM,MAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,28 @@ declare class InvalidOperationIdError extends Error {
|
|
|
44
44
|
type NormalizedSpec = {
|
|
45
45
|
readonly resources: readonly NormalizedResource[];
|
|
46
46
|
readonly responses: readonly NormalizedResponse[];
|
|
47
|
+
readonly warnings: readonly NormalizedSpecWarning[];
|
|
48
|
+
};
|
|
49
|
+
type NormalizedBodyMediaTypeSource = "content-type-header" | "body-schema" | "raw-fallback";
|
|
50
|
+
type NormalizedBodyTransport = "json" | "text" | "form-url-encoded" | "multipart" | "raw";
|
|
51
|
+
type NormalizedHttpBody = {
|
|
52
|
+
readonly schema: HttpBodySchema;
|
|
53
|
+
readonly mediaType: string;
|
|
54
|
+
readonly mediaTypeSource: NormalizedBodyMediaTypeSource;
|
|
55
|
+
readonly transport: NormalizedBodyTransport;
|
|
56
|
+
};
|
|
57
|
+
type NormalizedSpecWarningCode = "ambiguous-content-type-header" | "missing-content-type-header" | "raw-body-media-type-fallback";
|
|
58
|
+
type NormalizedSpecWarningLocation = {
|
|
59
|
+
readonly part: "request.body" | "response.body";
|
|
60
|
+
readonly resourceName?: string;
|
|
61
|
+
readonly operationId?: string;
|
|
62
|
+
readonly responseName?: string;
|
|
63
|
+
readonly statusCode?: HttpStatusCode;
|
|
64
|
+
};
|
|
65
|
+
type NormalizedSpecWarning = {
|
|
66
|
+
readonly code: NormalizedSpecWarningCode;
|
|
67
|
+
readonly message: string;
|
|
68
|
+
readonly location: NormalizedSpecWarningLocation;
|
|
47
69
|
};
|
|
48
70
|
type NormalizedResource = {
|
|
49
71
|
readonly name: string;
|
|
@@ -61,7 +83,7 @@ type NormalizedRequest = {
|
|
|
61
83
|
readonly header?: HttpHeaderSchema;
|
|
62
84
|
readonly param?: HttpParamSchema;
|
|
63
85
|
readonly query?: HttpQuerySchema;
|
|
64
|
-
readonly body?:
|
|
86
|
+
readonly body?: NormalizedHttpBody;
|
|
65
87
|
};
|
|
66
88
|
type NormalizedResponse = {
|
|
67
89
|
readonly name: string;
|
|
@@ -69,7 +91,7 @@ type NormalizedResponse = {
|
|
|
69
91
|
readonly statusCodeName: string;
|
|
70
92
|
readonly description: string;
|
|
71
93
|
readonly header?: HttpHeaderSchema;
|
|
72
|
-
readonly body?:
|
|
94
|
+
readonly body?: NormalizedHttpBody;
|
|
73
95
|
readonly kind: "response" | "derived-response";
|
|
74
96
|
readonly derivedFrom?: string;
|
|
75
97
|
readonly lineage?: readonly string[];
|
|
@@ -347,5 +369,5 @@ declare const compareRoutes: (a: {
|
|
|
347
369
|
//#region src/helpers/templateEngine.d.ts
|
|
348
370
|
declare function renderTemplate(template: string, data: Record<string, unknown>): string;
|
|
349
371
|
//#endregion
|
|
350
|
-
export { BasePlugin, CreateJSDocCommentOptions, DerivedResponseCycleError, DuplicateOperationIdError, DuplicateRouteError, EmptyOperationResponsesError, EmptyResourceOperationsError, EmptySpecResourcesError, GeneratorContext, InvalidDerivedResponseError, InvalidOperationIdError, InvalidRequestSchemaError, InvalidResourceNameError, MissingDerivedResponseParentError, NormalizedCanonicalResponseUsage, NormalizedInlineResponseUsage, NormalizedOperation, NormalizedRequest, NormalizedResource, NormalizedResponse, NormalizedResponseUsage, NormalizedSpec, OperationOutputPaths, PathParameterMismatchError, PluginConfig, PluginConstructor, PluginContext, type PluginContextBuilderApi, PluginDependencyError, PluginLoadError, PluginMetadata, PluginModule, PluginRegistration, type PluginRegistryApi, TypeweaverConfig, TypeweaverPlugin, compareRoutes, createJSDocComment, createPluginContextBuilder, createPluginRegistry, getMethodPriority, getPathParameterNames, isSupportedOperationId, isSupportedResourceName, normalizeRoutePath, normalizeSpec, relative, renderTemplate };
|
|
372
|
+
export { BasePlugin, CreateJSDocCommentOptions, DerivedResponseCycleError, DuplicateOperationIdError, DuplicateRouteError, EmptyOperationResponsesError, EmptyResourceOperationsError, EmptySpecResourcesError, GeneratorContext, InvalidDerivedResponseError, InvalidOperationIdError, InvalidRequestSchemaError, InvalidResourceNameError, MissingDerivedResponseParentError, NormalizedBodyMediaTypeSource, NormalizedBodyTransport, NormalizedCanonicalResponseUsage, NormalizedHttpBody, NormalizedInlineResponseUsage, NormalizedOperation, NormalizedRequest, NormalizedResource, NormalizedResponse, NormalizedResponseUsage, NormalizedSpec, NormalizedSpecWarning, NormalizedSpecWarningCode, NormalizedSpecWarningLocation, OperationOutputPaths, PathParameterMismatchError, PluginConfig, PluginConstructor, PluginContext, type PluginContextBuilderApi, PluginDependencyError, PluginLoadError, PluginMetadata, PluginModule, PluginRegistration, type PluginRegistryApi, TypeweaverConfig, TypeweaverPlugin, compareRoutes, createJSDocComment, createPluginContextBuilder, createPluginRegistry, getMethodPriority, getPathParameterNames, isSupportedOperationId, isSupportedResourceName, normalizeRoutePath, normalizeSpec, relative, renderTemplate };
|
|
351
373
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/NormalizedSpec.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/plugins/pluginContext.ts","../src/helpers/namingUtils.ts","../src/helpers/jsdoc.ts","../src/helpers/path.ts","../src/helpers/routePath.ts","../src/helpers/routeSort.ts","../src/helpers/templateEngine.ts"],"mappings":";;;cAAa,yBAAA,SAAkC,KAAA;cAC1B,YAAA;AAAA;;;cCDR,yBAAA,SAAkC,KAAA;cAC1B,WAAA;AAAA;;;cCDR,mBAAA,SAA4B,KAAA;cACpB,MAAA,UAAgB,IAAA,UAAc,cAAA;AAAA;;;cCDtC,4BAAA,SAAqC,KAAA;cAC7B,WAAA;AAAA;;;cCDR,4BAAA,SAAqC,KAAA;cAC7B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;EAAA,WAAA,CAAA;AAAA;;;cCAhC,2BAAA,SAAoC,KAAA;cAC5B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;cACxB,WAAA;AAAA;;;KCQT,cAAA;EAAA,SACD,SAAA,WAAoB,kBAAA;EAAA,SACpB,SAAA,WAAoB,kBAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/NormalizedSpec.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/plugins/pluginContext.ts","../src/helpers/namingUtils.ts","../src/helpers/jsdoc.ts","../src/helpers/path.ts","../src/helpers/routePath.ts","../src/helpers/routeSort.ts","../src/helpers/templateEngine.ts"],"mappings":";;;cAAa,yBAAA,SAAkC,KAAA;cAC1B,YAAA;AAAA;;;cCDR,yBAAA,SAAkC,KAAA;cAC1B,WAAA;AAAA;;;cCDR,mBAAA,SAA4B,KAAA;cACpB,MAAA,UAAgB,IAAA,UAAc,cAAA;AAAA;;;cCDtC,4BAAA,SAAqC,KAAA;cAC7B,WAAA;AAAA;;;cCDR,4BAAA,SAAqC,KAAA;cAC7B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;EAAA,WAAA,CAAA;AAAA;;;cCAhC,2BAAA,SAAoC,KAAA;cAC5B,YAAA;AAAA;;;cCDR,uBAAA,SAAgC,KAAA;c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oBa,iBAAA,GAAqB,MAAA;;;;;;;;;cA4BrB,aAAA,GACX,CAAA;EAAK,MAAA;EAAgB,IAAA;AAAA,GACrB,CAAA;EAAK,MAAA;EAAgB,IAAA;AAAA;;;iBCjCP,cAAA,CACd,QAAA,UACA,IAAA,EAAM,MAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -99,6 +99,175 @@ var PathParameterMismatchError = class extends Error {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
//#endregion
|
|
102
|
+
//#region src/bodyNormalization.ts
|
|
103
|
+
const JSON_BODY_SCHEMA_TYPES = new Set([
|
|
104
|
+
"array",
|
|
105
|
+
"boolean",
|
|
106
|
+
"enum",
|
|
107
|
+
"intersection",
|
|
108
|
+
"literal",
|
|
109
|
+
"null",
|
|
110
|
+
"number",
|
|
111
|
+
"object",
|
|
112
|
+
"record",
|
|
113
|
+
"tuple",
|
|
114
|
+
"union"
|
|
115
|
+
]);
|
|
116
|
+
const normalizeBody = (input) => {
|
|
117
|
+
if (input.bodySchema === void 0) return { warnings: [] };
|
|
118
|
+
const warnings = [];
|
|
119
|
+
const contentTypeHeader = extractContentTypeHeader(input.headerSchema);
|
|
120
|
+
if (contentTypeHeader.kind === "literal") return {
|
|
121
|
+
body: createNormalizedBody({
|
|
122
|
+
schema: input.bodySchema,
|
|
123
|
+
mediaType: contentTypeHeader.value,
|
|
124
|
+
mediaTypeSource: "content-type-header"
|
|
125
|
+
}),
|
|
126
|
+
warnings
|
|
127
|
+
};
|
|
128
|
+
if (contentTypeHeader.kind === "ambiguous") warnings.push({
|
|
129
|
+
code: "ambiguous-content-type-header",
|
|
130
|
+
message: "Content-Type header is present but does not have one unambiguous literal value; inferred body media type instead.",
|
|
131
|
+
location: input.location
|
|
132
|
+
});
|
|
133
|
+
else warnings.push({
|
|
134
|
+
code: "missing-content-type-header",
|
|
135
|
+
message: "Body schema is present without a Content-Type header; inferred body media type from schema.",
|
|
136
|
+
location: input.location
|
|
137
|
+
});
|
|
138
|
+
const inferred = inferBodyMediaType(input.bodySchema);
|
|
139
|
+
if (inferred.mediaTypeSource === "raw-fallback") warnings.push({
|
|
140
|
+
code: "raw-body-media-type-fallback",
|
|
141
|
+
message: "Body schema does not imply a concrete media type; used application/octet-stream raw transport fallback.",
|
|
142
|
+
location: input.location
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
body: createNormalizedBody({
|
|
146
|
+
schema: input.bodySchema,
|
|
147
|
+
...inferred
|
|
148
|
+
}),
|
|
149
|
+
warnings
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const createNormalizedBody = (input) => {
|
|
153
|
+
return {
|
|
154
|
+
schema: input.schema,
|
|
155
|
+
mediaType: input.mediaType,
|
|
156
|
+
mediaTypeSource: input.mediaTypeSource,
|
|
157
|
+
transport: resolveTransport(input.mediaType)
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
const extractContentTypeHeader = (headerSchema) => {
|
|
161
|
+
const headerObject = unwrapOptional(headerSchema);
|
|
162
|
+
if (headerObject === void 0 || !isZodObject$1(headerObject)) return { kind: "absent" };
|
|
163
|
+
const contentTypeEntries = Object.entries(headerObject.shape).filter(([headerName]) => headerName.toLowerCase() === "content-type");
|
|
164
|
+
if (contentTypeEntries.length === 0) return { kind: "absent" };
|
|
165
|
+
const literalValues = contentTypeEntries.flatMap(([, schema]) => extractStringLiteralValues(schema));
|
|
166
|
+
const distinctValues = new Set(literalValues);
|
|
167
|
+
if (contentTypeEntries.length === 1 && distinctValues.size === 1) {
|
|
168
|
+
const [value] = distinctValues;
|
|
169
|
+
return value === void 0 ? { kind: "ambiguous" } : {
|
|
170
|
+
kind: "literal",
|
|
171
|
+
value
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return { kind: "ambiguous" };
|
|
175
|
+
};
|
|
176
|
+
const inferBodyMediaType = (schema) => {
|
|
177
|
+
const inferenceSchema = unwrapMediaInferenceSchema(schema);
|
|
178
|
+
const schemaType = getSchemaType(inferenceSchema);
|
|
179
|
+
if (isTextBodySchema(inferenceSchema)) return {
|
|
180
|
+
mediaType: "text/plain",
|
|
181
|
+
mediaTypeSource: "body-schema"
|
|
182
|
+
};
|
|
183
|
+
if (schemaType === "any" || schemaType === "unknown") return {
|
|
184
|
+
mediaType: "application/octet-stream",
|
|
185
|
+
mediaTypeSource: "raw-fallback"
|
|
186
|
+
};
|
|
187
|
+
if (schemaType !== void 0 && JSON_BODY_SCHEMA_TYPES.has(schemaType)) return {
|
|
188
|
+
mediaType: "application/json",
|
|
189
|
+
mediaTypeSource: "body-schema"
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
mediaType: "application/octet-stream",
|
|
193
|
+
mediaTypeSource: "raw-fallback"
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
const isTextBodySchema = (schema) => {
|
|
197
|
+
const schemaType = getSchemaType(schema);
|
|
198
|
+
if (schemaType === "string") return true;
|
|
199
|
+
if (schemaType === "literal") {
|
|
200
|
+
const values = literalSchemaValues(schema);
|
|
201
|
+
return values.length > 0 && values.every((value) => typeof value === "string");
|
|
202
|
+
}
|
|
203
|
+
if (schemaType === "enum") {
|
|
204
|
+
const values = enumSchemaValues(schema);
|
|
205
|
+
return values.length > 0 && values.every((value) => typeof value === "string");
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
};
|
|
209
|
+
const resolveTransport = (mediaType) => {
|
|
210
|
+
const normalizedMediaType = mediaType.split(";")[0]?.trim().toLowerCase();
|
|
211
|
+
if (normalizedMediaType === "application/json" || normalizedMediaType?.endsWith("+json") === true) return "json";
|
|
212
|
+
if (normalizedMediaType?.startsWith("text/") === true) return "text";
|
|
213
|
+
if (normalizedMediaType === "application/x-www-form-urlencoded") return "form-url-encoded";
|
|
214
|
+
if (normalizedMediaType === "multipart/form-data") return "multipart";
|
|
215
|
+
return "raw";
|
|
216
|
+
};
|
|
217
|
+
const unwrapMediaInferenceSchema = (schema) => {
|
|
218
|
+
const visitedSchemas = /* @__PURE__ */ new Set();
|
|
219
|
+
let current = schema;
|
|
220
|
+
while (current !== void 0 && !visitedSchemas.has(current)) {
|
|
221
|
+
visitedSchemas.add(current);
|
|
222
|
+
const definition = getSchemaDefinition(current);
|
|
223
|
+
const schemaType = definition?.type;
|
|
224
|
+
if (schemaType === "optional" || schemaType === "nullable" || schemaType === "default" || schemaType === "catch" || schemaType === "prefault" || schemaType === "readonly") {
|
|
225
|
+
current = definition?.innerType;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (schemaType === "pipe") {
|
|
229
|
+
const outputType = getSchemaType(definition?.out);
|
|
230
|
+
if (outputType === void 0 || outputType === "transform") return;
|
|
231
|
+
current = definition?.out;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (schemaType === "effects") {
|
|
235
|
+
current = definition?.schema;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
return current;
|
|
239
|
+
}
|
|
240
|
+
return current;
|
|
241
|
+
};
|
|
242
|
+
const unwrapOptional = (schema) => {
|
|
243
|
+
return schema instanceof z.ZodOptional ? schema.unwrap() : schema;
|
|
244
|
+
};
|
|
245
|
+
const isZodObject$1 = (schema) => {
|
|
246
|
+
return getSchemaType(schema) === "object" && "shape" in schema;
|
|
247
|
+
};
|
|
248
|
+
const extractStringLiteralValues = (schema) => {
|
|
249
|
+
const unwrappedSchema = unwrapOptional(schema);
|
|
250
|
+
if (unwrappedSchema === void 0) return [];
|
|
251
|
+
if (getSchemaType(unwrappedSchema) === "literal") return literalSchemaValues(unwrappedSchema).filter((value) => typeof value === "string");
|
|
252
|
+
if (getSchemaType(unwrappedSchema) === "enum") return enumSchemaValues(unwrappedSchema).filter((value) => typeof value === "string");
|
|
253
|
+
return [];
|
|
254
|
+
};
|
|
255
|
+
const literalSchemaValues = (schema) => {
|
|
256
|
+
const literalSchema = schema;
|
|
257
|
+
return Array.from(literalSchema?.values ?? []);
|
|
258
|
+
};
|
|
259
|
+
const enumSchemaValues = (schema) => {
|
|
260
|
+
const enumSchema = schema;
|
|
261
|
+
return enumSchema?.options ?? enumSchema?.def?.values ?? Object.values(enumSchema?.def?.entries ?? enumSchema?.enum ?? {});
|
|
262
|
+
};
|
|
263
|
+
const getSchemaType = (schema) => {
|
|
264
|
+
return getSchemaDefinition(schema)?.type;
|
|
265
|
+
};
|
|
266
|
+
const getSchemaDefinition = (schema) => {
|
|
267
|
+
const schemaWithDefinition = schema;
|
|
268
|
+
return schemaWithDefinition?.def ?? schemaWithDefinition?._def;
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
102
271
|
//#region src/helpers/namingUtils.ts
|
|
103
272
|
const startsWithDigit = (value) => /^[0-9]/u.test(value);
|
|
104
273
|
const isSupportedIdentifierName = (value) => {
|
|
@@ -173,25 +342,49 @@ const validateInlineDerivedResponses = (definition, canonicalResponses) => {
|
|
|
173
342
|
validateDerivedResponseAgainstCanonicalGraph(response, canonicalResponses);
|
|
174
343
|
}
|
|
175
344
|
};
|
|
176
|
-
const normalizeResponseDefinition = (response) => {
|
|
345
|
+
const normalizeResponseDefinition = (response, location) => {
|
|
346
|
+
const body = normalizeBody({
|
|
347
|
+
bodySchema: response.body,
|
|
348
|
+
headerSchema: response.header,
|
|
349
|
+
location: {
|
|
350
|
+
...location,
|
|
351
|
+
part: "response.body"
|
|
352
|
+
}
|
|
353
|
+
});
|
|
177
354
|
return {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
355
|
+
response: {
|
|
356
|
+
name: response.name,
|
|
357
|
+
statusCode: response.statusCode,
|
|
358
|
+
statusCodeName: HttpStatusCodeNameMap[response.statusCode],
|
|
359
|
+
description: response.description,
|
|
360
|
+
header: response.header,
|
|
361
|
+
body: body.body,
|
|
362
|
+
kind: response.derived === void 0 ? "response" : "derived-response",
|
|
363
|
+
derivedFrom: response.derived?.parentName,
|
|
364
|
+
lineage: response.derived?.lineage,
|
|
365
|
+
depth: response.derived?.depth
|
|
366
|
+
},
|
|
367
|
+
warnings: body.warnings
|
|
188
368
|
};
|
|
189
369
|
};
|
|
190
370
|
const collectCanonicalResponses = (definition) => {
|
|
191
371
|
const canonicalResponseDefinitions = collectCanonicalResponseDefinitions(definition);
|
|
372
|
+
const warnings = [];
|
|
192
373
|
validateDerivedResponseGraph(canonicalResponseDefinitions);
|
|
193
374
|
validateInlineDerivedResponses(definition, canonicalResponseDefinitions);
|
|
194
|
-
|
|
375
|
+
const responses = /* @__PURE__ */ new Map();
|
|
376
|
+
for (const [responseName, response] of canonicalResponseDefinitions) {
|
|
377
|
+
const normalized = normalizeResponseDefinition(response, {
|
|
378
|
+
responseName,
|
|
379
|
+
statusCode: response.statusCode
|
|
380
|
+
});
|
|
381
|
+
responses.set(responseName, normalized.response);
|
|
382
|
+
warnings.push(...normalized.warnings);
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
responses,
|
|
386
|
+
warnings
|
|
387
|
+
};
|
|
195
388
|
};
|
|
196
389
|
//#endregion
|
|
197
390
|
//#region src/normalizeSpec.ts
|
|
@@ -205,7 +398,7 @@ const validateRequestSchema = (operationId, requestPart, schema) => {
|
|
|
205
398
|
if (!isZodType(schema)) throw new InvalidRequestSchemaError(operationId, requestPart);
|
|
206
399
|
if (requestPart === "param" && !isZodObject(schema)) throw new InvalidRequestSchemaError(operationId, requestPart);
|
|
207
400
|
};
|
|
208
|
-
const validateRequest = (operationId, path, request) => {
|
|
401
|
+
const validateRequest = (resourceName, operationId, path, request) => {
|
|
209
402
|
if (request.header !== void 0) validateRequestSchema(operationId, "header", request.header);
|
|
210
403
|
if (request.param !== void 0) validateRequestSchema(operationId, "param", request.param);
|
|
211
404
|
if (request.query !== void 0) validateRequestSchema(operationId, "query", request.query);
|
|
@@ -213,28 +406,51 @@ const validateRequest = (operationId, path, request) => {
|
|
|
213
406
|
const pathParams = getPathParameterNames(path);
|
|
214
407
|
const requestParams = request.param === void 0 ? [] : Object.keys(request.param.shape);
|
|
215
408
|
if (pathParams.length !== requestParams.length || pathParams.some((pathParam) => !requestParams.includes(pathParam))) throw new PathParameterMismatchError(operationId, path, pathParams, requestParams);
|
|
216
|
-
if (request.header === void 0 && request.param === void 0 && request.query === void 0 && request.body === void 0) return;
|
|
409
|
+
if (request.header === void 0 && request.param === void 0 && request.query === void 0 && request.body === void 0) return { warnings: [] };
|
|
410
|
+
const body = normalizeBody({
|
|
411
|
+
bodySchema: request.body,
|
|
412
|
+
headerSchema: request.header,
|
|
413
|
+
location: {
|
|
414
|
+
resourceName,
|
|
415
|
+
operationId,
|
|
416
|
+
part: "request.body"
|
|
417
|
+
}
|
|
418
|
+
});
|
|
217
419
|
return {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
420
|
+
request: {
|
|
421
|
+
header: request.header,
|
|
422
|
+
param: request.param,
|
|
423
|
+
query: request.query,
|
|
424
|
+
body: body.body
|
|
425
|
+
},
|
|
426
|
+
warnings: body.warnings
|
|
222
427
|
};
|
|
223
428
|
};
|
|
224
|
-
const normalizeOperationResponses = (responses) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
429
|
+
const normalizeOperationResponses = (resourceName, operationId, responses) => {
|
|
430
|
+
const warnings = [];
|
|
431
|
+
return {
|
|
432
|
+
responses: responses.map((response) => {
|
|
433
|
+
if (isNamedResponseDefinition(response)) return {
|
|
434
|
+
responseName: response.name,
|
|
435
|
+
source: "canonical"
|
|
436
|
+
};
|
|
437
|
+
const normalized = normalizeResponseDefinition(response, {
|
|
438
|
+
resourceName,
|
|
439
|
+
operationId,
|
|
440
|
+
responseName: response.name,
|
|
441
|
+
statusCode: response.statusCode
|
|
442
|
+
});
|
|
443
|
+
warnings.push(...normalized.warnings);
|
|
444
|
+
return {
|
|
445
|
+
responseName: response.name,
|
|
446
|
+
source: "inline",
|
|
447
|
+
response: normalized.response
|
|
448
|
+
};
|
|
449
|
+
}),
|
|
450
|
+
warnings
|
|
451
|
+
};
|
|
236
452
|
};
|
|
237
|
-
const normalizeOperation = (operationIds, routeKeys, operation) => {
|
|
453
|
+
const normalizeOperation = (resourceName, operationIds, routeKeys, operation) => {
|
|
238
454
|
if (!isSupportedOperationId(operation.operationId)) throw new InvalidOperationIdError(operation.operationId);
|
|
239
455
|
if (operationIds.has(operation.operationId)) throw new DuplicateOperationIdError(operation.operationId);
|
|
240
456
|
operationIds.add(operation.operationId);
|
|
@@ -243,13 +459,18 @@ const normalizeOperation = (operationIds, routeKeys, operation) => {
|
|
|
243
459
|
if (routeKeys.has(routeKey)) throw new DuplicateRouteError(operation.method, operation.path, normalizedPath);
|
|
244
460
|
routeKeys.add(routeKey);
|
|
245
461
|
if (operation.responses.length === 0) throw new EmptyOperationResponsesError(operation.operationId);
|
|
462
|
+
const request = validateRequest(resourceName, operation.operationId, operation.path, operation.request);
|
|
463
|
+
const responses = normalizeOperationResponses(resourceName, operation.operationId, operation.responses);
|
|
246
464
|
return {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
465
|
+
operation: {
|
|
466
|
+
operationId: operation.operationId,
|
|
467
|
+
method: operation.method,
|
|
468
|
+
path: operation.path,
|
|
469
|
+
summary: operation.summary,
|
|
470
|
+
request: request.request,
|
|
471
|
+
responses: responses.responses
|
|
472
|
+
},
|
|
473
|
+
warnings: [...request.warnings, ...responses.warnings]
|
|
253
474
|
};
|
|
254
475
|
};
|
|
255
476
|
const normalizeSpec = (definition) => {
|
|
@@ -259,16 +480,22 @@ const normalizeSpec = (definition) => {
|
|
|
259
480
|
const canonicalResponses = collectCanonicalResponses(definition);
|
|
260
481
|
const operationIds = /* @__PURE__ */ new Set();
|
|
261
482
|
const routeKeys = /* @__PURE__ */ new Set();
|
|
483
|
+
const warnings = [...canonicalResponses.warnings];
|
|
262
484
|
return {
|
|
263
485
|
resources: resourceEntries.map(([resourceName, resource]) => {
|
|
264
486
|
if (!isSupportedResourceName(resourceName)) throw new InvalidResourceNameError(resourceName);
|
|
265
487
|
if (resource.operations.length === 0) throw new EmptyResourceOperationsError(resourceName);
|
|
266
488
|
return {
|
|
267
489
|
name: resourceName,
|
|
268
|
-
operations: resource.operations.map((operation) =>
|
|
490
|
+
operations: resource.operations.map((operation) => {
|
|
491
|
+
const normalized = normalizeOperation(resourceName, operationIds, routeKeys, operation);
|
|
492
|
+
warnings.push(...normalized.warnings);
|
|
493
|
+
return normalized.operation;
|
|
494
|
+
})
|
|
269
495
|
};
|
|
270
496
|
}),
|
|
271
|
-
responses: Array.from(canonicalResponses.values())
|
|
497
|
+
responses: Array.from(canonicalResponses.responses.values()),
|
|
498
|
+
warnings
|
|
272
499
|
};
|
|
273
500
|
};
|
|
274
501
|
//#endregion
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/helpers/namingUtils.ts","../src/helpers/routePath.ts","../src/validation/derivedResponseValidation.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/helpers/path.ts","../src/helpers/templateEngine.ts","../src/plugins/errors/MissingCanonicalResponseError.ts","../src/plugins/pluginContext.ts","../src/helpers/jsdoc.ts","../src/helpers/routeSort.ts"],"sourcesContent":["export class DerivedResponseCycleError extends Error {\n public constructor(responseName: string) {\n super(`Derived response '${responseName}' contains a cyclic lineage.`);\n this.name = \"DerivedResponseCycleError\";\n }\n}\n","export class DuplicateOperationIdError extends Error {\n public constructor(operationId: string) {\n super(\n `Operation ID '${operationId}' must be globally unique within a spec.`\n );\n this.name = \"DuplicateOperationIdError\";\n }\n}\n","export class DuplicateRouteError extends Error {\n public constructor(method: string, path: string, normalizedPath: string) {\n super(\n `Route '${method} ${path}' conflicts with an existing route using normalized path '${normalizedPath}'.`\n );\n this.name = \"DuplicateRouteError\";\n }\n}\n","export class EmptyOperationResponsesError extends Error {\n public constructor(operationId: string) {\n super(`Operation '${operationId}' must declare at least one response.`);\n this.name = \"EmptyOperationResponsesError\";\n }\n}\n","export class EmptyResourceOperationsError extends Error {\n public constructor(resourceName: string) {\n super(`Resource '${resourceName}' must contain at least one operation.`);\n this.name = \"EmptyResourceOperationsError\";\n }\n}\n","export class EmptySpecResourcesError extends Error {\n public constructor() {\n super(\"Spec definition must contain at least one resource.\");\n this.name = \"EmptySpecResourcesError\";\n }\n}\n","export class InvalidDerivedResponseError extends Error {\n public constructor(responseName: string) {\n super(\n `Derived response '${responseName}' contains invalid lineage metadata.`\n );\n this.name = \"InvalidDerivedResponseError\";\n }\n}\n","export class InvalidOperationIdError extends Error {\n public constructor(operationId: string) {\n super(\n `Operation ID '${operationId}' is invalid. Use camelCase (preferred) or PascalCase. snake_case and kebab-case are not supported.`\n );\n this.name = \"InvalidOperationIdError\";\n }\n}\n","import type { NormalizedRequest } from \"../NormalizedSpec.js\";\n\nexport class InvalidRequestSchemaError extends Error {\n public constructor(\n operationId: string,\n requestPart: keyof NormalizedRequest\n ) {\n super(\n `Operation '${operationId}' has an invalid request.${requestPart} schema definition.`\n );\n this.name = \"InvalidRequestSchemaError\";\n }\n}\n","export class InvalidResourceNameError extends Error {\n public constructor(resourceName: string) {\n super(\n `Resource name '${resourceName}' is invalid. Use camelCase singular nouns when possible; PascalCase is also supported. snake_case and kebab-case are not supported.`\n );\n this.name = \"InvalidResourceNameError\";\n }\n}\n","export class MissingDerivedResponseParentError extends Error {\n public constructor(responseName: string, parentName: string) {\n super(\n `Derived response '${responseName}' references missing canonical parent '${parentName}'.`\n );\n this.name = \"MissingDerivedResponseParentError\";\n }\n}\n","export class PathParameterMismatchError extends Error {\n public constructor(\n operationId: string,\n path: string,\n pathParams: readonly string[],\n requestParams: readonly string[]\n ) {\n super(\n `Operation '${operationId}' has mismatched path parameters for '${path}'. Path params: [${pathParams.join(\n \", \"\n )}], request.param keys: [${requestParams.join(\", \")}].`\n );\n this.name = \"PathParameterMismatchError\";\n }\n}\n","import { isCamelCase, isPascalCase } from \"polycase\";\n\nconst startsWithDigit = (value: string): boolean => /^[0-9]/u.test(value);\n\nconst isSupportedIdentifierName = (value: string): boolean => {\n if (startsWithDigit(value)) {\n return false;\n }\n\n return isCamelCase(value) || isPascalCase(value);\n};\n\nexport const isSupportedOperationId = (value: string): boolean => {\n return isSupportedIdentifierName(value);\n};\n\nexport const isSupportedResourceName = (value: string): boolean => {\n return isSupportedIdentifierName(value);\n};\n","const PATH_PARAMETER_PATTERN = /:([A-Za-z0-9_]+)/g;\n\nexport const normalizeRoutePath = (path: string): string => {\n const segments = path.split(\"/\").filter(Boolean);\n\n if (segments.length === 0) {\n return \"/\";\n }\n\n return `/${segments.map(segment => (segment.startsWith(\":\") ? \":\" : segment)).join(\"/\")}`;\n};\n\nexport const getPathParameterNames = (path: string): string[] => {\n return Array.from(\n path.matchAll(PATH_PARAMETER_PATTERN),\n match => match[1] as string\n );\n};\n","import {\n HttpStatusCodeNameMap,\n isNamedResponseDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport type {\n ResponseDefinition,\n SpecDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport {\n DerivedResponseCycleError,\n InvalidDerivedResponseError,\n MissingDerivedResponseParentError,\n} from \"../errors/index.js\";\nimport type { NormalizedResponse } from \"../NormalizedSpec.js\";\n\nexport const validateDerivedResponseMetadata = (\n response: ResponseDefinition\n): void => {\n const derived = response.derived;\n\n if (derived === undefined) {\n return;\n }\n\n if (derived.parentName === response.name) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n if (derived.lineage.length === 0) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (derived.lineage.at(-1) !== response.name) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (derived.lineage.length !== derived.depth) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (new Set(derived.lineage).size !== derived.lineage.length) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n if (derived.depth > 1 && derived.lineage.at(-2) !== derived.parentName) {\n throw new InvalidDerivedResponseError(response.name);\n }\n};\n\nexport const collectCanonicalResponseDefinitions = (\n definition: SpecDefinition\n): Map<string, ResponseDefinition> => {\n const canonicalResponses = new Map<string, ResponseDefinition>();\n\n for (const resource of Object.values(definition.resources)) {\n for (const operation of resource.operations) {\n for (const response of operation.responses) {\n if (!isNamedResponseDefinition(response)) {\n continue;\n }\n\n validateDerivedResponseMetadata(response);\n\n canonicalResponses.set(response.name, response);\n }\n }\n }\n\n return canonicalResponses;\n};\n\nexport const getDerivedResponseChain = (\n response: ResponseDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): readonly string[] => {\n const chain: string[] = [response.name];\n const visitedResponseNames = new Set(chain);\n let parentName = response.derived?.parentName;\n\n while (parentName !== undefined) {\n if (visitedResponseNames.has(parentName)) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n const parentResponse = canonicalResponses.get(parentName);\n\n if (parentResponse === undefined) {\n throw new MissingDerivedResponseParentError(response.name, parentName);\n }\n\n chain.unshift(parentResponse.name);\n visitedResponseNames.add(parentResponse.name);\n parentName = parentResponse.derived?.parentName;\n }\n\n return chain;\n};\n\nexport const validateDerivedResponseGraph = (\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n for (const response of canonicalResponses.values()) {\n validateDerivedResponseAgainstCanonicalGraph(response, canonicalResponses);\n }\n};\n\nconst validateDerivedResponseAgainstCanonicalGraph = (\n response: ResponseDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n if (response.derived === undefined) {\n return;\n }\n\n const chain = getDerivedResponseChain(response, canonicalResponses);\n const materializedLineage = chain.slice(1);\n\n if (response.derived.depth !== materializedLineage.length) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (\n materializedLineage.length !== response.derived.lineage.length ||\n materializedLineage.some(\n (lineageEntry, index) => lineageEntry !== response.derived?.lineage[index]\n )\n ) {\n throw new InvalidDerivedResponseError(response.name);\n }\n};\n\nconst validateInlineDerivedResponses = (\n definition: SpecDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n for (const resource of Object.values(definition.resources)) {\n for (const operation of resource.operations) {\n for (const response of operation.responses) {\n if (isNamedResponseDefinition(response)) {\n continue;\n }\n\n validateDerivedResponseMetadata(response);\n validateDerivedResponseAgainstCanonicalGraph(\n response,\n canonicalResponses\n );\n }\n }\n }\n};\n\nexport const normalizeResponseDefinition = (\n response: ResponseDefinition\n): NormalizedResponse => {\n return {\n name: response.name,\n statusCode: response.statusCode,\n statusCodeName: HttpStatusCodeNameMap[response.statusCode],\n description: response.description,\n header: response.header,\n body: response.body,\n kind: response.derived === undefined ? \"response\" : \"derived-response\",\n derivedFrom: response.derived?.parentName,\n lineage: response.derived?.lineage,\n depth: response.derived?.depth,\n };\n};\n\nexport const collectCanonicalResponses = (\n definition: SpecDefinition\n): Map<string, NormalizedResponse> => {\n const canonicalResponseDefinitions =\n collectCanonicalResponseDefinitions(definition);\n\n validateDerivedResponseGraph(canonicalResponseDefinitions);\n validateInlineDerivedResponses(definition, canonicalResponseDefinitions);\n\n return new Map(\n Array.from(\n canonicalResponseDefinitions.entries(),\n ([responseName, response]) => [\n responseName,\n normalizeResponseDefinition(response),\n ]\n )\n );\n};\n","import {\n isNamedResponseDefinition,\n validateUniqueResponseNames,\n} from \"@rexeus/typeweaver-core\";\nimport type {\n RequestDefinition,\n ResourceDefinition,\n ResponseDefinition,\n SpecDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport { z } from \"zod\";\nimport {\n DuplicateOperationIdError,\n DuplicateRouteError,\n EmptyOperationResponsesError,\n EmptyResourceOperationsError,\n EmptySpecResourcesError,\n InvalidOperationIdError,\n InvalidRequestSchemaError,\n InvalidResourceNameError,\n PathParameterMismatchError,\n} from \"./errors/index.js\";\nimport {\n isSupportedOperationId,\n isSupportedResourceName,\n} from \"./helpers/namingUtils.js\";\nimport {\n getPathParameterNames,\n normalizeRoutePath,\n} from \"./helpers/routePath.js\";\nimport {\n collectCanonicalResponses,\n normalizeResponseDefinition,\n} from \"./validation/index.js\";\nimport type {\n NormalizedOperation,\n NormalizedRequest,\n NormalizedResponseUsage,\n NormalizedSpec,\n} from \"./NormalizedSpec.js\";\n\nconst isZodType = (schema: unknown): schema is z.ZodType => {\n return schema instanceof z.ZodType;\n};\n\nconst isZodObject = (\n schema: unknown\n): schema is z.ZodObject<z.core.$ZodShape> => {\n return schema instanceof z.ZodObject;\n};\n\nconst validateRequestSchema = (\n operationId: string,\n requestPart: keyof NormalizedRequest,\n schema: unknown\n): void => {\n if (!isZodType(schema)) {\n throw new InvalidRequestSchemaError(operationId, requestPart);\n }\n\n if (requestPart === \"param\" && !isZodObject(schema)) {\n throw new InvalidRequestSchemaError(operationId, requestPart);\n }\n};\n\nconst validateRequest = (\n operationId: string,\n path: string,\n request: RequestDefinition\n): NormalizedRequest | undefined => {\n if (request.header !== undefined) {\n validateRequestSchema(operationId, \"header\", request.header);\n }\n\n if (request.param !== undefined) {\n validateRequestSchema(operationId, \"param\", request.param);\n }\n\n if (request.query !== undefined) {\n validateRequestSchema(operationId, \"query\", request.query);\n }\n\n if (request.body !== undefined) {\n validateRequestSchema(operationId, \"body\", request.body);\n }\n\n const pathParams = getPathParameterNames(path);\n const requestParams =\n request.param === undefined ? [] : Object.keys(request.param.shape);\n\n if (\n pathParams.length !== requestParams.length ||\n pathParams.some(pathParam => !requestParams.includes(pathParam))\n ) {\n throw new PathParameterMismatchError(\n operationId,\n path,\n pathParams,\n requestParams\n );\n }\n\n if (\n request.header === undefined &&\n request.param === undefined &&\n request.query === undefined &&\n request.body === undefined\n ) {\n return undefined;\n }\n\n return {\n header: request.header,\n param: request.param,\n query: request.query,\n body: request.body,\n };\n};\n\nconst normalizeOperationResponses = (\n responses: readonly ResponseDefinition[]\n): NormalizedResponseUsage[] => {\n return responses.map(response => {\n if (isNamedResponseDefinition(response)) {\n return {\n responseName: response.name,\n source: \"canonical\",\n };\n }\n\n return {\n responseName: response.name,\n source: \"inline\",\n response: normalizeResponseDefinition(response),\n };\n });\n};\n\nconst normalizeOperation = (\n operationIds: Set<string>,\n routeKeys: Set<string>,\n operation: ResourceDefinition[\"operations\"][number]\n): NormalizedOperation => {\n if (!isSupportedOperationId(operation.operationId)) {\n throw new InvalidOperationIdError(operation.operationId);\n }\n\n if (operationIds.has(operation.operationId)) {\n throw new DuplicateOperationIdError(operation.operationId);\n }\n\n operationIds.add(operation.operationId);\n\n const normalizedPath = normalizeRoutePath(operation.path);\n const routeKey = `${operation.method}:${normalizedPath}`;\n\n if (routeKeys.has(routeKey)) {\n throw new DuplicateRouteError(\n operation.method,\n operation.path,\n normalizedPath\n );\n }\n\n routeKeys.add(routeKey);\n\n if (operation.responses.length === 0) {\n throw new EmptyOperationResponsesError(operation.operationId);\n }\n\n return {\n operationId: operation.operationId,\n method: operation.method,\n path: operation.path,\n summary: operation.summary,\n request: validateRequest(\n operation.operationId,\n operation.path,\n operation.request\n ),\n responses: normalizeOperationResponses(operation.responses),\n };\n};\n\nexport const normalizeSpec = (definition: SpecDefinition): NormalizedSpec => {\n const resourceEntries = Object.entries(definition.resources);\n\n if (resourceEntries.length === 0) {\n throw new EmptySpecResourcesError();\n }\n\n validateUniqueResponseNames(definition.resources);\n const canonicalResponses = collectCanonicalResponses(definition);\n const operationIds = new Set<string>();\n const routeKeys = new Set<string>();\n\n return {\n resources: resourceEntries.map(([resourceName, resource]) => {\n if (!isSupportedResourceName(resourceName)) {\n throw new InvalidResourceNameError(resourceName);\n }\n\n if (resource.operations.length === 0) {\n throw new EmptyResourceOperationsError(resourceName);\n }\n\n return {\n name: resourceName,\n operations: resource.operations.map(operation =>\n normalizeOperation(operationIds, routeKeys, operation)\n ),\n };\n }),\n responses: Array.from(canonicalResponses.values()),\n };\n};\n","import type { NormalizedResponse, NormalizedSpec } from \"../NormalizedSpec.js\";\n\n/**\n * Configuration for a typeweaver plugin\n */\nexport type PluginConfig = Record<string, unknown>;\n\n/**\n * Context provided to plugins during initialization and finalization\n */\nexport type PluginContext = {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n};\n\nexport type OperationOutputPaths = {\n readonly outputDir: string;\n readonly requestFile: string;\n readonly requestFileName: string;\n readonly responseFile: string;\n readonly responseFileName: string;\n readonly requestValidationFile: string;\n readonly requestValidationFileName: string;\n readonly responseValidationFile: string;\n readonly responseValidationFileName: string;\n readonly clientFile: string;\n readonly clientFileName: string;\n};\n\n/**\n * Context provided to plugins during generation\n */\nexport type GeneratorContext = PluginContext & {\n readonly normalizedSpec: NormalizedSpec;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n\n readonly getCanonicalResponse: (responseName: string) => NormalizedResponse;\n readonly getCanonicalResponseOutputFile: (responseName: string) => string;\n readonly getCanonicalResponseImportPath: (params: {\n readonly importerDir: string;\n readonly responseName: string;\n }) => string;\n readonly getSpecImportPath: (params: {\n readonly importerDir: string;\n }) => string;\n readonly getOperationDefinitionAccessor: (params: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => string;\n readonly getOperationOutputPaths: (params: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => OperationOutputPaths;\n readonly getResourceOutputDir: (resourceName: string) => string;\n readonly writeFile: (relativePath: string, content: string) => void;\n readonly renderTemplate: (templatePath: string, data: unknown) => string;\n readonly addGeneratedFile: (relativePath: string) => void;\n readonly getGeneratedFiles: () => string[];\n};\n\n/**\n * Plugin metadata\n */\nexport type PluginMetadata = {\n readonly name: string;\n readonly depends?: readonly string[];\n};\n\n/**\n * typeweaver plugin interface\n */\nexport type TypeweaverPlugin = PluginMetadata & {\n /**\n * Initialize the plugin\n * Called before any generation happens\n */\n initialize?(context: PluginContext): Promise<void> | void;\n\n /**\n * Collect and transform resources\n * Allows plugins to modify the resource collection\n */\n collectResources?(\n normalizedSpec: NormalizedSpec\n ): Promise<NormalizedSpec> | NormalizedSpec;\n\n /**\n * Main generation logic\n * Called with all resources and utilities\n */\n generate?(context: GeneratorContext): Promise<void> | void;\n\n /**\n * Finalize the plugin\n * Called after all generation is complete\n */\n finalize?(context: PluginContext): Promise<void> | void;\n};\n\n/**\n * Plugin constructor type\n */\nexport type PluginConstructor = new (config?: PluginConfig) => TypeweaverPlugin;\n\n/**\n * Plugin module export\n */\nexport type PluginModule = {\n default: PluginConstructor;\n};\n\n/**\n * Plugin registration entry\n */\nexport type PluginRegistration = {\n name: string;\n plugin: TypeweaverPlugin;\n config?: PluginConfig;\n};\n\n/**\n * typeweaver configuration\n */\nexport type TypeweaverConfig = {\n input: string;\n output: string;\n plugins?: (string | [string, PluginConfig])[];\n format?: boolean;\n clean?: boolean;\n};\n\n/**\n * Plugin loading error\n */\nexport class PluginLoadError extends Error {\n constructor(\n public pluginName: string,\n message: string\n ) {\n super(`Failed to load plugin '${pluginName}': ${message}`);\n this.name = \"PluginLoadError\";\n }\n}\n\n/**\n * Plugin dependency error\n */\nexport class PluginDependencyError extends Error {\n constructor(\n public pluginName: string,\n public missingDependency: string,\n message?: string\n ) {\n super(\n message ??\n `Plugin '${pluginName}' depends on '${missingDependency}' which is not loaded`\n );\n this.name = \"PluginDependencyError\";\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { NormalizedSpec } from \"../NormalizedSpec.js\";\nimport type {\n GeneratorContext,\n PluginConfig,\n PluginContext,\n TypeweaverPlugin,\n} from \"./types.js\";\n\n/**\n * Base class for typeweaver plugins\n * Provides default implementations and common utilities\n */\nexport abstract class BasePlugin implements TypeweaverPlugin {\n abstract name: string;\n description?: string;\n author?: string;\n depends?: string[];\n\n protected config: PluginConfig;\n\n constructor(config: PluginConfig = {}) {\n this.config = config;\n }\n\n /**\n * Default implementation - override in subclasses if needed\n */\n async initialize(_context: PluginContext): Promise<void> {\n // Default: no initialization needed\n }\n\n /**\n * Default implementation - override in subclasses if needed\n */\n collectResources(normalizedSpec: NormalizedSpec): NormalizedSpec {\n return normalizedSpec;\n }\n\n /**\n * Main generation logic - must be implemented by subclasses\n */\n abstract generate(context: GeneratorContext): Promise<void> | void;\n\n /**\n * Default implementation - override in subclasses if needed\n */\n async finalize(_context: PluginContext): Promise<void> {\n // Default: no finalization needed\n }\n\n protected copyLibFiles(\n context: GeneratorContext,\n libSourceDir: string,\n libNamespace: string\n ): void {\n if (!fs.existsSync(libSourceDir)) return;\n\n const libDir = path.join(context.outputDir, \"lib\", libNamespace);\n\n fs.cpSync(libSourceDir, libDir, { recursive: true });\n\n const libIndexPath = path.join(\"lib\", libNamespace, \"index.ts\");\n if (fs.existsSync(path.join(libDir, \"index.ts\"))) {\n context.addGeneratedFile(libIndexPath);\n }\n }\n}\n","import { PluginDependencyError } from \"./types.js\";\nimport type { PluginRegistration, TypeweaverPlugin } from \"./types.js\";\n\nexport type PluginRegistryApi = {\n readonly register: (plugin: TypeweaverPlugin, config?: unknown) => void;\n readonly get: (name: string) => PluginRegistration | undefined;\n readonly getAll: () => PluginRegistration[];\n readonly has: (name: string) => boolean;\n readonly clear: () => void;\n};\n\nexport function createPluginRegistry(): PluginRegistryApi {\n const plugins = new Map<string, PluginRegistration>();\n let sortedRegistrations: PluginRegistration[] | undefined;\n\n const invalidateSortedRegistrations = (): void => {\n sortedRegistrations = undefined;\n };\n\n return {\n register: (plugin: TypeweaverPlugin, config?: unknown): void => {\n if (plugins.has(plugin.name)) {\n console.info(\n `Skipping duplicate registration of required plugin: ${plugin.name}`\n );\n return;\n }\n\n const registration: PluginRegistration = {\n name: plugin.name,\n plugin,\n config: config as Record<string, unknown>,\n };\n\n plugins.set(plugin.name, registration);\n invalidateSortedRegistrations();\n console.info(`Registered plugin: ${plugin.name}`);\n },\n get: (name: string) => plugins.get(name),\n getAll: () => {\n if (sortedRegistrations === undefined) {\n sortedRegistrations = sortPluginRegistrations(\n Array.from(plugins.values())\n );\n }\n\n return [...sortedRegistrations];\n },\n has: (name: string) => plugins.has(name),\n clear: () => {\n plugins.clear();\n invalidateSortedRegistrations();\n },\n };\n}\n\nfunction sortPluginRegistrations(\n registrations: readonly PluginRegistration[]\n): PluginRegistration[] {\n const registrationsByName = new Map(\n registrations.map(registration => [registration.name, registration])\n );\n const visiting = new Set<string>();\n const visited = new Set<string>();\n const sorted: PluginRegistration[] = [];\n\n for (const registration of registrations) {\n visitPlugin({\n registration,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath: [],\n });\n }\n\n return sorted;\n}\n\nfunction visitPlugin(params: {\n readonly registration: PluginRegistration;\n readonly registrationsByName: ReadonlyMap<string, PluginRegistration>;\n readonly visiting: Set<string>;\n readonly visited: Set<string>;\n readonly sorted: PluginRegistration[];\n readonly dependencyPath: readonly string[];\n}): void {\n const {\n registration,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath,\n } = params;\n\n if (visited.has(registration.name)) {\n return;\n }\n\n if (visiting.has(registration.name)) {\n const cyclePath = [...dependencyPath, registration.name].join(\" -> \");\n throw new PluginDependencyError(\n registration.name,\n registration.name,\n `Detected plugin dependency cycle: ${cyclePath}`\n );\n }\n\n visiting.add(registration.name);\n\n for (const dependencyName of registration.plugin.depends ?? []) {\n const dependency = registrationsByName.get(dependencyName);\n if (dependency === undefined) {\n throw new PluginDependencyError(registration.name, dependencyName);\n }\n\n visitPlugin({\n registration: dependency,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath: [...dependencyPath, registration.name],\n });\n }\n\n visiting.delete(registration.name);\n visited.add(registration.name);\n sorted.push(registration);\n}\n","import path from \"node:path\";\n\nexport function relative(from: string, to: string): string {\n const relativePath = path.relative(from, to);\n\n const posixPath = relativePath.split(path.sep).join(\"/\");\n\n if (\n posixPath === \"..\" ||\n posixPath.startsWith(\"./\") ||\n posixPath.startsWith(\"../\")\n ) {\n return posixPath;\n }\n\n return `./${posixPath}`;\n}\n","function escapeHtml(input: string): string {\n return input\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\");\n}\n\nfunction stringifyTemplateValue(value: unknown): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n\n return String(value);\n}\n\nexport function renderTemplate(\n template: string,\n data: Record<string, unknown>\n): string {\n const outputChunks: string[] = [];\n const expressionPattern = /<%[=-]?[\\s\\S]*?%>/g;\n let currentIndex = 0;\n let match: RegExpExecArray | null = expressionPattern.exec(template);\n\n while (match !== null) {\n const [tag] = match;\n const tagStart = match.index;\n\n outputChunks.push(\n `__output.push(${JSON.stringify(template.slice(currentIndex, tagStart))});`\n );\n\n if (tag.startsWith(\"<%=\")) {\n const expression = tag.slice(3, -2).trim();\n outputChunks.push(`__output.push(__escape(__stringify(${expression})));`);\n } else if (tag.startsWith(\"<%-\")) {\n const expression = tag.slice(3, -2).trim();\n outputChunks.push(`__output.push(__stringify(${expression}));`);\n } else {\n outputChunks.push(tag.slice(2, -2));\n }\n\n currentIndex = tagStart + tag.length;\n match = expressionPattern.exec(template);\n }\n\n outputChunks.push(\n `__output.push(${JSON.stringify(template.slice(currentIndex))});`\n );\n\n const render = new Function(\n \"data\",\n \"__escape\",\n \"__stringify\",\n // This intentionally relies on `new Function()` sloppy mode so `with (data)`\n // can expose template variables as bare identifiers during rendering.\n // The tests pin the expected collision behavior: own properties on `data`\n // (including names like `name` or `toString`) must win over outer built-ins.\n `const __output = []; with (data) { ${outputChunks.join(\"\\n\")} } return __output.join(\"\");`\n ) as (\n data: Record<string, unknown>,\n escape: typeof escapeHtml,\n stringify: typeof stringifyTemplateValue\n ) => string;\n\n return render(data, escapeHtml, stringifyTemplateValue);\n}\n","export class MissingCanonicalResponseError extends Error {\n public override readonly name = \"MissingCanonicalResponseError\";\n\n public constructor(public readonly responseName: string) {\n super(\n `Missing canonical response '${responseName}' in the normalized spec.`\n );\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pascalCase } from \"polycase\";\nimport { relative } from \"../helpers/path.js\";\nimport { renderTemplate } from \"../helpers/templateEngine.js\";\nimport { MissingCanonicalResponseError } from \"./errors/MissingCanonicalResponseError.js\";\nimport type { NormalizedResponse, NormalizedSpec } from \"../NormalizedSpec.js\";\nimport type { GeneratorContext, PluginConfig, PluginContext } from \"./types.js\";\n\ntype SafeGeneratedFilePath = {\n readonly fullPath: string;\n readonly generatedPath: string;\n};\n\ntype FileSystemError = Error & {\n readonly code?: string;\n};\n\nconst WINDOWS_DRIVE_PREFIX_PATTERN = /^[a-zA-Z]:/;\n\nfunction pathContainsParentTraversal(projectPath: string): boolean {\n return projectPath.split(\"/\").includes(\"..\");\n}\n\nfunction pathEndsWithDirectorySeparator(projectPath: string): boolean {\n return projectPath.endsWith(\"/\");\n}\n\nfunction pathNamesCurrentDirectory(projectPath: string): boolean {\n return projectPath === \".\" || projectPath.endsWith(\"/.\");\n}\n\nfunction resolveSafeGeneratedFilePath(\n outputDir: string,\n requestedPath: string\n): SafeGeneratedFilePath {\n if (requestedPath.length === 0) {\n throwUnsafeGeneratedFilePath(requestedPath, \"path must not be empty\");\n }\n\n const projectPath = requestedPath.replace(/\\\\/g, \"/\");\n\n if (\n path.isAbsolute(requestedPath) ||\n path.posix.isAbsolute(projectPath) ||\n path.win32.isAbsolute(requestedPath) ||\n path.win32.isAbsolute(projectPath) ||\n WINDOWS_DRIVE_PREFIX_PATTERN.test(requestedPath)\n ) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"absolute paths are not allowed\"\n );\n }\n\n if (pathContainsParentTraversal(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path contains parent-directory traversal\"\n );\n }\n\n if (pathEndsWithDirectorySeparator(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n if (pathNamesCurrentDirectory(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n const generatedPath = path.posix.normalize(projectPath);\n\n if (generatedPath === \".\") {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n if (pathContainsParentTraversal(generatedPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path contains parent-directory traversal\"\n );\n }\n\n const outputRoot = path.resolve(outputDir);\n const fullPath = path.resolve(outputRoot, toNativePath(generatedPath));\n\n if (!isStrictlyInsidePath(fullPath, outputRoot)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path escapes the output directory\"\n );\n }\n\n assertGeneratedPathHasNoSymlinkComponents({\n outputRoot,\n generatedPath,\n requestedPath,\n });\n\n return { fullPath, generatedPath };\n}\n\nfunction toNativePath(projectPath: string): string {\n return projectPath.split(\"/\").join(path.sep);\n}\n\nfunction assertGeneratedPathHasNoSymlinkComponents(config: {\n readonly outputRoot: string;\n readonly generatedPath: string;\n readonly requestedPath: string;\n}): void {\n assertExistingPathIsNotSymlink(config.outputRoot, config.requestedPath);\n\n let currentPath = config.outputRoot;\n\n for (const segment of config.generatedPath.split(\"/\")) {\n currentPath = path.join(currentPath, segment);\n\n const pathStats = getExistingPathStats(currentPath);\n\n if (pathStats === undefined) {\n return;\n }\n\n assertPathStatsIsNotSymlink(pathStats, config.requestedPath);\n\n if (!pathStats.isDirectory()) {\n return;\n }\n }\n}\n\nfunction assertExistingPathIsNotSymlink(\n absolutePath: string,\n requestedPath: string\n): void {\n const pathStats = getExistingPathStats(absolutePath);\n\n if (pathStats === undefined) {\n return;\n }\n\n assertPathStatsIsNotSymlink(pathStats, requestedPath);\n}\n\nfunction assertPathStatsIsNotSymlink(\n pathStats: fs.Stats,\n requestedPath: string\n): void {\n if (!pathStats.isSymbolicLink()) {\n return;\n }\n\n throwUnsafeGeneratedFilePath(requestedPath, \"path contains a symbolic link\");\n}\n\nfunction getExistingPathStats(absolutePath: string): fs.Stats | undefined {\n try {\n return fs.lstatSync(absolutePath);\n } catch (error) {\n if (isMissingPathError(error)) {\n return undefined;\n }\n\n throw error;\n }\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return [\"ENOENT\", \"ENOTDIR\"].includes((error as FileSystemError).code ?? \"\");\n}\n\nfunction isStrictlyInsidePath(childPath: string, parentPath: string): boolean {\n const relativePath = path.relative(parentPath, childPath);\n\n return (\n relativePath !== \"\" &&\n relativePath !== \"..\" &&\n !relativePath.startsWith(`..${path.sep}`) &&\n !path.isAbsolute(relativePath)\n );\n}\n\nfunction throwUnsafeGeneratedFilePath(\n requestedPath: string,\n reason: string\n): never {\n throw new Error(\n `Unsafe generated file path '${requestedPath}': ${reason}. ` +\n `Generated writes must stay inside the output directory.`\n );\n}\n\nfunction revalidateGeneratedWritePath(\n outputDir: string,\n generatedPath: string\n): SafeGeneratedFilePath {\n return resolveSafeGeneratedFilePath(outputDir, generatedPath);\n}\n\nfunction writeGeneratedFileByReplacingDestination(config: {\n readonly outputDir: string;\n readonly generatedPath: string;\n readonly content: string;\n}): SafeGeneratedFilePath {\n const existingPath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n const existingFileMode = getExistingFileMode(existingPath.fullPath);\n const tempParentPath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n const destinationDir = path.dirname(tempParentPath.fullPath);\n const tempDir = fs.mkdtempSync(path.join(destinationDir, \".typeweaver-\"));\n const tempFile = path.join(tempDir, \"generated.tmp\");\n\n try {\n revalidateGeneratedWritePath(config.outputDir, config.generatedPath);\n fs.writeFileSync(tempFile, config.content, {\n flag: \"wx\",\n mode: existingFileMode ?? 0o666,\n });\n\n if (existingFileMode !== undefined) {\n fs.chmodSync(tempFile, existingFileMode);\n }\n\n const writablePath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n fs.renameSync(tempFile, writablePath.fullPath);\n\n return writablePath;\n } finally {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n}\n\nfunction getExistingFileMode(absolutePath: string): number | undefined {\n const pathStats = getExistingPathStats(absolutePath);\n\n if (pathStats?.isFile() !== true) {\n return undefined;\n }\n\n return pathStats.mode & 0o777;\n}\n\nexport type PluginContextBuilderApi = {\n readonly createPluginContext: (params: {\n outputDir: string;\n inputDir: string;\n config: PluginConfig;\n }) => PluginContext;\n readonly createGeneratorContext: (params: {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n readonly normalizedSpec: NormalizedSpec;\n readonly templateDir: string;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n }) => GeneratorContext;\n readonly getGeneratedFiles: () => string[];\n readonly clearGeneratedFiles: () => void;\n};\n\nexport function createPluginContextBuilder(): PluginContextBuilderApi {\n const generatedFiles = new Set<string>();\n\n const createPluginContext = (params: {\n outputDir: string;\n inputDir: string;\n config: PluginConfig;\n }): PluginContext => {\n return {\n outputDir: params.outputDir,\n inputDir: params.inputDir,\n config: params.config,\n };\n };\n\n const createGeneratorContext = (params: {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n readonly normalizedSpec: NormalizedSpec;\n readonly templateDir: string;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n }): GeneratorContext => {\n const pluginContext = createPluginContext(params);\n const canonicalResponsesByName = new Map<string, NormalizedResponse>(\n params.normalizedSpec.responses.map(response => [response.name, response])\n );\n\n const getResourceOutputDir = (resourceName: string): string => {\n return path.join(params.outputDir, resourceName);\n };\n\n const getOperationOutputPaths = (config: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => {\n const outputDir = getResourceOutputDir(config.resourceName);\n const fileBase = pascalCase(config.operationId);\n const requestFileName = `${fileBase}Request.ts`;\n const responseFileName = `${fileBase}Response.ts`;\n const requestValidationFileName = `${fileBase}RequestValidator.ts`;\n const responseValidationFileName = `${fileBase}ResponseValidator.ts`;\n const clientFileName = `${fileBase}Client.ts`;\n\n return {\n outputDir,\n requestFile: path.join(outputDir, requestFileName),\n requestFileName,\n responseFile: path.join(outputDir, responseFileName),\n responseFileName,\n requestValidationFile: path.join(outputDir, requestValidationFileName),\n requestValidationFileName,\n responseValidationFile: path.join(\n outputDir,\n responseValidationFileName\n ),\n responseValidationFileName,\n clientFile: path.join(outputDir, clientFileName),\n clientFileName,\n };\n };\n\n const getCanonicalResponse = (responseName: string): NormalizedResponse => {\n const response = canonicalResponsesByName.get(responseName);\n\n if (response === undefined) {\n throw new MissingCanonicalResponseError(responseName);\n }\n\n return response;\n };\n\n const getCanonicalResponseOutputFile = (responseName: string): string => {\n return path.join(\n params.responsesOutputDir,\n `${pascalCase(responseName)}Response.ts`\n );\n };\n\n return {\n ...pluginContext,\n normalizedSpec: params.normalizedSpec,\n coreDir: params.coreDir,\n responsesOutputDir: params.responsesOutputDir,\n specOutputDir: params.specOutputDir,\n getCanonicalResponse,\n getCanonicalResponseOutputFile,\n getCanonicalResponseImportPath: config => {\n return relative(\n config.importerDir,\n getCanonicalResponseOutputFile(config.responseName).replace(\n /\\.ts$/,\n \".js\"\n )\n );\n },\n getSpecImportPath: config => {\n return relative(\n config.importerDir,\n path.join(params.specOutputDir, \"spec.js\")\n );\n },\n getOperationDefinitionAccessor: config => {\n return (\n `getOperationDefinition(` +\n `spec, ` +\n `${JSON.stringify(config.resourceName)}, ` +\n `${JSON.stringify(config.operationId)}` +\n `)`\n );\n },\n getOperationOutputPaths,\n getResourceOutputDir,\n\n writeFile: (relativePath: string, content: string) => {\n const safePath = resolveSafeGeneratedFilePath(\n params.outputDir,\n relativePath\n );\n const dir = path.dirname(safePath.fullPath);\n\n fs.mkdirSync(dir, { recursive: true });\n const writablePath = revalidateGeneratedWritePath(\n params.outputDir,\n safePath.generatedPath\n );\n const generatedFile = writeGeneratedFileByReplacingDestination({\n outputDir: params.outputDir,\n generatedPath: writablePath.generatedPath,\n content,\n });\n generatedFiles.add(generatedFile.generatedPath);\n\n console.info(`Generated: ${generatedFile.generatedPath}`);\n },\n\n renderTemplate: (templatePath: string, data: unknown) => {\n const fullTemplatePath = path.isAbsolute(templatePath)\n ? templatePath\n : path.join(params.templateDir, templatePath);\n\n const template = fs.readFileSync(fullTemplatePath, \"utf8\");\n return renderTemplate(\n template,\n (data ?? {}) as Record<string, unknown>\n );\n },\n\n addGeneratedFile: (relativePath: string) => {\n const safePath = resolveSafeGeneratedFilePath(\n params.outputDir,\n relativePath\n );\n\n generatedFiles.add(safePath.generatedPath);\n },\n\n getGeneratedFiles: () => {\n return Array.from(generatedFiles);\n },\n };\n };\n\n return {\n createPluginContext,\n createGeneratorContext,\n getGeneratedFiles: () => Array.from(generatedFiles),\n clearGeneratedFiles: () => generatedFiles.clear(),\n };\n}\n","export type CreateJSDocCommentOptions = {\n readonly indentation?: string;\n};\n\nconst BLOCK_COMMENT_END_PATTERN = /\\*\\//g;\nconst LINE_BREAK_PATTERN = /\\r\\n?/g;\n\nexport function createJSDocComment(\n text: string | undefined,\n options: CreateJSDocCommentOptions = {}\n): string | undefined {\n const normalizedText = text?.replace(LINE_BREAK_PATTERN, \"\\n\");\n const trimmedText = normalizedText?.trim();\n\n if (!trimmedText) return undefined;\n\n const indentation = options.indentation ?? \"\";\n const lines = trimmedText\n .replace(BLOCK_COMMENT_END_PATTERN, \"*\\\\/\")\n .split(\"\\n\");\n\n return [\n `${indentation}/**`,\n ...lines.map(line => `${indentation} * ${line}`),\n `${indentation} */`,\n ].join(\"\\n\");\n}\n","import { HttpMethod } from \"@rexeus/typeweaver-core\";\n\n/**\n * HTTP method priority for route ordering.\n * Lower numbers = higher priority (sorted first).\n */\nconst METHOD_PRIORITY: Record<string, number> = {\n [HttpMethod.GET]: 1,\n [HttpMethod.POST]: 2,\n [HttpMethod.PUT]: 3,\n [HttpMethod.PATCH]: 4,\n [HttpMethod.DELETE]: 5,\n [HttpMethod.OPTIONS]: 6,\n [HttpMethod.HEAD]: 7,\n};\n\n/**\n * Returns the sort priority for an HTTP method.\n * Unrecognized methods default to priority 999.\n */\nexport const getMethodPriority = (method: string): number =>\n METHOD_PRIORITY[method] ?? 999;\n\n/**\n * Compares two path segments for route ordering.\n * Returns negative if a should come before b, positive if after.\n *\n * Order: static segments before parameters, then alphabetically.\n */\nconst comparePathSegments = (a: string, b: string): number => {\n const aIsParam = a.startsWith(\":\");\n const bIsParam = b.startsWith(\":\");\n\n if (aIsParam !== bIsParam) {\n return aIsParam ? 1 : -1;\n }\n\n return a.localeCompare(b);\n};\n\n/**\n * Compares two routes for ordering.\n * Routes are sorted by:\n * 1. Path depth (shallow to deep)\n * 2. Static segments before parameters\n * 3. Alphabetical within same segment type\n * 4. HTTP method priority\n */\nexport const compareRoutes = (\n a: { method: string; path: string },\n b: { method: string; path: string }\n): number => {\n const aSegments = a.path.split(\"/\").filter(Boolean);\n const bSegments = b.path.split(\"/\").filter(Boolean);\n\n if (aSegments.length !== bSegments.length) {\n return aSegments.length - bSegments.length;\n }\n\n for (let i = 0; i < aSegments.length; i++) {\n const cmp = comparePathSegments(aSegments[i]!, bSegments[i]!);\n if (cmp !== 0) {\n return cmp;\n }\n }\n\n return getMethodPriority(a.method) - getMethodPriority(b.method);\n};\n"],"mappings":";;;;;;AAAA,IAAa,4BAAb,cAA+C,MAAM;CACnD,YAAmB,cAAsB;AACvC,QAAM,qBAAqB,aAAa,8BAA8B;AACtE,OAAK,OAAO;;;;;ACHhB,IAAa,4BAAb,cAA+C,MAAM;CACnD,YAA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AAQ;AAEnD,KAAI,UAAU,WAAW,UAAU,OACjC,QAAO,UAAU,SAAS,UAAU;AAGtC,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,MAAM,oBAAoB,UAAU,IAAK,UAAU,GAAI;AAC7D,MAAI,QAAQ,EACV,QAAO;;AAIX,QAAO,kBAAkB,EAAE,OAAO,GAAG,kBAAkB,EAAE,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["isZodObject"],"sources":["../src/errors/DerivedResponseCycleError.ts","../src/errors/DuplicateOperationIdError.ts","../src/errors/DuplicateRouteError.ts","../src/errors/EmptyOperationResponsesError.ts","../src/errors/EmptyResourceOperationsError.ts","../src/errors/EmptySpecResourcesError.ts","../src/errors/InvalidDerivedResponseError.ts","../src/errors/InvalidOperationIdError.ts","../src/errors/InvalidRequestSchemaError.ts","../src/errors/InvalidResourceNameError.ts","../src/errors/MissingDerivedResponseParentError.ts","../src/errors/PathParameterMismatchError.ts","../src/bodyNormalization.ts","../src/helpers/namingUtils.ts","../src/helpers/routePath.ts","../src/validation/derivedResponseValidation.ts","../src/normalizeSpec.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/pluginRegistry.ts","../src/helpers/path.ts","../src/helpers/templateEngine.ts","../src/plugins/errors/MissingCanonicalResponseError.ts","../src/plugins/pluginContext.ts","../src/helpers/jsdoc.ts","../src/helpers/routeSort.ts"],"sourcesContent":["export class DerivedResponseCycleError extends Error {\n public constructor(responseName: string) {\n super(`Derived response '${responseName}' contains a cyclic lineage.`);\n this.name = \"DerivedResponseCycleError\";\n }\n}\n","export class DuplicateOperationIdError extends Error {\n public constructor(operationId: string) {\n super(\n `Operation ID '${operationId}' must be globally unique within a spec.`\n );\n this.name = \"DuplicateOperationIdError\";\n }\n}\n","export class DuplicateRouteError extends Error {\n public constructor(method: string, path: string, normalizedPath: string) {\n super(\n `Route '${method} ${path}' conflicts with an existing route using normalized path '${normalizedPath}'.`\n );\n this.name = \"DuplicateRouteError\";\n }\n}\n","export class EmptyOperationResponsesError extends Error {\n public constructor(operationId: string) {\n super(`Operation '${operationId}' must declare at least one response.`);\n this.name = \"EmptyOperationResponsesError\";\n }\n}\n","export class EmptyResourceOperationsError extends Error {\n public constructor(resourceName: string) {\n super(`Resource '${resourceName}' must contain at least one operation.`);\n this.name = \"EmptyResourceOperationsError\";\n }\n}\n","export class EmptySpecResourcesError extends Error {\n public constructor() {\n super(\"Spec definition must contain at least one resource.\");\n this.name = \"EmptySpecResourcesError\";\n }\n}\n","export class InvalidDerivedResponseError extends Error {\n public constructor(responseName: string) {\n super(\n `Derived response '${responseName}' contains invalid lineage metadata.`\n );\n this.name = \"InvalidDerivedResponseError\";\n }\n}\n","export class InvalidOperationIdError extends Error {\n public constructor(operationId: string) {\n super(\n `Operation ID '${operationId}' is invalid. Use camelCase (preferred) or PascalCase. snake_case and kebab-case are not supported.`\n );\n this.name = \"InvalidOperationIdError\";\n }\n}\n","import type { NormalizedRequest } from \"../NormalizedSpec.js\";\n\nexport class InvalidRequestSchemaError extends Error {\n public constructor(\n operationId: string,\n requestPart: keyof NormalizedRequest\n ) {\n super(\n `Operation '${operationId}' has an invalid request.${requestPart} schema definition.`\n );\n this.name = \"InvalidRequestSchemaError\";\n }\n}\n","export class InvalidResourceNameError extends Error {\n public constructor(resourceName: string) {\n super(\n `Resource name '${resourceName}' is invalid. Use camelCase singular nouns when possible; PascalCase is also supported. snake_case and kebab-case are not supported.`\n );\n this.name = \"InvalidResourceNameError\";\n }\n}\n","export class MissingDerivedResponseParentError extends Error {\n public constructor(responseName: string, parentName: string) {\n super(\n `Derived response '${responseName}' references missing canonical parent '${parentName}'.`\n );\n this.name = \"MissingDerivedResponseParentError\";\n }\n}\n","export class PathParameterMismatchError extends Error {\n public constructor(\n operationId: string,\n path: string,\n pathParams: readonly string[],\n requestParams: readonly string[]\n ) {\n super(\n `Operation '${operationId}' has mismatched path parameters for '${path}'. Path params: [${pathParams.join(\n \", \"\n )}], request.param keys: [${requestParams.join(\", \")}].`\n );\n this.name = \"PathParameterMismatchError\";\n }\n}\n","import type { HttpBodySchema, HttpHeaderSchema } from \"@rexeus/typeweaver-core\";\nimport { z } from \"zod\";\nimport type {\n NormalizedBodyMediaTypeSource,\n NormalizedBodyTransport,\n NormalizedHttpBody,\n NormalizedSpecWarning,\n NormalizedSpecWarningLocation,\n} from \"./NormalizedSpec.js\";\n\nexport type NormalizeBodyInput = {\n readonly bodySchema?: HttpBodySchema;\n readonly headerSchema?: HttpHeaderSchema;\n readonly location: NormalizedSpecWarningLocation;\n};\n\nexport type NormalizeBodyResult = {\n readonly body?: NormalizedHttpBody;\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\ntype ZodObjectWithShape = z.ZodObject<Record<string, z.ZodType>> & {\n readonly shape: Record<string, z.ZodType>;\n};\n\ntype ContentTypeHeaderResult =\n | { readonly kind: \"absent\" }\n | { readonly kind: \"ambiguous\" }\n | { readonly kind: \"literal\"; readonly value: string };\n\ntype ZodTypeDefinition = {\n readonly type?: string;\n readonly innerType?: z.ZodType;\n readonly schema?: z.ZodType;\n readonly in?: z.ZodType;\n readonly out?: z.ZodType;\n};\n\nconst JSON_BODY_SCHEMA_TYPES = new Set([\n \"array\",\n \"boolean\",\n \"enum\",\n \"intersection\",\n \"literal\",\n \"null\",\n \"number\",\n \"object\",\n \"record\",\n \"tuple\",\n \"union\",\n]);\n\nexport const normalizeBody = (\n input: NormalizeBodyInput\n): NormalizeBodyResult => {\n if (input.bodySchema === undefined) {\n return { warnings: [] };\n }\n\n const warnings: NormalizedSpecWarning[] = [];\n const contentTypeHeader = extractContentTypeHeader(input.headerSchema);\n\n if (contentTypeHeader.kind === \"literal\") {\n return {\n body: createNormalizedBody({\n schema: input.bodySchema,\n mediaType: contentTypeHeader.value,\n mediaTypeSource: \"content-type-header\",\n }),\n warnings,\n };\n }\n\n if (contentTypeHeader.kind === \"ambiguous\") {\n warnings.push({\n code: \"ambiguous-content-type-header\",\n message:\n \"Content-Type header is present but does not have one unambiguous literal value; inferred body media type instead.\",\n location: input.location,\n });\n } else {\n warnings.push({\n code: \"missing-content-type-header\",\n message:\n \"Body schema is present without a Content-Type header; inferred body media type from schema.\",\n location: input.location,\n });\n }\n\n const inferred = inferBodyMediaType(input.bodySchema);\n\n if (inferred.mediaTypeSource === \"raw-fallback\") {\n warnings.push({\n code: \"raw-body-media-type-fallback\",\n message:\n \"Body schema does not imply a concrete media type; used application/octet-stream raw transport fallback.\",\n location: input.location,\n });\n }\n\n return {\n body: createNormalizedBody({\n schema: input.bodySchema,\n ...inferred,\n }),\n warnings,\n };\n};\n\nconst createNormalizedBody = (input: {\n readonly schema: HttpBodySchema;\n readonly mediaType: string;\n readonly mediaTypeSource: NormalizedBodyMediaTypeSource;\n}): NormalizedHttpBody => {\n return {\n schema: input.schema,\n mediaType: input.mediaType,\n mediaTypeSource: input.mediaTypeSource,\n transport: resolveTransport(input.mediaType),\n };\n};\n\nconst extractContentTypeHeader = (\n headerSchema: HttpHeaderSchema | undefined\n): ContentTypeHeaderResult => {\n const headerObject = unwrapOptional(headerSchema);\n\n if (headerObject === undefined || !isZodObject(headerObject)) {\n return { kind: \"absent\" };\n }\n\n const contentTypeEntries = Object.entries(headerObject.shape).filter(\n ([headerName]) => headerName.toLowerCase() === \"content-type\"\n );\n\n if (contentTypeEntries.length === 0) {\n return { kind: \"absent\" };\n }\n\n const literalValues = contentTypeEntries.flatMap(([, schema]) =>\n extractStringLiteralValues(schema)\n );\n const distinctValues = new Set(literalValues);\n\n if (contentTypeEntries.length === 1 && distinctValues.size === 1) {\n const [value] = distinctValues;\n\n return value === undefined\n ? { kind: \"ambiguous\" }\n : { kind: \"literal\", value };\n }\n\n return { kind: \"ambiguous\" };\n};\n\nconst inferBodyMediaType = (\n schema: HttpBodySchema\n): {\n readonly mediaType: string;\n readonly mediaTypeSource: NormalizedBodyMediaTypeSource;\n} => {\n const inferenceSchema = unwrapMediaInferenceSchema(schema);\n const schemaType = getSchemaType(inferenceSchema);\n\n if (isTextBodySchema(inferenceSchema)) {\n return { mediaType: \"text/plain\", mediaTypeSource: \"body-schema\" };\n }\n\n if (schemaType === \"any\" || schemaType === \"unknown\") {\n return {\n mediaType: \"application/octet-stream\",\n mediaTypeSource: \"raw-fallback\",\n };\n }\n\n if (schemaType !== undefined && JSON_BODY_SCHEMA_TYPES.has(schemaType)) {\n return { mediaType: \"application/json\", mediaTypeSource: \"body-schema\" };\n }\n\n return {\n mediaType: \"application/octet-stream\",\n mediaTypeSource: \"raw-fallback\",\n };\n};\n\nconst isTextBodySchema = (schema: z.ZodType | undefined): boolean => {\n const schemaType = getSchemaType(schema);\n\n if (schemaType === \"string\") {\n return true;\n }\n\n if (schemaType === \"literal\") {\n const values = literalSchemaValues(schema);\n\n return (\n values.length > 0 && values.every(value => typeof value === \"string\")\n );\n }\n\n if (schemaType === \"enum\") {\n const values = enumSchemaValues(schema);\n\n return (\n values.length > 0 && values.every(value => typeof value === \"string\")\n );\n }\n\n return false;\n};\n\nexport const resolveTransport = (\n mediaType: string\n): NormalizedBodyTransport => {\n const normalizedMediaType = mediaType.split(\";\")[0]?.trim().toLowerCase();\n\n if (\n normalizedMediaType === \"application/json\" ||\n normalizedMediaType?.endsWith(\"+json\") === true\n ) {\n return \"json\";\n }\n\n if (normalizedMediaType?.startsWith(\"text/\") === true) {\n return \"text\";\n }\n\n if (normalizedMediaType === \"application/x-www-form-urlencoded\") {\n return \"form-url-encoded\";\n }\n\n if (normalizedMediaType === \"multipart/form-data\") {\n return \"multipart\";\n }\n\n return \"raw\";\n};\n\nconst unwrapMediaInferenceSchema = (\n schema: z.ZodType | undefined\n): z.ZodType | undefined => {\n const visitedSchemas = new Set<z.ZodType>();\n let current = schema;\n\n while (current !== undefined && !visitedSchemas.has(current)) {\n visitedSchemas.add(current);\n\n const definition = getSchemaDefinition(current);\n const schemaType = definition?.type;\n\n if (\n schemaType === \"optional\" ||\n schemaType === \"nullable\" ||\n schemaType === \"default\" ||\n schemaType === \"catch\" ||\n schemaType === \"prefault\" ||\n schemaType === \"readonly\"\n ) {\n current = definition?.innerType;\n continue;\n }\n\n if (schemaType === \"pipe\") {\n const outputType = getSchemaType(definition?.out);\n\n if (outputType === undefined || outputType === \"transform\") {\n return undefined;\n }\n\n current = definition?.out;\n continue;\n }\n\n if (schemaType === \"effects\") {\n current = definition?.schema;\n continue;\n }\n\n return current;\n }\n\n return current;\n};\n\nconst unwrapOptional = <TSchema extends z.ZodType>(\n schema: TSchema | z.ZodOptional<TSchema> | undefined\n): TSchema | undefined => {\n return schema instanceof z.ZodOptional\n ? (schema.unwrap() as TSchema)\n : schema;\n};\n\nconst isZodObject = (schema: z.ZodType): schema is ZodObjectWithShape => {\n return getSchemaType(schema) === \"object\" && \"shape\" in schema;\n};\n\nconst extractStringLiteralValues = (schema: z.ZodType): readonly string[] => {\n const unwrappedSchema = unwrapOptional(schema);\n\n if (unwrappedSchema === undefined) {\n return [];\n }\n\n if (getSchemaType(unwrappedSchema) === \"literal\") {\n return literalSchemaValues(unwrappedSchema).filter(\n (value): value is string => typeof value === \"string\"\n );\n }\n\n if (getSchemaType(unwrappedSchema) === \"enum\") {\n return enumSchemaValues(unwrappedSchema).filter(\n (value): value is string => typeof value === \"string\"\n );\n }\n\n return [];\n};\n\nconst literalSchemaValues = (\n schema: z.ZodType | undefined\n): readonly unknown[] => {\n const literalSchema = schema as\n | {\n readonly values?: ReadonlySet<unknown>;\n }\n | undefined;\n\n return Array.from(literalSchema?.values ?? []);\n};\n\nconst enumSchemaValues = (\n schema: z.ZodType | undefined\n): readonly unknown[] => {\n const enumSchema = schema as\n | {\n readonly options?: readonly unknown[];\n readonly enum?: Record<string, unknown>;\n readonly def?: {\n readonly entries?: Record<string, unknown>;\n readonly values?: readonly unknown[];\n };\n }\n | undefined;\n\n return (\n enumSchema?.options ??\n enumSchema?.def?.values ??\n Object.values(enumSchema?.def?.entries ?? enumSchema?.enum ?? {})\n );\n};\n\nconst getSchemaType = (schema: z.ZodType | undefined): string | undefined => {\n return getSchemaDefinition(schema)?.type;\n};\n\nconst getSchemaDefinition = (\n schema: z.ZodType | undefined\n): ZodTypeDefinition | undefined => {\n const schemaWithDefinition = schema as\n | {\n readonly def?: ZodTypeDefinition;\n readonly _def?: ZodTypeDefinition;\n }\n | undefined;\n\n return schemaWithDefinition?.def ?? schemaWithDefinition?._def;\n};\n","import { isCamelCase, isPascalCase } from \"polycase\";\n\nconst startsWithDigit = (value: string): boolean => /^[0-9]/u.test(value);\n\nconst isSupportedIdentifierName = (value: string): boolean => {\n if (startsWithDigit(value)) {\n return false;\n }\n\n return isCamelCase(value) || isPascalCase(value);\n};\n\nexport const isSupportedOperationId = (value: string): boolean => {\n return isSupportedIdentifierName(value);\n};\n\nexport const isSupportedResourceName = (value: string): boolean => {\n return isSupportedIdentifierName(value);\n};\n","const PATH_PARAMETER_PATTERN = /:([A-Za-z0-9_]+)/g;\n\nexport const normalizeRoutePath = (path: string): string => {\n const segments = path.split(\"/\").filter(Boolean);\n\n if (segments.length === 0) {\n return \"/\";\n }\n\n return `/${segments.map(segment => (segment.startsWith(\":\") ? \":\" : segment)).join(\"/\")}`;\n};\n\nexport const getPathParameterNames = (path: string): string[] => {\n return Array.from(\n path.matchAll(PATH_PARAMETER_PATTERN),\n match => match[1] as string\n );\n};\n","import {\n HttpStatusCodeNameMap,\n isNamedResponseDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport type {\n ResponseDefinition,\n SpecDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport { normalizeBody } from \"../bodyNormalization.js\";\nimport {\n DerivedResponseCycleError,\n InvalidDerivedResponseError,\n MissingDerivedResponseParentError,\n} from \"../errors/index.js\";\nimport type {\n NormalizedResponse,\n NormalizedSpecWarning,\n NormalizedSpecWarningLocation,\n} from \"../NormalizedSpec.js\";\n\nexport type NormalizeResponseDefinitionResult = {\n readonly response: NormalizedResponse;\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\nexport type CollectCanonicalResponsesResult = {\n readonly responses: Map<string, NormalizedResponse>;\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\nexport const validateDerivedResponseMetadata = (\n response: ResponseDefinition\n): void => {\n const derived = response.derived;\n\n if (derived === undefined) {\n return;\n }\n\n if (derived.parentName === response.name) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n if (derived.lineage.length === 0) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (derived.lineage.at(-1) !== response.name) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (derived.lineage.length !== derived.depth) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (new Set(derived.lineage).size !== derived.lineage.length) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n if (derived.depth > 1 && derived.lineage.at(-2) !== derived.parentName) {\n throw new InvalidDerivedResponseError(response.name);\n }\n};\n\nexport const collectCanonicalResponseDefinitions = (\n definition: SpecDefinition\n): Map<string, ResponseDefinition> => {\n const canonicalResponses = new Map<string, ResponseDefinition>();\n\n for (const resource of Object.values(definition.resources)) {\n for (const operation of resource.operations) {\n for (const response of operation.responses) {\n if (!isNamedResponseDefinition(response)) {\n continue;\n }\n\n validateDerivedResponseMetadata(response);\n\n canonicalResponses.set(response.name, response);\n }\n }\n }\n\n return canonicalResponses;\n};\n\nexport const getDerivedResponseChain = (\n response: ResponseDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): readonly string[] => {\n const chain: string[] = [response.name];\n const visitedResponseNames = new Set(chain);\n let parentName = response.derived?.parentName;\n\n while (parentName !== undefined) {\n if (visitedResponseNames.has(parentName)) {\n throw new DerivedResponseCycleError(response.name);\n }\n\n const parentResponse = canonicalResponses.get(parentName);\n\n if (parentResponse === undefined) {\n throw new MissingDerivedResponseParentError(response.name, parentName);\n }\n\n chain.unshift(parentResponse.name);\n visitedResponseNames.add(parentResponse.name);\n parentName = parentResponse.derived?.parentName;\n }\n\n return chain;\n};\n\nexport const validateDerivedResponseGraph = (\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n for (const response of canonicalResponses.values()) {\n validateDerivedResponseAgainstCanonicalGraph(response, canonicalResponses);\n }\n};\n\nconst validateDerivedResponseAgainstCanonicalGraph = (\n response: ResponseDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n if (response.derived === undefined) {\n return;\n }\n\n const chain = getDerivedResponseChain(response, canonicalResponses);\n const materializedLineage = chain.slice(1);\n\n if (response.derived.depth !== materializedLineage.length) {\n throw new InvalidDerivedResponseError(response.name);\n }\n\n if (\n materializedLineage.length !== response.derived.lineage.length ||\n materializedLineage.some(\n (lineageEntry, index) => lineageEntry !== response.derived?.lineage[index]\n )\n ) {\n throw new InvalidDerivedResponseError(response.name);\n }\n};\n\nconst validateInlineDerivedResponses = (\n definition: SpecDefinition,\n canonicalResponses: ReadonlyMap<string, ResponseDefinition>\n): void => {\n for (const resource of Object.values(definition.resources)) {\n for (const operation of resource.operations) {\n for (const response of operation.responses) {\n if (isNamedResponseDefinition(response)) {\n continue;\n }\n\n validateDerivedResponseMetadata(response);\n validateDerivedResponseAgainstCanonicalGraph(\n response,\n canonicalResponses\n );\n }\n }\n }\n};\n\nexport const normalizeResponseDefinition = (\n response: ResponseDefinition,\n location: Omit<NormalizedSpecWarningLocation, \"part\">\n): NormalizeResponseDefinitionResult => {\n const body = normalizeBody({\n bodySchema: response.body,\n headerSchema: response.header,\n location: { ...location, part: \"response.body\" },\n });\n\n return {\n response: {\n name: response.name,\n statusCode: response.statusCode,\n statusCodeName: HttpStatusCodeNameMap[response.statusCode],\n description: response.description,\n header: response.header,\n body: body.body,\n kind: response.derived === undefined ? \"response\" : \"derived-response\",\n derivedFrom: response.derived?.parentName,\n lineage: response.derived?.lineage,\n depth: response.derived?.depth,\n },\n warnings: body.warnings,\n };\n};\n\nexport const collectCanonicalResponses = (\n definition: SpecDefinition\n): CollectCanonicalResponsesResult => {\n const canonicalResponseDefinitions =\n collectCanonicalResponseDefinitions(definition);\n const warnings: NormalizedSpecWarning[] = [];\n\n validateDerivedResponseGraph(canonicalResponseDefinitions);\n validateInlineDerivedResponses(definition, canonicalResponseDefinitions);\n\n const responses = new Map<string, NormalizedResponse>();\n\n for (const [responseName, response] of canonicalResponseDefinitions) {\n const normalized = normalizeResponseDefinition(response, {\n responseName,\n statusCode: response.statusCode,\n });\n\n responses.set(responseName, normalized.response);\n warnings.push(...normalized.warnings);\n }\n\n return { responses, warnings };\n};\n","import {\n isNamedResponseDefinition,\n validateUniqueResponseNames,\n} from \"@rexeus/typeweaver-core\";\nimport type {\n RequestDefinition,\n ResourceDefinition,\n ResponseDefinition,\n SpecDefinition,\n} from \"@rexeus/typeweaver-core\";\nimport { z } from \"zod\";\nimport { normalizeBody } from \"./bodyNormalization.js\";\nimport {\n DuplicateOperationIdError,\n DuplicateRouteError,\n EmptyOperationResponsesError,\n EmptyResourceOperationsError,\n EmptySpecResourcesError,\n InvalidOperationIdError,\n InvalidRequestSchemaError,\n InvalidResourceNameError,\n PathParameterMismatchError,\n} from \"./errors/index.js\";\nimport {\n isSupportedOperationId,\n isSupportedResourceName,\n} from \"./helpers/namingUtils.js\";\nimport {\n getPathParameterNames,\n normalizeRoutePath,\n} from \"./helpers/routePath.js\";\nimport {\n collectCanonicalResponses,\n normalizeResponseDefinition,\n} from \"./validation/index.js\";\nimport type {\n NormalizedOperation,\n NormalizedRequest,\n NormalizedResponseUsage,\n NormalizedSpec,\n NormalizedSpecWarning,\n} from \"./NormalizedSpec.js\";\n\ntype ValidateRequestResult = {\n readonly request?: NormalizedRequest;\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\ntype NormalizeOperationResponsesResult = {\n readonly responses: readonly NormalizedResponseUsage[];\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\ntype NormalizeOperationResult = {\n readonly operation: NormalizedOperation;\n readonly warnings: readonly NormalizedSpecWarning[];\n};\n\nconst isZodType = (schema: unknown): schema is z.ZodType => {\n return schema instanceof z.ZodType;\n};\n\nconst isZodObject = (\n schema: unknown\n): schema is z.ZodObject<z.core.$ZodShape> => {\n return schema instanceof z.ZodObject;\n};\n\nconst validateRequestSchema = (\n operationId: string,\n requestPart: keyof NormalizedRequest,\n schema: unknown\n): void => {\n if (!isZodType(schema)) {\n throw new InvalidRequestSchemaError(operationId, requestPart);\n }\n\n if (requestPart === \"param\" && !isZodObject(schema)) {\n throw new InvalidRequestSchemaError(operationId, requestPart);\n }\n};\n\nconst validateRequest = (\n resourceName: string,\n operationId: string,\n path: string,\n request: RequestDefinition\n): ValidateRequestResult => {\n if (request.header !== undefined) {\n validateRequestSchema(operationId, \"header\", request.header);\n }\n\n if (request.param !== undefined) {\n validateRequestSchema(operationId, \"param\", request.param);\n }\n\n if (request.query !== undefined) {\n validateRequestSchema(operationId, \"query\", request.query);\n }\n\n if (request.body !== undefined) {\n validateRequestSchema(operationId, \"body\", request.body);\n }\n\n const pathParams = getPathParameterNames(path);\n const requestParams =\n request.param === undefined ? [] : Object.keys(request.param.shape);\n\n if (\n pathParams.length !== requestParams.length ||\n pathParams.some(pathParam => !requestParams.includes(pathParam))\n ) {\n throw new PathParameterMismatchError(\n operationId,\n path,\n pathParams,\n requestParams\n );\n }\n\n if (\n request.header === undefined &&\n request.param === undefined &&\n request.query === undefined &&\n request.body === undefined\n ) {\n return { warnings: [] };\n }\n\n const body = normalizeBody({\n bodySchema: request.body,\n headerSchema: request.header,\n location: { resourceName, operationId, part: \"request.body\" },\n });\n\n return {\n request: {\n header: request.header,\n param: request.param,\n query: request.query,\n body: body.body,\n },\n warnings: body.warnings,\n };\n};\n\nconst normalizeOperationResponses = (\n resourceName: string,\n operationId: string,\n responses: readonly ResponseDefinition[]\n): NormalizeOperationResponsesResult => {\n const warnings: NormalizedSpecWarning[] = [];\n const normalizedResponses = responses.map(response => {\n if (isNamedResponseDefinition(response)) {\n return {\n responseName: response.name,\n source: \"canonical\",\n } satisfies NormalizedResponseUsage;\n }\n\n const normalized = normalizeResponseDefinition(response, {\n resourceName,\n operationId,\n responseName: response.name,\n statusCode: response.statusCode,\n });\n\n warnings.push(...normalized.warnings);\n\n return {\n responseName: response.name,\n source: \"inline\",\n response: normalized.response,\n } satisfies NormalizedResponseUsage;\n });\n\n return { responses: normalizedResponses, warnings };\n};\n\nconst normalizeOperation = (\n resourceName: string,\n operationIds: Set<string>,\n routeKeys: Set<string>,\n operation: ResourceDefinition[\"operations\"][number]\n): NormalizeOperationResult => {\n if (!isSupportedOperationId(operation.operationId)) {\n throw new InvalidOperationIdError(operation.operationId);\n }\n\n if (operationIds.has(operation.operationId)) {\n throw new DuplicateOperationIdError(operation.operationId);\n }\n\n operationIds.add(operation.operationId);\n\n const normalizedPath = normalizeRoutePath(operation.path);\n const routeKey = `${operation.method}:${normalizedPath}`;\n\n if (routeKeys.has(routeKey)) {\n throw new DuplicateRouteError(\n operation.method,\n operation.path,\n normalizedPath\n );\n }\n\n routeKeys.add(routeKey);\n\n if (operation.responses.length === 0) {\n throw new EmptyOperationResponsesError(operation.operationId);\n }\n\n const request = validateRequest(\n resourceName,\n operation.operationId,\n operation.path,\n operation.request\n );\n const responses = normalizeOperationResponses(\n resourceName,\n operation.operationId,\n operation.responses\n );\n\n return {\n operation: {\n operationId: operation.operationId,\n method: operation.method,\n path: operation.path,\n summary: operation.summary,\n request: request.request,\n responses: responses.responses,\n },\n warnings: [...request.warnings, ...responses.warnings],\n };\n};\n\nexport const normalizeSpec = (definition: SpecDefinition): NormalizedSpec => {\n const resourceEntries = Object.entries(definition.resources);\n\n if (resourceEntries.length === 0) {\n throw new EmptySpecResourcesError();\n }\n\n validateUniqueResponseNames(definition.resources);\n const canonicalResponses = collectCanonicalResponses(definition);\n const operationIds = new Set<string>();\n const routeKeys = new Set<string>();\n const warnings: NormalizedSpecWarning[] = [...canonicalResponses.warnings];\n\n return {\n resources: resourceEntries.map(([resourceName, resource]) => {\n if (!isSupportedResourceName(resourceName)) {\n throw new InvalidResourceNameError(resourceName);\n }\n\n if (resource.operations.length === 0) {\n throw new EmptyResourceOperationsError(resourceName);\n }\n\n return {\n name: resourceName,\n operations: resource.operations.map(operation => {\n const normalized = normalizeOperation(\n resourceName,\n operationIds,\n routeKeys,\n operation\n );\n\n warnings.push(...normalized.warnings);\n\n return normalized.operation;\n }),\n };\n }),\n responses: Array.from(canonicalResponses.responses.values()),\n warnings,\n };\n};\n","import type { NormalizedResponse, NormalizedSpec } from \"../NormalizedSpec.js\";\n\n/**\n * Configuration for a typeweaver plugin\n */\nexport type PluginConfig = Record<string, unknown>;\n\n/**\n * Context provided to plugins during initialization and finalization\n */\nexport type PluginContext = {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n};\n\nexport type OperationOutputPaths = {\n readonly outputDir: string;\n readonly requestFile: string;\n readonly requestFileName: string;\n readonly responseFile: string;\n readonly responseFileName: string;\n readonly requestValidationFile: string;\n readonly requestValidationFileName: string;\n readonly responseValidationFile: string;\n readonly responseValidationFileName: string;\n readonly clientFile: string;\n readonly clientFileName: string;\n};\n\n/**\n * Context provided to plugins during generation\n */\nexport type GeneratorContext = PluginContext & {\n readonly normalizedSpec: NormalizedSpec;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n\n readonly getCanonicalResponse: (responseName: string) => NormalizedResponse;\n readonly getCanonicalResponseOutputFile: (responseName: string) => string;\n readonly getCanonicalResponseImportPath: (params: {\n readonly importerDir: string;\n readonly responseName: string;\n }) => string;\n readonly getSpecImportPath: (params: {\n readonly importerDir: string;\n }) => string;\n readonly getOperationDefinitionAccessor: (params: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => string;\n readonly getOperationOutputPaths: (params: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => OperationOutputPaths;\n readonly getResourceOutputDir: (resourceName: string) => string;\n readonly writeFile: (relativePath: string, content: string) => void;\n readonly renderTemplate: (templatePath: string, data: unknown) => string;\n readonly addGeneratedFile: (relativePath: string) => void;\n readonly getGeneratedFiles: () => string[];\n};\n\n/**\n * Plugin metadata\n */\nexport type PluginMetadata = {\n readonly name: string;\n readonly depends?: readonly string[];\n};\n\n/**\n * typeweaver plugin interface\n */\nexport type TypeweaverPlugin = PluginMetadata & {\n /**\n * Initialize the plugin\n * Called before any generation happens\n */\n initialize?(context: PluginContext): Promise<void> | void;\n\n /**\n * Collect and transform resources\n * Allows plugins to modify the resource collection\n */\n collectResources?(\n normalizedSpec: NormalizedSpec\n ): Promise<NormalizedSpec> | NormalizedSpec;\n\n /**\n * Main generation logic\n * Called with all resources and utilities\n */\n generate?(context: GeneratorContext): Promise<void> | void;\n\n /**\n * Finalize the plugin\n * Called after all generation is complete\n */\n finalize?(context: PluginContext): Promise<void> | void;\n};\n\n/**\n * Plugin constructor type\n */\nexport type PluginConstructor = new (config?: PluginConfig) => TypeweaverPlugin;\n\n/**\n * Plugin module export\n */\nexport type PluginModule = {\n default: PluginConstructor;\n};\n\n/**\n * Plugin registration entry\n */\nexport type PluginRegistration = {\n name: string;\n plugin: TypeweaverPlugin;\n config?: PluginConfig;\n};\n\n/**\n * typeweaver configuration\n */\nexport type TypeweaverConfig = {\n input: string;\n output: string;\n plugins?: (string | [string, PluginConfig])[];\n format?: boolean;\n clean?: boolean;\n};\n\n/**\n * Plugin loading error\n */\nexport class PluginLoadError extends Error {\n constructor(\n public pluginName: string,\n message: string\n ) {\n super(`Failed to load plugin '${pluginName}': ${message}`);\n this.name = \"PluginLoadError\";\n }\n}\n\n/**\n * Plugin dependency error\n */\nexport class PluginDependencyError extends Error {\n constructor(\n public pluginName: string,\n public missingDependency: string,\n message?: string\n ) {\n super(\n message ??\n `Plugin '${pluginName}' depends on '${missingDependency}' which is not loaded`\n );\n this.name = \"PluginDependencyError\";\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { NormalizedSpec } from \"../NormalizedSpec.js\";\nimport type {\n GeneratorContext,\n PluginConfig,\n PluginContext,\n TypeweaverPlugin,\n} from \"./types.js\";\n\n/**\n * Base class for typeweaver plugins\n * Provides default implementations and common utilities\n */\nexport abstract class BasePlugin implements TypeweaverPlugin {\n abstract name: string;\n description?: string;\n author?: string;\n depends?: string[];\n\n protected config: PluginConfig;\n\n constructor(config: PluginConfig = {}) {\n this.config = config;\n }\n\n /**\n * Default implementation - override in subclasses if needed\n */\n async initialize(_context: PluginContext): Promise<void> {\n // Default: no initialization needed\n }\n\n /**\n * Default implementation - override in subclasses if needed\n */\n collectResources(normalizedSpec: NormalizedSpec): NormalizedSpec {\n return normalizedSpec;\n }\n\n /**\n * Main generation logic - must be implemented by subclasses\n */\n abstract generate(context: GeneratorContext): Promise<void> | void;\n\n /**\n * Default implementation - override in subclasses if needed\n */\n async finalize(_context: PluginContext): Promise<void> {\n // Default: no finalization needed\n }\n\n protected copyLibFiles(\n context: GeneratorContext,\n libSourceDir: string,\n libNamespace: string\n ): void {\n if (!fs.existsSync(libSourceDir)) return;\n\n const libDir = path.join(context.outputDir, \"lib\", libNamespace);\n\n fs.cpSync(libSourceDir, libDir, { recursive: true });\n\n const libIndexPath = path.join(\"lib\", libNamespace, \"index.ts\");\n if (fs.existsSync(path.join(libDir, \"index.ts\"))) {\n context.addGeneratedFile(libIndexPath);\n }\n }\n}\n","import { PluginDependencyError } from \"./types.js\";\nimport type { PluginRegistration, TypeweaverPlugin } from \"./types.js\";\n\nexport type PluginRegistryApi = {\n readonly register: (plugin: TypeweaverPlugin, config?: unknown) => void;\n readonly get: (name: string) => PluginRegistration | undefined;\n readonly getAll: () => PluginRegistration[];\n readonly has: (name: string) => boolean;\n readonly clear: () => void;\n};\n\nexport function createPluginRegistry(): PluginRegistryApi {\n const plugins = new Map<string, PluginRegistration>();\n let sortedRegistrations: PluginRegistration[] | undefined;\n\n const invalidateSortedRegistrations = (): void => {\n sortedRegistrations = undefined;\n };\n\n return {\n register: (plugin: TypeweaverPlugin, config?: unknown): void => {\n if (plugins.has(plugin.name)) {\n console.info(\n `Skipping duplicate registration of required plugin: ${plugin.name}`\n );\n return;\n }\n\n const registration: PluginRegistration = {\n name: plugin.name,\n plugin,\n config: config as Record<string, unknown>,\n };\n\n plugins.set(plugin.name, registration);\n invalidateSortedRegistrations();\n console.info(`Registered plugin: ${plugin.name}`);\n },\n get: (name: string) => plugins.get(name),\n getAll: () => {\n if (sortedRegistrations === undefined) {\n sortedRegistrations = sortPluginRegistrations(\n Array.from(plugins.values())\n );\n }\n\n return [...sortedRegistrations];\n },\n has: (name: string) => plugins.has(name),\n clear: () => {\n plugins.clear();\n invalidateSortedRegistrations();\n },\n };\n}\n\nfunction sortPluginRegistrations(\n registrations: readonly PluginRegistration[]\n): PluginRegistration[] {\n const registrationsByName = new Map(\n registrations.map(registration => [registration.name, registration])\n );\n const visiting = new Set<string>();\n const visited = new Set<string>();\n const sorted: PluginRegistration[] = [];\n\n for (const registration of registrations) {\n visitPlugin({\n registration,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath: [],\n });\n }\n\n return sorted;\n}\n\nfunction visitPlugin(params: {\n readonly registration: PluginRegistration;\n readonly registrationsByName: ReadonlyMap<string, PluginRegistration>;\n readonly visiting: Set<string>;\n readonly visited: Set<string>;\n readonly sorted: PluginRegistration[];\n readonly dependencyPath: readonly string[];\n}): void {\n const {\n registration,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath,\n } = params;\n\n if (visited.has(registration.name)) {\n return;\n }\n\n if (visiting.has(registration.name)) {\n const cyclePath = [...dependencyPath, registration.name].join(\" -> \");\n throw new PluginDependencyError(\n registration.name,\n registration.name,\n `Detected plugin dependency cycle: ${cyclePath}`\n );\n }\n\n visiting.add(registration.name);\n\n for (const dependencyName of registration.plugin.depends ?? []) {\n const dependency = registrationsByName.get(dependencyName);\n if (dependency === undefined) {\n throw new PluginDependencyError(registration.name, dependencyName);\n }\n\n visitPlugin({\n registration: dependency,\n registrationsByName,\n visiting,\n visited,\n sorted,\n dependencyPath: [...dependencyPath, registration.name],\n });\n }\n\n visiting.delete(registration.name);\n visited.add(registration.name);\n sorted.push(registration);\n}\n","import path from \"node:path\";\n\nexport function relative(from: string, to: string): string {\n const relativePath = path.relative(from, to);\n\n const posixPath = relativePath.split(path.sep).join(\"/\");\n\n if (\n posixPath === \"..\" ||\n posixPath.startsWith(\"./\") ||\n posixPath.startsWith(\"../\")\n ) {\n return posixPath;\n }\n\n return `./${posixPath}`;\n}\n","function escapeHtml(input: string): string {\n return input\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\");\n}\n\nfunction stringifyTemplateValue(value: unknown): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n\n return String(value);\n}\n\nexport function renderTemplate(\n template: string,\n data: Record<string, unknown>\n): string {\n const outputChunks: string[] = [];\n const expressionPattern = /<%[=-]?[\\s\\S]*?%>/g;\n let currentIndex = 0;\n let match: RegExpExecArray | null = expressionPattern.exec(template);\n\n while (match !== null) {\n const [tag] = match;\n const tagStart = match.index;\n\n outputChunks.push(\n `__output.push(${JSON.stringify(template.slice(currentIndex, tagStart))});`\n );\n\n if (tag.startsWith(\"<%=\")) {\n const expression = tag.slice(3, -2).trim();\n outputChunks.push(`__output.push(__escape(__stringify(${expression})));`);\n } else if (tag.startsWith(\"<%-\")) {\n const expression = tag.slice(3, -2).trim();\n outputChunks.push(`__output.push(__stringify(${expression}));`);\n } else {\n outputChunks.push(tag.slice(2, -2));\n }\n\n currentIndex = tagStart + tag.length;\n match = expressionPattern.exec(template);\n }\n\n outputChunks.push(\n `__output.push(${JSON.stringify(template.slice(currentIndex))});`\n );\n\n const render = new Function(\n \"data\",\n \"__escape\",\n \"__stringify\",\n // This intentionally relies on `new Function()` sloppy mode so `with (data)`\n // can expose template variables as bare identifiers during rendering.\n // The tests pin the expected collision behavior: own properties on `data`\n // (including names like `name` or `toString`) must win over outer built-ins.\n `const __output = []; with (data) { ${outputChunks.join(\"\\n\")} } return __output.join(\"\");`\n ) as (\n data: Record<string, unknown>,\n escape: typeof escapeHtml,\n stringify: typeof stringifyTemplateValue\n ) => string;\n\n return render(data, escapeHtml, stringifyTemplateValue);\n}\n","export class MissingCanonicalResponseError extends Error {\n public override readonly name = \"MissingCanonicalResponseError\";\n\n public constructor(public readonly responseName: string) {\n super(\n `Missing canonical response '${responseName}' in the normalized spec.`\n );\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pascalCase } from \"polycase\";\nimport { relative } from \"../helpers/path.js\";\nimport { renderTemplate } from \"../helpers/templateEngine.js\";\nimport { MissingCanonicalResponseError } from \"./errors/MissingCanonicalResponseError.js\";\nimport type { NormalizedResponse, NormalizedSpec } from \"../NormalizedSpec.js\";\nimport type { GeneratorContext, PluginConfig, PluginContext } from \"./types.js\";\n\ntype SafeGeneratedFilePath = {\n readonly fullPath: string;\n readonly generatedPath: string;\n};\n\ntype FileSystemError = Error & {\n readonly code?: string;\n};\n\nconst WINDOWS_DRIVE_PREFIX_PATTERN = /^[a-zA-Z]:/;\n\nfunction pathContainsParentTraversal(projectPath: string): boolean {\n return projectPath.split(\"/\").includes(\"..\");\n}\n\nfunction pathEndsWithDirectorySeparator(projectPath: string): boolean {\n return projectPath.endsWith(\"/\");\n}\n\nfunction pathNamesCurrentDirectory(projectPath: string): boolean {\n return projectPath === \".\" || projectPath.endsWith(\"/.\");\n}\n\nfunction resolveSafeGeneratedFilePath(\n outputDir: string,\n requestedPath: string\n): SafeGeneratedFilePath {\n if (requestedPath.length === 0) {\n throwUnsafeGeneratedFilePath(requestedPath, \"path must not be empty\");\n }\n\n const projectPath = requestedPath.replace(/\\\\/g, \"/\");\n\n if (\n path.isAbsolute(requestedPath) ||\n path.posix.isAbsolute(projectPath) ||\n path.win32.isAbsolute(requestedPath) ||\n path.win32.isAbsolute(projectPath) ||\n WINDOWS_DRIVE_PREFIX_PATTERN.test(requestedPath)\n ) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"absolute paths are not allowed\"\n );\n }\n\n if (pathContainsParentTraversal(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path contains parent-directory traversal\"\n );\n }\n\n if (pathEndsWithDirectorySeparator(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n if (pathNamesCurrentDirectory(projectPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n const generatedPath = path.posix.normalize(projectPath);\n\n if (generatedPath === \".\") {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path must name a file inside the output directory\"\n );\n }\n\n if (pathContainsParentTraversal(generatedPath)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path contains parent-directory traversal\"\n );\n }\n\n const outputRoot = path.resolve(outputDir);\n const fullPath = path.resolve(outputRoot, toNativePath(generatedPath));\n\n if (!isStrictlyInsidePath(fullPath, outputRoot)) {\n throwUnsafeGeneratedFilePath(\n requestedPath,\n \"path escapes the output directory\"\n );\n }\n\n assertGeneratedPathHasNoSymlinkComponents({\n outputRoot,\n generatedPath,\n requestedPath,\n });\n\n return { fullPath, generatedPath };\n}\n\nfunction toNativePath(projectPath: string): string {\n return projectPath.split(\"/\").join(path.sep);\n}\n\nfunction assertGeneratedPathHasNoSymlinkComponents(config: {\n readonly outputRoot: string;\n readonly generatedPath: string;\n readonly requestedPath: string;\n}): void {\n assertExistingPathIsNotSymlink(config.outputRoot, config.requestedPath);\n\n let currentPath = config.outputRoot;\n\n for (const segment of config.generatedPath.split(\"/\")) {\n currentPath = path.join(currentPath, segment);\n\n const pathStats = getExistingPathStats(currentPath);\n\n if (pathStats === undefined) {\n return;\n }\n\n assertPathStatsIsNotSymlink(pathStats, config.requestedPath);\n\n if (!pathStats.isDirectory()) {\n return;\n }\n }\n}\n\nfunction assertExistingPathIsNotSymlink(\n absolutePath: string,\n requestedPath: string\n): void {\n const pathStats = getExistingPathStats(absolutePath);\n\n if (pathStats === undefined) {\n return;\n }\n\n assertPathStatsIsNotSymlink(pathStats, requestedPath);\n}\n\nfunction assertPathStatsIsNotSymlink(\n pathStats: fs.Stats,\n requestedPath: string\n): void {\n if (!pathStats.isSymbolicLink()) {\n return;\n }\n\n throwUnsafeGeneratedFilePath(requestedPath, \"path contains a symbolic link\");\n}\n\nfunction getExistingPathStats(absolutePath: string): fs.Stats | undefined {\n try {\n return fs.lstatSync(absolutePath);\n } catch (error) {\n if (isMissingPathError(error)) {\n return undefined;\n }\n\n throw error;\n }\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return [\"ENOENT\", \"ENOTDIR\"].includes((error as FileSystemError).code ?? \"\");\n}\n\nfunction isStrictlyInsidePath(childPath: string, parentPath: string): boolean {\n const relativePath = path.relative(parentPath, childPath);\n\n return (\n relativePath !== \"\" &&\n relativePath !== \"..\" &&\n !relativePath.startsWith(`..${path.sep}`) &&\n !path.isAbsolute(relativePath)\n );\n}\n\nfunction throwUnsafeGeneratedFilePath(\n requestedPath: string,\n reason: string\n): never {\n throw new Error(\n `Unsafe generated file path '${requestedPath}': ${reason}. ` +\n `Generated writes must stay inside the output directory.`\n );\n}\n\nfunction revalidateGeneratedWritePath(\n outputDir: string,\n generatedPath: string\n): SafeGeneratedFilePath {\n return resolveSafeGeneratedFilePath(outputDir, generatedPath);\n}\n\nfunction writeGeneratedFileByReplacingDestination(config: {\n readonly outputDir: string;\n readonly generatedPath: string;\n readonly content: string;\n}): SafeGeneratedFilePath {\n const existingPath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n const existingFileMode = getExistingFileMode(existingPath.fullPath);\n const tempParentPath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n const destinationDir = path.dirname(tempParentPath.fullPath);\n const tempDir = fs.mkdtempSync(path.join(destinationDir, \".typeweaver-\"));\n const tempFile = path.join(tempDir, \"generated.tmp\");\n\n try {\n revalidateGeneratedWritePath(config.outputDir, config.generatedPath);\n fs.writeFileSync(tempFile, config.content, {\n flag: \"wx\",\n mode: existingFileMode ?? 0o666,\n });\n\n if (existingFileMode !== undefined) {\n fs.chmodSync(tempFile, existingFileMode);\n }\n\n const writablePath = revalidateGeneratedWritePath(\n config.outputDir,\n config.generatedPath\n );\n fs.renameSync(tempFile, writablePath.fullPath);\n\n return writablePath;\n } finally {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n}\n\nfunction getExistingFileMode(absolutePath: string): number | undefined {\n const pathStats = getExistingPathStats(absolutePath);\n\n if (pathStats?.isFile() !== true) {\n return undefined;\n }\n\n return pathStats.mode & 0o777;\n}\n\nexport type PluginContextBuilderApi = {\n readonly createPluginContext: (params: {\n outputDir: string;\n inputDir: string;\n config: PluginConfig;\n }) => PluginContext;\n readonly createGeneratorContext: (params: {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n readonly normalizedSpec: NormalizedSpec;\n readonly templateDir: string;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n }) => GeneratorContext;\n readonly getGeneratedFiles: () => string[];\n readonly clearGeneratedFiles: () => void;\n};\n\nexport function createPluginContextBuilder(): PluginContextBuilderApi {\n const generatedFiles = new Set<string>();\n\n const createPluginContext = (params: {\n outputDir: string;\n inputDir: string;\n config: PluginConfig;\n }): PluginContext => {\n return {\n outputDir: params.outputDir,\n inputDir: params.inputDir,\n config: params.config,\n };\n };\n\n const createGeneratorContext = (params: {\n readonly outputDir: string;\n readonly inputDir: string;\n readonly config: PluginConfig;\n readonly normalizedSpec: NormalizedSpec;\n readonly templateDir: string;\n readonly coreDir: string;\n readonly responsesOutputDir: string;\n readonly specOutputDir: string;\n }): GeneratorContext => {\n const pluginContext = createPluginContext(params);\n const canonicalResponsesByName = new Map<string, NormalizedResponse>(\n params.normalizedSpec.responses.map(response => [response.name, response])\n );\n\n const getResourceOutputDir = (resourceName: string): string => {\n return path.join(params.outputDir, resourceName);\n };\n\n const getOperationOutputPaths = (config: {\n readonly resourceName: string;\n readonly operationId: string;\n }) => {\n const outputDir = getResourceOutputDir(config.resourceName);\n const fileBase = pascalCase(config.operationId);\n const requestFileName = `${fileBase}Request.ts`;\n const responseFileName = `${fileBase}Response.ts`;\n const requestValidationFileName = `${fileBase}RequestValidator.ts`;\n const responseValidationFileName = `${fileBase}ResponseValidator.ts`;\n const clientFileName = `${fileBase}Client.ts`;\n\n return {\n outputDir,\n requestFile: path.join(outputDir, requestFileName),\n requestFileName,\n responseFile: path.join(outputDir, responseFileName),\n responseFileName,\n requestValidationFile: path.join(outputDir, requestValidationFileName),\n requestValidationFileName,\n responseValidationFile: path.join(\n outputDir,\n responseValidationFileName\n ),\n responseValidationFileName,\n clientFile: path.join(outputDir, clientFileName),\n clientFileName,\n };\n };\n\n const getCanonicalResponse = (responseName: string): NormalizedResponse => {\n const response = canonicalResponsesByName.get(responseName);\n\n if (response === undefined) {\n throw new MissingCanonicalResponseError(responseName);\n }\n\n return response;\n };\n\n const getCanonicalResponseOutputFile = (responseName: string): string => {\n return path.join(\n params.responsesOutputDir,\n `${pascalCase(responseName)}Response.ts`\n );\n };\n\n return {\n ...pluginContext,\n normalizedSpec: params.normalizedSpec,\n coreDir: params.coreDir,\n responsesOutputDir: params.responsesOutputDir,\n specOutputDir: params.specOutputDir,\n getCanonicalResponse,\n getCanonicalResponseOutputFile,\n getCanonicalResponseImportPath: config => {\n return relative(\n config.importerDir,\n getCanonicalResponseOutputFile(config.responseName).replace(\n /\\.ts$/,\n \".js\"\n )\n );\n },\n getSpecImportPath: config => {\n return relative(\n config.importerDir,\n path.join(params.specOutputDir, \"spec.js\")\n );\n },\n getOperationDefinitionAccessor: config => {\n return (\n `getOperationDefinition(` +\n `spec, ` +\n `${JSON.stringify(config.resourceName)}, ` +\n `${JSON.stringify(config.operationId)}` +\n `)`\n );\n },\n getOperationOutputPaths,\n getResourceOutputDir,\n\n writeFile: (relativePath: string, content: string) => {\n const safePath = resolveSafeGeneratedFilePath(\n params.outputDir,\n relativePath\n );\n const dir = path.dirname(safePath.fullPath);\n\n fs.mkdirSync(dir, { recursive: true });\n const writablePath = revalidateGeneratedWritePath(\n params.outputDir,\n safePath.generatedPath\n );\n const generatedFile = writeGeneratedFileByReplacingDestination({\n outputDir: params.outputDir,\n generatedPath: writablePath.generatedPath,\n content,\n });\n generatedFiles.add(generatedFile.generatedPath);\n\n console.info(`Generated: ${generatedFile.generatedPath}`);\n },\n\n renderTemplate: (templatePath: string, data: unknown) => {\n const fullTemplatePath = path.isAbsolute(templatePath)\n ? templatePath\n : path.join(params.templateDir, templatePath);\n\n const template = fs.readFileSync(fullTemplatePath, \"utf8\");\n return renderTemplate(\n template,\n (data ?? {}) as Record<string, unknown>\n );\n },\n\n addGeneratedFile: (relativePath: string) => {\n const safePath = resolveSafeGeneratedFilePath(\n params.outputDir,\n relativePath\n );\n\n generatedFiles.add(safePath.generatedPath);\n },\n\n getGeneratedFiles: () => {\n return Array.from(generatedFiles);\n },\n };\n };\n\n return {\n createPluginContext,\n createGeneratorContext,\n getGeneratedFiles: () => Array.from(generatedFiles),\n clearGeneratedFiles: () => generatedFiles.clear(),\n };\n}\n","export type CreateJSDocCommentOptions = {\n readonly indentation?: string;\n};\n\nconst BLOCK_COMMENT_END_PATTERN = /\\*\\//g;\nconst LINE_BREAK_PATTERN = /\\r\\n?/g;\n\nexport function createJSDocComment(\n text: string | undefined,\n options: CreateJSDocCommentOptions = {}\n): string | undefined {\n const normalizedText = text?.replace(LINE_BREAK_PATTERN, \"\\n\");\n const trimmedText = normalizedText?.trim();\n\n if (!trimmedText) return undefined;\n\n const indentation = options.indentation ?? \"\";\n const lines = trimmedText\n .replace(BLOCK_COMMENT_END_PATTERN, \"*\\\\/\")\n .split(\"\\n\");\n\n return [\n `${indentation}/**`,\n ...lines.map(line => `${indentation} * ${line}`),\n `${indentation} */`,\n ].join(\"\\n\");\n}\n","import { HttpMethod } from \"@rexeus/typeweaver-core\";\n\n/**\n * HTTP method priority for route ordering.\n * Lower numbers = higher priority (sorted first).\n */\nconst METHOD_PRIORITY: Record<string, number> = {\n [HttpMethod.GET]: 1,\n [HttpMethod.POST]: 2,\n [HttpMethod.PUT]: 3,\n [HttpMethod.PATCH]: 4,\n [HttpMethod.DELETE]: 5,\n [HttpMethod.OPTIONS]: 6,\n [HttpMethod.HEAD]: 7,\n};\n\n/**\n * Returns the sort priority for an HTTP method.\n * Unrecognized methods default to priority 999.\n */\nexport const getMethodPriority = (method: string): number =>\n METHOD_PRIORITY[method] ?? 999;\n\n/**\n * Compares two path segments for route ordering.\n * Returns negative if a should come before b, positive if after.\n *\n * Order: static segments before parameters, then alphabetically.\n */\nconst comparePathSegments = (a: string, b: string): number => {\n const aIsParam = a.startsWith(\":\");\n const bIsParam = b.startsWith(\":\");\n\n if (aIsParam !== bIsParam) {\n return aIsParam ? 1 : -1;\n }\n\n return a.localeCompare(b);\n};\n\n/**\n * Compares two routes for ordering.\n * Routes are sorted by:\n * 1. Path depth (shallow to deep)\n * 2. Static segments before parameters\n * 3. Alphabetical within same segment type\n * 4. HTTP method priority\n */\nexport const compareRoutes = (\n a: { method: string; path: string },\n b: { method: string; path: string }\n): number => {\n const aSegments = a.path.split(\"/\").filter(Boolean);\n const bSegments = b.path.split(\"/\").filter(Boolean);\n\n if (aSegments.length !== bSegments.length) {\n return aSegments.length - bSegments.length;\n }\n\n for (let i = 0; i < aSegments.length; i++) {\n const cmp = comparePathSegments(aSegments[i]!, bSegments[i]!);\n if (cmp !== 0) {\n return cmp;\n }\n }\n\n return getMethodPriority(a.method) - getMethodPriority(b.method);\n};\n"],"mappings":";;;;;;AAAA,IAAa,4BAAb,cAA+C,MAAM;CACnD,YAAmB,cAAsB;AACvC,QAAM,qBAAqB,aAAa,8BAA8B;AACtE,OAAK,OAAO;;;;;ACHhB,IAAa,4BAAb,cAA+C,MAAM;CACnD,YAAmB,aAAqB;AACtC,QACE,iBAAiB,YAAY,0CAC9B;AACD,OAAK,OAAO;;;;;ACLhB,IAAa,sBAAb,cAAyC,MAA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KAAK;EACzC,MAAM,MAAM,oBAAoB,UAAU,IAAK,UAAU,GAAI;AAC7D,MAAI,QAAQ,EACV,QAAO;;AAIX,QAAO,kBAAkB,EAAE,OAAO,GAAG,kBAAkB,EAAE,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Template-driven engine that turns structured API definitions into production-ready artifacts. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"zod": "^4.3.0",
|
|
51
|
-
"@rexeus/typeweaver-core": "^0.
|
|
51
|
+
"@rexeus/typeweaver-core": "^0.12.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"zod": "^4.3.6",
|
|
55
|
-
"@rexeus/typeweaver-core": "^0.
|
|
55
|
+
"@rexeus/typeweaver-core": "^0.12.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"polycase": "^1.1.0"
|