@k-msg/messaging 0.4.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.
- package/README.md +72 -46
- package/dist/delivery/tracker.d.ts +2 -2
- package/dist/index.js +28 -28
- package/dist/index.js.map +11 -13
- package/dist/index.mjs +28 -28
- package/dist/index.mjs.map +11 -13
- package/dist/k-msg.d.ts +59 -4
- package/dist/queue/retry.handler.d.ts +1 -1
- package/dist/types/message.types.d.ts +5 -5
- package/package.json +4 -4
package/dist/k-msg.d.ts
CHANGED
|
@@ -1,8 +1,63 @@
|
|
|
1
|
-
import { KMsgError, type Provider, type Result, type
|
|
1
|
+
import { KMsgError, type MessageType, type Provider, type ProviderHealthStatus, type Result, type SendInput, type SendResult } from "@k-msg/core";
|
|
2
2
|
import type { KMsgHooks } from "./hooks";
|
|
3
|
+
export type RoutingStrategy = "first" | "round_robin";
|
|
4
|
+
export interface KMsgRoutingConfig {
|
|
5
|
+
byType?: Partial<Record<MessageType, string | string[]>>;
|
|
6
|
+
defaultProviderId?: string;
|
|
7
|
+
strategy?: RoutingStrategy;
|
|
8
|
+
}
|
|
9
|
+
export interface KMsgDefaultsConfig {
|
|
10
|
+
from?: string;
|
|
11
|
+
sms?: {
|
|
12
|
+
/**
|
|
13
|
+
* If type is omitted (SMS default input), upgrade to LMS when estimated bytes exceed this value.
|
|
14
|
+
* Default: 90
|
|
15
|
+
*/
|
|
16
|
+
autoLmsBytes?: number;
|
|
17
|
+
};
|
|
18
|
+
kakao?: {
|
|
19
|
+
profileId?: string;
|
|
20
|
+
};
|
|
21
|
+
naver?: {
|
|
22
|
+
talkId?: string;
|
|
23
|
+
};
|
|
24
|
+
rcs?: {
|
|
25
|
+
brandId?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface KMsgConfig {
|
|
29
|
+
providers: Provider[];
|
|
30
|
+
routing?: KMsgRoutingConfig;
|
|
31
|
+
defaults?: KMsgDefaultsConfig;
|
|
32
|
+
hooks?: KMsgHooks;
|
|
33
|
+
}
|
|
3
34
|
export declare class KMsg {
|
|
4
|
-
private readonly
|
|
35
|
+
private readonly providers;
|
|
36
|
+
private readonly providersById;
|
|
5
37
|
private readonly hooks;
|
|
6
|
-
|
|
7
|
-
|
|
38
|
+
private readonly routing;
|
|
39
|
+
private readonly defaults;
|
|
40
|
+
private readonly rrIndexByKey;
|
|
41
|
+
constructor(config: KMsgConfig);
|
|
42
|
+
healthCheck(): Promise<{
|
|
43
|
+
healthy: boolean;
|
|
44
|
+
providers: Record<string, ProviderHealthStatus>;
|
|
45
|
+
issues: string[];
|
|
46
|
+
}>;
|
|
47
|
+
send(input: SendInput): Promise<Result<SendResult, KMsgError>>;
|
|
48
|
+
sendOrThrow(input: SendInput): Promise<SendResult>;
|
|
49
|
+
sendMany(inputs: SendInput[], options?: {
|
|
50
|
+
concurrency?: number;
|
|
51
|
+
stopOnFailure?: boolean;
|
|
52
|
+
}): Promise<Array<Result<SendResult, KMsgError>>>;
|
|
53
|
+
private toKMsgError;
|
|
54
|
+
private selectProvider;
|
|
55
|
+
private pickRoundRobin;
|
|
56
|
+
private normalizeInput;
|
|
57
|
+
private applyDefaults;
|
|
58
|
+
private coerceVariables;
|
|
59
|
+
private interpolateText;
|
|
60
|
+
private interpolateTextOptions;
|
|
61
|
+
private stringifyVariables;
|
|
62
|
+
private estimateBytes;
|
|
8
63
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RetryOptions } from "@k-msg/core";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
export interface MessageRequest {
|
|
4
|
-
|
|
4
|
+
templateCode: string;
|
|
5
5
|
recipients: Recipient[];
|
|
6
6
|
variables: VariableMap;
|
|
7
7
|
scheduling?: SchedulingOptions;
|
|
@@ -49,7 +49,7 @@ export interface MessageResult {
|
|
|
49
49
|
metadata: {
|
|
50
50
|
createdAt: Date;
|
|
51
51
|
provider: string;
|
|
52
|
-
|
|
52
|
+
templateCode: string;
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
export interface RecipientResult {
|
|
@@ -93,7 +93,7 @@ export interface DeliveryAttempt {
|
|
|
93
93
|
provider: string;
|
|
94
94
|
}
|
|
95
95
|
export interface BulkMessageRequest {
|
|
96
|
-
|
|
96
|
+
templateCode: string;
|
|
97
97
|
recipients: BulkRecipient[];
|
|
98
98
|
commonVariables?: VariableMap;
|
|
99
99
|
options?: BulkSendingOptions;
|
|
@@ -197,7 +197,7 @@ export declare const SendingOptionsSchema: z.ZodObject<{
|
|
|
197
197
|
}, z.core.$strip>>;
|
|
198
198
|
}, z.core.$strip>;
|
|
199
199
|
export declare const MessageRequestSchema: z.ZodObject<{
|
|
200
|
-
|
|
200
|
+
templateCode: z.ZodString;
|
|
201
201
|
recipients: z.ZodArray<z.ZodObject<{
|
|
202
202
|
phoneNumber: z.ZodString;
|
|
203
203
|
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodDate]>>>;
|
|
@@ -272,7 +272,7 @@ export declare const MessageResultSchema: z.ZodObject<{
|
|
|
272
272
|
metadata: z.ZodObject<{
|
|
273
273
|
createdAt: z.ZodDate;
|
|
274
274
|
provider: z.ZodString;
|
|
275
|
-
|
|
275
|
+
templateCode: z.ZodString;
|
|
276
276
|
}, z.core.$strip>;
|
|
277
277
|
}, z.core.$strip>;
|
|
278
278
|
export type MessageRequestType = z.infer<typeof MessageRequestSchema>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/messaging",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"description": "AlimTalk messaging core for sending, queuing, and tracking messages",
|
|
6
6
|
"type": "module",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"zod": "^4.0.14",
|
|
33
|
-
"@k-msg/core": "0.
|
|
34
|
-
"@k-msg/provider": "0.
|
|
35
|
-
"@k-msg/template": "0.
|
|
33
|
+
"@k-msg/core": "0.5.0",
|
|
34
|
+
"@k-msg/provider": "0.5.0",
|
|
35
|
+
"@k-msg/template": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.7.2",
|