🎯 MapView v2.0 - Global Deployment Ready

 MAJOR FEATURES:
• Auto-zoom intelligence với smart bounds fitting
• Enhanced 3D GPS markers với pulsing effects
• Professional route display với 6-layer rendering
• Status-based parking icons với availability indicators
• Production-ready build optimizations

🗺️ AUTO-ZOOM FEATURES:
• Smart bounds fitting cho GPS + selected parking
• Adaptive padding (50px) cho visual balance
• Max zoom control (level 16) để tránh quá gần
• Dynamic centering khi không có selection

🎨 ENHANCED VISUALS:
• 3D GPS marker với multi-layer pulse effects
• Advanced parking icons với status colors
• Selection highlighting với animation
• Dimming system cho non-selected items

🛣️ ROUTE SYSTEM:
• OpenRouteService API integration
• Multi-layer route rendering (glow, shadow, main, animated)
• Real-time distance & duration calculation
• Visual route info trong popup

📱 PRODUCTION READY:
• SSR safe với dynamic imports
• Build errors resolved
• Global deployment via Vercel
• Optimized performance

🌍 DEPLOYMENT:
• Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
• Bundle size: 22.8 kB optimized
• Global CDN distribution
• HTTPS enabled

💾 VERSION CONTROL:
• MapView-v2.0.tsx backup created
• MAPVIEW_VERSIONS.md documentation
• Full version history tracking
This commit is contained in:
2025-07-20 19:52:16 +07:00
parent 3203463a6a
commit c65cc97a33
64624 changed files with 7199453 additions and 6462 deletions

22
backend/node_modules/@nestjs/core/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2017-2024 Kamil Mysliwiec <https://kamilmysliwiec.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
backend/node_modules/@nestjs/core/PACKAGE.md generated vendored Normal file
View File

@@ -0,0 +1 @@
Implements Nest's core functionality, low-level services, and utilities.

151
backend/node_modules/@nestjs/core/Readme.md generated vendored Normal file
View File

