@zimic/http 1.1.2-canary.2 → 1.1.2-canary.3
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-NMM3FZVR.mjs → chunk-DYXOLS3Q.mjs} +9 -202
- package/dist/chunk-DYXOLS3Q.mjs.map +1 -0
- package/dist/{chunk-JYYTLDL3.js → chunk-Q2OMLMIK.js} +8 -202
- package/dist/chunk-Q2OMLMIK.js.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/dist/chunk-JYYTLDL3.js.map +0 -1
- package/dist/chunk-NMM3FZVR.mjs.map +0 -1
|
@@ -3,68 +3,46 @@ import path from 'path';
|
|
|
3
3
|
import ts3 from 'typescript';
|
|
4
4
|
import color from 'picocolors';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
|
|
9
|
-
// ../zimic-utils/dist/chunk-2D3UJWOA.mjs
|
|
10
|
-
var __defProp2 = Object.defineProperty;
|
|
11
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
12
|
-
|
|
13
|
-
// ../zimic-utils/dist/chunk-WC2DBWWR.mjs
|
|
6
|
+
// ../zimic-utils/dist/chunk-5UH44FTS.mjs
|
|
14
7
|
function isDefined(value) {
|
|
15
8
|
return value !== void 0 && value !== null;
|
|
16
9
|
}
|
|
17
|
-
__name(isDefined, "isDefined");
|
|
18
|
-
__name2(isDefined, "isDefined");
|
|
19
10
|
var isDefined_default = isDefined;
|
|
20
11
|
function isNeverType(type) {
|
|
21
12
|
return type.kind === ts3.SyntaxKind.NeverKeyword;
|
|
22
13
|
}
|
|
23
|
-
__name(isNeverType, "isNeverType");
|
|
24
14
|
function isUnknownType(type) {
|
|
25
15
|
return type.kind === ts3.SyntaxKind.UnknownKeyword;
|
|
26
16
|
}
|
|
27
|
-
__name(isUnknownType, "isUnknownType");
|
|
28
17
|
function isNullType(type) {
|
|
29
18
|
return type.kind === ts3.SyntaxKind.NullKeyword;
|
|
30
19
|
}
|
|
31
|
-
__name(isNullType, "isNullType");
|
|
32
20
|
function createBlobType() {
|
|
33
21
|
return ts3.factory.createTypeReferenceNode("Blob");
|
|
34
22
|
}
|
|
35
|
-
__name(createBlobType, "createBlobType");
|
|
36
23
|
function createNullType() {
|
|
37
24
|
return ts3.factory.createLiteralTypeNode(ts3.factory.createNull());
|
|
38
25
|
}
|
|
39
|
-
__name(createNullType, "createNullType");
|
|
40
26
|
function createImportSpecifier(importName) {
|
|
41
27
|
return ts3.factory.createImportSpecifier(false, void 0, ts3.factory.createIdentifier(importName));
|
|
42
28
|
}
|
|
43
|
-
__name(createImportSpecifier, "createImportSpecifier");
|
|
44
29
|
function createImportDeclaration(importSpecifiers, moduleName, options) {
|
|
45
30
|
return ts3.factory.createImportDeclaration(
|
|
46
31
|
void 0,
|
|
47
32
|
ts3.factory.createImportClause(
|
|
48
|
-
|
|
33
|
+
ts3.SyntaxKind.TypeKeyword ,
|
|
49
34
|
void 0,
|
|
50
35
|
ts3.factory.createNamedImports(importSpecifiers)
|
|
51
36
|
),
|
|
52
37
|
ts3.factory.createStringLiteral(moduleName)
|
|
53
38
|
);
|
|
54
39
|
}
|
|
55
|
-
__name(createImportDeclaration, "createImportDeclaration");
|
|
56
40
|
|
|
57
41
|
// src/types/schema.ts
|
|
58
42
|
var HTTP_METHODS = Object.freeze(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
59
43
|
|
|
60
44
|
// ../zimic-utils/dist/logging/Logger.mjs
|
|
61
45
|
var Logger = class _Logger {
|
|
62
|
-
static {
|
|
63
|
-
__name(this, "_Logger");
|
|
64
|
-
}
|
|
65
|
-
static {
|
|
66
|
-
__name2(this, "Logger");
|
|
67
|
-
}
|
|
68
46
|
prefix;
|
|
69
47
|
raw;
|
|
70
48
|
constructor(options = {}) {
|
|
@@ -144,19 +122,15 @@ var logger = new Logger_default({
|
|
|
144
122
|
function createOperationsIdentifierText(serviceName) {
|
|
145
123
|
return `${serviceName}Operations`;
|
|
146
124
|
}
|
|
147
|
-
__name(createOperationsIdentifierText, "createOperationsIdentifierText");
|
|
148
125
|
function createOperationsIdentifier(serviceName) {
|
|
149
126
|
return ts3.factory.createIdentifier(createOperationsIdentifierText(serviceName));
|
|
150
127
|
}
|
|
151
|
-
__name(createOperationsIdentifier, "createOperationsIdentifier");
|
|
152
128
|
function isOperationsDeclaration(node) {
|
|
153
129
|
return node !== void 0 && ts3.isInterfaceDeclaration(node) && node.name.text === "operations";
|
|
154
130
|
}
|
|
155
|
-
__name(isOperationsDeclaration, "isOperationsDeclaration");
|
|
156
131
|
function isOperation(node) {
|
|
157
132
|
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && ts3.isTypeLiteralNode(node.type);
|
|
158
133
|
}
|
|
159
|
-
__name(isOperation, "isOperation");
|
|
160
134
|
function normalizeOperation(operation, context) {
|
|
161
135
|
if (!isOperation(operation)) {
|
|
162
136
|
return void 0;
|
|
@@ -170,7 +144,6 @@ function normalizeOperation(operation, context) {
|
|
|
170
144
|
newType
|
|
171
145
|
);
|
|
172
146
|
}
|
|
173
|
-
__name(normalizeOperation, "normalizeOperation");
|
|
174
147
|
function normalizeOperations(operations, context) {
|
|
175
148
|
const newIdentifier = createOperationsIdentifier(context.serviceName);
|
|
176
149
|
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(isDefined_default);
|
|
@@ -183,7 +156,6 @@ function normalizeOperations(operations, context) {
|
|
|
183
156
|
newMembers
|
|
184
157
|
);
|
|
185
158
|
}
|
|
186
|
-
__name(normalizeOperations, "normalizeOperations");
|
|
187
159
|
function removeOperationIfUnreferenced(operation, context) {
|
|
188
160
|
if (!isOperation(operation)) {
|
|
189
161
|
return void 0;
|
|
@@ -196,7 +168,6 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
196
168
|
}
|
|
197
169
|
return void 0;
|
|
198
170
|
}
|
|
199
|
-
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
200
171
|
function removeUnreferencedOperations(operations, context) {
|
|
201
172
|
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
202
173
|
context.referencedTypes.operations.clear();
|
|
@@ -212,45 +183,35 @@ function removeUnreferencedOperations(operations, context) {
|
|
|
212
183
|
newMembers
|
|
213
184
|
);
|
|
214
185
|
}
|
|
215
|
-
__name(removeUnreferencedOperations, "removeUnreferencedOperations");
|
|
216
186
|
|
|
217
187
|
// src/typegen/openapi/transform/methods.ts
|
|
218
188
|
function isMethod(node) {
|
|
219
189
|
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type));
|
|
220
190
|
}
|
|
221
|
-
__name(isMethod, "isMethod");
|
|
222
191
|
function isMethodMember(node) {
|
|
223
192
|
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type) || isNeverType(node.type));
|
|
224
193
|
}
|
|
225
|
-
__name(isMethodMember, "isMethodMember");
|
|
226
194
|
function isRequestMember(node) {
|
|
227
195
|
return ts3.isPropertySignature(node) && ts3.isIdentifier(node.name) && node.type !== void 0 && !isNeverType(node.type);
|
|
228
196
|
}
|
|
229
|
-
__name(isRequestMember, "isRequestMember");
|
|
230
197
|
function isRequestHeaders(node) {
|
|
231
198
|
return isRequestMember(node) && node.name.text === "headers" && ts3.isTypeLiteralNode(node.type);
|
|
232
199
|
}
|
|
233
|
-
__name(isRequestHeaders, "isRequestHeaders");
|
|
234
200
|
function isNormalizedRequestHeaders(node) {
|
|
235
201
|
return isRequestMember(node) && node.name.text === "headers" && ts3.isTypeLiteralNode(node.type);
|
|
236
202
|
}
|
|
237
|
-
__name(isNormalizedRequestHeaders, "isNormalizedRequestHeaders");
|
|
238
203
|
function isRequestParameters(node) {
|
|
239
204
|
return isRequestMember(node) && node.name.text === "parameters" && ts3.isTypeLiteralNode(node.type);
|
|
240
205
|
}
|
|
241
|
-
__name(isRequestParameters, "isRequestParameters");
|
|
242
206
|
function isContentPropertySignature(node) {
|
|
243
207
|
return isRequestMember(node) && node.name.text === "content" && ts3.isTypeLiteralNode(node.type);
|
|
244
208
|
}
|
|
245
|
-
__name(isContentPropertySignature, "isContentPropertySignature");
|
|
246
209
|
function isContentMember(node) {
|
|
247
210
|
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && !isNeverType(node.type);
|
|
248
211
|
}
|
|
249
|
-
__name(isContentMember, "isContentMember");
|
|
250
212
|
function isResponse(node) {
|
|
251
213
|
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name) || ts3.isNumericLiteral(node.name)) && node.type !== void 0;
|
|
252
214
|
}
|
|
253
|
-
__name(isResponse, "isResponse");
|
|
254
215
|
function removeRedundantNullUnionIfNecessary(type) {
|
|
255
216
|
const containsRedundantNullUnion = ts3.isUnionTypeNode(type) && type.types.some((type2) => {
|
|
256
217
|
const isNull = ts3.isLiteralTypeNode(type2) && isNullType(type2.literal);
|
|
@@ -275,21 +236,18 @@ function removeRedundantNullUnionIfNecessary(type) {
|
|
|
275
236
|
});
|
|
276
237
|
return ts3.factory.createUnionTypeNode(typesWithoutRedundantNullUnion);
|
|
277
238
|
}
|
|
278
|
-
__name(removeRedundantNullUnionIfNecessary, "removeRedundantNullUnionIfNecessary");
|
|
279
239
|
function wrapFormDataContentType(type, context) {
|
|
280
240
|
context.typeImports.http.add("HttpFormData");
|
|
281
241
|
return ts3.factory.createTypeReferenceNode(ts3.factory.createIdentifier("HttpFormData"), [
|
|
282
242
|
renameComponentReferences(type, context)
|
|
283
243
|
]);
|
|
284
244
|
}
|
|
285
|
-
__name(wrapFormDataContentType, "wrapFormDataContentType");
|
|
286
245
|
function wrapURLEncodedContentType(type, context) {
|
|
287
246
|
context.typeImports.http.add("HttpSearchParams");
|
|
288
247
|
return ts3.factory.createTypeReferenceNode(ts3.factory.createIdentifier("HttpSearchParams"), [
|
|
289
248
|
renameComponentReferences(type, context)
|
|
290
249
|
]);
|
|
291
250
|
}
|
|
292
|
-
__name(wrapURLEncodedContentType, "wrapURLEncodedContentType");
|
|
293
251
|
function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
294
252
|
if (!isContentMember(requestBodyMember)) {
|
|
295
253
|
return void 0;
|
|
@@ -313,7 +271,6 @@ function normalizeRequestBodyMember(requestBodyMember, context, options) {
|
|
|
313
271
|
)
|
|
314
272
|
};
|
|
315
273
|
}
|
|
316
|
-
__name(normalizeRequestBodyMember, "normalizeRequestBodyMember");
|
|
317
274
|
function normalizeHeaders(headers) {
|
|
318
275
|
const newHeaderMembers = headers.members.filter((header) => {
|
|
319
276
|
if (ts3.isIndexSignatureDeclaration(header)) {
|
|
@@ -329,7 +286,6 @@ function normalizeHeaders(headers) {
|
|
|
329
286
|
}
|
|
330
287
|
return ts3.factory.updateTypeLiteralNode(headers, ts3.factory.createNodeArray(newHeaderMembers));
|
|
331
288
|
}
|
|
332
|
-
__name(normalizeHeaders, "normalizeHeaders");
|
|
333
289
|
function normalizeRequestHeaders(requestHeader) {
|
|
334
290
|
if (!isRequestHeaders(requestHeader)) {
|
|
335
291
|
return void 0;
|
|
@@ -346,7 +302,6 @@ function normalizeRequestHeaders(requestHeader) {
|
|
|
346
302
|
newType
|
|
347
303
|
);
|
|
348
304
|
}
|
|
349
|
-
__name(normalizeRequestHeaders, "normalizeRequestHeaders");
|
|
350
305
|
function createHeaderForUnionByContentType(existingHeader, contentTypeName) {
|
|
351
306
|
const existingHeaderMembers = existingHeader?.type.members ?? [];
|
|
352
307
|
const contentTypeIdentifier = ts3.factory.createIdentifier('"content-type"');
|
|
@@ -362,7 +317,6 @@ function createHeaderForUnionByContentType(existingHeader, contentTypeName) {
|
|
|
362
317
|
newHeaderType
|
|
363
318
|
);
|
|
364
319
|
}
|
|
365
|
-
__name(createHeaderForUnionByContentType, "createHeaderForUnionByContentType");
|
|
366
320
|
function normalizeContentType(contentType, context, options) {
|
|
367
321
|
const { bodyQuestionToken } = options;
|
|
368
322
|
if (ts3.isIndexedAccessTypeNode(contentType)) {
|
|
@@ -389,7 +343,6 @@ function normalizeContentType(contentType, context, options) {
|
|
|
389
343
|
return ts3.factory.createUnionTypeNode(bodyMemberUnionTypes);
|
|
390
344
|
}
|
|
391
345
|
}
|
|
392
|
-
__name(normalizeContentType, "normalizeContentType");
|
|
393
346
|
function normalizeRequest(request, context) {
|
|
394
347
|
const newIdentifier = ts3.factory.createIdentifier("request");
|
|
395
348
|
const newType = normalizeContentType(request.type, context, {
|
|
@@ -401,7 +354,6 @@ function normalizeRequest(request, context) {
|
|
|
401
354
|
}
|
|
402
355
|
return ts3.factory.updatePropertySignature(request, request.modifiers, newIdentifier, void 0, newType);
|
|
403
356
|
}
|
|
404
|
-
__name(normalizeRequest, "normalizeRequest");
|
|
405
357
|
function normalizeResponseType(responseType, context, options) {
|
|
406
358
|
const { questionToken } = options;
|
|
407
359
|
if (!ts3.isTypeLiteralNode(responseType)) {
|
|
@@ -409,7 +361,6 @@ function normalizeResponseType(responseType, context, options) {
|
|
|
409
361
|
}
|
|
410
362
|
return normalizeContentType(responseType, context, { bodyQuestionToken: questionToken });
|
|
411
363
|
}
|
|
412
|
-
__name(normalizeResponseType, "normalizeResponseType");
|
|
413
364
|
var NON_NUMERIC_RESPONSE_STATUS_TO_MAPPED_TYPE = {
|
|
414
365
|
default: "HttpStatusCode",
|
|
415
366
|
"1xx": "HttpStatusCode.Information",
|
|
@@ -465,7 +416,6 @@ function normalizeResponse(response, context, options = {}) {
|
|
|
465
416
|
}
|
|
466
417
|
};
|
|
467
418
|
}
|
|
468
|
-
__name(normalizeResponse, "normalizeResponse");
|
|
469
419
|
function normalizeResponses(responses, context) {
|
|
470
420
|
if (isNeverType(responses.type) || !ts3.isTypeLiteralNode(responses.type)) {
|
|
471
421
|
return void 0;
|
|
@@ -513,7 +463,6 @@ function normalizeResponses(responses, context) {
|
|
|
513
463
|
renameComponentReferences(newType, context)
|
|
514
464
|
);
|
|
515
465
|
}
|
|
516
|
-
__name(normalizeResponses, "normalizeResponses");
|
|
517
466
|
function normalizeMethodMember(methodMember, context) {
|
|
518
467
|
if (isMethodMember(methodMember)) {
|
|
519
468
|
if (methodMember.name.text === "requestBody") {
|
|
@@ -526,7 +475,6 @@ function normalizeMethodMember(methodMember, context) {
|
|
|
526
475
|
}
|
|
527
476
|
return void 0;
|
|
528
477
|
}
|
|
529
|
-
__name(normalizeMethodMember, "normalizeMethodMember");
|
|
530
478
|
function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
531
479
|
const newIdentifier = ts3.factory.createIdentifier("searchParams");
|
|
532
480
|
const newQuestionToken = void 0;
|
|
@@ -539,7 +487,6 @@ function normalizeRequestQueryWithParameters(requestMember, context) {
|
|
|
539
487
|
newType
|
|
540
488
|
);
|
|
541
489
|
}
|
|
542
|
-
__name(normalizeRequestQueryWithParameters, "normalizeRequestQueryWithParameters");
|
|
543
490
|
function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
544
491
|
const newIdentifier = ts3.factory.createIdentifier("headers");
|
|
545
492
|
const newQuestionToken = void 0;
|
|
@@ -552,7 +499,6 @@ function normalizeRequestHeadersWithParameters(requestMember, context) {
|
|
|
552
499
|
newType
|
|
553
500
|
);
|
|
554
501
|
}
|
|
555
|
-
__name(normalizeRequestHeadersWithParameters, "normalizeRequestHeadersWithParameters");
|
|
556
502
|
function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
557
503
|
if (!isRequestMember(requestMember) || requestMember.name.text === "path") {
|
|
558
504
|
return void 0;
|
|
@@ -565,7 +511,6 @@ function normalizeRequestMemberWithParameters(requestMember, context) {
|
|
|
565
511
|
}
|
|
566
512
|
return requestMember;
|
|
567
513
|
}
|
|
568
|
-
__name(normalizeRequestMemberWithParameters, "normalizeRequestMemberWithParameters");
|
|
569
514
|
function mergeRequestHeadersMember(headers, otherHeaders) {
|
|
570
515
|
const newType = ts3.factory.updateTypeLiteralNode(
|
|
571
516
|
headers.type,
|
|
@@ -579,7 +524,6 @@ function mergeRequestHeadersMember(headers, otherHeaders) {
|
|
|
579
524
|
newType
|
|
580
525
|
);
|
|
581
526
|
}
|
|
582
|
-
__name(mergeRequestHeadersMember, "mergeRequestHeadersMember");
|
|
583
527
|
function mergeRequestHeadersMembers(members) {
|
|
584
528
|
let mergedHeaders;
|
|
585
529
|
let firstHeadersIndex;
|
|
@@ -600,7 +544,6 @@ function mergeRequestHeadersMembers(members) {
|
|
|
600
544
|
}
|
|
601
545
|
return mergedHeadersMembers.filter(isDefined_default);
|
|
602
546
|
}
|
|
603
|
-
__name(mergeRequestHeadersMembers, "mergeRequestHeadersMembers");
|
|
604
547
|
function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
605
548
|
const parameters = methodMembers.find(isRequestParameters);
|
|
606
549
|
const parametersMembers = parameters ? parameters.type.members : [];
|
|
@@ -615,7 +558,6 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
615
558
|
}
|
|
616
559
|
return ts3.factory.createTypeLiteralNode(newMembers);
|
|
617
560
|
}
|
|
618
|
-
__name(mergeRequestAndParameterTypes, "mergeRequestAndParameterTypes");
|
|
619
561
|
function normalizeRequestTypeWithParameters(requestType, methodMembers, context) {
|
|
620
562
|
if (ts3.isUnionTypeNode(requestType)) {
|
|
621
563
|
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(isDefined_default);
|
|
@@ -627,7 +569,6 @@ function normalizeRequestTypeWithParameters(requestType, methodMembers, context)
|
|
|
627
569
|
}
|
|
628
570
|
return mergeRequestAndParameterTypes(requestType, methodMembers, context);
|
|
629
571
|
}
|
|
630
|
-
__name(normalizeRequestTypeWithParameters, "normalizeRequestTypeWithParameters");
|
|
631
572
|
function normalizeMethodMemberWithParameters(methodMember, methodMembers, context) {
|
|
632
573
|
if (!ts3.isIdentifier(methodMember.name) || !methodMember.type) {
|
|
633
574
|
return void 0;
|
|
@@ -650,12 +591,10 @@ function normalizeMethodMemberWithParameters(methodMember, methodMembers, contex
|
|
|
650
591
|
}
|
|
651
592
|
return void 0;
|
|
652
593
|
}
|
|
653
|
-
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
654
594
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
655
595
|
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(isDefined_default).map((member, _index, partialMembers) => normalizeMethodMemberWithParameters(member, partialMembers, context)).filter(isDefined_default);
|
|
656
596
|
return ts3.factory.updateTypeLiteralNode(methodType, ts3.factory.createNodeArray(newMembers));
|
|
657
597
|
}
|
|
658
|
-
__name(normalizeTypeLiteralMethodType, "normalizeTypeLiteralMethodType");
|
|
659
598
|
function normalizeIndexedAccessMethodType(methodType, context) {
|
|
660
599
|
const isOperationsReference = ts3.isTypeReferenceNode(methodType.objectType) && ts3.isIdentifier(methodType.objectType.typeName) && methodType.objectType.typeName.text === "operations";
|
|
661
600
|
if (!isOperationsReference) {
|
|
@@ -670,7 +609,6 @@ function normalizeIndexedAccessMethodType(methodType, context) {
|
|
|
670
609
|
}
|
|
671
610
|
return ts3.factory.updateIndexedAccessTypeNode(methodType, newObjectType, methodType.indexType);
|
|
672
611
|
}
|
|
673
|
-
__name(normalizeIndexedAccessMethodType, "normalizeIndexedAccessMethodType");
|
|
674
612
|
function normalizeMethod(method, context, options) {
|
|
675
613
|
if (!isMethod(method)) {
|
|
676
614
|
return void 0;
|
|
@@ -695,23 +633,18 @@ function normalizeMethod(method, context, options) {
|
|
|
695
633
|
const newType = ts3.isTypeLiteralNode(method.type) ? normalizeTypeLiteralMethodType(method.type, context) : normalizeIndexedAccessMethodType(method.type, context);
|
|
696
634
|
return ts3.factory.updatePropertySignature(method, method.modifiers, newIdentifier, method.questionToken, newType);
|
|
697
635
|
}
|
|
698
|
-
__name(normalizeMethod, "normalizeMethod");
|
|
699
636
|
function createPathsIdentifier(serviceName) {
|
|
700
637
|
return ts3.factory.createIdentifier(`${serviceName}Schema`);
|
|
701
638
|
}
|
|
702
|
-
__name(createPathsIdentifier, "createPathsIdentifier");
|
|
703
639
|
function isPathsDeclaration(node) {
|
|
704
640
|
return node !== void 0 && (ts3.isInterfaceDeclaration(node) || ts3.isTypeAliasDeclaration(node)) && node.name.text === "paths";
|
|
705
641
|
}
|
|
706
|
-
__name(isPathsDeclaration, "isPathsDeclaration");
|
|
707
642
|
function isPath(node) {
|
|
708
643
|
return ts3.isPropertySignature(node) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name)) && node.type !== void 0 && (ts3.isTypeLiteralNode(node.type) || ts3.isIndexedAccessTypeNode(node.type));
|
|
709
644
|
}
|
|
710
|
-
__name(isPath, "isPath");
|
|
711
645
|
function normalizePathNameWithParameters(pathName) {
|
|
712
646
|
return pathName.replace(/{([^}]+)}/g, ":$1");
|
|
713
647
|
}
|
|
714
|
-
__name(normalizePathNameWithParameters, "normalizePathNameWithParameters");
|
|
715
648
|
function normalizePath(path4, context, options = {}) {
|
|
716
649
|
const { isComponent: isComponent2 = false } = options;
|
|
717
650
|
if (!isPath(path4)) {
|
|
@@ -731,13 +664,11 @@ function normalizePath(path4, context, options = {}) {
|
|
|
731
664
|
}
|
|
732
665
|
return ts3.factory.updatePropertySignature(path4, path4.modifiers, newIdentifier, path4.questionToken, newType);
|
|
733
666
|
}
|
|
734
|
-
__name(normalizePath, "normalizePath");
|
|
735
667
|
function wrapPathsType(type, context) {
|
|
736
668
|
context.typeImports.http.add("HttpSchema");
|
|
737
669
|
const httpSchemaPathsWrapper = ts3.factory.createIdentifier("HttpSchema");
|
|
738
670
|
return ts3.factory.createTypeReferenceNode(httpSchemaPathsWrapper, [type]);
|
|
739
671
|
}
|
|
740
|
-
__name(wrapPathsType, "wrapPathsType");
|
|
741
672
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
742
673
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
743
674
|
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, void 0, void 0, []) : pathsOrTypeAlias;
|
|
@@ -750,38 +681,30 @@ function normalizePaths(pathsOrTypeAlias, context) {
|
|
|
750
681
|
wrapPathsType(newType, context)
|
|
751
682
|
);
|
|
752
683
|
}
|
|
753
|
-
__name(normalizePaths, "normalizePaths");
|
|
754
684
|
|
|
755
685
|
// src/typegen/openapi/transform/components.ts
|
|
756
686
|
function createComponentsIdentifierText(serviceName) {
|
|
757
687
|
return `${serviceName}Components`;
|
|
758
688
|
}
|
|
759
|
-
__name(createComponentsIdentifierText, "createComponentsIdentifierText");
|
|
760
689
|
function createComponentsIdentifier(serviceName) {
|
|
761
690
|
return ts3.factory.createIdentifier(createComponentsIdentifierText(serviceName));
|
|
762
691
|
}
|
|
763
|
-
__name(createComponentsIdentifier, "createComponentsIdentifier");
|
|
764
692
|
function isComponentsDeclaration(node, context) {
|
|
765
693
|
const componentIdentifiers = ["components", createComponentsIdentifierText(context.serviceName)];
|
|
766
694
|
return node !== void 0 && ts3.isInterfaceDeclaration(node) && componentIdentifiers.includes(node.name.text);
|
|
767
695
|
}
|
|
768
|
-
__name(isComponentsDeclaration, "isComponentsDeclaration");
|
|
769
696
|
function isComponentGroup(node) {
|
|
770
697
|
return ts3.isPropertySignature(node) && node.type !== void 0 && ts3.isTypeLiteralNode(node.type) && ts3.isIdentifier(node.name);
|
|
771
698
|
}
|
|
772
|
-
__name(isComponentGroup, "isComponentGroup");
|
|
773
699
|
function isComponent(node) {
|
|
774
700
|
return ts3.isPropertySignature(node) && node.type !== void 0 && !isNeverType(node.type) && (ts3.isIdentifier(node.name) || ts3.isStringLiteral(node.name));
|
|
775
701
|
}
|
|
776
|
-
__name(isComponent, "isComponent");
|
|
777
702
|
function isRequestComponent(node) {
|
|
778
703
|
return ts3.isTypeLiteralNode(node.type);
|
|
779
704
|
}
|
|
780
|
-
__name(isRequestComponent, "isRequestComponent");
|
|
781
705
|
function unchangedIndexedAccessTypeNode(node) {
|
|
782
706
|
return node;
|
|
783
707
|
}
|
|
784
|
-
__name(unchangedIndexedAccessTypeNode, "unchangedIndexedAccessTypeNode");
|
|
785
708
|
function visitComponentReferences(node, context, options) {
|
|
786
709
|
const { onComponentReference, renameComponentReference = unchangedIndexedAccessTypeNode } = options;
|
|
787
710
|
if (isUnknownType(node)) {
|
|
@@ -866,14 +789,12 @@ function visitComponentReferences(node, context, options) {
|
|
|
866
789
|
}
|
|
867
790
|
return node;
|
|
868
791
|
}
|
|
869
|
-
__name(visitComponentReferences, "visitComponentReferences");
|
|
870
792
|
function normalizeComponentGroupName(rawComponentGroupName) {
|
|
871
793
|
if (rawComponentGroupName === "requestBodies") {
|
|
872
794
|
return "requests";
|
|
873
795
|
}
|
|
874
796
|
return rawComponentGroupName;
|
|
875
797
|
}
|
|
876
|
-
__name(normalizeComponentGroupName, "normalizeComponentGroupName");
|
|
877
798
|
function renameComponentReferences(node, context) {
|
|
878
799
|
return visitComponentReferences(node, context, {
|
|
879
800
|
onComponentReference(_node, componentPath) {
|
|
@@ -891,7 +812,6 @@ function renameComponentReferences(node, context) {
|
|
|
891
812
|
}
|
|
892
813
|
});
|
|
893
814
|
}
|
|
894
|
-
__name(renameComponentReferences, "renameComponentReferences");
|
|
895
815
|
function processPendingRequestComponentActions(component, context) {
|
|
896
816
|
const pendingRequestActions = context.pendingActions.components.requests;
|
|
897
817
|
const componentName = component.name.text;
|
|
@@ -900,7 +820,6 @@ function processPendingRequestComponentActions(component, context) {
|
|
|
900
820
|
pendingRequestActions.toMarkBodyAsOptional.delete(componentName);
|
|
901
821
|
return { bodyQuestionToken };
|
|
902
822
|
}
|
|
903
|
-
__name(processPendingRequestComponentActions, "processPendingRequestComponentActions");
|
|
904
823
|
function normalizeRequestComponent(component, context) {
|
|
905
824
|
if (!isRequestComponent(component)) {
|
|
906
825
|
return void 0;
|
|
@@ -915,7 +834,6 @@ function normalizeRequestComponent(component, context) {
|
|
|
915
834
|
newType
|
|
916
835
|
);
|
|
917
836
|
}
|
|
918
|
-
__name(normalizeRequestComponent, "normalizeRequestComponent");
|
|
919
837
|
function normalizeComponent(component, componentGroupName, context) {
|
|
920
838
|
if (!isComponent(component)) {
|
|
921
839
|
return void 0;
|
|
@@ -938,7 +856,6 @@ function normalizeComponent(component, componentGroupName, context) {
|
|
|
938
856
|
renameComponentReferences(component.type, context)
|
|
939
857
|
);
|
|
940
858
|
}
|
|
941
|
-
__name(normalizeComponent, "normalizeComponent");
|
|
942
859
|
function normalizeComponentGroup(componentGroup, context) {
|
|
943
860
|
if (!isComponentGroup(componentGroup)) {
|
|
944
861
|
return void 0;
|
|
@@ -955,7 +872,6 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
955
872
|
newType
|
|
956
873
|
);
|
|
957
874
|
}
|
|
958
|
-
__name(normalizeComponentGroup, "normalizeComponentGroup");
|
|
959
875
|
function normalizeComponents(components, context) {
|
|
960
876
|
const newIdentifier = createComponentsIdentifier(context.serviceName);
|
|
961
877
|
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(isDefined_default);
|
|
@@ -968,7 +884,6 @@ function normalizeComponents(components, context) {
|
|
|
968
884
|
newMembers
|
|
969
885
|
);
|
|
970
886
|
}
|
|
971
|
-
__name(normalizeComponents, "normalizeComponents");
|
|
972
887
|
function populateReferencedComponents(components, context) {
|
|
973
888
|
const pathsToVisit = new Set(context.referencedTypes.components);
|
|
974
889
|
while (pathsToVisit.size > 0) {
|
|
@@ -1002,7 +917,6 @@ function populateReferencedComponents(components, context) {
|
|
|
1002
917
|
}
|
|
1003
918
|
}
|
|
1004
919
|
}
|
|
1005
|
-
__name(populateReferencedComponents, "populateReferencedComponents");
|
|
1006
920
|
function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
1007
921
|
if (!isComponent(component)) {
|
|
1008
922
|
return void 0;
|
|
@@ -1015,7 +929,6 @@ function removeComponentIfUnreferenced(component, componentGroupName, context) {
|
|
|
1015
929
|
}
|
|
1016
930
|
return void 0;
|
|
1017
931
|
}
|
|
1018
|
-
__name(removeComponentIfUnreferenced, "removeComponentIfUnreferenced");
|
|
1019
932
|
function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
1020
933
|
if (!isComponentGroup(componentGroup)) {
|
|
1021
934
|
return void 0;
|
|
@@ -1033,7 +946,6 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
1033
946
|
ts3.factory.updateTypeLiteralNode(componentGroup.type, ts3.factory.createNodeArray(newComponents))
|
|
1034
947
|
);
|
|
1035
948
|
}
|
|
1036
|
-
__name(removeUnreferencedComponentsInGroup, "removeUnreferencedComponentsInGroup");
|
|
1037
949
|
function removeUnreferencedComponents(components, context) {
|
|
1038
950
|
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1039
951
|
context.referencedTypes.components.clear();
|
|
@@ -1049,120 +961,36 @@ function removeUnreferencedComponents(components, context) {
|
|
|
1049
961
|
newComponentGroups
|
|
1050
962
|
);
|
|
1051
963
|
}
|
|
1052
|
-
__name(removeUnreferencedComponents, "removeUnreferencedComponents");
|
|
1053
964
|
|
|
1054
965
|
// src/utils/strings.ts
|
|
1055
966
|
function convertToPascalCase(value) {
|
|
1056
967
|
return value.replace(/(?:^|[^A-Za-z\d])([A-Za-z\d])/g, (_match, letter) => letter.toUpperCase());
|
|
1057
968
|
}
|
|
1058
|
-
__name(convertToPascalCase, "convertToPascalCase");
|
|
1059
969
|
|
|
1060
970
|
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
1061
971
|
function isNonEmpty(value) {
|
|
1062
972
|
return isDefined_default(value) && value !== "";
|
|
1063
973
|
}
|
|
1064
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
1065
|
-
__name2(isNonEmpty, "isNonEmpty");
|
|
1066
974
|
var isNonEmpty_default = isNonEmpty;
|
|
1067
975
|
|
|
1068
|
-
// ../zimic-utils/dist/chunk-
|
|
976
|
+
// ../zimic-utils/dist/chunk-46M3OXFU.mjs
|
|
1069
977
|
function getExtraPatternsToEscape() {
|
|
1070
978
|
return /([.(){}+$])/g;
|
|
1071
979
|
}
|
|
1072
|
-
__name(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
1073
|
-
__name2(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
1074
980
|
function getURIEncodedBackSlashPattern() {
|
|
1075
981
|
return /%5C/g;
|
|
1076
982
|
}
|
|
1077
|
-
__name(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
1078
|
-
__name2(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
1079
|
-
function getPathParamPattern() {
|
|
1080
|
-
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)/gu;
|
|
1081
|
-
}
|
|
1082
|
-
__name(getPathParamPattern, "getPathParamPattern");
|
|
1083
|
-
__name2(getPathParamPattern, "getPathParamPattern");
|
|
1084
|
-
function getRepeatingPathParamPattern() {
|
|
1085
|
-
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\\+/gu;
|
|
1086
|
-
}
|
|
1087
|
-
__name(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
1088
|
-
__name2(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
1089
|
-
function getOptionalPathParamPattern() {
|
|
1090
|
-
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\?(?<trailingSlash>\/)?/gu;
|
|
1091
|
-
}
|
|
1092
|
-
__name(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
1093
|
-
__name2(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
1094
|
-
function getOptionalRepeatingPathParamPattern() {
|
|
1095
|
-
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\*(?<trailingSlash>\/)?/gu;
|
|
1096
|
-
}
|
|
1097
|
-
__name(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
1098
|
-
__name2(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
1099
|
-
function createParametrizedPathPattern(path4) {
|
|
1100
|
-
const replacedURL = encodeURI(path4).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(
|
|
1101
|
-
getOptionalRepeatingPathParamPattern(),
|
|
1102
|
-
(_match, leadingSlash, escape, identifier, trailingSlash) => {
|
|
1103
|
-
if (escape) {
|
|
1104
|
-
return `:${identifier}`;
|
|
1105
|
-
}
|
|
1106
|
-
const hasSegmentBeforePrefix = leadingSlash === "/";
|
|
1107
|
-
const prefixExpression = hasSegmentBeforePrefix ? "/?" : leadingSlash;
|
|
1108
|
-
const hasSegmentAfterSuffix = trailingSlash === "/";
|
|
1109
|
-
const suffixExpression = hasSegmentAfterSuffix ? "/?" : trailingSlash;
|
|
1110
|
-
if (prefixExpression && suffixExpression) {
|
|
1111
|
-
return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;
|
|
1112
|
-
} else if (prefixExpression) {
|
|
1113
|
-
return `(?:${prefixExpression}(?<${identifier}>.+?))?`;
|
|
1114
|
-
} else if (suffixExpression) {
|
|
1115
|
-
return `(?:(?<${identifier}>.+?)${suffixExpression})?`;
|
|
1116
|
-
} else {
|
|
1117
|
-
return `(?<${identifier}>.+?)?`;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
).replace(getRepeatingPathParamPattern(), (_match, escape, identifier) => {
|
|
1121
|
-
return escape ? `:${identifier}` : `(?<${identifier}>.+)`;
|
|
1122
|
-
}).replace(
|
|
1123
|
-
getOptionalPathParamPattern(),
|
|
1124
|
-
(_match, leadingSlash, escape, identifier, trailingSlash) => {
|
|
1125
|
-
if (escape) {
|
|
1126
|
-
return `:${identifier}`;
|
|
1127
|
-
}
|
|
1128
|
-
const hasSegmentBeforePrefix = leadingSlash === "/";
|
|
1129
|
-
const prefixExpression = hasSegmentBeforePrefix ? "/?" : leadingSlash;
|
|
1130
|
-
const hasSegmentAfterSuffix = trailingSlash === "/";
|
|
1131
|
-
const suffixExpression = hasSegmentAfterSuffix ? "/?" : trailingSlash;
|
|
1132
|
-
if (prefixExpression && suffixExpression) {
|
|
1133
|
-
return `(?:${prefixExpression}(?<${identifier}>[^\\/]+?)?${suffixExpression})`;
|
|
1134
|
-
} else if (prefixExpression) {
|
|
1135
|
-
return `(?:${prefixExpression}(?<${identifier}>[^\\/]+?))?`;
|
|
1136
|
-
} else if (suffixExpression) {
|
|
1137
|
-
return `(?:(?<${identifier}>[^\\/]+?)${suffixExpression})?`;
|
|
1138
|
-
} else {
|
|
1139
|
-
return `(?<${identifier}>[^\\/]+?)?`;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
).replace(getPathParamPattern(), (_match, escape, identifier) => {
|
|
1143
|
-
return escape ? `:${identifier}` : `(?<${identifier}>[^\\/]+?)`;
|
|
1144
|
-
});
|
|
1145
|
-
return new RegExp(`^/?${replacedURL}/?$`);
|
|
1146
|
-
}
|
|
1147
|
-
__name(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1148
|
-
__name2(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1149
983
|
|
|
1150
984
|
// ../zimic-utils/dist/url/createWildcardPathPattern.mjs
|
|
1151
985
|
function getSingleWildcardPattern() {
|
|
1152
986
|
return /(?<wildcardPrefix>^|[^*])(?<escape>\\)?\*(?<wildcardSuffix>[^*]|$)/g;
|
|
1153
987
|
}
|
|
1154
|
-
__name(getSingleWildcardPattern, "getSingleWildcardPattern");
|
|
1155
|
-
__name2(getSingleWildcardPattern, "getSingleWildcardPattern");
|
|
1156
988
|
function getDoubleWildcardPattern() {
|
|
1157
989
|
return /(?<escape>\\)?\*\*/g;
|
|
1158
990
|
}
|
|
1159
|
-
__name(getDoubleWildcardPattern, "getDoubleWildcardPattern");
|
|
1160
|
-
__name2(getDoubleWildcardPattern, "getDoubleWildcardPattern");
|
|
1161
991
|
function getTripleWildcardPattern() {
|
|
1162
992
|
return /(?<escape>\\)?\*\*\/\*(?<wildcardSuffix>[^*]|$)/g;
|
|
1163
993
|
}
|
|
1164
|
-
__name(getTripleWildcardPattern, "getTripleWildcardPattern");
|
|
1165
|
-
__name2(getTripleWildcardPattern, "getTripleWildcardPattern");
|
|
1166
994
|
function createWildcardPathPattern(path4) {
|
|
1167
995
|
const replacedURL = encodeURI(path4).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(getTripleWildcardPattern(), (_match, escape, wildcardSuffix) => {
|
|
1168
996
|
return escape === "\\" ? `\\*\\*/\\*${wildcardSuffix}` : `**${wildcardSuffix}`;
|
|
@@ -1176,8 +1004,6 @@ function createWildcardPathPattern(path4) {
|
|
|
1176
1004
|
});
|
|
1177
1005
|
return new RegExp(`^/?${replacedURL}/?$`);
|
|
1178
1006
|
}
|
|
1179
|
-
__name(createWildcardPathPattern, "createWildcardPathPattern");
|
|
1180
|
-
__name2(createWildcardPathPattern, "createWildcardPathPattern");
|
|
1181
1007
|
var createWildcardPathPattern_default = createWildcardPathPattern;
|
|
1182
1008
|
var HTTP_METHOD_OPTIONS = HTTP_METHODS.join("|");
|
|
1183
1009
|
var MODIFIER_GROUP = "(?<modifier>!?)";
|
|
@@ -1198,7 +1024,6 @@ function parseRawFilter(rawFilter) {
|
|
|
1198
1024
|
isNegativeMatch: filterModifier === "!"
|
|
1199
1025
|
};
|
|
1200
1026
|
}
|
|
1201
|
-
__name(parseRawFilter, "parseRawFilter");
|
|
1202
1027
|
function groupParsedFiltersByMatch(parsedFilters) {
|
|
1203
1028
|
return parsedFilters.reduce(
|
|
1204
1029
|
(groupedFilters, filter) => {
|
|
@@ -1214,18 +1039,15 @@ function groupParsedFiltersByMatch(parsedFilters) {
|
|
|
1214
1039
|
{ positive: [], negative: [] }
|
|
1215
1040
|
);
|
|
1216
1041
|
}
|
|
1217
|
-
__name(groupParsedFiltersByMatch, "groupParsedFiltersByMatch");
|
|
1218
1042
|
async function readPathFiltersFromFile(filePath) {
|
|
1219
1043
|
const fileContent = await filesystem.readFile(path.resolve(filePath), "utf-8");
|
|
1220
1044
|
const fileContentWithoutComments = fileContent.replace(/#.*$/gm, "");
|
|
1221
1045
|
const filters = fileContentWithoutComments.split("\n");
|
|
1222
1046
|
return filters;
|
|
1223
1047
|
}
|
|
1224
|
-
__name(readPathFiltersFromFile, "readPathFiltersFromFile");
|
|
1225
1048
|
function ignoreEmptyFilters(filters) {
|
|
1226
1049
|
return filters.map((line) => line.trim()).filter(isNonEmpty_default);
|
|
1227
1050
|
}
|
|
1228
|
-
__name(ignoreEmptyFilters, "ignoreEmptyFilters");
|
|
1229
1051
|
|
|
1230
1052
|
// src/typegen/openapi/transform/context.ts
|
|
1231
1053
|
function createTypeTransformationContext(serviceName, rawFilters) {
|
|
@@ -1249,29 +1071,23 @@ function createTypeTransformationContext(serviceName, rawFilters) {
|
|
|
1249
1071
|
}
|
|
1250
1072
|
};
|
|
1251
1073
|
}
|
|
1252
|
-
__name(createTypeTransformationContext, "createTypeTransformationContext");
|
|
1253
1074
|
|
|
1254
1075
|
// src/typegen/openapi/transform/imports.ts
|
|
1255
1076
|
var TYPEGEN_HTTP_IMPORT_MODULE = "@zimic/http";
|
|
1256
1077
|
function createImportDeclarations(context) {
|
|
1257
1078
|
const httpTypeImports = Array.from(context.typeImports.http).sort().map(createImportSpecifier);
|
|
1258
|
-
const httpImportDeclaration = createImportDeclaration(httpTypeImports, TYPEGEN_HTTP_IMPORT_MODULE
|
|
1259
|
-
typeOnly: true
|
|
1260
|
-
});
|
|
1079
|
+
const httpImportDeclaration = createImportDeclaration(httpTypeImports, TYPEGEN_HTTP_IMPORT_MODULE);
|
|
1261
1080
|
return [httpImportDeclaration];
|
|
1262
1081
|
}
|
|
1263
|
-
__name(createImportDeclarations, "createImportDeclarations");
|
|
1264
1082
|
|
|
1265
1083
|
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
1266
1084
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
1267
1085
|
let cachedImportResult;
|
|
1268
|
-
return
|
|
1086
|
+
return async function importModuleDynamicallyWithCache() {
|
|
1269
1087
|
cachedImportResult ??= await importModuleDynamically();
|
|
1270
1088
|
return cachedImportResult;
|
|
1271
|
-
}
|
|
1089
|
+
};
|
|
1272
1090
|
}
|
|
1273
|
-
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1274
|
-
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1275
1091
|
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
1276
1092
|
var importOpenapiTypeScript = createCachedDynamicImport_default(() => import('openapi-typescript'));
|
|
1277
1093
|
function transformSchemaObject(schemaObject) {
|
|
@@ -1284,7 +1100,6 @@ function transformSchemaObject(schemaObject) {
|
|
|
1284
1100
|
return blobType;
|
|
1285
1101
|
}
|
|
1286
1102
|
}
|
|
1287
|
-
__name(transformSchemaObject, "transformSchemaObject");
|
|
1288
1103
|
function convertFilePathOrURLToURL(filePathOrURL) {
|
|
1289
1104
|
try {
|
|
1290
1105
|
return new URL(filePathOrURL);
|
|
@@ -1292,7 +1107,6 @@ function convertFilePathOrURLToURL(filePathOrURL) {
|
|
|
1292
1107
|
return new URL(`file://${path.resolve(filePathOrURL)}`);
|
|
1293
1108
|
}
|
|
1294
1109
|
}
|
|
1295
|
-
__name(convertFilePathOrURLToURL, "convertFilePathOrURLToURL");
|
|
1296
1110
|
async function importTypesFromOpenAPI(filePathOrURL) {
|
|
1297
1111
|
const schemaURL = convertFilePathOrURLToURL(filePathOrURL);
|
|
1298
1112
|
const { default: generateTypesFromOpenAPI2 } = await importOpenapiTypeScript();
|
|
@@ -1314,7 +1128,6 @@ async function importTypesFromOpenAPI(filePathOrURL) {
|
|
|
1314
1128
|
});
|
|
1315
1129
|
return rawNodes;
|
|
1316
1130
|
}
|
|
1317
|
-
__name(importTypesFromOpenAPI, "importTypesFromOpenAPI");
|
|
1318
1131
|
async function convertTypesToString(nodes, options) {
|
|
1319
1132
|
const { astToString: convertTypeASTToString } = await importOpenapiTypeScript();
|
|
1320
1133
|
const typeOutput = convertTypeASTToString(nodes, {
|
|
@@ -1322,7 +1135,6 @@ async function convertTypesToString(nodes, options) {
|
|
|
1322
1135
|
});
|
|
1323
1136
|
return typeOutput;
|
|
1324
1137
|
}
|
|
1325
|
-
__name(convertTypesToString, "convertTypesToString");
|
|
1326
1138
|
function prepareTypeOutputToSave(output) {
|
|
1327
1139
|
const formattedOutput = output.replace(/^export (\w+)/gm, "\nexport $1").replace(/^( {4})+/gm, (match) => match.replace(/ {4}/g, " "));
|
|
1328
1140
|
const formattedOutputWithPrefix = [
|
|
@@ -1332,13 +1144,11 @@ function prepareTypeOutputToSave(output) {
|
|
|
1332
1144
|
].join("\n");
|
|
1333
1145
|
return formattedOutputWithPrefix;
|
|
1334
1146
|
}
|
|
1335
|
-
__name(prepareTypeOutputToSave, "prepareTypeOutputToSave");
|
|
1336
1147
|
async function writeTypeOutputToStandardOutput(formattedOutput) {
|
|
1337
1148
|
await new Promise((resolve) => {
|
|
1338
1149
|
process.stdout.write(formattedOutput, "utf-8", resolve);
|
|
1339
1150
|
});
|
|
1340
1151
|
}
|
|
1341
|
-
__name(writeTypeOutputToStandardOutput, "writeTypeOutputToStandardOutput");
|
|
1342
1152
|
|
|
1343
1153
|
// src/typegen/openapi/generate.ts
|
|
1344
1154
|
var RESOURCES_TO_REMOVE_IF_NOT_NORMALIZED = ["paths", "webhooks", "operations", "components", "$defs"];
|
|
@@ -1349,7 +1159,6 @@ function removeUnknownResources(node) {
|
|
|
1349
1159
|
}
|
|
1350
1160
|
return node;
|
|
1351
1161
|
}
|
|
1352
|
-
__name(removeUnknownResources, "removeUnknownResources");
|
|
1353
1162
|
function normalizeRawNodes(rawNodes, context, options) {
|
|
1354
1163
|
let normalizedNodes = rawNodes.map((node) => isPathsDeclaration(node) ? normalizePaths(node, context) : node);
|
|
1355
1164
|
if (options.prune) {
|
|
@@ -1367,7 +1176,6 @@ function normalizeRawNodes(rawNodes, context, options) {
|
|
|
1367
1176
|
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(isDefined_default);
|
|
1368
1177
|
return normalizedNodes;
|
|
1369
1178
|
}
|
|
1370
|
-
__name(normalizeRawNodes, "normalizeRawNodes");
|
|
1371
1179
|
async function generateTypesFromOpenAPI({
|
|
1372
1180
|
input: inputFilePathOrURL,
|
|
1373
1181
|
output: outputFilePath,
|
|
@@ -1395,7 +1203,6 @@ async function generateTypesFromOpenAPI({
|
|
|
1395
1203
|
await filesystem.writeFile(path.resolve(outputFilePath), formattedOutput);
|
|
1396
1204
|
}
|
|
1397
1205
|
}
|
|
1398
|
-
__name(generateTypesFromOpenAPI, "generateTypesFromOpenAPI");
|
|
1399
1206
|
var generate_default = generateTypesFromOpenAPI;
|
|
1400
1207
|
/* istanbul ignore if -- @preserve
|
|
1401
1208
|
* Operation members are always expected to be an operation. */
|
|
@@ -1437,6 +1244,6 @@ var generate_default = generateTypesFromOpenAPI;
|
|
|
1437
1244
|
/* istanbul ignore next -- @preserve
|
|
1438
1245
|
* The root import module is defined at build time. The fallback is not expected to be used. */
|
|
1439
1246
|
|
|
1440
|
-
export {
|
|
1441
|
-
//# sourceMappingURL=chunk-
|
|
1442
|
-
//# sourceMappingURL=chunk-
|
|
1247
|
+
export { generate_default, logger };
|
|
1248
|
+
//# sourceMappingURL=chunk-DYXOLS3Q.mjs.map
|
|
1249
|
+
//# sourceMappingURL=chunk-DYXOLS3Q.mjs.map
|