Initial commit - Event Planner application

This commit is contained in:
mberlin
2026-03-18 14:55:56 -03:00
commit 86d779eb4d
7548 changed files with 1006324 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import type { Logger, LoggerNamespace, LogContext, LoggerOptions } from './Logger.js';
/** Default logger implementation with colored output, query formatting, and namespace-based filtering. */
export declare class DefaultLogger implements Logger {
private readonly options;
debugMode: boolean | LoggerNamespace[];
readonly writer: (message: string) => void;
private readonly usesReplicas?;
private readonly highlighter?;
constructor(options: LoggerOptions);
/**
* @inheritDoc
*/
log(namespace: LoggerNamespace, message: string, context?: LogContext): void;
/**
* @inheritDoc
*/
error(namespace: LoggerNamespace, message: string, context?: LogContext): void;
/**
* @inheritDoc
*/
warn(namespace: LoggerNamespace, message: string, context?: LogContext): void;
/**
* @inheritDoc
*/
setDebugMode(debugMode: boolean | LoggerNamespace[]): void;
/** Checks whether logging is enabled for the given namespace, considering context overrides. */
isEnabled(namespace: LoggerNamespace, context?: LogContext): boolean;
/**
* @inheritDoc
*/
logQuery(
context: {
query: string;
} & LogContext,
): void;
/** Factory method for creating a new DefaultLogger instance. */
static create(this: void, options: LoggerOptions): DefaultLogger;
}

98
node_modules/@mikro-orm/core/logging/DefaultLogger.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
import { colors } from './colors.js';
/** Default logger implementation with colored output, query formatting, and namespace-based filtering. */
export class DefaultLogger {
options;
debugMode;
writer;
usesReplicas;
highlighter;
constructor(options) {
this.options = options;
this.debugMode = this.options.debugMode ?? false;
this.writer = this.options.writer;
this.usesReplicas = this.options.usesReplicas;
this.highlighter = this.options.highlighter;
}
/**
* @inheritDoc
*/
log(namespace, message, context) {
if (!this.isEnabled(namespace, context)) {
return;
}
// clean up the whitespace
message = message.replace(/\n/g, '').replace(/ +/g, ' ').trim();
// use red for error levels
if (context?.level === 'error') {
message = colors.red(message);
}
// use yellow for warning levels
if (context?.level === 'warning') {
message = colors.yellow(message);
}
const label = context?.label ? colors.cyan(`(${context.label}) `) : '';
this.writer(colors.grey(`[${namespace}] `) + label + message);
}
/**
* @inheritDoc
*/
error(namespace, message, context) {
this.log(namespace, message, { ...context, level: 'error' });
}
/**
* @inheritDoc
*/
warn(namespace, message, context) {
this.log(namespace, message, { ...context, level: 'warning' });
}
/**
* @inheritDoc
*/
setDebugMode(debugMode) {
this.debugMode = debugMode;
}
/** Checks whether logging is enabled for the given namespace, considering context overrides. */
isEnabled(namespace, context) {
if (context?.enabled !== undefined) {
return context.enabled;
}
const debugMode = context?.debugMode ?? this.debugMode;
if (namespace === 'deprecated') {
const { ignoreDeprecations = false } = this.options;
return Array.isArray(ignoreDeprecations)
? /* v8 ignore next */
!ignoreDeprecations.includes(context?.label ?? '')
: !ignoreDeprecations;
}
return !!debugMode && (!Array.isArray(debugMode) || debugMode.includes(namespace));
}
/**
* @inheritDoc
*/
logQuery(context) {
const namespace = context.namespace ?? 'query';
if (!this.isEnabled(namespace, context)) {
return;
}
/* v8 ignore next */
let msg = this.highlighter?.highlight(context.query) ?? context.query;
if (context.took != null) {
const meta = [`took ${context.took} ms`];
if (context.results != null) {
meta.push(`${context.results} result${context.results === 0 || context.results > 1 ? 's' : ''}`);
}
if (context.affected != null) {
meta.push(`${context.affected} row${context.affected === 0 || context.affected > 1 ? 's' : ''} affected`);
}
msg += colors.grey(` [${meta.join(', ')}]`);
}
if (this.usesReplicas && context.connection) {
msg += colors.cyan(` (via ${context.connection.type} connection '${context.connection.name}')`);
}
return this.log(namespace, msg, context);
}
/** Factory method for creating a new DefaultLogger instance. */
static create(options) {
return new DefaultLogger(options);
}
}