@@ -0,0 +1,151 @@
<p align="center">
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="https://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
Nest is a framework for building efficient, scalable <a href="https://nodejs.org" target="_blank">Node.js</a> server-side applications. It uses modern JavaScript, is built with <a href="https://www.typescriptlang.org" target="_blank">TypeScript</a> (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, but also provides compatibility with a wide range of other libraries, like <a href="https://github.com/fastify/fastify" target="_blank">Fastify</a>, allowing for easy use of the myriad of third-party plugins which are available.</p>
## Philosophy
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a>, and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a>, which improve developer productivity and enable the construction of fast, testable, and extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers, and tools for Node, none of them effectively solve the main problem - the architecture.</p>
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, and loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
## Getting started
- To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
- 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
- [가이드](readme_kr.md) 문서는 [docs.nestjs.com](https://docs.nestjs.com)에서 확인하실 수 있습니다. :books:
- [ガイド](readme_jp.md)は [docs.nestjs.com](https://docs.nestjs.com)でご確認ください。 :books:
## Questions
For questions and support please use the official [Discord channel](https://discord.gg/G7Qnnhy). The issue list of this repo is **exclusively** for bug reports and feature requests.
## Issues
Please make sure to read the [Issue Reporting Checklist](https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md#-submitting-an-issue) before opening an issue. Issues not conforming to the guidelines may be closed immediately.
## Consulting
With official support, you can get expert help straight from Nest core team. We provide dedicated technical support, migration strategies, advice on best practices (and design decisions), PR reviews, and team augmentation. Read more about [support here](https://enterprise.nestjs.com).
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
#### Principal Sponsors
<table style="text-align:center;">
<tr>
<td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
<td><a href="https://microsoft.com/" target="_blank"><img src="https://nestjs.com/img/logos/microsoft-logo.png" width="180" valign="middle" /></a></td>
<td><a href="https://mojam.co" target="_blank"><img src="https://nestjs.com/img/logos/mojam-logo.png" width="80" valign="middle" /></a></td>
<td><a href="https://marblism.com?utm_source=nest" target="_blank"><img src="https://nestjs.com/img/logos/marblism-logo.png" width="180" valign="middle" /></a></td>
<td><a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
<td><a href="https://amplication.com/" target="_blank"><img src="https://nestjs.com/img/logos/amplication-logo.svg" width="190" valign="middle" /></a></td>
</tr>
</table>
#### Gold Sponsors
<table style="text-align:center;">
<tr>
<td><a href="https://www.redhat.com" target="_blank"><img src="https://nestjs.com/img/logos/red-hat-logo.svg" width="200" valign="middle" /></a></td>
<td><a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
<td><a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/logos/nx-logo.png" height="45" valign="middle" /></a></td>
<td><a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/logos/intrinisic-logo.png" width="210" valign="middle" /></a></td>
<td><a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/logos/jetbrains-logo.svg" width="90" valign="middle" /></a></td>
</tr>
<tr>
<td><a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/logos/snyk-logo-black.png" width="185" valign="middle" /></a></td>
<td><a href="https://fuseautotech.com/" target="_blank"><img src="https://nestjs.com/img/logos/fuse-logo.svg" width="105" valign="middle" /></a></td>
<td><a href="https://ridicorp.com/career/" target="_blank"><img src="https://nestjs.com/img/logos/ridi-logo.svg" width="105" valign="middle" /></a></td>
<td><a href="https://www.movavi.com/imovie-for-windows.html" target="_blank"><img src="https://nestjs.com/img/logos/movavi-logo.svg" width="105" valign="middle" /></a></td>
<td><a href="https://skunk.team" target="_blank"><img src="https://nestjs.com/img/logos/skunk-logo.png" height="60" valign="middle" /></a></td>
</tr>
</table>
#### Silver Sponsors
<table style="text-align:center;">
<tr>
<td><a href="https://www.mercedes-benz.com/" target="_blank"><img src="https://nestjs.com/img/logos/mercedes-logo.png" width="100" valign="middle" /></a></td>
<td><a href="https://www.dinii.jp/" target="_blank"><img src="https://nestjs.com/img/logos/dinii-logo.png" width="65" valign="middle" /></a></td>
<td><a href="https://bloodycase.com/?promocode=NEST" target="_blank"><img src="https://nestjs.com/img/logos/bloodycase-logo.png" width="65" valign="middle" /></a></td>
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/logos/handsontable-dark-logo.svg#2" width="150" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.itflashcards.com/" target="_blank"><img src="https://nestjs.com/img/logos/it_flashcards-logo.png" width="170" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://arcjet.com/?ref=nestjs" target="_blank"><img src="https://nestjs.com/img/logos/arcjet-logo.svg" width="170" valign="middle" /></a></td>
</tr>
</table>
#### Sponsors
<table>
<tr>
<td align="center" valign="middle"><a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/logos/swingdev-logo.svg#1" width="110" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/logos/novologic.png" width="110" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/logos/mantro-logo.svg" width="95" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/logos/triplebyte.png" width="107" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://nearpod.com/" target="_blank"><img src="https://nestjs.com/img/logos/nearpod-logo.svg" width="100" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/logos/genuinebee.svg" width="97" valign="middle" /></a></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/logos/vpn-review-logo.png" width="85" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/logos/lambda-it-logo.svg" width="115" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://rocketech.it/cases/?utm_source=google&utm_medium=badge&utm_campaign=nestjs" target="_blank"><img src="https://nestjs.com/img/logos/rocketech-logo.svg" width="110" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.anonymistic.com/" target="_blank"><img src="https://nestjs.com/img/logos/anonymistic-logo.png" width="125" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.naologic.com/" target="_blank"><img src="https://nestjs.com/img/logos/naologic-logo.svg" width="125" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://triplecore.io" target="_blank"><img src="https://nestjs.com/img/logos/triplecore-logo.svg" width="50" valign="middle" /></a></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/logos/casinowizard-logo.png" width="120" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/logos/polygon-logo.svg" width="120" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/logos/boringowl-logo.svg" width="120" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/logos/nordbot-logo.png" width="120" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://doppio.sh/" target="_blank"><img src="https://nestjs.com/img/logos/dopiosh-logo.png" width="50" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.hingehealth.com/" target="_blank"><img src="https://nestjs.com/img/logos/hinge-health-logo.svg" width="100" valign="middle" /></a></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="https://julienferand.dev/" target="_blank"><img src="https://nestjs.com/img/logos/julienferand-logo.jpeg" width="55" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.tripoffice.com/" target="_blank"><img src="https://nestjs.com/img/logos/tripoffice-logo.png" width="140" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://solcellsforetag.se/" target="_blank"><img src="https://nestjs.com/img/logos/solcellsforetag-logo.svg" width="140" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.route4me.com/" target="_blank"><img src="https://nestjs.com/img/logos/route4me-logo.svg" width="100" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.slotsup.com/" target="_blank"><img src="https://nestjs.com/img/logos/slotsup-logo.png" width="60" valign="middle" /></a></td>
</tr>
</table>
## Backers
<a href="https://opencollective.com/nest" target="_blank"><img src="https://opencollective.com/nest/backers.svg?width=1000"></a>
## Stay in touch
- Author - [Kamil Myśliwiec](https://x.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- X - [@nestframework](https://x.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

View File

@@ -0,0 +1,61 @@
import { HttpServer, RequestMethod, VersioningOptions } from '@nestjs/common';
import { RequestHandler, VersionValue } from '@nestjs/common/interfaces';
import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
/**
* @publicApi
*/
export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any, TResponse = any> implements HttpServer<TRequest, TResponse> {
protected instance?: any;
protected httpServer: TServer;
constructor(instance?: any);
init(): Promise<void>;
use(...args: any[]): any;
get(handler: RequestHandler): any;
get(path: any, handler: RequestHandler): any;
post(handler: RequestHandler): any;
post(path: any, handler: RequestHandler): any;
head(handler: RequestHandler): any;
head(path: any, handler: RequestHandler): any;
delete(handler: RequestHandler): any;
delete(path: any, handler: RequestHandler): any;
put(handler: RequestHandler): any;
put(path: any, handler: RequestHandler): any;
patch(handler: RequestHandler): any;
patch(path: any, handler: RequestHandler): any;
all(handler: RequestHandler): any;
all(path: any, handler: RequestHandler): any;
search(handler: RequestHandler): any;
search(path: any, handler: RequestHandler): any;
options(handler: RequestHandler): any;
options(path: any, handler: RequestHandler): any;
listen(port: string | number, callback?: () => void): any;
listen(port: string | number, hostname: string, callback?: () => void): any;
getHttpServer(): TServer;
setHttpServer(httpServer: TServer): void;
setInstance<T = any>(instance: T): void;
getInstance<T = any>(): T;
abstract close(): any;
abstract initHttpServer(options: NestApplicationOptions): any;
abstract useStaticAssets(...args: any[]): any;
abstract setViewEngine(engine: string): any;
abstract getRequestHostname(request: any): any;
abstract getRequestMethod(request: any): any;
abstract getRequestUrl(request: any): any;
abstract status(response: any, statusCode: number): any;
abstract reply(response: any, body: any, statusCode?: number): any;
abstract end(response: any, message?: string): any;
abstract render(response: any, view: string, options: any): any;
abstract redirect(response: any, statusCode: number, url: string): any;
abstract setErrorHandler(handler: Function, prefix?: string): any;
abstract setNotFoundHandler(handler: Function, prefix?: string): any;
abstract isHeadersSent(response: any): any;
abstract getHeader?(response: any, name: string): any;
abstract setHeader(response: any, name: string, value: string): any;
abstract appendHeader?(response: any, name: string, value: string): any;
abstract registerParserMiddleware(prefix?: string, rawBody?: boolean): any;
abstract enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>, prefix?: string): any;
abstract createMiddlewareFactory(requestMethod: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
abstract getType(): string;
abstract applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): (req: TRequest, res: TResponse, next: () => void) => Function;
}

View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractHttpAdapter = void 0;
/**
* @publicApi
*/
class AbstractHttpAdapter {
constructor(instance) {
this.instance = instance;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
async init() { }
use(...args) {
return this.instance.use(...args);
}
get(...args) {
return this.instance.get(...args);
}
post(...args) {
return this.instance.post(...args);
}
head(...args) {
return this.instance.head(...args);
}
delete(...args) {
return this.instance.delete(...args);
}
put(...args) {
return this.instance.put(...args);
}
patch(...args) {
return this.instance.patch(...args);
}
all(...args) {
return this.instance.all(...args);
}
search(...args) {
return this.instance.search(...args);
}
options(...args) {
return this.instance.options(...args);
}
listen(port, hostname, callback) {
return this.instance.listen(port, hostname, callback);
}
getHttpServer() {
return this.httpServer;
}
setHttpServer(httpServer) {
this.httpServer = httpServer;
}
setInstance(instance) {
this.instance = instance;
}
getInstance() {
return this.instance;
}
}
exports.AbstractHttpAdapter = AbstractHttpAdapter;

View File

@@ -0,0 +1 @@
export * from './http-adapter';

4
backend/node_modules/@nestjs/core/adapters/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./http-adapter"), exports);

View File

@@ -0,0 +1,47 @@
import { CanActivate, ExceptionFilter, NestInterceptor, PipeTransform, VersioningOptions, WebSocketAdapter } from '@nestjs/common';
import { GlobalPrefixOptions } from '@nestjs/common/interfaces';
import { InstanceWrapper } from './injector/instance-wrapper';
import { ExcludeRouteMetadata } from './router/interfaces/exclude-route-metadata.interface';
export declare class ApplicationConfig {
private ioAdapter;
private globalPrefix;
private globalPrefixOptions;
private globalPipes;
private globalFilters;
private globalInterceptors;
private globalGuards;
private versioningOptions;
private readonly globalRequestPipes;
private readonly globalRequestFilters;
private readonly globalRequestInterceptors;
private readonly globalRequestGuards;
constructor(ioAdapter?: WebSocketAdapter | null);
setGlobalPrefix(prefix: string): void;
getGlobalPrefix(): string;
setGlobalPrefixOptions(options: GlobalPrefixOptions<ExcludeRouteMetadata>): void;
getGlobalPrefixOptions(): GlobalPrefixOptions<ExcludeRouteMetadata>;
setIoAdapter(ioAdapter: WebSocketAdapter): void;
getIoAdapter(): WebSocketAdapter;
addGlobalPipe(pipe: PipeTransform<any>): void;
useGlobalPipes(...pipes: PipeTransform<any>[]): void;
getGlobalFilters(): ExceptionFilter[];
addGlobalFilter(filter: ExceptionFilter): void;
useGlobalFilters(...filters: ExceptionFilter[]): void;
getGlobalPipes(): PipeTransform<any>[];
getGlobalInterceptors(): NestInterceptor[];
addGlobalInterceptor(interceptor: NestInterceptor): void;
useGlobalInterceptors(...interceptors: NestInterceptor[]): void;
getGlobalGuards(): CanActivate[];
addGlobalGuard(guard: CanActivate): void;
useGlobalGuards(...guards: CanActivate[]): void;
addGlobalRequestInterceptor(wrapper: InstanceWrapper<NestInterceptor>): void;
getGlobalRequestInterceptors(): InstanceWrapper<NestInterceptor>[];
addGlobalRequestPipe(wrapper: InstanceWrapper<PipeTransform>): void;
getGlobalRequestPipes(): InstanceWrapper<PipeTransform>[];
addGlobalRequestFilter(wrapper: InstanceWrapper<ExceptionFilter>): void;
getGlobalRequestFilters(): InstanceWrapper<ExceptionFilter>[];
addGlobalRequestGuard(wrapper: InstanceWrapper<CanActivate>): void;
getGlobalRequestGuards(): InstanceWrapper<CanActivate>[];
enableVersioning(options: VersioningOptions): void;
getVersioning(): VersioningOptions | undefined;
}

107
backend/node_modules/@nestjs/core/application-config.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationConfig = void 0;
class ApplicationConfig {
constructor(ioAdapter = null) {
this.ioAdapter = ioAdapter;
this.globalPrefix = '';
this.globalPrefixOptions = {};
this.globalPipes = [];
this.globalFilters = [];
this.globalInterceptors = [];
this.globalGuards = [];
this.globalRequestPipes = [];
this.globalRequestFilters = [];
this.globalRequestInterceptors = [];
this.globalRequestGuards = [];
}
setGlobalPrefix(prefix) {
this.globalPrefix = prefix;
}
getGlobalPrefix() {
return this.globalPrefix;
}
setGlobalPrefixOptions(options) {
this.globalPrefixOptions = options;
}
getGlobalPrefixOptions() {
return this.globalPrefixOptions;
}
setIoAdapter(ioAdapter) {
this.ioAdapter = ioAdapter;
}
getIoAdapter() {
return this.ioAdapter;
}
addGlobalPipe(pipe) {
this.globalPipes.push(pipe);
}
useGlobalPipes(...pipes) {
this.globalPipes = this.globalPipes.concat(pipes);
}
getGlobalFilters() {
return this.globalFilters;
}
addGlobalFilter(filter) {
this.globalFilters.push(filter);
}
useGlobalFilters(...filters) {
this.globalFilters = this.globalFilters.concat(filters);
}
getGlobalPipes() {
return this.globalPipes;
}
getGlobalInterceptors() {
return this.globalInterceptors;
}
addGlobalInterceptor(interceptor) {
this.globalInterceptors.push(interceptor);
}
useGlobalInterceptors(...interceptors) {
this.globalInterceptors = this.globalInterceptors.concat(interceptors);
}
getGlobalGuards() {
return this.globalGuards;
}
addGlobalGuard(guard) {
this.globalGuards.push(guard);
}
useGlobalGuards(...guards) {
this.globalGuards = this.globalGuards.concat(guards);
}
addGlobalRequestInterceptor(wrapper) {
this.globalRequestInterceptors.push(wrapper);
}
getGlobalRequestInterceptors() {
return this.globalRequestInterceptors;
}
addGlobalRequestPipe(wrapper) {
this.globalRequestPipes.push(wrapper);
}
getGlobalRequestPipes() {
return this.globalRequestPipes;
}
addGlobalRequestFilter(wrapper) {
this.globalRequestFilters.push(wrapper);
}
getGlobalRequestFilters() {
return this.globalRequestFilters;
}
addGlobalRequestGuard(wrapper) {
this.globalRequestGuards.push(wrapper);
}
getGlobalRequestGuards() {
return this.globalRequestGuards;
}
enableVersioning(options) {
if (Array.isArray(options.defaultVersion)) {
// Drop duplicated versions
options.defaultVersion = Array.from(new Set(options.defaultVersion));
}
this.versioningOptions = options;
}
getVersioning() {
return this.versioningOptions;
}
}
exports.ApplicationConfig = ApplicationConfig;

14
backend/node_modules/@nestjs/core/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { EnhancerSubtype } from '@nestjs/common/constants';
export declare const MESSAGES: {
APPLICATION_START: string;
APPLICATION_READY: string;
MICROSERVICE_READY: string;
UNKNOWN_EXCEPTION_MESSAGE: string;
ERROR_DURING_SHUTDOWN: string;
CALL_LISTEN_FIRST: string;
};
export declare const APP_INTERCEPTOR = "APP_INTERCEPTOR";
export declare const APP_PIPE = "APP_PIPE";
export declare const APP_GUARD = "APP_GUARD";
export declare const APP_FILTER = "APP_FILTER";
export declare const ENHANCER_TOKEN_TO_SUBTYPE_MAP: Record<typeof APP_GUARD | typeof APP_PIPE | typeof APP_FILTER | typeof APP_INTERCEPTOR, EnhancerSubtype>;

21
backend/node_modules/@nestjs/core/constants.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ENHANCER_TOKEN_TO_SUBTYPE_MAP = exports.APP_FILTER = exports.APP_GUARD = exports.APP_PIPE = exports.APP_INTERCEPTOR = exports.MESSAGES = void 0;
exports.MESSAGES = {
APPLICATION_START: `Starting Nest application...`,
APPLICATION_READY: `Nest application successfully started`,
MICROSERVICE_READY: `Nest microservice successfully started`,
UNKNOWN_EXCEPTION_MESSAGE: 'Internal server error',
ERROR_DURING_SHUTDOWN: 'Error happened during shutdown',
CALL_LISTEN_FIRST: 'app.listen() needs to be called before calling app.getUrl()',
};
exports.APP_INTERCEPTOR = 'APP_INTERCEPTOR';
exports.APP_PIPE = 'APP_PIPE';
exports.APP_GUARD = 'APP_GUARD';
exports.APP_FILTER = 'APP_FILTER';
exports.ENHANCER_TOKEN_TO_SUBTYPE_MAP = {
[exports.APP_GUARD]: 'guard',
[exports.APP_INTERCEPTOR]: 'interceptor',
[exports.APP_PIPE]: 'pipe',
[exports.APP_FILTER]: 'filter',
};

View File

@@ -0,0 +1,46 @@
import { Type } from '@nestjs/common';
import { InstanceWrapper } from '../injector/instance-wrapper';
import { ModulesContainer } from '../injector/modules-container';
export declare class DiscoverableMetaHostCollection {
/**
* A map of class references to metadata keys.
*/
static readonly metaHostLinks: Map<Function | Type<any>, string>;
/**
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
* The map is weakly referenced by the modules container (unique per application).
*/
private static readonly providersByMetaKey;
/**
* A map of metadata keys to instance wrappers (controllers) with the corresponding metadata key.
* The map is weakly referenced by the modules container (unique per application).
*/
private static readonly controllersByMetaKey;
/**
* Adds a link between a class reference and a metadata key.
* @param target The class reference.
* @param metadataKey The metadata key.
*/
static addClassMetaHostLink(target: Type | Function, metadataKey: string): void;
/**
* Inspects a provider instance wrapper and adds it to the collection of providers
* if it has a metadata key.
* @param hostContainerRef A reference to the modules container.
* @param instanceWrapper A provider instance wrapper.
* @returns void
*/
static inspectProvider(hostContainerRef: ModulesContainer, instanceWrapper: InstanceWrapper): void;
/**
* Inspects a controller instance wrapper and adds it to the collection of controllers
* if it has a metadata key.
* @param hostContainerRef A reference to the modules container.
* @param instanceWrapper A controller's instance wrapper.
* @returns void
*/
static inspectController(hostContainerRef: ModulesContainer, instanceWrapper: InstanceWrapper): void;
static insertByMetaKey(metaKey: string, instanceWrapper: InstanceWrapper, collection: Map<string, Set<InstanceWrapper>>): void;
static getProvidersByMetaKey(hostContainerRef: ModulesContainer, metaKey: string): Set<InstanceWrapper>;
static getControllersByMetaKey(hostContainerRef: ModulesContainer, metaKey: string): Set<InstanceWrapper>;
private static inspectInstanceWrapper;
private static getMetaKeyByInstanceWrapper;
}

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscoverableMetaHostCollection = void 0;
class DiscoverableMetaHostCollection {
/**
* Adds a link between a class reference and a metadata key.
* @param target The class reference.
* @param metadataKey The metadata key.
*/
static addClassMetaHostLink(target, metadataKey) {
this.metaHostLinks.set(target, metadataKey);
}
/**
* Inspects a provider instance wrapper and adds it to the collection of providers
* if it has a metadata key.
* @param hostContainerRef A reference to the modules container.
* @param instanceWrapper A provider instance wrapper.
* @returns void
*/
static inspectProvider(hostContainerRef, instanceWrapper) {
return this.inspectInstanceWrapper(hostContainerRef, instanceWrapper, this.providersByMetaKey);
}
/**
* Inspects a controller instance wrapper and adds it to the collection of controllers
* if it has a metadata key.
* @param hostContainerRef A reference to the modules container.
* @param instanceWrapper A controller's instance wrapper.
* @returns void
*/
static inspectController(hostContainerRef, instanceWrapper) {
return this.inspectInstanceWrapper(hostContainerRef, instanceWrapper, this.controllersByMetaKey);
}
static insertByMetaKey(metaKey, instanceWrapper, collection) {
if (collection.has(metaKey)) {
const wrappers = collection.get(metaKey);
wrappers.add(instanceWrapper);
}
else {
const wrappers = new Set();
wrappers.add(instanceWrapper);
collection.set(metaKey, wrappers);
}
}
static getProvidersByMetaKey(hostContainerRef, metaKey) {
const wrappersByMetaKey = this.providersByMetaKey.get(hostContainerRef);
return wrappersByMetaKey?.get(metaKey) ?? new Set();
}
static getControllersByMetaKey(hostContainerRef, metaKey) {
const wrappersByMetaKey = this.controllersByMetaKey.get(hostContainerRef);
return wrappersByMetaKey?.get(metaKey) ?? new Set();
}
static inspectInstanceWrapper(hostContainerRef, instanceWrapper, wrapperByMetaKeyMap) {
const metaKey = DiscoverableMetaHostCollection.getMetaKeyByInstanceWrapper(instanceWrapper);
if (!metaKey) {
return;
}
let collection;
if (wrapperByMetaKeyMap.has(hostContainerRef)) {
collection = wrapperByMetaKeyMap.get(hostContainerRef);
}
else {
collection = new Map();
wrapperByMetaKeyMap.set(hostContainerRef, collection);
}
this.insertByMetaKey(metaKey, instanceWrapper, collection);
}
static getMetaKeyByInstanceWrapper(instanceWrapper) {
return this.metaHostLinks.get(
// NOTE: Regarding the ternary statement below,
// - The condition `!wrapper.metatype` is needed because when we use `useValue`
// the value of `wrapper.metatype` will be `null`.
// - The condition `wrapper.inject` is needed here because when we use
// `useFactory`, the value of `wrapper.metatype` will be the supplied
// factory function.
// For both cases, we should use `wrapper.instance.constructor` instead
// of `wrapper.metatype` to resolve processor's class properly.
// But since calling `wrapper.instance` could degrade overall performance
// we must defer it as much we can.
instanceWrapper.metatype || instanceWrapper.inject
? (instanceWrapper.instance?.constructor ?? instanceWrapper.metatype)
: instanceWrapper.metatype);
}
}
exports.DiscoverableMetaHostCollection = DiscoverableMetaHostCollection;
/**
* A map of class references to metadata keys.
*/
DiscoverableMetaHostCollection.metaHostLinks = new Map();
/**
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
* The map is weakly referenced by the modules container (unique per application).
*/
DiscoverableMetaHostCollection.providersByMetaKey = new WeakMap();
/**
* A map of metadata keys to instance wrappers (controllers) with the corresponding metadata key.
* The map is weakly referenced by the modules container (unique per application).
*/
DiscoverableMetaHostCollection.controllersByMetaKey = new WeakMap();

View File

@@ -0,0 +1,5 @@
/**
* @publicApi
*/
export declare class DiscoveryModule {
}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscoveryModule = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs/common");
const metadata_scanner_1 = require("../metadata-scanner");
const discovery_service_1 = require("./discovery-service");
/**
* @publicApi
*/
let DiscoveryModule = class DiscoveryModule {
};
exports.DiscoveryModule = DiscoveryModule;
exports.DiscoveryModule = DiscoveryModule = tslib_1.__decorate([
(0, common_1.Module)({
providers: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
exports: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
})
], DiscoveryModule);

View File

@@ -0,0 +1,76 @@
import { CustomDecorator } from '@nestjs/common';
import { InstanceWrapper } from '../injector/instance-wrapper';
import { Module } from '../injector/module';
import { ModulesContainer } from '../injector/modules-container';
/**
* @publicApi
*/
export interface FilterByInclude {
/**
* List of modules to include (whitelist) into the discovery process.
*/
include?: Function[];
}
/**
* @publicApi
*/
export interface FilterByMetadataKey {
/**
* A key to filter controllers and providers by.
* Only instance wrappers with the specified metadata key will be returned.
*/
metadataKey?: string;
}
/**
* @publicApi
*/
export type DiscoveryOptions = FilterByInclude | FilterByMetadataKey;
/**
* @publicApi
*/
export type DiscoverableDecorator<T> = ((opts?: T) => CustomDecorator) & {
KEY: string;
};
/**
* @publicApi
*/
export declare class DiscoveryService {
private readonly modulesContainer;
constructor(modulesContainer: ModulesContainer);
/**
* Creates a decorator that can be used to decorate classes and methods with metadata.
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
* @returns A decorator function.
*/
static createDecorator<T>(): DiscoverableDecorator<T>;
/**
* Returns an array of instance wrappers (providers).
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
* @param options Discovery options.
* @param modules A list of modules to filter by.
* @returns An array of instance wrappers (providers).
*/
getProviders(options?: DiscoveryOptions, modules?: Module[]): InstanceWrapper[];
/**
* Returns an array of instance wrappers (controllers).
* Depending on the options, the array will contain either all controllers or only controllers with the specified metadata key.
* @param options Discovery options.
* @param modules A list of modules to filter by.
* @returns An array of instance wrappers (controllers).
*/
getControllers(options?: DiscoveryOptions, modules?: Module[]): InstanceWrapper[];
/**
* Retrieves metadata from the specified instance wrapper.
* @param decorator The decorator to retrieve metadata of.
* @param instanceWrapper Reference to the instance wrapper.
* @param methodKey An optional method key to retrieve metadata from.
* @returns Discovered metadata.
*/
getMetadataByDecorator<T extends DiscoverableDecorator<any>>(decorator: T, instanceWrapper: InstanceWrapper, methodKey?: string): T extends DiscoverableDecorator<infer R> ? R | undefined : T | undefined;
/**
* Returns a list of modules to be used for discovery.
*/
protected getModules(options?: DiscoveryOptions): Module[];
private includeWhitelisted;
}

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscoveryService = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs/common");
const uid_1 = require("uid");
const modules_container_1 = require("../injector/modules-container");
const discoverable_meta_host_collection_1 = require("./discoverable-meta-host-collection");
/**
* @publicApi
*/
let DiscoveryService = class DiscoveryService {
constructor(modulesContainer) {
this.modulesContainer = modulesContainer;
}
/**
* Creates a decorator that can be used to decorate classes and methods with metadata.
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
* @returns A decorator function.
*/
static createDecorator() {
const metadataKey = (0, uid_1.uid)(21);
const decoratorFn = (opts) => (target, key, descriptor) => {
if (!descriptor) {
discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.addClassMetaHostLink(target, metadataKey);
}
(0, common_1.SetMetadata)(metadataKey, opts ?? {})(target, key, descriptor);
};
decoratorFn.KEY = metadataKey;
return decoratorFn;
}
/**
* Returns an array of instance wrappers (providers).
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
* @param options Discovery options.
* @param modules A list of modules to filter by.
* @returns An array of instance wrappers (providers).
*/
getProviders(options = {}, modules = this.getModules(options)) {
if ('metadataKey' in options) {
const providers = discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.getProvidersByMetaKey(this.modulesContainer, options.metadataKey);
return Array.from(providers);
}
const providers = modules.map(item => [...item.providers.values()]);
return (0, common_1.flatten)(providers);
}
/**
* Returns an array of instance wrappers (controllers).
* Depending on the options, the array will contain either all controllers or only controllers with the specified metadata key.
* @param options Discovery options.
* @param modules A list of modules to filter by.
* @returns An array of instance wrappers (controllers).
*/
getControllers(options = {}, modules = this.getModules(options)) {
if ('metadataKey' in options) {
const controllers = discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.getControllersByMetaKey(this.modulesContainer, options.metadataKey);
return Array.from(controllers);
}
const controllers = modules.map(item => [...item.controllers.values()]);
return (0, common_1.flatten)(controllers);
}
/**
* Retrieves metadata from the specified instance wrapper.
* @param decorator The decorator to retrieve metadata of.
* @param instanceWrapper Reference to the instance wrapper.
* @param methodKey An optional method key to retrieve metadata from.
* @returns Discovered metadata.
*/
getMetadataByDecorator(decorator, instanceWrapper, methodKey) {
if (methodKey) {
return Reflect.getMetadata(decorator.KEY, instanceWrapper.instance[methodKey]);
}
const clsRef = instanceWrapper.instance?.constructor ?? instanceWrapper.metatype;
return Reflect.getMetadata(decorator.KEY, clsRef);
}
/**
* Returns a list of modules to be used for discovery.
*/
getModules(options = {}) {
const includeInOpts = 'include' in options;
if (!includeInOpts) {
const moduleRefs = [...this.modulesContainer.values()];
return moduleRefs;
}
const whitelisted = this.includeWhitelisted(options.include);
return whitelisted;
}
includeWhitelisted(include) {
const moduleRefs = [...this.modulesContainer.values()];
return moduleRefs.filter(({ metatype }) => include.some(item => item === metatype));
}
};
exports.DiscoveryService = DiscoveryService;
exports.DiscoveryService = DiscoveryService = tslib_1.__decorate([
(0, common_1.Injectable)(),
tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
], DiscoveryService);

View File

@@ -0,0 +1,2 @@
export * from './discovery-module';
export * from './discovery-service';

5
backend/node_modules/@nestjs/core/discovery/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./discovery-module"), exports);
tslib_1.__exportStar(require("./discovery-service"), exports);

View File

@@ -0,0 +1,5 @@
import { RuntimeException } from './exceptions/runtime.exception';
export declare class ExceptionHandler {
private static readonly logger;
handle(exception: RuntimeException | Error): void;
}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExceptionHandler = void 0;
const runtime_exception_1 = require("./exceptions/runtime.exception");
const logger_service_1 = require("@nestjs/common/services/logger.service");
class ExceptionHandler {
handle(exception) {
if (!(exception instanceof runtime_exception_1.RuntimeException)) {
ExceptionHandler.logger.error(exception.message, exception.stack);
return;
}
ExceptionHandler.logger.error(exception.what(), exception.stack);
}
}
exports.ExceptionHandler = ExceptionHandler;
ExceptionHandler.logger = new logger_service_1.Logger(ExceptionHandler.name);

View File

@@ -0,0 +1,5 @@
export declare class ExceptionsZone {
private static readonly exceptionHandler;
static run(callback: () => void, teardown: (err: any) => void, autoFlushLogs: boolean): void;
static asyncRun(callback: () => Promise<void>, teardown: (err: any) => void, autoFlushLogs: boolean): Promise<void>;
}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExceptionsZone = void 0;
const common_1 = require("@nestjs/common");
const exception_handler_1 = require("./exception-handler");
const DEFAULT_TEARDOWN = () => process.exit(1);
class ExceptionsZone {
static run(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
try {
callback();
}
catch (e) {
this.exceptionHandler.handle(e);
if (autoFlushLogs) {
common_1.Logger.flush();
}
teardown(e);
}
}
static async asyncRun(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
try {
await callback();
}
catch (e) {
this.exceptionHandler.handle(e);
if (autoFlushLogs) {
common_1.Logger.flush();
}
teardown(e);
}
}
}
exports.ExceptionsZone = ExceptionsZone;
ExceptionsZone.exceptionHandler = new exception_handler_1.ExceptionHandler();

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class CircularDependencyException extends RuntimeException {
constructor(context?: string);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CircularDependencyException = void 0;
const runtime_exception_1 = require("./runtime.exception");
class CircularDependencyException extends runtime_exception_1.RuntimeException {
constructor(context) {
const ctx = context ? ` inside ${context}` : ``;
super(`A circular dependency has been detected${ctx}. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.`);
}
}
exports.CircularDependencyException = CircularDependencyException;

View File

@@ -0,0 +1,8 @@
export * from './circular-dependency.exception';
export * from './runtime.exception';
export * from './unknown-element.exception';
export * from './invalid-class-scope.exception';
export * from './invalid-class.exception';
export * from './unknown-export.exception';
export * from './unknown-module.exception';
export * from './undefined-forwardref.exception';

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./circular-dependency.exception"), exports);
tslib_1.__exportStar(require("./runtime.exception"), exports);
tslib_1.__exportStar(require("./unknown-element.exception"), exports);
tslib_1.__exportStar(require("./invalid-class-scope.exception"), exports);
tslib_1.__exportStar(require("./invalid-class.exception"), exports);
tslib_1.__exportStar(require("./unknown-export.exception"), exports);
tslib_1.__exportStar(require("./unknown-module.exception"), exports);
tslib_1.__exportStar(require("./undefined-forwardref.exception"), exports);

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidClassModuleException extends RuntimeException {
constructor(metatypeUsedAsAModule: any, scope: any[]);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidClassModuleException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
constructor(metatypeUsedAsAModule, scope) {
super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope));
}
}
exports.InvalidClassModuleException = InvalidClassModuleException;

View File

@@ -0,0 +1,5 @@
import { Abstract, Type } from '@nestjs/common/interfaces';
import { RuntimeException } from './runtime.exception';
export declare class InvalidClassScopeException extends RuntimeException {
constructor(metatypeOrToken: Type<any> | Abstract<any> | string | symbol);
}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidClassScopeException = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class InvalidClassScopeException extends runtime_exception_1.RuntimeException {
constructor(metatypeOrToken) {
let name = (0, shared_utils_1.isFunction)(metatypeOrToken)
? metatypeOrToken.name
: metatypeOrToken;
name = name && name.toString();
super((0, messages_1.INVALID_CLASS_SCOPE_MESSAGE) `${name}`);
}
}
exports.InvalidClassScopeException = InvalidClassScopeException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidClassException extends RuntimeException {
constructor(value: any);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidClassException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class InvalidClassException extends runtime_exception_1.RuntimeException {
constructor(value) {
super((0, messages_1.INVALID_CLASS_MESSAGE) `${value}`);
}
}
exports.InvalidClassException = InvalidClassException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidExceptionFilterException extends RuntimeException {
constructor();
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidExceptionFilterException = void 0;
const runtime_exception_1 = require("./runtime.exception");
const messages_1 = require("../messages");
class InvalidExceptionFilterException extends runtime_exception_1.RuntimeException {
constructor() {
super(messages_1.INVALID_EXCEPTION_FILTER);
}
}
exports.InvalidExceptionFilterException = InvalidExceptionFilterException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidMiddlewareConfigurationException extends RuntimeException {
constructor();
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidMiddlewareConfigurationException = void 0;
const runtime_exception_1 = require("./runtime.exception");
const messages_1 = require("../messages");
class InvalidMiddlewareConfigurationException extends runtime_exception_1.RuntimeException {
constructor() {
super(messages_1.INVALID_MIDDLEWARE_CONFIGURATION);
}
}
exports.InvalidMiddlewareConfigurationException = InvalidMiddlewareConfigurationException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidMiddlewareException extends RuntimeException {
constructor(name: string);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidMiddlewareException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class InvalidMiddlewareException extends runtime_exception_1.RuntimeException {
constructor(name) {
super((0, messages_1.INVALID_MIDDLEWARE_MESSAGE) `${name}`);
}
}
exports.InvalidMiddlewareException = InvalidMiddlewareException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class InvalidModuleException extends RuntimeException {
constructor(parentModule: any, index: number, scope: any[]);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidModuleException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class InvalidModuleException extends runtime_exception_1.RuntimeException {
constructor(parentModule, index, scope) {
super((0, messages_1.INVALID_MODULE_MESSAGE)(parentModule, index, scope));
}
}
exports.InvalidModuleException = InvalidModuleException;

View File

@@ -0,0 +1,4 @@
export declare class RuntimeException extends Error {
constructor(message?: string);
what(): string;
}

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimeException = void 0;
class RuntimeException extends Error {
constructor(message = ``) {
super(message);
}
what() {
return this.message;
}
}
exports.RuntimeException = RuntimeException;

View File

@@ -0,0 +1,6 @@
import { InjectorDependencyContext } from '../../injector/injector';
import { RuntimeException } from './runtime.exception';
import { Module } from '../../injector/module';
export declare class UndefinedDependencyException extends RuntimeException {
constructor(type: string, undefinedDependencyContext: InjectorDependencyContext, module?: Module);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndefinedDependencyException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
constructor(type, undefinedDependencyContext, module) {
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, undefinedDependencyContext, module));
}
}
exports.UndefinedDependencyException = UndefinedDependencyException;

View File

@@ -0,0 +1,5 @@
import { RuntimeException } from './runtime.exception';
import { Type } from '@nestjs/common';
export declare class UndefinedForwardRefException extends RuntimeException {
constructor(scope: Type<any>[]);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndefinedForwardRefException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class UndefinedForwardRefException extends runtime_exception_1.RuntimeException {
constructor(scope) {
super((0, messages_1.UNDEFINED_FORWARDREF_MESSAGE)(scope));
}
}
exports.UndefinedForwardRefException = UndefinedForwardRefException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class UndefinedModuleException extends RuntimeException {
constructor(parentModule: any, index: number, scope: any[]);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndefinedModuleException = void 0;
const runtime_exception_1 = require("./runtime.exception");
const messages_1 = require("../messages");
class UndefinedModuleException extends runtime_exception_1.RuntimeException {
constructor(parentModule, index, scope) {
super((0, messages_1.UNDEFINED_MODULE_MESSAGE)(parentModule, index, scope));
}
}
exports.UndefinedModuleException = UndefinedModuleException;

View File

@@ -0,0 +1,16 @@
import { InjectorDependencyContext } from '../../injector/injector';
import { Module } from '../../injector/module';
import { RuntimeException } from './runtime.exception';
export declare class UnknownDependenciesException extends RuntimeException {
readonly type: string | symbol;
readonly context: InjectorDependencyContext;
readonly metadata?: {
id: string;
};
readonly moduleRef: {
id: string;
} | undefined;
constructor(type: string | symbol, context: InjectorDependencyContext, moduleRef?: Module, metadata?: {
id: string;
});
}

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownDependenciesException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class UnknownDependenciesException extends runtime_exception_1.RuntimeException {
constructor(type, context, moduleRef, metadata) {
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, context, moduleRef));
this.type = type;
this.context = context;
this.metadata = metadata;
this.moduleRef = moduleRef && { id: moduleRef.id };
}
}
exports.UnknownDependenciesException = UnknownDependenciesException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class UnknownElementException extends RuntimeException {
constructor(name?: string | symbol);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownElementException = void 0;
const runtime_exception_1 = require("./runtime.exception");
class UnknownElementException extends runtime_exception_1.RuntimeException {
constructor(name) {
name = name && name.toString();
super(`Nest could not find ${name || 'given'} element (this provider does not exist in the current context)`);
}
}
exports.UnknownElementException = UnknownElementException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class UnknownExportException extends RuntimeException {
constructor(token: string | symbol, moduleName: string);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownExportException = void 0;
const messages_1 = require("../messages");
const runtime_exception_1 = require("./runtime.exception");
class UnknownExportException extends runtime_exception_1.RuntimeException {
constructor(token, moduleName) {
super((0, messages_1.UNKNOWN_EXPORT_MESSAGE)(token, moduleName));
}
}
exports.UnknownExportException = UnknownExportException;

View File

@@ -0,0 +1,4 @@
import { RuntimeException } from './runtime.exception';
export declare class UnknownModuleException extends RuntimeException {
constructor(moduleName?: string);
}

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownModuleException = void 0;
const runtime_exception_1 = require("./runtime.exception");
class UnknownModuleException extends runtime_exception_1.RuntimeException {
constructor(moduleName) {
super(`Nest could not select the given module (${moduleName ? `"${moduleName}"` : 'it'} does not exist in current context).`);
}
}
exports.UnknownModuleException = UnknownModuleException;

View File

@@ -0,0 +1,5 @@
import type { Type } from '@nestjs/common';
import { RuntimeException } from './runtime.exception';
export declare class UnknownRequestMappingException extends RuntimeException {
constructor(metatype: Type);
}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownRequestMappingException = void 0;
const runtime_exception_1 = require("./runtime.exception");
const messages_1 = require("../messages");
class UnknownRequestMappingException extends runtime_exception_1.RuntimeException {
constructor(metatype) {
super((0, messages_1.UNKNOWN_REQUEST_MAPPING)(metatype));
}
}
exports.UnknownRequestMappingException = UnknownRequestMappingException;

17
backend/node_modules/@nestjs/core/errors/messages.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { ForwardReference, Type } from '@nestjs/common';
import { InjectorDependencyContext } from '../injector/injector';
import { Module } from '../injector/module';
export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, module: Module) => string;
export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol, module: string) => string;
export declare const INVALID_CLASS_MESSAGE: (text: TemplateStringsArray, value: any) => string;
export declare const INVALID_CLASS_SCOPE_MESSAGE: (text: TemplateStringsArray, name: string | undefined) => string;
export declare const UNKNOWN_REQUEST_MAPPING: (metatype: Type) => string;
export declare const INVALID_MIDDLEWARE_CONFIGURATION = "An invalid middleware configuration has been passed inside the module 'configure()' method.";
export declare const UNHANDLED_RUNTIME_EXCEPTION = "Unhandled Runtime Exception.";
export declare const INVALID_EXCEPTION_FILTER = "Invalid exception filters (@UseFilters()).";
export declare const MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = "Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)";

145
backend/node_modules/@nestjs/core/errors/messages.js generated vendored Normal file
View File

@@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
/**
* Returns the name of an instance or `undefined`
* @param instance The instance which should get the name from
*/
const getInstanceName = (instance) => {
if (instance?.forwardRef) {
return instance.forwardRef()?.name;
}
if (instance?.module) {
return instance.module?.name;
}
return instance?.name;
};
/**
* Returns the name of the dependency.
* Tries to get the class name, otherwise the string value
* (= injection token). As fallback to any falsy value for `dependency`, it
* returns `fallbackValue`
* @param dependency The name of the dependency to be displayed
* @param fallbackValue The fallback value if the dependency is falsy
* @param disambiguated Whether dependency's name is disambiguated with double quotes
*/
const getDependencyName = (dependency, fallbackValue, disambiguated = true) =>
// use class name
getInstanceName(dependency) ||
// use injection token (symbol)
((0, shared_utils_1.isSymbol)(dependency) && dependency.toString()) ||
// use string directly
(dependency
? disambiguated
? `"${dependency}"`
: dependency
: undefined) ||
// otherwise
fallbackValue;
/**
* Returns the name of the module
* Tries to get the class name. As fallback it returns 'current'.
* @param module The module which should get displayed
*/
const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, module) => {
const { index, name, dependencies, key } = unknownDependencyContext;
const moduleName = getModuleName(module);
const dependencyName = getDependencyName(name, 'dependency');
const potentialSolutions =
// If module's name is well defined
moduleName !== 'current'
? `\n
Potential solutions:
- Is ${moduleName} a valid NestJS module?
- If ${dependencyName} is a provider, is it part of the current ${moduleName}?
- If ${dependencyName} is exported from a separate @Module, is that module imported within ${moduleName}?
@Module({
imports: [ /* the Module containing ${dependencyName} */ ]
})
`
: `\n
Potential solutions:
- If ${dependencyName} is a provider, is it part of the current Module?
- If ${dependencyName} is exported from a separate @Module, is that module imported within Module?
@Module({
imports: [ /* the Module containing ${dependencyName} */ ]
})
`;
let message = `Nest can't resolve dependencies of the ${type.toString()}`;
if ((0, shared_utils_1.isNil)(index)) {
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
return message;
}
const dependenciesName = (dependencies || []).map(dependencyName => getDependencyName(dependencyName, '+', false));
dependenciesName[index] = '?';
message += ` (`;
message += dependenciesName.join(', ');
message += `). Please make sure that the argument ${dependencyName} at index [${index}] is available in the ${moduleName} context.`;
message += potentialSolutions;
return message;
};
exports.UNKNOWN_DEPENDENCIES_MESSAGE = UNKNOWN_DEPENDENCIES_MESSAGE;
const INVALID_MIDDLEWARE_MESSAGE = (text, name) => `The middleware doesn't provide the 'use' method (${name})`;
exports.INVALID_MIDDLEWARE_MESSAGE = INVALID_MIDDLEWARE_MESSAGE;
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.
(Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
Scope [${stringifyScope(scope)}]
`;
exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
const parentModuleName = parentModule?.name || 'module';
return `Nest cannot create the ${parentModuleName} instance.
Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
Scope [${stringifyScope(scope)}]`;
};
exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"` || 'that class';
return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
Scope [${stringifyScope(scope)}]
`;
};
exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = USING_INVALID_CLASS_AS_A_MODULE_MESSAGE;
const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
const parentModuleName = parentModule?.name || 'module';
return `Nest cannot create the ${parentModuleName} instance.
The module at index [${index}] of the ${parentModuleName} "imports" array is undefined.
Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
- The module at index [${index}] is of type "undefined". Check your import statements and the type of the module.
Scope [${stringifyScope(scope)}]`;
};
exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
token = (0, shared_utils_1.isSymbol)(token) ? token.toString() : token;
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.
Possible Solutions:
- Is ${token} part of the relevant providers/imports within ${module}?
`;
};
exports.UNKNOWN_EXPORT_MESSAGE = UNKNOWN_EXPORT_MESSAGE;
const INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
exports.INVALID_CLASS_MESSAGE = INVALID_CLASS_MESSAGE;
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.`;
exports.INVALID_CLASS_SCOPE_MESSAGE = INVALID_CLASS_SCOPE_MESSAGE;
const UNKNOWN_REQUEST_MAPPING = (metatype) => {
const className = metatype.name;
return className
? `An invalid controller has been detected. "${className}" does not have the @Controller() decorator but it is being listed in the "controllers" array of some module.`
: `An invalid controller has been detected. Perhaps, one of your controllers is missing the @Controller() decorator.`;
};
exports.UNKNOWN_REQUEST_MAPPING = UNKNOWN_REQUEST_MAPPING;
exports.INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
exports.UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
exports.INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;

View File

@@ -0,0 +1,14 @@
import { Type } from '@nestjs/common/interfaces';
import { ExceptionFilter } from '@nestjs/common/interfaces/exceptions/exception-filter.interface';
import { ContextCreator } from '../helpers/context-creator';
import { NestContainer } from '../injector/container';
import { InstanceWrapper } from '../injector/instance-wrapper';
export declare class BaseExceptionFilterContext extends ContextCreator {
private readonly container;
protected moduleContext: string;
constructor(container: NestContainer);
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
getFilterInstance(filter: Function | ExceptionFilter, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExceptionFilter | null;
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
reflectCatchExceptions(instance: ExceptionFilter): Type<any>[];
}

View File

@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseExceptionFilterContext = void 0;
const constants_1 = require("@nestjs/common/constants");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const iterare_1 = require("iterare");
const context_creator_1 = require("../helpers/context-creator");
const constants_2 = require("../injector/constants");
class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
constructor(container) {
super();
this.container = container;
}
createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
if ((0, shared_utils_1.isEmpty)(metadata)) {
return [];
}
return (0, iterare_1.iterate)(metadata)
.filter(instance => instance && ((0, shared_utils_1.isFunction)(instance.catch) || instance.name))
.map(filter => this.getFilterInstance(filter, contextId, inquirerId))
.filter(item => !!item)
.map(instance => ({
func: instance.catch.bind(instance),
exceptionMetatypes: this.reflectCatchExceptions(instance),
}))
.toArray();
}
getFilterInstance(filter, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
const isObject = filter.catch;
if (isObject) {
return filter;
}
const instanceWrapper = this.getInstanceByMetatype(filter);
if (!instanceWrapper) {
return null;
}
const instanceHost = instanceWrapper.getInstanceByContextId(this.getContextId(contextId, instanceWrapper), inquirerId);
return instanceHost && instanceHost.instance;
}
getInstanceByMetatype(metatype) {
if (!this.moduleContext) {
return;
}
const collection = this.container.getModules();
const moduleRef = collection.get(this.moduleContext);
if (!moduleRef) {
return;
}
return moduleRef.injectables.get(metatype);
}
reflectCatchExceptions(instance) {
const prototype = Object.getPrototypeOf(instance);
return (Reflect.getMetadata(constants_1.FILTER_CATCH_EXCEPTIONS, prototype.constructor) || []);
}
}
exports.BaseExceptionFilterContext = BaseExceptionFilterContext;

View File

@@ -0,0 +1,20 @@
import { ArgumentsHost, ExceptionFilter, HttpServer } from '@nestjs/common';
import { AbstractHttpAdapter } from '../adapters';
import { HttpAdapterHost } from '../helpers/http-adapter-host';
export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
protected readonly applicationRef?: HttpServer;
private static readonly logger;
protected readonly httpAdapterHost?: HttpAdapterHost;
constructor(applicationRef?: HttpServer);
catch(exception: T, host: ArgumentsHost): void;
handleUnknownError(exception: T, host: ArgumentsHost, applicationRef: AbstractHttpAdapter | HttpServer): void;
isExceptionObject(err: any): err is Error;
/**
* Checks if the thrown error comes from the "http-errors" library.
* @param err error object
*/
isHttpError(err: any): err is {
statusCode: number;
message: string;
};
}

View File

@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseExceptionFilter = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs/common");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const constants_1 = require("../constants");
const http_adapter_host_1 = require("../helpers/http-adapter-host");
class BaseExceptionFilter {
constructor(applicationRef) {
this.applicationRef = applicationRef;
}
catch(exception, host) {
const applicationRef = this.applicationRef ||
(this.httpAdapterHost && this.httpAdapterHost.httpAdapter);
if (!(exception instanceof common_1.HttpException)) {
return this.handleUnknownError(exception, host, applicationRef);
}
const res = exception.getResponse();
const message = (0, shared_utils_1.isObject)(res)
? res
: {
statusCode: exception.getStatus(),
message: res,
};
const response = host.getArgByIndex(1);
if (!applicationRef.isHeadersSent(response)) {
applicationRef.reply(response, message, exception.getStatus());
}
else {
applicationRef.end(response);
}
}
handleUnknownError(exception, host, applicationRef) {
const body = this.isHttpError(exception)
? {
statusCode: exception.statusCode,
message: exception.message,
}
: {
statusCode: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
message: constants_1.MESSAGES.UNKNOWN_EXCEPTION_MESSAGE,
};
const response = host.getArgByIndex(1);
if (!applicationRef.isHeadersSent(response)) {
applicationRef.reply(response, body, body.statusCode);
}
else {
applicationRef.end(response);
}
if (this.isExceptionObject(exception)) {
return BaseExceptionFilter.logger.error(exception.message, exception.stack);
}
return BaseExceptionFilter.logger.error(exception);
}
isExceptionObject(err) {
return (0, shared_utils_1.isObject)(err) && !!err.message;
}
/**
* Checks if the thrown error comes from the "http-errors" library.
* @param err error object
*/
isHttpError(err) {
return err?.statusCode && err?.message;
}
}
exports.BaseExceptionFilter = BaseExceptionFilter;
BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
tslib_1.__decorate([
(0, common_1.Optional)(),
(0, common_1.Inject)(),
tslib_1.__metadata("design:type", http_adapter_host_1.HttpAdapterHost)
], BaseExceptionFilter.prototype, "httpAdapterHost", void 0);

View File

@@ -0,0 +1,10 @@
import { HttpException } from '@nestjs/common';
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/exception-filter-metadata.interface';
import { BaseExceptionFilter } from './base-exception-filter';
export declare class ExceptionsHandler extends BaseExceptionFilter {
private filters;
next(exception: Error | HttpException | any, ctx: ArgumentsHost): void;
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
invokeCustomFilters<T = any>(exception: T, ctx: ArgumentsHost): boolean;
}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExceptionsHandler = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
const base_exception_filter_1 = require("./base-exception-filter");
const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
constructor() {
super(...arguments);
this.filters = [];
}
next(exception, ctx) {
if (this.invokeCustomFilters(exception, ctx)) {
return;
}
super.catch(exception, ctx);
}
setCustomFilters(filters) {
if (!Array.isArray(filters)) {
throw new invalid_exception_filter_exception_1.InvalidExceptionFilterException();
}
this.filters = filters;
}
invokeCustomFilters(exception, ctx) {
if ((0, shared_utils_1.isEmpty)(this.filters)) {
return false;
}
const filter = (0, select_exception_filter_metadata_util_1.selectExceptionFilterMetadata)(this.filters, exception);
filter && filter.func(exception, ctx);
return !!filter;
}
}
exports.ExceptionsHandler = ExceptionsHandler;

View File

@@ -0,0 +1,12 @@
import { Controller } from '@nestjs/common/interfaces';
import { ApplicationConfig } from '../application-config';
import { NestContainer } from '../injector/container';
import { RouterProxyCallback } from '../router/router-proxy';
import { BaseExceptionFilterContext } from './base-exception-filter-context';
import { ExternalExceptionsHandler } from './external-exceptions-handler';
export declare class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
private readonly config?;
constructor(container: NestContainer, config?: ApplicationConfig);
create(instance: Controller, callback: RouterProxyCallback, module: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExternalExceptionsHandler;
getGlobalMetadata<T extends any[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExternalExceptionFilterContext = void 0;
const constants_1 = require("@nestjs/common/constants");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const constants_2 = require("../injector/constants");
const base_exception_filter_context_1 = require("./base-exception-filter-context");
const external_exceptions_handler_1 = require("./external-exceptions-handler");
const iterare_1 = require("iterare");
class ExternalExceptionFilterContext extends base_exception_filter_context_1.BaseExceptionFilterContext {
constructor(container, config) {
super(container);
this.config = config;
}
create(instance, callback, module, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
this.moduleContext = module;
const exceptionHandler = new external_exceptions_handler_1.ExternalExceptionsHandler();
const filters = this.createContext(instance, callback, constants_1.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
if ((0, shared_utils_1.isEmpty)(filters)) {
return exceptionHandler;
}
exceptionHandler.setCustomFilters(filters.reverse());
return exceptionHandler;
}
getGlobalMetadata(contextId = constants_2.STATIC_CONTEXT, inquirerId) {
if (!this.config) {
return [];
}
const globalFilters = this.config.getGlobalFilters();
if (contextId === constants_2.STATIC_CONTEXT && !inquirerId) {
return globalFilters;
}
const scopedFilterWrappers = this.config.getGlobalRequestFilters();
const scopedFilters = (0, iterare_1.iterate)(scopedFilterWrappers)
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
.filter(host => !!host)
.map(host => host.instance)
.toArray();
return globalFilters.concat(scopedFilters);
}
}
exports.ExternalExceptionFilterContext = ExternalExceptionFilterContext;

View File

@@ -0,0 +1,5 @@
import { ArgumentsHost } from '@nestjs/common';
export declare class ExternalExceptionFilter<T = any, R = any> {
private static readonly logger;
catch(exception: T, host: ArgumentsHost): R | Promise<R>;
}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExternalExceptionFilter = void 0;
const common_1 = require("@nestjs/common");
class ExternalExceptionFilter {
catch(exception, host) {
if (exception instanceof Error && !(exception instanceof common_1.HttpException)) {
ExternalExceptionFilter.logger.error(exception.message, exception.stack);
}
throw exception;
}
}
exports.ExternalExceptionFilter = ExternalExceptionFilter;
ExternalExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');

View File

@@ -0,0 +1,9 @@
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions';
import { ExternalExceptionFilter } from './external-exception-filter';
export declare class ExternalExceptionsHandler extends ExternalExceptionFilter {
private filters;
next(exception: Error | any, host: ArgumentsHost): Promise<any>;
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
invokeCustomFilters<T = any>(exception: T, host: ArgumentsHost): Promise<any> | null;
}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExternalExceptionsHandler = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
const external_exception_filter_1 = require("./external-exception-filter");
const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
class ExternalExceptionsHandler extends external_exception_filter_1.ExternalExceptionFilter {
constructor() {
super(...arguments);
this.filters = [];
}
next(exception, host) {
const result = this.invokeCustomFilters(exception, host);
if (result) {
return result;
}
return super.catch(exception, host);
}
setCustomFilters(filters) {
if (!Array.isArray(filters)) {
throw new invalid_exception_filter_exception_1.InvalidExceptionFilterException();
}
this.filters = filters;
}
invokeCustomFilters(exception, host) {
if ((0, shared_utils_1.isEmpty)(this.filters)) {
return null;
}
const filter = (0, select_exception_filter_metadata_util_1.selectExceptionFilterMetadata)(this.filters, exception);
return filter ? filter.func(exception, host) : null;
}
}
exports.ExternalExceptionsHandler = ExternalExceptionsHandler;

View File

@@ -0,0 +1 @@
export * from './base-exception-filter';

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./base-exception-filter"), exports);

View File

@@ -0,0 +1 @@
export declare const FORBIDDEN_MESSAGE = "Forbidden resource";

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FORBIDDEN_MESSAGE = void 0;
exports.FORBIDDEN_MESSAGE = 'Forbidden resource';

View File

@@ -0,0 +1,9 @@
import { CanActivate } from '@nestjs/common';
import { ContextType, Controller } from '@nestjs/common/interfaces';
import { Observable } from 'rxjs';
import { ExecutionContextHost } from '../helpers/execution-context-host';
export declare class GuardsConsumer {
tryActivate<TContext extends string = ContextType>(guards: CanActivate[], args: unknown[], instance: Controller, callback: (...args: unknown[]) => unknown, type?: TContext): Promise<boolean>;
createContext(args: unknown[], instance: Controller, callback: (...args: unknown[]) => unknown): ExecutionContextHost;
pickResult(result: boolean | Promise<boolean> | Observable<boolean>): Promise<boolean>;
}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GuardsConsumer = void 0;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const rxjs_1 = require("rxjs");
const execution_context_host_1 = require("../helpers/execution-context-host");
class GuardsConsumer {
async tryActivate(guards, args, instance, callback, type) {
if (!guards || (0, shared_utils_1.isEmpty)(guards)) {
return true;
}
const context = this.createContext(args, instance, callback);
context.setType(type);
for (const guard of guards) {
const result = guard.canActivate(context);
if (await this.pickResult(result)) {
continue;
}
return false;
}
return true;
}
createContext(args, instance, callback) {
return new execution_context_host_1.ExecutionContextHost(args, instance.constructor, callback);
}
async pickResult(result) {
if (result instanceof rxjs_1.Observable) {
return (0, rxjs_1.lastValueFrom)(result);
}
return result;
}
}
exports.GuardsConsumer = GuardsConsumer;

View File

@@ -0,0 +1,17 @@
import { CanActivate } from '@nestjs/common';
import { Controller, Type } from '@nestjs/common/interfaces';
import { ApplicationConfig } from '../application-config';
import { ContextCreator } from '../helpers/context-creator';
import { NestContainer } from '../injector/container';
import { InstanceWrapper } from '../injector/instance-wrapper';
export declare class GuardsContextCreator extends ContextCreator {
private readonly container;
private readonly config?;
private moduleContext;
constructor(container: NestContainer, config?: ApplicationConfig);
create(instance: Controller, callback: (...args: unknown[]) => unknown, module: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): CanActivate[];
createConcreteContext<T extends unknown[], R extends unknown[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
getGuardInstance(metatype: Function | CanActivate, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): CanActivate | null;
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
getGlobalMetadata<T extends unknown[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
}

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GuardsContextCreator = void 0;
const constants_1 = require("@nestjs/common/constants");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const iterare_1 = require("iterare");
const context_creator_1 = require("../helpers/context-creator");
const constants_2 = require("../injector/constants");
class GuardsContextCreator extends context_creator_1.ContextCreator {
constructor(container, config) {
super();
this.container = container;
this.config = config;
}
create(instance, callback, module, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
this.moduleContext = module;
return this.createContext(instance, callback, constants_1.GUARDS_METADATA, contextId, inquirerId);
}
createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
if ((0, shared_utils_1.isEmpty)(metadata)) {
return [];
}
return (0, iterare_1.iterate)(metadata)
.filter((guard) => guard && (guard.name || guard.canActivate))
.map(guard => this.getGuardInstance(guard, contextId, inquirerId))
.filter((guard) => guard && (0, shared_utils_1.isFunction)(guard.canActivate))
.toArray();
}
getGuardInstance(metatype, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
const isObject = metatype.canActivate;
if (isObject) {
return metatype;
}
const instanceWrapper = this.getInstanceByMetatype(metatype);
if (!instanceWrapper) {
return null;
}
const instanceHost = instanceWrapper.getInstanceByContextId(this.getContextId(contextId, instanceWrapper), inquirerId);
return instanceHost && instanceHost.instance;
}
getInstanceByMetatype(metatype) {
if (!this.moduleContext) {
return;
}
const collection = this.container.getModules();
const moduleRef = collection.get(this.moduleContext);
if (!moduleRef) {
return;
}
const injectables = moduleRef.injectables;
return injectables.get(metatype);
}
getGlobalMetadata(contextId = constants_2.STATIC_CONTEXT, inquirerId) {
if (!this.config) {
return [];
}
const globalGuards = this.config.getGlobalGuards();
if (contextId === constants_2.STATIC_CONTEXT && !inquirerId) {
return globalGuards;
}
const scopedGuardWrappers = this.config.getGlobalRequestGuards();
const scopedGuards = (0, iterare_1.iterate)(scopedGuardWrappers)
.map(wrapper => wrapper.getInstanceByContextId(this.getContextId(contextId, wrapper), inquirerId))
.filter(host => !!host)
.map(host => host.instance)
.toArray();
return globalGuards.concat(scopedGuards);
}
}
exports.GuardsContextCreator = GuardsContextCreator;

3
backend/node_modules/@nestjs/core/guards/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export * from './constants';
export * from './guards-consumer';
export * from './guards-context-creator';

6
backend/node_modules/@nestjs/core/guards/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./constants"), exports);
tslib_1.__exportStar(require("./guards-consumer"), exports);
tslib_1.__exportStar(require("./guards-context-creator"), exports);

View File

@@ -0,0 +1,10 @@
import { Controller } from '@nestjs/common/interfaces';
import { ContextId, InstanceWrapper } from '../injector/instance-wrapper';
export declare abstract class ContextCreator {
abstract createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: ContextId, inquirerId?: string): R;
getGlobalMetadata?<T extends any[]>(contextId?: ContextId, inquirerId?: string): T;
createContext<T extends unknown[] = any, R extends unknown[] = any>(instance: Controller, callback: (...args: any[]) => void, metadataKey: string, contextId?: ContextId, inquirerId?: string): R;
reflectClassMetadata<T>(instance: Controller, metadataKey: string): T;
reflectMethodMetadata<T>(callback: (...args: unknown[]) => unknown, metadataKey: string): T;
protected getContextId(contextId: ContextId, instanceWrapper: InstanceWrapper): ContextId;
}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextCreator = void 0;
const constants_1 = require("../injector/constants");
class ContextCreator {
createContext(instance, callback, metadataKey, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
const globalMetadata = this.getGlobalMetadata &&
this.getGlobalMetadata(contextId, inquirerId);
const classMetadata = this.reflectClassMetadata(instance, metadataKey);
const methodMetadata = this.reflectMethodMetadata(callback, metadataKey);
return [
...this.createConcreteContext(globalMetadata || [], contextId, inquirerId),
...this.createConcreteContext(classMetadata, contextId, inquirerId),
...this.createConcreteContext(methodMetadata, contextId, inquirerId),
];
}
reflectClassMetadata(instance, metadataKey) {
const prototype = Object.getPrototypeOf(instance);
return Reflect.getMetadata(metadataKey, prototype.constructor);
}
reflectMethodMetadata(callback, metadataKey) {
return Reflect.getMetadata(metadataKey, callback);
}
getContextId(contextId, instanceWrapper) {
return contextId.getParent
? contextId.getParent({
token: instanceWrapper.token,
isTreeDurable: instanceWrapper.isDependencyTreeDurable(),
})
: contextId;
}
}
exports.ContextCreator = ContextCreator;

View File

@@ -0,0 +1,41 @@
import { ContextId, HostComponentInfo } from '../injector/instance-wrapper';
export declare function createContextId(): ContextId;
export type ContextIdResolverFn = (info: HostComponentInfo) => ContextId;
export interface ContextIdResolver {
/**
* Payload associated with the custom context id
*/
payload: unknown;
/**
* A context id resolver function
*/
resolve: ContextIdResolverFn;
}
export interface ContextIdStrategy<T = any> {
/**
* Allows to attach a parent context id to the existing child context id.
* This lets you construct durable DI sub-trees that can be shared between contexts.
* @param contextId auto-generated child context id
* @param request request object
*/
attach(contextId: ContextId, request: T): ContextIdResolverFn | ContextIdResolver | undefined;
}
export declare class ContextIdFactory {
private static strategy?;
/**
* Generates a context identifier based on the request object.
*/
static create(): ContextId;
/**
* Generates a random identifier to track asynchronous execution context.
* @param request request object
*/
static getByRequest<T extends Record<any, any> = any>(request: T, propsToInspect?: string[]): ContextId;
/**
* Registers a custom context id strategy that lets you attach
* a parent context id to the existing context id object.
* @param strategy strategy instance
*/
static apply(strategy: ContextIdStrategy): void;
private static isContextIdResolverWithPayload;
}

View File

@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextIdFactory = void 0;
exports.createContextId = createContextId;
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const request_constants_1 = require("../router/request/request-constants");
function createContextId() {
/**
* We are generating random identifier to track asynchronous
* execution context. An identifier does not have to be neither unique
* nor unpredictable because WeakMap uses objects as keys (reference comparison).
* Thus, even though identifier number might be equal, WeakMap would properly
* associate asynchronous context with its internal map values using object reference.
* Object is automatically removed once request has been processed (closure).
*/
return { id: Math.random() };
}
class ContextIdFactory {
/**
* Generates a context identifier based on the request object.
*/
static create() {
return createContextId();
}
/**
* Generates a random identifier to track asynchronous execution context.
* @param request request object
*/
static getByRequest(request, propsToInspect = ['raw']) {
if (!request) {
return ContextIdFactory.create();
}
if (request[request_constants_1.REQUEST_CONTEXT_ID]) {
return request[request_constants_1.REQUEST_CONTEXT_ID];
}
for (const key of propsToInspect) {
if (request[key]?.[request_constants_1.REQUEST_CONTEXT_ID]) {
return request[key][request_constants_1.REQUEST_CONTEXT_ID];
}
}
if (!this.strategy) {
return ContextIdFactory.create();
}
const contextId = createContextId();
const resolverObjectOrFunction = this.strategy.attach(contextId, request);
if (this.isContextIdResolverWithPayload(resolverObjectOrFunction)) {
contextId.getParent = resolverObjectOrFunction.resolve;
contextId.payload = resolverObjectOrFunction.payload;
}
else {
contextId.getParent = resolverObjectOrFunction;
}
return contextId;
}
/**
* Registers a custom context id strategy that lets you attach
* a parent context id to the existing context id object.
* @param strategy strategy instance
*/
static apply(strategy) {
this.strategy = strategy;
}
static isContextIdResolverWithPayload(resolverOrResolverFn) {
return (0, shared_utils_1.isObject)(resolverOrResolverFn);
}
}
exports.ContextIdFactory = ContextIdFactory;

View File

@@ -0,0 +1,23 @@
import { ParamData } from '@nestjs/common';
import { ContextType, Controller, PipeTransform } from '@nestjs/common/interfaces';
import { ExecutionContextHost } from './execution-context-host';
export interface ParamProperties<T = any, IExtractor extends Function = any> {
index: number;
type: T | string;
data: ParamData;
pipes: PipeTransform[];
extractValue: IExtractor;
}
export declare class ContextUtils {
mapParamType(key: string): string;
reflectCallbackParamtypes(instance: Controller, methodName: string): any[];
reflectCallbackMetadata<T = any>(instance: Controller, methodName: string, metadataKey: string): T;
reflectPassthrough(instance: Controller, methodName: string): boolean;
getArgumentsLength<T>(keys: string[], metadata: T): number;
createNullArray(length: number): any[];
mergeParamsMetatypes(paramsProperties: ParamProperties[], paramtypes: any[]): (ParamProperties & {
metatype?: any;
})[];
getCustomFactory(factory: (...args: unknown[]) => void, data: unknown, contextFactory: (args: unknown[]) => ExecutionContextHost): (...args: unknown[]) => unknown;
getContextFactory<TContext extends string = ContextType>(contextType: TContext, instance?: object, callback?: Function): (args: unknown[]) => ExecutionContextHost;
}

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextUtils = void 0;
const constants_1 = require("@nestjs/common/constants");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const execution_context_host_1 = require("./execution-context-host");
class ContextUtils {
mapParamType(key) {
const keyPair = key.split(':');
return keyPair[0];
}
reflectCallbackParamtypes(instance, methodName) {
return Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, instance, methodName);
}
reflectCallbackMetadata(instance, methodName, metadataKey) {
return Reflect.getMetadata(metadataKey, instance.constructor, methodName);
}
reflectPassthrough(instance, methodName) {
return Reflect.getMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, instance.constructor, methodName);
}
getArgumentsLength(keys, metadata) {
return keys.length
? Math.max(...keys.map(key => metadata[key].index)) + 1
: 0;
}
createNullArray(length) {
const a = new Array(length);
for (let i = 0; i < length; ++i)
a[i] = undefined;
return a;
}
mergeParamsMetatypes(paramsProperties, paramtypes) {
if (!paramtypes) {
return paramsProperties;
}
return paramsProperties.map(param => ({
...param,
metatype: paramtypes[param.index],
}));
}
getCustomFactory(factory, data, contextFactory) {
return (0, shared_utils_1.isFunction)(factory)
? (...args) => factory(data, contextFactory(args))
: () => null;
}
getContextFactory(contextType, instance, callback) {
const type = instance && instance.constructor;
return (args) => {
const ctx = new execution_context_host_1.ExecutionContextHost(args, type, callback);
ctx.setType(contextType);
return ctx;
};
}
}
exports.ContextUtils = ContextUtils;

View File

@@ -0,0 +1,19 @@
import { ExecutionContext } from '@nestjs/common';
import { Type } from '@nestjs/common/interfaces';
import { ContextType, HttpArgumentsHost, RpcArgumentsHost, WsArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
export declare class ExecutionContextHost implements ExecutionContext {
private readonly args;
private readonly constructorRef;
private readonly handler;
private contextType;
constructor(args: any[], constructorRef?: Type<any>, handler?: Function);
setType<TContext extends string = ContextType>(type: TContext): void;
getType<TContext extends string = ContextType>(): TContext;
getClass<T = any>(): Type<T>;
getHandler(): Function;
getArgs<T extends Array<any> = any[]>(): T;
getArgByIndex<T = any>(index: number): T;
switchToRpc(): RpcArgumentsHost;
switchToHttp(): HttpArgumentsHost;
switchToWs(): WsArgumentsHost;
}

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecutionContextHost = void 0;
class ExecutionContextHost {
constructor(args, constructorRef = null, handler = null) {
this.args = args;
this.constructorRef = constructorRef;
this.handler = handler;
this.contextType = 'http';
}
setType(type) {
type && (this.contextType = type);
}
getType() {
return this.contextType;
}
getClass() {
return this.constructorRef;
}
getHandler() {
return this.handler;
}
getArgs() {
return this.args;
}
getArgByIndex(index) {
return this.args[index];
}
switchToRpc() {
return Object.assign(this, {
getData: () => this.getArgByIndex(0),
getContext: () => this.getArgByIndex(1),
});
}
switchToHttp() {
return Object.assign(this, {
getRequest: () => this.getArgByIndex(0),
getResponse: () => this.getArgByIndex(1),
getNext: () => this.getArgByIndex(2),
});
}
switchToWs() {
return Object.assign(this, {
getClient: () => this.getArgByIndex(0),
getData: () => this.getArgByIndex(1),
getPattern: () => this.getArgByIndex(this.getArgs().length - 1),
});
}
}
exports.ExecutionContextHost = ExecutionContextHost;

View File

@@ -0,0 +1,51 @@
import { ParamData } from '@nestjs/common';
import { ContextType, Controller, PipeTransform } from '@nestjs/common/interfaces';
import { ExternalExceptionFilterContext } from '../exceptions/external-exception-filter-context';
import { GuardsConsumer, GuardsContextCreator } from '../guards';
import { NestContainer } from '../injector/container';
import { ContextId } from '../injector/instance-wrapper';
import { ModulesContainer } from '../injector/modules-container';
import { InterceptorsConsumer, InterceptorsContextCreator } from '../interceptors';
import { PipesConsumer, PipesContextCreator } from '../pipes';
import { ParamProperties } from './context-utils';
import { ExternalHandlerMetadata } from './interfaces/external-handler-metadata.interface';
import { ParamsMetadata } from './interfaces/params-metadata.interface';
export interface ParamsFactory {
exchangeKeyForValue(type: number, data: ParamData, args: any): any;
}
export interface ExternalContextOptions {
guards?: boolean;
interceptors?: boolean;
filters?: boolean;
}
export declare class ExternalContextCreator {
private readonly guardsContextCreator;
private readonly guardsConsumer;
private readonly interceptorsContextCreator;
private readonly interceptorsConsumer;
private readonly modulesContainer;
private readonly pipesContextCreator;
private readonly pipesConsumer;
private readonly filtersContextCreator;
private readonly contextUtils;
private readonly externalErrorProxy;
private readonly handlerMetadataStorage;
private container;
constructor(guardsContextCreator: GuardsContextCreator, guardsConsumer: GuardsConsumer, interceptorsContextCreator: InterceptorsContextCreator, interceptorsConsumer: InterceptorsConsumer, modulesContainer: ModulesContainer, pipesContextCreator: PipesContextCreator, pipesConsumer: PipesConsumer, filtersContextCreator: ExternalExceptionFilterContext);
static fromContainer(container: NestContainer): ExternalContextCreator;
create<TParamsMetadata extends ParamsMetadata = ParamsMetadata, TContext extends string = ContextType>(instance: Controller, callback: (...args: unknown[]) => unknown, methodName: string, metadataKey?: string, paramsFactory?: ParamsFactory, contextId?: ContextId, inquirerId?: string, options?: ExternalContextOptions, contextType?: TContext): (...args: any[]) => Promise<any>;
getMetadata<TMetadata, TContext extends string = ContextType>(instance: Controller, methodName: string, metadataKey?: string, paramsFactory?: ParamsFactory, contextType?: TContext): ExternalHandlerMetadata;
getContextModuleKey(moduleCtor: Function | undefined): string;
exchangeKeysForValues<TMetadata = any>(keys: string[], metadata: TMetadata, moduleContext: string, paramsFactory: ParamsFactory, contextId?: ContextId, inquirerId?: string, contextFactory?: (args: unknown[]) => import("./execution-context-host").ExecutionContextHost): ParamProperties[];
createPipesFn(pipes: PipeTransform[], paramsOptions: (ParamProperties & {
metatype?: unknown;
})[]): (args: unknown[], ...params: unknown[]) => Promise<void>;
getParamValue<T>(value: T, { metatype, type, data }: {
metatype: any;
type: any;
data: any;
}, pipes: PipeTransform[]): Promise<any>;
transformToResult(resultOrDeferred: any): Promise<any>;
createGuardsFn<TContext extends string = ContextType>(guards: any[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): Function | null;
registerRequestProvider<T = any>(request: T, contextId: ContextId): void;
}

View File

@@ -0,0 +1,166 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExternalContextCreator = void 0;
const common_1 = require("@nestjs/common");
const constants_1 = require("@nestjs/common/constants");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const rxjs_1 = require("rxjs");
const external_exception_filter_context_1 = require("../exceptions/external-exception-filter-context");
const constants_2 = require("../guards/constants");
const guards_1 = require("../guards");
const constants_3 = require("../injector/constants");
const interceptors_1 = require("../interceptors");
const pipes_1 = require("../pipes");
const context_utils_1 = require("./context-utils");
const external_proxy_1 = require("./external-proxy");
const handler_metadata_storage_1 = require("./handler-metadata-storage");
class ExternalContextCreator {
constructor(guardsContextCreator, guardsConsumer, interceptorsContextCreator, interceptorsConsumer, modulesContainer, pipesContextCreator, pipesConsumer, filtersContextCreator) {
this.guardsContextCreator = guardsContextCreator;
this.guardsConsumer = guardsConsumer;
this.interceptorsContextCreator = interceptorsContextCreator;
this.interceptorsConsumer = interceptorsConsumer;
this.modulesContainer = modulesContainer;
this.pipesContextCreator = pipesContextCreator;
this.pipesConsumer = pipesConsumer;
this.filtersContextCreator = filtersContextCreator;
this.contextUtils = new context_utils_1.ContextUtils();
this.externalErrorProxy = new external_proxy_1.ExternalErrorProxy();
this.handlerMetadataStorage = new handler_metadata_storage_1.HandlerMetadataStorage();
}
static fromContainer(container) {
const guardsContextCreator = new guards_1.GuardsContextCreator(container, container.applicationConfig);
const guardsConsumer = new guards_1.GuardsConsumer();
const interceptorsContextCreator = new interceptors_1.InterceptorsContextCreator(container, container.applicationConfig);
const interceptorsConsumer = new interceptors_1.InterceptorsConsumer();
const pipesContextCreator = new pipes_1.PipesContextCreator(container, container.applicationConfig);
const pipesConsumer = new pipes_1.PipesConsumer();
const filtersContextCreator = new external_exception_filter_context_1.ExternalExceptionFilterContext(container, container.applicationConfig);
const externalContextCreator = new ExternalContextCreator(guardsContextCreator, guardsConsumer, interceptorsContextCreator, interceptorsConsumer, container.getModules(), pipesContextCreator, pipesConsumer, filtersContextCreator);
externalContextCreator.container = container;
return externalContextCreator;
}
create(instance, callback, methodName, metadataKey, paramsFactory, contextId = constants_3.STATIC_CONTEXT, inquirerId, options = {
interceptors: true,
guards: true,
filters: true,
}, contextType = 'http') {
const module = this.getContextModuleKey(instance.constructor);
const { argsLength, paramtypes, getParamsMetadata } = this.getMetadata(instance, methodName, metadataKey, paramsFactory, contextType);
const pipes = this.pipesContextCreator.create(instance, callback, module, contextId, inquirerId);
const guards = this.guardsContextCreator.create(instance, callback, module, contextId, inquirerId);
const exceptionFilter = this.filtersContextCreator.create(instance, callback, module, contextId, inquirerId);
const interceptors = options.interceptors
? this.interceptorsContextCreator.create(instance, callback, module, contextId, inquirerId)
: [];
const paramsMetadata = getParamsMetadata(module, contextId, inquirerId);
const paramsOptions = paramsMetadata
? this.contextUtils.mergeParamsMetatypes(paramsMetadata, paramtypes)
: [];
const fnCanActivate = options.guards
? this.createGuardsFn(guards, instance, callback, contextType)
: null;
const fnApplyPipes = this.createPipesFn(pipes, paramsOptions);
const handler = (initialArgs, ...args) => async () => {
if (fnApplyPipes) {
await fnApplyPipes(initialArgs, ...args);
return callback.apply(instance, initialArgs);
}
return callback.apply(instance, args);
};
const target = async (...args) => {
const initialArgs = this.contextUtils.createNullArray(argsLength);
fnCanActivate && (await fnCanActivate(args));
const result = await this.interceptorsConsumer.intercept(interceptors, args, instance, callback, handler(initialArgs, ...args), contextType);
return this.transformToResult(result);
};
return options.filters
? this.externalErrorProxy.createProxy(target, exceptionFilter, contextType)
: target;
}
getMetadata(instance, methodName, metadataKey, paramsFactory, contextType) {
const cacheMetadata = this.handlerMetadataStorage.get(instance, methodName);
if (cacheMetadata) {
return cacheMetadata;
}
const metadata = this.contextUtils.reflectCallbackMetadata(instance, methodName, metadataKey || '') || {};
const keys = Object.keys(metadata);
const argsLength = this.contextUtils.getArgumentsLength(keys, metadata);
const paramtypes = this.contextUtils.reflectCallbackParamtypes(instance, methodName);
const contextFactory = this.contextUtils.getContextFactory(contextType, instance, instance[methodName]);
const getParamsMetadata = (moduleKey, contextId = constants_3.STATIC_CONTEXT, inquirerId) => paramsFactory
? this.exchangeKeysForValues(keys, metadata, moduleKey, paramsFactory, contextId, inquirerId, contextFactory)
: null;
const handlerMetadata = {
argsLength,
paramtypes,
getParamsMetadata,
};
this.handlerMetadataStorage.set(instance, methodName, handlerMetadata);
return handlerMetadata;
}
getContextModuleKey(moduleCtor) {
const emptyModuleKey = '';
if (!moduleCtor) {
return emptyModuleKey;
}
const moduleContainerEntries = this.modulesContainer.entries();
for (const [key, moduleRef] of moduleContainerEntries) {
if (moduleRef.hasProvider(moduleCtor)) {
return key;
}
}
return emptyModuleKey;
}
exchangeKeysForValues(keys, metadata, moduleContext, paramsFactory, contextId = constants_3.STATIC_CONTEXT, inquirerId, contextFactory = this.contextUtils.getContextFactory('http')) {
this.pipesContextCreator.setModuleContext(moduleContext);
return keys.map(key => {
const { index, data, pipes: pipesCollection } = metadata[key];
const pipes = this.pipesContextCreator.createConcreteContext(pipesCollection, contextId, inquirerId);
const type = this.contextUtils.mapParamType(key);
if (key.includes(constants_1.CUSTOM_ROUTE_ARGS_METADATA)) {
const { factory } = metadata[key];
const customExtractValue = this.contextUtils.getCustomFactory(factory, data, contextFactory);
return { index, extractValue: customExtractValue, type, data, pipes };
}
const numericType = Number(type);
const extractValue = (...args) => paramsFactory.exchangeKeyForValue(numericType, data, args);
return { index, extractValue, type: numericType, data, pipes };
});
}
createPipesFn(pipes, paramsOptions) {
const pipesFn = async (args, ...params) => {
const resolveParamValue = async (param) => {
const { index, extractValue, type, data, metatype, pipes: paramPipes, } = param;
const value = extractValue(...params);
args[index] = await this.getParamValue(value, { metatype, type, data }, pipes.concat(paramPipes));
};
await Promise.all(paramsOptions.map(resolveParamValue));
};
return paramsOptions.length ? pipesFn : null;
}
async getParamValue(value, { metatype, type, data }, pipes) {
return (0, shared_utils_1.isEmpty)(pipes)
? value
: this.pipesConsumer.apply(value, { metatype, type, data }, pipes);
}
async transformToResult(resultOrDeferred) {
if ((0, rxjs_1.isObservable)(resultOrDeferred)) {
return (0, rxjs_1.lastValueFrom)(resultOrDeferred);
}
return resultOrDeferred;
}
createGuardsFn(guards, instance, callback, contextType) {
const canActivateFn = async (args) => {
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback, contextType);
if (!canActivate) {
throw new common_1.ForbiddenException(constants_2.FORBIDDEN_MESSAGE);
}
};
return guards.length ? canActivateFn : null;
}
registerRequestProvider(request, contextId) {
this.container.registerRequestProvider(request, contextId);
}
}
exports.ExternalContextCreator = ExternalContextCreator;

View File

@@ -0,0 +1,5 @@
import { ContextType } from '@nestjs/common/interfaces';
import { ExternalExceptionsHandler } from '../exceptions/external-exceptions-handler';
export declare class ExternalErrorProxy {
createProxy<TContext extends string = ContextType>(targetCallback: (...args: any[]) => any, exceptionsHandler: ExternalExceptionsHandler, type?: TContext): (...args: any[]) => Promise<any>;
}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExternalErrorProxy = void 0;
const execution_context_host_1 = require("../helpers/execution-context-host");
class ExternalErrorProxy {
createProxy(targetCallback, exceptionsHandler, type) {
return async (...args) => {
try {
return await targetCallback(...args);
}
catch (e) {
const host = new execution_context_host_1.ExecutionContextHost(args);
host.setType(type);
return exceptionsHandler.next(e, host);
}
};
}
}
exports.ExternalErrorProxy = ExternalErrorProxy;

View File

@@ -0,0 +1,3 @@
import { Scope } from '@nestjs/common';
import { Type } from '@nestjs/common/interfaces/type.interface';
export declare function getClassScope(provider: Type<unknown>): Scope;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getClassScope = getClassScope;
const constants_1 = require("@nestjs/common/constants");
function getClassScope(provider) {
const metadata = Reflect.getMetadata(constants_1.SCOPE_OPTIONS_METADATA, provider);
return metadata && metadata.scope;
}

View File

@@ -0,0 +1,27 @@
import { Type } from '@nestjs/common/interfaces';
import { IncomingMessage } from 'http';
import { Observable } from 'rxjs';
import { ContextId } from '../injector/instance-wrapper';
import { HeaderStream } from '../router/sse-stream';
import { ParamProperties } from './context-utils';
export declare const HANDLER_METADATA_SYMBOL: unique symbol;
export type HandleResponseFn = HandlerResponseBasicFn | HandleSseResponseFn;
export type HandlerResponseBasicFn = <TResult, TResponse>(result: TResult, res: TResponse, req?: any) => any;
export type HandleSseResponseFn = <TResult extends Observable<unknown> = any, TResponse extends HeaderStream = any, TRequest extends IncomingMessage = any>(result: TResult, res: TResponse, req: TRequest) => any;
export interface HandlerMetadata {
argsLength: number;
paramtypes: any[];
httpStatusCode: number;
responseHeaders: any[];
hasCustomHeaders: boolean;
getParamsMetadata: (moduleKey: string, contextId?: ContextId, inquirerId?: string) => (ParamProperties & {
metatype?: any;
})[];
fnHandleResponse: HandleResponseFn;
}
export declare class HandlerMetadataStorage<TValue = HandlerMetadata, TKey extends Type<unknown> = any> {
private readonly [HANDLER_METADATA_SYMBOL];
set(controller: TKey, methodName: string, metadata: TValue): void;
get(controller: TKey, methodName: string): TValue | undefined;
private getMetadataKey;
}

View File

@@ -0,0 +1,26 @@
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HandlerMetadataStorage = exports.HANDLER_METADATA_SYMBOL = void 0;
const constants_1 = require("../injector/constants");
exports.HANDLER_METADATA_SYMBOL = Symbol.for('handler_metadata:cache');
class HandlerMetadataStorage {
constructor() {
this[_a] = new Map();
}
set(controller, methodName, metadata) {
const metadataKey = this.getMetadataKey(controller, methodName);
this[exports.HANDLER_METADATA_SYMBOL].set(metadataKey, metadata);
}
get(controller, methodName) {
const metadataKey = this.getMetadataKey(controller, methodName);
return this[exports.HANDLER_METADATA_SYMBOL].get(metadataKey);
}
getMetadataKey(controller, methodName) {
const ctor = controller.constructor;
const controllerKey = ctor && (ctor[constants_1.CONTROLLER_ID_KEY] || ctor.name);
return controllerKey + methodName;
}
}
exports.HandlerMetadataStorage = HandlerMetadataStorage;
_a = exports.HANDLER_METADATA_SYMBOL;

View File

@@ -0,0 +1,45 @@
import { Observable } from 'rxjs';
import { AbstractHttpAdapter } from '../adapters/http-adapter';
/**
* Defines the `HttpAdapterHost` object.
*
* `HttpAdapterHost` wraps the underlying
* platform-specific `HttpAdapter`. The `HttpAdapter` is a wrapper around the underlying
* native HTTP server library (e.g., Express). The `HttpAdapterHost` object
* provides methods to `get` and `set` the underlying HttpAdapter.
*
* @see [Http adapter](https://docs.nestjs.com/faq/http-adapter)
*
* @publicApi
*/
export declare class HttpAdapterHost<T extends AbstractHttpAdapter = AbstractHttpAdapter> {
private _httpAdapter?;
private _listen$;
private isListening;
/**
* Accessor for the underlying `HttpAdapter`
*
* @param httpAdapter reference to the `HttpAdapter` to be set
*/
set httpAdapter(httpAdapter: T);
/**
* Accessor for the underlying `HttpAdapter`
*
* @example
* `const httpAdapter = adapterHost.httpAdapter;`
*/
get httpAdapter(): T;
/**
* Observable that allows to subscribe to the `listen` event.
* This event is emitted when the HTTP application is listening for incoming requests.
*/
get listen$(): Observable<void>;
/**
* Sets the listening state of the application.
*/
set listening(listening: boolean);
/**
* Returns a boolean indicating whether the application is listening for incoming requests.
*/
get listening(): boolean;
}

Some files were not shown because too many files have changed in this diff Show More