@k-msg/provider 0.4.0 → 0.6.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 +35 -124
- package/dist/aligo/provider.d.ts +20 -9
- package/dist/index.d.ts +5 -26
- package/dist/index.js +48 -48
- package/dist/index.js.map +11 -28
- package/dist/index.mjs +48 -48
- package/dist/index.mjs.map +11 -28
- package/dist/iwinv/provider.d.ts +27 -59
- package/dist/iwinv/types/iwinv.d.ts +10 -2
- package/dist/providers/mock/mock.provider.d.ts +6 -1
- package/dist/solapi/provider.d.ts +20 -6
- package/dist/solapi/types/solapi.d.ts +10 -2
- package/package.json +2 -22
- package/dist/abstract/provider.base.d.ts +0 -108
- package/dist/adapters/aligo.adapter.d.ts +0 -50
- package/dist/adapters/iwinv.adapter.d.ts +0 -139
- package/dist/adapters/solapi.adapter.d.ts +0 -48
- package/dist/config/provider-config-v2.d.ts +0 -122
- package/dist/contracts/provider.contract.d.ts +0 -355
- package/dist/contracts/sms.contract.d.ts +0 -135
- package/dist/interfaces/index.d.ts +0 -14
- package/dist/interfaces/plugin.d.ts +0 -122
- package/dist/interfaces/services.d.ts +0 -222
- package/dist/iwinv/contracts/account.contract.d.ts +0 -11
- package/dist/iwinv/contracts/analytics.contract.d.ts +0 -16
- package/dist/iwinv/contracts/channel.contract.d.ts +0 -15
- package/dist/iwinv/contracts/messaging.contract.d.ts +0 -14
- package/dist/iwinv/contracts/sms.contract.d.ts +0 -33
- package/dist/iwinv/contracts/template.contract.d.ts +0 -18
- package/dist/iwinv/provider-multi.d.ts +0 -116
- package/dist/iwinv/provider-sms.d.ts +0 -55
- package/dist/middleware/index.d.ts +0 -27
- package/dist/mock/index.d.ts +0 -1
- package/dist/registry/index.d.ts +0 -1
- package/dist/registry/plugin-registry.d.ts +0 -15
- package/dist/services/provider.manager.d.ts +0 -24
- package/dist/services/provider.service.d.ts +0 -49
- package/dist/test-helpers.d.ts +0 -110
- package/dist/types/base.d.ts +0 -172
- package/dist/types/typed-templates.d.ts +0 -199
- package/dist/types/unified-config.d.ts +0 -197
- package/dist/types/unified-errors.d.ts +0 -225
- package/dist/utils/base-plugin.d.ts +0 -35
- package/dist/utils/index.d.ts +0 -12
- /package/dist/{types → aligo/types}/aligo.d.ts +0 -0
package/dist/iwinv/provider.d.ts
CHANGED
|
@@ -1,72 +1,40 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { IWINVConfig
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
requestNo?: string;
|
|
9
|
-
pageNum?: number;
|
|
10
|
-
pageSize?: number;
|
|
11
|
-
phone?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare class IWINVProvider extends UniversalProvider {
|
|
14
|
-
private static readonly directSmsTemplates;
|
|
15
|
-
private readonly iwinvConfig;
|
|
1
|
+
import { KMsgError, type MessageType, type Provider, type ProviderHealthStatus, type Result, type SendOptions, type SendResult } from "@k-msg/core";
|
|
2
|
+
import type { IWINVConfig } from "./types/iwinv";
|
|
3
|
+
export declare class IWINVProvider implements Provider {
|
|
4
|
+
readonly id = "iwinv";
|
|
5
|
+
readonly name = "IWINV Messaging Provider";
|
|
6
|
+
readonly supportedTypes: readonly MessageType[];
|
|
7
|
+
private readonly config;
|
|
16
8
|
constructor(config: IWINVConfig);
|
|
17
|
-
|
|
18
|
-
send(
|
|
19
|
-
/**
|
|
20
|
-
* SMS v2: 잔액(충전금) 조회
|
|
21
|
-
* - URL: POST https://sms.bizservice.iwinv.kr/api/charge/
|
|
22
|
-
* - Header: secret: base64(SMS_API_KEY&SMS_AUTH_KEY)
|
|
23
|
-
* - Body: { "version": "1.0" }
|
|
24
|
-
*/
|
|
25
|
-
getSmsCharge(): Promise<number>;
|
|
26
|
-
/**
|
|
27
|
-
* SMS v2: 전송 내역 조회
|
|
28
|
-
* - URL: POST https://sms.bizservice.iwinv.kr/api/history/
|
|
29
|
-
* - 기간은 90일 이내만 허용
|
|
30
|
-
*/
|
|
31
|
-
getSmsHistory(params: IWINVSmsHistoryParams): Promise<{
|
|
32
|
-
totalCount: number;
|
|
33
|
-
list: IWINVSmsHistoryItem[];
|
|
34
|
-
message: string;
|
|
35
|
-
}>;
|
|
36
|
-
private isStandardRequest;
|
|
37
|
-
private isSmsChannelRequest;
|
|
38
|
-
private resolveSmsBaseUrl;
|
|
39
|
-
private resolveSmsMessageType;
|
|
40
|
-
private extractMessageText;
|
|
41
|
-
private formatSmsReserveDate;
|
|
42
|
-
private formatSmsHistoryDate;
|
|
43
|
-
private assertSmsHistoryWindow;
|
|
44
|
-
private requestSmsApi;
|
|
9
|
+
healthCheck(): Promise<ProviderHealthStatus>;
|
|
10
|
+
send(options: SendOptions): Promise<Result<SendResult, KMsgError>>;
|
|
45
11
|
private normalizePhoneNumber;
|
|
12
|
+
private toBase64;
|
|
13
|
+
private isHttpUrl;
|
|
14
|
+
private guessImageContentType;
|
|
15
|
+
private resolveImageInput;
|
|
16
|
+
private toImageBlob;
|
|
17
|
+
private getSendEndpoint;
|
|
18
|
+
private getAlimTalkHeaders;
|
|
19
|
+
private formatIWINVDate;
|
|
20
|
+
private sendAlimTalk;
|
|
21
|
+
private mapIwinvCodeToKMsgErrorCode;
|
|
22
|
+
private normalizeIwinvCode;
|
|
23
|
+
private resolveSmsBaseUrl;
|
|
24
|
+
private canSendSmsV2;
|
|
46
25
|
private buildSmsSecretHeader;
|
|
47
|
-
private
|
|
26
|
+
private formatSmsReserveDate;
|
|
27
|
+
private normalizeCode;
|
|
48
28
|
private mapSmsResponseMessage;
|
|
49
29
|
private mapSmsErrorCode;
|
|
50
|
-
private
|
|
51
|
-
private
|
|
52
|
-
private
|
|
53
|
-
private isIpRestrictionResult;
|
|
54
|
-
private getIpRetryCount;
|
|
55
|
-
private getIpRetryDelayMs;
|
|
56
|
-
private wait;
|
|
57
|
-
private emitIpRestrictionAlert;
|
|
58
|
-
private addIpRetryMetadata;
|
|
59
|
-
private sendWithIpRetry;
|
|
60
|
-
private sendSmsRequestOnce;
|
|
30
|
+
private buildLmsTitle;
|
|
31
|
+
private sendSmsV2Mms;
|
|
32
|
+
private sendSmsV2;
|
|
61
33
|
}
|
|
62
34
|
export declare const createIWINVProvider: (config: IWINVConfig) => IWINVProvider;
|
|
63
35
|
export declare const createDefaultIWINVProvider: () => IWINVProvider;
|
|
64
36
|
export declare class IWINVProviderFactory {
|
|
65
37
|
static create(config: IWINVConfig): IWINVProvider;
|
|
66
38
|
static createDefault(): IWINVProvider;
|
|
67
|
-
static getInstance(): {
|
|
68
|
-
createProvider: (config: IWINVConfig) => IWINVProvider;
|
|
69
|
-
initialize: () => void;
|
|
70
|
-
};
|
|
71
39
|
}
|
|
72
40
|
export declare function initializeIWINV(): void;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* IWINV API TypeScript 타입 정의
|
|
3
3
|
* IWINV 알림톡 REST API 규격서 기반
|
|
4
4
|
*/
|
|
5
|
-
import type { ProviderConfig } from "@k-msg/core";
|
|
6
5
|
export interface IWINVBaseResponse {
|
|
7
6
|
code: number;
|
|
8
7
|
message: string;
|
|
@@ -149,7 +148,16 @@ export interface IWINVSmsHistoryResponse {
|
|
|
149
148
|
totalCount: number;
|
|
150
149
|
list: IWINVSmsHistoryItem[];
|
|
151
150
|
}
|
|
152
|
-
export interface IWINVConfig
|
|
151
|
+
export interface IWINVConfig {
|
|
152
|
+
/**
|
|
153
|
+
* IWINV AlimTalk API key (used for AUTH header).
|
|
154
|
+
*/
|
|
155
|
+
apiKey: string;
|
|
156
|
+
/**
|
|
157
|
+
* IWINV AlimTalk base URL.
|
|
158
|
+
* Default: https://alimtalk.bizservice.iwinv.kr
|
|
159
|
+
*/
|
|
160
|
+
baseUrl: string;
|
|
153
161
|
smsApiKey?: string;
|
|
154
162
|
smsAuthKey?: string;
|
|
155
163
|
smsBaseUrl?: string;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { KMsgError, type Provider, type Result, type SendOptions, type SendResult, type Template, type TemplateProvider } from "@k-msg/core";
|
|
1
|
+
import { KMsgError, type MessageType, type Provider, type Result, type SendOptions, type SendResult, type Template, type TemplateProvider } from "@k-msg/core";
|
|
2
2
|
export declare class MockProvider implements Provider, TemplateProvider {
|
|
3
3
|
readonly id = "mock";
|
|
4
4
|
readonly name = "Mock Provider";
|
|
5
|
+
readonly supportedTypes: readonly MessageType[];
|
|
5
6
|
calls: SendOptions[];
|
|
6
7
|
private failureCount;
|
|
7
8
|
private templates;
|
|
9
|
+
healthCheck(): Promise<{
|
|
10
|
+
healthy: boolean;
|
|
11
|
+
issues: never[];
|
|
12
|
+
}>;
|
|
8
13
|
send(params: SendOptions): Promise<Result<SendResult, KMsgError>>;
|
|
9
14
|
mockSuccess(): void;
|
|
10
15
|
mockFailure(count: number): void;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
1
|
+
import { KMsgError, type MessageType, type Provider, type ProviderHealthStatus, type Result, type SendOptions, type SendResult } from "@k-msg/core";
|
|
2
|
+
import { SolapiMessageService } from "solapi";
|
|
3
3
|
import type { SolapiConfig } from "./types/solapi";
|
|
4
|
-
export
|
|
4
|
+
export type SolapiSdkClient = Pick<SolapiMessageService, "sendOne" | "getMessages" | "getBalance" | "uploadFile">;
|
|
5
|
+
export declare class SolapiProvider implements Provider {
|
|
6
|
+
readonly id = "solapi";
|
|
7
|
+
readonly name = "SOLAPI Messaging Provider";
|
|
8
|
+
readonly supportedTypes: readonly MessageType[];
|
|
9
|
+
private readonly config;
|
|
10
|
+
private readonly client;
|
|
5
11
|
constructor(config: SolapiConfig, client?: SolapiSdkClient);
|
|
6
|
-
|
|
7
|
-
send(
|
|
8
|
-
|
|
12
|
+
healthCheck(): Promise<ProviderHealthStatus>;
|
|
13
|
+
send(options: SendOptions): Promise<Result<SendResult, KMsgError>>;
|
|
14
|
+
private adaptSendResult;
|
|
15
|
+
private mapError;
|
|
16
|
+
private normalizePhoneNumber;
|
|
17
|
+
private stringifyVariables;
|
|
18
|
+
private toKakaoButtons;
|
|
19
|
+
private resolveImageRef;
|
|
20
|
+
private extractFileId;
|
|
21
|
+
private toSolapiMessageType;
|
|
22
|
+
private buildSolapiSendOneMessage;
|
|
9
23
|
}
|
|
10
24
|
export declare const createSolapiProvider: (config: SolapiConfig) => SolapiProvider;
|
|
11
25
|
export declare const createDefaultSolapiProvider: () => SolapiProvider;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export interface SolapiConfig {
|
|
2
|
+
/**
|
|
3
|
+
* SOLAPI API Key
|
|
4
|
+
*/
|
|
5
|
+
apiKey: string;
|
|
3
6
|
/**
|
|
4
7
|
* SOLAPI API Secret
|
|
5
8
|
*/
|
|
@@ -28,4 +31,9 @@ export interface SolapiConfig extends ProviderConfig {
|
|
|
28
31
|
* Default country code (e.g. "82"). Optional.
|
|
29
32
|
*/
|
|
30
33
|
defaultCountry?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Base URL for SOLAPI API.
|
|
36
|
+
*/
|
|
37
|
+
baseUrl?: string;
|
|
38
|
+
debug?: boolean;
|
|
31
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Complete provider system with adapters and implementations for K-Message platform",
|
|
@@ -12,26 +12,6 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.mjs",
|
|
14
14
|
"require": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./interfaces": {
|
|
17
|
-
"types": "./dist/interfaces/index.d.ts",
|
|
18
|
-
"import": "./dist/interfaces/index.mjs",
|
|
19
|
-
"require": "./dist/interfaces/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./registry": {
|
|
22
|
-
"types": "./dist/registry/index.d.ts",
|
|
23
|
-
"import": "./dist/registry/index.mjs",
|
|
24
|
-
"require": "./dist/registry/index.js"
|
|
25
|
-
},
|
|
26
|
-
"./middleware": {
|
|
27
|
-
"types": "./dist/middleware/index.d.ts",
|
|
28
|
-
"import": "./dist/middleware/index.mjs",
|
|
29
|
-
"require": "./dist/middleware/index.js"
|
|
30
|
-
},
|
|
31
|
-
"./utils": {
|
|
32
|
-
"types": "./dist/utils/index.d.ts",
|
|
33
|
-
"import": "./dist/utils/index.mjs",
|
|
34
|
-
"require": "./dist/utils/index.js"
|
|
35
15
|
}
|
|
36
16
|
},
|
|
37
17
|
"publishConfig": {
|
|
@@ -55,7 +35,7 @@
|
|
|
55
35
|
"publish": "bun publish --access public"
|
|
56
36
|
},
|
|
57
37
|
"dependencies": {
|
|
58
|
-
"@k-msg/core": "0.
|
|
38
|
+
"@k-msg/core": "0.6.0",
|
|
59
39
|
"solapi": "^5.5.4",
|
|
60
40
|
"zod": "^4.0.14"
|
|
61
41
|
},
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { ConfigurationSchema, DeliveryStatus } from "@k-msg/core";
|
|
2
|
-
import type { AccountContract, AlimTalkProvider, AlimTalkRequest, AlimTalkResult, AnalyticsContract, ChannelContract, MessagingContract, ProviderCapabilities, ProviderConfiguration, TemplateContract } from "../contracts/provider.contract";
|
|
3
|
-
export declare abstract class BaseAlimTalkProvider implements AlimTalkProvider {
|
|
4
|
-
abstract readonly id: string;
|
|
5
|
-
abstract readonly name: string;
|
|
6
|
-
readonly type: "messaging";
|
|
7
|
-
abstract readonly version: string;
|
|
8
|
-
abstract readonly capabilities: ProviderCapabilities;
|
|
9
|
-
protected config: Record<string, unknown>;
|
|
10
|
-
protected isConfigured: boolean;
|
|
11
|
-
abstract templates: TemplateContract;
|
|
12
|
-
abstract channels: ChannelContract;
|
|
13
|
-
abstract messaging: MessagingContract;
|
|
14
|
-
abstract analytics: AnalyticsContract;
|
|
15
|
-
abstract account: AccountContract;
|
|
16
|
-
constructor(config?: Record<string, unknown>);
|
|
17
|
-
/**
|
|
18
|
-
* Configure the provider with necessary credentials and settings
|
|
19
|
-
*/
|
|
20
|
-
configure(config: Record<string, unknown>): void;
|
|
21
|
-
abstract send<T extends AlimTalkRequest = AlimTalkRequest, R extends AlimTalkResult = AlimTalkResult>(request: T): Promise<R>;
|
|
22
|
-
abstract getStatus(requestId: string): Promise<DeliveryStatus>;
|
|
23
|
-
abstract cancel?(requestId: string): Promise<boolean>;
|
|
24
|
-
abstract getSupportedFeatures(): string[];
|
|
25
|
-
abstract getConfigurationSchema(): ConfigurationSchema;
|
|
26
|
-
abstract getProviderConfiguration(): ProviderConfiguration;
|
|
27
|
-
/**
|
|
28
|
-
* Validate the provided configuration
|
|
29
|
-
*/
|
|
30
|
-
protected validateConfiguration(config: Record<string, unknown>): void;
|
|
31
|
-
private validateFieldValue;
|
|
32
|
-
/**
|
|
33
|
-
* Called after configuration is set
|
|
34
|
-
*/
|
|
35
|
-
protected onConfigured(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Check if the provider is properly configured
|
|
38
|
-
*/
|
|
39
|
-
isReady(): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Get configuration value
|
|
42
|
-
*/
|
|
43
|
-
protected getConfig<T = unknown>(key: string): T;
|
|
44
|
-
/**
|
|
45
|
-
* Check if a configuration key exists
|
|
46
|
-
*/
|
|
47
|
-
protected hasConfig(key: string): boolean;
|
|
48
|
-
getCapabilities(): ProviderCapabilities;
|
|
49
|
-
/**
|
|
50
|
-
* Perform health check on the provider
|
|
51
|
-
*/
|
|
52
|
-
healthCheck(): Promise<{
|
|
53
|
-
healthy: boolean;
|
|
54
|
-
issues: string[];
|
|
55
|
-
latency?: number;
|
|
56
|
-
}>;
|
|
57
|
-
/**
|
|
58
|
-
* Test basic connectivity to the provider
|
|
59
|
-
*/
|
|
60
|
-
protected abstract testConnectivity(): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Test authentication with the provider
|
|
63
|
-
*/
|
|
64
|
-
protected abstract testAuthentication(): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Get provider information
|
|
67
|
-
*/
|
|
68
|
-
getInfo(): {
|
|
69
|
-
id: string;
|
|
70
|
-
name: string;
|
|
71
|
-
version: string;
|
|
72
|
-
capabilities: ProviderCapabilities;
|
|
73
|
-
configured: boolean;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Get provider version
|
|
77
|
-
*/
|
|
78
|
-
protected abstract getVersion(): string;
|
|
79
|
-
/**
|
|
80
|
-
* Cleanup resources when provider is destroyed
|
|
81
|
-
*/
|
|
82
|
-
destroy(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Called when provider is being destroyed
|
|
85
|
-
*/
|
|
86
|
-
protected onDestroy(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Create standardized error
|
|
89
|
-
*/
|
|
90
|
-
protected createError(code: string, message: string, details?: Record<string, unknown>): Error;
|
|
91
|
-
/**
|
|
92
|
-
* Log provider activity
|
|
93
|
-
*/
|
|
94
|
-
protected log(level: "info" | "warn" | "error", message: string, data?: unknown): void;
|
|
95
|
-
/**
|
|
96
|
-
* Handle rate limiting
|
|
97
|
-
*/
|
|
98
|
-
protected handleRateLimit(operation: string): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Retry mechanism for failed operations
|
|
101
|
-
*/
|
|
102
|
-
protected withRetry<T>(operation: () => Promise<T>, options?: {
|
|
103
|
-
maxRetries?: number;
|
|
104
|
-
initialDelay?: number;
|
|
105
|
-
maxDelay?: number;
|
|
106
|
-
backoffFactor?: number;
|
|
107
|
-
}): Promise<T>;
|
|
108
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { BaseProviderAdapter, KMsgError, type Provider, type Result, type SendOptions, type SendResult, type StandardError, type StandardRequest, type StandardResult, type Template, type TemplateProvider } from "@k-msg/core";
|
|
2
|
-
import type { AligoConfig, AligoResponse } from "../types/aligo";
|
|
3
|
-
export declare class AligoAdapter extends BaseProviderAdapter implements Provider, TemplateProvider {
|
|
4
|
-
protected readonly aligoConfig: AligoConfig;
|
|
5
|
-
private static readonly directTemplates;
|
|
6
|
-
readonly id = "aligo";
|
|
7
|
-
readonly name = "Aligo Smart SMS";
|
|
8
|
-
private readonly SMS_HOST;
|
|
9
|
-
private readonly ALIMTALK_HOST;
|
|
10
|
-
constructor(aligoConfig: AligoConfig);
|
|
11
|
-
send(params: SendOptions): Promise<Result<SendResult, KMsgError>>;
|
|
12
|
-
sendStandard(request: StandardRequest): Promise<StandardResult>;
|
|
13
|
-
adaptRequest(request: StandardRequest): any;
|
|
14
|
-
adaptResponse(response: AligoResponse): StandardResult;
|
|
15
|
-
mapError(error: any): StandardError;
|
|
16
|
-
private mapAligoError;
|
|
17
|
-
getAuthHeaders(): Record<string, string>;
|
|
18
|
-
getBaseUrl(): string;
|
|
19
|
-
getEndpoint(operation: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Aligo 특화 기능: 잔액 조회
|
|
22
|
-
*/
|
|
23
|
-
getBalance(): Promise<number>;
|
|
24
|
-
createTemplate(template: Omit<Template, "id" | "status" | "createdAt" | "updatedAt">): Promise<Result<Template, KMsgError>>;
|
|
25
|
-
updateTemplate(_code: string, _template: Partial<Omit<Template, "id" | "code" | "status" | "createdAt" | "updatedAt">>): Promise<Result<Template, KMsgError>>;
|
|
26
|
-
deleteTemplate(code: string): Promise<Result<void, KMsgError>>;
|
|
27
|
-
getTemplate(code: string): Promise<Result<Template, KMsgError>>;
|
|
28
|
-
listTemplates(_params?: {
|
|
29
|
-
status?: string;
|
|
30
|
-
page?: number;
|
|
31
|
-
limit?: number;
|
|
32
|
-
}): Promise<Result<Template[], KMsgError>>;
|
|
33
|
-
private sendSMS;
|
|
34
|
-
private sendAlimTalk;
|
|
35
|
-
private sendFriendTalk;
|
|
36
|
-
private formatAligoDate;
|
|
37
|
-
private request;
|
|
38
|
-
private handleError;
|
|
39
|
-
private toProviderChannel;
|
|
40
|
-
private normalizeChannelLike;
|
|
41
|
-
private resolveStandardChannel;
|
|
42
|
-
private extractStandardMessage;
|
|
43
|
-
private buildSmsBodyFromStandard;
|
|
44
|
-
private isKakaoChannel;
|
|
45
|
-
private buildFriendTalkBody;
|
|
46
|
-
private buildAlimTalkBodyFromStandard;
|
|
47
|
-
private buildFriendTalkBodyFromStandard;
|
|
48
|
-
private interpolateMessage;
|
|
49
|
-
private mapTemplateStatus;
|
|
50
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IWINV Provider Adapter
|
|
3
|
-
* IWINV API를 표준 인터페이스로 변환하는 어댑터
|
|
4
|
-
*/
|
|
5
|
-
import { type AdapterFactory, BaseProviderAdapter, KMsgError, type ProviderConfig, type ProviderMetadata, type Result, type StandardError, type StandardRequest, type StandardResult, type Template, type TemplateProvider } from "@k-msg/core";
|
|
6
|
-
import type { IWINVConfig } from "../iwinv/types/iwinv";
|
|
7
|
-
export type { IWINVConfig } from "../iwinv/types/iwinv";
|
|
8
|
-
export interface IWINVError {
|
|
9
|
-
code: number;
|
|
10
|
-
message: string;
|
|
11
|
-
status?: number;
|
|
12
|
-
data?: unknown;
|
|
13
|
-
}
|
|
14
|
-
export interface IWINVRequest {
|
|
15
|
-
templateCode: string;
|
|
16
|
-
reserve?: "Y" | "N";
|
|
17
|
-
sendDate?: string;
|
|
18
|
-
reSend?: "Y" | "N";
|
|
19
|
-
resendCallback?: string;
|
|
20
|
-
resendType?: "Y" | "N";
|
|
21
|
-
resendTitle?: string;
|
|
22
|
-
resendContent?: string;
|
|
23
|
-
list: IWINVRecipient[];
|
|
24
|
-
}
|
|
25
|
-
export interface IWINVRecipient {
|
|
26
|
-
phone: string;
|
|
27
|
-
templateParam?: string[];
|
|
28
|
-
}
|
|
29
|
-
export interface IWINVResponse {
|
|
30
|
-
code: number;
|
|
31
|
-
message: string;
|
|
32
|
-
success?: number;
|
|
33
|
-
fail?: number;
|
|
34
|
-
seqNo?: number;
|
|
35
|
-
}
|
|
36
|
-
export interface IWINVBalanceResponse {
|
|
37
|
-
code: number;
|
|
38
|
-
charge: number;
|
|
39
|
-
}
|
|
40
|
-
export interface IWINVTemplate {
|
|
41
|
-
templateCode: string;
|
|
42
|
-
templateName: string;
|
|
43
|
-
templateContent: string;
|
|
44
|
-
status: "Y" | "I" | "R";
|
|
45
|
-
templateStatusMsg?: string;
|
|
46
|
-
templateStatusComments?: string;
|
|
47
|
-
createDate: string;
|
|
48
|
-
buttons: unknown[];
|
|
49
|
-
}
|
|
50
|
-
export interface IWINVTemplateListResponse extends IWINVResponse {
|
|
51
|
-
totalCount: number;
|
|
52
|
-
list: IWINVTemplate[];
|
|
53
|
-
}
|
|
54
|
-
export declare function isIWINVError(error: unknown): error is IWINVError;
|
|
55
|
-
export declare function isIWINVResponse(response: unknown): response is IWINVResponse;
|
|
56
|
-
export declare function isIWINVBalanceResponse(response: unknown): response is IWINVBalanceResponse;
|
|
57
|
-
/**
|
|
58
|
-
* IWINV API 어댑터 구현
|
|
59
|
-
*/
|
|
60
|
-
export declare class IWINVAdapter extends BaseProviderAdapter implements TemplateProvider {
|
|
61
|
-
private static readonly directTemplates;
|
|
62
|
-
private readonly endpoints;
|
|
63
|
-
constructor(config: IWINVConfig);
|
|
64
|
-
adaptRequest(request: StandardRequest): IWINVRequest;
|
|
65
|
-
adaptResponse(response: IWINVResponse): StandardResult;
|
|
66
|
-
mapError(error: IWINVError | Error | unknown): StandardError;
|
|
67
|
-
getAuthHeaders(): Record<string, string>;
|
|
68
|
-
getBaseUrl(): string;
|
|
69
|
-
getEndpoint(operation: string): string;
|
|
70
|
-
getRequestConfig(): RequestInit;
|
|
71
|
-
createTemplate(template: Omit<Template, "id" | "status" | "createdAt" | "updatedAt">): Promise<Result<Template, KMsgError>>;
|
|
72
|
-
updateTemplate(code: string, template: Partial<Omit<Template, "id" | "code" | "status" | "createdAt" | "updatedAt">>): Promise<Result<Template, KMsgError>>;
|
|
73
|
-
deleteTemplate(code: string): Promise<Result<void, KMsgError>>;
|
|
74
|
-
getTemplate(code: string): Promise<Result<Template, KMsgError>>;
|
|
75
|
-
listTemplates(params?: {
|
|
76
|
-
status?: string;
|
|
77
|
-
page?: number;
|
|
78
|
-
limit?: number;
|
|
79
|
-
}): Promise<Result<Template[], KMsgError>>;
|
|
80
|
-
private mapIWINVTemplate;
|
|
81
|
-
private mapIWINVTemplateStatus;
|
|
82
|
-
isRetryableError(error: IWINVError | Error | unknown): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* IWINV 날짜 형식으로 변환 (yyyy-MM-dd HH:mm:ss)
|
|
85
|
-
*/
|
|
86
|
-
private formatIWINVDate;
|
|
87
|
-
/**
|
|
88
|
-
* IWINV 상태 코드를 표준 상태로 매핑
|
|
89
|
-
*/
|
|
90
|
-
private mapIWINVStatus;
|
|
91
|
-
/**
|
|
92
|
-
* IWINV 특화 기능: 예약 발송 취소
|
|
93
|
-
*/
|
|
94
|
-
cancelScheduledMessage(messageId: string): Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* IWINV 특화 기능: 잔액 조회
|
|
97
|
-
*/
|
|
98
|
-
getBalance(): Promise<number>;
|
|
99
|
-
/**
|
|
100
|
-
* IWINV SMS v2: 잔액 조회
|
|
101
|
-
* - URL: POST https://sms.bizservice.iwinv.kr/api/charge/
|
|
102
|
-
* - Header: secret: base64(SMS_API_KEY&SMS_AUTH_KEY)
|
|
103
|
-
* - Body: { "version": "1.0" }
|
|
104
|
-
*/
|
|
105
|
-
getSmsCharge(): Promise<number>;
|
|
106
|
-
/**
|
|
107
|
-
* IWINV SMS v2: 전송 내역 조회
|
|
108
|
-
* - URL: POST https://sms.bizservice.iwinv.kr/api/history/
|
|
109
|
-
* - 기간은 90일 이내만 허용
|
|
110
|
-
*/
|
|
111
|
-
getSmsHistory(params: {
|
|
112
|
-
companyId?: string;
|
|
113
|
-
startDate: string | Date;
|
|
114
|
-
endDate: string | Date;
|
|
115
|
-
requestNo?: string;
|
|
116
|
-
pageNum?: number;
|
|
117
|
-
pageSize?: number;
|
|
118
|
-
phone?: string;
|
|
119
|
-
version?: string;
|
|
120
|
-
}): Promise<{
|
|
121
|
-
totalCount: number;
|
|
122
|
-
list: unknown[];
|
|
123
|
-
message: string;
|
|
124
|
-
}>;
|
|
125
|
-
private resolveSmsBaseUrl;
|
|
126
|
-
private buildSmsSecretHeader;
|
|
127
|
-
private formatSmsHistoryDate;
|
|
128
|
-
private assertSmsHistoryWindow;
|
|
129
|
-
private requestSmsApi;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* IWINV 어댑터 팩토리
|
|
133
|
-
*/
|
|
134
|
-
export declare class IWINVAdapterFactory implements AdapterFactory {
|
|
135
|
-
create(config: ProviderConfig): BaseProviderAdapter;
|
|
136
|
-
private isValidIWINVConfig;
|
|
137
|
-
supports(providerId: string): boolean;
|
|
138
|
-
getMetadata(): ProviderMetadata;
|
|
139
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { HistoryQuery, StandardError, StandardRequest, StandardResult } from "@k-msg/core";
|
|
2
|
-
import { BaseProviderAdapter } from "@k-msg/core";
|
|
3
|
-
import { SolapiMessageService } from "solapi";
|
|
4
|
-
import type { SolapiConfig } from "../solapi/types/solapi";
|
|
5
|
-
export type SolapiSdkClient = Pick<SolapiMessageService, "sendOne" | "getMessages" | "getBalance" | "uploadFile">;
|
|
6
|
-
export declare class SolapiAdapter extends BaseProviderAdapter {
|
|
7
|
-
private static readonly directTemplates;
|
|
8
|
-
private readonly solapiConfig;
|
|
9
|
-
private readonly client;
|
|
10
|
-
constructor(config: SolapiConfig, client?: SolapiSdkClient);
|
|
11
|
-
adaptRequest(request: StandardRequest): Record<string, unknown>;
|
|
12
|
-
adaptResponse(response: unknown): StandardResult;
|
|
13
|
-
mapError(error: unknown): StandardError;
|
|
14
|
-
getAuthHeaders(): Record<string, string>;
|
|
15
|
-
getBaseUrl(): string;
|
|
16
|
-
getEndpoint(_operation: string): string;
|
|
17
|
-
sendStandard(request: StandardRequest): Promise<StandardResult>;
|
|
18
|
-
getSmsCharge(): Promise<number>;
|
|
19
|
-
getBalance(): Promise<number>;
|
|
20
|
-
getSmsHistory(params: {
|
|
21
|
-
channel?: HistoryQuery["channel"];
|
|
22
|
-
startDate: string | Date;
|
|
23
|
-
endDate: string | Date;
|
|
24
|
-
requestNo?: string;
|
|
25
|
-
pageNum?: number;
|
|
26
|
-
pageSize?: number;
|
|
27
|
-
phone?: string;
|
|
28
|
-
startKey?: string;
|
|
29
|
-
}): Promise<{
|
|
30
|
-
totalCount: number;
|
|
31
|
-
list: unknown[];
|
|
32
|
-
message: string;
|
|
33
|
-
nextKey?: string | null;
|
|
34
|
-
raw?: unknown;
|
|
35
|
-
}>;
|
|
36
|
-
getHistory(query: HistoryQuery): Promise<unknown>;
|
|
37
|
-
private clampLimit;
|
|
38
|
-
private normalizePhoneNumber;
|
|
39
|
-
private toSolapiTypeFromChannel;
|
|
40
|
-
private stringifyVariables;
|
|
41
|
-
private extractText;
|
|
42
|
-
private extractSubject;
|
|
43
|
-
private resolveChannelLike;
|
|
44
|
-
private toSolapiMessageType;
|
|
45
|
-
private toKakaoButtons;
|
|
46
|
-
private toRcsButtons;
|
|
47
|
-
private buildSolapiSendOneMessage;
|
|
48
|
-
}
|