@nestbridge/core 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { SyntaxKind, isArrayLiteralExpression, isArrayTypeNode, isArrowFunction, isBlock, isCallExpression, isClassDeclaration, isDecorator, isExportDeclaration, isExpressionStatement, isFalseLiteral, isFunctionExpression, isIdentifier, isImportDeclaration, isMethodDeclaration, isNamedExports, isNamedImports, isNewExpression, isNullLiteral, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isReturnStatement, isSpreadElement, isStringLiteral, isStringLiteralLikeNode, isTrueLiteral, isTypeReferenceNode, isUnionTypeNode, isVariableStatement } from "typescript/unstable/ast";
1
+ import { SyntaxKind, isArrayLiteralExpression, isArrayTypeNode, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isConditionalExpression, isDecorator, isDoStatement, isExportDeclaration, isExpressionStatement, isFalseLiteral, isForInStatement, isForOfStatement, isForStatement, isFunctionExpression, isIdentifier, isIfStatement, isImportDeclaration, isMethodDeclaration, isNamedExports, isNamedImports, isNewExpression, isNullLiteral, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isReturnStatement, isSpreadElement, isStringLiteral, isStringLiteralLikeNode, isSwitchStatement, isTrueLiteral, isTypeReferenceNode, isUnionTypeNode, isVariableStatement, isWhileStatement } from "typescript/unstable/ast";
2
2
  import { API } from "typescript/unstable/sync";
3
3
  import { existsSync } from "node:fs";
4
4
  import { dirname, extname, relative, resolve } from "node:path";
@@ -43,6 +43,12 @@ var readStaticStringArgument = (decorator) => {
43
43
  };
44
44
  };
45
45
  //#endregion
46
+ //#region src/models/graphql-operation-kind.ts
47
+ var GRAPHQL_OPERATION_DECORATOR_NAMES = {
48
+ Query: "query",
49
+ Mutation: "mutation"
50
+ };
51
+ //#endregion
46
52
  //#region src/models/http-method.ts
