@zimic/http 1.1.2-canary.2 → 1.1.2-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-JYYTLDL3.js → chunk-OFNBRVSF.js} +28 -219
- package/dist/chunk-OFNBRVSF.js.map +1 -0
- package/dist/{chunk-NMM3FZVR.mjs → chunk-ZPOGWLJW.mjs} +29 -219
- package/dist/chunk-ZPOGWLJW.mjs.map +1 -0
- package/dist/cli.js +4 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +1 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -23
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +3 -3
- package/src/typegen/openapi/transform/context.ts +2 -2
- package/src/typegen/openapi/transform/filters.ts +3 -3
- package/src/typegen/openapi/transform/methods.ts +2 -2
- package/dist/chunk-JYYTLDL3.js.map +0 -1
- package/dist/chunk-NMM3FZVR.mjs.map +0 -1
|
@@ -12,68 +12,46 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
12
12
|
var ts3__default = /*#__PURE__*/_interopDefault(ts3);
|
|
13
13
|
var color__default = /*#__PURE__*/_interopDefault(color);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
|
|
18
|
-
// ../zimic-utils/dist/chunk-2D3UJWOA.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-WC2DBWWR.mjs
|
|
15
|
+
// ../zimic-utils/dist/chunk-5UH44FTS.mjs
|
|
23
16
|
function isDefined(value) {
|
|
24
17
|
return value !== void 0 && value !== null;
|
|
25
18
|
}
|
|
26
|
-
__name(isDefined, "isDefined");
|
|
27
|
-
__name2(isDefined, "isDefined");
|
|
28
19
|
var isDefined_default = isDefined;
|
|
29
20
|
function isNeverType(type) {
|
|
30
21
|
return type.kind === ts3__default.default.SyntaxKind.NeverKeyword;
|
|
31
22
|
}
|
|
32
|
-
__name(isNeverType, "isNeverType");
|
|
33
23
|
function isUnknownType(type) {
|
|
34
24
|
return type.kind === ts3__default.default.SyntaxKind.UnknownKeyword;
|
|
35
25
|
}
|
|
36
|
-
__name(isUnknownType, "isUnknownType");
|
|
37
26
|
function isNullType(type) {
|
|
38
27
|
return type.kind === ts3__default.default.SyntaxKind.NullKeyword;
|
|
39
28
|
}
|
|
40
|
-
__name(isNullType, "isNullType");
|
|
41
29
|
function createBlobType() {
|
|
42
30
|
return ts3__default.default.factory.createTypeReferenceNode("Blob");
|
|
43
31
|
}
|
|
44
|
-
__name(createBlobType, "createBlobType");
|
|
45
32
|
function createNullType() {
|
|
46
33
|
return ts3__default.default.factory.createLiteralTypeNode(ts3__default.default.factory.createNull());
|
|
47
34
|
}
|
|
48
|
-
__name(createNullType, "createNullType");
|
|
49
35
|
function createImportSpecifier(importName) {
|
|
50
36
|
return ts3__default.default.factory.createImportSpecifier(false, void 0, ts3__default.default.factory.createIdentifier(importName));
|
|
51
37
|
}
|
|
52
|
-
__name(createImportSpecifier, "createImportSpecifier");
|
|
53
38
|
function createImportDeclaration(importSpecifiers, moduleName, options) {
|
|
54
39
|
return ts3__default.default.factory.createImportDeclaration(
|
|
55
40
|
void 0,
|
|
56
41
|
ts3__default.default.factory.createImportClause(
|
|
57
|
-
|
|
42
|
+
ts3__default.default.SyntaxKind.TypeKeyword ,
|
|
58
43
|
void 0,
|
|
59
44
|
ts3__default.default.factory.createNamedImports(importSpecifiers)
|
|
60
45
|
),
|
|
61
46
|
ts3__default.default.factory.createStringLiteral(moduleName)
|
|
62
47
|
);
|
|
63
48
|
}
|
|
64
|
-
__name(createImportDeclaration, "createImportDeclaration");
|
|
65
49
|
|
|
66
50
|
// src/types/schema.ts
|
|
67
51
|
var HTTP_METHODS = Object.freeze(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
68
52
|
|
|
69
53
|
// ../zimic-utils/dist/logging/Logger.mjs
|
|
70
54
|
var Logger = class _Logger {
|
|
71
|
-
static {
|
|
72
|
-
__name(this, "_Logger");
|
|
73
|
-
}
|
|
74
|
-
static {
|
|
75
|
-
__name2(this, "Logger");
|
|
76
|
-
}
|
|
77
55
|
prefix;
|
|
78
56
|
raw;
|
|
79
57
|
constructor(options = {}) {
|
|
@@ -153,19 +131,15 @@ var logger = new Logger_default({
|
|
|
153
131
|
function createOperationsIdentifierText(serviceName) {
|
|
154
132
|
return `${serviceName}Operations`;
|
|
155
133
|
}
|
|
156
|
-
__name(createOperationsIdentifierText, "createOperationsIdentifierText");
|
|
157
134
|
function createOperationsIdentifier(serviceName) {
|
|
158
135
|
return ts3__default.default.factory.createIdentifier(createOperationsIdentifierText(serviceName));
|
|
159
136
|
}
|
|
160
|
-
__name(createOperationsIdentifier, "createOperationsIdentifier");
|
|
161
137
|
function isOperationsDeclaration(node) {
|
|
162
138
|
return node !== void 0 && ts3__default.default.isInterfaceDeclaration(node) && node.name.text === "operations";
|
|
163
139
|
}
|
|
164
|
-
__name(isOperationsDeclaration, "isOperationsDeclaration");
|
|
165
140
|
function isOperation(node) {
|
|
166
141
|
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);
|
|
167
142
|
}
|
|
168
|
-
__name(isOperation, "isOperation");
|
|
169
143
|
function normalizeOperation(operation, context) {
|
|
170
144
|
if (!isOperation(operation)) {
|
|
171
145
|
return void 0;
|
|
@@ -179,7 +153,6 @@ function normalizeOperation(operation, context) {
|
|
|
179
153
|
newType
|
|
180
154
|
);
|
|
181
155
|
}
|
|
182
|
-
__name(normalizeOperation, "normalizeOperation");
|
|
183
156
|
function normalizeOperations(operations, context) {
|
|
184
157
|
const newIdentifier = createOperationsIdentifier(context.serviceName);
|
|
185
158
|
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(isDefined_default);
|
|
@@ -192,7 +165,6 @@ function normalizeOperations(operations, context) {
|
|
|
192
165
|
newMembers
|
|
193
166
|
);
|
|
194
167
|
}
|
|
195
|
-
__name(normalizeOperations, "normalizeOperations");
|
|
196
168
|
function removeOperationIfUnreferenced(operation, context) {
|
|
197
169
|
if (!isOperation(operation)) {
|
|
198
170
|
return void 0;
|
|
@@ -205,7 +177,6 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
205
177
|
}
|
|
206
178
|
return void 0;
|
|
207
179
|
}
|
|
208
|
-
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
209
180
|
function removeUnreferencedOperations(operations, context) {
|
|
210
181
|
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
211
182
|
context.referencedTypes.operations.clear();
|
|
@@ -221,45 +192,35 @@ function removeUnreferencedOperations(operations, context) {
|
|
|
221
192
|
newMembers
|
|
222
193
|
);
|
|
223
194
|
}
|
|
224
|
-
__name(removeUnreferencedOperations, "removeUnreferencedOperations");
|
|
225
195
|
|
|
226
196
|
// src/typegen/openapi/transform/methods.ts
|
|
227
197
|
function isMethod(node) {
|
|
228
198
|
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));
|
|
229
199
|
}
|
|
230
|
-
__name(isMethod, "isMethod");
|
|
231
200
|
function isMethodMember(node) {
|
|
232
201
|
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));
|
|
233
202
|
}
|
|
234
|
-
__name(isMethodMember, "isMethodMember");
|
|
235
203
|
function isRequestMember(node) {
|
|
236
204
|
return ts3__default.default.isPropertySignature(node) && ts3__default.default.isIdentifier(node.name) && node.type !== void 0 && !isNeverType(node.type);
|
|
237
205
|
}
|
|
238
|
-
__name(isRequestMember, "isRequestMember");
|
|
239
206
|
function isRequestHeaders(node) {
|
|
240
207
|
return isRequestMember(node) && node.name.text === "headers" && ts3__default.default.isTypeLiteralNode(node.type);
|
|
241
208
|
}
|
|
242
|
-
__name(isRequestHeaders, "isRequestHeaders");
|
|
243
209
|
function isNormalizedRequestHeaders(node) {
|
|
244
210
|
return isRequestMember(node) && node.name.text === "headers" && ts3__default.default.isTypeLiteralNode(node.type);
|
|
245
211
|
}
|
|
246
|
-
__name(isNormalizedRequestHeaders, "isNormalizedRequestHeaders");
|
|
247
212
|
function isRequestParameters(node) {
|
|
248
213
|
return isRequestMember(node) && node.name.text === "parameters" && ts3__default.default.isTypeLiteralNode(node.type);
|
|
249
214
|
}
|
|
250
|
-
__name(isRequestParameters, "isRequestParameters");
|
|
251
215
|
function isContentPropertySignature(node) {
|
|
252
216
|
return isRequestMember(node) && node.name.text === "content" && ts3__default.default.isTypeLiteralNode(node.type);
|
|
253
217
|
}
|
|
254
|
-
__name(isContentPropertySignature, "isContentPropertySignature");
|
|
255
218
|
function isContentMember(node) {
|
|
256
219
|
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);
|
|
257
220
|
}
|
|
258
|
-
__name(isContentMember, "isContentMember");
|
|
259
221
|
function isResponse(node) {
|
|
260
222
|
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;
|
|
261
223
|
}
|
|
262
|
-
__name(isResponse, "isResponse");
|
|
263
224
|
function removeRedundantNullUnionIfNecessary(type) {
|
|
264
225
|
const containsRedundantNullUnion = ts3__default.default.isUnionTypeNode(type) && type.types.some((type2) => {
|
|
265
226
|
const isNull = ts3__default.default.isLiteralTypeNode(type2) && isNullType(type2.literal);
|
|
@@ -284,21 +245,18 @@ function removeRedundantNullUnionIfNecessary(type) {
|
|
|
284
245
|
});
|
|
285
246
|
return ts3__default.default.factory.createUnionTypeNode(typesWithoutRedundantNullUnion);
|
|
286
247
|
}
|
|
287
|
-
__name(removeRedundantNullUnionIfNecessary, "removeRedundantNullUnionIfNecessary");
|
|
288
248
|
function wrapFormDataContentType(type, context) {
|
|
289
249
|
context.typeImports.http.add("HttpFormData");
|
|
290
250
|
return ts3__default.default.factory.createTypeReferenceNode(ts3__default.default.factory.createIdentifier("HttpFormData"), [
|
|
291
251
|
renameComponentReferences(type, context)
|
|
292
252
|
]);
|
|
293
253
|
}
|
|
294
|
-
__name(wrapFormDataContentType, "wrapFormDataContentType");
|
|
295
254
|
function wrapURLEncodedContentType(type, context) {
|
|
296
255
|
context.typeImports.http.add("HttpSearchParams");
|
|
297
256
|
return ts3__default.default.factory.createTypeReferenceNode(ts3__default.default.factory.createIdentifier("HttpSearchParams"), [
|
|
298
257
|
renameComponentReferences(type, context)
|
|
299
258
|
]);
|
|
300
259
|
}
|
|
301
|
-
__name(wrapURLEncodedContentType, "wrapURLEncodedContentType");
|
|
302
260
|
function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
303
261
|
if (!isContentMember(requestBodyMember)) {
|
|
304
262
|
return void 0;
|
|
@@ -322,7 +280,6 @@ function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
|
322
280
|
)
|
|
323
281
|
};
|
|
324
282
|
}
|
|
325
|
-
__name(normalizeRequestBodyMember, "normalizeRequestBodyMember");
|
|
326
283
|
function normalizeHeaders(headers) {
|
|
327
284
|
const newHeaderMembers = headers.members.filter((header) => {
|
|
328
285
|
if (ts3__default.default.isIndexSignatureDeclaration(header)) {
|
|
@@ -338,7 +295,6 @@ function normalizeHeaders(headers) {
|
|
|
338
295
|
}
|
|
339
296
|
return ts3__default.default.factory.updateTypeLiteralNode(headers, ts3__default.default.factory.createNodeArray(newHeaderMembers));
|
|
340
297
|
}
|
|
341
|
-
__name(normalizeHeaders, "normalizeHeaders");
|
|
342
298
|
function normalizeRequestHeaders(requestHeader) {
|
|
343
299
|
if (!isRequestHeaders(requestHeader)) {
|
|
344
300
|
return void 0;
|
|
@@ -355,7 +311,6 @@ function normalizeRequestHeaders(requestHeader) {
|
|
|
355
311
|
newType
|
|
356
312
|
);
|
|
357
313
|
}
|
|
358
|
-
__name(normalizeRequestHeaders, "normalizeRequestHeaders");
|
|
359
314
|
function createHeaderForUnionByContentType(existingHeader, contentTypeName) {
|
|
360
315
|
const existingHeaderMembers = existingHeader?.type.members ?? [];
|
|
361
316
|
const contentTypeIdentifier = ts3__default.default.factory.createIdentifier('"content-type"');
|
|
@@ -371,7 +326,6 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName) {
|
|
|
371
326
|
newHeaderType
|
|
372
327
|
);
|
|
373
328
|
}
|
|
374
|
-
__name(createHeaderForUnionByContentType, "createHeaderForUnionByContentType");
|
|
375
329
|
function normalizeContentType(contentType, context, options) {
|
|
376
330
|
const { bodyQuestionToken } = options;
|
|
377
331
|
if (ts3__default.default.isIndexedAccessTypeNode(contentType)) {
|
|
@@ -398,7 +352,6 @@ function normalizeContentType(contentType, context, options) {
|
|
|
398
352
|
return ts3__default.default.factory.createUnionTypeNode(bodyMemberUnionTypes);
|
|
399
353
|
}
|
|
400
354
|
}
|
|
401
|
-
__name(normalizeContentType, "normalizeContentType");
|
|
402
355
|
function normalizeRequest(request, context) {
|
|
403
356
|
const newIdentifier = ts3__default.default.factory.createIdentifier("request");
|
|
404
357
|
const newType = normalizeContentType(request.type, context, {
|
|
@@ -410,7 +363,6 @@ function normalizeRequest(request, context) {
|
|
|
410
363
|
}
|
|
411
364
|
return ts3__default.default.factory.updatePropertySignature(request, request.modifiers, newIdentifier, void 0, newType);
|
|
412
365
|
}
|
|
413
|
-
__name(normalizeRequest, "normalizeRequest");
|
|
414
366
|
function normalizeResponseType(responseType, context, options) {
|
|
415
367
|
const { questionToken } = options;
|
|
416
368
|
if (!ts3__default.default.isTypeLiteralNode(responseType)) {
|
|
@@ -418,7 +370,6 @@ function normalizeResponseType(responseType, context, options) {
|
|
|
418
370
|
}
|
|
419
371
|
return normalizeContentType(responseType, context, { bodyQuestionToken: questionToken });
|
|
420
372
|
}
|
|
421
|
-
__name(normalizeResponseType, "normalizeResponseType");
|
|
422
373
|
var NON_NUMERIC_RESPONSE_STATUS_TO_MAPPED_TYPE = {
|
|
423
374
|
default: "HttpStatusCode",
|
|
424
375
|
"1xx": "HttpStatusCode.Information",
|
|
@@ -474,7 +425,6 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
474
425
|
}
|
|
475
426
|
};
|
|
476
427
|
}
|
|
477
|
-
__name(normalizeResponse, "normalizeResponse");
|
|
478
428
|
function normalizeResponses(responses, context) {
|
|
479
429
|
if (isNeverType(responses.type) || !ts3__default.default.isTypeLiteralNode(responses.type)) {
|
|
480
430
|
return void 0;
|
|
@@ -522,7 +472,6 @@ function normalizeResponses(responses, context) {
|
|
|
522
472
|
renameComponentReferences(newType, context)
|
|
523
473
|
);
|
|
524
474
|
}
|
|
525
|
-
__name(normalizeResponses, "normalizeResponses");
|
|
526
475
|
function normalizeMethodMember(methodMember, context) {
|
|
527
476
|
if (isMethodMember(methodMember)) {
|
|
528
477
|
if (methodMember.name.text === "requestBody") {
|
|
@@ -535,7 +484,6 @@ function normalizeMethodMember(methodMember, context) {
|
|
|
535
484
|
}
|
|
536
485
|
return void 0;
|
|
537
486
|
}
|
|
538
|
-
__name(normalizeMethodMember, "normalizeMethodMember");
|
|
539
487
|
function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
540
488
|
const newIdentifier = ts3__default.default.factory.createIdentifier("searchParams");
|
|
541
489
|
const newQuestionToken = void 0;
|
|
@@ -548,7 +496,6 @@ function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
|
548
496
|
newType
|
|
549
497
|
);
|
|
550
498
|
}
|
|
551
|
-
__name(normalizeRequestQueryWithParameters, "normalizeRequestQueryWithParameters");
|
|
552
499
|
function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
553
500
|
const newIdentifier = ts3__default.default.factory.createIdentifier("headers");
|
|
554
501
|
const newQuestionToken = void 0;
|
|
@@ -561,7 +508,6 @@ function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
|
561
508
|
newType
|
|
562
509
|
);
|
|
563
510
|
}
|
|
564
|
-
__name(normalizeRequestHeadersWithParameters, "normalizeRequestHeadersWithParameters");
|
|
565
511
|
function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
566
512
|
if (!isRequestMember(requestMember) || requestMember.name.text === "path") {
|
|
567
513
|
return void 0;
|
|
@@ -574,7 +520,6 @@ function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
|
574
520
|
}
|
|
575
521
|
return requestMember;
|
|
576
522
|
}
|
|
577
|
-
__name(normalizeRequestMemberWithParameters, "normalizeRequestMemberWithParameters");
|
|
578
523
|
function mergeRequestHeadersMember(headers, otherHeaders) {
|
|
579
524
|
const newType = ts3__default.default.factory.updateTypeLiteralNode(
|
|
580
525
|
headers.type,
|
|
@@ -588,7 +533,6 @@ function mergeRequestHeadersMember(headers, otherHeaders) {
|
|
|
588
533
|
newType
|
|
589
534
|
);
|
|
590
535
|
}
|
|
591
|
-
__name(mergeRequestHeadersMember, "mergeRequestHeadersMember");
|
|
592
536
|
function mergeRequestHeadersMembers(members) {
|
|
593
537
|
let mergedHeaders;
|
|
594
538
|
let firstHeadersIndex;
|
|
@@ -609,7 +553,6 @@ function mergeRequestHeadersMembers(members) {
|
|
|
609
553
|
}
|
|
610
554
|
return mergedHeadersMembers.filter(isDefined_default);
|
|
611
555
|
}
|
|
612
|
-
__name(mergeRequestHeadersMembers, "mergeRequestHeadersMembers");
|
|
613
556
|
function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
614
557
|
const parameters = methodMembers.find(isRequestParameters);
|
|
615
558
|
const parametersMembers = parameters ? parameters.type.members : [];
|
|
@@ -624,7 +567,6 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
624
567
|
}
|
|
625
568
|
return ts3__default.default.factory.createTypeLiteralNode(newMembers);
|
|
626
569
|
}
|
|
627
|
-
__name(mergeRequestAndParameterTypes, "mergeRequestAndParameterTypes");
|
|
628
570
|
function normalizeRequestTypeWithParameters(requestType, methodMembers, context) {
|
|
629
571
|
if (ts3__default.default.isUnionTypeNode(requestType)) {
|
|
630
572
|
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(isDefined_default);
|
|
@@ -636,7 +578,6 @@ function normalizeRequestTypeWithParameters(requestType, methodMembers, context)
|
|
|
636
578
|
}
|
|
637
579
|
return mergeRequestAndParameterTypes(requestType, methodMembers, context);
|
|
638
580
|
}
|
|
639
|
-
__name(normalizeRequestTypeWithParameters, "normalizeRequestTypeWithParameters");
|
|
640
581
|
function normalizeMethodMemberWithParameters(methodMember, methodMembers, context) {
|
|
641
582
|
if (!ts3__default.default.isIdentifier(methodMember.name) || !methodMember.type) {
|
|
642
583
|
return void 0;
|
|
@@ -659,12 +600,10 @@ function normalizeMethodMemberWithParameters(methodMember, methodMembers, contex
|
|
|
659
600
|
}
|
|
660
601
|
return void 0;
|
|
661
602
|
}
|
|
662
|
-
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
663
603
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
664
604
|
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(isDefined_default).map((member, _index, partialMembers) => normalizeMethodMemberWithParameters(member, partialMembers, context)).filter(isDefined_default);
|
|
665
605
|
return ts3__default.default.factory.updateTypeLiteralNode(methodType, ts3__default.default.factory.createNodeArray(newMembers));
|
|
666
606
|
}
|
|
667
|
-
__name(normalizeTypeLiteralMethodType, "normalizeTypeLiteralMethodType");
|
|
668
607
|
function normalizeIndexedAccessMethodType(methodType, context) {
|
|
669
608
|
const isOperationsReference = ts3__default.default.isTypeReferenceNode(methodType.objectType) && ts3__default.default.isIdentifier(methodType.objectType.typeName) && methodType.objectType.typeName.text === "operations";
|
|
670
609
|
if (!isOperationsReference) {
|
|
@@ -679,7 +618,6 @@ function normalizeIndexedAccessMethodType(methodType, context) {
|
|
|
679
618
|
}
|
|
680
619
|
return ts3__default.default.factory.updateIndexedAccessTypeNode(methodType, newObjectType, methodType.indexType);
|
|
681
620
|
}
|
|
682
|
-
__name(normalizeIndexedAccessMethodType, "normalizeIndexedAccessMethodType");
|
|
683
621
|
function normalizeMethod(method, context, options) {
|
|
684
622
|
if (!isMethod(method)) {
|
|
685
623
|
return void 0;
|
|
@@ -689,13 +627,13 @@ function normalizeMethod(method, context, options) {
|
|
|
689
627
|
return void 0;
|
|
690
628
|
}
|
|
691
629
|
const matchesPositiveFilters = context.filters.paths.positive.length === 0 || context.filters.paths.positive.some(
|
|
692
|
-
(filter) => filter.
|
|
630
|
+
(filter) => filter.methodRegex.test(methodName) && filter.pathRegex.test(options.pathName)
|
|
693
631
|
);
|
|
694
632
|
if (!matchesPositiveFilters) {
|
|
695
633
|
return void 0;
|
|
696
634
|
}
|
|
697
635
|
const matchesNegativeFilters = context.filters.paths.negative.length > 0 && context.filters.paths.negative.some(
|
|
698
|
-
(filter) => filter.
|
|
636
|
+
(filter) => filter.methodRegex.test(methodName) && filter.pathRegex.test(options.pathName)
|
|
699
637
|
);
|
|
700
638
|
if (matchesNegativeFilters) {
|
|
701
639
|
return void 0;
|
|
@@ -704,23 +642,18 @@ function normalizeMethod(method, context, options) {
|
|
|
704
642
|
const newType = ts3__default.default.isTypeLiteralNode(method.type) ? normalizeTypeLiteralMethodType(method.type, context) : normalizeIndexedAccessMethodType(method.type, context);
|
|
705
643
|
return ts3__default.default.factory.updatePropertySignature(method, method.modifiers, newIdentifier, method.questionToken, newType);
|
|
706
644
|
}
|
|
707
|
-
__name(normalizeMethod, "normalizeMethod");
|
|
708
645
|
function createPathsIdentifier(serviceName) {
|
|
709
646
|
return ts3__default.default.factory.createIdentifier(`${serviceName}Schema`);
|
|
710
647
|
}
|
|
711
|
-
__name(createPathsIdentifier, "createPathsIdentifier");
|
|
712
648
|
function isPathsDeclaration(node) {
|
|
713
649
|
return node !== void 0 && (ts3__default.default.isInterfaceDeclaration(node) || ts3__default.default.isTypeAliasDeclaration(node)) && node.name.text === "paths";
|
|
714
650
|
}
|
|
715
|
-
__name(isPathsDeclaration, "isPathsDeclaration");
|
|
716
651
|
function isPath(node) {
|
|
717
652
|
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));
|
|
718
653
|
}
|
|
719
|
-
__name(isPath, "isPath");
|
|
720
654
|
function normalizePathNameWithParameters(pathName) {
|
|
721
655
|
return pathName.replace(/{([^}]+)}/g, ":$1");
|
|
722
656
|
}
|
|
723
|
-
__name(normalizePathNameWithParameters, "normalizePathNameWithParameters");
|
|
724
657
|
function normalizePath(path4, context, options = {}) {
|
|
725
658
|
const { isComponent: isComponent2 = false } = options;
|
|
726
659
|
if (!isPath(path4)) {
|
|
@@ -740,13 +673,11 @@ function normalizePath(path4, context, options = {}) {
|
|
|
740
673
|
}
|
|
741
674
|
return ts3__default.default.factory.updatePropertySignature(path4, path4.modifiers, newIdentifier, path4.questionToken, newType);
|
|
742
675
|
}
|
|
743
|
-
__name(normalizePath, "normalizePath");
|
|
744
676
|
function wrapPathsType(type, context) {
|
|
745
677
|
context.typeImports.http.add("HttpSchema");
|
|
746
678
|
const httpSchemaPathsWrapper = ts3__default.default.factory.createIdentifier("HttpSchema");
|
|
747
679
|
return ts3__default.default.factory.createTypeReferenceNode(httpSchemaPathsWrapper, [type]);
|
|
748
680
|
}
|
|
749
|
-
__name(wrapPathsType, "wrapPathsType");
|
|
750
681
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
751
682
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
752
683
|
const paths = ts3__default.default.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3__default.default.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, void 0, void 0, []) : pathsOrTypeAlias;
|
|
@@ -759,38 +690,30 @@ function normalizePaths(pathsOrTypeAlias, context) {
|
|
|
759
690
|
wrapPathsType(newType, context)
|
|
760
691
|
);
|
|
761
692
|
}
|
|
762
|
-
__name(normalizePaths, "normalizePaths");
|
|
763
693
|
|
|
764
694
|
// src/typegen/openapi/transform/components.ts
|
|
765
695
|
function createComponentsIdentifierText(serviceName) {
|
|
766
696
|
return `${serviceName}Components`;
|
|
767
697
|
}
|
|
768
|
-
__name(createComponentsIdentifierText, "createComponentsIdentifierText");
|
|
769
698
|
function createComponentsIdentifier(serviceName) {
|
|
770
699
|
return ts3__default.default.factory.createIdentifier(createComponentsIdentifierText(serviceName));
|
|
771
700
|
}
|
|
772
|
-
__name(createComponentsIdentifier, "createComponentsIdentifier");
|
|
773
701
|
function isComponentsDeclaration(node, context) {
|
|
774
702
|
const componentIdentifiers = ["components", createComponentsIdentifierText(context.serviceName)];
|
|
775
703
|
return node !== void 0 && ts3__default.default.isInterfaceDeclaration(node) && componentIdentifiers.includes(node.name.text);
|
|
776
704
|
}
|
|
777
|
-
__name(isComponentsDeclaration, "isComponentsDeclaration");
|
|
778
705
|
function isComponentGroup(node) {
|
|
779
706
|
return ts3__default.default.isPropertySignature(node) && node.type !== void 0 && ts3__default.default.isTypeLiteralNode(node.type) && ts3__default.default.isIdentifier(node.name);
|
|
780
707
|
}
|
|
781
|
-
__name(isComponentGroup, "isComponentGroup");
|
|
782
708
|
function isComponent(node) {
|
|
783
709
|
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));
|
|
784
710
|
}
|
|
785
|
-
__name(isComponent, "isComponent");
|
|
786
711
|
function isRequestComponent(node) {
|
|
787
712
|
return ts3__default.default.isTypeLiteralNode(node.type);
|
|
788
713
|
}
|
|
789
|
-
__name(isRequestComponent, "isRequestComponent");
|
|
790
714
|
function unchangedIndexedAccessTypeNode(node) {
|
|
791
715
|
return node;
|
|
792
716
|
}
|
|
793
|
-
__name(unchangedIndexedAccessTypeNode, "unchangedIndexedAccessTypeNode");
|
|
794
717
|
function visitComponentReferences(node, context, options) {
|
|
795
718
|
const { onComponentReference, renameComponentReference = unchangedIndexedAccessTypeNode } = options;
|
|
796
719
|
if (isUnknownType(node)) {
|
|
@@ -875,14 +798,12 @@ function visitComponentReferences(node, context, options) {
|
|
|
875
798
|
}
|
|
876
799
|
return node;
|
|
877
800
|
}
|
|
878
|
-
__name(visitComponentReferences, "visitComponentReferences");
|
|
879
801
|
function normalizeComponentGroupName(rawComponentGroupName) {
|
|
880
802
|
if (rawComponentGroupName === "requestBodies") {
|
|
881
803
|
return "requests";
|
|
882
804
|
}
|
|
883
805
|
return rawComponentGroupName;
|
|
884
806
|
}
|
|
885
|
-
__name(normalizeComponentGroupName, "normalizeComponentGroupName");
|
|
886
807
|
function renameComponentReferences(node, context) {
|
|
887
808
|
return visitComponentReferences(node, context, {
|
|
888
809
|
onComponentReference(_node, componentPath) {
|
|
@@ -900,7 +821,6 @@ function renameComponentReferences(node, context) {
|
|
|
900
821
|
}
|
|
901
822
|
});
|
|
902
823
|
}
|
|
903
|
-
__name(renameComponentReferences, "renameComponentReferences");
|
|
904
824
|
function processPendingRequestComponentActions(component, context) {
|
|
905
825
|
const pendingRequestActions = context.pendingActions.components.requests;
|
|
906
826
|
const componentName = component.name.text;
|
|
@@ -909,7 +829,6 @@ function processPendingRequestComponentActions(component, context) {
|
|
|
909
829
|
pendingRequestActions.toMarkBodyAsOptional.delete(componentName);
|
|
910
830
|
return { bodyQuestionToken };
|
|
911
831
|
}
|
|
912
|
-
__name(processPendingRequestComponentActions, "processPendingRequestComponentActions");
|
|
913
832
|
function normalizeRequestComponent(component, context) {
|
|
914
833
|
if (!isRequestComponent(component)) {
|
|
915
834
|
return void 0;
|
|
@@ -924,7 +843,6 @@ function normalizeRequestComponent(component, context) {
|
|
|
924
843
|
newType
|
|
925
844
|
);
|
|
926
845
|
}
|
|
927
|
-
__name(normalizeRequestComponent, "normalizeRequestComponent");
|
|
928
846
|
function normalizeComponent(component, componentGroupName, context) {
|
|
929
847
|
if (!isComponent(component)) {
|
|
930
848
|
return void 0;
|
|
@@ -947,7 +865,6 @@ function normalizeComponent(component, componentGroupName, context) {
|
|
|
947
865
|
renameComponentReferences(component.type, context)
|
|
948
866
|
);
|
|
949
867
|
}
|
|
950
|
-
__name(normalizeComponent, "normalizeComponent");
|
|
951
868
|
function normalizeComponentGroup(componentGroup, context) {
|
|
952
869
|
if (!isComponentGroup(componentGroup)) {
|
|
953
870
|
return void 0;
|
|
@@ -964,7 +881,6 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
964
881
|
newType
|
|
965
882
|
);
|
|
966
883
|
}
|
|
967
|
-
__name(normalizeComponentGroup, "normalizeComponentGroup");
|
|
968
884
|
function normalizeComponents(components, context) {
|
|
969
885
|
const newIdentifier = createComponentsIdentifier(context.serviceName);
|
|
970
886
|
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(isDefined_default);
|
|
@@ -977,7 +893,6 @@ function normalizeComponents(components, context) {
|
|
|
977
893
|
newMembers
|
|
978
894
|
);
|
|
979
895
|
}
|
|
980
|
-
__name(normalizeComponents, "normalizeComponents");
|
|
981
896
|
function populateReferencedComponents(components, context) {
|
|
982
897
|
const pathsToVisit = new Set(context.referencedTypes.components);
|
|
983
898
|
while (pathsToVisit.size > 0) {
|
|
@@ -1011,7 +926,6 @@ function populateReferencedComponents(components, context) {
|
|
|
1011
926
|
}
|
|
1012
927
|
}
|
|
1013
928
|
}
|
|
1014
|
-
__name(populateReferencedComponents, "populateReferencedComponents");
|
|
1015
929
|
function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
1016
930
|
if (!isComponent(component)) {
|
|
1017
931
|
return void 0;
|
|
@@ -1024,7 +938,6 @@ function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
|
1024
938
|
}
|
|
1025
939
|
return void 0;
|
|
1026
940
|
}
|
|
1027
|
-
__name(removeComponentIfUnreferenced, "removeComponentIfUnreferenced");
|
|
1028
941
|
function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
1029
942
|
if (!isComponentGroup(componentGroup)) {
|
|
1030
943
|
return void 0;
|
|
@@ -1042,7 +955,6 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
1042
955
|
ts3__default.default.factory.updateTypeLiteralNode(componentGroup.type, ts3__default.default.factory.createNodeArray(newComponents))
|
|
1043
956
|
);
|
|
1044
957
|
}
|
|
1045
|
-
__name(removeUnreferencedComponentsInGroup, "removeUnreferencedComponentsInGroup");
|
|
1046
958
|
function removeUnreferencedComponents(components, context) {
|
|
1047
959
|
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1048
960
|
context.referencedTypes.components.clear();
|
|
@@ -1058,136 +970,53 @@ function removeUnreferencedComponents(components, context) {
|
|
|
1058
970
|
newComponentGroups
|
|
1059
971
|
);
|
|
1060
972
|
}
|
|
1061
|
-
__name(removeUnreferencedComponents, "removeUnreferencedComponents");
|
|
1062
973
|
|
|
1063
974
|
// src/utils/strings.ts
|
|
1064
975
|
function convertToPascalCase(value) {
|
|
1065
976
|
return value.replace(/(?:^|[^A-Za-z\d])([A-Za-z\d])/g, (_match, letter) => letter.toUpperCase());
|
|
1066
977
|
}
|
|
1067
|
-
__name(convertToPascalCase, "convertToPascalCase");
|
|
1068
978
|
|
|
1069
979
|
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
1070
980
|
function isNonEmpty(value) {
|
|
1071
981
|
return isDefined_default(value) && value !== "";
|
|
1072
982
|
}
|
|
1073
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
1074
|
-
__name2(isNonEmpty, "isNonEmpty");
|
|
1075
983
|
var isNonEmpty_default = isNonEmpty;
|
|
1076
984
|
|
|
1077
|
-
// ../zimic-utils/dist/chunk-
|
|
1078
|
-
function
|
|
985
|
+
// ../zimic-utils/dist/chunk-TYSDS3LQ.mjs
|
|
986
|
+
function createPathCharactersToEscapeRegex() {
|
|
1079
987
|
return /([.(){}+$])/g;
|
|
1080
988
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
__name(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
1087
|
-
__name2(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
1088
|
-
function getPathParamPattern() {
|
|
1089
|
-
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)/gu;
|
|
1090
|
-
}
|
|
1091
|
-
__name(getPathParamPattern, "getPathParamPattern");
|
|
1092
|
-
__name2(getPathParamPattern, "getPathParamPattern");
|
|
1093
|
-
function getRepeatingPathParamPattern() {
|
|
1094
|
-
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\\+/gu;
|
|
1095
|
-
}
|
|
1096
|
-
__name(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
1097
|
-
__name2(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
1098
|
-
function getOptionalPathParamPattern() {
|
|
1099
|
-
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\?(?<trailingSlash>\/)?/gu;
|
|
1100
|
-
}
|
|
1101
|
-
__name(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
1102
|
-
__name2(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
1103
|
-
function getOptionalRepeatingPathParamPattern() {
|
|
1104
|
-
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\*(?<trailingSlash>\/)?/gu;
|
|
1105
|
-
}
|
|
1106
|
-
__name(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
1107
|
-
__name2(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
1108
|
-
function createParametrizedPathPattern(path4) {
|
|
1109
|
-
const replacedURL = encodeURI(path4).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(
|
|
1110
|
-
getOptionalRepeatingPathParamPattern(),
|
|
1111
|
-
(_match, leadingSlash, escape, identifier, trailingSlash) => {
|
|
1112
|
-
if (escape) {
|
|
1113
|
-
return `:${identifier}`;
|
|
1114
|
-
}
|
|
1115
|
-
const hasSegmentBeforePrefix = leadingSlash === "/";
|
|
1116
|
-
const prefixExpression = hasSegmentBeforePrefix ? "/?" : leadingSlash;
|
|
1117
|
-
const hasSegmentAfterSuffix = trailingSlash === "/";
|
|
1118
|
-
const suffixExpression = hasSegmentAfterSuffix ? "/?" : trailingSlash;
|
|
1119
|
-
if (prefixExpression && suffixExpression) {
|
|
1120
|
-
return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;
|
|
1121
|
-
} else if (prefixExpression) {
|
|
1122
|
-
return `(?:${prefixExpression}(?<${identifier}>.+?))?`;
|
|
1123
|
-
} else if (suffixExpression) {
|
|
1124
|
-
return `(?:(?<${identifier}>.+?)${suffixExpression})?`;
|
|
1125
|
-
} else {
|
|
1126
|
-
return `(?<${identifier}>.+?)?`;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
).replace(getRepeatingPathParamPattern(), (_match, escape, identifier) => {
|
|
1130
|
-
return escape ? `:${identifier}` : `(?<${identifier}>.+)`;
|
|
1131
|
-
}).replace(
|
|
1132
|
-
getOptionalPathParamPattern(),
|
|
1133
|
-
(_match, leadingSlash, escape, identifier, trailingSlash) => {
|
|
1134
|
-
if (escape) {
|
|
1135
|
-
return `:${identifier}`;
|
|
1136
|
-
}
|
|
1137
|
-
const hasSegmentBeforePrefix = leadingSlash === "/";
|
|
1138
|
-
const prefixExpression = hasSegmentBeforePrefix ? "/?" : leadingSlash;
|
|
1139
|
-
const hasSegmentAfterSuffix = trailingSlash === "/";
|
|
1140
|
-
const suffixExpression = hasSegmentAfterSuffix ? "/?" : trailingSlash;
|
|
1141
|
-
if (prefixExpression && suffixExpression) {
|
|
1142
|
-
return `(?:${prefixExpression}(?<${identifier}>[^\\/]+?)?${suffixExpression})`;
|
|
1143
|
-
} else if (prefixExpression) {
|
|
1144
|
-
return `(?:${prefixExpression}(?<${identifier}>[^\\/]+?))?`;
|
|
1145
|
-
} else if (suffixExpression) {
|
|
1146
|
-
return `(?:(?<${identifier}>[^\\/]+?)${suffixExpression})?`;
|
|
1147
|
-
} else {
|
|
1148
|
-
return `(?<${identifier}>[^\\/]+?)?`;
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
).replace(getPathParamPattern(), (_match, escape, identifier) => {
|
|
1152
|
-
return escape ? `:${identifier}` : `(?<${identifier}>[^\\/]+?)`;
|
|
1153
|
-
});
|
|
1154
|
-
return new RegExp(`^/?${replacedURL}/?$`);
|
|
989
|
+
function preparePathForRegex(path4) {
|
|
990
|
+
const pathURLPrefix = `data:${path4.startsWith("/") ? "" : "/"}`;
|
|
991
|
+
const pathAsURL = new URL(`${pathURLPrefix}${path4}`);
|
|
992
|
+
const encodedPath = pathAsURL.href.replace(pathURLPrefix, "");
|
|
993
|
+
return encodedPath.replace(/^\/+/g, "").replace(/\/+$/g, "").replace(createPathCharactersToEscapeRegex(), "\\$1");
|
|
1155
994
|
}
|
|
1156
|
-
__name(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1157
|
-
__name2(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1158
995
|
|
|
1159
|
-
// ../zimic-utils/dist/url/
|
|
1160
|
-
function
|
|
996
|
+
// ../zimic-utils/dist/url/createWildcardRegexFromPath.mjs
|
|
997
|
+
function getSingleWildcardPathRegex() {
|
|
1161
998
|
return /(?<wildcardPrefix>^|[^*])(?<escape>\\)?\*(?<wildcardSuffix>[^*]|$)/g;
|
|
1162
999
|
}
|
|
1163
|
-
|
|
1164
|
-
__name2(getSingleWildcardPattern, "getSingleWildcardPattern");
|
|
1165
|
-
function getDoubleWildcardPattern() {
|
|
1000
|
+
function getDoubleWildcardPathRegex() {
|
|
1166
1001
|
return /(?<escape>\\)?\*\*/g;
|
|
1167
1002
|
}
|
|
1168
|
-
|
|
1169
|
-
__name2(getDoubleWildcardPattern, "getDoubleWildcardPattern");
|
|
1170
|
-
function getTripleWildcardPattern() {
|
|
1003
|
+
function getTripleWildcardPathRegex() {
|
|
1171
1004
|
return /(?<escape>\\)?\*\*\/\*(?<wildcardSuffix>[^*]|$)/g;
|
|
1172
1005
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
function createWildcardPathPattern(path4) {
|
|
1176
|
-
const replacedURL = encodeURI(path4).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(getTripleWildcardPattern(), (_match, escape, wildcardSuffix) => {
|
|
1006
|
+
function createWildcardRegexFromPath(path4) {
|
|
1007
|
+
const pathRegexContent = preparePathForRegex(path4).replace(getTripleWildcardPathRegex(), (_match, escape, wildcardSuffix) => {
|
|
1177
1008
|
return escape === "\\" ? `\\*\\*/\\*${wildcardSuffix}` : `**${wildcardSuffix}`;
|
|
1178
1009
|
}).replace(
|
|
1179
|
-
|
|
1010
|
+
getSingleWildcardPathRegex(),
|
|
1180
1011
|
(_match, wildcardPrefix, escape, wildcardSuffix) => {
|
|
1181
1012
|
return escape === "\\" ? `${wildcardPrefix}\\*${wildcardSuffix}` : `${wildcardPrefix}[^/]*${wildcardSuffix}`;
|
|
1182
1013
|
}
|
|
1183
|
-
).replace(
|
|
1014
|
+
).replace(getDoubleWildcardPathRegex(), (_match, escape) => {
|
|
1184
1015
|
return escape === "\\" ? "\\*\\*" : ".*";
|
|
1185
1016
|
});
|
|
1186
|
-
return new RegExp(`^/?${
|
|
1017
|
+
return new RegExp(`^/?${pathRegexContent}/?$`);
|
|
1187
1018
|
}
|
|
1188
|
-
|
|
1189
|
-
__name2(createWildcardPathPattern, "createWildcardPathPattern");
|
|
1190
|
-
var createWildcardPathPattern_default = createWildcardPathPattern;
|
|
1019
|
+
var createWildcardRegexFromPath_default = createWildcardRegexFromPath;
|
|
1191
1020
|
var HTTP_METHOD_OPTIONS = HTTP_METHODS.join("|");
|
|
1192
1021
|
var MODIFIER_GROUP = "(?<modifier>!?)";
|
|
1193
1022
|
var METHOD_FILTER_GROUP = `(?<method>(?:\\*|(?:${HTTP_METHOD_OPTIONS})(?:,\\s*(?:${HTTP_METHOD_OPTIONS}))*))`;
|
|
@@ -1202,12 +1031,11 @@ function parseRawFilter(rawFilter) {
|
|
|
1202
1031
|
return void 0;
|
|
1203
1032
|
}
|
|
1204
1033
|
return {
|
|
1205
|
-
|
|
1206
|
-
|
|
1034
|
+
methodRegex: new RegExp(`(?:${filteredMethodsOrWildcard.toUpperCase().replace(/,/g, "|").replace(/\*/g, ".*")})`),
|
|
1035
|
+
pathRegex: createWildcardRegexFromPath_default(filteredPath),
|
|
1207
1036
|
isNegativeMatch: filterModifier === "!"
|
|
1208
1037
|
};
|
|
1209
1038
|
}
|
|
1210
|
-
__name(parseRawFilter, "parseRawFilter");
|
|
1211
1039
|
function groupParsedFiltersByMatch(parsedFilters) {
|
|
1212
1040
|
return parsedFilters.reduce(
|
|
1213
1041
|
(groupedFilters, filter) => {
|
|
@@ -1223,18 +1051,15 @@ function groupParsedFiltersByMatch(parsedFilters) {
|
|
|
1223
1051
|
{ positive: [], negative: [] }
|
|
1224
1052
|
);
|
|
1225
1053
|
}
|
|
1226
|
-
__name(groupParsedFiltersByMatch, "groupParsedFiltersByMatch");
|
|
1227
1054
|
async function readPathFiltersFromFile(filePath) {
|
|
1228
1055
|
const fileContent = await filesystem__default.default.readFile(path__default.default.resolve(filePath), "utf-8");
|
|
1229
1056
|
const fileContentWithoutComments = fileContent.replace(/#.*$/gm, "");
|
|
1230
1057
|
const filters = fileContentWithoutComments.split("\n");
|
|
1231
1058
|
return filters;
|
|
1232
1059
|
}
|
|
1233
|
-
__name(readPathFiltersFromFile, "readPathFiltersFromFile");
|
|
1234
1060
|
function ignoreEmptyFilters(filters) {
|
|
1235
1061
|
return filters.map((line) => line.trim()).filter(isNonEmpty_default);
|
|
1236
1062
|
}
|
|
1237
|
-
__name(ignoreEmptyFilters, "ignoreEmptyFilters");
|
|
1238
1063
|
|
|
1239
1064
|
// src/typegen/openapi/transform/context.ts
|
|
1240
1065
|
function createTypeTransformationContext(serviceName, rawFilters) {
|
|
@@ -1258,29 +1083,23 @@ function createTypeTransformationContext(serviceName, rawFilters) {
|
|
|
1258
1083
|
}
|
|
1259
1084
|
};
|
|
1260
1085
|
}
|
|
1261
|
-
__name(createTypeTransformationContext, "createTypeTransformationContext");
|
|
1262
1086
|
|
|
1263
1087
|
// src/typegen/openapi/transform/imports.ts
|
|
1264
1088
|
var TYPEGEN_HTTP_IMPORT_MODULE = "@zimic/http";
|
|
1265
1089
|
function createImportDeclarations(context) {
|
|
1266
1090
|
const httpTypeImports = Array.from(context.typeImports.http).sort().map(createImportSpecifier);
|
|
1267
|
-
const httpImportDeclaration = createImportDeclaration(httpTypeImports, TYPEGEN_HTTP_IMPORT_MODULE
|
|
1268
|
-
typeOnly: true
|
|
1269
|
-
});
|
|
1091
|
+
const httpImportDeclaration = createImportDeclaration(httpTypeImports, TYPEGEN_HTTP_IMPORT_MODULE);
|
|
1270
1092
|
return [httpImportDeclaration];
|
|
1271
1093
|
}
|
|
1272
|
-
__name(createImportDeclarations, "createImportDeclarations");
|
|
1273
1094
|
|
|
1274
1095
|
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
1275
1096
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
1276
1097
|
let cachedImportResult;
|
|
1277
|
-
return
|
|
1098
|
+
return async function importModuleDynamicallyWithCache() {
|
|
1278
1099
|
cachedImportResult ??= await importModuleDynamically();
|
|
1279
1100
|
return cachedImportResult;
|
|
1280
|
-
}
|
|
1101
|
+
};
|
|
1281
1102
|
}
|
|
1282
|
-
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1283
|
-
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1284
1103
|
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
1285
1104
|
var importOpenapiTypeScript = createCachedDynamicImport_default(() => import('openapi-typescript'));
|
|
1286
1105
|
function transformSchemaObject(schemaObject) {
|
|
@@ -1293,7 +1112,6 @@ function transformSchemaObject(schemaObject) {
|
|
|
1293
1112
|
return blobType;
|
|
1294
1113
|
}
|
|
1295
1114
|
}
|
|
1296
|
-
__name(transformSchemaObject, "transformSchemaObject");
|
|
1297
1115
|
function convertFilePathOrURLToURL(filePathOrURL) {
|
|
1298
1116
|
try {
|
|
1299
1117
|
return new URL(filePathOrURL);
|
|
@@ -1301,7 +1119,6 @@ function convertFilePathOrURLToURL(filePathOrURL) {
|
|
|
1301
1119
|
return new URL(`file://${path__default.default.resolve(filePathOrURL)}`);
|
|
1302
1120
|
}
|
|
1303
1121
|
}
|
|
1304
|
-
__name(convertFilePathOrURLToURL, "convertFilePathOrURLToURL");
|
|
1305
1122
|
async function importTypesFromOpenAPI(filePathOrURL) {
|
|
1306
1123
|
const schemaURL = convertFilePathOrURLToURL(filePathOrURL);
|
|
1307
1124
|
const { default: generateTypesFromOpenAPI2 } = await importOpenapiTypeScript();
|
|
@@ -1323,7 +1140,6 @@ async function importTypesFromOpenAPI(filePathOrURL) {
|
|
|
1323
1140
|
});
|
|
1324
1141
|
return rawNodes;
|
|
1325
1142
|
}
|
|
1326
|
-
__name(importTypesFromOpenAPI, "importTypesFromOpenAPI");
|
|
1327
1143
|
async function convertTypesToString(nodes, options) {
|
|
1328
1144
|
const { astToString: convertTypeASTToString } = await importOpenapiTypeScript();
|
|
1329
1145
|
const typeOutput = convertTypeASTToString(nodes, {
|
|
@@ -1331,7 +1147,6 @@ async function convertTypesToString(nodes, options) {
|
|
|
1331
1147
|
});
|
|
1332
1148
|
return typeOutput;
|
|
1333
1149
|
}
|
|
1334
|
-
__name(convertTypesToString, "convertTypesToString");
|
|
1335
1150
|
function prepareTypeOutputToSave(output) {
|
|
1336
1151
|
const formattedOutput = output.replace(/^export (\w+)/gm, "\nexport $1").replace(/^( {4})+/gm, (match) => match.replace(/ {4}/g, " "));
|
|
1337
1152
|
const formattedOutputWithPrefix = [
|
|
@@ -1341,13 +1156,11 @@ function prepareTypeOutputToSave(output) {
|
|
|
1341
1156
|
].join("\n");
|
|
1342
1157
|
return formattedOutputWithPrefix;
|
|
1343
1158
|
}
|
|
1344
|
-
__name(prepareTypeOutputToSave, "prepareTypeOutputToSave");
|
|
1345
1159
|
async function writeTypeOutputToStandardOutput(formattedOutput) {
|
|
1346
1160
|
await new Promise((resolve) => {
|
|
1347
1161
|
process.stdout.write(formattedOutput, "utf-8", resolve);
|
|
1348
1162
|
});
|
|
1349
1163
|
}
|
|
1350
|
-
__name(writeTypeOutputToStandardOutput, "writeTypeOutputToStandardOutput");
|
|
1351
1164
|
|
|
1352
1165
|
// src/typegen/openapi/generate.ts
|
|
1353
1166
|
var RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED = ["paths", "webhooks", "operations", "components", "$defs"];
|
|
@@ -1358,7 +1171,6 @@ function removeUnknownResources(node) {
|
|
|
1358
1171
|
}
|
|
1359
1172
|
return node;
|
|
1360
1173
|
}
|
|
1361
|
-
__name(removeUnknownResources, "removeUnknownResources");
|
|
1362
1174
|
function normalizeRawNodes(rawNodes, context, options) {
|
|
1363
1175
|
let normalizedNodes = rawNodes.map((node) => isPathsDeclaration(node) ? normalizePaths(node, context) : node);
|
|
1364
1176
|
if (options.prune) {
|
|
@@ -1376,7 +1188,6 @@ function normalizeRawNodes(rawNodes, context, options) {
|
|
|
1376
1188
|
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(isDefined_default);
|
|
1377
1189
|
return normalizedNodes;
|
|
1378
1190
|
}
|
|
1379
|
-
__name(normalizeRawNodes, "normalizeRawNodes");
|
|
1380
1191
|
async function generateTypesFromOpenAPI({
|
|
1381
1192
|
input: inputFilePathOrURL,
|
|
1382
1193
|
output: outputFilePath,
|
|
@@ -1404,7 +1215,6 @@ async function generateTypesFromOpenAPI({
|
|
|
1404
1215
|
await filesystem__default.default.writeFile(path__default.default.resolve(outputFilePath), formattedOutput);
|
|
1405
1216
|
}
|
|
1406
1217
|
}
|
|
1407
|
-
__name(generateTypesFromOpenAPI, "generateTypesFromOpenAPI");
|
|
1408
1218
|
var generate_default = generateTypesFromOpenAPI;
|
|
1409
1219
|
/* istanbul ignore if -- @preserve
|
|
1410
1220
|
* Operation members are always expected to be an operation. */
|
|
@@ -1446,8 +1256,7 @@ var generate_default = generateTypesFromOpenAPI;
|
|
|
1446
1256
|
/* istanbul ignore next -- @preserve
|
|
1447
1257
|
* The root import module is defined at build time. The fallback is not expected to be used. */
|
|
1448
1258
|
|
|
1449
|
-
exports.__name = __name;
|
|
1450
1259
|
exports.generate_default = generate_default;
|
|
1451
1260
|
exports.logger = logger;
|
|
1452
|
-
//# sourceMappingURL=chunk-
|
|
1453
|
-
//# sourceMappingURL=chunk-
|
|
1261
|
+
//# sourceMappingURL=chunk-OFNBRVSF.js.map
|
|
1262
|
+
//# sourceMappingURL=chunk-OFNBRVSF.js.map
|