1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | const getInstanceName = (instance) => instance && instance.name;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | const getDependencyName = (dependency) =>
|
16 |
|
17 | getInstanceName(dependency) ||
|
18 |
|
19 | (shared_utils_1.isSymbol(dependency) && dependency.toString()) ||
|
20 |
|
21 | dependency ||
|
22 |
|
23 | '+';
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
|
30 | exports.UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, module) => {
|
31 | const { index, name = 'dependency', dependencies, key, } = unknownDependencyContext;
|
32 | const moduleName = getModuleName(module) || 'Module';
|
33 | const dependencyName = getDependencyName(name);
|
34 | let message = `Nest can't resolve dependencies of the ${type.toString()}`;
|
35 | const potentialSolutions = `\n
|
36 | Potential solutions:
|
37 | - If ${dependencyName} is a provider, is it part of the current ${moduleName}?
|
38 | - If ${dependencyName} is exported from a separate @Module, is that module imported within ${moduleName}?
|
39 | @Module({
|
40 | imports: [ /* the Module containing ${dependencyName} */ ]
|
41 | })
|
42 | `;
|
43 | if (shared_utils_1.isNil(index)) {
|
44 | message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
45 | return message;
|
46 | }
|
47 | const dependenciesName = (dependencies || []).map(getDependencyName);
|
48 | dependenciesName[index] = '?';
|
49 | message += ` (`;
|
50 | message += dependenciesName.join(', ');
|
51 | message += `). Please make sure that the argument ${dependencyName} at index [${index}] is available in the ${getModuleName(module)} context.`;
|
52 | message += potentialSolutions;
|
53 | return message;
|
54 | };
|
55 | exports.INVALID_MIDDLEWARE_MESSAGE = (text, name) => `The middleware doesn't provide the 'use' method (${name})`;
|
56 | exports.INVALID_MODULE_MESSAGE = (text, scope) => `Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
|
57 |
|
58 | (Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
|
59 | Scope [${scope}]
|
60 | `;
|
61 | exports.UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
|
62 | return `Nest cannot export a provider/module that is not a part of the currently processed module (${module}). Please verify whether the exported ${token} is available in this particular context.
|
63 |
|
64 | Possible Solutions:
|
65 | - Is ${token} part of the relevant providers/imports within ${module}?
|
66 | `;
|
67 | };
|
68 | exports.INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
|
69 | exports.INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name ||
|
70 | 'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
71 | exports.INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
|
72 | exports.UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;
|
73 | exports.UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
|
74 | exports.INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
|
75 | exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;
|