1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const getInstanceName = (instance) => {
|
10 | var _a, _b, _c;
|
11 | if ((_a = instance) === null || _a === void 0 ? void 0 : _a.forwardRef) {
|
12 | return (_b = instance.forwardRef()) === null || _b === void 0 ? void 0 : _b.name;
|
13 | }
|
14 | return (_c = instance) === null || _c === void 0 ? void 0 : _c.name;
|
15 | };
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | const getDependencyName = (dependency) =>
|
23 |
|
24 | getInstanceName(dependency) ||
|
25 |
|
26 | (shared_utils_1.isSymbol(dependency) && dependency.toString()) ||
|
27 |
|
28 | dependency ||
|
29 |
|
30 | '+';
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
|
37 | const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
|
38 | const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, module) => {
|
39 | const { index, name = 'dependency', dependencies, key, } = unknownDependencyContext;
|
40 | const moduleName = getModuleName(module) || 'Module';
|
41 | const dependencyName = getDependencyName(name);
|
42 | let message = `Nest can't resolve dependencies of the ${type.toString()}`;
|
43 | const potentialSolutions = `\n
|
44 | Potential solutions:
|
45 | - If ${dependencyName} is a provider, is it part of the current ${moduleName}?
|
46 | - If ${dependencyName} is exported from a separate @Module, is that module imported within ${moduleName}?
|
47 | @Module({
|
48 | imports: [ /* the Module containing ${dependencyName} */ ]
|
49 | })
|
50 | `;
|
51 | if (shared_utils_1.isNil(index)) {
|
52 | message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
53 | return message;
|
54 | }
|
55 | const dependenciesName = (dependencies || []).map(getDependencyName);
|
56 | dependenciesName[index] = '?';
|
57 | message += ` (`;
|
58 | message += dependenciesName.join(', ');
|
59 | message += `). Please make sure that the argument ${dependencyName} at index [${index}] is available in the ${getModuleName(module)} context.`;
|
60 | message += potentialSolutions;
|
61 | return message;
|
62 | };
|
63 | exports.UNKNOWN_DEPENDENCIES_MESSAGE = UNKNOWN_DEPENDENCIES_MESSAGE;
|
64 | const INVALID_MIDDLEWARE_MESSAGE = (text, name) => `The middleware doesn't provide the 'use' method (${name})`;
|
65 | exports.INVALID_MIDDLEWARE_MESSAGE = INVALID_MIDDLEWARE_MESSAGE;
|
66 | const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
|
67 |
|
68 | (Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
|
69 | Scope [${stringifyScope(scope)}]
|
70 | `;
|
71 | exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
|
72 | const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
|
73 | const parentModuleName = (parentModule === null || parentModule === void 0 ? void 0 : parentModule.name) || 'module';
|
74 | return `Nest cannot create the ${parentModuleName} instance.
|
75 | Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
|
76 |
|
77 | Scope [${stringifyScope(scope)}]`;
|
78 | };
|
79 | exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
|
80 | const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
|
81 | const parentModuleName = (parentModule === null || parentModule === void 0 ? void 0 : parentModule.name) || 'module';
|
82 | return `Nest cannot create the ${parentModuleName} instance.
|
83 | The module at index [${index}] of the ${parentModuleName} "imports" array is undefined.
|
84 |
|
85 | Potential causes:
|
86 | - A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
|
87 | - The module at index [${index}] is of type "undefined". Check your import statements and the type of the module.
|
88 |
|
89 | Scope [${stringifyScope(scope)}]`;
|
90 | };
|
91 | exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
|
92 | const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
|
93 | token = shared_utils_1.isSymbol(token) ? token.toString() : token;
|
94 | 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.
|
95 |
|
96 | Possible Solutions:
|
97 | - Is ${token} part of the relevant providers/imports within ${module}?
|
98 | `;
|
99 | };
|
100 | exports.UNKNOWN_EXPORT_MESSAGE = UNKNOWN_EXPORT_MESSAGE;
|
101 | const INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
|
102 | exports.INVALID_CLASS_MESSAGE = INVALID_CLASS_MESSAGE;
|
103 | const INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name || '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.`;
|
104 | exports.INVALID_CLASS_SCOPE_MESSAGE = INVALID_CLASS_SCOPE_MESSAGE;
|
105 | exports.INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
|
106 | exports.UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;
|
107 | exports.UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
|
108 | exports.INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
|
109 | exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;
|