콘텐츠로 이동

@k-msg/template

K-Message 플랫폼의 템플릿 관리 및 검증 패키지입니다.

Terminal window
npm install @k-msg/template @k-msg/core
# or
bun add @k-msg/template @k-msg/core
  • Template Engine: 템플릿 종합 관리 시스템
  • Variable Parsing: 템플릿 변수 자동 추출 및 검증
  • Template Validation: 템플릿 내용/구조 내장 검증
  • Template Registry: 템플릿 중앙 저장/조회
  • Template Builder: 템플릿 동적 생성/수정
  • 런타임에서 Node 내장 모듈에 의존하지 않아 Edge 환경에서 nodejs_compat 없이 동작합니다.
import { interpolate } from '@k-msg/template';
const text = interpolate('[MyApp] Your verification code is #{code}.', {
code: '123456',
});
console.log(text); // "[MyApp] Your verification code is 123456."
import { TemplateRegistry } from '@k-msg/template';
const registry = new TemplateRegistry();
// 템플릿 등록
await registry.register({
id: 'otp-basic',
name: 'Basic OTP Template',
content: '[#{service}] Verification code: #{code}',
category: 'AUTHENTICATION'
});
// 템플릿 검색
const templates = await registry.search({
category: 'AUTHENTICATION',
status: 'ACTIVE'
});

TemplateService@k-msg/coreTemplateProvider 인터페이스를 감싸는 작은 helper입니다.

import { TemplateService } from '@k-msg/template';
import type { TemplateProvider } from '@k-msg/core';
const provider: TemplateProvider = /* your implementation */;
const templateService = new TemplateService(provider);
await templateService.create({
code: 'OTP_001',
name: 'OTP Verification',
content: '[MyApp] Your verification code is #{code}.',
category: 'AUTHENTICATION'
});

MIT