create-bunspace 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -0
- package/dist/bin.js +5755 -0
- package/dist/templates/monorepo/CLAUDE.md +164 -0
- package/dist/templates/monorepo/LICENSE +21 -0
- package/dist/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
- package/dist/templates/monorepo/README.md +74 -0
- package/dist/templates/monorepo/SYNC_VERIFICATION.md +1 -0
- package/dist/templates/monorepo/apps/example/package.json +19 -0
- package/dist/templates/monorepo/apps/example/src/index.ts +23 -0
- package/dist/templates/monorepo/apps/example/src/types/index.ts +7 -0
- package/dist/templates/monorepo/apps/example/src/utils/index.ts +7 -0
- package/dist/templates/monorepo/core/packages/main/package.json +41 -0
- package/dist/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
- package/dist/templates/monorepo/core/packages/main/src/index.ts +80 -0
- package/dist/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
- package/dist/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
- package/dist/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
- package/dist/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
- package/dist/templates/monorepo/core/packages/utils/package.json +43 -0
- package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
- package/dist/templates/monorepo/core/packages/utils/src/index.ts +2 -0
- package/dist/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
- package/dist/templates/monorepo/core/packages/utils/src/result.ts +146 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
- package/dist/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
- package/dist/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
- package/dist/templates/monorepo/oxlint.json +14 -0
- package/dist/templates/monorepo/package.json +39 -0
- package/dist/templates/monorepo/tsconfig.json +35 -0
- package/dist/templates/telegram-bot/.oxlintrc.json +33 -0
- package/dist/templates/telegram-bot/.prettierignore +5 -0
- package/dist/templates/telegram-bot/.prettierrc +26 -0
- package/dist/templates/telegram-bot/CLAUDE.deploy.md +356 -0
- package/dist/templates/telegram-bot/CLAUDE.dev.md +266 -0
- package/dist/templates/telegram-bot/CLAUDE.md +280 -0
- package/dist/templates/telegram-bot/Dockerfile +46 -0
- package/dist/templates/telegram-bot/README.md +245 -0
- package/dist/templates/telegram-bot/apps/.gitkeep +0 -0
- package/dist/templates/telegram-bot/bun.lock +208 -0
- package/dist/templates/telegram-bot/core/.env.example +71 -0
- package/dist/templates/telegram-bot/core/README.md +1067 -0
- package/dist/templates/telegram-bot/core/package.json +15 -0
- package/dist/templates/telegram-bot/core/src/config/env.ts +131 -0
- package/dist/templates/telegram-bot/core/src/config/index.ts +97 -0
- package/dist/templates/telegram-bot/core/src/config/logging.ts +110 -0
- package/dist/templates/telegram-bot/core/src/handlers/control.ts +85 -0
- package/dist/templates/telegram-bot/core/src/handlers/health.ts +83 -0
- package/dist/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
- package/dist/templates/telegram-bot/core/src/index.ts +161 -0
- package/dist/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
- package/dist/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
- package/dist/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
- package/dist/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
- package/dist/templates/telegram-bot/core/src/types/bot.ts +92 -0
- package/dist/templates/telegram-bot/core/src/types/constants.ts +50 -0
- package/dist/templates/telegram-bot/core/src/types/result.ts +1 -0
- package/dist/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
- package/dist/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
- package/dist/templates/telegram-bot/core/src/utils/commands.ts +63 -0
- package/dist/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
- package/dist/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
- package/dist/templates/telegram-bot/core/src/utils/memory.ts +33 -0
- package/dist/templates/telegram-bot/core/src/utils/result.ts +26 -0
- package/dist/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
- package/dist/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
- package/dist/templates/telegram-bot/core/tsconfig.json +9 -0
- package/dist/templates/telegram-bot/docker-compose.yml +37 -0
- package/dist/templates/telegram-bot/docs/cli-commands.md +377 -0
- package/dist/templates/telegram-bot/docs/development.md +363 -0
- package/dist/templates/telegram-bot/docs/environment.md +460 -0
- package/dist/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
- package/dist/templates/telegram-bot/docs/examples/simple-command.md +207 -0
- package/dist/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
- package/dist/templates/telegram-bot/docs/getting-started.md +223 -0
- package/dist/templates/telegram-bot/docs/troubleshooting.md +489 -0
- package/dist/templates/telegram-bot/package.json +49 -0
- package/dist/templates/telegram-bot/packages/utils/package.json +12 -0
- package/dist/templates/telegram-bot/packages/utils/src/index.ts +2 -0
- package/dist/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
- package/dist/templates/telegram-bot/packages/utils/src/result.ts +80 -0
- package/dist/templates/telegram-bot/tools/README.md +47 -0
- package/dist/templates/telegram-bot/tools/commands/doctor.ts +460 -0
- package/dist/templates/telegram-bot/tools/commands/index.ts +35 -0
- package/dist/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
- package/dist/templates/telegram-bot/tools/commands/setup.ts +368 -0
- package/dist/templates/telegram-bot/tools/commands/status.ts +140 -0
- package/dist/templates/telegram-bot/tools/index.ts +16 -0
- package/dist/templates/telegram-bot/tools/package.json +12 -0
- package/dist/templates/telegram-bot/tools/utils/index.ts +13 -0
- package/dist/templates/telegram-bot/tsconfig.json +22 -0
- package/dist/templates/telegram-bot/vitest.config.ts +29 -0
- package/package.json +35 -0
- package/templates/monorepo/CLAUDE.md +164 -0
- package/templates/monorepo/LICENSE +21 -0
- package/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +269 -0
- package/templates/monorepo/README.md +74 -0
- package/templates/monorepo/apps/example/package.json +19 -0
- package/templates/monorepo/apps/example/src/index.ts +23 -0
- package/templates/monorepo/apps/example/src/types/index.ts +7 -0
- package/templates/monorepo/apps/example/src/utils/index.ts +7 -0
- package/templates/monorepo/core/packages/main/package.json +41 -0
- package/templates/monorepo/core/packages/main/rolldown.config.ts +24 -0
- package/templates/monorepo/core/packages/main/src/index.ts +80 -0
- package/templates/monorepo/core/packages/main/src/types/constants.ts +15 -0
- package/templates/monorepo/core/packages/main/src/types/index.ts +8 -0
- package/templates/monorepo/core/packages/main/src/types/main.types.ts +25 -0
- package/templates/monorepo/core/packages/main/src/utils/index.ts +5 -0
- package/templates/monorepo/core/packages/utils/package.json +43 -0
- package/templates/monorepo/core/packages/utils/rolldown.config.ts +34 -0
- package/templates/monorepo/core/packages/utils/src/index.ts +2 -0
- package/templates/monorepo/core/packages/utils/src/logger.ts +68 -0
- package/templates/monorepo/core/packages/utils/src/result.ts +146 -0
- package/templates/monorepo/core/packages/utils/src/types/constants.ts +15 -0
- package/templates/monorepo/core/packages/utils/src/types/index.ts +8 -0
- package/templates/monorepo/core/packages/utils/src/types/utils.types.ts +32 -0
- package/templates/monorepo/core/packages/utils/src/utils/index.ts +5 -0
- package/templates/monorepo/oxlint.json +14 -0
- package/templates/monorepo/package.json +39 -0
- package/templates/monorepo/tsconfig.json +35 -0
- package/templates/telegram-bot/.oxlintrc.json +33 -0
- package/templates/telegram-bot/.prettierignore +5 -0
- package/templates/telegram-bot/.prettierrc +26 -0
- package/templates/telegram-bot/CLAUDE.deploy.md +356 -0
- package/templates/telegram-bot/CLAUDE.dev.md +266 -0
- package/templates/telegram-bot/CLAUDE.md +280 -0
- package/templates/telegram-bot/Dockerfile +46 -0
- package/templates/telegram-bot/README.md +245 -0
- package/templates/telegram-bot/apps/.gitkeep +0 -0
- package/templates/telegram-bot/bun.lock +208 -0
- package/templates/telegram-bot/core/.env.example +71 -0
- package/templates/telegram-bot/core/README.md +1067 -0
- package/templates/telegram-bot/core/package.json +15 -0
- package/templates/telegram-bot/core/src/config/env.ts +131 -0
- package/templates/telegram-bot/core/src/config/index.ts +97 -0
- package/templates/telegram-bot/core/src/config/logging.ts +110 -0
- package/templates/telegram-bot/core/src/handlers/control.ts +85 -0
- package/templates/telegram-bot/core/src/handlers/health.ts +83 -0
- package/templates/telegram-bot/core/src/handlers/logs.ts +126 -0
- package/templates/telegram-bot/core/src/index.ts +161 -0
- package/templates/telegram-bot/core/src/middleware/auth.ts +41 -0
- package/templates/telegram-bot/core/src/middleware/error-handler.ts +41 -0
- package/templates/telegram-bot/core/src/middleware/logging.ts +1 -0
- package/templates/telegram-bot/core/src/middleware/topics.ts +55 -0
- package/templates/telegram-bot/core/src/types/bot.ts +92 -0
- package/templates/telegram-bot/core/src/types/constants.ts +50 -0
- package/templates/telegram-bot/core/src/types/result.ts +1 -0
- package/templates/telegram-bot/core/src/utils/bot-manager.test.ts +111 -0
- package/templates/telegram-bot/core/src/utils/bot-manager.ts +201 -0
- package/templates/telegram-bot/core/src/utils/commands.ts +63 -0
- package/templates/telegram-bot/core/src/utils/formatters.ts +82 -0
- package/templates/telegram-bot/core/src/utils/instance-manager.ts +189 -0
- package/templates/telegram-bot/core/src/utils/memory.ts +33 -0
- package/templates/telegram-bot/core/src/utils/result.ts +26 -0
- package/templates/telegram-bot/core/src/utils/telegram.ts +31 -0
- package/templates/telegram-bot/core/src/utils/type-guards.ts +71 -0
- package/templates/telegram-bot/core/tsconfig.json +9 -0
- package/templates/telegram-bot/docker-compose.yml +37 -0
- package/templates/telegram-bot/docs/cli-commands.md +377 -0
- package/templates/telegram-bot/docs/development.md +363 -0
- package/templates/telegram-bot/docs/environment.md +460 -0
- package/templates/telegram-bot/docs/examples/middleware-auth.md +335 -0
- package/templates/telegram-bot/docs/examples/simple-command.md +207 -0
- package/templates/telegram-bot/docs/examples/webhook-setup.md +362 -0
- package/templates/telegram-bot/docs/getting-started.md +223 -0
- package/templates/telegram-bot/docs/troubleshooting.md +489 -0
- package/templates/telegram-bot/package.json +49 -0
- package/templates/telegram-bot/packages/utils/package.json +12 -0
- package/templates/telegram-bot/packages/utils/src/index.ts +2 -0
- package/templates/telegram-bot/packages/utils/src/logger.ts +72 -0
- package/templates/telegram-bot/packages/utils/src/result.ts +80 -0
- package/templates/telegram-bot/tools/README.md +47 -0
- package/templates/telegram-bot/tools/commands/doctor.ts +460 -0
- package/templates/telegram-bot/tools/commands/index.ts +35 -0
- package/templates/telegram-bot/tools/commands/ngrok.ts +207 -0
- package/templates/telegram-bot/tools/commands/setup.ts +368 -0
- package/templates/telegram-bot/tools/commands/status.ts +140 -0
- package/templates/telegram-bot/tools/index.ts +16 -0
- package/templates/telegram-bot/tools/package.json +12 -0
- package/templates/telegram-bot/tools/utils/index.ts +13 -0
- package/templates/telegram-bot/tsconfig.json +22 -0
- package/templates/telegram-bot/vitest.config.ts +29 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{NAME}}
|
|
3
|
+
*
|
|
4
|
+
* {{DESCRIPTION}}
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { greet } from '{{SCOPE}}/core';
|
|
10
|
+
* import { createLogger } from '{{SCOPE}}/utils/logger';
|
|
11
|
+
*
|
|
12
|
+
* const log = createLogger('Main');
|
|
13
|
+
*
|
|
14
|
+
* const result = greet('World');
|
|
15
|
+
*
|
|
16
|
+
* if (result.isErr()) {
|
|
17
|
+
* log.error('Failed', result.error);
|
|
18
|
+
* return;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* log.success(result.value);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { ok, type Result, type ResultError } from '{{SCOPE}}/utils/result';
|
|
26
|
+
import type { AppErrorCode } from '{{SCOPE}}/utils/result';
|
|
27
|
+
|
|
28
|
+
// Importar tipos desde /types para uso interno
|
|
29
|
+
import type { IGreetOptions } from './types';
|
|
30
|
+
|
|
31
|
+
// Re-exportar tipos desde /types
|
|
32
|
+
export * from './types';
|
|
33
|
+
|
|
34
|
+
// Version del package
|
|
35
|
+
export const version = '0.1.0';
|
|
36
|
+
|
|
37
|
+
// Tipo de error
|
|
38
|
+
type AppError = ResultError<AppErrorCode>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Saluda a alguien con un mensaje personalizable.
|
|
42
|
+
*
|
|
43
|
+
* @param name - Nombre de la persona a saludar
|
|
44
|
+
* @param options - Opciones de saludo
|
|
45
|
+
* @returns Result con mensaje de saludo o error
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const result = greet('World', { prefix: 'Hello' });
|
|
50
|
+
* if (result.isOk()) {
|
|
51
|
+
* console.log(result.value); // "Hello, World!"
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function greet(
|
|
56
|
+
name: string,
|
|
57
|
+
options?: IGreetOptions
|
|
58
|
+
): Result<string, AppError> {
|
|
59
|
+
const prefix = options?.prefix ?? 'Hello';
|
|
60
|
+
const suffix = options?.suffix ?? '!';
|
|
61
|
+
return ok(`${prefix}, ${name}${suffix}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Factory function para crear un greeter configurado.
|
|
66
|
+
*
|
|
67
|
+
* @param defaultOptions - Opciones por defecto para todos los saludos
|
|
68
|
+
* @returns Funcion greeter configurada
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const spanishGreeter = createGreeter({ prefix: 'Hola' });
|
|
73
|
+
* const result = spanishGreeter('Mundo'); // "Hola, Mundo!"
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function createGreeter(defaultOptions?: IGreetOptions) {
|
|
77
|
+
return (name: string, options?: IGreetOptions): Result<string, AppError> => {
|
|
78
|
+
return greet(name, { ...defaultOptions, ...options });
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos del dominio principal.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Opciones de configuracion para saludos.
|
|
9
|
+
*/
|
|
10
|
+
export interface IGreetOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Prefijo del saludo (default: "Hello").
|
|
13
|
+
*/
|
|
14
|
+
prefix?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Sufijo del saludo (default: "!").
|
|
18
|
+
*/
|
|
19
|
+
suffix?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Callback para notificar eventos.
|
|
24
|
+
*/
|
|
25
|
+
export type IEventCallback = (event: string) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{SCOPE}}/utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared utilities for {{NAME}}",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./logger": {
|
|
15
|
+
"types": "./dist/logger.d.ts",
|
|
16
|
+
"import": "./dist/logger.js"
|
|
17
|
+
},
|
|
18
|
+
"./result": {
|
|
19
|
+
"types": "./dist/result.d.ts",
|
|
20
|
+
"import": "./dist/result.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "rolldown --config rolldown.config.ts && tsgo --emitDeclarationOnly",
|
|
29
|
+
"typecheck": "tsgo --noEmit",
|
|
30
|
+
"dev": "bun --watch src/index.ts"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@mks2508/better-logger": "^4.0.0",
|
|
34
|
+
"@mks2508/no-throw": "^0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.10.5",
|
|
38
|
+
"rolldown": "^1.0.0-beta.58"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineConfig } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
input: './src/index.ts',
|
|
6
|
+
output: {
|
|
7
|
+
dir: './dist',
|
|
8
|
+
format: 'esm',
|
|
9
|
+
exports: 'named',
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
},
|
|
12
|
+
external: ['@mks2508/better-logger', '@mks2508/no-throw'],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
input: './src/logger.ts',
|
|
16
|
+
output: {
|
|
17
|
+
file: './dist/logger.js',
|
|
18
|
+
format: 'esm',
|
|
19
|
+
exports: 'named',
|
|
20
|
+
sourcemap: true,
|
|
21
|
+
},
|
|
22
|
+
external: ['@mks2508/better-logger'],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
input: './src/result.ts',
|
|
26
|
+
output: {
|
|
27
|
+
file: './dist/result.js',
|
|
28
|
+
format: 'esm',
|
|
29
|
+
exports: 'named',
|
|
30
|
+
sourcemap: true,
|
|
31
|
+
},
|
|
32
|
+
external: ['@mks2508/no-throw'],
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utility basado en @mks2508/better-logger.
|
|
3
|
+
*
|
|
4
|
+
* Configura el preset cyberpunk y exporta funciones para crear loggers nombrados.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createLogger } from '{{SCOPE}}/utils/logger';
|
|
11
|
+
*
|
|
12
|
+
* const log = createLogger('MyComponent');
|
|
13
|
+
*
|
|
14
|
+
* log.info('Started');
|
|
15
|
+
* log.error('Failed to connect', { error });
|
|
16
|
+
* log.success('Completed');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import logger, { component, type LogLevel } from '@mks2508/better-logger';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Aplica el preset cyberpunk al logger principal.
|
|
24
|
+
*
|
|
25
|
+
* Este preset proporciona colores profesionales para operaciones de logging.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://github.com/mks2508/better-logger | better-logger documentation}
|
|
28
|
+
*/
|
|
29
|
+
logger.preset('cyberpunk');
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Logger principal configurado con preset cyberpunk.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { logger } from '{{SCOPE}}/utils/logger';
|
|
37
|
+
*
|
|
38
|
+
* logger.info('Application started');
|
|
39
|
+
* logger.success('Operation completed');
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export { logger };
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Crea un logger nombrado para un componente especifico.
|
|
46
|
+
*
|
|
47
|
+
* @param name - Nombre del logger/componente
|
|
48
|
+
* @returns Logger con prefijo de componente
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const log = createLogger('MyService');
|
|
53
|
+
* log.info('Service started'); // [MyService] Service started
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const createLogger = (name: string) => component(name);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Niveles de log disponibles.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import type { LogLevel } from '{{SCOPE}}/utils/logger';
|
|
64
|
+
*
|
|
65
|
+
* const level: LogLevel = 'info';
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export type { LogLevel };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result pattern utilities basado en @mks2508/no-throw.
|
|
3
|
+
*
|
|
4
|
+
* Proporciona un tipo Result<T, E> para manejo de errores sin excepciones,
|
|
5
|
+
* junto con funciones auxiliares para trabajar con Results.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { ok, err, tryCatch, type Result } from '{{SCOPE}}/utils/result';
|
|
12
|
+
*
|
|
13
|
+
* async function fetchData(url: string): Promise<Result<string, AppError>> {
|
|
14
|
+
* const result = await tryCatch(
|
|
15
|
+
* async () => {
|
|
16
|
+
* const response = await fetch(url);
|
|
17
|
+
* return await response.text();
|
|
18
|
+
* },
|
|
19
|
+
* AppErrorCode.NetworkError
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* if (result.isErr()) {
|
|
23
|
+
* return createAppError(
|
|
24
|
+
* AppErrorCode.NetworkError,
|
|
25
|
+
* `Failed to fetch from ${url}`,
|
|
26
|
+
* result.error
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* return ok(result.value);
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
all,
|
|
37
|
+
collect,
|
|
38
|
+
err,
|
|
39
|
+
fail,
|
|
40
|
+
flatMap,
|
|
41
|
+
fromPromise,
|
|
42
|
+
isErr,
|
|
43
|
+
isOk,
|
|
44
|
+
map,
|
|
45
|
+
mapErr,
|
|
46
|
+
match,
|
|
47
|
+
ok,
|
|
48
|
+
tryCatch,
|
|
49
|
+
tryCatchAsync,
|
|
50
|
+
unwrap,
|
|
51
|
+
unwrapOr,
|
|
52
|
+
unwrapOrElse,
|
|
53
|
+
type Err,
|
|
54
|
+
type Ok,
|
|
55
|
+
type Result,
|
|
56
|
+
type ResultError,
|
|
57
|
+
} from '@mks2508/no-throw';
|
|
58
|
+
|
|
59
|
+
export { all };
|
|
60
|
+
export { collect };
|
|
61
|
+
export { err };
|
|
62
|
+
export { fail };
|
|
63
|
+
export { flatMap };
|
|
64
|
+
export { fromPromise };
|
|
65
|
+
export { isErr };
|
|
66
|
+
export { isOk };
|
|
67
|
+
export { map };
|
|
68
|
+
export { mapErr };
|
|
69
|
+
export { match };
|
|
70
|
+
export { ok };
|
|
71
|
+
export { tryCatch };
|
|
72
|
+
export { tryCatchAsync };
|
|
73
|
+
export { unwrap };
|
|
74
|
+
export { unwrapOr };
|
|
75
|
+
export { unwrapOrElse };
|
|
76
|
+
export type { Result };
|
|
77
|
+
export type { Ok };
|
|
78
|
+
export type { Err };
|
|
79
|
+
export type { ResultError };
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Codigos de error de aplicacion.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { AppErrorCode } from '{{SCOPE}}/utils/result';
|
|
87
|
+
*
|
|
88
|
+
* const code: AppErrorCode = AppErrorCode.NetworkError;
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export const AppErrorCode = {
|
|
92
|
+
/** Error de red o conexion fallida. */
|
|
93
|
+
NetworkError: 'NETWORK_ERROR',
|
|
94
|
+
/** Recurso no encontrado. */
|
|
95
|
+
NotFound: 'NOT_FOUND',
|
|
96
|
+
/** Permisos insuficientes. */
|
|
97
|
+
PermissionDenied: 'PERMISSION_DENIED',
|
|
98
|
+
/** Error de validacion. */
|
|
99
|
+
ValidationError: 'VALIDATION_ERROR',
|
|
100
|
+
/** Operacion cancelada. */
|
|
101
|
+
Cancelled: 'CANCELLED',
|
|
102
|
+
} as const;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Tipo de codigo de error de aplicacion.
|
|
106
|
+
*/
|
|
107
|
+
export type AppErrorCode = (typeof AppErrorCode)[keyof typeof AppErrorCode];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Crea un error de aplicacion con codigo, mensaje y causa opcional.
|
|
111
|
+
*
|
|
112
|
+
* @param code - Codigo de error de AppErrorCode
|
|
113
|
+
* @param message - Mensaje descriptivo del error
|
|
114
|
+
* @param cause - Error original que causo el fallo (opcional)
|
|
115
|
+
* @returns Result con error de aplicacion
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const error = createAppError(
|
|
120
|
+
* AppErrorCode.NetworkError,
|
|
121
|
+
* 'Failed to connect to server',
|
|
122
|
+
* originalError
|
|
123
|
+
* );
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export const createAppError = (
|
|
127
|
+
code: AppErrorCode,
|
|
128
|
+
message: string,
|
|
129
|
+
cause?: Error
|
|
130
|
+
): Result<never, ResultError<AppErrorCode>> => {
|
|
131
|
+
return fail(code, message, cause);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Tipo de error de aplicacion.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import type { AppError } from '{{SCOPE}}/utils/result';
|
|
140
|
+
*
|
|
141
|
+
* function handleError(error: AppError) {
|
|
142
|
+
* console.log(error.code);
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export type AppError = ResultError<AppErrorCode>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constantes compartidas del package {{SCOPE}}/utils.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Preset de logger para server-side (Node.js/Bun).
|
|
9
|
+
*/
|
|
10
|
+
export const LOGGER_PRESET = 'cyberpunk' as const;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Nivel de log por defecto.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_LOG_LEVEL = 'info' as const;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos especificos del package {{SCOPE}}/utils.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Nivel de log disponible.
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel =
|
|
11
|
+
| 'debug'
|
|
12
|
+
| 'info'
|
|
13
|
+
| 'warn'
|
|
14
|
+
| 'error'
|
|
15
|
+
| 'success'
|
|
16
|
+
| 'critical'
|
|
17
|
+
| 'trace';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Opciones para crear un logger nombrado.
|
|
21
|
+
*/
|
|
22
|
+
export interface ILoggerOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Nombre del logger/componente.
|
|
25
|
+
*/
|
|
26
|
+
name: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Nivel de log minimo (opcional).
|
|
30
|
+
*/
|
|
31
|
+
minLevel?: LogLevel;
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"categories": {
|
|
3
|
+
"correctness": "warn",
|
|
4
|
+
"suspicious": "warn",
|
|
5
|
+
"perf": "warn",
|
|
6
|
+
"style": "warn",
|
|
7
|
+
"restriction": "off"
|
|
8
|
+
},
|
|
9
|
+
"env": {
|
|
10
|
+
"node": true,
|
|
11
|
+
"es2021": true
|
|
12
|
+
},
|
|
13
|
+
"ignore": ["node_modules", "dist", "build", ".turbo", "coverage"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{NAME}}-monorepo",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"workspaces": [
|
|
7
|
+
"core/packages/*",
|
|
8
|
+
"apps/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "bun run --filter '*' dev",
|
|
12
|
+
"build": "bun run --filter '*' build",
|
|
13
|
+
"lint": "oxlint",
|
|
14
|
+
"lint:fix": "oxlint --fix",
|
|
15
|
+
"format": "prettier --write .",
|
|
16
|
+
"format:check": "prettier --check .",
|
|
17
|
+
"typecheck": "bun run --filter '*' typecheck",
|
|
18
|
+
"clean": "rm -rf node_modules **/node_modules **/dist **/.turbo",
|
|
19
|
+
"changeset": "changeset",
|
|
20
|
+
"changeset:version": "changeset version",
|
|
21
|
+
"changeset:publish": "changeset publish"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@changesets/cli": "^2.27.11",
|
|
25
|
+
"@oxlint/darwin-arm64": "0.11.1",
|
|
26
|
+
"@types/bun": "^1.1.15",
|
|
27
|
+
"@types/node": "^22.10.5",
|
|
28
|
+
"@typescript/native-preview": "^7.0.0-dev.20260106.1",
|
|
29
|
+
"oxlint": "^0.11.1",
|
|
30
|
+
"prettier": "^3.4.2",
|
|
31
|
+
"prettier-plugin-organize-imports": "^4.1.0"
|
|
32
|
+
},
|
|
33
|
+
"packageManager": "bun@1.1.43",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@mks2508/better-logger": "^4.0.0",
|
|
36
|
+
"@mks2508/no-throw": "^0.1.0",
|
|
37
|
+
"arktype": "^2.1.29"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noImplicitAny": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"strictFunctionTypes": true,
|
|
13
|
+
"strictBindCallApply": true,
|
|
14
|
+
"strictPropertyInitialization": true,
|
|
15
|
+
"noImplicitThis": true,
|
|
16
|
+
"alwaysStrict": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noImplicitReturns": false,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": false,
|
|
22
|
+
"exactOptionalPropertyTypes": false,
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
"esModuleInterop": true,
|
|
25
|
+
"allowSyntheticDefaultImports": true,
|
|
26
|
+
"forceConsistentCasingInFileNames": true,
|
|
27
|
+
"isolatedModules": true,
|
|
28
|
+
"verbatimModuleSyntax": true,
|
|
29
|
+
"declaration": true,
|
|
30
|
+
"declarationMap": true,
|
|
31
|
+
"sourceMap": true,
|
|
32
|
+
"removeComments": false
|
|
33
|
+
},
|
|
34
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"plugins": ["typescript", "import"],
|
|
4
|
+
"env": {
|
|
5
|
+
"browser": false,
|
|
6
|
+
"node": true
|
|
7
|
+
},
|
|
8
|
+
"categories": {
|
|
9
|
+
"correctness": "error",
|
|
10
|
+
"suspicious": "warn",
|
|
11
|
+
"style": "off",
|
|
12
|
+
"pedantic": "off",
|
|
13
|
+
"perf": "warn"
|
|
14
|
+
},
|
|
15
|
+
"rules": {
|
|
16
|
+
"no-unused-vars": "warn",
|
|
17
|
+
"no-console": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
19
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
20
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
21
|
+
"import/no-cycle": "error",
|
|
22
|
+
"import/no-duplicates": "warn"
|
|
23
|
+
},
|
|
24
|
+
"overrides": [
|
|
25
|
+
{
|
|
26
|
+
"files": ["*.test.ts", "*.spec.ts", "**/__tests__/**"],
|
|
27
|
+
"rules": {
|
|
28
|
+
"@typescript-eslint/no-explicit-any": "off"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"ignorePatterns": ["node_modules", "dist", "*.lock"]
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"semi": false,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"tabWidth": 2,
|
|
5
|
+
"useTabs": false,
|
|
6
|
+
"trailingComma": "es5",
|
|
7
|
+
"bracketSpacing": true,
|
|
8
|
+
"arrowParens": "always",
|
|
9
|
+
"printWidth": 100,
|
|
10
|
+
"endOfLine": "lf",
|
|
11
|
+
"overrides": [
|
|
12
|
+
{
|
|
13
|
+
"files": "*.json",
|
|
14
|
+
"options": {
|
|
15
|
+
"tabWidth": 2
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"files": ["*.md", "*.mdx"],
|
|
20
|
+
"options": {
|
|
21
|
+
"proseWrap": "always",
|
|
22
|
+
"printWidth": 80
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|