@k-msg/provider 0.3.0 → 0.5.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.
Files changed (44) hide show
  1. package/README.md +35 -124
  2. package/dist/aligo/provider.d.ts +18 -8
  3. package/dist/index.d.ts +8 -29
  4. package/dist/index.js +47 -47
  5. package/dist/index.js.map +10 -28
  6. package/dist/index.mjs +47 -47
  7. package/dist/index.mjs.map +10 -28
  8. package/dist/iwinv/provider.d.ts +21 -59
  9. package/dist/iwinv/types/iwinv.d.ts +10 -2
  10. package/dist/providers/mock/mock.provider.d.ts +6 -1
  11. package/dist/solapi/provider.d.ts +18 -6
  12. package/dist/solapi/types/solapi.d.ts +14 -2
  13. package/package.json +2 -22
  14. package/dist/abstract/provider.base.d.ts +0 -108
  15. package/dist/adapters/aligo.adapter.d.ts +0 -50
  16. package/dist/adapters/iwinv.adapter.d.ts +0 -139
  17. package/dist/adapters/solapi.adapter.d.ts +0 -48
  18. package/dist/config/provider-config-v2.d.ts +0 -122
  19. package/dist/contracts/provider.contract.d.ts +0 -355
  20. package/dist/contracts/sms.contract.d.ts +0 -135
  21. package/dist/interfaces/index.d.ts +0 -14
  22. package/dist/interfaces/plugin.d.ts +0 -122
  23. package/dist/interfaces/services.d.ts +0 -222
  24. package/dist/iwinv/contracts/account.contract.d.ts +0 -11
  25. package/dist/iwinv/contracts/analytics.contract.d.ts +0 -16
  26. package/dist/iwinv/contracts/channel.contract.d.ts +0 -15
  27. package/dist/iwinv/contracts/messaging.contract.d.ts +0 -14
  28. package/dist/iwinv/contracts/sms.contract.d.ts +0 -33
  29. package/dist/iwinv/contracts/template.contract.d.ts +0 -18
  30. package/dist/iwinv/provider-multi.d.ts +0 -116
  31. package/dist/iwinv/provider-sms.d.ts +0 -55
  32. package/dist/middleware/index.d.ts +0 -27
  33. package/dist/mock/index.d.ts +0 -1
  34. package/dist/registry/index.d.ts +0 -1
  35. package/dist/registry/plugin-registry.d.ts +0 -15
  36. package/dist/services/provider.manager.d.ts +0 -24
  37. package/dist/services/provider.service.d.ts +0 -49
  38. package/dist/test-helpers.d.ts +0 -110
  39. package/dist/types/base.d.ts +0 -172
  40. package/dist/types/typed-templates.d.ts +0 -199
  41. package/dist/types/unified-config.d.ts +0 -197
  42. package/dist/types/unified-errors.d.ts +0 -225
  43. package/dist/utils/base-plugin.d.ts +0 -35
  44. package/dist/utils/index.d.ts +0 -12
