@k-msg/provider 0.1.0 → 0.1.2
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 +3 -1
- package/dist/abstract/provider.base.d.ts +108 -0
- package/dist/adapters/aligo.adapter.d.ts +50 -0
- package/dist/adapters/iwinv.adapter.d.ts +111 -0
- package/dist/aligo/provider.d.ts +18 -0
- package/dist/config/provider-config-v2.d.ts +122 -0
- package/dist/contracts/provider.contract.d.ts +355 -0
- package/dist/contracts/sms.contract.d.ts +135 -0
- package/dist/index.d.ts +29 -1424
- package/dist/index.js +21 -2003
- package/dist/index.js.map +98 -1
- package/dist/index.mjs +25 -0
- package/dist/index.mjs.map +98 -0
- package/dist/interfaces/index.d.ts +14 -0
- package/dist/interfaces/plugin.d.ts +122 -0
- package/dist/interfaces/services.d.ts +222 -0
- package/dist/iwinv/contracts/account.contract.d.ts +11 -0
- package/dist/iwinv/contracts/analytics.contract.d.ts +16 -0
- package/dist/iwinv/contracts/channel.contract.d.ts +15 -0
- package/dist/iwinv/contracts/messaging.contract.d.ts +14 -0
- package/dist/iwinv/contracts/sms.contract.d.ts +33 -0
- package/dist/iwinv/contracts/template.contract.d.ts +18 -0
- package/dist/iwinv/index.d.ts +5 -0
- package/dist/iwinv/provider-multi.d.ts +116 -0
- package/dist/iwinv/provider-sms.d.ts +55 -0
- package/dist/iwinv/provider.d.ts +42 -0
- package/dist/iwinv/types/iwinv.d.ts +153 -0
- package/dist/middleware/index.d.ts +27 -0
- package/dist/mock/index.d.ts +1 -0
- package/dist/providers/mock/index.d.ts +1 -0
- package/dist/providers/mock/mock.provider.d.ts +22 -0
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/plugin-registry.d.ts +15 -0
- package/dist/services/provider.manager.d.ts +24 -0
- package/dist/services/provider.service.d.ts +49 -0
- package/dist/test-helpers.d.ts +110 -0
- package/dist/types/aligo.d.ts +69 -0
- package/dist/types/base.d.ts +172 -0
- package/dist/types/typed-templates.d.ts +199 -0
- package/dist/types/unified-config.d.ts +197 -0
- package/dist/types/unified-errors.d.ts +225 -0
- package/dist/utils/base-plugin.d.ts +35 -0
- package/dist/utils/index.d.ts +12 -0
- package/package.json +25 -14
- package/dist/index.cjs +0 -2061
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1425
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./plugin";
|
|
2
|
+
export * from "./services";
|
|
3
|
+
export interface NotificationRequest {
|
|
4
|
+
phoneNumber: string;
|
|
5
|
+
message: string;
|
|
6
|
+
templateCode?: string;
|
|
7
|
+
variables?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface NotificationResponse {
|
|
10
|
+
success: boolean;
|
|
11
|
+
messageId?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { EventEmitter } from "events";
|
|
2
|
+
export interface ProviderPlugin {
|
|
3
|
+
readonly metadata: ProviderMetadata;
|
|
4
|
+
readonly capabilities: ProviderCapabilities;
|
|
5
|
+
initialize(context: PluginContext): Promise<void>;
|
|
6
|
+
destroy(): Promise<void>;
|
|
7
|
+
middleware?: ProviderMiddleware[];
|
|
8
|
+
getImplementation(): ProviderImplementation;
|
|
9
|
+
}
|
|
10
|
+
export interface ProviderMetadata {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
author: string;
|
|
14
|
+
description: string;
|
|
15
|
+
homepage?: string;
|
|
16
|
+
repository?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ProviderCapabilities {
|
|
19
|
+
messaging: {
|
|
20
|
+
single: boolean;
|
|
21
|
+
bulk: boolean;
|
|
22
|
+
maxBulkSize?: number;
|
|
23
|
+
maxMessageLength?: number;
|
|
24
|
+
variableSupport?: boolean;
|
|
25
|
+
maxVariables?: number;
|
|
26
|
+
};
|
|
27
|
+
scheduling?: {
|
|
28
|
+
supported: boolean;
|
|
29
|
+
maxAdvanceDays?: number;
|
|
30
|
+
minAdvanceMinutes?: number;
|
|
31
|
+
modifiable?: boolean;
|
|
32
|
+
cancellable?: boolean;
|
|
33
|
+
};
|
|
34
|
+
templating?: {
|
|
35
|
+
supported: boolean;
|
|
36
|
+
crud: boolean;
|
|
37
|
+
validation: boolean;
|
|
38
|
+
buttonTypes?: string[];
|
|
39
|
+
maxButtons?: number;
|
|
40
|
+
reviewRequired?: boolean;
|
|
41
|
+
reviewTime?: string;
|
|
42
|
+
};
|
|
43
|
+
resending?: {
|
|
44
|
+
supported: boolean;
|
|
45
|
+
fallbackTypes?: string[];
|
|
46
|
+
customContent?: boolean;
|
|
47
|
+
};
|
|
48
|
+
webhooks?: {
|
|
49
|
+
delivery: boolean;
|
|
50
|
+
status: boolean;
|
|
51
|
+
};
|
|
52
|
+
rateLimit?: {
|
|
53
|
+
messagesPerSecond?: number;
|
|
54
|
+
messagesPerMinute?: number;
|
|
55
|
+
messagesPerHour?: number;
|
|
56
|
+
messagesPerDay?: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface PluginContext {
|
|
60
|
+
config: ProviderConfig;
|
|
61
|
+
logger: Logger;
|
|
62
|
+
metrics: MetricsCollector;
|
|
63
|
+
storage: PluginStorage;
|
|
64
|
+
eventBus: EventEmitter;
|
|
65
|
+
}
|
|
66
|
+
export interface ProviderConfig {
|
|
67
|
+
apiUrl: string;
|
|
68
|
+
apiKey?: string;
|
|
69
|
+
secretKey?: string;
|
|
70
|
+
userId?: string;
|
|
71
|
+
senderKey?: string;
|
|
72
|
+
plusFriendId?: string;
|
|
73
|
+
headers?: Record<string, string>;
|
|
74
|
+
customFields?: Record<string, any>;
|
|
75
|
+
timeout?: number;
|
|
76
|
+
retryConfig?: RetryConfig;
|
|
77
|
+
logLevel?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface RetryConfig {
|
|
80
|
+
maxRetries: number;
|
|
81
|
+
retryDelay: number;
|
|
82
|
+
retryableErrors?: string[];
|
|
83
|
+
retryableStatusCodes?: number[];
|
|
84
|
+
}
|
|
85
|
+
export interface Logger {
|
|
86
|
+
info(message: string, ...args: any[]): void;
|
|
87
|
+
error(message: string, error?: any): void;
|
|
88
|
+
debug(message: string, ...args: any[]): void;
|
|
89
|
+
warn(message: string, ...args: any[]): void;
|
|
90
|
+
}
|
|
91
|
+
export interface MetricsCollector {
|
|
92
|
+
increment(metric: string, labels?: Record<string, string>): void;
|
|
93
|
+
histogram(metric: string, value: number, labels?: Record<string, string>): void;
|
|
94
|
+
gauge(metric: string, value: number, labels?: Record<string, string>): void;
|
|
95
|
+
}
|
|
96
|
+
export interface PluginStorage {
|
|
97
|
+
get(key: string): Promise<any>;
|
|
98
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
99
|
+
delete(key: string): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
import type { AnalyticsService, BalanceService, HistoryService, MessagingService, SchedulingService, TemplatingService, WebhookService } from "./services";
|
|
102
|
+
export interface ProviderImplementation {
|
|
103
|
+
messaging: MessagingService;
|
|
104
|
+
scheduling?: SchedulingService;
|
|
105
|
+
templating?: TemplatingService;
|
|
106
|
+
analytics?: AnalyticsService;
|
|
107
|
+
webhooks?: WebhookService;
|
|
108
|
+
balance?: BalanceService;
|
|
109
|
+
history?: HistoryService;
|
|
110
|
+
}
|
|
111
|
+
export interface ProviderMiddleware {
|
|
112
|
+
name: string;
|
|
113
|
+
pre?: (context: MiddlewareContext) => Promise<void>;
|
|
114
|
+
post?: (context: MiddlewareContext) => Promise<void>;
|
|
115
|
+
error?: (error: Error, context: MiddlewareContext) => Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
export interface MiddlewareContext {
|
|
118
|
+
request: any;
|
|
119
|
+
response?: any;
|
|
120
|
+
metadata: Record<string, any>;
|
|
121
|
+
startTime: number;
|
|
122
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
export interface MessagingService {
|
|
2
|
+
sendMessage(params: SendMessageParams): Promise<SendMessageResult>;
|
|
3
|
+
sendBulk(params: BulkMessageParams): Promise<BulkMessageResult>;
|
|
4
|
+
getDeliveryStatus?(messageId: string): Promise<DeliveryStatus>;
|
|
5
|
+
}
|
|
6
|
+
export interface SchedulingService {
|
|
7
|
+
schedule(params: ScheduleMessageParams): Promise<ScheduleResult>;
|
|
8
|
+
cancelSchedule(params: CancelScheduleParams): Promise<void>;
|
|
9
|
+
modifySchedule?(params: ModifyScheduleParams): Promise<ScheduleResult>;
|
|
10
|
+
}
|
|
11
|
+
export interface TemplatingService {
|
|
12
|
+
createTemplate(params: TemplateParams): Promise<Template>;
|
|
13
|
+
updateTemplate(templateId: string, params: TemplateParams): Promise<Template>;
|
|
14
|
+
deleteTemplate(templateId: string): Promise<void>;
|
|
15
|
+
getTemplate(templateId: string): Promise<Template>;
|
|
16
|
+
listTemplates(params?: ListTemplatesParams): Promise<TemplateList>;
|
|
17
|
+
validateTemplate(params: TemplateParams): Promise<ValidationResult>;
|
|
18
|
+
}
|
|
19
|
+
export interface AnalyticsService {
|
|
20
|
+
getStats(params: AnalyticsParams): Promise<AnalyticsData>;
|
|
21
|
+
getDeliveryReport(messageId: string): Promise<DeliveryReport>;
|
|
22
|
+
}
|
|
23
|
+
export interface WebhookService {
|
|
24
|
+
registerWebhook(params: WebhookParams): Promise<WebhookRegistration>;
|
|
25
|
+
updateWebhook(webhookId: string, params: WebhookParams): Promise<WebhookRegistration>;
|
|
26
|
+
deleteWebhook(webhookId: string): Promise<void>;
|
|
27
|
+
listWebhooks(): Promise<WebhookRegistration[]>;
|
|
28
|
+
}
|
|
29
|
+
export interface BalanceService {
|
|
30
|
+
getBalance(): Promise<BalanceInfo>;
|
|
31
|
+
getRate?(): Promise<RateInfo>;
|
|
32
|
+
}
|
|
33
|
+
export interface HistoryService {
|
|
34
|
+
getHistory(params: HistoryParams): Promise<HistoryList>;
|
|
35
|
+
getMessageDetail(messageId: string): Promise<MessageDetail>;
|
|
36
|
+
}
|
|
37
|
+
export interface SendMessageParams {
|
|
38
|
+
to: string;
|
|
39
|
+
templateId?: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
variables?: Record<string, string>;
|
|
42
|
+
resend?: ResendConfig;
|
|
43
|
+
}
|
|
44
|
+
export interface BulkMessageParams {
|
|
45
|
+
templateId: string;
|
|
46
|
+
messages: Array<{
|
|
47
|
+
to: string;
|
|
48
|
+
variables?: Record<string, string>;
|
|
49
|
+
}>;
|
|
50
|
+
resend?: ResendConfig;
|
|
51
|
+
}
|
|
52
|
+
export interface ResendConfig {
|
|
53
|
+
from: string;
|
|
54
|
+
content?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface SendMessageResult {
|
|
58
|
+
messageId: string;
|
|
59
|
+
status: "SUCCESS" | "FAILED" | "PENDING";
|
|
60
|
+
statusCode?: string;
|
|
61
|
+
remainingBalance?: number;
|
|
62
|
+
creditsUsed?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface BulkMessageResult {
|
|
65
|
+
messageIds: string[];
|
|
66
|
+
successCount: number;
|
|
67
|
+
failureCount: number;
|
|
68
|
+
results: Array<{
|
|
69
|
+
status: "SUCCESS" | "FAILED";
|
|
70
|
+
statusCode?: string;
|
|
71
|
+
messageId?: string;
|
|
72
|
+
}>;
|
|
73
|
+
remainingBalance?: number;
|
|
74
|
+
creditsUsed?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface ScheduleMessageParams {
|
|
77
|
+
templateId: string;
|
|
78
|
+
messages: Array<{
|
|
79
|
+
to: string;
|
|
80
|
+
variables?: Record<string, string>;
|
|
81
|
+
}>;
|
|
82
|
+
scheduledAt: Date;
|
|
83
|
+
resend?: ResendConfig;
|
|
84
|
+
}
|
|
85
|
+
export interface ScheduleResult {
|
|
86
|
+
scheduleId: string;
|
|
87
|
+
scheduledAt: Date;
|
|
88
|
+
messageCount: number;
|
|
89
|
+
}
|
|
90
|
+
export interface CancelScheduleParams {
|
|
91
|
+
scheduleId: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ModifyScheduleParams {
|
|
94
|
+
scheduleId: string;
|
|
95
|
+
scheduledAt?: Date;
|
|
96
|
+
messages?: Array<{
|
|
97
|
+
to: string;
|
|
98
|
+
variables?: Record<string, string>;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
export interface TemplateParams {
|
|
102
|
+
name: string;
|
|
103
|
+
content: string;
|
|
104
|
+
variables?: string[];
|
|
105
|
+
buttons?: TemplateButton[];
|
|
106
|
+
}
|
|
107
|
+
export interface TemplateButton {
|
|
108
|
+
type: string;
|
|
109
|
+
name: string;
|
|
110
|
+
linkMobile?: string;
|
|
111
|
+
linkPc?: string;
|
|
112
|
+
linkIos?: string;
|
|
113
|
+
linkAndroid?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface Template {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
content: string;
|
|
119
|
+
status: "ACTIVE" | "PENDING" | "REJECTED";
|
|
120
|
+
variables: string[];
|
|
121
|
+
buttons?: TemplateButton[];
|
|
122
|
+
createdAt: Date;
|
|
123
|
+
updatedAt: Date;
|
|
124
|
+
}
|
|
125
|
+
export interface ListTemplatesParams {
|
|
126
|
+
page?: number;
|
|
127
|
+
pageSize?: number;
|
|
128
|
+
templateCode?: string;
|
|
129
|
+
templateName?: string;
|
|
130
|
+
status?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface TemplateList {
|
|
133
|
+
items: Template[];
|
|
134
|
+
totalCount: number;
|
|
135
|
+
currentPage: number;
|
|
136
|
+
totalPages: number;
|
|
137
|
+
}
|
|
138
|
+
export interface ValidationResult {
|
|
139
|
+
valid: boolean;
|
|
140
|
+
errors?: string[];
|
|
141
|
+
}
|
|
142
|
+
export interface DeliveryStatus {
|
|
143
|
+
messageId: string;
|
|
144
|
+
status: "PENDING" | "SENT" | "DELIVERED" | "FAILED" | "EXPIRED";
|
|
145
|
+
sentAt?: Date;
|
|
146
|
+
deliveredAt?: Date;
|
|
147
|
+
failureReason?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface AnalyticsParams {
|
|
150
|
+
startDate: Date;
|
|
151
|
+
endDate: Date;
|
|
152
|
+
templateIds?: string[];
|
|
153
|
+
metrics?: string[];
|
|
154
|
+
}
|
|
155
|
+
export interface AnalyticsData {
|
|
156
|
+
sent: number;
|
|
157
|
+
delivered: number;
|
|
158
|
+
failed: number;
|
|
159
|
+
deliveryRate: number;
|
|
160
|
+
templateStats?: Record<string, any>;
|
|
161
|
+
}
|
|
162
|
+
export interface DeliveryReport {
|
|
163
|
+
messageId: string;
|
|
164
|
+
templateId?: string;
|
|
165
|
+
recipient: string;
|
|
166
|
+
status: string;
|
|
167
|
+
sentAt: Date;
|
|
168
|
+
deliveredAt?: Date;
|
|
169
|
+
events: Array<{
|
|
170
|
+
timestamp: Date;
|
|
171
|
+
event: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
export interface WebhookParams {
|
|
176
|
+
url: string;
|
|
177
|
+
events: string[];
|
|
178
|
+
secretKey?: string;
|
|
179
|
+
}
|
|
180
|
+
export interface WebhookRegistration {
|
|
181
|
+
id: string;
|
|
182
|
+
url: string;
|
|
183
|
+
events: string[];
|
|
184
|
+
isActive: boolean;
|
|
185
|
+
createdAt: Date;
|
|
186
|
+
}
|
|
187
|
+
export interface BalanceInfo {
|
|
188
|
+
amount: number;
|
|
189
|
+
currency: string;
|
|
190
|
+
lastUpdated: Date;
|
|
191
|
+
}
|
|
192
|
+
export interface RateInfo {
|
|
193
|
+
messageRate: number;
|
|
194
|
+
currency: string;
|
|
195
|
+
unit: string;
|
|
196
|
+
}
|
|
197
|
+
export interface HistoryParams {
|
|
198
|
+
startDate?: Date;
|
|
199
|
+
endDate?: Date;
|
|
200
|
+
phoneNumber?: string;
|
|
201
|
+
templateId?: string;
|
|
202
|
+
status?: string;
|
|
203
|
+
page?: number;
|
|
204
|
+
pageSize?: number;
|
|
205
|
+
}
|
|
206
|
+
export interface HistoryList {
|
|
207
|
+
items: MessageDetail[];
|
|
208
|
+
totalCount: number;
|
|
209
|
+
currentPage: number;
|
|
210
|
+
totalPages: number;
|
|
211
|
+
}
|
|
212
|
+
export interface MessageDetail {
|
|
213
|
+
messageId: string;
|
|
214
|
+
phoneNumber: string;
|
|
215
|
+
templateId?: string;
|
|
216
|
+
content: string;
|
|
217
|
+
status: string;
|
|
218
|
+
sentAt: Date;
|
|
219
|
+
deliveredAt?: Date;
|
|
220
|
+
failureReason?: string;
|
|
221
|
+
creditsUsed: number;
|
|
222
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Account Contract Implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { AccountContract, AccountProfile, Balance } from "../../contracts/provider.contract";
|
|
5
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
6
|
+
export declare class IWINVAccountContract implements AccountContract {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IWINVConfig);
|
|
9
|
+
getBalance(): Promise<Balance>;
|
|
10
|
+
getProfile(): Promise<AccountProfile>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Analytics Contract Implementation
|
|
3
|
+
*/
|
|
4
|
+
import { type AnalyticsContract, type DateRange, type DeliveryReport, type TemplateStats, type UsageStats } from "../../contracts/provider.contract";
|
|
5
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
6
|
+
export declare class IWINVAnalyticsContract implements AnalyticsContract {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IWINVConfig);
|
|
9
|
+
getUsage(period: DateRange): Promise<UsageStats>;
|
|
10
|
+
getTemplateStats(templateId: string, period: DateRange): Promise<TemplateStats>;
|
|
11
|
+
getDeliveryReport(messageId: string): Promise<DeliveryReport>;
|
|
12
|
+
private groupByTemplate;
|
|
13
|
+
private groupByDay;
|
|
14
|
+
private groupByHour;
|
|
15
|
+
private mapStatus;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Channel Contract Implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { Channel, ChannelContract, ChannelRequest, SenderNumber } from "../../contracts/provider.contract";
|
|
5
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
6
|
+
export declare class IWINVChannelContract implements ChannelContract {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IWINVConfig);
|
|
9
|
+
register(channel: ChannelRequest): Promise<Channel>;
|
|
10
|
+
list(): Promise<Channel[]>;
|
|
11
|
+
private getDefaultChannel;
|
|
12
|
+
addSenderNumber(channelId: string, number: string): Promise<SenderNumber>;
|
|
13
|
+
verifySenderNumber(number: string, verificationCode: string): Promise<boolean>;
|
|
14
|
+
private mapPlusFriendStatus;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Messaging Contract Implementation
|
|
3
|
+
*/
|
|
4
|
+
import { MessageStatus, type MessagingContract, type ProviderBulkResult, type ProviderMessageRequest, type ProviderMessageResult, type ScheduleResult } from "../../contracts/provider.contract";
|
|
5
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
6
|
+
export declare class IWINVMessagingContract implements MessagingContract {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IWINVConfig);
|
|
9
|
+
send(message: ProviderMessageRequest): Promise<ProviderMessageResult>;
|
|
10
|
+
sendBulk(messages: ProviderMessageRequest[]): Promise<ProviderBulkResult>;
|
|
11
|
+
schedule(message: ProviderMessageRequest, scheduledAt: Date): Promise<ScheduleResult>;
|
|
12
|
+
cancel(messageId: string): Promise<void>;
|
|
13
|
+
getStatus(messageId: string): Promise<MessageStatus>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type BulkSMSResult, type ScheduleResult, type SMSAccountContract, type SMSAccountProfile, type SMSBalance, type SMSContract, type SMSResult, type SMSSenderNumber, type SMSSendRequest, SMSStatus } from "../../contracts/sms.contract";
|
|
2
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
3
|
+
export declare class IWINVSMSContract implements SMSContract {
|
|
4
|
+
private config;
|
|
5
|
+
constructor(config: IWINVConfig);
|
|
6
|
+
send(request: SMSSendRequest): Promise<SMSResult>;
|
|
7
|
+
sendBulk(requests: SMSSendRequest[]): Promise<BulkSMSResult>;
|
|
8
|
+
schedule(request: SMSSendRequest, scheduledAt: Date): Promise<ScheduleResult>;
|
|
9
|
+
cancel(messageId: string): Promise<void>;
|
|
10
|
+
getStatus(messageId: string): Promise<SMSStatus>;
|
|
11
|
+
private determineMessageType;
|
|
12
|
+
private getDefaultSenderNumber;
|
|
13
|
+
private formatDate;
|
|
14
|
+
private mapIWINVStatusToDeliveryStatus;
|
|
15
|
+
private mapIWINVStatusToSMSStatus;
|
|
16
|
+
private isRetryableError;
|
|
17
|
+
private formatDateForHistory;
|
|
18
|
+
private generateMessageId;
|
|
19
|
+
private generateRequestId;
|
|
20
|
+
private generateScheduleId;
|
|
21
|
+
private makeRequest;
|
|
22
|
+
}
|
|
23
|
+
export declare class IWINVSMSAccountContract implements SMSAccountContract {
|
|
24
|
+
private config;
|
|
25
|
+
constructor(config: IWINVConfig);
|
|
26
|
+
getBalance(): Promise<SMSBalance>;
|
|
27
|
+
getProfile(): Promise<SMSAccountProfile>;
|
|
28
|
+
getSenderNumbers(): Promise<SMSSenderNumber[]>;
|
|
29
|
+
addSenderNumber(phoneNumber: string): Promise<SMSSenderNumber>;
|
|
30
|
+
verifySenderNumber(phoneNumber: string, verificationCode: string): Promise<boolean>;
|
|
31
|
+
private mapSenderStatus;
|
|
32
|
+
private makeRequest;
|
|
33
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Template Contract Implementation
|
|
3
|
+
*/
|
|
4
|
+
import { type ProviderTemplate, type SyncResult, type TemplateContract, type TemplateCreateRequest, type TemplateCreateResult, type TemplateFilters, type TemplateUpdateRequest, type TemplateUpdateResult } from "../../contracts/provider.contract";
|
|
5
|
+
import type { IWINVConfig } from "../types/iwinv";
|
|
6
|
+
export declare class IWINVTemplateContract implements TemplateContract {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: IWINVConfig);
|
|
9
|
+
create(template: TemplateCreateRequest): Promise<TemplateCreateResult>;
|
|
10
|
+
update(templateId: string, template: TemplateUpdateRequest): Promise<TemplateUpdateResult>;
|
|
11
|
+
delete(templateId: string): Promise<void>;
|
|
12
|
+
get(templateId: string): Promise<ProviderTemplate>;
|
|
13
|
+
list(filters?: TemplateFilters): Promise<ProviderTemplate[]>;
|
|
14
|
+
sync(): Promise<SyncResult>;
|
|
15
|
+
private mapIWINVTemplateStatus;
|
|
16
|
+
private applyFilters;
|
|
17
|
+
private mapIWINVStatus;
|
|
18
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV Multi Provider - New Adapter Pattern Implementation
|
|
3
|
+
* 새 어댑터 패턴을 사용한 IWINV 다중 프로바이더 구현
|
|
4
|
+
*/
|
|
5
|
+
import { IWINVProvider } from "./provider";
|
|
6
|
+
import { IWINVSMSProvider } from "./provider-sms";
|
|
7
|
+
import type { IWINVConfig } from "./types/iwinv";
|
|
8
|
+
/**
|
|
9
|
+
* AlimTalk과 SMS를 모두 지원하는 통합 IWINV 프로바이더
|
|
10
|
+
*/
|
|
11
|
+
export declare class IWINVMultiProvider {
|
|
12
|
+
private alimtalkProvider;
|
|
13
|
+
private smsProvider;
|
|
14
|
+
private config;
|
|
15
|
+
constructor(config: IWINVConfig);
|
|
16
|
+
get id(): string;
|
|
17
|
+
get name(): string;
|
|
18
|
+
get version(): string;
|
|
19
|
+
get type(): "messaging";
|
|
20
|
+
/**
|
|
21
|
+
* AlimTalk 프로바이더 인스턴스 반환
|
|
22
|
+
*/
|
|
23
|
+
getAlimTalkProvider(): IWINVProvider;
|
|
24
|
+
/**
|
|
25
|
+
* SMS 프로바이더 인스턴스 반환
|
|
26
|
+
*/
|
|
27
|
+
getSMSProvider(): IWINVSMSProvider;
|
|
28
|
+
/**
|
|
29
|
+
* 채널 타입에 따른 자동 라우팅 전송
|
|
30
|
+
*/
|
|
31
|
+
send(request: any & {
|
|
32
|
+
channel?: "alimtalk" | "sms" | "auto";
|
|
33
|
+
}): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* AlimTalk 전송 (템플릿 기반)
|
|
36
|
+
*/
|
|
37
|
+
sendAlimTalk(templateId: string, to: string, variables: Record<string, string>, options?: {
|
|
38
|
+
scheduledAt?: Date;
|
|
39
|
+
senderNumber?: string;
|
|
40
|
+
priority?: "high" | "normal" | "low";
|
|
41
|
+
}): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* SMS 전송 (직접 메시지)
|
|
44
|
+
*/
|
|
45
|
+
sendSMS(phoneNumber: string, message: string, options?: {
|
|
46
|
+
senderNumber?: string;
|
|
47
|
+
scheduledAt?: Date;
|
|
48
|
+
priority?: "high" | "normal" | "low";
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
/**
|
|
51
|
+
* LMS 전송 (긴 메시지)
|
|
52
|
+
*/
|
|
53
|
+
sendLMS(phoneNumber: string, subject: string, message: string, options?: {
|
|
54
|
+
senderNumber?: string;
|
|
55
|
+
scheduledAt?: Date;
|
|
56
|
+
priority?: "high" | "normal" | "low";
|
|
57
|
+
}): Promise<any>;
|
|
58
|
+
/**
|
|
59
|
+
* 폴백 전송 (AlimTalk 실패 시 SMS로 자동 전환)
|
|
60
|
+
*/
|
|
61
|
+
sendWithFallback(request: {
|
|
62
|
+
templateCode: string;
|
|
63
|
+
phoneNumber: string;
|
|
64
|
+
variables: Record<string, string>;
|
|
65
|
+
fallbackMessage?: string;
|
|
66
|
+
options?: {
|
|
67
|
+
scheduledAt?: Date;
|
|
68
|
+
senderNumber?: string;
|
|
69
|
+
priority?: "high" | "normal" | "low";
|
|
70
|
+
};
|
|
71
|
+
}): Promise<any & {
|
|
72
|
+
channel: "alimtalk" | "sms";
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* 대량 전송 (채널 자동 선택)
|
|
76
|
+
*/
|
|
77
|
+
sendBulk(requests: Array<any & {
|
|
78
|
+
channel?: "alimtalk" | "sms" | "auto";
|
|
79
|
+
}>, options?: {
|
|
80
|
+
batchSize?: number;
|
|
81
|
+
concurrency?: number;
|
|
82
|
+
}): Promise<any[]>;
|
|
83
|
+
/**
|
|
84
|
+
* 헬스체크 (두 프로바이더 모두 확인)
|
|
85
|
+
*/
|
|
86
|
+
healthCheck(): Promise<{
|
|
87
|
+
healthy: boolean;
|
|
88
|
+
issues: string[];
|
|
89
|
+
data: {
|
|
90
|
+
alimtalk: import("@k-msg/core").ProviderHealthStatus | null;
|
|
91
|
+
sms: import("@k-msg/core").ProviderHealthStatus | null;
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* 지원 기능 목록
|
|
96
|
+
*/
|
|
97
|
+
getSupportedFeatures(): string[];
|
|
98
|
+
/**
|
|
99
|
+
* 설정 정보
|
|
100
|
+
*/
|
|
101
|
+
getCapabilities(): {
|
|
102
|
+
channels: string[];
|
|
103
|
+
maxRecipientsPerRequest: number;
|
|
104
|
+
maxRequestsPerSecond: number;
|
|
105
|
+
supportsBulk: boolean;
|
|
106
|
+
supportsScheduling: boolean;
|
|
107
|
+
supportsTemplating: boolean;
|
|
108
|
+
supportsAutoFallback: boolean;
|
|
109
|
+
supportsWebhooks: boolean;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Multi Provider 팩토리 함수들
|
|
114
|
+
*/
|
|
115
|
+
export declare const createIWINVMultiProvider: (config: IWINVConfig) => IWINVMultiProvider;
|
|
116
|
+
export declare const createDefaultIWINVMultiProvider: () => IWINVMultiProvider;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IWINV SMS Provider - New Adapter Pattern Implementation
|
|
3
|
+
* 새 어댑터 패턴을 사용한 IWINV SMS 프로바이더 구현
|
|
4
|
+
*/
|
|
5
|
+
import { IWINVProvider } from "./provider";
|
|
6
|
+
import type { IWINVConfig } from "./types/iwinv";
|
|
7
|
+
/**
|
|
8
|
+
* SMS 특화 IWINV 프로바이더
|
|
9
|
+
* 새 어댑터 패턴 기반으로 SMS 기능에 최적화
|
|
10
|
+
*/
|
|
11
|
+
export declare class IWINVSMSProvider extends IWINVProvider {
|
|
12
|
+
constructor(config: IWINVConfig);
|
|
13
|
+
/**
|
|
14
|
+
* SMS 전송 (표준 인터페이스 사용)
|
|
15
|
+
*/
|
|
16
|
+
sendSMS(phoneNumber: string, message: string, options?: {
|
|
17
|
+
senderNumber?: string;
|
|
18
|
+
scheduledAt?: Date;
|
|
19
|
+
priority?: "high" | "normal" | "low";
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* LMS 전송 (긴 문자 메시지)
|
|
23
|
+
*/
|
|
24
|
+
sendLMS(phoneNumber: string, subject: string, message: string, options?: {
|
|
25
|
+
senderNumber?: string;
|
|
26
|
+
scheduledAt?: Date;
|
|
27
|
+
priority?: "high" | "normal" | "low";
|
|
28
|
+
}): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* 대량 SMS 전송
|
|
31
|
+
*/
|
|
32
|
+
sendBulkSMS(recipients: Array<{
|
|
33
|
+
phoneNumber: string;
|
|
34
|
+
message: string;
|
|
35
|
+
variables?: Record<string, string>;
|
|
36
|
+
}>, options?: {
|
|
37
|
+
senderNumber?: string;
|
|
38
|
+
scheduledAt?: Date;
|
|
39
|
+
batchSize?: number;
|
|
40
|
+
}): Promise<(PromiseRejectedResult | PromiseFulfilledResult<any>)[]>;
|
|
41
|
+
/**
|
|
42
|
+
* SMS/LMS 자동 판별 전송
|
|
43
|
+
*/
|
|
44
|
+
sendMessage(phoneNumber: string, message: string, options?: {
|
|
45
|
+
senderNumber?: string;
|
|
46
|
+
scheduledAt?: Date;
|
|
47
|
+
subject?: string;
|
|
48
|
+
priority?: "high" | "normal" | "low";
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* SMS Provider 팩토리 함수들
|
|
53
|
+
*/
|
|
54
|
+
export declare const createIWINVSMSProvider: (config: IWINVConfig) => IWINVSMSProvider;
|
|
55
|
+
export declare const createDefaultIWINVSMSProvider: () => IWINVSMSProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type SendOptions, type StandardRequest, UniversalProvider } from "@k-msg/core";
|
|
2
|
+
import type { IWINVConfig } from "./types/iwinv";
|
|
3
|
+
export declare class IWINVProvider extends UniversalProvider {
|
|
4
|
+
private static readonly directSmsTemplates;
|
|
5
|
+
private readonly iwinvConfig;
|
|
6
|
+
constructor(config: IWINVConfig);
|
|
7
|
+
send(params: SendOptions | StandardRequest | any): Promise<any>;
|
|
8
|
+
private isStandardRequest;
|
|
9
|
+
private isSmsChannelRequest;
|
|
10
|
+
private resolveSmsBaseUrl;
|
|
11
|
+
private isLongMessage;
|
|
12
|
+
private resolveSmsMessageType;
|
|
13
|
+
private extractMessageText;
|
|
14
|
+
private formatSmsReserveDate;
|
|
15
|
+
private normalizePhoneNumber;
|
|
16
|
+
private buildSmsSecretHeader;
|
|
17
|
+
private buildLmsTitle;
|
|
18
|
+
private mapSmsResponseMessage;
|
|
19
|
+
private mapSmsErrorCode;
|
|
20
|
+
private isSmsRetryableCode;
|
|
21
|
+
private normalizeCode;
|
|
22
|
+
private extractProviderCode;
|
|
23
|
+
private isIpRestrictionResult;
|
|
24
|
+
private getIpRetryCount;
|
|
25
|
+
private getIpRetryDelayMs;
|
|
26
|
+
private wait;
|
|
27
|
+
private emitIpRestrictionAlert;
|
|
28
|
+
private addIpRetryMetadata;
|
|
29
|
+
private sendWithIpRetry;
|
|
30
|
+
private sendSmsRequestOnce;
|
|
31
|
+
}
|
|
32
|
+
export declare const createIWINVProvider: (config: IWINVConfig) => IWINVProvider;
|
|
33
|
+
export declare const createDefaultIWINVProvider: () => IWINVProvider;
|
|
34
|
+
export declare class IWINVProviderFactory {
|
|
35
|
+
static create(config: IWINVConfig): IWINVProvider;
|
|
36
|
+
static createDefault(): IWINVProvider;
|
|
37
|
+
static getInstance(): {
|
|
38
|
+
createProvider: (config: IWINVConfig) => IWINVProvider;
|
|
39
|
+
initialize: () => void;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare function initializeIWINV(): void;
|