@zimic/http 0.1.0-canary.13 → 0.1.0-canary.14
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-PRWTKZHR.mjs → chunk-SSSE2VVN.mjs} +74 -29
- package/dist/chunk-SSSE2VVN.mjs.map +1 -0
- package/dist/{chunk-2CRLX2VH.js → chunk-WHT4TCQM.js} +74 -33
- package/dist/chunk-WHT4TCQM.js.map +1 -0
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -4
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +6 -6
- package/src/utils/prettier.ts +1 -1
- package/dist/chunk-2CRLX2VH.js.map +0 -1
- package/dist/chunk-PRWTKZHR.mjs.map +0 -1
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import isDefined2 from '@zimic/utils/data/isDefined';
|
|
2
1
|
import filesystem from 'fs/promises';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import ts3 from 'typescript';
|
|
5
4
|
import chalk from 'chalk';
|
|
6
|
-
import isNonEmpty from '@zimic/utils/data/isNonEmpty';
|
|
7
|
-
import createRegExpFromWildcardPath from '@zimic/utils/url/createRegExpFromWildcardPath';
|
|
8
|
-
import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';
|
|
9
5
|
|
|
10
6
|
var __defProp = Object.defineProperty;
|
|
11
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
|
|
9
|
+
// ../zimic-utils/dist/chunk-PAWJFY3S.mjs
|
|
10
|
+
var __defProp2 = Object.defineProperty;
|
|
11
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
12
|
+
|
|
13
|
+
// ../zimic-utils/dist/chunk-3O5CS47X.mjs
|
|
14
|
+
function isDefined(value) {
|
|
15
|
+
return value !== undefined && value !== null;
|
|
16
|
+
}
|
|
17
|
+
__name(isDefined, "isDefined");
|
|
18
|
+
__name2(isDefined, "isDefined");
|
|
19
|
+
var isDefined_default = isDefined;
|
|
12
20
|
function isNeverType(type) {
|
|
13
21
|
return type.kind === ts3.SyntaxKind.NeverKeyword;
|
|
14
22
|
}
|
|
@@ -88,7 +96,7 @@ function normalizeOperation(operation, context) {
|
|
|
88
96
|
__name(normalizeOperation, "normalizeOperation");
|
|
89
97
|
function normalizeOperations(operations, context) {
|
|
90
98
|
const newIdentifier = createOperationsIdentifier(context.serviceName);
|
|
91
|
-
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(
|
|
99
|
+
const newMembers = operations.members.map((operation) => normalizeOperation(operation, context)).filter(isDefined_default);
|
|
92
100
|
return ts3.factory.updateInterfaceDeclaration(
|
|
93
101
|
operations,
|
|
94
102
|
operations.modifiers,
|
|
@@ -113,7 +121,7 @@ function removeOperationIfUnreferenced(operation, context) {
|
|
|
113
121
|
}
|
|
114
122
|
__name(removeOperationIfUnreferenced, "removeOperationIfUnreferenced");
|
|
115
123
|
function removeUnreferencedOperations(operations, context) {
|
|
116
|
-
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(
|
|
124
|
+
const newMembers = operations.members.map((operation) => removeOperationIfUnreferenced(operation, context)).filter(isDefined_default);
|
|
117
125
|
context.referencedTypes.operations.clear();
|
|
118
126
|
if (newMembers.length === 0) {
|
|
119
127
|
return undefined;
|
|
@@ -305,16 +313,16 @@ function normalizeContentType(contentType, context, options) {
|
|
|
305
313
|
if (!ts3.isTypeLiteralNode(contentType)) {
|
|
306
314
|
return contentType;
|
|
307
315
|
}
|
|
308
|
-
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(
|
|
316
|
+
const newHeader = contentType.members.map((member) => normalizeRequestHeaders(member, context)).find(isDefined_default);
|
|
309
317
|
const newBodyMembers = contentType.members.flatMap((body) => {
|
|
310
318
|
if (isContentPropertySignature(body)) {
|
|
311
|
-
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(
|
|
319
|
+
return body.type.members.map((member) => normalizeRequestBodyMember(member, context, { questionToken: bodyQuestionToken })).filter(isDefined_default);
|
|
312
320
|
}
|
|
313
321
|
return [];
|
|
314
322
|
});
|
|
315
323
|
if (newBodyMembers.length <= 1) {
|
|
316
324
|
const newBodyMemberPropertySignatures = newBodyMembers.map((bodyMember) => bodyMember.propertySignature);
|
|
317
|
-
const newMembers = [newHeader, ...newBodyMemberPropertySignatures].filter(
|
|
325
|
+
const newMembers = [newHeader, ...newBodyMemberPropertySignatures].filter(isDefined_default);
|
|
318
326
|
return ts3.factory.updateTypeLiteralNode(contentType, ts3.factory.createNodeArray(newMembers));
|
|
319
327
|
} else {
|
|
320
328
|
const bodyMemberUnionTypes = newBodyMembers.map((bodyMember) => {
|
|
@@ -419,7 +427,7 @@ function normalizeResponses(responses, context) {
|
|
|
419
427
|
}
|
|
420
428
|
const newIdentifier = ts3.factory.createIdentifier("response");
|
|
421
429
|
const newQuestionToken = undefined;
|
|
422
|
-
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(
|
|
430
|
+
const newMembers = responses.type.members.map((response) => normalizeResponse(response, context), context).filter(isDefined_default);
|
|
423
431
|
const sortedNewMembers = Array.from(newMembers).sort((response, otherResponse) => {
|
|
424
432
|
return response.statusCode.value.localeCompare(otherResponse.statusCode.value);
|
|
425
433
|
});
|
|
@@ -556,7 +564,7 @@ function mergeRequestHeadersMembers(members) {
|
|
|
556
564
|
if (firstHeadersIndex !== undefined) {
|
|
557
565
|
mergedHeadersMembers[firstHeadersIndex] = mergedHeaders;
|
|
558
566
|
}
|
|
559
|
-
return mergedHeadersMembers.filter(
|
|
567
|
+
return mergedHeadersMembers.filter(isDefined_default);
|
|
560
568
|
}
|
|
561
569
|
__name(mergeRequestHeadersMembers, "mergeRequestHeadersMembers");
|
|
562
570
|
function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
@@ -576,12 +584,12 @@ function mergeRequestAndParameterTypes(requestType, methodMembers, context) {
|
|
|
576
584
|
__name(mergeRequestAndParameterTypes, "mergeRequestAndParameterTypes");
|
|
577
585
|
function normalizeRequestTypeWithParameters(requestType, methodMembers, context) {
|
|
578
586
|
if (ts3.isUnionTypeNode(requestType)) {
|
|
579
|
-
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(
|
|
587
|
+
const newTypes = requestType.types.map((type) => normalizeRequestTypeWithParameters(type, methodMembers, context)).filter(isDefined_default);
|
|
580
588
|
return ts3.factory.updateUnionTypeNode(requestType, ts3.factory.createNodeArray(newTypes));
|
|
581
589
|
}
|
|
582
590
|
if (ts3.isIndexedAccessTypeNode(requestType)) {
|
|
583
591
|
const newType = normalizeRequestTypeWithParameters(ts3.factory.createTypeLiteralNode([]), methodMembers, context);
|
|
584
|
-
return ts3.factory.createIntersectionTypeNode([requestType, newType].filter(
|
|
592
|
+
return ts3.factory.createIntersectionTypeNode([requestType, newType].filter(isDefined_default));
|
|
585
593
|
}
|
|
586
594
|
return mergeRequestAndParameterTypes(requestType, methodMembers, context);
|
|
587
595
|
}
|
|
@@ -610,7 +618,7 @@ function normalizeMethodMemberWithParameters(methodMember, methodMembers, contex
|
|
|
610
618
|
}
|
|
611
619
|
__name(normalizeMethodMemberWithParameters, "normalizeMethodMemberWithParameters");
|
|
612
620
|
function normalizeTypeLiteralMethodType(methodType, context) {
|
|
613
|
-
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(
|
|
621
|
+
const newMembers = methodType.members.map((member) => normalizeMethodMember(member, context)).filter(isDefined_default).map((member, _index, partialMembers) => normalizeMethodMemberWithParameters(member, partialMembers, context)).filter(isDefined_default);
|
|
614
622
|
return ts3.factory.updateTypeLiteralNode(methodType, ts3.factory.createNodeArray(newMembers));
|
|
615
623
|
}
|
|
616
624
|
__name(normalizeTypeLiteralMethodType, "normalizeTypeLiteralMethodType");
|
|
@@ -682,7 +690,7 @@ function normalizePath(path4, context, options = {}) {
|
|
|
682
690
|
const newIdentifier = isComponent2 ? path4.name : ts3.factory.createStringLiteral(newPathName);
|
|
683
691
|
let newType;
|
|
684
692
|
if (ts3.isTypeLiteralNode(path4.type)) {
|
|
685
|
-
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(
|
|
693
|
+
const newMethods = path4.type.members.map((method) => normalizeMethod(method, context, { pathName: newPathName })).filter(isDefined_default);
|
|
686
694
|
if (newMethods.length === 0) {
|
|
687
695
|
return undefined;
|
|
688
696
|
}
|
|
@@ -708,7 +716,7 @@ __name(wrapPathsType, "wrapPathsType");
|
|
|
708
716
|
function normalizePaths(pathsOrTypeAlias, context) {
|
|
709
717
|
const newIdentifier = createPathsIdentifier(context.serviceName);
|
|
710
718
|
const paths = ts3.isTypeAliasDeclaration(pathsOrTypeAlias) ? ts3.factory.createInterfaceDeclaration(pathsOrTypeAlias.modifiers, pathsOrTypeAlias.name, undefined, undefined, []) : pathsOrTypeAlias;
|
|
711
|
-
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(
|
|
719
|
+
const newMembers = paths.members.map((path4) => normalizePath(path4, context)).filter(isDefined_default);
|
|
712
720
|
const newType = ts3.factory.createTypeLiteralNode(newMembers);
|
|
713
721
|
return ts3.factory.createTypeAliasDeclaration(
|
|
714
722
|
paths.modifiers,
|
|
@@ -921,7 +929,7 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
921
929
|
}
|
|
922
930
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
923
931
|
const newIdentifier = ts3.factory.createIdentifier(componentGroupName);
|
|
924
|
-
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(
|
|
932
|
+
const newComponents = componentGroup.type.members.map((component) => normalizeComponent(component, componentGroupName, context)).filter(isDefined_default);
|
|
925
933
|
const newType = ts3.factory.updateTypeLiteralNode(componentGroup.type, ts3.factory.createNodeArray(newComponents));
|
|
926
934
|
return ts3.factory.updatePropertySignature(
|
|
927
935
|
componentGroup,
|
|
@@ -934,7 +942,7 @@ function normalizeComponentGroup(componentGroup, context) {
|
|
|
934
942
|
__name(normalizeComponentGroup, "normalizeComponentGroup");
|
|
935
943
|
function normalizeComponents(components, context) {
|
|
936
944
|
const newIdentifier = createComponentsIdentifier(context.serviceName);
|
|
937
|
-
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(
|
|
945
|
+
const newMembers = components.members.map((componentGroup) => normalizeComponentGroup(componentGroup, context)).filter(isDefined_default);
|
|
938
946
|
return ts3.factory.updateInterfaceDeclaration(
|
|
939
947
|
components,
|
|
940
948
|
components.modifiers,
|
|
@@ -997,7 +1005,7 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
997
1005
|
return undefined;
|
|
998
1006
|
}
|
|
999
1007
|
const componentGroupName = normalizeComponentGroupName(componentGroup.name.text);
|
|
1000
|
-
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(
|
|
1008
|
+
const newComponents = componentGroup.type.members.map((component) => removeComponentIfUnreferenced(component, componentGroupName, context)).filter(isDefined_default);
|
|
1001
1009
|
if (newComponents.length === 0) {
|
|
1002
1010
|
return undefined;
|
|
1003
1011
|
}
|
|
@@ -1011,7 +1019,7 @@ function removeUnreferencedComponentsInGroup(componentGroup, context) {
|
|
|
1011
1019
|
}
|
|
1012
1020
|
__name(removeUnreferencedComponentsInGroup, "removeUnreferencedComponentsInGroup");
|
|
1013
1021
|
function removeUnreferencedComponents(components, context) {
|
|
1014
|
-
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(
|
|
1022
|
+
const newComponentGroups = components.members.map((componentGroup) => removeUnreferencedComponentsInGroup(componentGroup, context)).filter(isDefined_default);
|
|
1015
1023
|
context.referencedTypes.components.clear();
|
|
1016
1024
|
if (newComponentGroups.length === 0) {
|
|
1017
1025
|
return undefined;
|
|
@@ -1032,6 +1040,29 @@ function convertToPascalCase(value) {
|
|
|
1032
1040
|
return value.replace(/(?:^|[^A-Za-z\d])([A-Za-z\d])/g, (_match, letter) => letter.toUpperCase());
|
|
1033
1041
|
}
|
|
1034
1042
|
__name(convertToPascalCase, "convertToPascalCase");
|
|
1043
|
+
|
|
1044
|
+
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
1045
|
+
function isNonEmpty(value) {
|
|
1046
|
+
return isDefined_default(value) && value !== "";
|
|
1047
|
+
}
|
|
1048
|
+
__name(isNonEmpty, "isNonEmpty");
|
|
1049
|
+
__name2(isNonEmpty, "isNonEmpty");
|
|
1050
|
+
var isNonEmpty_default = isNonEmpty;
|
|
1051
|
+
|
|
1052
|
+
// ../zimic-utils/dist/url/createRegExpFromWildcardPath.mjs
|
|
1053
|
+
function prepareURLForRegex(url) {
|
|
1054
|
+
const encodedURL = encodeURI(url);
|
|
1055
|
+
return encodedURL.replace(/([.()*?+$\\])/g, "\\$1");
|
|
1056
|
+
}
|
|
1057
|
+
__name(prepareURLForRegex, "prepareURLForRegex");
|
|
1058
|
+
__name2(prepareURLForRegex, "prepareURLForRegex");
|
|
1059
|
+
function createRegExpFromWildcardPath(path4, options) {
|
|
1060
|
+
const pathWithReplacedWildcards = prepareURLForRegex(path4).replace(/^\/+|\/+$/g, "").replace(/\\\*/g, "*").replace(/\*\*\/\*/g, "**").replace(/(^|[^*])\*([^*]|$)/g, "$1[^/]*$2").replace(/\*\*/g, ".*");
|
|
1061
|
+
return new RegExp(`^${options.prefix}/*${pathWithReplacedWildcards}/*$`);
|
|
1062
|
+
}
|
|
1063
|
+
__name(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1064
|
+
__name2(createRegExpFromWildcardPath, "createRegExpFromWildcardPath");
|
|
1065
|
+
var createRegExpFromWildcardPath_default = createRegExpFromWildcardPath;
|
|
1035
1066
|
var HTTP_METHOD_OPTIONS = HTTP_METHODS.join("|");
|
|
1036
1067
|
var MODIFIER_GROUP = "(?<modifier>!?)";
|
|
1037
1068
|
var METHOD_FILTER_GROUP = `(?<method>(?:\\*|(?:${HTTP_METHOD_OPTIONS})(?:,\\s*(?:${HTTP_METHOD_OPTIONS}))*))`;
|
|
@@ -1050,7 +1081,7 @@ function parseRawFilter(rawFilter) {
|
|
|
1050
1081
|
const methodFilterGroup = `(?:${filteredMethodsOrWildcard.toUpperCase().replace(/,/g, "|").replace(/\*/g, ".*")}) `;
|
|
1051
1082
|
const isNegativeMatch = filterModifier === "!";
|
|
1052
1083
|
return {
|
|
1053
|
-
expression:
|
|
1084
|
+
expression: createRegExpFromWildcardPath_default(filteredPath, { prefix: methodFilterGroup }),
|
|
1054
1085
|
isNegativeMatch
|
|
1055
1086
|
};
|
|
1056
1087
|
}
|
|
@@ -1079,7 +1110,7 @@ async function readPathFiltersFromFile(filePath) {
|
|
|
1079
1110
|
}
|
|
1080
1111
|
__name(readPathFiltersFromFile, "readPathFiltersFromFile");
|
|
1081
1112
|
function ignoreEmptyFilters(filters) {
|
|
1082
|
-
return filters.map((line) => line.trim()).filter(
|
|
1113
|
+
return filters.map((line) => line.trim()).filter(isNonEmpty_default);
|
|
1083
1114
|
}
|
|
1084
1115
|
__name(ignoreEmptyFilters, "ignoreEmptyFilters");
|
|
1085
1116
|
|
|
@@ -1117,7 +1148,21 @@ function createImportDeclarations(context) {
|
|
|
1117
1148
|
return [httpImportDeclaration];
|
|
1118
1149
|
}
|
|
1119
1150
|
__name(createImportDeclarations, "createImportDeclarations");
|
|
1120
|
-
|
|
1151
|
+
|
|
1152
|
+
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
1153
|
+
function createCachedDynamicImport(importModuleDynamically) {
|
|
1154
|
+
let cachedImportResult;
|
|
1155
|
+
return /* @__PURE__ */ __name2(/* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
|
|
1156
|
+
if (cachedImportResult === undefined) {
|
|
1157
|
+
cachedImportResult = await importModuleDynamically();
|
|
1158
|
+
}
|
|
1159
|
+
return cachedImportResult;
|
|
1160
|
+
}, "importModuleDynamicallyWithCache"), "importModuleDynamicallyWithCache");
|
|
1161
|
+
}
|
|
1162
|
+
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1163
|
+
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
1164
|
+
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
1165
|
+
var importOpenapiTypeScript = createCachedDynamicImport_default(() => import('openapi-typescript'));
|
|
1121
1166
|
function transformSchemaObject(schemaObject) {
|
|
1122
1167
|
if (schemaObject.format === "binary") {
|
|
1123
1168
|
const blobType = createBlobType();
|
|
@@ -1197,18 +1242,18 @@ __name(removeUnknownResources, "removeUnknownResources");
|
|
|
1197
1242
|
function normalizeRawNodes(rawNodes, context, options) {
|
|
1198
1243
|
let normalizedNodes = rawNodes.map((node) => isPathsDeclaration(node) ? normalizePaths(node, context) : node);
|
|
1199
1244
|
if (options.prune) {
|
|
1200
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(
|
|
1245
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? removeUnreferencedOperations(node, context) : node).filter(isDefined_default);
|
|
1201
1246
|
}
|
|
1202
|
-
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(
|
|
1247
|
+
normalizedNodes = normalizedNodes.map((node) => isOperationsDeclaration(node) ? normalizeOperations(node, context) : node).filter(isDefined_default);
|
|
1203
1248
|
if (options.prune) {
|
|
1204
1249
|
for (const node of normalizedNodes) {
|
|
1205
1250
|
if (isComponentsDeclaration(node, context)) {
|
|
1206
1251
|
populateReferencedComponents(node, context);
|
|
1207
1252
|
}
|
|
1208
1253
|
}
|
|
1209
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(
|
|
1254
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? removeUnreferencedComponents(node, context) : node).filter(isDefined_default);
|
|
1210
1255
|
}
|
|
1211
|
-
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(
|
|
1256
|
+
normalizedNodes = normalizedNodes.map((node) => isComponentsDeclaration(node, context) ? normalizeComponents(node, context) : node).map(removeUnknownResources).filter(isDefined_default);
|
|
1212
1257
|
return normalizedNodes;
|
|
1213
1258
|
}
|
|
1214
1259
|
__name(normalizeRawNodes, "normalizeRawNodes");
|
|
@@ -1300,5 +1345,5 @@ var typegen = Object.freeze(new TypegenNamespace_default());
|
|
|
1300
1345
|
* The root import module is defined at build time. The fallback is not expected to be used. */
|
|
1301
1346
|
|
|
1302
1347
|
export { __name, logWithPrefix, typegen };
|
|
1303
|
-
//# sourceMappingURL=chunk-
|
|
1304
|
-
//# sourceMappingURL=chunk-
|
|
1348
|
+
//# sourceMappingURL=chunk-SSSE2VVN.mjs.map
|
|
1349
|
+
//# sourceMappingURL=chunk-SSSE2VVN.mjs.map
|