63
node_modules/@mikro-orm/core/logging/Logger.d.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import type { AnyString, Dictionary, Highlighter } from '../typings.js';
/** Interface for ORM logging, supporting namespaced log levels and query logging. */
export interface Logger {
/**
* Logs a message inside given namespace.
*/
log(namespace: LoggerNamespace | AnyString, message: string, context?: LogContext): void;
/**
* Logs error message inside given namespace.
*/
error(namespace: LoggerNamespace | AnyString, message: string, context?: LogContext): void;
/**
* Logs warning message inside given namespace.
*/
warn(namespace: LoggerNamespace | AnyString, message: string, context?: LogContext): void;
/**
* Logs a message inside given namespace.
*/
logQuery(context: LogContext): void;
/**
* Sets active namespaces. Pass `true` to enable all logging.
*/
setDebugMode(debugMode: boolean | LoggerNamespace[]): void;
/** Checks whether logging is enabled for the given namespace. */
isEnabled(namespace: LoggerNamespace, context?: LogContext): boolean;
}
/** Available logging namespaces that can be individually enabled or disabled. */
export type LoggerNamespace = 'query' | 'query-params' | 'schema' | 'discovery' | 'info' | 'deprecated' | 'slow-query';
/** Contextual metadata passed alongside log messages, including query details and timing. */
export interface LogContext extends Dictionary {
query?: string;
label?: string;
namespace?: LoggerNamespace;
params?: readonly unknown[];
took?: number;
results?: number;
affected?: number;
level?: 'info' | 'warning' | 'error';
enabled?: boolean;
debugMode?: LoggerNamespace[];
connection?: {
type?: string;
name?: string;
};
}
/** Options for constructing a Logger instance. */
export interface LoggerOptions {
writer: (message: string) => void;
debugMode?: boolean | LoggerNamespace[];
ignoreDeprecations?: boolean | string[];
highlighter?: Highlighter;
usesReplicas?: boolean;
}
/**
* Logger options to modify format output and overrides, including a label and additional properties that can be accessed by custom loggers.
*
* Differs from {@apilink LoggerOptions} in terms of how they are used; this type is primarily a public type meant to be used within methods like `em.find()`.
*
* @example
* await em.findOne(User, 1, { logger: { label: 'user middleware' } };
* // [query] (user middleware) select * from user where id = 1;
*/
export type LoggingOptions = Pick<LogContext, 'label' | 'enabled' | 'debugMode'>;

1
node_modules/@mikro-orm/core/logging/Logger.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

20
node_modules/@mikro-orm/core/logging/SimpleLogger.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import type { LogContext, LoggerNamespace, LoggerOptions } from './Logger.js';
import { DefaultLogger } from './DefaultLogger.js';
/**
* A basic logger that provides fully formatted output without color
*/
export declare class SimpleLogger extends DefaultLogger {
/**
* @inheritDoc
*/
log(namespace: LoggerNamespace, message: string, context?: LogContext): void;
/**
* @inheritDoc
*/
logQuery(
context: {
query: string;
} & LogContext,
): void;
static create(this: void, options: LoggerOptions): SimpleLogger;
}

30
node_modules/@mikro-orm/core/logging/SimpleLogger.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import { DefaultLogger } from './DefaultLogger.js';
/**
* A basic logger that provides fully formatted output without color
*/
export class SimpleLogger extends DefaultLogger {
/**
* @inheritDoc
*/
log(namespace, message, context) {
if (!this.isEnabled(namespace, context)) {
return;
}
// clean up the whitespace
message = message.replace(/\n/g, '').replace(/ +/g, ' ').trim();
const label = context?.label ? `(${context.label}) ` : '';
this.writer(`[${namespace}] ${label}${message}`);
}
/**
* @inheritDoc
*/
logQuery(context) {
if (!this.isEnabled('query', context)) {
return;
}
return this.log('query', context.query, context);
}
static create(options) {
return new SimpleLogger(options);
}
}

9
node_modules/@mikro-orm/core/logging/colors.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
/** @internal */
export declare const colors: {
red: (text: string) => string;
green: (text: string) => string;
yellow: (text: string) => string;
grey: (text: string) => string;
cyan: (text: string) => string;
enabled: () => boolean;
};

15
node_modules/@mikro-orm/core/logging/colors.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { getEnv } from '../utils/env-vars.js';
const bool = k => ['true', 't', '1'].includes(getEnv(k)?.toLowerCase() ?? '');
const boolIfDefined = k => (getEnv(k) != null ? bool(k) : true);
const enabled = () =>
!bool('NO_COLOR') && !bool('MIKRO_ORM_NO_COLOR') && boolIfDefined('FORCE_COLOR') && boolIfDefined('MIKRO_ORM_COLORS');
const wrap = fn => text => (enabled() ? fn(text) : text);
/** @internal */
export const colors = {
red: wrap(text => `\x1B[31m${text}\x1B[39m`),
green: wrap(text => `\x1B[32m${text}\x1B[39m`),
yellow: wrap(text => `\x1B[33m${text}\x1B[39m`),
grey: wrap(text => `\x1B[90m${text}\x1B[39m`),
cyan: wrap(text => `\x1B[36m${text}\x1B[39m`),
enabled,
};

5
node_modules/@mikro-orm/core/logging/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export * from './colors.js';
export type * from './Logger.js';
export * from './DefaultLogger.js';
export * from './SimpleLogger.js';
export * from './inspect.js';

4
node_modules/@mikro-orm/core/logging/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export * from './colors.js';
export * from './DefaultLogger.js';
export * from './SimpleLogger.js';
export * from './inspect.js';

2
node_modules/@mikro-orm/core/logging/inspect.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/** @internal */
export declare function inspect(value: unknown, options?: Record<string, any>): string;

11
node_modules/@mikro-orm/core/logging/inspect.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
let nodeInspect;
/** @internal */
export function inspect(value, options) {
nodeInspect ??= globalThis.process?.getBuiltinModule?.('node:util').inspect;
/* v8 ignore else */
if (nodeInspect) {
return nodeInspect(value, options);
}
/* v8 ignore next */
return JSON.stringify(value, null, 2);
}