@zimic/http 0.1.0-canary.7 → 0.1.1-canary.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/LICENSE.md +1 -1
- package/README.md +173 -179
- package/dist/{chunk-6UNIPPBC.mjs → chunk-C5GWXTO5.mjs} +117 -140
- package/dist/chunk-C5GWXTO5.mjs.map +1 -0
- package/dist/{chunk-343XY3VF.js → chunk-KDDZRZK6.js} +117 -140
- package/dist/chunk-KDDZRZK6.js.map +1 -0
- package/dist/cli.js +9 -9
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.ts +22 -37
- package/dist/index.js +17 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -19
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +13 -13
- package/src/formData/HttpFormData.ts +2 -2
- package/src/formData/types.ts +1 -1
- package/src/headers/HttpHeaders.ts +12 -10
- package/src/headers/types.ts +1 -1
- package/src/pathParams/types.ts +1 -1
- package/src/searchParams/HttpSearchParams.ts +1 -1
- package/src/searchParams/types.ts +1 -1
- package/src/typegen/openapi/generate.ts +1 -2
- package/src/typegen/openapi/transform/components.ts +2 -3
- package/src/typegen/openapi/transform/filters.ts +3 -3
- package/src/typegen/openapi/transform/io.ts +3 -5
- package/src/typegen/openapi/transform/methods.ts +4 -5
- package/src/typegen/openapi/transform/operations.ts +2 -3
- package/src/typegen/openapi/transform/paths.ts +2 -3
- package/src/types/requests.ts +2 -1
- package/src/types/schema.ts +14 -32
- package/src/utils/console.ts +1 -1
- package/src/utils/files.ts +4 -24
- package/src/utils/prettier.ts +1 -1
- package/src/utils/time.ts +1 -1
- package/dist/chunk-343XY3VF.js.map +0 -1
- package/dist/chunk-6UNIPPBC.mjs.map +0 -1
- package/src/types/arrays.d.ts +0 -4
- package/src/types/objects.d.ts +0 -14
- package/src/types/strings.d.ts +0 -9
- package/src/types/utils.ts +0 -40
- package/src/utils/data.ts +0 -13
- package/src/utils/imports.ts +0 -12
- package/src/utils/urls.ts +0 -52
|
@@ -6,15 +6,17 @@ import chalk from 'chalk';
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// ../zimic-utils/dist/chunk-PAWJFY3S.mjs
|
|
10
|
+
var __defProp2 = Object.defineProperty;
|
|
11
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
12
|
+
|
|
13
|
+
// ../zimic-utils/dist/chunk-3O5CS47X.mjs
|
|
10
14
|
function isDefined(value) {
|
|
11
|
-
return value !==
|
|
15
|
+
return value !== void 0 && value !== null;
|
|
12
16
|
}
|
|
13
17
|
__name(isDefined, "isDefined");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
18
|
+
__name2(isDefined, "isDefined");
|
|
19
|
+
var isDefined_default = isDefined;
|
|
18
20
|
function isNeverType(type) {
|
|
19
21
|
return type.kind === ts3.SyntaxKind.NeverKeyword;
|
|
20
22
|
}
|
|
@@ -36,13 +38,13 @@ function createNullType() {
|
|
|
36
38
|
}
|
|
37
39
|
__name(createNullType, "createNullType");
|
|
38
40
|
function createImportSpecifier(importName) {
|
|
39
|
-
return ts3.factory.createImportSpecifier(false,
|
|
41
|
+
return ts3.factory.createImportSpecifier(false, void 0, ts3.factory.createIdentifier(importName));
|
|
40
42
|
}
|
|
41
43
|
__name(createImportSpecifier, "createImportSpecifier");
|
|
42
44
|
function createImportDeclaration(importSpecifiers, moduleName, options) {
|
|
43
45
|
return ts3.factory.createImportDeclaration(
|
|
44
|
-
|
|
45
|
-
ts3.factory.createImportClause(options.typeOnly,
|
|
46
|
+
void 0,
|
|
47
|
+
ts3.factory.createImportClause(options.typeOnly, void 0, ts3.factory.createNamedImports(importSpecifiers)),
|
|
46
48
|
ts3.factory.createStringLiteral(moduleName)
|
|
47
49
|
);
|
|
48
50
|
}
|
|
@@ -50,7 +52,7 @@ __name(createImportDeclaration, "createImportDeclaration");
|
|
|
50
52
|
var HTTP_METHODS = Object.freeze(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
51
53
|
function logWithPrefix(message, options) {
|
|
52
54
|
const { method } = options;
|
|
53
|
-
console[method](chalk.cyan("[zimic]"), message);
|
|
55
|
+
console[method](chalk.cyan("[@zimic/http]"), message);
|
|
54
56
|
}
|
|
55
57
|
__name(logWithPrefix, "logWithPrefix");
|
|
56
58
|
function createOperationsIdentifierText(serviceName) {
|
|
@@ -62,11 +64,11 @@ function createOperationsIdentifier(serviceName) {
|
|
|
62
64
|
}
|
|
63
65
|
__name(createOperationsIdentifier, "createOperationsIdentifier");
|
|
64
66
|
function isOperationsDeclaration(node) {
|
|
65
|
-
return node !==
|
|
67
|
+
return node !== void 0 && ts3.isInterfaceDeclaration(node) && node.name.text === "operations";
|
|
66
68
|
}
|
|
67
69
|
__name(isOperationsDeclaration, "isOperationsDeclaration");
|
|
68
70
|
function isOperation(node) {
|
|
69
|
-
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);
|
|
70
72
|
}
|
|
71
73
|
__name(isOperation, "isOperation");
|
|
72
74
|
function wrapOperationType(type, context) {
|
|
@@ -80,7 +82,7 @@ function wrapOperationType(type, context) {
|
|
|
80
82
|
__name(wrapOperationType, "wrapOperationType");
|
|
81
83
|
function normalizeOperation(operation, context) {
|
|
82
84
|
if (!isOperation(operation)) {
|
|
83
|
-
return
|
|
85
|
+
return void 0;
|
|
84
86
|
}
|
|
85
87
|
const newType = normalizeTypeLiteralMethodType(operation.type, context);
|
|
86
88
|
return ts3.factory.updatePropertySignature(
|
|
@@ -94,7 +96,7 @@ function normalizeOperation(operation, context) {
|
|
|
94
96
|
__name(normalizeOperation, "normalizeOperation");
|
|
95
97
|
function normalizeOperations(operations, context) {
|
|
96
98
|
const newIdentifier = createOperationsIdentifier(context.serviceName);
|
|
97
|
-
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(
|
|
99
|
+
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(isDefined_default);
|
|
98
100
|
return ts3.factory.updateInterfaceDeclaration(
|
|
99
101
|
operations,
|
|
100
102
|
operations.modifiers,
|
|
@@ -107,7 +109,7 @@ function normalizeOperations(operations, context) {
|
|
|
107
109
|
__name(normalizeOperations, "normalizeOperations");
|
|
108
110
|
function removeOperationIfUnreferenced(operation, context) {
|
|
109
111
|
if (!isOperation(operation)) {
|
|
110
|
-
return
|
|
112
|
+
return void 0;
|
|
111
113
|
}
|
|
112
114
|
const operationName = operation.name.text;
|
|
113
115
|
const isReferenced = context.referencedTypes.operations.has(operationName);
|
|
@@ -115,14 +117,14 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
115
117
|
context.referencedTypes.operations.delete(operationName);
|
|
116
118
|
return operation;
|
|
117
119
|
}
|
|
118
|
-
return
|
|
120
|
+
return void 0;
|
|
119
121
|
}
|
|
120
122
|
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
121
123
|
function removeUnreferencedOperations(operations, context) {
|
|
122
|
-
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(
|
|
124
|
+
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
123
125
|
context.referencedTypes.operations.clear();
|
|
124
126
|
if (newMembers.length === 0) {
|
|
125
|
-
return
|
|
127
|
+
return void 0;
|
|
126
128
|
}
|
|
127
129
|
return ts3.factory.updateInterfaceDeclaration(
|
|
128
130
|
operations,
|
|
@@ -137,15 +139,15 @@ __name(removeUnreferencedOperations, "removeUnreferencedOperations");
|
|
|
137
139
|
|
|
138
140
|
// src/typegen/openapi/transform/methods.ts
|
|
139
141
|
function isMethod(node) {
|
|
140
|
-
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));
|
|
141
143
|
}
|
|
142
144
|
__name(isMethod, "isMethod");
|
|
143
145
|
function isMethodMember(node) {
|
|
144
|
-
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));
|
|
145
147
|
}
|
|
146
148
|
__name(isMethodMember, "isMethodMember");
|
|
147
149
|
function isRequestMember(node) {
|
|
148
|
-
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);
|
|
149
151
|
}
|
|
150
152
|
__name(isRequestMember, "isRequestMember");
|
|
151
153
|
function isRequestHeaders(node) {
|
|
@@ -153,7 +155,7 @@ function isRequestHeaders(node) {
|
|
|
153
155
|
}
|
|
154
156
|
__name(isRequestHeaders, "isRequestHeaders");
|
|
155
157
|
function isNormalizedRequestHeaders(node) {
|
|
156
|
-
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]);
|
|
157
159
|
}
|
|
158
160
|
__name(isNormalizedRequestHeaders, "isNormalizedRequestHeaders");
|
|
159
161
|
function isRequestParameters(node) {
|
|
@@ -165,11 +167,11 @@ function isContentPropertySignature(node) {
|
|
|
165
167
|
}
|
|
166
168
|
__name(isContentPropertySignature, "isContentPropertySignature");
|
|
167
169
|
function isContentMember(node) {
|
|
168
|
-
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);
|
|
169
171
|
}
|
|
170
172
|
__name(isContentMember, "isContentMember");
|
|
171
173
|
function isResponse(node) {
|
|
172
|
-
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;
|
|
173
175
|
}
|
|
174
176
|
__name(isResponse, "isResponse");
|
|
175
177
|
function removeRedundantNullUnionIfNecessary(type) {
|
|
@@ -219,7 +221,7 @@ function wrapURLEncodedContentType(type, context) {
|
|
|
219
221
|
__name(wrapURLEncodedContentType, "wrapURLEncodedContentType");
|
|
220
222
|
function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
221
223
|
if (!isContentMember(requestBodyMember)) {
|
|
222
|
-
return
|
|
224
|
+
return void 0;
|
|
223
225
|
}
|
|
224
226
|
const newIdentifier = ts3.factory.createIdentifier("body");
|
|
225
227
|
const contentType = requestBodyMember.name.text;
|
|
@@ -256,12 +258,12 @@ function normalizeHeaders(headers, context) {
|
|
|
256
258
|
return false;
|
|
257
259
|
}
|
|
258
260
|
if (ts3.isPropertySignature(header)) {
|
|
259
|
-
return header.type !==
|
|
261
|
+
return header.type !== void 0 && !isUnknownType(header.type);
|
|
260
262
|
}
|
|
261
263
|
return true;
|
|
262
264
|
});
|
|
263
265
|
if (newHeaderMembers.length === 0) {
|
|
264
|
-
return
|
|
266
|
+
return void 0;
|
|
265
267
|
}
|
|
266
268
|
const newHeaders = ts3.factory.updateTypeLiteralNode(headers, ts3.factory.createNodeArray(newHeaderMembers));
|
|
267
269
|
return wrapHeadersType(newHeaders, context);
|
|
@@ -269,11 +271,11 @@ function normalizeHeaders(headers, context) {
|
|
|
269
271
|
__name(normalizeHeaders, "normalizeHeaders");
|
|
270
272
|
function normalizeRequestHeaders(requestHeader, context) {
|
|
271
273
|
if (!isRequestHeaders(requestHeader)) {
|
|
272
|
-
return
|
|
274
|
+
return void 0;
|
|
273
275
|
}
|
|
274
276
|
const newType = normalizeHeaders(requestHeader.type, context);
|
|
275
277
|
if (!newType) {
|
|
276
|
-
return
|
|
278
|
+
return void 0;
|
|
277
279
|
}
|
|
278
280
|
return ts3.factory.updatePropertySignature(
|
|
279
281
|
requestHeader,
|
|
@@ -290,7 +292,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
290
292
|
const contentTypeValue = ts3.factory.createLiteralTypeNode(ts3.factory.createStringLiteral(contentTypeName));
|
|
291
293
|
const newHeaderType = wrapHeadersType(
|
|
292
294
|
ts3.factory.createTypeLiteralNode([
|
|
293
|
-
ts3.factory.createPropertySignature(
|
|
295
|
+
ts3.factory.createPropertySignature(void 0, contentTypeIdentifier, void 0, contentTypeValue),
|
|
294
296
|
...existingHeaderMembers
|
|
295
297
|
]),
|
|
296
298
|
context
|
|
@@ -298,7 +300,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
298
300
|
return ts3.factory.createPropertySignature(
|
|
299
301
|
existingHeader?.modifiers,
|
|
300
302
|
ts3.factory.createIdentifier("headers"),
|
|
301
|
-
|
|
303
|
+
void 0,
|
|
302
304
|
newHeaderType
|
|
303
305
|
);
|
|
304
306
|
}
|
|
@@ -311,16 +313,15 @@ function normalizeContentType(contentType, context, options) {
|
|
|
311
313
|
if (!ts3.isTypeLiteralNode(contentType)) {
|
|
312
314
|
return contentType;
|
|
313
315
|
}
|
|
314
|
-
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(
|
|
316
|
+
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(isDefined_default);
|
|
315
317
|
const newBodyMembers = contentType.members.flatMap((body) => {
|
|
316
318
|
if (isContentPropertySignature(body)) {
|
|
317
|
-
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(
|
|
319
|
+
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(isDefined_default);
|
|
318
320
|
}
|
|
319
321
|
return [];
|
|
320
322
|
});
|
|
321
|
-
if (newBodyMembers.length
|
|
322
|
-
const
|
|
323
|
-
const newMembers = [newHeader, ...newBodyMemberPropertySignatures].filter(isDefined);
|
|
323
|
+
if (newBodyMembers.length === 0) {
|
|
324
|
+
const newMembers = [newHeader].filter(isDefined_default);
|
|
324
325
|
return ts3.factory.updateTypeLiteralNode(contentType, ts3.factory.createNodeArray(newMembers));
|
|
325
326
|
} else {
|
|
326
327
|
const bodyMemberUnionTypes = newBodyMembers.map((bodyMember) => {
|
|
@@ -340,7 +341,7 @@ function normalizeRequest(request, context) {
|
|
|
340
341
|
const referencedComponentName = request.type.indexType.literal.text;
|
|
341
342
|
context.pendingActions.components.requests.toMarkBodyAsOptional.add(referencedComponentName);
|
|
342
343
|
}
|
|
343
|
-
return ts3.factory.updatePropertySignature(request, request.modifiers, newIdentifier,
|
|
344
|
+
return ts3.factory.updatePropertySignature(request, request.modifiers, newIdentifier, void 0, newType);
|
|
344
345
|
}
|
|
345
346
|
__name(normalizeRequest, "normalizeRequest");
|
|
346
347
|
function wrapResponseType(type, context) {
|
|
@@ -372,7 +373,7 @@ var NON_NUMERIC_RESPONSE_STATUS_TO_MAPPED_TYPE = {
|
|
|
372
373
|
function normalizeResponse(response, context, options = {}) {
|
|
373
374
|
const { isComponent: isComponent2 = false } = options;
|
|
374
375
|
if (!isResponse(response)) {
|
|
375
|
-
return
|
|
376
|
+
return void 0;
|
|
376
377
|
}
|
|
377
378
|
const newType = normalizeResponseType(response.type, context, {
|
|
378
379
|
isComponent: isComponent2,
|
|
@@ -398,7 +399,7 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
398
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'.`,
|
|
399
400
|
{ method: "warn" }
|
|
400
401
|
);
|
|
401
|
-
return
|
|
402
|
+
return void 0;
|
|
402
403
|
}
|
|
403
404
|
context.typeImports.http.add("HttpStatusCode");
|
|
404
405
|
const newIdentifier = ts3.factory.createIdentifier(`[StatusCode in ${mappedType}]`);
|
|
@@ -421,11 +422,11 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
421
422
|
__name(normalizeResponse, "normalizeResponse");
|
|
422
423
|
function normalizeResponses(responses, context) {
|
|
423
424
|
if (isNeverType(responses.type) || !ts3.isTypeLiteralNode(responses.type)) {
|
|
424
|
-
return
|
|
425
|
+
return void 0;
|
|
425
426
|
}
|
|
426
427
|
const newIdentifier = ts3.factory.createIdentifier("response");
|
|
427
|
-
const newQuestionToken =
|
|
428
|
-
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(
|
|
428
|
+
const newQuestionToken = void 0;
|
|
429
|
+
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(isDefined_default);
|
|
429
430
|
const sortedNewMembers = Array.from(newMembers).sort((response, otherResponse) => {
|
|
430
431
|
return response.statusCode.value.localeCompare(otherResponse.statusCode.value);
|
|
431
432
|
});
|
|
@@ -477,12 +478,12 @@ function normalizeMethodMember(methodMember, context) {
|
|
|
477
478
|
}
|
|
478
479
|
return methodMember;
|
|
479
480
|
}
|
|
480
|
-
return
|
|
481
|
+
return void 0;
|
|
481
482
|
}
|
|
482
483
|
__name(normalizeMethodMember, "normalizeMethodMember");
|
|
483
484
|
function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
484
485
|
const newIdentifier = ts3.factory.createIdentifier("searchParams");
|
|
485
|
-
const newQuestionToken =
|
|
486
|
+
const newQuestionToken = void 0;
|
|
486
487
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
487
488
|
context.typeImports.http.add("HttpSearchParamsSerialized");
|
|
488
489
|
const serializedWrapper = ts3.factory.createIdentifier("HttpSearchParamsSerialized");
|
|
@@ -498,7 +499,7 @@ function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
|
498
499
|
__name(normalizeRequestQueryWithParameters, "normalizeRequestQueryWithParameters");
|
|
499
500
|
function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
500
501
|
const newIdentifier = ts3.factory.createIdentifier("headers");
|
|
501
|
-
const newQuestionToken =
|
|
502
|
+
const newQuestionToken = void 0;
|
|
502
503
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
503
504
|
context.typeImports.http.add("HttpHeadersSerialized");
|
|
504
505
|
const serializedWrapper = ts3.factory.createIdentifier("HttpHeadersSerialized");
|
|
@@ -514,7 +515,7 @@ function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
|
514
515
|
__name(normalizeRequestHeadersWithParameters, "normalizeRequestHeadersWithParameters");
|
|
515
516
|
function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
516
517
|
if (!isRequestMember(requestMember) || requestMember.name.text === "path") {
|
|
517
|
-
return
|
|
518
|
+
return void 0;
|
|
518
519
|
}
|
|
519
520
|
if (requestMember.name.text === "query") {
|
|
520
521
|
return normalizeRequestQueryWithParameters(requestMember, context);
|
|
@@ -551,18 +552,18 @@ function mergeRequestHeadersMembers(members) {
|
|
|
551
552
|
if (!member || !isNormalizedRequestHeaders(member)) {
|
|
552
553
|
return member;
|
|
553
554
|
}
|
|
554
|
-
if (firstHeadersIndex ===
|
|
555
|
+
if (firstHeadersIndex === void 0 || !mergedHeaders) {
|
|
555
556
|
firstHeadersIndex = index;
|
|
556
557
|
mergedHeaders = member;
|
|
557
558
|
return member;
|
|
558
559
|
}
|
|
559
560
|
mergedHeaders = mergeRequestHeadersMember(mergedHeaders, member);
|
|
560
|
-
return
|
|
561
|
+
return void 0;
|
|
561
562
|
});
|
|
562
|
-
if (firstHeadersIndex !==
|
|
563
|
+
if (firstHeadersIndex !== void 0) {
|
|
563
564
|
mergedHeadersMembers[firstHeadersIndex] = mergedHeaders;
|
|
564
565
|
}
|
|
565
|
-
return mergedHeadersMembers.filter(
|
|
566
|
+
return mergedHeadersMembers.filter(isDefined_default);
|
|
566
567
|
}
|
|
567
568
|
__name(mergeRequestHeadersMembers, "mergeRequestHeadersMembers");
|
|
568
569
|
function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
@@ -575,48 +576,48 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
575
576
|
})
|
|
576
577
|
);
|
|
577
578
|
if (newMembers.length === 0) {
|
|
578
|
-
return
|
|
579
|
+
return void 0;
|
|
579
580
|
}
|
|
580
581
|
return ts3.factory.createTypeLiteralNode(newMembers);
|
|
581
582
|
}
|
|
582
583
|
__name(mergeRequestAndParameterTypes, "mergeRequestAndParameterTypes");
|
|
583
584
|
function normalizeRequestTypeWithParameters(requestType, methodMembers, context) {
|
|
584
585
|
if (ts3.isUnionTypeNode(requestType)) {
|
|
585
|
-
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(
|
|
586
|
+
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(isDefined_default);
|
|
586
587
|
return ts3.factory.updateUnionTypeNode(requestType, ts3.factory.createNodeArray(newTypes));
|
|
587
588
|
}
|
|
588
589
|
if (ts3.isIndexedAccessTypeNode(requestType)) {
|
|
589
590
|
const newType = normalizeRequestTypeWithParameters(ts3.factory.createTypeLiteralNode([]), methodMembers, context);
|
|
590
|
-
return ts3.factory.createIntersectionTypeNode([requestType, newType].filter(
|
|
591
|
+
return ts3.factory.createIntersectionTypeNode([requestType, newType].filter(isDefined_default));
|
|
591
592
|
}
|
|
592
593
|
return mergeRequestAndParameterTypes(requestType, methodMembers, context);
|
|
593
594
|
}
|
|
594
595
|
__name(normalizeRequestTypeWithParameters, "normalizeRequestTypeWithParameters");
|
|
595
596
|
function normalizeMethodMemberWithParameters(methodMember, methodMembers, context) {
|
|
596
597
|
if (!ts3.isIdentifier(methodMember.name) || !methodMember.type) {
|
|
597
|
-
return
|
|
598
|
+
return void 0;
|
|
598
599
|
}
|
|
599
600
|
if (methodMember.name.text === "request") {
|
|
600
601
|
const newType = normalizeRequestTypeWithParameters(methodMember.type, methodMembers, context);
|
|
601
602
|
if (!newType) {
|
|
602
|
-
return
|
|
603
|
+
return void 0;
|
|
603
604
|
}
|
|
604
605
|
return ts3.factory.updatePropertySignature(
|
|
605
606
|
methodMember,
|
|
606
607
|
methodMember.modifiers,
|
|
607
608
|
methodMember.name,
|
|
608
|
-
|
|
609
|
+
void 0,
|
|
609
610
|
newType
|
|
610
611
|
);
|
|
611
612
|
}
|
|
612
613
|
if (methodMember.name.text === "response") {
|
|
613
614
|
return methodMember;
|
|
614
615
|
}
|
|
615
|
-
return
|
|
616
|
+
return void 0;
|
|
616
617
|
}
|
|
617
618
|
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
618
619
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
619
|
-
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(
|
|
620
|
+
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(isDefined_default).map((member, _index, partialMembers) => normalizeMethodMemberWithParameters(member, partialMembers, context)).filter(isDefined_default);
|
|
620
621
|
return ts3.factory.updateTypeLiteralNode(methodType, ts3.factory.createNodeArray(newMembers));
|
|
621
622
|
}
|
|
622
623
|
__name(normalizeTypeLiteralMethodType, "normalizeTypeLiteralMethodType");
|
|
@@ -637,17 +638,17 @@ function normalizeIndexedAccessMethodType(methodType, context) {
|
|
|
637
638
|
__name(normalizeIndexedAccessMethodType, "normalizeIndexedAccessMethodType");
|
|
638
639
|
function normalizeMethod(method, context, options) {
|
|
639
640
|
if (!isMethod(method)) {
|
|
640
|
-
return
|
|
641
|
+
return void 0;
|
|
641
642
|
}
|
|
642
643
|
const methodName = method.name.text.toUpperCase();
|
|
643
644
|
if (!HTTP_METHODS.includes(methodName)) {
|
|
644
|
-
return
|
|
645
|
+
return void 0;
|
|
645
646
|
}
|
|
646
647
|
const pathMethodCompareString = `${methodName} ${options.pathName}`;
|
|
647
648
|
const matchesPositiveFilters = context.filters.paths.positive.length === 0 || context.filters.paths.positive.some((filter) => filter.test(pathMethodCompareString));
|
|
648
649
|
const matchesNegativeFilters = context.filters.paths.negative.length > 0 && context.filters.paths.negative.some((filter) => filter.test(pathMethodCompareString));
|
|
649
650
|
if (!matchesPositiveFilters || matchesNegativeFilters) {
|
|
650
|
-
return
|
|
651
|
+
return void 0;
|
|
651
652
|
}
|
|
652
653
|
const newIdentifier = ts3.factory.createIdentifier(methodName);
|
|
653
654
|
const newType = ts3.isTypeLiteralNode(method.type) ? normalizeTypeLiteralMethodType(method.type, context) : normalizeIndexedAccessMethodType(method.type, context);
|
|
@@ -659,11 +660,11 @@ function createPathsIdentifier(serviceName) {
|
|
|
659
660
|
}
|
|
660
661
|
__name(createPathsIdentifier, "createPathsIdentifier");
|
|
661
662
|
function isPathsDeclaration(node) {
|
|
662
|
-
return node !==
|
|
663
|
+
return node !== void 0 && (ts3.isInterfaceDeclaration(node) || ts3.isTypeAliasDeclaration(node)) && node.name.text === "paths";
|
|
663
664
|
}
|
|
664
665
|
__name(isPathsDeclaration, "isPathsDeclaration");
|
|
665
666
|
function isPath(node) {
|
|
666
|
-
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));
|
|
667
668
|
}
|
|
668
669
|
__name(isPath, "isPath");
|
|
669
670
|
function normalizePathNameWithParameters(pathName) {
|
|
@@ -682,15 +683,15 @@ __name(wrapComponentPathType, "wrapComponentPathType");
|
|
|
682
683
|
function normalizePath(path4, context, options = {}) {
|
|
683
684
|
const { isComponent: isComponent2 = false } = options;
|
|
684
685
|
if (!isPath(path4)) {
|
|
685
|
-
return
|
|
686
|
+
return void 0;
|
|
686
687
|
}
|
|
687
688
|
const newPathName = isComponent2 ? path4.name.text : normalizePathNameWithParameters(path4.name.text);
|
|
688
689
|
const newIdentifier = isComponent2 ? path4.name : ts3.factory.createStringLiteral(newPathName);
|
|
689
690
|
let newType;
|
|
690
691
|
if (ts3.isTypeLiteralNode(path4.type)) {
|
|
691
|
-
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(
|
|
692
|
+
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(isDefined_default);
|
|
692
693
|
if (newMethods.length === 0) {
|
|
693
|
-
return
|
|
694
|
+
return void 0;
|
|
694
695
|
}
|
|
695
696
|
newType = ts3.factory.updateTypeLiteralNode(path4.type, ts3.factory.createNodeArray(newMethods));
|
|
696
697
|
} else {
|
|
@@ -713,8 +714,8 @@ function wrapPathsType(type, context) {
|
|
|
713
714
|
__name(wrapPathsType, "wrapPathsType");
|
|
714
715
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
715
716
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
716
|
-
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name,
|
|
717
|
-
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(
|
|
717
|
+
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, void 0, void 0, []) : pathsOrTypeAlias;
|
|
718
|
+
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(isDefined_default);
|
|
718
719
|
const newType = ts3.factory.createTypeLiteralNode(newMembers);
|
|
719
720
|
return ts3.factory.createTypeAliasDeclaration(
|
|
720
721
|
paths.modifiers,
|
|
@@ -736,15 +737,15 @@ function createComponentsIdentifier(serviceName) {
|
|
|
736
737
|
__name(createComponentsIdentifier, "createComponentsIdentifier");
|
|
737
738
|
function isComponentsDeclaration(node, context) {
|
|
738
739
|
const componentIdentifiers = ["components", createComponentsIdentifierText(context.serviceName)];
|
|
739
|
-
return node !==
|
|
740
|
+
return node !== void 0 && ts3.isInterfaceDeclaration(node) && componentIdentifiers.includes(node.name.text);
|
|
740
741
|
}
|
|
741
742
|
__name(isComponentsDeclaration, "isComponentsDeclaration");
|
|
742
743
|
function isComponentGroup(node) {
|
|
743
|
-
return ts3.isPropertySignature(node) && node.type !==
|
|
744
|
+
return ts3.isPropertySignature(node) && node.type !== void 0 && ts3.isTypeLiteralNode(node.type) && ts3.isIdentifier(node.name);
|
|
744
745
|
}
|
|
745
746
|
__name(isComponentGroup, "isComponentGroup");
|
|
746
747
|
function isComponent(node) {
|
|
747
|
-
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));
|
|
748
749
|
}
|
|
749
750
|
__name(isComponent, "isComponent");
|
|
750
751
|
function isRequestComponent(node) {
|
|
@@ -885,7 +886,7 @@ function wrapRequestComponentType(type, context) {
|
|
|
885
886
|
__name(wrapRequestComponentType, "wrapRequestComponentType");
|
|
886
887
|
function normalizeRequestComponent(component, context) {
|
|
887
888
|
if (!isRequestComponent(component)) {
|
|
888
|
-
return
|
|
889
|
+
return void 0;
|
|
889
890
|
}
|
|
890
891
|
const { bodyQuestionToken } = processPendingRequestComponentActions(component, context);
|
|
891
892
|
const newType = normalizeContentType(component.type, context, { bodyQuestionToken });
|
|
@@ -900,7 +901,7 @@ function normalizeRequestComponent(component, context) {
|
|
|
900
901
|
__name(normalizeRequestComponent, "normalizeRequestComponent");
|
|
901
902
|
function normalizeComponent(component, componentGroupName, context) {
|
|
902
903
|
if (!isComponent(component)) {
|
|
903
|
-
return
|
|
904
|
+
return void 0;
|
|
904
905
|
}
|
|
905
906
|
if (componentGroupName === "requests") {
|
|
906
907
|
return normalizeRequestComponent(component, context);
|
|
@@ -923,11 +924,11 @@ function normalizeComponent(component, componentGroupName, context) {
|
|
|
923
924
|
__name(normalizeComponent, "normalizeComponent");
|
|
924
925
|
function normalizeComponentGroup(componentGroup, context) {
|
|
925
926
|
if (!isComponentGroup(componentGroup)) {
|
|
926
|
-
return
|
|
927
|
+
return void 0;
|
|
927
928
|
}
|
|
928
929
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
929
930
|
const newIdentifier = ts3.factory.createIdentifier(componentGroupName);
|
|
930
|
-
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(
|
|
931
|
+
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(isDefined_default);
|
|
931
932
|
const newType = ts3.factory.updateTypeLiteralNode(componentGroup.type, ts3.factory.createNodeArray(newComponents));
|
|
932
933
|
return ts3.factory.updatePropertySignature(
|
|
933
934
|
componentGroup,
|
|
@@ -940,7 +941,7 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
940
941
|
__name(normalizeComponentGroup, "normalizeComponentGroup");
|
|
941
942
|
function normalizeComponents(components, context) {
|
|
942
943
|
const newIdentifier = createComponentsIdentifier(context.serviceName);
|
|
943
|
-
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(
|
|
944
|
+
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(isDefined_default);
|
|
944
945
|
return ts3.factory.updateInterfaceDeclaration(
|
|
945
946
|
components,
|
|
946
947
|
components.modifiers,
|
|
@@ -987,7 +988,7 @@ function populateReferencedComponents(components, context) {
|
|
|
987
988
|
__name(populateReferencedComponents, "populateReferencedComponents");
|
|
988
989
|
function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
989
990
|
if (!isComponent(component)) {
|
|
990
|
-
return
|
|
991
|
+
return void 0;
|
|
991
992
|
}
|
|
992
993
|
const componentName = component.name.text;
|
|
993
994
|
const componentPath = `${componentGroupName}.${componentName}`;
|
|
@@ -995,17 +996,17 @@ function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
|
995
996
|
context.referencedTypes.components.delete(componentPath);
|
|
996
997
|
return component;
|
|
997
998
|
}
|
|
998
|
-
return
|
|
999
|
+
return void 0;
|
|
999
1000
|
}
|
|
1000
1001
|
__name(removeComponentIfUnreferenced, "removeComponentIfUnreferenced");
|
|
1001
1002
|
function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
1002
1003
|
if (!isComponentGroup(componentGroup)) {
|
|
1003
|
-
return
|
|
1004
|
+
return void 0;
|
|
1004
1005
|
}
|
|
1005
1006
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
1006
|
-
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(
|
|
1007
|
+
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(isDefined_default);
|
|
1007
1008
|
if (newComponents.length === 0) {
|
|
1008
|
-
return
|
|
1009
|
+
return void 0;
|
|
1009
1010
|
}
|
|
1010
1011
|
return ts3.factory.updatePropertySignature(
|
|
1011
1012
|
componentGroup,
|
|
@@ -1017,10 +1018,10 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
1017
1018
|
}
|
|
1018
1019
|
__name(removeUnreferencedComponentsInGroup, "removeUnreferencedComponentsInGroup");
|
|
1019
1020
|
function removeUnreferencedComponents(components, context) {
|
|
1020
|
-
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(
|
|
1021
|
+
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1021
1022
|
context.referencedTypes.components.clear();
|
|
1022
1023
|
if (newComponentGroups.length === 0) {
|
|
1023
|
-
return
|
|
1024
|
+
return void 0;
|
|
1024
1025
|
}
|
|
1025
1026
|
return ts3.factory.updateInterfaceDeclaration(
|
|
1026
1027
|
components,
|
|
@@ -1039,52 +1040,28 @@ function convertToPascalCase(value) {
|
|
|
1039
1040
|
}
|
|
1040
1041
|
__name(convertToPascalCase, "convertToPascalCase");
|
|
1041
1042
|
|
|
1042
|
-
//
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
__name(this, "InvalidURLError");
|
|
1046
|
-
}
|
|
1047
|
-
constructor(url) {
|
|
1048
|
-
super(`Invalid URL: '${url}'`);
|
|
1049
|
-
this.name = "InvalidURL";
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
function createURLOrThrow(rawURL) {
|
|
1053
|
-
try {
|
|
1054
|
-
const url = new URL(rawURL);
|
|
1055
|
-
Object.defineProperty(url, "raw", {
|
|
1056
|
-
value: rawURL.toString(),
|
|
1057
|
-
writable: false,
|
|
1058
|
-
enumerable: true,
|
|
1059
|
-
configurable: false
|
|
1060
|
-
});
|
|
1061
|
-
return url;
|
|
1062
|
-
} catch {
|
|
1063
|
-
throw new InvalidURLError(rawURL);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
__name(createURLOrThrow, "createURLOrThrow");
|
|
1067
|
-
function createURL(rawURL) {
|
|
1068
|
-
const url = createURLOrThrow(rawURL);
|
|
1069
|
-
return url;
|
|
1070
|
-
}
|
|
1071
|
-
__name(createURL, "createURL");
|
|
1072
|
-
function createFileURL(filePath) {
|
|
1073
|
-
return createURL(`file://${filePath}`);
|
|
1043
|
+
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
1044
|
+
function isNonEmpty(value) {
|
|
1045
|
+
return isDefined_default(value) && value !== "";
|
|
1074
1046
|
}
|
|
1075
|
-
__name(
|
|
1047
|
+
__name(isNonEmpty, "isNonEmpty");
|
|
1048
|
+
__name2(isNonEmpty, "isNonEmpty");
|
|
1049
|
+
var isNonEmpty_default = isNonEmpty;
|
|
1050
|
+
|
|
1051
|
+
// ../zimic-utils/dist/url/createRegExpFromWildcardPath.mjs
|
|
1076
1052
|
function prepareURLForRegex(url) {
|
|
1077
1053
|
const encodedURL = encodeURI(url);
|
|
1078
1054
|
return encodedURL.replace(/([.()*?+$\\])/g, "\\$1");
|
|
1079
1055
|
}
|
|
1080
1056
|
__name(prepareURLForRegex, "prepareURLForRegex");
|
|
1081
|
-
|
|
1057
|
+
__name2(prepareURLForRegex, "prepareURLForRegex");
|
|
1058
|
+
function createRegExpFromWildcardPath(path4, options) {
|
|
1082
1059
|
const pathWithReplacedWildcards = prepareURLForRegex(path4).replace(/^\/+|\/+$/g, "").replace(/\\\*/g, "*").replace(/\*\*\/\*/g, "**").replace(/(^|[^*])\*([^*]|$)/g, "$1[^/]*$2").replace(/\*\*/g, ".*");
|
|
1083
1060
|
return new RegExp(`^${options.prefix}/*${pathWithReplacedWildcards}/*$`);
|
|
1084
1061
|
}
|
|
1085
|
-
__name(
|
|
1086
|
-
|
|
1087
|
-
|
|
1062
|
+
__name(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1063
|
+
__name2(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1064
|
+
var createRegExpFromWildcardPath_default = createRegExpFromWildcardPath;
|
|
1088
1065
|
var HTTP_METHOD_OPTIONS = HTTP_METHODS.join("|");
|
|
1089
1066
|
var MODIFIER_GROUP = "(?<modifier>!?)";
|
|
1090
1067
|
var METHOD_FILTER_GROUP = `(?<method>(?:\\*|(?:${HTTP_METHOD_OPTIONS})(?:,\\s*(?:${HTTP_METHOD_OPTIONS}))*))`;
|
|
@@ -1098,12 +1075,12 @@ function parseRawFilter(rawFilter) {
|
|
|
1098
1075
|
logWithPrefix(`Warning: Filter could not be parsed and was ignored: ${chalk.yellow(rawFilter)}`, {
|
|
1099
1076
|
method: "warn"
|
|
1100
1077
|
});
|
|
1101
|
-
return
|
|
1078
|
+
return void 0;
|
|
1102
1079
|
}
|
|
1103
1080
|
const methodFilterGroup = `(?:${filteredMethodsOrWildcard.toUpperCase().replace(/,/g, "|").replace(/\*/g, ".*")}) `;
|
|
1104
1081
|
const isNegativeMatch = filterModifier === "!";
|
|
1105
1082
|
return {
|
|
1106
|
-
expression:
|
|
1083
|
+
expression: createRegExpFromWildcardPath_default(filteredPath, { prefix: methodFilterGroup }),
|
|
1107
1084
|
isNegativeMatch
|
|
1108
1085
|
};
|
|
1109
1086
|
}
|
|
@@ -1132,7 +1109,7 @@ async function readPathFiltersFromFile(filePath) {
|
|
|
1132
1109
|
}
|
|
1133
1110
|
__name(readPathFiltersFromFile, "readPathFiltersFromFile");
|
|
1134
1111
|
function ignoreEmptyFilters(filters) {
|
|
1135
|
-
return filters.map((line) => line.trim()).filter(
|
|
1112
|
+
return filters.map((line) => line.trim()).filter(isNonEmpty_default);
|
|
1136
1113
|
}
|
|
1137
1114
|
__name(ignoreEmptyFilters, "ignoreEmptyFilters");
|
|
1138
1115
|
|
|
@@ -1171,20 +1148,20 @@ function createImportDeclarations(context) {
|
|
|
1171
1148
|
}
|
|
1172
1149
|
__name(createImportDeclarations, "createImportDeclarations");
|
|
1173
1150
|
|
|
1174
|
-
//
|
|
1151
|
+
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
1175
1152
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
1176
1153
|
let cachedImportResult;
|
|
1177
|
-
return /* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1178
|
-
if (cachedImportResult ===
|
|
1154
|
+
return /* @__PURE__ */ __name2(/* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1155
|
+
if (cachedImportResult === void 0) {
|
|
1179
1156
|
cachedImportResult = await importModuleDynamically();
|
|
1180
1157
|
}
|
|
1181
1158
|
return cachedImportResult;
|
|
1182
|
-
}, "importModuleDynamicallyWithCache");
|
|
1159
|
+
}, "importModuleDynamicallyWithCache"), "importModuleDynamicallyWithCache");
|
|
1183
1160
|
}
|
|
1184
1161
|
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
var importOpenapiTypeScript =
|
|
1162
|
+
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1163
|
+
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
1164
|
+
var importOpenapiTypeScript = createCachedDynamicImport_default(() => import('openapi-typescript'));
|
|
1188
1165
|
function transformSchemaObject(schemaObject) {
|
|
1189
1166
|
if (schemaObject.format === "binary") {
|
|
1190
1167
|
const blobType = createBlobType();
|
|
@@ -1198,9 +1175,9 @@ function transformSchemaObject(schemaObject) {
|
|
|
1198
1175
|
__name(transformSchemaObject, "transformSchemaObject");
|
|
1199
1176
|
function convertFilePathOrURLToURL(filePathOrURL) {
|
|
1200
1177
|
try {
|
|
1201
|
-
return
|
|
1178
|
+
return new URL(filePathOrURL);
|
|
1202
1179
|
} catch {
|
|
1203
|
-
return
|
|
1180
|
+
return new URL(`file://${path.resolve(filePathOrURL)}`);
|
|
1204
1181
|
}
|
|
1205
1182
|
}
|
|
1206
1183
|
__name(convertFilePathOrURLToURL, "convertFilePathOrURLToURL");
|
|
@@ -1256,7 +1233,7 @@ var RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED = ["paths", "webhooks", "operations",
|
|
|
1256
1233
|
function removeUnknownResources(node) {
|
|
1257
1234
|
const isUnknownResource = !node || (ts3.isTypeAliasDeclaration(node) || ts3.isInterfaceDeclaration(node)) && RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED.includes(node.name.text);
|
|
1258
1235
|
if (isUnknownResource) {
|
|
1259
|
-
return
|
|
1236
|
+
return void 0;
|
|
1260
1237
|
}
|
|
1261
1238
|
return node;
|
|
1262
1239
|
}
|
|
@@ -1264,18 +1241,18 @@ __name(removeUnknownResources, "removeUnknownResources");
|
|
|
1264
1241
|
function normalizeRawNodes(rawNodes, context, options) {
|
|
1265
1242
|
let normalizedNodes = rawNodes.map((node) => isPathsDeclaration(node) ? normalizePaths(node, context) : node);
|
|
1266
1243
|
if (options.prune) {
|
|
1267
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(
|
|
1244
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(isDefined_default);
|
|
1268
1245
|
}
|
|
1269
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(
|
|
1246
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(isDefined_default);
|
|
1270
1247
|
if (options.prune) {
|
|
1271
1248
|
for (const node of normalizedNodes) {
|
|
1272
1249
|
if (isComponentsDeclaration(node, context)) {
|
|
1273
1250
|
populateReferencedComponents(node, context);
|
|
1274
1251
|
}
|
|
1275
1252
|
}
|
|
1276
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(
|
|
1253
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(isDefined_default);
|
|
1277
1254
|
}
|
|
1278
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(
|
|
1255
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(isDefined_default);
|
|
1279
1256
|
return normalizedNodes;
|
|
1280
1257
|
}
|
|
1281
1258
|
__name(normalizeRawNodes, "normalizeRawNodes");
|
|
@@ -1299,7 +1276,7 @@ async function generateTypesFromOpenAPI({
|
|
|
1299
1276
|
}
|
|
1300
1277
|
const typeOutput = await convertTypesToString(nodes, { includeComments });
|
|
1301
1278
|
const formattedOutput = prepareTypeOutputToSave(typeOutput);
|
|
1302
|
-
const shouldWriteToStdout = outputFilePath ===
|
|
1279
|
+
const shouldWriteToStdout = outputFilePath === void 0;
|
|
1303
1280
|
if (shouldWriteToStdout) {
|
|
1304
1281
|
await writeTypeOutputToStandardOutput(formattedOutput);
|
|
1305
1282
|
} else {
|
|
@@ -1367,5 +1344,5 @@ var typegen = Object.freeze(new TypegenNamespace_default());
|
|
|
1367
1344
|
* The root import module is defined at build time. The fallback is not expected to be used. */
|
|
1368
1345
|
|
|
1369
1346
|
export { __name, logWithPrefix, typegen };
|
|
1370
|
-
//# sourceMappingURL=chunk-
|
|
1371
|
-
//# sourceMappingURL=chunk-
|
|
1347
|
+
//# sourceMappingURL=chunk-C5GWXTO5.mjs.map
|
|
1348
|
+
//# sourceMappingURL=chunk-C5GWXTO5.mjs.map
|