@zimic/http 0.1.0-canary.17 → 0.1.0-canary.18
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/chunk-7A4JDAZZ.mjs +63 -63
- package/dist/chunk-7A4JDAZZ.mjs.map +1 -1
- package/dist/chunk-VEQ424IU.js +63 -63
- package/dist/chunk-VEQ424IU.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/chunk-7A4JDAZZ.mjs
CHANGED
|
@@ -12,7 +12,7 @@ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name
|
|
|
12
12
|
|
|
13
13
|
// ../zimic-utils/dist/chunk-3O5CS47X.mjs
|
|
14
14
|
function isDefined(value) {
|
|
15
|
-
return value !==
|
|
15
|
+
return value !== void 0 && value !== null;
|
|
16
16
|
}
|
|
17
17
|
__name(isDefined, "isDefined");
|
|
18
18
|
__name2(isDefined, "isDefined");
|
|
@@ -38,13 +38,13 @@ function createNullType() {
|
|
|
38
38
|
}
|
|
39
39
|
__name(createNullType, "createNullType");
|
|
40
40
|
function createImportSpecifier(importName) {
|
|
41
|
-
return ts3.factory.createImportSpecifier(false,
|
|
41
|
+
return ts3.factory.createImportSpecifier(false, void 0, ts3.factory.createIdentifier(importName));
|
|
42
42
|
}
|
|
43
43
|
__name(createImportSpecifier, "createImportSpecifier");
|
|
44
44
|
function createImportDeclaration(importSpecifiers, moduleName, options) {
|
|
45
45
|
return ts3.factory.createImportDeclaration(
|
|
46
|
-
|
|
47
|
-
ts3.factory.createImportClause(options.typeOnly,
|
|
46
|
+
void 0,
|
|
47
|
+
ts3.factory.createImportClause(options.typeOnly, void 0, ts3.factory.createNamedImports(importSpecifiers)),
|
|
48
48
|
ts3.factory.createStringLiteral(moduleName)
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -64,11 +64,11 @@ function createOperationsIdentifier(serviceName) {
|
|
|
64
64
|
}
|
|
65
65
|
__name(createOperationsIdentifier, "createOperationsIdentifier");
|
|
66
66
|
function isOperationsDeclaration(node) {
|
|
67
|
-
return node !==
|
|
67
|
+
return node !== void 0 && ts3.isInterfaceDeclaration(node) && node.name.text === "operations";
|
|
68
68
|
}
|
|
69
69
|
__name(isOperationsDeclaration, "isOperationsDeclaration");
|
|
70
70
|
function isOperation(node) {
|
|
71
|
-
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !==
|
|
71
|
+
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && ts3.isTypeLiteralNode(node.type);
|
|
72
72
|
}
|
|
73
73
|
__name(isOperation, "isOperation");
|
|
74
74
|
function wrapOperationType(type, context) {
|
|
@@ -82,7 +82,7 @@ function wrapOperationType(type, context) {
|
|
|
82
82
|
__name(wrapOperationType, "wrapOperationType");
|
|
83
83
|
function normalizeOperation(operation, context) {
|
|
84
84
|
if (!isOperation(operation)) {
|
|
85
|
-
return
|
|
85
|
+
return void 0;
|
|
86
86
|
}
|
|
87
87
|
const newType = normalizeTypeLiteralMethodType(operation.type, context);
|
|
88
88
|
return ts3.factory.updatePropertySignature(
|
|
@@ -109,7 +109,7 @@ function normalizeOperations(operations, context) {
|
|
|
109
109
|
__name(normalizeOperations, "normalizeOperations");
|
|
110
110
|
function removeOperationIfUnreferenced(operation, context) {
|
|
111
111
|
if (!isOperation(operation)) {
|
|
112
|
-
return
|
|
112
|
+
return void 0;
|
|
113
113
|
}
|
|
114
114
|
const operationName = operation.name.text;
|
|
115
115
|
const isReferenced = context.referencedTypes.operations.has(operationName);
|
|
@@ -117,14 +117,14 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
117
117
|
context.referencedTypes.operations.delete(operationName);
|
|
118
118
|
return operation;
|
|
119
119
|
}
|
|
120
|
-
return
|
|
120
|
+
return void 0;
|
|
121
121
|
}
|
|
122
122
|
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
123
123
|
function removeUnreferencedOperations(operations, context) {
|
|
124
124
|
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
125
125
|
context.referencedTypes.operations.clear();
|
|
126
126
|
if (newMembers.length === 0) {
|
|
127
|
-
return
|
|
127
|
+
return void 0;
|
|
128
128
|
}
|
|
129
129
|
return ts3.factory.updateInterfaceDeclaration(
|
|
130
130
|
operations,
|
|
@@ -139,15 +139,15 @@ __name(removeUnreferencedOperations, "removeUnreferencedOperations");
|
|
|
139
139
|
|
|
140
140
|
// src/typegen/openapi/transform/methods.ts
|
|
141
141
|
function isMethod(node) {
|
|
142
|
-
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !==
|
|
142
|
+
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type));
|
|
143
143
|
}
|
|
144
144
|
__name(isMethod, "isMethod");
|
|
145
145
|
function isMethodMember(node) {
|
|
146
|
-
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !==
|
|
146
|
+
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type) || isNeverType(node.type));
|
|
147
147
|
}
|
|
148
148
|
__name(isMethodMember, "isMethodMember");
|
|
149
149
|
function isRequestMember(node) {
|
|
150
|
-
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !==
|
|
150
|
+
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && !isNeverType(node.type);
|
|
151
151
|
}
|
|
152
152
|
__name(isRequestMember, "isRequestMember");
|
|
153
153
|
function isRequestHeaders(node) {
|
|
@@ -155,7 +155,7 @@ function isRequestHeaders(node) {
|
|
|
155
155
|
}
|
|
156
156
|
__name(isRequestHeaders, "isRequestHeaders");
|
|
157
157
|
function isNormalizedRequestHeaders(node) {
|
|
158
|
-
return isRequestMember(node) && node.name.text === "headers" && ts3.isTypeReferenceNode(node.type) && node.type.typeArguments !==
|
|
158
|
+
return isRequestMember(node) && node.name.text === "headers" && ts3.isTypeReferenceNode(node.type) && node.type.typeArguments !== void 0 && node.type.typeArguments.length === 1 && ts3.isTypeLiteralNode(node.type.typeArguments[0]);
|
|
159
159
|
}
|
|
160
160
|
__name(isNormalizedRequestHeaders, "isNormalizedRequestHeaders");
|
|
161
161
|
function isRequestParameters(node) {
|
|
@@ -167,11 +167,11 @@ function isContentPropertySignature(node) {
|
|
|
167
167
|
}
|
|
168
168
|
__name(isContentPropertySignature, "isContentPropertySignature");
|
|
169
169
|
function isContentMember(node) {
|
|
170
|
-
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !==
|
|
170
|
+
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && !isNeverType(node.type);
|
|
171
171
|
}
|
|
172
172
|
__name(isContentMember, "isContentMember");
|
|
173
173
|
function isResponse(node) {
|
|
174
|
-
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name) || ts3.isNumericLiteral(node.name)) && node.type !==
|
|
174
|
+
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name) || ts3.isNumericLiteral(node.name)) && node.type !== void 0;
|
|
175
175
|
}
|
|
176
176
|
__name(isResponse, "isResponse");
|
|
177
177
|
function removeRedundantNullUnionIfNecessary(type) {
|
|
@@ -221,7 +221,7 @@ function wrapURLEncodedContentType(type, context) {
|
|
|
221
221
|
__name(wrapURLEncodedContentType, "wrapURLEncodedContentType");
|
|
222
222
|
function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
223
223
|
if (!isContentMember(requestBodyMember)) {
|
|
224
|
-
return
|
|
224
|
+
return void 0;
|
|
225
225
|
}
|
|
226
226
|
const newIdentifier = ts3.factory.createIdentifier("body");
|
|
227
227
|
const contentType = requestBodyMember.name.text;
|
|
@@ -258,12 +258,12 @@ function normalizeHeaders(headers, context) {
|
|
|
258
258
|
return false;
|
|
259
259
|
}
|
|
260
260
|
if (ts3.isPropertySignature(header)) {
|
|
261
|
-
return header.type !==
|
|
261
|
+
return header.type !== void 0 && !isUnknownType(header.type);
|
|
262
262
|
}
|
|
263
263
|
return true;
|
|
264
264
|
});
|
|
265
265
|
if (newHeaderMembers.length === 0) {
|
|
266
|
-
return
|
|
266
|
+
return void 0;
|
|
267
267
|
}
|
|
268
268
|
const newHeaders = ts3.factory.updateTypeLiteralNode(headers, ts3.factory.createNodeArray(newHeaderMembers));
|
|
269
269
|
return wrapHeadersType(newHeaders, context);
|
|
@@ -271,11 +271,11 @@ function normalizeHeaders(headers, context) {
|
|
|
271
271
|
__name(normalizeHeaders, "normalizeHeaders");
|
|
272
272
|
function normalizeRequestHeaders(requestHeader, context) {
|
|
273
273
|
if (!isRequestHeaders(requestHeader)) {
|
|
274
|
-
return
|
|
274
|
+
return void 0;
|
|
275
275
|
}
|
|
276
276
|
const newType = normalizeHeaders(requestHeader.type, context);
|
|
277
277
|
if (!newType) {
|
|
278
|
-
return
|
|
278
|
+
return void 0;
|
|
279
279
|
}
|
|
280
280
|
return ts3.factory.updatePropertySignature(
|
|
281
281
|
requestHeader,
|
|
@@ -292,7 +292,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
292
292
|
const contentTypeValue = ts3.factory.createLiteralTypeNode(ts3.factory.createStringLiteral(contentTypeName));
|
|
293
293
|
const newHeaderType = wrapHeadersType(
|
|
294
294
|
ts3.factory.createTypeLiteralNode([
|
|
295
|
-
ts3.factory.createPropertySignature(
|
|
295
|
+
ts3.factory.createPropertySignature(void 0, contentTypeIdentifier, void 0, contentTypeValue),
|
|
296
296
|
...existingHeaderMembers
|
|
297
297
|
]),
|
|
298
298
|
context
|
|
@@ -300,7 +300,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
300
300
|
return ts3.factory.createPropertySignature(
|
|
301
301
|
existingHeader?.modifiers,
|
|
302
302
|
ts3.factory.createIdentifier("headers"),
|
|
303
|
-
|
|
303
|
+
void 0,
|
|
304
304
|
newHeaderType
|
|
305
305
|
);
|
|
306
306
|
}
|
|
@@ -341,7 +341,7 @@ function normalizeRequest(request, context) {
|
|
|
341
341
|
const referencedComponentName = request.type.indexType.literal.text;
|
|
342
342
|
context.pendingActions.components.requests.toMarkBodyAsOptional.add(referencedComponentName);
|
|
343
343
|
}
|
|
344
|
-
return ts3.factory.updatePropertySignature(request, request.modifiers, newIdentifier,
|
|
344
|
+
return ts3.factory.updatePropertySignature(request, request.modifiers, newIdentifier, void 0, newType);
|
|
345
345
|
}
|
|
346
346
|
__name(normalizeRequest, "normalizeRequest");
|
|
347
347
|
function wrapResponseType(type, context) {
|
|
@@ -373,7 +373,7 @@ var NON_NUMERIC_RESPONSE_STATUS_TO_MAPPED_TYPE = {
|
|
|
373
373
|
function normalizeResponse(response, context, options = {}) {
|
|
374
374
|
const { isComponent: isComponent2 = false } = options;
|
|
375
375
|
if (!isResponse(response)) {
|
|
376
|
-
return
|
|
376
|
+
return void 0;
|
|
377
377
|
}
|
|
378
378
|
const newType = normalizeResponseType(response.type, context, {
|
|
379
379
|
isComponent: isComponent2,
|
|
@@ -399,7 +399,7 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
399
399
|
`Warning: Response has a non-standard status code: ${chalk.yellow(response.name.text)}. Consider replacing it with a number (e.g. '200'), a pattern ('1xx', '2xx', '3xx', '4xx', or '5xx'), or 'default'.`,
|
|
400
400
|
{ method: "warn" }
|
|
401
401
|
);
|
|
402
|
-
return
|
|
402
|
+
return void 0;
|
|
403
403
|
}
|
|
404
404
|
context.typeImports.http.add("HttpStatusCode");
|
|
405
405
|
const newIdentifier = ts3.factory.createIdentifier(`[StatusCode in ${mappedType}]`);
|
|
@@ -422,10 +422,10 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
422
422
|
__name(normalizeResponse, "normalizeResponse");
|
|
423
423
|
function normalizeResponses(responses, context) {
|
|
424
424
|
if (isNeverType(responses.type) || !ts3.isTypeLiteralNode(responses.type)) {
|
|
425
|
-
return
|
|
425
|
+
return void 0;
|
|
426
426
|
}
|
|
427
427
|
const newIdentifier = ts3.factory.createIdentifier("response");
|
|
428
|
-
const newQuestionToken =
|
|
428
|
+
const newQuestionToken = void 0;
|
|
429
429
|
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(isDefined_default);
|
|
430
430
|
const sortedNewMembers = Array.from(newMembers).sort((response, otherResponse) => {
|
|
431
431
|
return response.statusCode.value.localeCompare(otherResponse.statusCode.value);
|
|
@@ -478,12 +478,12 @@ function normalizeMethodMember(methodMember, context) {
|
|
|
478
478
|
}
|
|
479
479
|
return methodMember;
|
|
480
480
|
}
|
|
481
|
-
return
|
|
481
|
+
return void 0;
|
|
482
482
|
}
|
|
483
483
|
__name(normalizeMethodMember, "normalizeMethodMember");
|
|
484
484
|
function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
485
485
|
const newIdentifier = ts3.factory.createIdentifier("searchParams");
|
|
486
|
-
const newQuestionToken =
|
|
486
|
+
const newQuestionToken = void 0;
|
|
487
487
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
488
488
|
context.typeImports.http.add("HttpSearchParamsSerialized");
|
|
489
489
|
const serializedWrapper = ts3.factory.createIdentifier("HttpSearchParamsSerialized");
|
|
@@ -499,7 +499,7 @@ function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
|
499
499
|
__name(normalizeRequestQueryWithParameters, "normalizeRequestQueryWithParameters");
|
|
500
500
|
function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
501
501
|
const newIdentifier = ts3.factory.createIdentifier("headers");
|
|
502
|
-
const newQuestionToken =
|
|
502
|
+
const newQuestionToken = void 0;
|
|
503
503
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
504
504
|
context.typeImports.http.add("HttpHeadersSerialized");
|
|
505
505
|
const serializedWrapper = ts3.factory.createIdentifier("HttpHeadersSerialized");
|
|
@@ -515,7 +515,7 @@ function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
|
515
515
|
__name(normalizeRequestHeadersWithParameters, "normalizeRequestHeadersWithParameters");
|
|
516
516
|
function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
517
517
|
if (!isRequestMember(requestMember) || requestMember.name.text === "path") {
|
|
518
|
-
return
|
|
518
|
+
return void 0;
|
|
519
519
|
}
|
|
520
520
|
if (requestMember.name.text === "query") {
|
|
521
521
|
return normalizeRequestQueryWithParameters(requestMember, context);
|
|
@@ -552,15 +552,15 @@ function mergeRequestHeadersMembers(members) {
|
|
|
552
552
|
if (!member || !isNormalizedRequestHeaders(member)) {
|
|
553
553
|
return member;
|
|
554
554
|
}
|
|
555
|
-
if (firstHeadersIndex ===
|
|
555
|
+
if (firstHeadersIndex === void 0 || !mergedHeaders) {
|
|
556
556
|
firstHeadersIndex = index;
|
|
557
557
|
mergedHeaders = member;
|
|
558
558
|
return member;
|
|
559
559
|
}
|
|
560
560
|
mergedHeaders = mergeRequestHeadersMember(mergedHeaders, member);
|
|
561
|
-
return
|
|
561
|
+
return void 0;
|
|
562
562
|
});
|
|
563
|
-
if (firstHeadersIndex !==
|
|
563
|
+
if (firstHeadersIndex !== void 0) {
|
|
564
564
|
mergedHeadersMembers[firstHeadersIndex] = mergedHeaders;
|
|
565
565
|
}
|
|
566
566
|
return mergedHeadersMembers.filter(isDefined_default);
|
|
@@ -576,7 +576,7 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
576
576
|
})
|
|
577
577
|
);
|
|
578
578
|
if (newMembers.length === 0) {
|
|
579
|
-
return
|
|
579
|
+
return void 0;
|
|
580
580
|
}
|
|
581
581
|
return ts3.factory.createTypeLiteralNode(newMembers);
|
|
582
582
|
}
|
|
@@ -595,25 +595,25 @@ function normalizeRequestTypeWithParameters(requestType, methodMembers, context)
|
|
|
595
595
|
__name(normalizeRequestTypeWithParameters, "normalizeRequestTypeWithParameters");
|
|
596
596
|
function normalizeMethodMemberWithParameters(methodMember, methodMembers, context) {
|
|
597
597
|
if (!ts3.isIdentifier(methodMember.name) || !methodMember.type) {
|
|
598
|
-
return
|
|
598
|
+
return void 0;
|
|
599
599
|
}
|
|
600
600
|
if (methodMember.name.text === "request") {
|
|
601
601
|
const newType = normalizeRequestTypeWithParameters(methodMember.type, methodMembers, context);
|
|
602
602
|
if (!newType) {
|
|
603
|
-
return
|
|
603
|
+
return void 0;
|
|
604
604
|
}
|
|
605
605
|
return ts3.factory.updatePropertySignature(
|
|
606
606
|
methodMember,
|
|
607
607
|
methodMember.modifiers,
|
|
608
608
|
methodMember.name,
|
|
609
|
-
|
|
609
|
+
void 0,
|
|
610
610
|
newType
|
|
611
611
|
);
|
|
612
612
|
}
|
|
613
613
|
if (methodMember.name.text === "response") {
|
|
614
614
|
return methodMember;
|
|
615
615
|
}
|
|
616
|
-
return
|
|
616
|
+
return void 0;
|
|
617
617
|
}
|
|
618
618
|
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
619
619
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
@@ -638,17 +638,17 @@ function normalizeIndexedAccessMethodType(methodType, context) {
|
|
|
638
638
|
__name(normalizeIndexedAccessMethodType, "normalizeIndexedAccessMethodType");
|
|
639
639
|
function normalizeMethod(method, context, options) {
|
|
640
640
|
if (!isMethod(method)) {
|
|
641
|
-
return
|
|
641
|
+
return void 0;
|
|
642
642
|
}
|
|
643
643
|
const methodName = method.name.text.toUpperCase();
|
|
644
644
|
if (!HTTP_METHODS.includes(methodName)) {
|
|
645
|
-
return
|
|
645
|
+
return void 0;
|
|
646
646
|
}
|
|
647
647
|
const pathMethodCompareString = `${methodName} ${options.pathName}`;
|
|
648
648
|
const matchesPositiveFilters = context.filters.paths.positive.length === 0 || context.filters.paths.positive.some((filter) => filter.test(pathMethodCompareString));
|
|
649
649
|
const matchesNegativeFilters = context.filters.paths.negative.length > 0 && context.filters.paths.negative.some((filter) => filter.test(pathMethodCompareString));
|
|
650
650
|
if (!matchesPositiveFilters || matchesNegativeFilters) {
|
|
651
|
-
return
|
|
651
|
+
return void 0;
|
|
652
652
|
}
|
|
653
653
|
const newIdentifier = ts3.factory.createIdentifier(methodName);
|
|
654
654
|
const newType = ts3.isTypeLiteralNode(method.type) ? normalizeTypeLiteralMethodType(method.type, context) : normalizeIndexedAccessMethodType(method.type, context);
|
|
@@ -660,11 +660,11 @@ function createPathsIdentifier(serviceName) {
|
|
|
660
660
|
}
|
|
661
661
|
__name(createPathsIdentifier, "createPathsIdentifier");
|
|
662
662
|
function isPathsDeclaration(node) {
|
|
663
|
-
return node !==
|
|
663
|
+
return node !== void 0 && (ts3.isInterfaceDeclaration(node) || ts3.isTypeAliasDeclaration(node)) && node.name.text === "paths";
|
|
664
664
|
}
|
|
665
665
|
__name(isPathsDeclaration, "isPathsDeclaration");
|
|
666
666
|
function isPath(node) {
|
|
667
|
-
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !==
|
|
667
|
+
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type));
|
|
668
668
|
}
|
|
669
669
|
__name(isPath, "isPath");
|
|
670
670
|
function normalizePathNameWithParameters(pathName) {
|
|
@@ -683,7 +683,7 @@ __name(wrapComponentPathType, "wrapComponentPathType");
|
|
|
683
683
|
function normalizePath(path4, context, options = {}) {
|
|
684
684
|
const { isComponent: isComponent2 = false } = options;
|
|
685
685
|
if (!isPath(path4)) {
|
|
686
|
-
return
|
|
686
|
+
return void 0;
|
|
687
687
|
}
|
|
688
688
|
const newPathName = isComponent2 ? path4.name.text : normalizePathNameWithParameters(path4.name.text);
|
|
689
689
|
const newIdentifier = isComponent2 ? path4.name : ts3.factory.createStringLiteral(newPathName);
|
|
@@ -691,7 +691,7 @@ function normalizePath(path4, context, options = {}) {
|
|
|
691
691
|
if (ts3.isTypeLiteralNode(path4.type)) {
|
|
692
692
|
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(isDefined_default);
|
|
693
693
|
if (newMethods.length === 0) {
|
|
694
|
-
return
|
|
694
|
+
return void 0;
|
|
695
695
|
}
|
|
696
696
|
newType = ts3.factory.updateTypeLiteralNode(path4.type, ts3.factory.createNodeArray(newMethods));
|
|
697
697
|
} else {
|
|
@@ -714,7 +714,7 @@ function wrapPathsType(type, context) {
|
|
|
714
714
|
__name(wrapPathsType, "wrapPathsType");
|
|
715
715
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
716
716
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
717
|
-
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name,
|
|
717
|
+
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, void 0, void 0, []) : pathsOrTypeAlias;
|
|
718
718
|
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(isDefined_default);
|
|
719
719
|
const newType = ts3.factory.createTypeLiteralNode(newMembers);
|
|
720
720
|
return ts3.factory.createTypeAliasDeclaration(
|
|
@@ -737,15 +737,15 @@ function createComponentsIdentifier(serviceName) {
|
|
|
737
737
|
__name(createComponentsIdentifier, "createComponentsIdentifier");
|
|
738
738
|
function isComponentsDeclaration(node, context) {
|
|
739
739
|
const componentIdentifiers = ["components", createComponentsIdentifierText(context.serviceName)];
|
|
740
|
-
return node !==
|
|
740
|
+
return node !== void 0 && ts3.isInterfaceDeclaration(node) && componentIdentifiers.includes(node.name.text);
|
|
741
741
|
}
|
|
742
742
|
__name(isComponentsDeclaration, "isComponentsDeclaration");
|
|
743
743
|
function isComponentGroup(node) {
|
|
744
|
-
return ts3.isPropertySignature(node) && node.type !==
|
|
744
|
+
return ts3.isPropertySignature(node) && node.type !== void 0 && ts3.isTypeLiteralNode(node.type) && ts3.isIdentifier(node.name);
|
|
745
745
|
}
|
|
746
746
|
__name(isComponentGroup, "isComponentGroup");
|
|
747
747
|
function isComponent(node) {
|
|
748
|
-
return ts3.isPropertySignature(node) && node.type !==
|
|
748
|
+
return ts3.isPropertySignature(node) && node.type !== void 0 && !isNeverType(node.type) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name));
|
|
749
749
|
}
|
|
750
750
|
__name(isComponent, "isComponent");
|
|
751
751
|
function isRequestComponent(node) {
|
|
@@ -886,7 +886,7 @@ function wrapRequestComponentType(type, context) {
|
|
|
886
886
|
__name(wrapRequestComponentType, "wrapRequestComponentType");
|
|
887
887
|
function normalizeRequestComponent(component, context) {
|
|
888
888
|
if (!isRequestComponent(component)) {
|
|
889
|
-
return
|
|
889
|
+
return void 0;
|
|
890
890
|
}
|
|
891
891
|
const { bodyQuestionToken } = processPendingRequestComponentActions(component, context);
|
|
892
892
|
const newType = normalizeContentType(component.type, context, { bodyQuestionToken });
|
|
@@ -901,7 +901,7 @@ function normalizeRequestComponent(component, context) {
|
|
|
901
901
|
__name(normalizeRequestComponent, "normalizeRequestComponent");
|
|
902
902
|
function normalizeComponent(component, componentGroupName, context) {
|
|
903
903
|
if (!isComponent(component)) {
|
|
904
|
-
return
|
|
904
|
+
return void 0;
|
|
905
905
|
}
|
|
906
906
|
if (componentGroupName === "requests") {
|
|
907
907
|
return normalizeRequestComponent(component, context);
|
|
@@ -924,7 +924,7 @@ function normalizeComponent(component, componentGroupName, context) {
|
|
|
924
924
|
__name(normalizeComponent, "normalizeComponent");
|
|
925
925
|
function normalizeComponentGroup(componentGroup, context) {
|
|
926
926
|
if (!isComponentGroup(componentGroup)) {
|
|
927
|
-
return
|
|
927
|
+
return void 0;
|
|
928
928
|
}
|
|
929
929
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
930
930
|
const newIdentifier = ts3.factory.createIdentifier(componentGroupName);
|
|
@@ -988,7 +988,7 @@ function populateReferencedComponents(components, context) {
|
|
|
988
988
|
__name(populateReferencedComponents, "populateReferencedComponents");
|
|
989
989
|
function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
990
990
|
if (!isComponent(component)) {
|
|
991
|
-
return
|
|
991
|
+
return void 0;
|
|
992
992
|
}
|
|
993
993
|
const componentName = component.name.text;
|
|
994
994
|
const componentPath = `${componentGroupName}.${componentName}`;
|
|
@@ -996,17 +996,17 @@ function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
|
996
996
|
context.referencedTypes.components.delete(componentPath);
|
|
997
997
|
return component;
|
|
998
998
|
}
|
|
999
|
-
return
|
|
999
|
+
return void 0;
|
|
1000
1000
|
}
|
|
1001
1001
|
__name(removeComponentIfUnreferenced, "removeComponentIfUnreferenced");
|
|
1002
1002
|
function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
1003
1003
|
if (!isComponentGroup(componentGroup)) {
|
|
1004
|
-
return
|
|
1004
|
+
return void 0;
|
|
1005
1005
|
}
|
|
1006
1006
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
1007
1007
|
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(isDefined_default);
|
|
1008
1008
|
if (newComponents.length === 0) {
|
|
1009
|
-
return
|
|
1009
|
+
return void 0;
|
|
1010
1010
|
}
|
|
1011
1011
|
return ts3.factory.updatePropertySignature(
|
|
1012
1012
|
componentGroup,
|
|
@@ -1021,7 +1021,7 @@ function removeUnreferencedComponents(components, context) {
|
|
|
1021
1021
|
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1022
1022
|
context.referencedTypes.components.clear();
|
|
1023
1023
|
if (newComponentGroups.length === 0) {
|
|
1024
|
-
return
|
|
1024
|
+
return void 0;
|
|
1025
1025
|
}
|
|
1026
1026
|
return ts3.factory.updateInterfaceDeclaration(
|
|
1027
1027
|
components,
|
|
@@ -1075,7 +1075,7 @@ function parseRawFilter(rawFilter) {
|
|
|
1075
1075
|
logWithPrefix(`Warning: Filter could not be parsed and was ignored: ${chalk.yellow(rawFilter)}`, {
|
|
1076
1076
|
method: "warn"
|
|
1077
1077
|
});
|
|
1078
|
-
return
|
|
1078
|
+
return void 0;
|
|
1079
1079
|
}
|
|
1080
1080
|
const methodFilterGroup = `(?:${filteredMethodsOrWildcard.toUpperCase().replace(/,/g, "|").replace(/\*/g, ".*")}) `;
|
|
1081
1081
|
const isNegativeMatch = filterModifier === "!";
|
|
@@ -1152,7 +1152,7 @@ __name(createImportDeclarations, "createImportDeclarations");
|
|
|
1152
1152
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
1153
1153
|
let cachedImportResult;
|
|
1154
1154
|
return /* @__PURE__ */ __name2(/* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1155
|
-
if (cachedImportResult ===
|
|
1155
|
+
if (cachedImportResult === void 0) {
|
|
1156
1156
|
cachedImportResult = await importModuleDynamically();
|
|
1157
1157
|
}
|
|
1158
1158
|
return cachedImportResult;
|
|
@@ -1233,7 +1233,7 @@ var RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED = ["paths", "webhooks", "operations",
|
|
|
1233
1233
|
function removeUnknownResources(node) {
|
|
1234
1234
|
const isUnknownResource = !node || (ts3.isTypeAliasDeclaration(node) || ts3.isInterfaceDeclaration(node)) && RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED.includes(node.name.text);
|
|
1235
1235
|
if (isUnknownResource) {
|
|
1236
|
-
return
|
|
1236
|
+
return void 0;
|
|
1237
1237
|
}
|
|
1238
1238
|
return node;
|
|
1239
1239
|
}
|
|
@@ -1276,7 +1276,7 @@ async function generateTypesFromOpenAPI({
|
|
|
1276
1276
|
}
|
|
1277
1277
|
const typeOutput = await convertTypesToString(nodes, { includeComments });
|
|
1278
1278
|
const formattedOutput = prepareTypeOutputToSave(typeOutput);
|
|
1279
|
-
const shouldWriteToStdout = outputFilePath ===
|
|
1279
|
+
const shouldWriteToStdout = outputFilePath === void 0;
|
|
1280
1280
|
if (shouldWriteToStdout) {
|
|
1281
1281
|
await writeTypeOutputToStandardOutput(formattedOutput);
|
|
1282
1282
|
} else {
|