@zimic/http 0.1.0-canary.2 → 0.1.0-canary.20
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 +110 -180
- package/dist/{chunk-VHQRAQPQ.mjs → chunk-C5GWXTO5.mjs} +117 -140
- package/dist/chunk-C5GWXTO5.mjs.map +1 -0
- package/dist/{chunk-VUDGONB5.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 +29 -38
- 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.d.ts +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +19 -16
- 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/index.ts +5 -0
- package/src/pathParams/types.ts +1 -1
- package/src/searchParams/HttpSearchParams.ts +1 -1
- package/src/searchParams/types.ts +1 -1
- package/src/typegen/index.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 +35 -2
- 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-VHQRAQPQ.mjs.map +0 -1
- package/dist/chunk-VUDGONB5.js.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 -64
- package/src/utils/data.ts +0 -13
- package/src/utils/imports.ts +0 -12
- package/src/utils/urls.ts +0 -52
|
@@ -15,15 +15,17 @@ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// ../zimic-utils/dist/chunk-PAWJFY3S.mjs
|
|
19
|
+
var __defProp2 = Object.defineProperty;
|
|
20
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
21
|
+
|
|
22
|
+
// ../zimic-utils/dist/chunk-3O5CS47X.mjs
|
|
19
23
|
function isDefined(value) {
|
|
20
|
-
return value !==
|
|
24
|
+
return value !== void 0 && value !== null;
|
|
21
25
|
}
|
|
22
26
|
__name(isDefined, "isDefined");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
27
|
+
__name2(isDefined, "isDefined");
|
|
28
|
+
var isDefined_default = isDefined;
|
|
27
29
|
function isNeverType(type) {
|
|
28
30
|
return type.kind === ts3__default.default.SyntaxKind.NeverKeyword;
|
|
29
31
|
}
|
|
@@ -45,13 +47,13 @@ function createNullType() {
|
|
|
45
47
|
}
|
|
46
48
|
__name(createNullType, "createNullType");
|
|
47
49
|
function createImportSpecifier(importName) {
|
|
48
|
-
return ts3__default.default.factory.createImportSpecifier(false,
|
|
50
|
+
return ts3__default.default.factory.createImportSpecifier(false, void 0, ts3__default.default.factory.createIdentifier(importName));
|
|
49
51
|
}
|
|
50
52
|
__name(createImportSpecifier, "createImportSpecifier");
|
|
51
53
|
function createImportDeclaration(importSpecifiers, moduleName, options) {
|
|
52
54
|
return ts3__default.default.factory.createImportDeclaration(
|
|
53
|
-
|
|
54
|
-
ts3__default.default.factory.createImportClause(options.typeOnly,
|
|
55
|
+
void 0,
|
|
56
|
+
ts3__default.default.factory.createImportClause(options.typeOnly, void 0, ts3__default.default.factory.createNamedImports(importSpecifiers)),
|
|
55
57
|
ts3__default.default.factory.createStringLiteral(moduleName)
|
|
56
58
|
);
|
|
57
59
|
}
|
|
@@ -59,7 +61,7 @@ __name(createImportDeclaration, "createImportDeclaration");
|
|
|
59
61
|
var HTTP_METHODS = Object.freeze(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
60
62
|
function logWithPrefix(message, options) {
|
|
61
63
|
const { method } = options;
|
|
62
|
-
console[method](chalk__default.default.cyan("[zimic]"), message);
|
|
64
|
+
console[method](chalk__default.default.cyan("[@zimic/http]"), message);
|
|
63
65
|
}
|
|
64
66
|
__name(logWithPrefix, "logWithPrefix");
|
|
65
67
|
function createOperationsIdentifierText(serviceName) {
|
|
@@ -71,11 +73,11 @@ function createOperationsIdentifier(serviceName) {
|
|
|
71
73
|
}
|
|
72
74
|
__name(createOperationsIdentifier, "createOperationsIdentifier");
|
|
73
75
|
function isOperationsDeclaration(node) {
|
|
74
|
-
return node !==
|
|
76
|
+
return node !== void 0 && ts3__default.default.isInterfaceDeclaration(node) && node.name.text === "operations";
|
|
75
77
|
}
|
|
76
78
|
__name(isOperationsDeclaration, "isOperationsDeclaration");
|
|
77
79
|
function isOperation(node) {
|
|
78
|
-
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !==
|
|
80
|
+
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !== void 0 && ts3__default.default.isTypeLiteralNode(node.type);
|
|
79
81
|
}
|
|
80
82
|
__name(isOperation, "isOperation");
|
|
81
83
|
function wrapOperationType(type, context) {
|
|
@@ -89,7 +91,7 @@ function wrapOperationType(type, context) {
|
|
|
89
91
|
__name(wrapOperationType, "wrapOperationType");
|
|
90
92
|
function normalizeOperation(operation, context) {
|
|
91
93
|
if (!isOperation(operation)) {
|
|
92
|
-
return
|
|
94
|
+
return void 0;
|
|
93
95
|
}
|
|
94
96
|
const newType = normalizeTypeLiteralMethodType(operation.type, context);
|
|
95
97
|
return ts3__default.default.factory.updatePropertySignature(
|
|
@@ -103,7 +105,7 @@ function normalizeOperation(operation, context) {
|
|
|
103
105
|
__name(normalizeOperation, "normalizeOperation");
|
|
104
106
|
function normalizeOperations(operations, context) {
|
|
105
107
|
const newIdentifier = createOperationsIdentifier(context.serviceName);
|
|
106
|
-
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(
|
|
108
|
+
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(isDefined_default);
|
|
107
109
|
return ts3__default.default.factory.updateInterfaceDeclaration(
|
|
108
110
|
operations,
|
|
109
111
|
operations.modifiers,
|
|
@@ -116,7 +118,7 @@ function normalizeOperations(operations, context) {
|
|
|
116
118
|
__name(normalizeOperations, "normalizeOperations");
|
|
117
119
|
function removeOperationIfUnreferenced(operation, context) {
|
|
118
120
|
if (!isOperation(operation)) {
|
|
119
|
-
return
|
|
121
|
+
return void 0;
|
|
120
122
|
}
|
|
121
123
|
const operationName = operation.name.text;
|
|
122
124
|
const isReferenced = context.referencedTypes.operations.has(operationName);
|
|
@@ -124,14 +126,14 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
124
126
|
context.referencedTypes.operations.delete(operationName);
|
|
125
127
|
return operation;
|
|
126
128
|
}
|
|
127
|
-
return
|
|
129
|
+
return void 0;
|
|
128
130
|
}
|
|
129
131
|
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
130
132
|
function removeUnreferencedOperations(operations, context) {
|
|
131
|
-
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(
|
|
133
|
+
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
132
134
|
context.referencedTypes.operations.clear();
|
|
133
135
|
if (newMembers.length === 0) {
|
|
134
|
-
return
|
|
136
|
+
return void 0;
|
|
135
137
|
}
|
|
136
138
|
return ts3__default.default.factory.updateInterfaceDeclaration(
|
|
137
139
|
operations,
|
|
@@ -146,15 +148,15 @@ __name(removeUnreferencedOperations, "removeUnreferencedOperations");
|
|
|
146
148
|
|
|
147
149
|
// src/typegen/openapi/transform/methods.ts
|
|
148
150
|
function isMethod(node) {
|
|
149
|
-
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !==
|
|
151
|
+
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !== void 0 && (ts3__default.default.isTypeLiteralNode(node.type) || ts3__default.default.isIndexedAccessTypeNode(node.type));
|
|
150
152
|
}
|
|
151
153
|
__name(isMethod, "isMethod");
|
|
152
154
|
function isMethodMember(node) {
|
|
153
|
-
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !==
|
|
155
|
+
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !== void 0 && (ts3__default.default.isTypeLiteralNode(node.type) || ts3__default.default.isIndexedAccessTypeNode(node.type) || isNeverType(node.type));
|
|
154
156
|
}
|
|
155
157
|
__name(isMethodMember, "isMethodMember");
|
|
156
158
|
function isRequestMember(node) {
|
|
157
|
-
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !==
|
|
159
|
+
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !== void 0 && !isNeverType(node.type);
|
|
158
160
|
}
|
|
159
161
|
__name(isRequestMember, "isRequestMember");
|
|
160
162
|
function isRequestHeaders(node) {
|
|
@@ -162,7 +164,7 @@ function isRequestHeaders(node) {
|
|
|
162
164
|
}
|
|
163
165
|
__name(isRequestHeaders, "isRequestHeaders");
|
|
164
166
|
function isNormalizedRequestHeaders(node) {
|
|
165
|
-
return isRequestMember(node) && node.name.text === "headers" && ts3__default.default.isTypeReferenceNode(node.type) && node.type.typeArguments !==
|
|
167
|
+
return isRequestMember(node) && node.name.text === "headers" && ts3__default.default.isTypeReferenceNode(node.type) && node.type.typeArguments !== void 0 && node.type.typeArguments.length === 1 && ts3__default.default.isTypeLiteralNode(node.type.typeArguments[0]);
|
|
166
168
|
}
|
|
167
169
|
__name(isNormalizedRequestHeaders, "isNormalizedRequestHeaders");
|
|
168
170
|
function isRequestParameters(node) {
|
|
@@ -174,11 +176,11 @@ function isContentPropertySignature(node) {
|
|
|
174
176
|
}
|
|
175
177
|
__name(isContentPropertySignature, "isContentPropertySignature");
|
|
176
178
|
function isContentMember(node) {
|
|
177
|
-
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !==
|
|
179
|
+
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !== void 0 && !isNeverType(node.type);
|
|
178
180
|
}
|
|
179
181
|
__name(isContentMember, "isContentMember");
|
|
180
182
|
function isResponse(node) {
|
|
181
|
-
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name) || ts3__default.default.isNumericLiteral(node.name)) && node.type !==
|
|
183
|
+
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name) || ts3__default.default.isNumericLiteral(node.name)) && node.type !== void 0;
|
|
182
184
|
}
|
|
183
185
|
__name(isResponse, "isResponse");
|
|
184
186
|
function removeRedundantNullUnionIfNecessary(type) {
|
|
@@ -228,7 +230,7 @@ function wrapURLEncodedContentType(type, context) {
|
|
|
228
230
|
__name(wrapURLEncodedContentType, "wrapURLEncodedContentType");
|
|
229
231
|
function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
230
232
|
if (!isContentMember(requestBodyMember)) {
|
|
231
|
-
return
|
|
233
|
+
return void 0;
|
|
232
234
|
}
|
|
233
235
|
const newIdentifier = ts3__default.default.factory.createIdentifier("body");
|
|
234
236
|
const contentType = requestBodyMember.name.text;
|
|
@@ -265,12 +267,12 @@ function normalizeHeaders(headers, context) {
|
|
|
265
267
|
return false;
|
|
266
268
|
}
|
|
267
269
|
if (ts3__default.default.isPropertySignature(header)) {
|
|
268
|
-
return header.type !==
|
|
270
|
+
return header.type !== void 0 && !isUnknownType(header.type);
|
|
269
271
|
}
|
|
270
272
|
return true;
|
|
271
273
|
});
|
|
272
274
|
if (newHeaderMembers.length === 0) {
|
|
273
|
-
return
|
|
275
|
+
return void 0;
|
|
274
276
|
}
|
|
275
277
|
const newHeaders = ts3__default.default.factory.updateTypeLiteralNode(headers, ts3__default.default.factory.createNodeArray(newHeaderMembers));
|
|
276
278
|
return wrapHeadersType(newHeaders, context);
|
|
@@ -278,11 +280,11 @@ function normalizeHeaders(headers, context) {
|
|
|
278
280
|
__name(normalizeHeaders, "normalizeHeaders");
|
|
279
281
|
function normalizeRequestHeaders(requestHeader, context) {
|
|
280
282
|
if (!isRequestHeaders(requestHeader)) {
|
|
281
|
-
return
|
|
283
|
+
return void 0;
|
|
282
284
|
}
|
|
283
285
|
const newType = normalizeHeaders(requestHeader.type, context);
|
|
284
286
|
if (!newType) {
|
|
285
|
-
return
|
|
287
|
+
return void 0;
|
|
286
288
|
}
|
|
287
289
|
return ts3__default.default.factory.updatePropertySignature(
|
|
288
290
|
requestHeader,
|
|
@@ -299,7 +301,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
299
301
|
const contentTypeValue = ts3__default.default.factory.createLiteralTypeNode(ts3__default.default.factory.createStringLiteral(contentTypeName));
|
|
300
302
|
const newHeaderType = wrapHeadersType(
|
|
301
303
|
ts3__default.default.factory.createTypeLiteralNode([
|
|
302
|
-
ts3__default.default.factory.createPropertySignature(
|
|
304
|
+
ts3__default.default.factory.createPropertySignature(void 0, contentTypeIdentifier, void 0, contentTypeValue),
|
|
303
305
|
...existingHeaderMembers
|
|
304
306
|
]),
|
|
305
307
|
context
|
|
@@ -307,7 +309,7 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName, cont
|
|
|
307
309
|
return ts3__default.default.factory.createPropertySignature(
|
|
308
310
|
existingHeader?.modifiers,
|
|
309
311
|
ts3__default.default.factory.createIdentifier("headers"),
|
|
310
|
-
|
|
312
|
+
void 0,
|
|
311
313
|
newHeaderType
|
|
312
314
|
);
|
|
313
315
|
}
|
|
@@ -320,16 +322,15 @@ function normalizeContentType(contentType, context, options) {
|
|
|
320
322
|
if (!ts3__default.default.isTypeLiteralNode(contentType)) {
|
|
321
323
|
return contentType;
|
|
322
324
|
}
|
|
323
|
-
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(
|
|
325
|
+
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(isDefined_default);
|
|
324
326
|
const newBodyMembers = contentType.members.flatMap((body) => {
|
|
325
327
|
if (isContentPropertySignature(body)) {
|
|
326
|
-
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(
|
|
328
|
+
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(isDefined_default);
|
|
327
329
|
}
|
|
328
330
|
return [];
|
|
329
331
|
});
|
|
330
|
-
if (newBodyMembers.length
|
|
331
|
-
const
|
|
332
|
-
const newMembers = [newHeader, ...newBodyMemberPropertySignatures].filter(isDefined);
|
|
332
|
+
if (newBodyMembers.length === 0) {
|
|
333
|
+
const newMembers = [newHeader].filter(isDefined_default);
|
|
333
334
|
return ts3__default.default.factory.updateTypeLiteralNode(contentType, ts3__default.default.factory.createNodeArray(newMembers));
|
|
334
335
|
} else {
|
|
335
336
|
const bodyMemberUnionTypes = newBodyMembers.map((bodyMember) => {
|
|
@@ -349,7 +350,7 @@ function normalizeRequest(request, context) {
|
|
|
349
350
|
const referencedComponentName = request.type.indexType.literal.text;
|
|
350
351
|
context.pendingActions.components.requests.toMarkBodyAsOptional.add(referencedComponentName);
|
|
351
352
|
}
|
|
352
|
-
return ts3__default.default.factory.updatePropertySignature(request, request.modifiers, newIdentifier,
|
|
353
|
+
return ts3__default.default.factory.updatePropertySignature(request, request.modifiers, newIdentifier, void 0, newType);
|
|
353
354
|
}
|
|
354
355
|
__name(normalizeRequest, "normalizeRequest");
|
|
355
356
|
function wrapResponseType(type, context) {
|
|
@@ -381,7 +382,7 @@ var NON_NUMERIC_RESPONSE_STATUS_TO_MAPPED_TYPE = {
|
|
|
381
382
|
function normalizeResponse(response, context, options = {}) {
|
|
382
383
|
const { isComponent: isComponent2 = false } = options;
|
|
383
384
|
if (!isResponse(response)) {
|
|
384
|
-
return
|
|
385
|
+
return void 0;
|
|
385
386
|
}
|
|
386
387
|
const newType = normalizeResponseType(response.type, context, {
|
|
387
388
|
isComponent: isComponent2,
|
|
@@ -407,7 +408,7 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
407
408
|
`Warning: Response has a non-standard status code: ${chalk__default.default.yellow(response.name.text)}. Consider replacing it with a number (e.g. '200'), a pattern ('1xx', '2xx', '3xx', '4xx', or '5xx'), or 'default'.`,
|
|
408
409
|
{ method: "warn" }
|
|
409
410
|
);
|
|
410
|
-
return
|
|
411
|
+
return void 0;
|
|
411
412
|
}
|
|
412
413
|
context.typeImports.http.add("HttpStatusCode");
|
|
413
414
|
const newIdentifier = ts3__default.default.factory.createIdentifier(`[StatusCode in ${mappedType}]`);
|
|
@@ -430,11 +431,11 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
430
431
|
__name(normalizeResponse, "normalizeResponse");
|
|
431
432
|
function normalizeResponses(responses, context) {
|
|
432
433
|
if (isNeverType(responses.type) || !ts3__default.default.isTypeLiteralNode(responses.type)) {
|
|
433
|
-
return
|
|
434
|
+
return void 0;
|
|
434
435
|
}
|
|
435
436
|
const newIdentifier = ts3__default.default.factory.createIdentifier("response");
|
|
436
|
-
const newQuestionToken =
|
|
437
|
-
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(
|
|
437
|
+
const newQuestionToken = void 0;
|
|
438
|
+
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(isDefined_default);
|
|
438
439
|
const sortedNewMembers = Array.from(newMembers).sort((response, otherResponse) => {
|
|
439
440
|
return response.statusCode.value.localeCompare(otherResponse.statusCode.value);
|
|
440
441
|
});
|
|
@@ -486,12 +487,12 @@ function normalizeMethodMember(methodMember, context) {
|
|
|
486
487
|
}
|
|
487
488
|
return methodMember;
|
|
488
489
|
}
|
|
489
|
-
return
|
|
490
|
+
return void 0;
|
|
490
491
|
}
|
|
491
492
|
__name(normalizeMethodMember, "normalizeMethodMember");
|
|
492
493
|
function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
493
494
|
const newIdentifier = ts3__default.default.factory.createIdentifier("searchParams");
|
|
494
|
-
const newQuestionToken =
|
|
495
|
+
const newQuestionToken = void 0;
|
|
495
496
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
496
497
|
context.typeImports.http.add("HttpSearchParamsSerialized");
|
|
497
498
|
const serializedWrapper = ts3__default.default.factory.createIdentifier("HttpSearchParamsSerialized");
|
|
@@ -507,7 +508,7 @@ function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
|
507
508
|
__name(normalizeRequestQueryWithParameters, "normalizeRequestQueryWithParameters");
|
|
508
509
|
function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
509
510
|
const newIdentifier = ts3__default.default.factory.createIdentifier("headers");
|
|
510
|
-
const newQuestionToken =
|
|
511
|
+
const newQuestionToken = void 0;
|
|
511
512
|
const newType = renameComponentReferences(requestMember.type, context);
|
|
512
513
|
context.typeImports.http.add("HttpHeadersSerialized");
|
|
513
514
|
const serializedWrapper = ts3__default.default.factory.createIdentifier("HttpHeadersSerialized");
|
|
@@ -523,7 +524,7 @@ function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
|
523
524
|
__name(normalizeRequestHeadersWithParameters, "normalizeRequestHeadersWithParameters");
|
|
524
525
|
function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
525
526
|
if (!isRequestMember(requestMember) || requestMember.name.text === "path") {
|
|
526
|
-
return
|
|
527
|
+
return void 0;
|
|
527
528
|
}
|
|
528
529
|
if (requestMember.name.text === "query") {
|
|
529
530
|
return normalizeRequestQueryWithParameters(requestMember, context);
|
|
@@ -560,18 +561,18 @@ function mergeRequestHeadersMembers(members) {
|
|
|
560
561
|
if (!member || !isNormalizedRequestHeaders(member)) {
|
|
561
562
|
return member;
|
|
562
563
|
}
|
|
563
|
-
if (firstHeadersIndex ===
|
|
564
|
+
if (firstHeadersIndex === void 0 || !mergedHeaders) {
|
|
564
565
|
firstHeadersIndex = index;
|
|
565
566
|
mergedHeaders = member;
|
|
566
567
|
return member;
|
|
567
568
|
}
|
|
568
569
|
mergedHeaders = mergeRequestHeadersMember(mergedHeaders, member);
|
|
569
|
-
return
|
|
570
|
+
return void 0;
|
|
570
571
|
});
|
|
571
|
-
if (firstHeadersIndex !==
|
|
572
|
+
if (firstHeadersIndex !== void 0) {
|
|
572
573
|
mergedHeadersMembers[firstHeadersIndex] = mergedHeaders;
|
|
573
574
|
}
|
|
574
|
-
return mergedHeadersMembers.filter(
|
|
575
|
+
return mergedHeadersMembers.filter(isDefined_default);
|
|
575
576
|
}
|
|
576
577
|
__name(mergeRequestHeadersMembers, "mergeRequestHeadersMembers");
|
|
577
578
|
function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
@@ -584,48 +585,48 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
584
585
|
})
|
|
585
586
|
);
|
|
586
587
|
if (newMembers.length === 0) {
|
|
587
|
-
return
|
|
588
|
+
return void 0;
|
|
588
589
|
}
|
|
589
590
|
return ts3__default.default.factory.createTypeLiteralNode(newMembers);
|
|
590
591
|
}
|
|
591
592
|
__name(mergeRequestAndParameterTypes, "mergeRequestAndParameterTypes");
|
|
592
593
|
function normalizeRequestTypeWithParameters(requestType, methodMembers, context) {
|
|
593
594
|
if (ts3__default.default.isUnionTypeNode(requestType)) {
|
|
594
|
-
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(
|
|
595
|
+
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(isDefined_default);
|
|
595
596
|
return ts3__default.default.factory.updateUnionTypeNode(requestType, ts3__default.default.factory.createNodeArray(newTypes));
|
|
596
597
|
}
|
|
597
598
|
if (ts3__default.default.isIndexedAccessTypeNode(requestType)) {
|
|
598
599
|
const newType = normalizeRequestTypeWithParameters(ts3__default.default.factory.createTypeLiteralNode([]), methodMembers, context);
|
|
599
|
-
return ts3__default.default.factory.createIntersectionTypeNode([requestType, newType].filter(
|
|
600
|
+
return ts3__default.default.factory.createIntersectionTypeNode([requestType, newType].filter(isDefined_default));
|
|
600
601
|
}
|
|
601
602
|
return mergeRequestAndParameterTypes(requestType, methodMembers, context);
|
|
602
603
|
}
|
|
603
604
|
__name(normalizeRequestTypeWithParameters, "normalizeRequestTypeWithParameters");
|
|
604
605
|
function normalizeMethodMemberWithParameters(methodMember, methodMembers, context) {
|
|
605
606
|
if (!ts3__default.default.isIdentifier(methodMember.name) || !methodMember.type) {
|
|
606
|
-
return
|
|
607
|
+
return void 0;
|
|
607
608
|
}
|
|
608
609
|
if (methodMember.name.text === "request") {
|
|
609
610
|
const newType = normalizeRequestTypeWithParameters(methodMember.type, methodMembers, context);
|
|
610
611
|
if (!newType) {
|
|
611
|
-
return
|
|
612
|
+
return void 0;
|
|
612
613
|
}
|
|
613
614
|
return ts3__default.default.factory.updatePropertySignature(
|
|
614
615
|
methodMember,
|
|
615
616
|
methodMember.modifiers,
|
|
616
617
|
methodMember.name,
|
|
617
|
-
|
|
618
|
+
void 0,
|
|
618
619
|
newType
|
|
619
620
|
);
|
|
620
621
|
}
|
|
621
622
|
if (methodMember.name.text === "response") {
|
|
622
623
|
return methodMember;
|
|
623
624
|
}
|
|
624
|
-
return
|
|
625
|
+
return void 0;
|
|
625
626
|
}
|
|
626
627
|
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
627
628
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
628
|
-
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(
|
|
629
|
+
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(isDefined_default).map((member, _index, partialMembers) => normalizeMethodMemberWithParameters(member, partialMembers, context)).filter(isDefined_default);
|
|
629
630
|
return ts3__default.default.factory.updateTypeLiteralNode(methodType, ts3__default.default.factory.createNodeArray(newMembers));
|
|
630
631
|
}
|
|
631
632
|
__name(normalizeTypeLiteralMethodType, "normalizeTypeLiteralMethodType");
|
|
@@ -646,17 +647,17 @@ function normalizeIndexedAccessMethodType(methodType, context) {
|
|
|
646
647
|
__name(normalizeIndexedAccessMethodType, "normalizeIndexedAccessMethodType");
|
|
647
648
|
function normalizeMethod(method, context, options) {
|
|
648
649
|
if (!isMethod(method)) {
|
|
649
|
-
return
|
|
650
|
+
return void 0;
|
|
650
651
|
}
|
|
651
652
|
const methodName = method.name.text.toUpperCase();
|
|
652
653
|
if (!HTTP_METHODS.includes(methodName)) {
|
|
653
|
-
return
|
|
654
|
+
return void 0;
|
|
654
655
|
}
|
|
655
656
|
const pathMethodCompareString = `${methodName} ${options.pathName}`;
|
|
656
657
|
const matchesPositiveFilters = context.filters.paths.positive.length === 0 || context.filters.paths.positive.some((filter) => filter.test(pathMethodCompareString));
|
|
657
658
|
const matchesNegativeFilters = context.filters.paths.negative.length > 0 && context.filters.paths.negative.some((filter) => filter.test(pathMethodCompareString));
|
|
658
659
|
if (!matchesPositiveFilters || matchesNegativeFilters) {
|
|
659
|
-
return
|
|
660
|
+
return void 0;
|
|
660
661
|
}
|
|
661
662
|
const newIdentifier = ts3__default.default.factory.createIdentifier(methodName);
|
|
662
663
|
const newType = ts3__default.default.isTypeLiteralNode(method.type) ? normalizeTypeLiteralMethodType(method.type, context) : normalizeIndexedAccessMethodType(method.type, context);
|
|
@@ -668,11 +669,11 @@ function createPathsIdentifier(serviceName) {
|
|
|
668
669
|
}
|
|
669
670
|
__name(createPathsIdentifier, "createPathsIdentifier");
|
|
670
671
|
function isPathsDeclaration(node) {
|
|
671
|
-
return node !==
|
|
672
|
+
return node !== void 0 && (ts3__default.default.isInterfaceDeclaration(node) || ts3__default.default.isTypeAliasDeclaration(node)) && node.name.text === "paths";
|
|
672
673
|
}
|
|
673
674
|
__name(isPathsDeclaration, "isPathsDeclaration");
|
|
674
675
|
function isPath(node) {
|
|
675
|
-
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !==
|
|
676
|
+
return ts3__default.default.isPropertySignature(node) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name)) && node.type !== void 0 && (ts3__default.default.isTypeLiteralNode(node.type) || ts3__default.default.isIndexedAccessTypeNode(node.type));
|
|
676
677
|
}
|
|
677
678
|
__name(isPath, "isPath");
|
|
678
679
|
function normalizePathNameWithParameters(pathName) {
|
|
@@ -691,15 +692,15 @@ __name(wrapComponentPathType, "wrapComponentPathType");
|
|
|
691
692
|
function normalizePath(path4, context, options = {}) {
|
|
692
693
|
const { isComponent: isComponent2 = false } = options;
|
|
693
694
|
if (!isPath(path4)) {
|
|
694
|
-
return
|
|
695
|
+
return void 0;
|
|
695
696
|
}
|
|
696
697
|
const newPathName = isComponent2 ? path4.name.text : normalizePathNameWithParameters(path4.name.text);
|
|
697
698
|
const newIdentifier = isComponent2 ? path4.name : ts3__default.default.factory.createStringLiteral(newPathName);
|
|
698
699
|
let newType;
|
|
699
700
|
if (ts3__default.default.isTypeLiteralNode(path4.type)) {
|
|
700
|
-
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(
|
|
701
|
+
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(isDefined_default);
|
|
701
702
|
if (newMethods.length === 0) {
|
|
702
|
-
return
|
|
703
|
+
return void 0;
|
|
703
704
|
}
|
|
704
705
|
newType = ts3__default.default.factory.updateTypeLiteralNode(path4.type, ts3__default.default.factory.createNodeArray(newMethods));
|
|
705
706
|
} else {
|
|
@@ -722,8 +723,8 @@ function wrapPathsType(type, context) {
|
|
|
722
723
|
__name(wrapPathsType, "wrapPathsType");
|
|
723
724
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
724
725
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
725
|
-
const paths = ts3__default.default.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3__default.default.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name,
|
|
726
|
-
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(
|
|
726
|
+
const paths = ts3__default.default.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3__default.default.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, void 0, void 0, []) : pathsOrTypeAlias;
|
|
727
|
+
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(isDefined_default);
|
|
727
728
|
const newType = ts3__default.default.factory.createTypeLiteralNode(newMembers);
|
|
728
729
|
return ts3__default.default.factory.createTypeAliasDeclaration(
|
|
729
730
|
paths.modifiers,
|
|
@@ -745,15 +746,15 @@ function createComponentsIdentifier(serviceName) {
|
|
|
745
746
|
__name(createComponentsIdentifier, "createComponentsIdentifier");
|
|
746
747
|
function isComponentsDeclaration(node, context) {
|
|
747
748
|
const componentIdentifiers = ["components", createComponentsIdentifierText(context.serviceName)];
|
|
748
|
-
return node !==
|
|
749
|
+
return node !== void 0 && ts3__default.default.isInterfaceDeclaration(node) && componentIdentifiers.includes(node.name.text);
|
|
749
750
|
}
|
|
750
751
|
__name(isComponentsDeclaration, "isComponentsDeclaration");
|
|
751
752
|
function isComponentGroup(node) {
|
|
752
|
-
return ts3__default.default.isPropertySignature(node) && node.type !==
|
|
753
|
+
return ts3__default.default.isPropertySignature(node) && node.type !== void 0 && ts3__default.default.isTypeLiteralNode(node.type) && ts3__default.default.isIdentifier(node.name);
|
|
753
754
|
}
|
|
754
755
|
__name(isComponentGroup, "isComponentGroup");
|
|
755
756
|
function isComponent(node) {
|
|
756
|
-
return ts3__default.default.isPropertySignature(node) && node.type !==
|
|
757
|
+
return ts3__default.default.isPropertySignature(node) && node.type !== void 0 && !isNeverType(node.type) && (ts3__default.default.isIdentifier(node.name) || ts3__default.default.isStringLiteral(node.name));
|
|
757
758
|
}
|
|
758
759
|
__name(isComponent, "isComponent");
|
|
759
760
|
function isRequestComponent(node) {
|
|
@@ -894,7 +895,7 @@ function wrapRequestComponentType(type, context) {
|
|
|
894
895
|
__name(wrapRequestComponentType, "wrapRequestComponentType");
|
|
895
896
|
function normalizeRequestComponent(component, context) {
|
|
896
897
|
if (!isRequestComponent(component)) {
|
|
897
|
-
return
|
|
898
|
+
return void 0;
|
|
898
899
|
}
|
|
899
900
|
const { bodyQuestionToken } = processPendingRequestComponentActions(component, context);
|
|
900
901
|
const newType = normalizeContentType(component.type, context, { bodyQuestionToken });
|
|
@@ -909,7 +910,7 @@ function normalizeRequestComponent(component, context) {
|
|
|
909
910
|
__name(normalizeRequestComponent, "normalizeRequestComponent");
|
|
910
911
|
function normalizeComponent(component, componentGroupName, context) {
|
|
911
912
|
if (!isComponent(component)) {
|
|
912
|
-
return
|
|
913
|
+
return void 0;
|
|
913
914
|
}
|
|
914
915
|
if (componentGroupName === "requests") {
|
|
915
916
|
return normalizeRequestComponent(component, context);
|
|
@@ -932,11 +933,11 @@ function normalizeComponent(component, componentGroupName, context) {
|
|
|
932
933
|
__name(normalizeComponent, "normalizeComponent");
|
|
933
934
|
function normalizeComponentGroup(componentGroup, context) {
|
|
934
935
|
if (!isComponentGroup(componentGroup)) {
|
|
935
|
-
return
|
|
936
|
+
return void 0;
|
|
936
937
|
}
|
|
937
938
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
938
939
|
const newIdentifier = ts3__default.default.factory.createIdentifier(componentGroupName);
|
|
939
|
-
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(
|
|
940
|
+
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(isDefined_default);
|
|
940
941
|
const newType = ts3__default.default.factory.updateTypeLiteralNode(componentGroup.type, ts3__default.default.factory.createNodeArray(newComponents));
|
|
941
942
|
return ts3__default.default.factory.updatePropertySignature(
|
|
942
943
|
componentGroup,
|
|
@@ -949,7 +950,7 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
949
950
|
__name(normalizeComponentGroup, "normalizeComponentGroup");
|
|
950
951
|
function normalizeComponents(components, context) {
|
|
951
952
|
const newIdentifier = createComponentsIdentifier(context.serviceName);
|
|
952
|
-
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(
|
|
953
|
+
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(isDefined_default);
|
|
953
954
|
return ts3__default.default.factory.updateInterfaceDeclaration(
|
|
954
955
|
components,
|
|
955
956
|
components.modifiers,
|
|
@@ -996,7 +997,7 @@ function populateReferencedComponents(components, context) {
|
|
|
996
997
|
__name(populateReferencedComponents, "populateReferencedComponents");
|
|
997
998
|
function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
998
999
|
if (!isComponent(component)) {
|
|
999
|
-
return
|
|
1000
|
+
return void 0;
|
|
1000
1001
|
}
|
|
1001
1002
|
const componentName = component.name.text;
|
|
1002
1003
|
const componentPath = `${componentGroupName}.${componentName}`;
|
|
@@ -1004,17 +1005,17 @@ function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
|
1004
1005
|
context.referencedTypes.components.delete(componentPath);
|
|
1005
1006
|
return component;
|
|
1006
1007
|
}
|
|
1007
|
-
return
|
|
1008
|
+
return void 0;
|
|
1008
1009
|
}
|
|
1009
1010
|
__name(removeComponentIfUnreferenced, "removeComponentIfUnreferenced");
|
|
1010
1011
|
function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
1011
1012
|
if (!isComponentGroup(componentGroup)) {
|
|
1012
|
-
return
|
|
1013
|
+
return void 0;
|
|
1013
1014
|
}
|
|
1014
1015
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
1015
|
-
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(
|
|
1016
|
+
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(isDefined_default);
|
|
1016
1017
|
if (newComponents.length === 0) {
|
|
1017
|
-
return
|
|
1018
|
+
return void 0;
|
|
1018
1019
|
}
|
|
1019
1020
|
return ts3__default.default.factory.updatePropertySignature(
|
|
1020
1021
|
componentGroup,
|
|
@@ -1026,10 +1027,10 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
1026
1027
|
}
|
|
1027
1028
|
__name(removeUnreferencedComponentsInGroup, "removeUnreferencedComponentsInGroup");
|
|
1028
1029
|
function removeUnreferencedComponents(components, context) {
|
|
1029
|
-
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(
|
|
1030
|
+
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1030
1031
|
context.referencedTypes.components.clear();
|
|
1031
1032
|
if (newComponentGroups.length === 0) {
|
|
1032
|
-
return
|
|
1033
|
+
return void 0;
|
|
1033
1034
|
}
|
|
1034
1035
|
return ts3__default.default.factory.updateInterfaceDeclaration(
|
|
1035
1036
|
components,
|
|
@@ -1048,52 +1049,28 @@ function convertToPascalCase(value) {
|
|
|
1048
1049
|
}
|
|
1049
1050
|
__name(convertToPascalCase, "convertToPascalCase");
|
|
1050
1051
|
|
|
1051
|
-
//
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
__name(this, "InvalidURLError");
|
|
1055
|
-
}
|
|
1056
|
-
constructor(url) {
|
|
1057
|
-
super(`Invalid URL: '${url}'`);
|
|
1058
|
-
this.name = "InvalidURL";
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
function createURLOrThrow(rawURL) {
|
|
1062
|
-
try {
|
|
1063
|
-
const url = new URL(rawURL);
|
|
1064
|
-
Object.defineProperty(url, "raw", {
|
|
1065
|
-
value: rawURL.toString(),
|
|
1066
|
-
writable: false,
|
|
1067
|
-
enumerable: true,
|
|
1068
|
-
configurable: false
|
|
1069
|
-
});
|
|
1070
|
-
return url;
|
|
1071
|
-
} catch {
|
|
1072
|
-
throw new InvalidURLError(rawURL);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
__name(createURLOrThrow, "createURLOrThrow");
|
|
1076
|
-
function createURL(rawURL) {
|
|
1077
|
-
const url = createURLOrThrow(rawURL);
|
|
1078
|
-
return url;
|
|
1079
|
-
}
|
|
1080
|
-
__name(createURL, "createURL");
|
|
1081
|
-
function createFileURL(filePath) {
|
|
1082
|
-
return createURL(`file://${filePath}`);
|
|
1052
|
+
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
1053
|
+
function isNonEmpty(value) {
|
|
1054
|
+
return isDefined_default(value) && value !== "";
|
|
1083
1055
|
}
|
|
1084
|
-
__name(
|
|
1056
|
+
__name(isNonEmpty, "isNonEmpty");
|
|
1057
|
+
__name2(isNonEmpty, "isNonEmpty");
|
|
1058
|
+
var isNonEmpty_default = isNonEmpty;
|
|
1059
|
+
|
|
1060
|
+
// ../zimic-utils/dist/url/createRegExpFromWildcardPath.mjs
|
|
1085
1061
|
function prepareURLForRegex(url) {
|
|
1086
1062
|
const encodedURL = encodeURI(url);
|
|
1087
1063
|
return encodedURL.replace(/([.()*?+$\\])/g, "\\$1");
|
|
1088
1064
|
}
|
|
1089
1065
|
__name(prepareURLForRegex, "prepareURLForRegex");
|
|
1090
|
-
|
|
1066
|
+
__name2(prepareURLForRegex, "prepareURLForRegex");
|
|
1067
|
+
function createRegExpFromWildcardPath(path4, options) {
|
|
1091
1068
|
const pathWithReplacedWildcards = prepareURLForRegex(path4).replace(/^\/+|\/+$/g, "").replace(/\\\*/g, "*").replace(/\*\*\/\*/g, "**").replace(/(^|[^*])\*([^*]|$)/g, "$1[^/]*$2").replace(/\*\*/g, ".*");
|
|
1092
1069
|
return new RegExp(`^${options.prefix}/*${pathWithReplacedWildcards}/*$`);
|
|
1093
1070
|
}
|
|
1094
|
-
__name(
|
|
1095
|
-
|
|
1096
|
-
|
|
1071
|
+
__name(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1072
|
+
__name2(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1073
|
+
var createRegExpFromWildcardPath_default = createRegExpFromWildcardPath;
|
|
1097
1074
|
var HTTP_METHOD_OPTIONS = HTTP_METHODS.join("|");
|
|
1098
1075
|
var MODIFIER_GROUP = "(?<modifier>!?)";
|
|
1099
1076
|
var METHOD_FILTER_GROUP = `(?<method>(?:\\*|(?:${HTTP_METHOD_OPTIONS})(?:,\\s*(?:${HTTP_METHOD_OPTIONS}))*))`;
|
|
@@ -1107,12 +1084,12 @@ function parseRawFilter(rawFilter) {
|
|
|
1107
1084
|
logWithPrefix(`Warning: Filter could not be parsed and was ignored: ${chalk__default.default.yellow(rawFilter)}`, {
|
|
1108
1085
|
method: "warn"
|
|
1109
1086
|
});
|
|
1110
|
-
return
|
|
1087
|
+
return void 0;
|
|
1111
1088
|
}
|
|
1112
1089
|
const methodFilterGroup = `(?:${filteredMethodsOrWildcard.toUpperCase().replace(/,/g, "|").replace(/\*/g, ".*")}) `;
|
|
1113
1090
|
const isNegativeMatch = filterModifier === "!";
|
|
1114
1091
|
return {
|
|
1115
|
-
expression:
|
|
1092
|
+
expression: createRegExpFromWildcardPath_default(filteredPath, { prefix: methodFilterGroup }),
|
|
1116
1093
|
isNegativeMatch
|
|
1117
1094
|
};
|
|
1118
1095
|
}
|
|
@@ -1141,7 +1118,7 @@ async function readPathFiltersFromFile(filePath) {
|
|
|
1141
1118
|
}
|
|
1142
1119
|
__name(readPathFiltersFromFile, "readPathFiltersFromFile");
|
|
1143
1120
|
function ignoreEmptyFilters(filters) {
|
|
1144
|
-
return filters.map((line) => line.trim()).filter(
|
|
1121
|
+
return filters.map((line) => line.trim()).filter(isNonEmpty_default);
|
|
1145
1122
|
}
|
|
1146
1123
|
__name(ignoreEmptyFilters, "ignoreEmptyFilters");
|
|
1147
1124
|
|
|
@@ -1180,20 +1157,20 @@ function createImportDeclarations(context) {
|
|
|
1180
1157
|
}
|
|
1181
1158
|
__name(createImportDeclarations, "createImportDeclarations");
|
|
1182
1159
|
|
|
1183
|
-
//
|
|
1160
|
+
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
1184
1161
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
1185
1162
|
let cachedImportResult;
|
|
1186
|
-
return /* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1187
|
-
if (cachedImportResult ===
|
|
1163
|
+
return /* @__PURE__ */ __name2(/* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1164
|
+
if (cachedImportResult === void 0) {
|
|
1188
1165
|
cachedImportResult = await importModuleDynamically();
|
|
1189
1166
|
}
|
|
1190
1167
|
return cachedImportResult;
|
|
1191
|
-
}, "importModuleDynamicallyWithCache");
|
|
1168
|
+
}, "importModuleDynamicallyWithCache"), "importModuleDynamicallyWithCache");
|
|
1192
1169
|
}
|
|
1193
1170
|
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
var importOpenapiTypeScript =
|
|
1171
|
+
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1172
|
+
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
1173
|
+
var importOpenapiTypeScript = createCachedDynamicImport_default(() => import('openapi-typescript'));
|
|
1197
1174
|
function transformSchemaObject(schemaObject) {
|
|
1198
1175
|
if (schemaObject.format === "binary") {
|
|
1199
1176
|
const blobType = createBlobType();
|
|
@@ -1207,9 +1184,9 @@ function transformSchemaObject(schemaObject) {
|
|
|
1207
1184
|
__name(transformSchemaObject, "transformSchemaObject");
|
|
1208
1185
|
function convertFilePathOrURLToURL(filePathOrURL) {
|
|
1209
1186
|
try {
|
|
1210
|
-
return
|
|
1187
|
+
return new URL(filePathOrURL);
|
|
1211
1188
|
} catch {
|
|
1212
|
-
return
|
|
1189
|
+
return new URL(`file://${path__default.default.resolve(filePathOrURL)}`);
|
|
1213
1190
|
}
|
|
1214
1191
|
}
|
|
1215
1192
|
__name(convertFilePathOrURLToURL, "convertFilePathOrURLToURL");
|
|
@@ -1265,7 +1242,7 @@ var RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED = ["paths", "webhooks", "operations",
|
|
|
1265
1242
|
function removeUnknownResources(node) {
|
|
1266
1243
|
const isUnknownResource = !node || (ts3__default.default.isTypeAliasDeclaration(node) || ts3__default.default.isInterfaceDeclaration(node)) && RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED.includes(node.name.text);
|
|
1267
1244
|
if (isUnknownResource) {
|
|
1268
|
-
return
|
|
1245
|
+
return void 0;
|
|
1269
1246
|
}
|
|
1270
1247
|
return node;
|
|
1271
1248
|
}
|
|
@@ -1273,18 +1250,18 @@ __name(removeUnknownResources, "removeUnknownResources");
|
|
|
1273
1250
|
function normalizeRawNodes(rawNodes, context, options) {
|
|
1274
1251
|
let normalizedNodes = rawNodes.map((node) => isPathsDeclaration(node) ? normalizePaths(node, context) : node);
|
|
1275
1252
|
if (options.prune) {
|
|
1276
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(
|
|
1253
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(isDefined_default);
|
|
1277
1254
|
}
|
|
1278
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(
|
|
1255
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(isDefined_default);
|
|
1279
1256
|
if (options.prune) {
|
|
1280
1257
|
for (const node of normalizedNodes) {
|
|
1281
1258
|
if (isComponentsDeclaration(node, context)) {
|
|
1282
1259
|
populateReferencedComponents(node, context);
|
|
1283
1260
|
}
|
|
1284
1261
|
}
|
|
1285
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(
|
|
1262
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(isDefined_default);
|
|
1286
1263
|
}
|
|
1287
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(
|
|
1264
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(isDefined_default);
|
|
1288
1265
|
return normalizedNodes;
|
|
1289
1266
|
}
|
|
1290
1267
|
__name(normalizeRawNodes, "normalizeRawNodes");
|
|
@@ -1308,7 +1285,7 @@ async function generateTypesFromOpenAPI({
|
|
|
1308
1285
|
}
|
|
1309
1286
|
const typeOutput = await convertTypesToString(nodes, { includeComments });
|
|
1310
1287
|
const formattedOutput = prepareTypeOutputToSave(typeOutput);
|
|
1311
|
-
const shouldWriteToStdout = outputFilePath ===
|
|
1288
|
+
const shouldWriteToStdout = outputFilePath === void 0;
|
|
1312
1289
|
if (shouldWriteToStdout) {
|
|
1313
1290
|
await writeTypeOutputToStandardOutput(formattedOutput);
|
|
1314
1291
|
} else {
|
|
@@ -1378,5 +1355,5 @@ var typegen = Object.freeze(new TypegenNamespace_default());
|
|
|
1378
1355
|
exports.__name = __name;
|
|
1379
1356
|
exports.logWithPrefix = logWithPrefix;
|
|
1380
1357
|
exports.typegen = typegen;
|
|
1381
|
-
//# sourceMappingURL=chunk-
|
|
1382
|
-
//# sourceMappingURL=chunk-
|
|
1358
|
+
//# sourceMappingURL=chunk-KDDZRZK6.js.map
|
|
1359
|
+
//# sourceMappingURL=chunk-KDDZRZK6.js.map
|