@ingestkorea/client-sens 1.8.0 → 1.10.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 +1 -0
- package/dist-cjs/SensClient.js +21 -18
- package/dist-cjs/commands/GetAlimtalkStatusCommand.js +1 -3
- package/dist-cjs/commands/GetSMSStatusCommand.js +2 -3
- package/dist-cjs/commands/ListAlimtalkStatusCommand.js +19 -11
- package/dist-cjs/commands/ListSMSStatusCommand.js +35 -0
- package/dist-cjs/commands/SendAlimtalkCommand.js +7 -14
- package/dist-cjs/commands/SendMMSCommand.js +9 -19
- package/dist-cjs/commands/SendSMSCommand.js +5 -7
- package/dist-cjs/commands/constants.js +47 -1
- package/dist-cjs/commands/index.js +1 -0
- package/dist-cjs/index.js +1 -0
- package/dist-cjs/middleware/middleware-metadata.js +1 -1
- package/dist-cjs/middleware/middleware-retry.js +19 -26
- package/dist-cjs/models/ListSMSStatus.js +2 -0
- package/dist-cjs/models/SensError.js +14 -0
- package/dist-cjs/models/SensErrorInfo.js +29 -11
- package/dist-cjs/models/index.js +2 -0
- package/dist-cjs/protocols/GetAlimtalkStatus.js +5 -5
- package/dist-cjs/protocols/GetAlimtalkTemplate.js +1 -1
- package/dist-cjs/protocols/GetSMSResult.js +3 -2
- package/dist-cjs/protocols/GetSMSStatus.js +28 -11
- package/dist-cjs/protocols/ListAlimtalkChannels.js +2 -2
- package/dist-cjs/protocols/ListAlimtalkTemplates.js +2 -2
- package/dist-cjs/protocols/ListSMSStatus.js +48 -0
- package/dist-cjs/protocols/SendAlimtalk.js +1 -1
- package/dist-cjs/protocols/SendSMS.js +1 -1
- package/dist-cjs/protocols/constants.js +80 -49
- package/dist-es/SensClient.js +21 -18
- package/dist-es/commands/GetAlimtalkStatusCommand.js +1 -3
- package/dist-es/commands/GetSMSStatusCommand.js +3 -0
- package/dist-es/commands/ListAlimtalkStatusCommand.js +22 -14
- package/dist-es/commands/ListSMSStatusCommand.js +46 -0
- package/dist-es/commands/SendAlimtalkCommand.js +7 -13
- package/dist-es/commands/SendMMSCommand.js +9 -19
- package/dist-es/commands/SendSMSCommand.js +5 -7
- package/dist-es/commands/constants.js +47 -1
- package/dist-es/commands/index.js +1 -0
- package/dist-es/index.js +1 -0
- package/dist-es/middleware/middleware-metadata.js +1 -1
- package/dist-es/middleware/middleware-retry.js +21 -32
- package/dist-es/models/ListSMSStatus.js +2 -0
- package/dist-es/models/SensError.js +14 -0
- package/dist-es/models/SensErrorInfo.js +29 -11
- package/dist-es/models/index.js +2 -0
- package/dist-es/protocols/GetAlimtalkStatus.js +12 -12
- package/dist-es/protocols/GetAlimtalkTemplate.js +1 -1
- package/dist-es/protocols/GetSMSResult.js +5 -9
- package/dist-es/protocols/GetSMSStatus.js +28 -11
- package/dist-es/protocols/ListAlimtalkChannels.js +2 -2
- package/dist-es/protocols/ListAlimtalkTemplates.js +2 -2
- package/dist-es/protocols/ListSMSStatus.js +42 -0
- package/dist-es/protocols/SendAlimtalk.js +1 -1
- package/dist-es/protocols/SendSMS.js +1 -1
- package/dist-es/protocols/constants.js +83 -52
- package/dist-types/commands/ListSMSStatusCommand.d.ts +11 -0
- package/dist-types/commands/constants.d.ts +17 -0
- package/dist-types/commands/index.d.ts +1 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/models/GetSMSResult.d.ts +2 -6
- package/dist-types/models/GetSMSStatus.d.ts +15 -0
- package/dist-types/models/ListSMSStatus.d.ts +15 -0
- package/dist-types/models/SendAlimtalk.d.ts +1 -0
- package/dist-types/models/SensClient.d.ts +0 -1
- package/dist-types/models/SensError.d.ts +17 -0
- package/dist-types/models/SensErrorInfo.d.ts +51 -15
- package/dist-types/models/index.d.ts +2 -0
- package/dist-types/protocols/GetSMSStatus.d.ts +2 -1
- package/dist-types/protocols/ListSMSStatus.d.ts +4 -0
- package/dist-types/protocols/constants.d.ts +2 -1
- package/package.json +2 -3
package/README.md
CHANGED
package/dist-cjs/SensClient.js
CHANGED
|
@@ -33,8 +33,14 @@ class SensClient {
|
|
|
33
33
|
const output = yield deserializer(response, this.config);
|
|
34
34
|
return output;
|
|
35
35
|
}
|
|
36
|
-
catch (
|
|
37
|
-
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (err instanceof index_js_1.SensError)
|
|
38
|
+
throw err;
|
|
39
|
+
throw new index_js_1.SensError({
|
|
40
|
+
code: -1,
|
|
41
|
+
type: "SDK.UNKNOWN_ERROR",
|
|
42
|
+
message: err instanceof Error ? err.message : "unknown error",
|
|
43
|
+
});
|
|
38
44
|
}
|
|
39
45
|
});
|
|
40
46
|
}
|
|
@@ -48,20 +54,19 @@ const composeMiddleware = (middlewares, finalHandler) => {
|
|
|
48
54
|
};
|
|
49
55
|
const resolveCredentials = (config) => {
|
|
50
56
|
const { credentials } = config;
|
|
51
|
-
|
|
52
|
-
code:
|
|
53
|
-
type: "
|
|
54
|
-
message: "
|
|
55
|
-
invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 인증 정보를 확인해주세요" }],
|
|
57
|
+
const error = new index_js_1.SensError({
|
|
58
|
+
code: -1,
|
|
59
|
+
type: "SDK.AUTH_ERROR",
|
|
60
|
+
message: "SensClient 초기화시 인증 정보를 입력해주세요.",
|
|
56
61
|
});
|
|
57
62
|
if (!credentials)
|
|
58
63
|
throw error;
|
|
59
64
|
if (!credentials.accessKey) {
|
|
60
|
-
error.
|
|
65
|
+
error.message = "AccessKey 정보를 확인해주세요.";
|
|
61
66
|
throw error;
|
|
62
67
|
}
|
|
63
68
|
if (!credentials.secretKey) {
|
|
64
|
-
error.
|
|
69
|
+
error.message = "SecretKey 정보를 확인해주세요.";
|
|
65
70
|
throw error;
|
|
66
71
|
}
|
|
67
72
|
return {
|
|
@@ -70,24 +75,22 @@ const resolveCredentials = (config) => {
|
|
|
70
75
|
};
|
|
71
76
|
};
|
|
72
77
|
const resolveServiceId = (config) => {
|
|
73
|
-
var _a, _b
|
|
78
|
+
var _a, _b;
|
|
74
79
|
const { serviceId } = config;
|
|
75
|
-
|
|
76
|
-
code:
|
|
77
|
-
type: "
|
|
78
|
-
message: "
|
|
79
|
-
invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 서비스 정보를 확인해주세요" }],
|
|
80
|
+
const error = new index_js_1.SensError({
|
|
81
|
+
code: -1,
|
|
82
|
+
type: "SDK.GENERAL_ERROR",
|
|
83
|
+
message: "SensClient 초기화시 사용할 서비스 정보를 입력해주세요.",
|
|
80
84
|
});
|
|
81
85
|
if (!serviceId)
|
|
82
86
|
throw error;
|
|
83
87
|
const isReady = !!Object.values(serviceId).filter((d) => !!d).length;
|
|
84
88
|
if (!isReady) {
|
|
85
|
-
error.
|
|
89
|
+
error.message = "최소 1개 이상의 서비스 정보가 필요합니다";
|
|
86
90
|
throw error;
|
|
87
91
|
}
|
|
88
92
|
return {
|
|
89
93
|
kakao: (_a = serviceId.kakao) !== null && _a !== void 0 ? _a : "",
|
|
90
|
-
|
|
91
|
-
sms: (_c = serviceId.sms) !== null && _c !== void 0 ? _c : "",
|
|
94
|
+
sms: (_b = serviceId.sms) !== null && _b !== void 0 ? _b : "",
|
|
92
95
|
};
|
|
93
96
|
};
|
|
@@ -4,12 +4,10 @@ exports.GetAlimtalkStatusCommand = void 0;
|
|
|
4
4
|
const index_js_1 = require("../models/index.js");
|
|
5
5
|
const GetAlimtalkStatus_js_1 = require("../protocols/GetAlimtalkStatus.js");
|
|
6
6
|
const MAX_LIMIT = 100;
|
|
7
|
-
const DEFAULT_LIMIT = 20;
|
|
8
7
|
class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
|
|
9
8
|
constructor(input) {
|
|
10
|
-
var _a;
|
|
11
9
|
super(input);
|
|
12
|
-
this.input = Object.assign({ requestId: input.requestId, pageSize: Math.min(MAX_LIMIT, Math.max(1,
|
|
10
|
+
this.input = Object.assign({ requestId: input.requestId, pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT }, (input.nextToken && { nextToken: input.nextToken }));
|
|
13
11
|
this.serializer = GetAlimtalkStatus_js_1.se_GetAlimtalkStatusCommand;
|
|
14
12
|
this.deserializer = GetAlimtalkStatus_js_1.de_GetAlimtalkStatusCommand;
|
|
15
13
|
}
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GetSMSStatusCommand = void 0;
|
|
4
4
|
const index_js_1 = require("../models/index.js");
|
|
5
5
|
const GetSMSStatus_js_1 = require("../protocols/GetSMSStatus.js");
|
|
6
|
+
const MAX_LIMIT = 100;
|
|
6
7
|
class GetSMSStatusCommand extends index_js_1.SensCommand {
|
|
7
8
|
constructor(input) {
|
|
8
9
|
super(input);
|
|
9
|
-
this.input = {
|
|
10
|
-
requestId: input.requestId,
|
|
11
|
-
};
|
|
10
|
+
this.input = Object.assign({ requestId: input.requestId, pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT }, (input.nextToken && { nextToken: input.nextToken }));
|
|
12
11
|
this.serializer = GetSMSStatus_js_1.se_GetSMSStatusCommand;
|
|
13
12
|
this.deserializer = GetSMSStatus_js_1.de_GetSMSStatusCommand;
|
|
14
13
|
}
|
|
@@ -3,25 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ListAlimtalkStatusCommand = void 0;
|
|
4
4
|
const index_js_1 = require("../models/index.js");
|
|
5
5
|
const ListAlimtalkStatus_js_1 = require("../protocols/ListAlimtalkStatus.js");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const constants_js_1 = require("./constants.js");
|
|
7
|
+
const DURATION_LIMIT_MS = 30 * 24 * 3600000; // 30일 이내만 조회 가능
|
|
8
8
|
const MAX_LIMIT = 100;
|
|
9
9
|
const DEFAULT_LIMIT = 20;
|
|
10
10
|
class ListAlimtalkStatusCommand extends index_js_1.SensCommand {
|
|
11
11
|
constructor(input) {
|
|
12
12
|
var _a;
|
|
13
13
|
super(input);
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
|
|
15
|
+
throw new index_js_1.SensError({
|
|
16
|
+
code: -1,
|
|
17
|
+
type: "SDK.GENERAL_ERROR",
|
|
18
|
+
message: "페이지네이션 검색 조건 불일치",
|
|
19
|
+
errors: [
|
|
20
|
+
"nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션이 모두 동일하게 유지되어야 합니다.",
|
|
21
|
+
"requestStartTime, requestEndTime, pageSize 옵션을 확인해주세요.",
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const defaultDuration = (0, constants_js_1.getDefaultRequestDuration)({ durationLimitMs: DURATION_LIMIT_MS });
|
|
26
|
+
const { startTimeMs, endTimeMs } = (0, constants_js_1.resolveRequestDuration)({
|
|
27
|
+
startTime: input.requestStartTime ? (0, constants_js_1.convertToUtc)(input.requestStartTime) : defaultDuration.startTime,
|
|
28
|
+
endTime: input.requestEndTime ? (0, constants_js_1.convertToUtc)(input.requestEndTime) : defaultDuration.endTime,
|
|
29
|
+
}, { durationLimitMs: DURATION_LIMIT_MS });
|
|
30
|
+
this.input = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ plusFriendId: input.plusFriendId, requestStartTime: (0, constants_js_1.convertToKst)(startTimeMs), requestEndTime: (0, constants_js_1.convertToKst)(endTimeMs), pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)) }, (input.requestStatusName && { requestStatusName: input.requestStatusName })), (input.messageStatusName && { messageStatusName: input.messageStatusName })), (input.requestId && { requestId: input.requestId, pageSize: MAX_LIMIT })), (input.messageId && { messageId: input.messageId })), (input.templateCode && { templateCode: input.templateCode })), (input.to && { to: (0, constants_js_1.prettyPhoneNum)(input.to) })), (input.nextToken && { nextToken: input.nextToken }));
|
|
16
31
|
this.serializer = ListAlimtalkStatus_js_1.se_ListAlimtalkStatusCommand;
|
|
17
32
|
this.deserializer = ListAlimtalkStatus_js_1.de_ListAlimtalkStatusCommand;
|
|
18
33
|
}
|
|
19
34
|
}
|
|
20
35
|
exports.ListAlimtalkStatusCommand = ListAlimtalkStatusCommand;
|
|
21
|
-
const getDefaultRequestDurationKST = (config) => {
|
|
22
|
-
const now = new Date().getTime() + KST_OFFSET;
|
|
23
|
-
return {
|
|
24
|
-
startTime: new Date(now - config.durationLimit).toISOString().replace(/\.\d{3}Z$/, ""),
|
|
25
|
-
endTime: new Date(now).toISOString().replace(/\.\d{3}Z$/, ""),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListSMSStatusCommand = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
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일 이내만 조회 가능
|
|
8
|
+
const MAX_LIMIT = 100;
|
|
9
|
+
const DEFAULT_LIMIT = 20;
|
|
10
|
+
class ListSMSStatusCommand extends index_js_1.SensCommand {
|
|
11
|
+
constructor(input) {
|
|
12
|
+
var _a;
|
|
13
|
+
super(input);
|
|
14
|
+
if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
|
|
15
|
+
throw new index_js_1.SensError({
|
|
16
|
+
code: -1,
|
|
17
|
+
type: "SDK.GENERAL_ERROR",
|
|
18
|
+
message: "페이지네이션 검색 조건 불일치",
|
|
19
|
+
errors: [
|
|
20
|
+
"nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션이 모두 동일하게 유지되어야 합니다.",
|
|
21
|
+
"requestStartTime, requestEndTime, pageSize 옵션을 확인해주세요.",
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const defaultDuration = (0, constants_js_1.getDefaultRequestDuration)({ durationLimitMs: DURATION_LIMIT_MS });
|
|
26
|
+
const { startTimeMs, endTimeMs } = (0, constants_js_1.resolveRequestDuration)({
|
|
27
|
+
startTime: input.requestStartTime ? (0, constants_js_1.convertToUtc)(input.requestStartTime) : defaultDuration.startTime,
|
|
28
|
+
endTime: input.requestEndTime ? (0, constants_js_1.convertToUtc)(input.requestEndTime) : defaultDuration.endTime,
|
|
29
|
+
}, { durationLimitMs: DURATION_LIMIT_MS });
|
|
30
|
+
this.input = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ requestStartTime: (0, constants_js_1.convertToKst)(startTimeMs), requestEndTime: (0, constants_js_1.convertToKst)(endTimeMs), pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)) }, (input.type && { type: input.type })), (input.contentType && { contentType: input.contentType })), (input.status && { status: input.status })), (input.from && { from: (0, constants_js_1.prettyPhoneNum)(input.from) })), (input.to && { to: (0, constants_js_1.prettyPhoneNum)(input.to) })), (input.statusName && { statusName: input.statusName })), (input.nextToken && { nextToken: input.nextToken }));
|
|
31
|
+
this.serializer = ListSMSStatus_js_1.se_ListSMSStatusCommand;
|
|
32
|
+
this.deserializer = ListSMSStatus_js_1.de_ListSMSStatusCommand;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ListSMSStatusCommand = ListSMSStatusCommand;
|
|
@@ -22,27 +22,20 @@ exports.SendAlimtalkCommand = SendAlimtalkCommand;
|
|
|
22
22
|
const resolveAlimtalkMessages = (messages, config) => {
|
|
23
23
|
if (!messages.length || messages.length > config.maxRecipients) {
|
|
24
24
|
throw new index_js_1.SensError({
|
|
25
|
-
code:
|
|
26
|
-
type: "
|
|
27
|
-
message:
|
|
28
|
-
invalidInputs: [
|
|
29
|
-
{
|
|
30
|
-
type: "not-valid.args",
|
|
31
|
-
message: `메세지 동시 발송은 최소 1명, 최대 ${config.maxRecipients}명까지 가능합니다.`,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
25
|
+
code: -1,
|
|
26
|
+
type: "SDK.GENERAL_ERROR",
|
|
27
|
+
message: `알림톡 동시 발송은 최소 1명, 최대 ${config.maxRecipients}명까지 가능합니다.`,
|
|
34
28
|
});
|
|
35
29
|
}
|
|
36
30
|
const result = messages.map((message) => {
|
|
37
31
|
if (message.content.length > config.maxContentLength) {
|
|
38
32
|
throw new index_js_1.SensError({
|
|
39
|
-
code:
|
|
40
|
-
type: "
|
|
41
|
-
message:
|
|
42
|
-
invalidInputs: [{ type: "not-valid.args", message: `메세지 최대 길이는 ${config.maxContentLength}글자입니다` }],
|
|
33
|
+
code: -1,
|
|
34
|
+
type: "SDK.GENERAL_ERROR",
|
|
35
|
+
message: `알림톡 최대 길이는 ${config.maxContentLength}글자입니다`,
|
|
43
36
|
});
|
|
44
37
|
}
|
|
45
|
-
return Object.assign({ to: message.to.replace(/\-/gi, ""), content: message.content }, (message.buttons && message.buttons.length && { buttons: message.buttons }));
|
|
38
|
+
return Object.assign({ to: message.to.replace(/\-/gi, ""), content: message.content, useSmsFailover: message.useSmsFailover != undefined ? message.useSmsFailover : false }, (message.buttons && message.buttons.length && { buttons: message.buttons }));
|
|
46
39
|
});
|
|
47
40
|
return result;
|
|
48
41
|
};
|
|
@@ -36,12 +36,9 @@ const resolveSendFile = (file, options) => {
|
|
|
36
36
|
const ext = parsed.ext.toLocaleLowerCase();
|
|
37
37
|
if (!options.supportExt.includes(ext)) {
|
|
38
38
|
throw new index_js_1.SensError({
|
|
39
|
-
code:
|
|
40
|
-
type: "
|
|
41
|
-
message: "
|
|
42
|
-
invalidInputs: [
|
|
43
|
-
{ type: "not-valid.args", message: `${options.supportExt.join(", ")} 형식의 첨부파일만 지원합니다.` },
|
|
44
|
-
],
|
|
39
|
+
code: -1,
|
|
40
|
+
type: "SDK.GENERAL_ERROR",
|
|
41
|
+
message: `MMS는 ${options.supportExt.join(", ")} 형식의 첨부파일만 보낼 수 있습니다.`,
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
if (file.body) {
|
|
@@ -55,10 +52,9 @@ const resolveSendFile = (file, options) => {
|
|
|
55
52
|
}
|
|
56
53
|
if (!(0, node_fs_1.existsSync)(file.name)) {
|
|
57
54
|
throw new index_js_1.SensError({
|
|
58
|
-
code:
|
|
59
|
-
type: "
|
|
60
|
-
message:
|
|
61
|
-
invalidInputs: [{ type: "not-valid.args", message: `${file.name} 파일이 존재하지 않습니다.` }],
|
|
55
|
+
code: -1,
|
|
56
|
+
type: "SDK.GENERAL_ERROR",
|
|
57
|
+
message: `${file.name} 첨부파일이 존재하지 않습니다.`,
|
|
62
58
|
});
|
|
63
59
|
}
|
|
64
60
|
const buffer = (0, node_fs_1.readFileSync)(file.name);
|
|
@@ -74,15 +70,9 @@ const checkSizeLimit = (buffer, maxKiB) => {
|
|
|
74
70
|
const kibSize = Math.ceil(byteSize / 1024);
|
|
75
71
|
if (kibSize > maxKiB) {
|
|
76
72
|
throw new index_js_1.SensError({
|
|
77
|
-
code:
|
|
78
|
-
type: "
|
|
79
|
-
message:
|
|
80
|
-
invalidInputs: [
|
|
81
|
-
{
|
|
82
|
-
type: "not-valid.args",
|
|
83
|
-
message: `최대 ${maxKiB}KiB까지 전송 가능합니다. 현재 ${kibSize}KiB`,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
73
|
+
code: -1,
|
|
74
|
+
type: "SDK.GENERAL_ERROR",
|
|
75
|
+
message: `첨부파일은 ${maxKiB}KiB까지 전송 가능합니다. 현재 ${kibSize}KiB`,
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
78
|
return;
|
|
@@ -36,18 +36,16 @@ const getMessageType = (input) => {
|
|
|
36
36
|
const contentLength = (0, constants_1.getContentLength)(input.content);
|
|
37
37
|
if (!contentLength) {
|
|
38
38
|
throw new index_js_1.SensError({
|
|
39
|
-
code:
|
|
40
|
-
type: "
|
|
39
|
+
code: -1,
|
|
40
|
+
type: "SDK.GENERAL_ERROR",
|
|
41
41
|
message: "메세지 내용이 없습니다.",
|
|
42
|
-
invalidInputs: [{ type: "not-valid.args", message: "메세지 내용을 확인해주세요." }],
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
if (contentLength > LMS_MAX_CONTENT_LENGTH) {
|
|
46
45
|
throw new index_js_1.SensError({
|
|
47
|
-
code:
|
|
48
|
-
type: "
|
|
49
|
-
message:
|
|
50
|
-
invalidInputs: [{ type: "not-valid.args", message: `메세지 최대 길이는 ${LMS_MAX_CONTENT_LENGTH}글자입니다` }],
|
|
46
|
+
code: -1,
|
|
47
|
+
type: "SDK.GENERAL_ERROR",
|
|
48
|
+
message: `메세지 최대 길이는 ${LMS_MAX_CONTENT_LENGTH}글자입니다`,
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
return contentLength > SMS_MAX_CONTENT_LENGTH ? "LMS" : "SMS";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContentLength = exports.prettyPhoneNum = exports.trimText = void 0;
|
|
3
|
+
exports.resolveRequestDuration = exports.getDefaultRequestDuration = exports.convertToKst = exports.convertToUtc = exports.getContentLength = exports.prettyPhoneNum = exports.trimText = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
4
5
|
const trimText = (input) => input.trim();
|
|
5
6
|
exports.trimText = trimText;
|
|
6
7
|
const prettyPhoneNum = (input) => input.replace(/\-/gi, "");
|
|
@@ -15,3 +16,48 @@ const getContentLength = (input) => {
|
|
|
15
16
|
}, 0);
|
|
16
17
|
};
|
|
17
18
|
exports.getContentLength = getContentLength;
|
|
19
|
+
const convertToUtc = (input) => {
|
|
20
|
+
const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
21
|
+
return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
|
|
22
|
+
};
|
|
23
|
+
exports.convertToUtc = convertToUtc;
|
|
24
|
+
const convertToKst = (input) => {
|
|
25
|
+
const KST_OFFSET = 9 * 3600000;
|
|
26
|
+
return new Date(input + KST_OFFSET).toISOString().replace(/\.\d{3}Z$/, "");
|
|
27
|
+
};
|
|
28
|
+
exports.convertToKst = convertToKst;
|
|
29
|
+
// UTC
|
|
30
|
+
const getDefaultRequestDuration = (config) => {
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
return {
|
|
33
|
+
startTime: new Date(now - config.durationLimitMs).toISOString(),
|
|
34
|
+
endTime: new Date(now).toISOString(),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.getDefaultRequestDuration = getDefaultRequestDuration;
|
|
38
|
+
// UTC
|
|
39
|
+
const resolveRequestDuration = (input, config) => {
|
|
40
|
+
const start = new Date(input.startTime).getTime();
|
|
41
|
+
const end = new Date(input.endTime).getTime();
|
|
42
|
+
const diff = end - start;
|
|
43
|
+
if (diff < 0) {
|
|
44
|
+
throw new index_js_1.SensError({
|
|
45
|
+
code: -1,
|
|
46
|
+
type: "SDK.GENERAL_ERROR",
|
|
47
|
+
message: "조회 가능 날짜 오류. 종료일이 시작일보다 빠를 수 없습니다.",
|
|
48
|
+
errors: [`종료일: ${input.endTime}`, `시작일: ${input.startTime}`],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (diff > config.durationLimitMs) {
|
|
52
|
+
throw new index_js_1.SensError({
|
|
53
|
+
code: -1,
|
|
54
|
+
type: "SDK.GENERAL_ERROR",
|
|
55
|
+
message: `최대 ${config.durationLimitMs / (24 * 3600000)}일 이내에서 조회 가능합니다.`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
startTimeMs: start,
|
|
60
|
+
endTimeMs: end,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.resolveRequestDuration = resolveRequestDuration;
|
|
@@ -22,6 +22,7 @@ __exportStar(require("./GetSMSStatusCommand.js"), exports);
|
|
|
22
22
|
__exportStar(require("./ListAlimtalkChannelsCommand.js"), exports);
|
|
23
23
|
__exportStar(require("./ListAlimtalkStatusCommand.js"), exports);
|
|
24
24
|
__exportStar(require("./ListAlimtalkTemplatesCommand.js"), exports);
|
|
25
|
+
__exportStar(require("./ListSMSStatusCommand.js"), exports);
|
|
25
26
|
__exportStar(require("./SendAlimtalkCommand.js"), exports);
|
|
26
27
|
__exportStar(require("./SendMMSCommand.js"), exports);
|
|
27
28
|
__exportStar(require("./SendSMSCommand.js"), exports);
|
package/dist-cjs/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./commands/index.js"), exports);
|
|
18
18
|
__exportStar(require("./SensClient.js"), exports);
|
|
19
|
+
__exportStar(require("./models/SensError.js"), exports);
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.middlewareIngestkoreaMetadata = void 0;
|
|
13
13
|
const constants_js_1 = require("./constants.js");
|
|
14
14
|
const middlewareIngestkoreaMetadata = (next) => (input, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
input.request.headers = Object.assign(Object.assign({}, input.request.headers), { [constants_js_1.INGESTKOREA_USER_AGENT]: "@ingestkorea/client-sens/1.
|
|
15
|
+
input.request.headers = Object.assign(Object.assign({}, input.request.headers), { [constants_js_1.INGESTKOREA_USER_AGENT]: "@ingestkorea/client-sens/1.10.x" });
|
|
16
16
|
return next(input, context);
|
|
17
17
|
});
|
|
18
18
|
exports.middlewareIngestkoreaMetadata = middlewareIngestkoreaMetadata;
|
|
@@ -10,54 +10,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.middlewareRetry = void 0;
|
|
13
|
-
const
|
|
13
|
+
const index_js_1 = require("../models/index.js");
|
|
14
14
|
const constants_js_1 = require("./constants.js");
|
|
15
15
|
const middlewareRetry = (next) => (input, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
var _c;
|
|
18
16
|
const MAX_RETRIES = 3;
|
|
17
|
+
const MIN_DELAY_MS = 300;
|
|
19
18
|
const BASE_DELAY_MS = 500;
|
|
20
19
|
const MAX_DELAY_MS = 5000;
|
|
21
20
|
let attempts = 0;
|
|
22
21
|
let totalRetryDelay = 0;
|
|
23
|
-
|
|
24
|
-
let lastError = new util_error_handler_1.IngestkoreaError({
|
|
25
|
-
code: 400,
|
|
26
|
-
type: "Bad Request",
|
|
27
|
-
message: "Invalid Request",
|
|
28
|
-
description: { attempts, maxRetries: MAX_RETRIES, totalRetryDelay },
|
|
29
|
-
});
|
|
22
|
+
input.request.headers = Object.assign({}, input.request.headers);
|
|
30
23
|
while (attempts < MAX_RETRIES) {
|
|
31
|
-
|
|
32
|
-
const requestLog = `attempt=${
|
|
24
|
+
attempts++;
|
|
25
|
+
const requestLog = `attempt=${attempts}; max=${MAX_RETRIES}; totalRetryDelay=${totalRetryDelay}`;
|
|
33
26
|
input.request.headers[constants_js_1.INGESTKOREA_REQUEST_LOG] = requestLog;
|
|
34
27
|
try {
|
|
35
28
|
const { response } = yield next(input, context);
|
|
36
|
-
response.headers[constants_js_1.INGESTKOREA_RETRY] =
|
|
29
|
+
response.headers[constants_js_1.INGESTKOREA_RETRY] = attempts.toString();
|
|
37
30
|
response.headers[constants_js_1.INGESTKOREA_RETRY_DELAY] = totalRetryDelay.toString();
|
|
38
31
|
return { response };
|
|
39
32
|
}
|
|
40
33
|
catch (error) {
|
|
41
|
-
attempts++;
|
|
42
|
-
lastError.error.description = { attempts, maxRetries: MAX_RETRIES, totalRetryDelay };
|
|
43
|
-
if (error instanceof util_error_handler_1.IngestkoreaError) {
|
|
44
|
-
lastError.error.description = Object.assign(Object.assign({}, lastError.error.description), { detail: error.error.description });
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
lastError.error.description = Object.assign(Object.assign({}, lastError.error.description), { detail: String((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error) });
|
|
48
|
-
}
|
|
49
34
|
if (attempts >= MAX_RETRIES) {
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
throw new index_js_1.SensError({
|
|
36
|
+
code: -1,
|
|
37
|
+
type: "SDK.REQUEST_ERROR",
|
|
38
|
+
message: error instanceof Error ? error.message : requestLog,
|
|
39
|
+
});
|
|
52
40
|
}
|
|
53
41
|
const exp = BASE_DELAY_MS * Math.pow(2, (attempts - 1));
|
|
54
42
|
const capped = Math.min(MAX_DELAY_MS, exp);
|
|
55
|
-
const
|
|
43
|
+
const baseWait = Math.max(MIN_DELAY_MS, Math.floor(capped / 2));
|
|
44
|
+
const jitter = Math.floor(Math.random() * (capped - baseWait));
|
|
45
|
+
const delay = baseWait + jitter;
|
|
56
46
|
totalRetryDelay += delay;
|
|
57
|
-
lastError.error.description = { attempts, maxRetries: MAX_RETRIES, totalRetryDelay };
|
|
58
47
|
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
59
48
|
}
|
|
60
49
|
}
|
|
61
|
-
throw
|
|
50
|
+
throw new index_js_1.SensError({
|
|
51
|
+
code: -1,
|
|
52
|
+
type: "SDK.UNKNOWN_ERROR",
|
|
53
|
+
message: "Unexpected retry loop termination",
|
|
54
|
+
});
|
|
62
55
|
});
|
|
63
56
|
exports.middlewareRetry = middlewareRetry;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SensError = void 0;
|
|
4
|
+
class SensError extends Error {
|
|
5
|
+
constructor(info) {
|
|
6
|
+
super(info.message);
|
|
7
|
+
this.name = "SensError";
|
|
8
|
+
this.code = info.code;
|
|
9
|
+
this.type = info.type;
|
|
10
|
+
this.errors = info.errors || [];
|
|
11
|
+
this.timestamp = new Date().toISOString();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SensError = SensError;
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.
|
|
3
|
+
exports.NCLOUD_ERROR_BODY_SPEC = exports.SENS_ERROR_BODY_SPEC = exports.NCLOUD_ERROR_CODE_SPEC = exports.SENS_ERROR_CODE_SPEC = void 0;
|
|
4
|
+
exports.SENS_ERROR_CODE_SPEC = {
|
|
5
|
+
400: "Bad Request",
|
|
6
|
+
401: "Unauthorized",
|
|
7
|
+
403: "Forbidden",
|
|
8
|
+
404: "Not Found",
|
|
9
|
+
429: "Too Many Requests",
|
|
10
|
+
500: "Internal Server Error",
|
|
11
|
+
};
|
|
12
|
+
exports.NCLOUD_ERROR_CODE_SPEC = {
|
|
13
|
+
"100": { status: 400, type: exports.SENS_ERROR_CODE_SPEC["400"] },
|
|
14
|
+
"200": { status: 401, type: exports.SENS_ERROR_CODE_SPEC["401"] },
|
|
15
|
+
"210": { status: 403, type: exports.SENS_ERROR_CODE_SPEC["403"] },
|
|
16
|
+
"300": { status: 404, type: exports.SENS_ERROR_CODE_SPEC["404"] },
|
|
17
|
+
"400": { status: 429, type: exports.SENS_ERROR_CODE_SPEC["429"] },
|
|
18
|
+
"410": { status: 429, type: exports.SENS_ERROR_CODE_SPEC["429"] },
|
|
19
|
+
"420": { status: 429, type: exports.SENS_ERROR_CODE_SPEC["429"] },
|
|
20
|
+
"900": { status: 500, type: exports.SENS_ERROR_CODE_SPEC["500"] },
|
|
21
|
+
};
|
|
22
|
+
exports.SENS_ERROR_BODY_SPEC = [
|
|
23
|
+
["status", "number", true],
|
|
24
|
+
["errorMessage", "string", false],
|
|
25
|
+
["errors", "object", false],
|
|
26
|
+
];
|
|
27
|
+
exports.NCLOUD_ERROR_BODY_SPEC = [
|
|
28
|
+
["errorCode", "string", true],
|
|
29
|
+
["message", "string", false],
|
|
30
|
+
["details", "string", false],
|
|
31
|
+
];
|
package/dist-cjs/models/index.js
CHANGED
|
@@ -22,11 +22,13 @@ __exportStar(require("./GetSMSStatus.js"), exports);
|
|
|
22
22
|
__exportStar(require("./ListAlimtalkChannels.js"), exports);
|
|
23
23
|
__exportStar(require("./ListAlimtalkStatus.js"), exports);
|
|
24
24
|
__exportStar(require("./ListAlimtalkTemplates.js"), exports);
|
|
25
|
+
__exportStar(require("./ListSMSStatus.js"), exports);
|
|
25
26
|
__exportStar(require("./MetadataBearer.js"), exports);
|
|
26
27
|
__exportStar(require("./SendAlimtalk.js"), exports);
|
|
27
28
|
__exportStar(require("./SendMMS.js"), exports);
|
|
28
29
|
__exportStar(require("./SendSMS.js"), exports);
|
|
29
30
|
__exportStar(require("./SensClient.js"), exports);
|
|
30
31
|
__exportStar(require("./SensCommand.js"), exports);
|
|
32
|
+
__exportStar(require("./SensError.js"), exports);
|
|
31
33
|
__exportStar(require("./SensErrorInfo.js"), exports);
|
|
32
34
|
__exportStar(require("./SensMiddleware.js"), exports);
|
|
@@ -45,15 +45,15 @@ const de_GetAlimtalkStatusCommand = (response, config) => __awaiter(void 0, void
|
|
|
45
45
|
exports.de_GetAlimtalkStatusCommand = de_GetAlimtalkStatusCommand;
|
|
46
46
|
const de_GetAlimtalkStatusResult = (output) => {
|
|
47
47
|
return {
|
|
48
|
-
requestId: output.requestId
|
|
49
|
-
statusCode: output.statusCode
|
|
50
|
-
statusName: output.statusName
|
|
48
|
+
requestId: output.requestId ? output.requestId : undefined,
|
|
49
|
+
statusCode: output.statusCode ? output.statusCode : undefined,
|
|
50
|
+
statusName: output.statusName ? output.statusName : undefined,
|
|
51
51
|
messages: output.messages ? de_AlimtalkMessageStatusList(output.messages) : [],
|
|
52
52
|
pageSize: output.pageSize !== undefined ? output.pageSize : undefined,
|
|
53
53
|
pageIndex: output.pageIndex !== undefined ? output.pageIndex : undefined,
|
|
54
54
|
itemCount: output.itemCount !== undefined ? output.itemCount : undefined,
|
|
55
55
|
hasMore: output.hasMore !== undefined ? output.hasMore : undefined,
|
|
56
|
-
nextToken: output.nextToken
|
|
56
|
+
nextToken: output.nextToken ? output.nextToken : undefined,
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
exports.de_GetAlimtalkStatusResult = de_GetAlimtalkStatusResult;
|
|
@@ -61,6 +61,6 @@ const de_AlimtalkMessageStatusList = (output) => {
|
|
|
61
61
|
return (output || []).filter((e) => e != null).map((entry) => (0, exports.de_AlimtalkMessageStatus)(entry));
|
|
62
62
|
};
|
|
63
63
|
const de_AlimtalkMessageStatus = (output) => {
|
|
64
|
-
return Object.assign(Object.assign({}, (0, SendAlimtalk_js_1.de_AlimtalkMessageRequestStatus)(output)), { requestId: output.requestId
|
|
64
|
+
return Object.assign(Object.assign({}, (0, SendAlimtalk_js_1.de_AlimtalkMessageRequestStatus)(output)), { requestId: output.requestId ? output.requestId : undefined, requestTime: output.requestTime ? (0, constants_js_1.convertToUtc)(output.requestTime) : undefined, plusFriendId: output.plusFriendId ? output.plusFriendId : undefined, templateCode: output.templateCode ? output.templateCode : undefined, completeTime: output.completeTime ? (0, constants_js_1.convertToUtc)(output.completeTime) : undefined, messageStatusCode: output.messageStatusCode ? output.messageStatusCode : undefined, messageStatusName: output.messageStatusName ? output.messageStatusName : undefined, messageStatusDesc: output.messageStatusDesc ? output.messageStatusDesc : undefined });
|
|
65
65
|
};
|
|
66
66
|
exports.de_AlimtalkMessageStatus = de_AlimtalkMessageStatus;
|
|
@@ -60,7 +60,7 @@ const de_Comment = (output) => {
|
|
|
60
60
|
commentId: output.commentId != undefined ? output.commentId : undefined,
|
|
61
61
|
content: output.content != undefined ? output.content : undefined,
|
|
62
62
|
status: output.status != undefined ? output.status : undefined,
|
|
63
|
-
createTime: output.createTime != undefined ? output.createTime : undefined,
|
|
63
|
+
createTime: output.createTime != undefined ? (0, constants_js_1.convertToUtc)(output.createTime) : undefined,
|
|
64
64
|
attachment: output.attachment != undefined ? de_AttachmentList(output.attachment) : [],
|
|
65
65
|
};
|
|
66
66
|
};
|
|
@@ -47,13 +47,14 @@ const de_SMSMessageStatusList = (output) => {
|
|
|
47
47
|
return (output || []).filter((e) => e != null).map((entry) => de_SMSMessageStatus(entry));
|
|
48
48
|
};
|
|
49
49
|
const de_SMSMessageStatus = (output) => {
|
|
50
|
-
return Object.assign(Object.assign({}, (0, GetSMSStatus_js_1.de_SMSMessageRequestStatus)(output)), {
|
|
50
|
+
return Object.assign(Object.assign({}, (0, GetSMSStatus_js_1.de_SMSMessageRequestStatus)(output)), { subject: output.subject ? output.subject : undefined, content: output.content ? output.content : undefined, files: output.files ? de_FileList(output.files) : [] });
|
|
51
51
|
};
|
|
52
52
|
const de_FileList = (output) => {
|
|
53
53
|
return (output || []).filter((e) => e != null).map((entry) => de_File(entry));
|
|
54
54
|
};
|
|
55
55
|
const de_File = (output) => {
|
|
56
56
|
return {
|
|
57
|
-
|
|
57
|
+
fileId: output.fileId ? output.fileId : undefined,
|
|
58
|
+
name: output.name ? output.name : undefined,
|
|
58
59
|
};
|
|
59
60
|
};
|