@@ -1,197 +0,0 @@
1
- /**
2
- * Unified Configuration Types
3
- * 통합된 설정 타입 시스템
4
- */
5
- import type { ProviderConfig } from "@k-msg/core";
6
- /**
7
- * 환경별 설정
8
- */
9
- export type Environment = "development" | "staging" | "production";
10
- /**
11
- * 로그 레벨
12
- */
13
- export type LogLevel = "debug" | "info" | "warn" | "error";
14
- /**
15
- * 공통 설정 인터페이스
16
- */
17
- export interface BaseConfig {
18
- environment: Environment;
19
- debug?: boolean;
20
- logLevel?: LogLevel;
21
- timeout?: number;
22
- }
23
- /**
24
- * IWINV 기본 설정 (모든 IWINV 관련 설정의 기준)
25
- */
26
- export interface IWINVBaseConfig extends ProviderConfig, BaseConfig {
27
- apiKey: string;
28
- baseUrl: string;
29
- userId?: string;
30
- senderNumber?: string;
31
- }
32
- /**
33
- * AlimTalk 특화 설정
34
- */
35
- export interface AlimTalkConfig extends IWINVBaseConfig {
36
- type: "alimtalk";
37
- senderKey?: string;
38
- fallbackSettings?: {
39
- enableSMSFallback: boolean;
40
- fallbackSenderNumber?: string;
41
- };
42
- }
43
- /**
44
- * SMS 특화 설정
45
- */
46
- export interface SMSConfig extends IWINVBaseConfig {
47
- type: "sms";
48
- defaultMsgType?: "SMS" | "LMS" | "MMS";
49
- autoDetectMessageType?: boolean;
50
- maxSMSLength?: number;
51
- maxLMSLength?: number;
52
- }
53
- /**
54
- * MMS 특화 설정
55
- */
56
- export interface MMSConfig extends IWINVBaseConfig {
57
- type: "mms";
58
- maxFileSize?: number;
59
- allowedMimeTypes?: string[];
60
- imageOptimization?: {
61
- enabled: boolean;
62
- maxWidth?: number;
63
- maxHeight?: number;
64
- quality?: number;
65
- };
66
- }
67
- /**
68
- * 채널별 설정 유니온
69
- */
70
- export type ChannelConfig = AlimTalkConfig | SMSConfig | MMSConfig;
71
- /**
72
- * 다중 채널 지원 설정
73
- */
74
- export interface MultiChannelConfig {
75
- channels: ChannelConfig[];
76
- defaultChannel: "alimtalk" | "sms" | "mms";
77
- fallbackChain?: ("alimtalk" | "sms" | "mms")[];
78
- }
79
- /**
80
- * 성능 및 안정성 설정
81
- */
82
- export interface PerformanceConfig {
83
- rateLimiting?: {
84
- requestsPerSecond: number;
85
- burstSize: number;
86
- strategy: "token_bucket" | "sliding_window";
87
- };
88
- circuitBreaker?: {
89
- enabled: boolean;
90
- failureThreshold: number;
91
- timeoutMs: number;
92
- retryDelayMs: number;
93
- };
94
- caching?: {
95
- enabled: boolean;
96
- ttl: number;
97
- maxSize: number;
98
- };
99
- connectionPool?: {
100
- maxConnections: number;
101
- idleTimeout: number;
102
- connectionTimeout: number;
103
- };
104
- }
105
- /**
106
- * 모니터링 설정
107
- */
108
- export interface MonitoringConfig {
109
- enableMetrics: boolean;
110
- enableTracing: boolean;
111
- enableHealthChecks: boolean;
112
- metricsInterval?: number;
113
- healthCheckInterval?: number;
114
- }
115
- /**
116
- * 완전한 통합 설정
117
- */
118
- export interface UnifiedProviderConfig extends BaseConfig {
119
- provider: {
120
- type: "iwinv";
121
- apiKey: string;
122
- baseUrl: string;
123
- };
124
- channels?: {
125
- alimtalk?: Omit<AlimTalkConfig, "apiKey" | "baseUrl" | "type">;
126
- sms?: Omit<SMSConfig, "apiKey" | "baseUrl" | "type">;
127
- mms?: Omit<MMSConfig, "apiKey" | "baseUrl" | "type">;
128
- };
129
- performance?: PerformanceConfig;
130
- monitoring?: MonitoringConfig;
131
- multiChannel?: {
132
- defaultChannel: "alimtalk" | "sms" | "mms";
133
- fallbackChain: ("alimtalk" | "sms" | "mms")[];
134
- };
135
- }
136
- /**
137
- * 기본 설정 검증
138
- */
139
- export declare function isValidBaseConfig(config: unknown): config is BaseConfig;
140
- /**
141
- * IWINV 기본 설정 검증
142
- */
143
- export declare function isValidIWINVBaseConfig(config: unknown): config is IWINVBaseConfig;
144
- /**
145
- * AlimTalk 설정 검증
146
- */
147
- export declare function isValidAlimTalkConfig(config: unknown): config is AlimTalkConfig;
148
- /**
149
- * SMS 설정 검증
150
- */
151
- export declare function isValidSMSConfig(config: unknown): config is SMSConfig;
152
- /**
153
- * MMS 설정 검증
154
- */
155
- export declare function isValidMMSConfig(config: unknown): config is MMSConfig;
156
- /**
157
- * 통합 설정 검증
158
- */
159
- export declare function isValidUnifiedConfig(config: unknown): config is UnifiedProviderConfig;
160
- /**
161
- * 타입 안전한 설정 빌더
162
- */
163
- export declare class UnifiedConfigBuilder {
164
- private config;
165
- static create(): UnifiedConfigBuilder;
166
- environment(env: Environment): this;
167
- provider(apiKey: string, baseUrl: string): this;
168
- alimtalk(config: Omit<AlimTalkConfig, "apiKey" | "baseUrl" | "type">): this;
169
- sms(config: Omit<SMSConfig, "apiKey" | "baseUrl" | "type">): this;
170
- mms(config: Omit<MMSConfig, "apiKey" | "baseUrl" | "type">): this;
171
- performance(config: PerformanceConfig): this;
172
- monitoring(config: MonitoringConfig): this;
173
- multiChannel(defaultChannel: "alimtalk" | "sms" | "mms", fallbackChain: ("alimtalk" | "sms" | "mms")[]): this;
174
- build(): UnifiedProviderConfig;
175
- }
176
- export declare class UnifiedConfigFactory {
177
- /**
178
- * 개발 환경 기본 설정
179
- */
180
- static development(apiKey: string, baseUrl?: string): UnifiedProviderConfig;
181
- /**
182
- * 프로덕션 환경 기본 설정
183
- */
184
- static production(apiKey: string, baseUrl?: string): UnifiedProviderConfig;
185
- /**
186
- * 환경 변수에서 설정 생성
187
- */
188
- static fromEnvironment(): UnifiedProviderConfig;
189
- }
190
- /**
191
- * 통합 설정을 레거시 IWINVConfig로 변환
192
- */
193
- export declare function toLegacyIWINVConfig(config: UnifiedProviderConfig): IWINVBaseConfig;
194
- /**
195
- * 레거시 IWINVConfig를 통합 설정으로 변환
196
- */
197
- export declare function fromLegacyIWINVConfig(legacyConfig: IWINVBaseConfig): UnifiedProviderConfig;
@@ -1,225 +0,0 @@
1
- /**
2
- * Unified Error System
3
- * 통합 에러 처리 시스템
4
- */
5
- type StandardError = any;
6
- /**
7
- * 에러 카테고리
8
- */
9
- export declare enum ErrorCategory {
10
- SYSTEM = "SYSTEM",
11
- NETWORK = "NETWORK",
12
- CONFIGURATION = "CONFIGURATION",
13
- AUTHENTICATION = "AUTHENTICATION",
14
- AUTHORIZATION = "AUTHORIZATION",
15
- VALIDATION = "VALIDATION",
16
- BUSINESS_LOGIC = "BUSINESS_LOGIC",
17
- PROVIDER = "PROVIDER",
18
- TEMPLATE = "TEMPLATE",
19
- RATE_LIMIT = "RATE_LIMIT",
20
- UNKNOWN = "UNKNOWN"
21
- }
22
- /**
23
- * 에러 심각도
24
- */
25
- export declare enum ErrorSeverity {
26
- LOW = "LOW",// 로깅만, 재시도 불필요
27
- MEDIUM = "MEDIUM",// 경고, 재시도 가능
28
- HIGH = "HIGH",// 에러, 재시도 필요
29
- CRITICAL = "CRITICAL"
30
- }
31
- /**
32
- * 기본 에러 정보
33
- */
34
- export interface BaseErrorInfo {
35
- code: string;
36
- message: string;
37
- category: ErrorCategory;
38
- severity: ErrorSeverity;
39
- retryable: boolean;
40
- timestamp: Date;
41
- context?: Record<string, unknown>;
42
- }
43
- /**
44
- * Provider 특화 에러 정보
45
- */
46
- export interface ProviderErrorInfo extends BaseErrorInfo {
47
- provider: string;
48
- originalCode?: string | number;
49
- originalMessage?: string;
50
- endpoint?: string;
51
- requestId?: string;
52
- }
53
- /**
54
- * 템플릿 관련 에러 정보
55
- */
56
- export interface TemplateErrorInfo extends BaseErrorInfo {
57
- templateCode?: string;
58
- templateName?: string;
59
- validationErrors?: string[];
60
- missingVariables?: string[];
61
- }
62
- /**
63
- * 네트워크 관련 에러 정보
64
- */
65
- export interface NetworkErrorInfo extends BaseErrorInfo {
66
- url?: string;
67
- method?: string;
68
- statusCode?: number;
69
- timeout?: boolean;
70
- connectionRefused?: boolean;
71
- }
72
- /**
73
- * 통합 에러 타입
74
- */
75
- export type UnifiedErrorInfo = ProviderErrorInfo | TemplateErrorInfo | NetworkErrorInfo | BaseErrorInfo;
76
- /**
77
- * 기본 통합 에러 클래스
78
- */
79
- export declare class UnifiedError extends Error {
80
- readonly category: ErrorCategory;
81
- readonly severity: ErrorSeverity;
82
- readonly retryable: boolean;
83
- readonly timestamp: Date;
84
- readonly context: Record<string, unknown>;
85
- constructor(info: BaseErrorInfo);
86
- /**
87
- * StandardError 형식으로 변환
88
- */
89
- toStandardError(): StandardError;
90
- /**
91
- * 에러 카테고리를 StandardErrorCode로 매핑
92
- */
93
- private mapToStandardErrorCode;
94
- }
95
- /**
96
- * Provider 에러 클래스
97
- */
98
- export declare class ProviderError extends UnifiedError {
99
- readonly provider: string;
100
- readonly originalCode?: string | number;
101
- readonly originalMessage?: string;
102
- readonly endpoint?: string;
103
- readonly requestId?: string;
104
- constructor(info: ProviderErrorInfo);
105
- }
106
- /**
107
- * 템플릿 에러 클래스
108
- */
109
- export declare class TemplateError extends UnifiedError {
110
- readonly templateCode?: string;
111
- readonly templateName?: string;
112
- readonly validationErrors?: string[];
113
- readonly missingVariables?: string[];
114
- constructor(info: TemplateErrorInfo);
115
- }
116
- /**
117
- * 네트워크 에러 클래스
118
- */
119
- export declare class NetworkError extends UnifiedError {
120
- readonly url?: string;
121
- readonly method?: string;
122
- readonly statusCode?: number;
123
- readonly timeout?: boolean;
124
- readonly connectionRefused?: boolean;
125
- constructor(info: NetworkErrorInfo);
126
- }
127
- export declare class ErrorFactory {
128
- /**
129
- * Provider 에러 생성
130
- */
131
- static createProviderError(params: {
132
- provider: string;
133
- message: string;
134
- originalCode?: string | number;
135
- originalMessage?: string;
136
- endpoint?: string;
137
- retryable?: boolean;
138
- context?: Record<string, unknown>;
139
- }): ProviderError;
140
- /**
141
- * 템플릿 에러 생성
142
- */
143
- static createTemplateError(params: {
144
- templateCode?: string;
145
- message: string;
146
- validationErrors?: string[];
147
- missingVariables?: string[];
148
- retryable?: boolean;
149
- }): TemplateError;
150
- /**
151
- * 네트워크 에러 생성
152
- */
153
- static createNetworkError(params: {
154
- url?: string;
155
- method?: string;
156
- statusCode?: number;
157
- message: string;
158
- timeout?: boolean;
159
- connectionRefused?: boolean;
160
- }): NetworkError;
161
- /**
162
- * 인증 에러 생성
163
- */
164
- static createAuthenticationError(message?: string): UnifiedError;
165
- /**
166
- * 검증 에러 생성
167
- */
168
- static createValidationError(message: string, context?: Record<string, unknown>): UnifiedError;
169
- /**
170
- * 요율 제한 에러 생성
171
- */
172
- static createRateLimitError(message?: string, retryAfter?: number): UnifiedError;
173
- }
174
- export declare class ErrorConverter {
175
- /**
176
- * 임의의 에러를 UnifiedError로 변환
177
- */
178
- static toUnifiedError(error: unknown, context?: Record<string, unknown>): UnifiedError;
179
- /**
180
- * IWINV 에러를 ProviderError로 변환
181
- */
182
- static fromIWINVError(error: {
183
- code: number;
184
- message: string;
185
- status?: number;
186
- data?: unknown;
187
- }): ProviderError;
188
- /**
189
- * HTTP 에러를 NetworkError로 변환
190
- */
191
- static fromHttpError(params: {
192
- url: string;
193
- method: string;
194
- statusCode: number;
195
- statusText?: string;
196
- responseBody?: unknown;
197
- }): NetworkError;
198
- }
199
- export declare function isUnifiedError(error: unknown): error is UnifiedError;
200
- export declare function isProviderError(error: unknown): error is ProviderError;
201
- export declare function isTemplateError(error: unknown): error is TemplateError;
202
- export declare function isNetworkError(error: unknown): error is NetworkError;
203
- export declare function isRetryableError(error: unknown): boolean;
204
- export interface ErrorStats {
205
- total: number;
206
- byCategory: Record<ErrorCategory, number>;
207
- bySeverity: Record<ErrorSeverity, number>;
208
- retryable: number;
209
- nonRetryable: number;
210
- }
211
- export declare class ErrorAnalyzer {
212
- /**
213
- * 에러 목록 통계 분석
214
- */
215
- static analyze(errors: UnifiedError[]): ErrorStats;
216
- /**
217
- * 중요 에러 필터링
218
- */
219
- static getCriticalErrors(errors: UnifiedError[]): UnifiedError[];
220
- /**
221
- * 재시도 가능한 에러 필터링
222
- */
223
- static getRetryableErrors(errors: UnifiedError[]): UnifiedError[];
224
- }
225
- export {};
@@ -1,35 +0,0 @@
1
- import type { PluginContext, ProviderCapabilities, ProviderImplementation, ProviderMetadata, ProviderMiddleware, ProviderPlugin } from "../interfaces";
2
- export declare abstract class BasePlugin implements ProviderPlugin {
3
- abstract readonly metadata: ProviderMetadata;
4
- abstract readonly capabilities: ProviderCapabilities;
5
- protected context: PluginContext;
6
- middleware: ProviderMiddleware[];
7
- initialize(context: PluginContext): Promise<void>;
8
- destroy(): Promise<void>;
9
- abstract getImplementation(): ProviderImplementation;
10
- protected executeMiddleware(phase: "pre" | "post" | "error", context: any, error?: Error): Promise<void>;
11
- protected createMiddlewareContext(request: any, metadata?: Record<string, any>): {
12
- request: any;
13
- response: any;
14
- metadata: {
15
- pluginName: string;
16
- pluginVersion: string;
17
- };
18
- startTime: number;
19
- };
20
- protected validateConfig(config: any, required: string[]): void;
21
- protected makeRequest(url: string, options: RequestInit, metadata?: Record<string, any>): Promise<Response>;
22
- /**
23
- * Make HTTP request and parse JSON response
24
- * Subclasses should use their specific response adapters to transform the result
25
- */
26
- protected makeJSONRequest<T = any>(url: string, options: RequestInit, metadata?: Record<string, any>): Promise<T>;
27
- /**
28
- * Helper method for logging provider-specific operations
29
- */
30
- protected logOperation(operation: string, data?: any): void;
31
- /**
32
- * Helper method for logging provider-specific errors
33
- */
34
- protected logError(operation: string, error: any, data?: any): void;
35
- }
@@ -1,12 +0,0 @@
1
- export * from "./base-plugin";
2
- export declare function normalizePhoneNumber(phone: string): string;
3
- export declare function validatePhoneNumber(phone: string): boolean;
4
- export declare function formatDateTime(date: Date): string;
5
- export declare function parseTemplate(template: string, variables: Record<string, string>): string;
6
- export declare function extractVariables(template: string): string[];
7
- export declare function delay(ms: number): Promise<void>;
8
- export declare function retry<T>(fn: () => Promise<T>, options: {
9
- maxRetries: number;
10
- delay: number;
11
- backoff?: "linear" | "exponential";
12
- }): Promise<T>;