@ingestkorea/client-sens 1.10.0 → 1.11.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 +98 -57
- package/dist-cjs/SensClient.js +31 -35
- package/dist-cjs/commands/GetAlimtalkResultCommand.js +3 -0
- package/dist-cjs/commands/GetAlimtalkStatusCommand.js +8 -1
- package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +3 -0
- package/dist-cjs/commands/GetSMSResultCommand.js +3 -0
- package/dist-cjs/commands/GetSMSStatusCommand.js +8 -1
- package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +3 -0
- package/dist-cjs/commands/ListAlimtalkStatusCommand.js +17 -3
- package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +3 -0
- package/dist-cjs/commands/ListSMSStatusCommand.js +16 -3
- package/dist-cjs/commands/SendAlimtalkCommand.js +9 -1
- package/dist-cjs/commands/SendMMSCommand.js +7 -4
- package/dist-cjs/commands/SendSMSCommand.js +23 -9
- package/dist-cjs/commands/constants.js +2 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/middleware/constants.js +2 -1
- package/dist-cjs/middleware/middleware-metadata.js +7 -12
- package/dist-cjs/middleware/middleware-retry.js +37 -20
- package/dist-cjs/middleware/middleware-sign.js +8 -12
- package/dist-cjs/models/{SensErrorInfo.js → SensApiError.js} +1 -11
- package/dist-cjs/models/{SensError.js → SensClientError.js} +4 -0
- package/dist-cjs/models/SensCommand.js +1 -0
- package/dist-cjs/models/index.js +2 -2
- package/dist-cjs/protocols/GetAlimtalkResult.js +14 -17
- package/dist-cjs/protocols/GetAlimtalkStatus.js +21 -17
- package/dist-cjs/protocols/GetAlimtalkTemplate.js +29 -17
- package/dist-cjs/protocols/GetSMSResult.js +16 -17
- package/dist-cjs/protocols/GetSMSStatus.js +10 -16
- package/dist-cjs/protocols/ListAlimtalkChannels.js +10 -16
- package/dist-cjs/protocols/ListAlimtalkStatus.js +10 -16
- package/dist-cjs/protocols/ListAlimtalkTemplates.js +12 -19
- package/dist-cjs/protocols/ListSMSStatus.js +10 -16
- package/dist-cjs/protocols/SendAlimtalk.js +10 -16
- package/dist-cjs/protocols/SendMMS.js +4 -13
- package/dist-cjs/protocols/SendSMS.js +11 -17
- package/dist-cjs/protocols/constants.js +91 -75
- package/dist-es/SensClient.js +25 -22
- package/dist-es/commands/GetAlimtalkResultCommand.js +8 -9
- package/dist-es/commands/GetAlimtalkStatusCommand.js +8 -9
- package/dist-es/commands/GetAlimtalkTemplateCommand.js +8 -9
- package/dist-es/commands/GetSMSResultCommand.js +8 -9
- package/dist-es/commands/GetSMSStatusCommand.js +8 -9
- package/dist-es/commands/ListAlimtalkChannelsCommand.js +8 -9
- package/dist-es/commands/ListAlimtalkStatusCommand.js +19 -21
- package/dist-es/commands/ListAlimtalkTemplatesCommand.js +8 -9
- package/dist-es/commands/ListSMSStatusCommand.js +20 -22
- package/dist-es/commands/SendAlimtalkCommand.js +12 -13
- package/dist-es/commands/SendMMSCommand.js +28 -29
- package/dist-es/commands/SendSMSCommand.js +20 -22
- package/dist-es/commands/constants.js +12 -22
- package/dist-es/commands/index.js +12 -28
- package/dist-es/index.js +3 -19
- package/dist-es/middleware/constants.js +8 -10
- package/dist-es/middleware/index.js +3 -19
- package/dist-es/middleware/middleware-metadata.js +4 -7
- package/dist-es/middleware/middleware-retry.js +39 -19
- package/dist-es/middleware/middleware-sign.js +9 -13
- package/dist-es/models/GetAlimtalkResult.js +1 -2
- package/dist-es/models/GetAlimtalkStatus.js +1 -2
- package/dist-es/models/GetAlimtalkTemplate.js +1 -2
- package/dist-es/models/GetSMSResult.js +1 -2
- package/dist-es/models/GetSMSStatus.js +1 -2
- package/dist-es/models/ListAlimtalkChannels.js +1 -2
- package/dist-es/models/ListAlimtalkStatus.js +1 -2
- package/dist-es/models/ListAlimtalkTemplates.js +1 -2
- package/dist-es/models/ListSMSStatus.js +1 -2
- package/dist-es/models/MetadataBearer.js +1 -2
- package/dist-es/models/SendAlimtalk.js +2 -5
- package/dist-es/models/SendMMS.js +2 -5
- package/dist-es/models/SendSMS.js +1 -2
- package/dist-es/models/SensApiError.js +18 -0
- package/dist-es/models/SensClient.js +1 -2
- package/dist-es/models/{SensError.js → SensClientError.js} +5 -5
- package/dist-es/models/SensCommand.js +2 -5
- package/dist-es/models/SensMiddleware.js +1 -2
- package/dist-es/models/index.js +18 -34
- package/dist-es/protocols/GetAlimtalkResult.js +11 -16
- package/dist-es/protocols/GetAlimtalkStatus.js +17 -24
- package/dist-es/protocols/GetAlimtalkTemplate.js +12 -17
- package/dist-es/protocols/GetSMSResult.js +11 -16
- package/dist-es/protocols/GetSMSStatus.js +15 -22
- package/dist-es/protocols/ListAlimtalkChannels.js +11 -16
- package/dist-es/protocols/ListAlimtalkStatus.js +11 -16
- package/dist-es/protocols/ListAlimtalkTemplates.js +15 -22
- package/dist-es/protocols/ListSMSStatus.js +11 -16
- package/dist-es/protocols/SendAlimtalk.js +12 -18
- package/dist-es/protocols/SendMMS.js +5 -10
- package/dist-es/protocols/SendSMS.js +12 -18
- package/dist-es/protocols/constants.js +96 -84
- package/dist-types/SensClient.d.ts +0 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/middleware/constants.d.ts +1 -0
- package/dist-types/models/MetadataBearer.d.ts +1 -0
- package/dist-types/models/{SensErrorInfo.d.ts → SensApiError.d.ts} +0 -2
- package/dist-types/models/SensClient.d.ts +8 -0
- package/dist-types/models/{SensError.d.ts → SensClientError.d.ts} +3 -2
- package/dist-types/models/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist-es/models/SensErrorInfo.js +0 -31
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { SensCommand, } from "../models/index.js";
|
|
2
|
+
import { se_GetSMSResultCommand, de_GetSMSResultCommand } from "../protocols/GetSMSResult.js";
|
|
3
|
+
export class GetSMSResultCommand extends SensCommand {
|
|
4
|
+
input;
|
|
5
|
+
serializer;
|
|
6
|
+
deserializer;
|
|
7
7
|
constructor(input) {
|
|
8
8
|
super(input);
|
|
9
9
|
this.input = {
|
|
10
10
|
messageId: input.messageId,
|
|
11
11
|
};
|
|
12
|
-
this.serializer =
|
|
13
|
-
this.deserializer =
|
|
12
|
+
this.serializer = se_GetSMSResultCommand;
|
|
13
|
+
this.deserializer = de_GetSMSResultCommand;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
exports.GetSMSResultCommand = GetSMSResultCommand;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GetSMSStatusCommand = void 0;
|
|
4
|
-
const index_js_1 = require("../models/index.js");
|
|
5
|
-
const GetSMSStatus_js_1 = require("../protocols/GetSMSStatus.js");
|
|
1
|
+
import { SensCommand, } from "../models/index.js";
|
|
2
|
+
import { se_GetSMSStatusCommand, de_GetSMSStatusCommand } from "../protocols/GetSMSStatus.js";
|
|
6
3
|
const MAX_LIMIT = 100;
|
|
7
|
-
class GetSMSStatusCommand extends
|
|
4
|
+
export class GetSMSStatusCommand extends SensCommand {
|
|
5
|
+
input;
|
|
6
|
+
serializer;
|
|
7
|
+
deserializer;
|
|
8
8
|
constructor(input) {
|
|
9
9
|
super(input);
|
|
10
10
|
this.input = {
|
|
@@ -12,8 +12,7 @@ class GetSMSStatusCommand extends index_js_1.SensCommand {
|
|
|
12
12
|
pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT,
|
|
13
13
|
...(input.nextToken && { nextToken: input.nextToken }),
|
|
14
14
|
};
|
|
15
|
-
this.serializer =
|
|
16
|
-
this.deserializer =
|
|
15
|
+
this.serializer = se_GetSMSStatusCommand;
|
|
16
|
+
this.deserializer = de_GetSMSStatusCommand;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
exports.GetSMSStatusCommand = GetSMSStatusCommand;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { SensCommand, } from "../models/index.js";
|
|
2
|
+
import { se_ListAlimtalkChannelsCommand, de_ListAlimtalkChannelsCommand } from "../protocols/ListAlimtalkChannels.js";
|
|
3
|
+
export class ListAlimtalkChannelsCommand extends SensCommand {
|
|
4
|
+
input;
|
|
5
|
+
serializer;
|
|
6
|
+
deserializer;
|
|
7
7
|
constructor(input) {
|
|
8
8
|
super(input);
|
|
9
9
|
this.input = {};
|
|
10
|
-
this.serializer =
|
|
11
|
-
this.deserializer =
|
|
10
|
+
this.serializer = se_ListAlimtalkChannelsCommand;
|
|
11
|
+
this.deserializer = de_ListAlimtalkChannelsCommand;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
exports.ListAlimtalkChannelsCommand = ListAlimtalkChannelsCommand;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const ListAlimtalkStatus_js_1 = require("../protocols/ListAlimtalkStatus.js");
|
|
6
|
-
const constants_js_1 = require("./constants.js");
|
|
7
|
-
const DURATION_LIMIT_MS = 30 * 24 * 3600000; // 30일 이내만 조회 가능
|
|
1
|
+
import { SensCommand, SensError, } from "../models/index.js";
|
|
2
|
+
import { se_ListAlimtalkStatusCommand, de_ListAlimtalkStatusCommand } from "../protocols/ListAlimtalkStatus.js";
|
|
3
|
+
import { getDefaultRequestDuration, resolveRequestDuration, convertToUtc, convertToKst, prettyPhoneNum, } from "./constants.js";
|
|
4
|
+
const DURATION_LIMIT_MS = 30 * 24 * 3_600_000; // 30일 이내만 조회 가능
|
|
8
5
|
const MAX_LIMIT = 100;
|
|
9
6
|
const DEFAULT_LIMIT = 20;
|
|
10
|
-
class ListAlimtalkStatusCommand extends
|
|
7
|
+
export class ListAlimtalkStatusCommand extends SensCommand {
|
|
8
|
+
input;
|
|
9
|
+
serializer;
|
|
10
|
+
deserializer;
|
|
11
11
|
constructor(input) {
|
|
12
|
-
var _a;
|
|
13
12
|
super(input);
|
|
14
13
|
if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
|
|
15
|
-
throw new
|
|
14
|
+
throw new SensError({
|
|
16
15
|
code: -1,
|
|
17
16
|
type: "SDK.GENERAL_ERROR",
|
|
18
17
|
message: "페이지네이션 검색 조건 불일치",
|
|
@@ -22,26 +21,25 @@ class ListAlimtalkStatusCommand extends index_js_1.SensCommand {
|
|
|
22
21
|
],
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
|
-
const defaultDuration =
|
|
26
|
-
const { startTimeMs, endTimeMs } =
|
|
27
|
-
startTime: input.requestStartTime ?
|
|
28
|
-
endTime: input.requestEndTime ?
|
|
24
|
+
const defaultDuration = getDefaultRequestDuration({ durationLimitMs: DURATION_LIMIT_MS });
|
|
25
|
+
const { startTimeMs, endTimeMs } = resolveRequestDuration({
|
|
26
|
+
startTime: input.requestStartTime ? convertToUtc(input.requestStartTime) : defaultDuration.startTime,
|
|
27
|
+
endTime: input.requestEndTime ? convertToUtc(input.requestEndTime) : defaultDuration.endTime,
|
|
29
28
|
}, { durationLimitMs: DURATION_LIMIT_MS });
|
|
30
29
|
this.input = {
|
|
31
30
|
plusFriendId: input.plusFriendId,
|
|
32
|
-
requestStartTime:
|
|
33
|
-
requestEndTime:
|
|
34
|
-
pageSize: Math.min(MAX_LIMIT, Math.max(1,
|
|
31
|
+
requestStartTime: convertToKst(startTimeMs),
|
|
32
|
+
requestEndTime: convertToKst(endTimeMs),
|
|
33
|
+
pageSize: Math.min(MAX_LIMIT, Math.max(1, input.pageSize ?? DEFAULT_LIMIT)),
|
|
35
34
|
...(input.requestStatusName && { requestStatusName: input.requestStatusName }),
|
|
36
35
|
...(input.messageStatusName && { messageStatusName: input.messageStatusName }),
|
|
37
36
|
...(input.requestId && { requestId: input.requestId, pageSize: MAX_LIMIT }),
|
|
38
37
|
...(input.messageId && { messageId: input.messageId }),
|
|
39
38
|
...(input.templateCode && { templateCode: input.templateCode }),
|
|
40
|
-
...(input.to && { to:
|
|
39
|
+
...(input.to && { to: prettyPhoneNum(input.to) }),
|
|
41
40
|
...(input.nextToken && { nextToken: input.nextToken }),
|
|
42
41
|
};
|
|
43
|
-
this.serializer =
|
|
44
|
-
this.deserializer =
|
|
42
|
+
this.serializer = se_ListAlimtalkStatusCommand;
|
|
43
|
+
this.deserializer = de_ListAlimtalkStatusCommand;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
exports.ListAlimtalkStatusCommand = ListAlimtalkStatusCommand;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { SensCommand, } from "../models/index.js";
|
|
2
|
+
import { se_ListAlimtalkTemplatesCommand, de_ListAlimtalkTemplatesCommand, } from "../protocols/ListAlimtalkTemplates.js";
|
|
3
|
+
export class ListAlimtalkTemplatesCommand extends SensCommand {
|
|
4
|
+
input;
|
|
5
|
+
serializer;
|
|
6
|
+
deserializer;
|
|
7
7
|
constructor(input) {
|
|
8
8
|
super(input);
|
|
9
9
|
this.input = {
|
|
10
10
|
channelId: input.channelId,
|
|
11
11
|
};
|
|
12
|
-
this.serializer =
|
|
13
|
-
this.deserializer =
|
|
12
|
+
this.serializer = se_ListAlimtalkTemplatesCommand;
|
|
13
|
+
this.deserializer = de_ListAlimtalkTemplatesCommand;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
exports.ListAlimtalkTemplatesCommand = ListAlimtalkTemplatesCommand;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const ListSMSStatus_js_1 = require("../protocols/ListSMSStatus.js");
|
|
6
|
-
const constants_js_1 = require("./constants.js");
|
|
7
|
-
const DURATION_LIMIT_MS = 30 * 24 * 3600000; // 30일 이내만 조회 가능
|
|
1
|
+
import { SensCommand, SensError, } from "../models/index.js";
|
|
2
|
+
import { se_ListSMSStatusCommand, de_ListSMSStatusCommand } from "../protocols/ListSMSStatus.js";
|
|
3
|
+
import { getDefaultRequestDuration, resolveRequestDuration, convertToUtc, convertToKst, prettyPhoneNum, } from "./constants.js";
|
|
4
|
+
const DURATION_LIMIT_MS = 30 * 24 * 3_600_000; // 30일 이내만 조회 가능
|
|
8
5
|
const MAX_LIMIT = 100;
|
|
9
6
|
const DEFAULT_LIMIT = 20;
|
|
10
|
-
class ListSMSStatusCommand extends
|
|
7
|
+
export class ListSMSStatusCommand extends SensCommand {
|
|
8
|
+
input;
|
|
9
|
+
serializer;
|
|
10
|
+
deserializer;
|
|
11
11
|
constructor(input) {
|
|
12
|
-
var _a;
|
|
13
12
|
super(input);
|
|
14
13
|
if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
|
|
15
|
-
throw new
|
|
14
|
+
throw new SensError({
|
|
16
15
|
code: -1,
|
|
17
16
|
type: "SDK.GENERAL_ERROR",
|
|
18
17
|
message: "페이지네이션 검색 조건 불일치",
|
|
@@ -22,25 +21,24 @@ class ListSMSStatusCommand extends index_js_1.SensCommand {
|
|
|
22
21
|
],
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
|
-
const defaultDuration =
|
|
26
|
-
const { startTimeMs, endTimeMs } =
|
|
27
|
-
startTime: input.requestStartTime ?
|
|
28
|
-
endTime: input.requestEndTime ?
|
|
24
|
+
const defaultDuration = getDefaultRequestDuration({ durationLimitMs: DURATION_LIMIT_MS });
|
|
25
|
+
const { startTimeMs, endTimeMs } = resolveRequestDuration({
|
|
26
|
+
startTime: input.requestStartTime ? convertToUtc(input.requestStartTime) : defaultDuration.startTime,
|
|
27
|
+
endTime: input.requestEndTime ? convertToUtc(input.requestEndTime) : defaultDuration.endTime,
|
|
29
28
|
}, { durationLimitMs: DURATION_LIMIT_MS });
|
|
30
29
|
this.input = {
|
|
31
|
-
requestStartTime:
|
|
32
|
-
requestEndTime:
|
|
33
|
-
pageSize: Math.min(MAX_LIMIT, Math.max(1,
|
|
30
|
+
requestStartTime: convertToKst(startTimeMs),
|
|
31
|
+
requestEndTime: convertToKst(endTimeMs),
|
|
32
|
+
pageSize: Math.min(MAX_LIMIT, Math.max(1, input.pageSize ?? DEFAULT_LIMIT)),
|
|
34
33
|
...(input.type && { type: input.type }),
|
|
35
34
|
...(input.contentType && { contentType: input.contentType }),
|
|
36
35
|
...(input.status && { status: input.status }),
|
|
37
|
-
...(input.from && { from:
|
|
38
|
-
...(input.to && { to:
|
|
36
|
+
...(input.from && { from: prettyPhoneNum(input.from) }),
|
|
37
|
+
...(input.to && { to: prettyPhoneNum(input.to) }),
|
|
39
38
|
...(input.statusName && { statusName: input.statusName }),
|
|
40
39
|
...(input.nextToken && { nextToken: input.nextToken }),
|
|
41
40
|
};
|
|
42
|
-
this.serializer =
|
|
43
|
-
this.deserializer =
|
|
41
|
+
this.serializer = se_ListSMSStatusCommand;
|
|
42
|
+
this.deserializer = de_ListSMSStatusCommand;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
exports.ListSMSStatusCommand = ListSMSStatusCommand;
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { SensCommand, ALIMTALK_MAX_RECIPIENTS, ALIMTALK_MAX_CONTENT_LENGTH, SensError, } from "../models/index.js";
|
|
2
|
+
import { se_SendAlimtalkCommand, de_SendAlimtalkCommand } from "../protocols/SendAlimtalk.js";
|
|
3
|
+
export class SendAlimtalkCommand extends SensCommand {
|
|
4
|
+
input;
|
|
5
|
+
serializer;
|
|
6
|
+
deserializer;
|
|
7
7
|
constructor(input) {
|
|
8
8
|
super(input);
|
|
9
9
|
this.input = {
|
|
10
10
|
plusFriendId: input.plusFriendId,
|
|
11
11
|
templateCode: input.templateCode,
|
|
12
12
|
messages: resolveAlimtalkMessages(input.messages, {
|
|
13
|
-
maxRecipients:
|
|
14
|
-
maxContentLength:
|
|
13
|
+
maxRecipients: ALIMTALK_MAX_RECIPIENTS,
|
|
14
|
+
maxContentLength: ALIMTALK_MAX_CONTENT_LENGTH,
|
|
15
15
|
}),
|
|
16
16
|
};
|
|
17
|
-
this.serializer =
|
|
18
|
-
this.deserializer =
|
|
17
|
+
this.serializer = se_SendAlimtalkCommand;
|
|
18
|
+
this.deserializer = de_SendAlimtalkCommand;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.SendAlimtalkCommand = SendAlimtalkCommand;
|
|
22
21
|
const resolveAlimtalkMessages = (messages, config) => {
|
|
23
22
|
if (!messages.length || messages.length > config.maxRecipients) {
|
|
24
|
-
throw new
|
|
23
|
+
throw new SensError({
|
|
25
24
|
code: -1,
|
|
26
25
|
type: "SDK.GENERAL_ERROR",
|
|
27
26
|
message: `알림톡 동시 발송은 최소 1명, 최대 ${config.maxRecipients}명까지 가능합니다.`,
|
|
@@ -29,7 +28,7 @@ const resolveAlimtalkMessages = (messages, config) => {
|
|
|
29
28
|
}
|
|
30
29
|
const result = messages.map((message) => {
|
|
31
30
|
if (message.content.length > config.maxContentLength) {
|
|
32
|
-
throw new
|
|
31
|
+
throw new SensError({
|
|
33
32
|
code: -1,
|
|
34
33
|
type: "SDK.GENERAL_ERROR",
|
|
35
34
|
message: `알림톡 최대 길이는 ${config.maxContentLength}글자입니다`,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { parse, format } from "node:path";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { SensCommand, MMS_MAX_SUPPORT_FILE_SIZE, MMS_SUPPORT_FILE_EXTENSION, SensError, } from "../models/index.js";
|
|
5
|
+
import { se_SendMMSCommand, de_SendMMSCommand } from "../protocols/SendMMS.js";
|
|
6
|
+
import { trimText, prettyPhoneNum } from "./constants.js";
|
|
7
|
+
import { resolveInputMessages } from "./SendSMSCommand.js";
|
|
8
|
+
export class SendMMSCommand extends SensCommand {
|
|
9
|
+
input;
|
|
10
|
+
serializer;
|
|
11
|
+
deserializer;
|
|
12
12
|
constructor(input) {
|
|
13
13
|
super(input);
|
|
14
|
-
const content = input.content ?
|
|
15
|
-
const subject = input.subject ?
|
|
16
|
-
const messages =
|
|
14
|
+
const content = input.content ? trimText(input.content) : "내용없음";
|
|
15
|
+
const subject = input.subject ? trimText(input.subject) : "제목없음";
|
|
16
|
+
const messages = resolveInputMessages(input.messages, { defaultContent: content, defaultSubject: subject });
|
|
17
17
|
this.input = {
|
|
18
|
-
from:
|
|
18
|
+
from: prettyPhoneNum(input.from),
|
|
19
19
|
content,
|
|
20
20
|
messages,
|
|
21
21
|
type: "MMS",
|
|
@@ -23,19 +23,18 @@ class SendMMSCommand extends index_js_1.SensCommand {
|
|
|
23
23
|
countryCode: input.countryCode ? input.countryCode : "82",
|
|
24
24
|
subject,
|
|
25
25
|
files: (input.files || []).map((file) => {
|
|
26
|
-
return resolveSendFile(file, { maxKiB:
|
|
26
|
+
return resolveSendFile(file, { maxKiB: MMS_MAX_SUPPORT_FILE_SIZE, supportExt: MMS_SUPPORT_FILE_EXTENSION });
|
|
27
27
|
}),
|
|
28
28
|
};
|
|
29
|
-
this.serializer =
|
|
30
|
-
this.deserializer =
|
|
29
|
+
this.serializer = se_SendMMSCommand;
|
|
30
|
+
this.deserializer = de_SendMMSCommand;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
exports.SendMMSCommand = SendMMSCommand;
|
|
34
33
|
const resolveSendFile = (file, options) => {
|
|
35
|
-
const parsed =
|
|
34
|
+
const parsed = parse(file.name); // { dir, name, ext, base }
|
|
36
35
|
const ext = parsed.ext.toLocaleLowerCase();
|
|
37
36
|
if (!options.supportExt.includes(ext)) {
|
|
38
|
-
throw new
|
|
37
|
+
throw new SensError({
|
|
39
38
|
code: -1,
|
|
40
39
|
type: "SDK.GENERAL_ERROR",
|
|
41
40
|
message: `MMS는 ${options.supportExt.join(", ")} 형식의 첨부파일만 보낼 수 있습니다.`,
|
|
@@ -44,24 +43,24 @@ const resolveSendFile = (file, options) => {
|
|
|
44
43
|
if (file.body) {
|
|
45
44
|
const buffer = Buffer.from(file.body, "base64");
|
|
46
45
|
checkSizeLimit(buffer, options.maxKiB);
|
|
47
|
-
const hash =
|
|
46
|
+
const hash = createHash("md5").update(buffer).digest("hex");
|
|
48
47
|
return {
|
|
49
|
-
name:
|
|
48
|
+
name: format({ name: hash, ext }),
|
|
50
49
|
body: file.body,
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
|
-
if (!
|
|
54
|
-
throw new
|
|
52
|
+
if (!existsSync(file.name)) {
|
|
53
|
+
throw new SensError({
|
|
55
54
|
code: -1,
|
|
56
55
|
type: "SDK.GENERAL_ERROR",
|
|
57
56
|
message: `${file.name} 첨부파일이 존재하지 않습니다.`,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
|
-
const buffer =
|
|
59
|
+
const buffer = readFileSync(file.name);
|
|
61
60
|
checkSizeLimit(buffer, options.maxKiB);
|
|
62
|
-
const hash =
|
|
61
|
+
const hash = createHash("md5").update(buffer).digest("hex");
|
|
63
62
|
return {
|
|
64
|
-
name:
|
|
63
|
+
name: format({ name: hash, ext }),
|
|
65
64
|
body: buffer.toString("base64"),
|
|
66
65
|
};
|
|
67
66
|
};
|
|
@@ -69,7 +68,7 @@ const checkSizeLimit = (buffer, maxKiB) => {
|
|
|
69
68
|
const byteSize = buffer.length;
|
|
70
69
|
const kibSize = Math.ceil(byteSize / 1024);
|
|
71
70
|
if (kibSize > maxKiB) {
|
|
72
|
-
throw new
|
|
71
|
+
throw new SensError({
|
|
73
72
|
code: -1,
|
|
74
73
|
type: "SDK.GENERAL_ERROR",
|
|
75
74
|
message: `첨부파일은 ${maxKiB}KiB까지 전송 가능합니다. 현재 ${kibSize}KiB`,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { SensCommand, SensError, } from "../models/index.js";
|
|
2
|
+
import { se_SendSMSCommand, de_SendSMSCommand } from "../protocols/SendSMS.js";
|
|
3
|
+
import { trimText, prettyPhoneNum, getContentLength } from "./constants.js";
|
|
4
|
+
export class SendSMSCommand extends SensCommand {
|
|
5
|
+
input;
|
|
6
|
+
serializer;
|
|
7
|
+
deserializer;
|
|
8
8
|
constructor(input) {
|
|
9
9
|
super(input);
|
|
10
|
-
const content = input.content ?
|
|
11
|
-
const subject = input.subject ?
|
|
12
|
-
const messages =
|
|
10
|
+
const content = input.content ? trimText(input.content) : "내용없음";
|
|
11
|
+
const subject = input.subject ? trimText(input.subject) : "제목없음";
|
|
12
|
+
const messages = resolveInputMessages(input.messages, { defaultContent: content, defaultSubject: subject });
|
|
13
13
|
const isLMS = !!messages.filter((msg) => !!msg.subject).length;
|
|
14
14
|
this.input = {
|
|
15
|
-
from:
|
|
15
|
+
from: prettyPhoneNum(input.from),
|
|
16
16
|
content,
|
|
17
17
|
messages,
|
|
18
18
|
type: isLMS ? "LMS" : "SMS",
|
|
@@ -20,40 +20,38 @@ class SendSMSCommand extends index_js_1.SensCommand {
|
|
|
20
20
|
countryCode: input.countryCode ? input.countryCode : "82",
|
|
21
21
|
...(isLMS && { subject }),
|
|
22
22
|
};
|
|
23
|
-
this.serializer =
|
|
24
|
-
this.deserializer =
|
|
23
|
+
this.serializer = se_SendSMSCommand;
|
|
24
|
+
this.deserializer = de_SendSMSCommand;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const resolveInputMessages = (messages, config) => {
|
|
27
|
+
export const resolveInputMessages = (messages, config) => {
|
|
29
28
|
const output = messages
|
|
30
29
|
.filter((d) => !!d)
|
|
31
30
|
.map((message) => {
|
|
32
|
-
const content = message.content ?
|
|
33
|
-
const subject = message.subject ?
|
|
31
|
+
const content = message.content ? trimText(message.content) : config.defaultContent;
|
|
32
|
+
const subject = message.subject ? trimText(message.subject) : config.defaultSubject;
|
|
34
33
|
const msgType = getMessageType({ content });
|
|
35
34
|
return {
|
|
36
|
-
to:
|
|
35
|
+
to: prettyPhoneNum(message.to),
|
|
37
36
|
content,
|
|
38
37
|
...(msgType === "LMS" && { subject }),
|
|
39
38
|
};
|
|
40
39
|
});
|
|
41
40
|
return output;
|
|
42
41
|
};
|
|
43
|
-
exports.resolveInputMessages = resolveInputMessages;
|
|
44
42
|
const getMessageType = (input) => {
|
|
45
43
|
const SMS_MAX_CONTENT_LENGTH = 90;
|
|
46
44
|
const LMS_MAX_CONTENT_LENGTH = 2000;
|
|
47
|
-
const contentLength =
|
|
45
|
+
const contentLength = getContentLength(input.content);
|
|
48
46
|
if (!contentLength) {
|
|
49
|
-
throw new
|
|
47
|
+
throw new SensError({
|
|
50
48
|
code: -1,
|
|
51
49
|
type: "SDK.GENERAL_ERROR",
|
|
52
50
|
message: "메세지 내용이 없습니다.",
|
|
53
51
|
});
|
|
54
52
|
}
|
|
55
53
|
if (contentLength > LMS_MAX_CONTENT_LENGTH) {
|
|
56
|
-
throw new
|
|
54
|
+
throw new SensError({
|
|
57
55
|
code: -1,
|
|
58
56
|
type: "SDK.GENERAL_ERROR",
|
|
59
57
|
message: `메세지 최대 길이는 ${LMS_MAX_CONTENT_LENGTH}글자입니다`,
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const index_js_1 = require("../models/index.js");
|
|
5
|
-
const trimText = (input) => input.trim();
|
|
6
|
-
exports.trimText = trimText;
|
|
7
|
-
const prettyPhoneNum = (input) => input.replace(/\-/gi, "");
|
|
8
|
-
exports.prettyPhoneNum = prettyPhoneNum;
|
|
1
|
+
import { SensError } from "../models/index.js";
|
|
2
|
+
export const trimText = (input) => input.trim();
|
|
3
|
+
export const prettyPhoneNum = (input) => input.replace(/\-/gi, "");
|
|
9
4
|
/** @returns content-length(euc-kr) */
|
|
10
|
-
const getContentLength = (input) => {
|
|
5
|
+
export const getContentLength = (input) => {
|
|
11
6
|
return input.split("").reduce((acc, text) => {
|
|
12
7
|
let byte = Buffer.from(text).length;
|
|
13
8
|
let modulo = byte % 3;
|
|
@@ -15,33 +10,29 @@ const getContentLength = (input) => {
|
|
|
15
10
|
return acc;
|
|
16
11
|
}, 0);
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
const convertToUtc = (input) => {
|
|
13
|
+
export const convertToUtc = (input) => {
|
|
20
14
|
const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
21
15
|
return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const KST_OFFSET = 9 * 3600000;
|
|
17
|
+
export const convertToKst = (input) => {
|
|
18
|
+
const KST_OFFSET = 9 * 3_600_000;
|
|
26
19
|
return new Date(input + KST_OFFSET).toISOString().replace(/\.\d{3}Z$/, "");
|
|
27
20
|
};
|
|
28
|
-
exports.convertToKst = convertToKst;
|
|
29
21
|
// UTC
|
|
30
|
-
const getDefaultRequestDuration = (config) => {
|
|
22
|
+
export const getDefaultRequestDuration = (config) => {
|
|
31
23
|
const now = Date.now();
|
|
32
24
|
return {
|
|
33
25
|
startTime: new Date(now - config.durationLimitMs).toISOString(),
|
|
34
26
|
endTime: new Date(now).toISOString(),
|
|
35
27
|
};
|
|
36
28
|
};
|
|
37
|
-
exports.getDefaultRequestDuration = getDefaultRequestDuration;
|
|
38
29
|
// UTC
|
|
39
|
-
const resolveRequestDuration = (input, config) => {
|
|
30
|
+
export const resolveRequestDuration = (input, config) => {
|
|
40
31
|
const start = new Date(input.startTime).getTime();
|
|
41
32
|
const end = new Date(input.endTime).getTime();
|
|
42
33
|
const diff = end - start;
|
|
43
34
|
if (diff < 0) {
|
|
44
|
-
throw new
|
|
35
|
+
throw new SensError({
|
|
45
36
|
code: -1,
|
|
46
37
|
type: "SDK.GENERAL_ERROR",
|
|
47
38
|
message: "조회 가능 날짜 오류. 종료일이 시작일보다 빠를 수 없습니다.",
|
|
@@ -49,10 +40,10 @@ const resolveRequestDuration = (input, config) => {
|
|
|
49
40
|
});
|
|
50
41
|
}
|
|
51
42
|
if (diff > config.durationLimitMs) {
|
|
52
|
-
throw new
|
|
43
|
+
throw new SensError({
|
|
53
44
|
code: -1,
|
|
54
45
|
type: "SDK.GENERAL_ERROR",
|
|
55
|
-
message: `최대 ${config.durationLimitMs / (24 *
|
|
46
|
+
message: `최대 ${config.durationLimitMs / (24 * 3_600_000)}일 이내에서 조회 가능합니다.`,
|
|
56
47
|
});
|
|
57
48
|
}
|
|
58
49
|
return {
|
|
@@ -60,4 +51,3 @@ const resolveRequestDuration = (input, config) => {
|
|
|
60
51
|
endTimeMs: end,
|
|
61
52
|
};
|
|
62
53
|
};
|
|
63
|
-
exports.resolveRequestDuration = resolveRequestDuration;
|
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./GetAlimtalkResultCommand.js"), exports);
|
|
18
|
-
__exportStar(require("./GetAlimtalkStatusCommand.js"), exports);
|
|
19
|
-
__exportStar(require("./GetAlimtalkTemplateCommand.js"), exports);
|
|
20
|
-
__exportStar(require("./GetSMSResultCommand.js"), exports);
|
|
21
|
-
__exportStar(require("./GetSMSStatusCommand.js"), exports);
|
|
22
|
-
__exportStar(require("./ListAlimtalkChannelsCommand.js"), exports);
|
|
23
|
-
__exportStar(require("./ListAlimtalkStatusCommand.js"), exports);
|
|
24
|
-
__exportStar(require("./ListAlimtalkTemplatesCommand.js"), exports);
|
|
25
|
-
__exportStar(require("./ListSMSStatusCommand.js"), exports);
|
|
26
|
-
__exportStar(require("./SendAlimtalkCommand.js"), exports);
|
|
27
|
-
__exportStar(require("./SendMMSCommand.js"), exports);
|
|
28
|
-
__exportStar(require("./SendSMSCommand.js"), exports);
|
|
1
|
+
export * from "./GetAlimtalkResultCommand.js";
|
|
2
|
+
export * from "./GetAlimtalkStatusCommand.js";
|
|
3
|
+
export * from "./GetAlimtalkTemplateCommand.js";
|
|
4
|
+
export * from "./GetSMSResultCommand.js";
|
|
5
|
+
export * from "./GetSMSStatusCommand.js";
|
|
6
|
+
export * from "./ListAlimtalkChannelsCommand.js";
|
|
7
|
+
export * from "./ListAlimtalkStatusCommand.js";
|
|
8
|
+
export * from "./ListAlimtalkTemplatesCommand.js";
|
|
9
|
+
export * from "./ListSMSStatusCommand.js";
|
|
10
|
+
export * from "./SendAlimtalkCommand.js";
|
|
11
|
+
export * from "./SendMMSCommand.js";
|
|
12
|
+
export * from "./SendSMSCommand.js";
|
package/dist-es/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./commands/index.js"), exports);
|
|
18
|
-
__exportStar(require("./SensClient.js"), exports);
|
|
19
|
-
__exportStar(require("./models/SensError.js"), exports);
|
|
1
|
+
export * from "./commands/index.js";
|
|
2
|
+
export * from "./SensClient.js";
|
|
3
|
+
export * from "./models/SensClientError.js";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.NCP_TIMESTAMP = "x-ncp-apigw-timestamp";
|
|
10
|
-
exports.NCP_SIGNATURE = "x-ncp-apigw-signature-v2";
|
|
1
|
+
export const INGESTKOREA_USER_AGENT = "x-ingestkorea-user-agent";
|
|
2
|
+
export const INGESTKOREA_REQUEST_LOG = "x-ingestkorea-request";
|
|
3
|
+
export const INGESTKOREA_RETRY = "x-ingestkorea-attempts";
|
|
4
|
+
export const INGESTKOREA_RETRY_DELAY = "x-ingestkorea-total-retry-delay";
|
|
5
|
+
export const NCP_ACCESS_KEY = "x-ncp-iam-access-key";
|
|
6
|
+
export const NCP_TIMESTAMP = "x-ncp-apigw-timestamp";
|
|
7
|
+
export const NCP_SIGNATURE = "x-ncp-apigw-signature-v2";
|
|
8
|
+
export const NCP_TRACE_ID = "x-ncp-trace-id";
|