mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 07:30:16 +03:00
feat: add example
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { {{name.pascalCase}}ErrorCode } from '../types/{{name.kebabCase}}-error-code.type'
|
||||
|
||||
/**
|
||||
* Доменная ошибка бизнес-модуля {{name.pascalCase}}.
|
||||
*
|
||||
* UI/i18n-слой должен использовать `code`, а не `message`, для выбора пользовательского текста.
|
||||
*/
|
||||
export class {{name.pascalCase}}BusinessError extends Error {
|
||||
/** Код доменной ошибки для UI/i18n-слоя. */
|
||||
readonly code: {{name.pascalCase}}ErrorCode
|
||||
/** Исходная ошибка нижележащей runtime-зависимости. */
|
||||
readonly cause: unknown
|
||||
|
||||
constructor(code: {{name.pascalCase}}ErrorCode, cause: unknown) {
|
||||
super(code)
|
||||
|
||||
this.name = '{{name.pascalCase}}BusinessError'
|
||||
this.code = code
|
||||
this.cause = cause
|
||||
}
|
||||
}
|
||||
6
.templates/business/{{name.kebabCase}}/index.ts
Normal file
6
.templates/business/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export { {{name.camelCase}}Factory } from './{{name.kebabCase}}.factory'
|
||||
export type { {{name.pascalCase}}Api } from './types/{{name.kebabCase}}-api.type'
|
||||
export type { {{name.pascalCase}}Deps } from './types/{{name.kebabCase}}-deps.type'
|
||||
export type { {{name.pascalCase}}Error } from './types/{{name.kebabCase}}-error.type'
|
||||
export type { {{name.pascalCase}}ErrorCode } from './types/{{name.kebabCase}}-error-code.type'
|
||||
export type { {{name.pascalCase}}Factory } from './types/{{name.kebabCase}}-factory.type'
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Публичный API бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export type {{name.pascalCase}}Api = object
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Runtime-зависимости бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export type {{name.pascalCase}}Deps = object
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Коды доменных ошибок бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.screamingSnakeCase}}_ERROR_CODES = {
|
||||
/** Базовая доменная ошибка бизнес-модуля {{name.pascalCase}}. */
|
||||
UNKNOWN: '{{name.screamingSnakeCase}}_UNKNOWN'
|
||||
} as const
|
||||
|
||||
/**
|
||||
* Код доменной ошибки бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export type {{name.pascalCase}}ErrorCode = (typeof {{name.screamingSnakeCase}}_ERROR_CODES)[keyof typeof {{name.screamingSnakeCase}}_ERROR_CODES]
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { {{name.pascalCase}}ErrorCode } from './{{name.kebabCase}}-error-code.type'
|
||||
|
||||
/**
|
||||
* Публичный структурный контракт доменной ошибки {{name.pascalCase}}.
|
||||
*/
|
||||
export type {{name.pascalCase}}Error = {
|
||||
/** Исходная ошибка нижележащей runtime-зависимости. */
|
||||
cause: unknown
|
||||
/** Код доменной ошибки для UI/i18n-слоя. */
|
||||
code: {{name.pascalCase}}ErrorCode
|
||||
/** Сообщение ошибки, не используемое как UI-контракт. */
|
||||
message: string
|
||||
/** Имя доменной ошибки для диагностики. */
|
||||
name: string
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { {{name.pascalCase}}Api } from './{{name.kebabCase}}-api.type'
|
||||
import type { {{name.pascalCase}}Deps } from './{{name.kebabCase}}-deps.type'
|
||||
|
||||
/**
|
||||
* Фабрика публичного API бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export type {{name.pascalCase}}Factory = (deps: {{name.pascalCase}}Deps) => {{name.pascalCase}}Api
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { {{name.pascalCase}}Factory } from './types/{{name.kebabCase}}-factory.type'
|
||||
|
||||
/**
|
||||
* Создаёт публичный API бизнес-модуля {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.camelCase}}Factory: {{name.pascalCase}}Factory = (_deps) => {
|
||||
return {}
|
||||
}
|
||||
Reference in New Issue
Block a user