@k-msg/provider 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 +140 -0
- package/dist/index.cjs +2061 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1425 -0
- package/dist/index.d.ts +1425 -0
- package/dist/index.js +2007 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @k-msg/provider
|
|
2
|
+
|
|
3
|
+
Provider system and interfaces for the K-Message platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @k-msg/provider @k-msg/core
|
|
9
|
+
# or
|
|
10
|
+
bun add @k-msg/provider @k-msg/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Complete Provider System**: All-in-one package with providers, adapters, and implementations
|
|
16
|
+
- **Built-in IWINV Provider**: Production-ready IWINV AlimTalk integration
|
|
17
|
+
- **BaseAlimTalkProvider**: Abstract base class for creating custom providers
|
|
18
|
+
- **Request/Response Adapters**: Standardized API communication adapters
|
|
19
|
+
- **Provider Registry**: Centralized provider management and registration
|
|
20
|
+
- **Contract System**: Modular contract-based architecture
|
|
21
|
+
- **Configuration Validation**: Built-in configuration validation with schemas
|
|
22
|
+
- **Health Monitoring**: Comprehensive health checks and diagnostics
|
|
23
|
+
|
|
24
|
+
## Built-in Providers
|
|
25
|
+
|
|
26
|
+
### IWINV Provider
|
|
27
|
+
Production-ready AlimTalk provider with full feature support:
|
|
28
|
+
- ✅ AlimTalk message sending with variable substitution
|
|
29
|
+
- ✅ SMS/LMS fallback for failed AlimTalk messages
|
|
30
|
+
- ✅ Template management (create, update, delete, list)
|
|
31
|
+
- ✅ Account balance and profile information
|
|
32
|
+
- ✅ Real-time delivery tracking and status updates
|
|
33
|
+
- ✅ Channel and sender number management
|
|
34
|
+
- ✅ Analytics and usage statistics
|
|
35
|
+
- ✅ Configuration validation and health checks
|
|
36
|
+
|
|
37
|
+
## Basic Usage
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { IWINVProvider } from '@k-msg/provider';
|
|
41
|
+
|
|
42
|
+
// Use the built-in IWINV provider
|
|
43
|
+
const iwinvProvider = new IWINVProvider({
|
|
44
|
+
apiKey: process.env.IWINV_API_KEY!,
|
|
45
|
+
baseUrl: 'https://alimtalk.bizservice.iwinv.kr',
|
|
46
|
+
debug: false
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Send a message
|
|
50
|
+
const result = await iwinvProvider.sendMessage({
|
|
51
|
+
templateCode: 'TPL001',
|
|
52
|
+
phoneNumber: '01012345678',
|
|
53
|
+
variables: { code: '123456' }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
console.log('Message sent:', result.messageId);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Custom Provider Registration
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { PluginRegistry } from '@k-msg/provider';
|
|
63
|
+
|
|
64
|
+
const registry = new PluginRegistry();
|
|
65
|
+
|
|
66
|
+
// Register a custom provider plugin
|
|
67
|
+
await registry.registerPlugin({
|
|
68
|
+
id: 'custom-provider',
|
|
69
|
+
name: 'Custom Provider',
|
|
70
|
+
version: '1.0.0',
|
|
71
|
+
capabilities: {
|
|
72
|
+
messaging: true,
|
|
73
|
+
templates: true,
|
|
74
|
+
analytics: false
|
|
75
|
+
},
|
|
76
|
+
factory: () => new CustomProvider()
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Get registered providers
|
|
80
|
+
const providers = registry.getRegisteredPlugins();
|
|
81
|
+
console.log('Available providers:', providers);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Creating Custom Providers
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { BasePlugin } from '@k-msg/provider';
|
|
88
|
+
|
|
89
|
+
export class CustomProvider extends BasePlugin {
|
|
90
|
+
constructor() {
|
|
91
|
+
super({
|
|
92
|
+
id: 'custom-provider',
|
|
93
|
+
name: 'Custom Provider',
|
|
94
|
+
version: '1.0.0'
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async initialize(config: any): Promise<void> {
|
|
99
|
+
// Initialize provider with configuration
|
|
100
|
+
this.config = config;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async sendMessage(options: MessageSendOptions): Promise<MessageResult> {
|
|
104
|
+
// Implement message sending logic
|
|
105
|
+
return {
|
|
106
|
+
messageId: 'msg-123',
|
|
107
|
+
status: 'SENT'
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getHealth(): Promise<HealthStatus> {
|
|
112
|
+
// Implement health check
|
|
113
|
+
return {
|
|
114
|
+
healthy: true,
|
|
115
|
+
latency: 150
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Service Interfaces
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { MessagingService, TemplateService } from '@k-msg/provider';
|
|
125
|
+
|
|
126
|
+
// Implement messaging service
|
|
127
|
+
class CustomMessagingService implements MessagingService {
|
|
128
|
+
async sendMessage(request: MessageRequest): Promise<MessageResponse> {
|
|
129
|
+
// Custom implementation
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async getMessageStatus(messageId: string): Promise<MessageStatus> {
|
|
133
|
+
// Custom implementation
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|