47
53
  var HTTP_METHOD_DECORATOR_NAMES = {
48
54
  Get: "GET",
@@ -257,6 +263,35 @@ var readResponseKind = (returnType) => {
257
263
  return "json";
258
264
  };
259
265
  //#endregion
266
+ //#region src/analysis/read-route-version.ts
267
+ var VERSION_NEUTRAL_NAME = "VERSION_NEUTRAL";
268
+ var readSingleRouteVersion = (expression) => {
269
+ if (isStringLiteralLikeNode(expression)) return {
270
+ ok: true,
271
+ version: expression.text
272
+ };
273
+ if (isIdentifier(expression) && expression.text === VERSION_NEUTRAL_NAME) return {
274
+ ok: true,
275
+ version: null
276
+ };
277
+ return {
278
+ ok: false,
279
+ argumentText: expression.getText()
280
+ };
281
+ };
282
+ /**
283
+ * An array of versions registers the route once per version, so any one of them is a valid URL;
284
+ * the first is used.
285
+ */
286
+ var readRouteVersion = (expression) => {
287
+ if (!isArrayLiteralExpression(expression)) return readSingleRouteVersion(expression);
288
+ const [firstElement] = expression.elements;
289
+ return firstElement === void 0 ? {
290
+ ok: false,
291
+ argumentText: expression.getText()
292
+ } : readSingleRouteVersion(firstElement);
293
+ };
294
+ //#endregion
260
295
  //#region src/analysis/route-path.ts
261
296
  var trimSlashes = (segment) => segment.replace(/^\/+/, "").replace(/\/+$/, "");
262
297
  var joinRoutePath = (controllerPath, methodPath) => {
@@ -264,6 +299,26 @@ var joinRoutePath = (controllerPath, methodPath) => {
264
299
  };
265
300
  //#endregion
266
301
  //#region src/analysis/extract-method-definition.ts
302
+ var VERSION_DECORATOR_NAME = "Version";
303
+ var readMethodVersion = (method, context) => {
304
+ const decorator = findDecorator(method, VERSION_DECORATOR_NAME);
305
+ if (decorator === void 0) return { value: context.controllerVersion };
306
+ const [argument] = isCallExpression(decorator.expression) ? decorator.expression.arguments : [];
307
+ const routeVersion = argument === void 0 ? void 0 : readRouteVersion(argument);
308
+ if (routeVersion?.ok === true) return { value: routeVersion.version };
309
+ const location = locationOf(context.sourceFile, method);
310
+ context.diagnostics.push({
311
+ code: "unsupported-route",
312
+ title: "Unsupported route.",
313
+ controllerName: context.controllerName,
314
+ memberName: method.name.getText(),
315
+ detail: "Route versions must be statically analyzable.",
316
+ found: `@Version(${routeVersion?.argumentText ?? ""})`,
317
+ filePath: context.filePath,
318
+ line: location.line,
319
+ column: location.column
320
+ });
321
+ };
267
322
  var extractMethodDefinition = (method, context) => {
268
323
  const decorator = findAnyDecorator(method, Object.keys(HTTP_METHOD_DECORATOR_NAMES));
269
324
  if (decorator === void 0) return;
@@ -288,6 +343,8 @@ var extractMethodDefinition = (method, context) => {
288
343
  });
289
344
  return;
290
345
  }
346
+ const version = readMethodVersion(method, context);
347
+ if (version === void 0) return;
291
348
  const parameters = method.parameters.map((parameter, index) => extractParameterDefinition(parameter, index, {
292
349
  sourceFile: context.sourceFile,
293
350
  filePath: context.filePath,
@@ -300,6 +357,7 @@ var extractMethodDefinition = (method, context) => {
300
357
  name: methodName,
301
358
  httpMethod,
302
359
  path: joinRoutePath(context.controllerPath, routeArgument.value),
360
+ version: version.value,
303
361
  parameters: parameters.filter((parameter) => parameter !== void 0),
304
362
  responseKind: readResponseKind(method.type),
305
363
  line: location.line,
@@ -307,21 +365,81 @@ var extractMethodDefinition = (method, context) => {
307
365
  };
308
366
  };
309
367
  //#endregion
368
+ //#region src/analysis/read-controller-options.ts
369
+ var PATH_OPTION_NAME = "path";
370
+ var VERSION_OPTION_NAME = "version";
371
+ var optionNameOf = (property) => {
372
+ const name = property.name;
373
+ return isIdentifier(name) || isStringLiteralLikeNode(name) ? name.text : void 0;
374
+ };
375
+ var readControllerOptions = (decorator) => {
376
+ const expression = decorator.expression;
377
+ if (!isCallExpression(expression)) return {
378
+ ok: true,
379
+ path: void 0,
380
+ version: void 0
381
+ };
382
+ const [firstArgument] = expression.arguments;
383
+ if (firstArgument === void 0) return {
384
+ ok: true,
385
+ path: void 0,
386
+ version: void 0
387
+ };
388
+ if (isStringLiteralLikeNode(firstArgument)) return {
389
+ ok: true,
390
+ path: firstArgument.text,
391
+ version: void 0
392
+ };
393
+ if (!isObjectLiteralExpression(firstArgument)) return {
394
+ ok: false,
395
+ argumentText: firstArgument.getText()
396
+ };
397
+ let path;
398
+ let version;
399
+ for (const property of firstArgument.properties) {
400
+ if (!isPropertyAssignment(property)) return {
401
+ ok: false,
402
+ argumentText: firstArgument.getText()
403
+ };
404
+ const optionName = optionNameOf(property);
405
+ if (optionName === PATH_OPTION_NAME) {
406
+ if (!isStringLiteralLikeNode(property.initializer)) return {
407
+ ok: false,
408
+ argumentText: firstArgument.getText()
409
+ };
410
+ path = property.initializer.text;
411
+ }
412
+ if (optionName === VERSION_OPTION_NAME) {
413
+ const routeVersion = readRouteVersion(property.initializer);
414
+ if (!routeVersion.ok) return {
415
+ ok: false,
416
+ argumentText: firstArgument.getText()
417
+ };
418
+ version = routeVersion.version;
419
+ }
420
+ }
421
+ return {
422
+ ok: true,
423
+ path,
424
+ version
425
+ };
426
+ };
427
+ //#endregion
310
428
  //#region src/analysis/extract-controller-definition.ts
311
429
  var extractControllerDefinition = (classDeclaration, sourceFile, filePath, diagnostics) => {
312
430
  const controllerName = classDeclaration.name?.text ?? "(anonymous controller)";
313
431
  const decorator = findDecorator(classDeclaration, "Controller");
314
432
  if (decorator === void 0) return;
315
433
  const location = locationOf(sourceFile, classDeclaration);
316
- const argument = readStaticStringArgument(decorator);
317
- if (!argument.ok) {
434
+ const options = readControllerOptions(decorator);
435
+ if (!options.ok) {
318
436
  diagnostics.push({
319
437
  code: "unsupported-route",
320
438
  title: "Unsupported route.",
321
439
  controllerName,
322
440
  memberName: "",
323
- detail: "Controller paths must be statically analyzable.",
324
- found: `@Controller(${argument.argumentText})`,
441
+ detail: "Controller paths and versions must be statically analyzable.",
442
+ found: `@Controller(${options.argumentText})`,
325
443
  filePath,
326
444
  line: location.line,
327
445
  column: location.column
@@ -332,12 +450,13 @@ var extractControllerDefinition = (classDeclaration, sourceFile, filePath, diagn
332
450
  sourceFile,
333
451
  filePath,
334
452
  controllerName,
335
- controllerPath: argument.value ?? "",
453
+ controllerPath: options.path ?? "",
454
+ controllerVersion: options.version,
336
455
  diagnostics
337
456
  })).filter((method) => method !== void 0);
338
457
  return {
339
458
  name: controllerName,
340
- path: argument.value ?? "",
459
+ path: options.path ?? "",
341
460
  sourceFile: filePath,
342
461
  methods
343
462
  };
@@ -378,12 +497,6 @@ var analyzeControllers = (filePaths) => {
378
497
  };
379
498
  };
380
499
  //#endregion
381
- //#region src/models/graphql-operation-kind.ts
382
- var GRAPHQL_OPERATION_DECORATOR_NAMES = {
383
- Query: "query",
384
- Mutation: "mutation"
385
- };
386
- //#endregion
387
500
  //#region src/analysis/read-type-thunk-expression.ts
388
501
  var readTypeThunkExpression = (thunk) => {
389
502
  if (!isBlock(thunk.body)) return thunk.body;
@@ -840,6 +953,40 @@ var analyzeResolvers = (filePaths) => {
840
953
  };
841
954
  };
842
955
  //#endregion
956
+ //#region src/analysis/apply-application-routing.ts
957
+ var splitSegments = (path) => path.split("/").filter((segment) => segment.length > 0);
958
+ var matchesExclusionPath = (pattern, path) => {
959
+ const patternSegments = splitSegments(pattern);
960
+ const pathSegments = splitSegments(path);
961
+ for (const [index, patternSegment] of patternSegments.entries()) {
962
+ if (patternSegment.startsWith("*")) return pathSegments.length > index;
963
+ const pathSegment = pathSegments[index];
964
+ if (pathSegment === void 0) return false;
965
+ if (!patternSegment.startsWith(":") && patternSegment !== pathSegment) return false;
966
+ }
967
+ return patternSegments.length === pathSegments.length;
968
+ };
969
+ var isExcluded = (exclusion, method) => (exclusion.httpMethod === void 0 || exclusion.httpMethod === method.httpMethod) && matchesExclusionPath(exclusion.path, method.path);
970
+ var prefixSegmentFor = (method, globalPrefix) => {
971
+ if (globalPrefix === void 0 || splitSegments(globalPrefix.prefix).length === 0) return "";
972
+ if (globalPrefix.exclude.some((exclusion) => isExcluded(exclusion, method))) return "";
973
+ return `/${splitSegments(globalPrefix.prefix).join("/")}`;
974
+ };
975
+ var versionSegmentFor = (method, versioning) => {
976
+ if (versioning === void 0 || method.version === null) return "";
977
+ const version = method.version ?? versioning.defaultVersion;
978
+ return version === void 0 ? "" : `/${versioning.prefix}${version}`;
979
+ };
980
+ var joinRoutedPath = (...parts) => `/${splitSegments(parts.join("/")).join("/")}`;
981
+ var routeMethod = (method, routing) => ({
982
+ ...method,
983
+ path: joinRoutedPath(prefixSegmentFor(method, routing.globalPrefix), versionSegmentFor(method, routing.versioning), method.path)
984
+ });
985
+ var applyApplicationRouting = (controllers, routing) => controllers.map((controller) => ({
986
+ ...controller,
987
+ methods: controller.methods.map((method) => routeMethod(method, routing))
988
+ }));
989
+ //#endregion
843
990
  //#region src/analysis/find-app-filter-provider-class-name.ts
844
991
  var MODULE_DECORATOR_NAME = "Module";
845
992
  var PROVIDERS_PROPERTY_NAME = "providers";
@@ -1025,6 +1172,152 @@ var detectErrorResponseShape = (bootstrapFilePath) => {
1025
1172
  return errorBodyTypeSource === void 0 ? void 0 : { errorBodyTypeSource };
1026
1173
  };
1027
1174
  //#endregion
1175
+ //#region src/analysis/collect-bootstrap-calls.ts
1176
+ var isConditionalContainer = (node) => isIfStatement(node) || isConditionalExpression(node) || isSwitchStatement(node) || isForStatement(node) || isForInStatement(node) || isForOfStatement(node) || isWhileStatement(node) || isDoStatement(node) || isBinaryExpression(node) && (node.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken || node.operatorToken.kind === SyntaxKind.BarBarToken || node.operatorToken.kind === SyntaxKind.QuestionQuestionToken);
1177
+ var collect = (node, methodName, conditional, calls) => {
1178
+ if (isCallExpression(node) && isPropertyAccessExpression(node.expression) && node.expression.name.text === methodName) calls.push({
1179
+ call: node,
1180
+ conditional
1181
+ });
1182
+ const childConditional = conditional || isConditionalContainer(node);
1183
+ node.forEachChild((child) => {
1184
+ collect(child, methodName, childConditional, calls);
1185
+ });
1186
+ };
1187
+ var collectBootstrapCalls = (sourceFile, methodName) => {
1188
+ const calls = [];
1189
+ collect(sourceFile, methodName, false, calls);
1190
+ return calls;
1191
+ };
1192
+ //#endregion
1193
+ //#region src/analysis/create-bootstrap-diagnostic.ts
1194
+ var createBootstrapDiagnostic = (source) => {
1195
+ const location = locationOf(source.sourceFile, source.node);
1196
+ return {
1197
+ code: source.code,
1198
+ title: source.title,
1199
+ controllerName: "(bootstrap)",
1200
+ memberName: "",
1201
+ detail: source.detail,
1202
+ found: source.node.getText(),
1203
+ expected: source.expected,
1204
+ filePath: source.filePath,
1205
+ line: location.line,
1206
+ column: location.column
1207
+ };
1208
+ };
1209
+ //#endregion
1210
+ //#region src/analysis/read-global-prefix-exclusions.ts
1211
+ var REQUEST_METHOD_ENUM_NAME = "RequestMethod";
1212
+ var REQUEST_METHOD_ALL_NAME = "ALL";
1213
+ var EXCLUDE_OPTION_NAME = "exclude";
1214
+ var PATH_PROPERTY_NAME = "path";
1215
+ var METHOD_PROPERTY_NAME = "method";
1216
+ var SUPPORTED_EXCLUSION_PATH = /^[A-Za-z0-9_\-./:*]*$/;
1217
+ var REQUEST_METHODS = {
1218
+ GET: "GET",
1219
+ POST: "POST",
1220
+ PUT: "PUT",
1221
+ PATCH: "PATCH",
1222
+ DELETE: "DELETE"
1223
+ };
1224
+ var readExclusionPath = (expression) => isStringLiteralLikeNode(expression) && SUPPORTED_EXCLUSION_PATH.test(expression.text) ? expression.text : void 0;
1225
+ var readRequestMethod = (expression) => {
1226
+ if (!isPropertyAccessExpression(expression) || !isIdentifier(expression.expression) || expression.expression.text !== REQUEST_METHOD_ENUM_NAME) return;
1227
+ const methodName = expression.name.text;
1228
+ if (methodName === REQUEST_METHOD_ALL_NAME) return {
1229
+ httpMethod: void 0,
1230
+ generated: true
1231
+ };
1232
+ const httpMethod = REQUEST_METHODS[methodName];
1233
+ return {
1234
+ httpMethod,
1235
+ generated: httpMethod !== void 0
1236
+ };
1237
+ };
1238
+ var readExclusion = (element) => {
1239
+ if (isStringLiteralLikeNode(element)) {
1240
+ const path = readExclusionPath(element);
1241
+ return path === void 0 ? void 0 : { exclusion: { path } };
1242
+ }
1243
+ if (!isObjectLiteralExpression(element)) return;
1244
+ let path;
1245
+ let httpMethod;
1246
+ for (const property of element.properties) {
1247
+ if (!isPropertyAssignment(property)) return;
1248
+ const propertyName = property.name.getText();
1249
+ if (propertyName === PATH_PROPERTY_NAME) path = readExclusionPath(property.initializer);
1250
+ if (propertyName === METHOD_PROPERTY_NAME) {
1251
+ const requestMethod = readRequestMethod(property.initializer);
1252
+ if (requestMethod === void 0) return;
1253
+ if (!requestMethod.generated) return { exclusion: void 0 };
1254
+ httpMethod = requestMethod.httpMethod;
1255
+ }
1256
+ }
1257
+ if (path === void 0) return;
1258
+ return { exclusion: httpMethod === void 0 ? { path } : {
1259
+ path,
1260
+ httpMethod
1261
+ } };
1262
+ };
1263
+ /**
1264
+ * Returns `undefined` when an entry cannot be read statically. Entries for request methods
1265
+ * NestBridge never generates (OPTIONS, HEAD, SEARCH) are dropped because they cannot match.
1266
+ */
1267
+ var readGlobalPrefixExclusions = (options) => {
1268
+ if (options === void 0) return [];
1269
+ if (!isObjectLiteralExpression(options)) return;
1270
+ const exclusions = [];
1271
+ for (const property of options.properties) {
1272
+ if (!isPropertyAssignment(property)) return;
1273
+ if (property.name.getText() !== EXCLUDE_OPTION_NAME) continue;
1274
+ if (!isArrayLiteralExpression(property.initializer)) return;
1275
+ for (const element of property.initializer.elements) {
1276
+ const entry = readExclusion(element);
1277
+ if (entry === void 0) return;
1278
+ if (entry.exclusion !== void 0) exclusions.push(entry.exclusion);
1279
+ }
1280
+ }
1281
+ return exclusions;
1282
+ };
1283
+ //#endregion
1284
+ //#region src/analysis/detect-global-prefix.ts
1285
+ var SET_GLOBAL_PREFIX_METHOD_NAME = "setGlobalPrefix";
1286
+ var EXPECTED$1 = "A single unconditional setGlobalPrefix() call with a string literal prefix and exclude entries written as string literals or { path, method } literals. Set the `globalPrefix` option to provide the prefix explicitly.";
1287
+ var unsupported$1 = (sourceFile, filePath, node, detail) => ({
1288
+ value: void 0,
1289
+ diagnostics: [createBootstrapDiagnostic({
1290
+ code: "unsupported-global-prefix",
1291
+ title: "Unsupported global prefix.",
1292
+ detail,
1293
+ expected: EXPECTED$1,
1294
+ node,
1295
+ sourceFile,
1296
+ filePath
1297
+ })]
1298
+ });
1299
+ var detectGlobalPrefix = (bootstrapFilePath) => {
1300
+ const sourceFile = parseSourceFile(bootstrapFilePath);
1301
+ const calls = collectBootstrapCalls(sourceFile, SET_GLOBAL_PREFIX_METHOD_NAME);
1302
+ const [first] = calls;
1303
+ if (first === void 0) return {
1304
+ value: void 0,
1305
+ diagnostics: []
1306
+ };
1307
+ if (calls.length > 1 || first.conditional) return unsupported$1(sourceFile, bootstrapFilePath, first.call, "setGlobalPrefix() must be called exactly once and unconditionally.");
1308
+ const [prefixArgument, optionsArgument] = first.call.arguments;
1309
+ if (prefixArgument === void 0 || !isStringLiteralLikeNode(prefixArgument)) return unsupported$1(sourceFile, bootstrapFilePath, first.call, "The global prefix must be a string literal.");
1310
+ const exclude = readGlobalPrefixExclusions(optionsArgument);
1311
+ if (exclude === void 0) return unsupported$1(sourceFile, bootstrapFilePath, first.call, "Global prefix exclusions must be statically analyzable.");
1312
+ return {
1313
+ value: {
1314
+ prefix: prefixArgument.text,
1315
+ exclude
1316
+ },
1317
+ diagnostics: []
1318
+ };
1319
+ };
1320
+ //#endregion
1028
1321
  //#region src/analysis/find-global-interceptor-class-names.ts
1029
1322
  var USE_GLOBAL_INTERCEPTORS_METHOD_NAME = "useGlobalInterceptors";
1030
1323
  var collectUseGlobalInterceptorsCalls = (node, calls) => {
@@ -1155,6 +1448,71 @@ var detectResponseWrapper = (bootstrapFilePath) => {
1155
1448
  return { wrappedResultTypeSource: composedTypeSource };
1156
1449
  };
1157
1450
  //#endregion
1451
+ //#region src/analysis/detect-versioning.ts
1452
+ var ENABLE_VERSIONING_METHOD_NAME = "enableVersioning";
1453
+ var VERSIONING_TYPE_ENUM_NAME = "VersioningType";
1454
+ var URI_VERSIONING_TYPE_NAME = "URI";
1455
+ var TYPE_OPTION_NAME = "type";
1456
+ var PREFIX_OPTION_NAME = "prefix";
1457
+ var DEFAULT_VERSION_OPTION_NAME = "defaultVersion";
1458
+ var DEFAULT_VERSION_PREFIX = "v";
1459
+ var EXPECTED = "A single unconditional enableVersioning() call with `type: VersioningType.URI`, a string literal or `false` prefix, and a string literal defaultVersion. Header, media type and custom versioning need request headers NestBridge cannot set. Set the `versioning` option to provide URI versioning explicitly.";
1460
+ var unsupported = (sourceFile, filePath, node, detail) => ({
1461
+ value: void 0,
1462
+ diagnostics: [createBootstrapDiagnostic({
1463
+ code: "unsupported-versioning",
1464
+ title: "Unsupported versioning.",
1465
+ detail,
1466
+ expected: EXPECTED,
1467
+ node,
1468
+ sourceFile,
1469
+ filePath
1470
+ })]
1471
+ });
1472
+ var isUriVersioningType = (node) => isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === VERSIONING_TYPE_ENUM_NAME && node.name.text === URI_VERSIONING_TYPE_NAME;
1473
+ var detectVersioning = (bootstrapFilePath) => {
1474
+ const sourceFile = parseSourceFile(bootstrapFilePath);
1475
+ const calls = collectBootstrapCalls(sourceFile, ENABLE_VERSIONING_METHOD_NAME);
1476
+ const [first] = calls;
1477
+ if (first === void 0) return {
1478
+ value: void 0,
1479
+ diagnostics: []
1480
+ };
1481
+ if (calls.length > 1 || first.conditional) return unsupported(sourceFile, bootstrapFilePath, first.call, "enableVersioning() must be called exactly once and unconditionally.");
1482
+ const [options] = first.call.arguments;
1483
+ if (options === void 0 || !isObjectLiteralExpression(options)) return unsupported(sourceFile, bootstrapFilePath, first.call, "The versioning options must be an object literal.");
1484
+ let hasUriType = false;
1485
+ let prefix = DEFAULT_VERSION_PREFIX;
1486
+ let defaultVersion;
1487
+ for (const property of options.properties) {
1488
+ if (!isPropertyAssignment(property)) return unsupported(sourceFile, bootstrapFilePath, property, "Versioning options must be written as plain properties.");
1489
+ const optionName = property.name.getText();
1490
+ const value = property.initializer;
1491
+ if (optionName === TYPE_OPTION_NAME) {
1492
+ if (!isUriVersioningType(value)) return unsupported(sourceFile, bootstrapFilePath, property, "Only VersioningType.URI is supported.");
1493
+ hasUriType = true;
1494
+ }
1495
+ if (optionName === PREFIX_OPTION_NAME) {
1496
+ if (value.kind === SyntaxKind.FalseKeyword) prefix = "";
1497
+ else if (isStringLiteralLikeNode(value)) prefix = value.text;
1498
+ else return unsupported(sourceFile, bootstrapFilePath, property, "The version prefix must be a string literal or false.");
1499
+ }
1500
+ if (optionName === DEFAULT_VERSION_OPTION_NAME) {
1501
+ const routeVersion = readRouteVersion(value);
1502
+ if (!routeVersion.ok) return unsupported(sourceFile, bootstrapFilePath, property, "The default version must be a string literal.");
1503
+ defaultVersion = routeVersion.version ?? void 0;
1504
+ }
1505
+ }
1506
+ if (!hasUriType) return unsupported(sourceFile, bootstrapFilePath, first.call, "The versioning type must be VersioningType.URI.");
1507
+ return {
1508
+ value: defaultVersion === void 0 ? { prefix } : {
1509
+ prefix,
1510
+ defaultVersion
1511
+ },
1512
+ diagnostics: []
1513
+ };
1514
+ };
1515
+ //#endregion
1158
1516
  //#region src/declarations/generate-controller-declaration.ts
1159
1517
  var REMOTE_RESULT_HELPERS = {
1160
1518
  json: "RemoteResult",
@@ -1242,8 +1600,8 @@ var NestBridgeDiagnosticError = class extends Error {
1242
1600
  };
1243
1601
  //#endregion
1244
1602
  //#region src/version.ts
1245
- var VERSION = "2.1.3";
1603
+ var VERSION = "2.2.0";
1246
1604
  //#endregion
1247
- export { NestBridgeDiagnosticError, VERSION, analyzeControllers, analyzeResolvers, detectErrorResponseShape, detectResponseWrapper, formatDiagnostic, generateControllerDeclaration, generateErrorBodyDeclaration };
1605
+ export { NestBridgeDiagnosticError, VERSION, analyzeControllers, analyzeResolvers, applyApplicationRouting, detectErrorResponseShape, detectGlobalPrefix, detectResponseWrapper, detectVersioning, formatDiagnostic, generateControllerDeclaration, generateErrorBodyDeclaration };
1248
1606
 
1249
1607
  //# sourceMappingURL=nestbridge.core.js.map