@ingestkorea/client-sens 1.7.0 → 1.9.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.
Files changed (157) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +98 -63
  3. package/dist-cjs/SensClient.js +57 -28
  4. package/dist-cjs/commands/GetAlimtalkResultCommand.js +5 -32
  5. package/dist-cjs/commands/GetAlimtalkStatusCommand.js +7 -35
  6. package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +5 -32
  7. package/dist-cjs/commands/GetSMSResultCommand.js +8 -33
  8. package/dist-cjs/commands/GetSMSStatusCommand.js +7 -33
  9. package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +6 -33
  10. package/dist-cjs/commands/ListAlimtalkStatusCommand.js +29 -35
  11. package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +5 -32
  12. package/dist-cjs/commands/ListSMSStatusCommand.js +37 -0
  13. package/dist-cjs/commands/SendAlimtalkCommand.js +36 -44
  14. package/dist-cjs/commands/SendMMSCommand.js +67 -103
  15. package/dist-cjs/commands/SendSMSCommand.js +38 -71
  16. package/dist-cjs/commands/constants.js +57 -14
  17. package/dist-cjs/commands/index.js +12 -11
  18. package/dist-cjs/index.js +2 -2
  19. package/dist-cjs/middleware/constants.js +10 -0
  20. package/dist-cjs/middleware/index.js +3 -4
  21. package/dist-cjs/middleware/middleware-metadata.js +4 -5
  22. package/dist-cjs/middleware/middleware-retry.js +32 -27
  23. package/dist-cjs/middleware/middleware-sign.js +10 -9
  24. package/dist-cjs/models/SendAlimtalk.js +3 -0
  25. package/dist-cjs/models/SendMMS.js +3 -0
  26. package/dist-cjs/models/SensClient.js +2 -0
  27. package/dist-cjs/models/SensErrorInfo.js +13 -0
  28. package/dist-cjs/models/SensMiddleware.js +2 -0
  29. package/dist-cjs/models/index.js +17 -14
  30. package/dist-cjs/protocols/GetAlimtalkResult.js +19 -22
  31. package/dist-cjs/protocols/GetAlimtalkStatus.js +39 -40
  32. package/dist-cjs/protocols/GetAlimtalkTemplate.js +56 -90
  33. package/dist-cjs/protocols/GetSMSResult.js +31 -48
  34. package/dist-cjs/protocols/GetSMSStatus.js +51 -37
  35. package/dist-cjs/protocols/ListAlimtalkChannels.js +27 -31
  36. package/dist-cjs/protocols/ListAlimtalkStatus.js +22 -19
  37. package/dist-cjs/protocols/ListAlimtalkTemplates.js +33 -25
  38. package/dist-cjs/protocols/ListSMSStatus.js +48 -0
  39. package/dist-cjs/protocols/SendAlimtalk.js +23 -27
  40. package/dist-cjs/protocols/SendMMS.js +8 -38
  41. package/dist-cjs/protocols/SendSMS.js +20 -22
  42. package/dist-cjs/protocols/constants.js +103 -34
  43. package/dist-es/SensClient.js +63 -30
  44. package/dist-es/commands/GetAlimtalkResultCommand.js +9 -19
  45. package/dist-es/commands/GetAlimtalkStatusCommand.js +12 -19
  46. package/dist-es/commands/GetAlimtalkTemplateCommand.js +9 -19
  47. package/dist-es/commands/GetSMSResultCommand.js +10 -20
  48. package/dist-es/commands/GetSMSStatusCommand.js +13 -20
  49. package/dist-es/commands/ListAlimtalkChannelsCommand.js +10 -22
  50. package/dist-es/commands/ListAlimtalkStatusCommand.js +39 -28
  51. package/dist-es/commands/ListAlimtalkTemplatesCommand.js +9 -19
  52. package/dist-es/commands/ListSMSStatusCommand.js +48 -0
  53. package/dist-es/commands/SendAlimtalkCommand.js +35 -30
  54. package/dist-es/commands/SendMMSCommand.js +70 -100
  55. package/dist-es/commands/SendSMSCommand.js +51 -66
  56. package/dist-es/commands/constants.js +65 -15
  57. package/dist-es/commands/index.js +28 -11
  58. package/dist-es/index.js +18 -2
  59. package/dist-es/middleware/constants.js +10 -0
  60. package/dist-es/middleware/index.js +19 -4
  61. package/dist-es/middleware/middleware-metadata.js +11 -5
  62. package/dist-es/middleware/middleware-retry.js +39 -30
  63. package/dist-es/middleware/middleware-sign.js +19 -14
  64. package/dist-es/models/GetAlimtalkResult.js +2 -1
  65. package/dist-es/models/GetAlimtalkStatus.js +2 -1
  66. package/dist-es/models/GetAlimtalkTemplate.js +2 -1
  67. package/dist-es/models/GetSMSResult.js +2 -1
  68. package/dist-es/models/GetSMSStatus.js +2 -1
  69. package/dist-es/models/ListAlimtalkChannels.js +2 -1
  70. package/dist-es/models/ListAlimtalkStatus.js +2 -1
  71. package/dist-es/models/ListAlimtalkTemplates.js +2 -1
  72. package/dist-es/models/ListSMSStatus.js +2 -0
  73. package/dist-es/models/MetadataBearer.js +2 -1
  74. package/dist-es/models/SendAlimtalk.js +5 -1
  75. package/dist-es/models/SendMMS.js +5 -1
  76. package/dist-es/models/SendSMS.js +2 -1
  77. package/dist-es/models/SensClient.js +2 -0
  78. package/dist-es/models/SensCommand.js +5 -1
  79. package/dist-es/models/SensErrorInfo.js +13 -0
  80. package/dist-es/models/SensMiddleware.js +2 -0
  81. package/dist-es/models/index.js +33 -14
  82. package/dist-es/protocols/GetAlimtalkResult.js +24 -23
  83. package/dist-es/protocols/GetAlimtalkStatus.js +51 -47
  84. package/dist-es/protocols/GetAlimtalkTemplate.js +78 -87
  85. package/dist-es/protocols/GetSMSResult.js +40 -47
  86. package/dist-es/protocols/GetSMSStatus.js +55 -37
  87. package/dist-es/protocols/ListAlimtalkChannels.js +31 -31
  88. package/dist-es/protocols/ListAlimtalkStatus.js +26 -32
  89. package/dist-es/protocols/ListAlimtalkTemplates.js +37 -24
  90. package/dist-es/protocols/ListSMSStatus.js +42 -0
  91. package/dist-es/protocols/SendAlimtalk.js +27 -26
  92. package/dist-es/protocols/SendMMS.js +10 -49
  93. package/dist-es/protocols/SendSMS.js +24 -31
  94. package/dist-es/protocols/constants.js +119 -39
  95. package/dist-types/SensClient.d.ts +3 -20
  96. package/dist-types/commands/GetAlimtalkResultCommand.d.ts +5 -10
  97. package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +5 -10
  98. package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +5 -10
  99. package/dist-types/commands/GetSMSResultCommand.d.ts +5 -10
  100. package/dist-types/commands/GetSMSStatusCommand.d.ts +5 -10
  101. package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +5 -10
  102. package/dist-types/commands/ListAlimtalkStatusCommand.d.ts +5 -10
  103. package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +5 -10
  104. package/dist-types/commands/ListSMSStatusCommand.d.ts +11 -0
  105. package/dist-types/commands/SendAlimtalkCommand.d.ts +5 -10
  106. package/dist-types/commands/SendMMSCommand.d.ts +5 -10
  107. package/dist-types/commands/SendSMSCommand.d.ts +9 -10
  108. package/dist-types/commands/constants.d.ts +14 -4
  109. package/dist-types/commands/index.d.ts +12 -11
  110. package/dist-types/index.d.ts +2 -2
  111. package/dist-types/middleware/constants.d.ts +7 -0
  112. package/dist-types/middleware/index.d.ts +3 -4
  113. package/dist-types/middleware/middleware-metadata.d.ts +2 -2
  114. package/dist-types/middleware/middleware-retry.d.ts +2 -2
  115. package/dist-types/middleware/middleware-sign.d.ts +2 -2
  116. package/dist-types/models/GetAlimtalkResult.d.ts +3 -3
  117. package/dist-types/models/GetAlimtalkStatus.d.ts +8 -5
  118. package/dist-types/models/GetAlimtalkTemplate.d.ts +5 -5
  119. package/dist-types/models/GetSMSResult.d.ts +7 -15
  120. package/dist-types/models/GetSMSStatus.d.ts +19 -4
  121. package/dist-types/models/ListAlimtalkChannels.d.ts +4 -4
  122. package/dist-types/models/ListAlimtalkStatus.d.ts +8 -8
  123. package/dist-types/models/ListAlimtalkTemplates.d.ts +2 -2
  124. package/dist-types/models/ListSMSStatus.d.ts +15 -0
  125. package/dist-types/models/MetadataBearer.d.ts +3 -3
  126. package/dist-types/models/SendAlimtalk.d.ts +7 -4
  127. package/dist-types/models/SendMMS.d.ts +5 -3
  128. package/dist-types/models/SendSMS.d.ts +2 -2
  129. package/dist-types/models/SensClient.d.ts +17 -0
  130. package/dist-types/models/SensCommand.d.ts +4 -6
  131. package/dist-types/models/SensErrorInfo.d.ts +21 -0
  132. package/dist-types/models/SensMiddleware.d.ts +8 -0
  133. package/dist-types/models/index.d.ts +17 -14
  134. package/dist-types/protocols/GetAlimtalkResult.d.ts +4 -11
  135. package/dist-types/protocols/GetAlimtalkStatus.d.ts +6 -12
  136. package/dist-types/protocols/GetAlimtalkTemplate.d.ts +4 -14
  137. package/dist-types/protocols/GetSMSResult.d.ts +4 -12
  138. package/dist-types/protocols/GetSMSStatus.d.ts +6 -11
  139. package/dist-types/protocols/ListAlimtalkChannels.d.ts +4 -11
  140. package/dist-types/protocols/ListAlimtalkStatus.d.ts +4 -10
  141. package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -12
  142. package/dist-types/protocols/ListSMSStatus.d.ts +4 -0
  143. package/dist-types/protocols/SendAlimtalk.d.ts +5 -12
  144. package/dist-types/protocols/SendMMS.d.ts +4 -10
  145. package/dist-types/protocols/SendSMS.d.ts +5 -10
  146. package/dist-types/protocols/constants.d.ts +4 -2
  147. package/package.json +20 -4
  148. package/.github/pull_request_template.md +0 -19
  149. package/dist-cjs/middleware/middleware-sort-headers.js +0 -25
  150. package/dist-cjs/protocols/index.js +0 -28
  151. package/dist-es/middleware/middleware-sort-headers.js +0 -12
  152. package/dist-es/models/Middleware.js +0 -1
  153. package/dist-es/protocols/index.js +0 -12
  154. package/dist-types/middleware/middleware-sort-headers.d.ts +0 -2
  155. package/dist-types/models/Middleware.d.ts +0 -12
  156. package/dist-types/protocols/index.d.ts +0 -12
  157. /package/dist-cjs/models/{Middleware.js → ListSMSStatus.js} +0 -0
@@ -1,26 +1,16 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_GetSMSResultCommand, deserializeIngestkorea_restJson_GetSMSResultCommand, } from "../protocols/GetSMSResult";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- export class GetSMSResultCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSMSResultCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetSMSResult_js_1 = require("../protocols/GetSMSResult.js");
6
+ class GetSMSResultCommand extends index_js_1.SensCommand {
5
7
  constructor(input) {
6
8
  super(input);
7
9
  this.input = {
8
- ...input,
10
+ messageId: input.messageId,
9
11
  };
10
- }
11
- async serialize(input, config) {
12
- if (!config.serviceId.sms)
13
- throw new IngestkoreaError({
14
- code: 400,
15
- type: "Bad Request",
16
- message: "Invalid Params",
17
- description: "Please Check SMS ServiceId",
18
- });
19
- let request = await serializeIngestkorea_restJson_GetSMSResultCommand(input, config);
20
- return request;
21
- }
22
- async deserialize(response) {
23
- let output = await deserializeIngestkorea_restJson_GetSMSResultCommand(response);
24
- return output;
12
+ this.serializer = GetSMSResult_js_1.se_GetSMSResultCommand;
13
+ this.deserializer = GetSMSResult_js_1.de_GetSMSResultCommand;
25
14
  }
26
15
  }
16
+ exports.GetSMSResultCommand = GetSMSResultCommand;
@@ -1,26 +1,19 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_GetSMSStatusCommand, deserializeIngestkorea_restJson_GetSMSStatusCommand, } from "../protocols/GetSMSStatus";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- export class GetSMSStatusCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSMSStatusCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetSMSStatus_js_1 = require("../protocols/GetSMSStatus.js");
6
+ const MAX_LIMIT = 100;
7
+ class GetSMSStatusCommand extends index_js_1.SensCommand {
5
8
  constructor(input) {
6
9
  super(input);
7
10
  this.input = {
8
- ...input,
11
+ requestId: input.requestId,
12
+ pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT,
13
+ ...(input.nextToken && { nextToken: input.nextToken }),
9
14
  };
10
- }
11
- async serialize(input, config) {
12
- if (!config.serviceId.sms)
13
- throw new IngestkoreaError({
14
- code: 400,
15
- type: "Bad Request",
16
- message: "Invalid Params",
17
- description: "Please Check SMS ServiceId",
18
- });
19
- let request = await serializeIngestkorea_restJson_GetSMSStatusCommand(input, config);
20
- return request;
21
- }
22
- async deserialize(response) {
23
- let output = await deserializeIngestkorea_restJson_GetSMSStatusCommand(response);
24
- return output;
15
+ this.serializer = GetSMSStatus_js_1.se_GetSMSStatusCommand;
16
+ this.deserializer = GetSMSStatus_js_1.de_GetSMSStatusCommand;
25
17
  }
26
18
  }
19
+ exports.GetSMSStatusCommand = GetSMSStatusCommand;
@@ -1,26 +1,14 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_ListAlimtalkChannelsCommand, deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand, } from "../protocols/ListAlimtalkChannels";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- export class ListAlimtalkChannelsCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListAlimtalkChannelsCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
5
+ const ListAlimtalkChannels_js_1 = require("../protocols/ListAlimtalkChannels.js");
6
+ class ListAlimtalkChannelsCommand extends index_js_1.SensCommand {
5
7
  constructor(input) {
6
8
  super(input);
7
- this.input = {
8
- ...input,
9
- };
10
- }
11
- async serialize(input, config) {
12
- if (!config.serviceId.kakao)
13
- throw new IngestkoreaError({
14
- code: 400,
15
- type: "Bad Request",
16
- message: "Invalid Params",
17
- description: "Please Check Kakao ServiceId",
18
- });
19
- let request = await serializeIngestkorea_restJson_ListAlimtalkChannelsCommand(input, config);
20
- return request;
21
- }
22
- async deserialize(response) {
23
- let output = await deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand(response);
24
- return output;
9
+ this.input = {};
10
+ this.serializer = ListAlimtalkChannels_js_1.se_ListAlimtalkChannelsCommand;
11
+ this.deserializer = ListAlimtalkChannels_js_1.de_ListAlimtalkChannelsCommand;
25
12
  }
26
13
  }
14
+ exports.ListAlimtalkChannelsCommand = ListAlimtalkChannelsCommand;
@@ -1,38 +1,49 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_ListAlimtalkStatusCommand, deserializeIngestkorea_restJson_ListAlimtalkStatusCommand, } from "../protocols/ListAlimtalkStatus";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- import { getRequestDuration } from "./constants";
5
- export class ListAlimtalkStatusCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListAlimtalkStatusCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
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일 이내만 조회 가능
8
+ const MAX_LIMIT = 100;
9
+ const DEFAULT_LIMIT = 20;
10
+ class ListAlimtalkStatusCommand extends index_js_1.SensCommand {
6
11
  constructor(input) {
12
+ var _a;
7
13
  super(input);
8
- const { startTime, endTime } = getRequestDuration();
14
+ if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
15
+ throw new index_js_1.SensError({
16
+ code: 400,
17
+ type: "Bad Request",
18
+ message: "페이지네이션 검색 조건 불일치",
19
+ invalidInputs: [
20
+ {
21
+ type: "not-valid.args",
22
+ message: "nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션(requestStartTime, requestEndTime, pageSize 등)이 모두 동일하게 유지되어야 합니다.",
23
+ },
24
+ ],
25
+ });
26
+ }
27
+ const defaultDuration = (0, constants_js_1.getDefaultRequestDuration)({ durationLimitMs: DURATION_LIMIT_MS });
28
+ const { startTimeMs, endTimeMs } = (0, constants_js_1.resolveRequestDuration)({
29
+ startTime: input.requestStartTime ? (0, constants_js_1.convertToUtc)(input.requestStartTime) : defaultDuration.startTime,
30
+ endTime: input.requestEndTime ? (0, constants_js_1.convertToUtc)(input.requestEndTime) : defaultDuration.endTime,
31
+ }, { durationLimitMs: DURATION_LIMIT_MS });
9
32
  this.input = {
10
33
  plusFriendId: input.plusFriendId,
11
- ...(input.requestId && { requestId: input.requestId }),
12
- ...(input.messageId && { messageId: input.messageId }),
34
+ requestStartTime: (0, constants_js_1.convertToKst)(startTimeMs),
35
+ requestEndTime: (0, constants_js_1.convertToKst)(endTimeMs),
36
+ pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)),
13
37
  ...(input.requestStatusName && { requestStatusName: input.requestStatusName }),
14
38
  ...(input.messageStatusName && { messageStatusName: input.messageStatusName }),
39
+ ...(input.requestId && { requestId: input.requestId, pageSize: MAX_LIMIT }),
40
+ ...(input.messageId && { messageId: input.messageId }),
15
41
  ...(input.templateCode && { templateCode: input.templateCode }),
16
- ...(input.to && { to: input.to.replace(/\-/gi, "") }),
17
- requestStartTime: input.requestStartTime ? input.requestStartTime : startTime,
18
- requestEndTime: input.requestEndTime ? input.requestEndTime : endTime,
19
- pageIndex: input.pageIndex ? input.pageIndex : 0,
20
- pageSize: input.pageSize && input.pageSize <= 100 ? input.pageSize : 20,
42
+ ...(input.to && { to: (0, constants_js_1.prettyPhoneNum)(input.to) }),
43
+ ...(input.nextToken && { nextToken: input.nextToken }),
21
44
  };
22
- }
23
- async serialize(input, config) {
24
- if (!config.serviceId.kakao)
25
- throw new IngestkoreaError({
26
- code: 400,
27
- type: "Bad Request",
28
- message: "Invalid Params",
29
- description: "Please Check Kakao ServiceId",
30
- });
31
- let request = await serializeIngestkorea_restJson_ListAlimtalkStatusCommand(input, config);
32
- return request;
33
- }
34
- async deserialize(response) {
35
- let output = await deserializeIngestkorea_restJson_ListAlimtalkStatusCommand(response);
36
- return output;
45
+ this.serializer = ListAlimtalkStatus_js_1.se_ListAlimtalkStatusCommand;
46
+ this.deserializer = ListAlimtalkStatus_js_1.de_ListAlimtalkStatusCommand;
37
47
  }
38
48
  }
49
+ exports.ListAlimtalkStatusCommand = ListAlimtalkStatusCommand;
@@ -1,26 +1,16 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_ListAlimtalkTemplatesCommand, deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand, } from "../protocols/ListAlimtalkTemplates";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- export class ListAlimtalkTemplatesCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListAlimtalkTemplatesCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
5
+ const ListAlimtalkTemplates_js_1 = require("../protocols/ListAlimtalkTemplates.js");
6
+ class ListAlimtalkTemplatesCommand extends index_js_1.SensCommand {
5
7
  constructor(input) {
6
8
  super(input);
7
9
  this.input = {
8
10
  channelId: input.channelId,
9
11
  };
10
- }
11
- async serialize(input, config) {
12
- if (!config.serviceId.kakao)
13
- throw new IngestkoreaError({
14
- code: 400,
15
- type: "Bad Request",
16
- message: "Invalid Params",
17
- description: "Please Check Kakao ServiceId",
18
- });
19
- let request = await serializeIngestkorea_restJson_ListAlimtalkTemplatesCommand(input, config);
20
- return request;
21
- }
22
- async deserialize(response) {
23
- let output = await deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand(response);
24
- return output;
12
+ this.serializer = ListAlimtalkTemplates_js_1.se_ListAlimtalkTemplatesCommand;
13
+ this.deserializer = ListAlimtalkTemplates_js_1.de_ListAlimtalkTemplatesCommand;
25
14
  }
26
15
  }
16
+ exports.ListAlimtalkTemplatesCommand = ListAlimtalkTemplatesCommand;
@@ -0,0 +1,48 @@
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: 400,
17
+ type: "Bad Request",
18
+ message: "페이지네이션 검색 조건 불일치",
19
+ invalidInputs: [
20
+ {
21
+ type: "not-valid.args",
22
+ message: "nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션(requestStartTime, requestEndTime, pageSize 등)이 모두 동일하게 유지되어야 합니다.",
23
+ },
24
+ ],
25
+ });
26
+ }
27
+ const defaultDuration = (0, constants_js_1.getDefaultRequestDuration)({ durationLimitMs: DURATION_LIMIT_MS });
28
+ const { startTimeMs, endTimeMs } = (0, constants_js_1.resolveRequestDuration)({
29
+ startTime: input.requestStartTime ? (0, constants_js_1.convertToUtc)(input.requestStartTime) : defaultDuration.startTime,
30
+ endTime: input.requestEndTime ? (0, constants_js_1.convertToUtc)(input.requestEndTime) : defaultDuration.endTime,
31
+ }, { durationLimitMs: DURATION_LIMIT_MS });
32
+ this.input = {
33
+ requestStartTime: (0, constants_js_1.convertToKst)(startTimeMs),
34
+ requestEndTime: (0, constants_js_1.convertToKst)(endTimeMs),
35
+ pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)),
36
+ ...(input.type && { type: input.type }),
37
+ ...(input.contentType && { contentType: input.contentType }),
38
+ ...(input.status && { status: input.status }),
39
+ ...(input.from && { from: (0, constants_js_1.prettyPhoneNum)(input.from) }),
40
+ ...(input.to && { to: (0, constants_js_1.prettyPhoneNum)(input.to) }),
41
+ ...(input.statusName && { statusName: input.statusName }),
42
+ ...(input.nextToken && { nextToken: input.nextToken }),
43
+ };
44
+ this.serializer = ListSMSStatus_js_1.se_ListSMSStatusCommand;
45
+ this.deserializer = ListSMSStatus_js_1.de_ListSMSStatusCommand;
46
+ }
47
+ }
48
+ exports.ListSMSStatusCommand = ListSMSStatusCommand;
@@ -1,46 +1,51 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_SendAlimtalkCommand, deserializeIngestkorea_restJson_SendAlimtalkCommand, } from "../protocols/SendAlimtalk";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- export class SendAlimtalkCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendAlimtalkCommand = void 0;
4
+ const index_js_1 = require("../models/index.js");
5
+ const SendAlimtalk_js_1 = require("../protocols/SendAlimtalk.js");
6
+ class SendAlimtalkCommand extends index_js_1.SensCommand {
5
7
  constructor(input) {
6
8
  super(input);
7
9
  this.input = {
8
- ...input,
9
10
  plusFriendId: input.plusFriendId,
10
11
  templateCode: input.templateCode,
11
- messages: resolveAlimtalkMessage(input.messages),
12
+ messages: resolveAlimtalkMessages(input.messages, {
13
+ maxRecipients: index_js_1.ALIMTALK_MAX_RECIPIENTS,
14
+ maxContentLength: index_js_1.ALIMTALK_MAX_CONTENT_LENGTH,
15
+ }),
12
16
  };
17
+ this.serializer = SendAlimtalk_js_1.se_SendAlimtalkCommand;
18
+ this.deserializer = SendAlimtalk_js_1.de_SendAlimtalkCommand;
13
19
  }
14
- async serialize(input, config) {
15
- if (!config.serviceId.kakao)
16
- throw new IngestkoreaError({
20
+ }
21
+ exports.SendAlimtalkCommand = SendAlimtalkCommand;
22
+ const resolveAlimtalkMessages = (messages, config) => {
23
+ if (!messages.length || messages.length > config.maxRecipients) {
24
+ throw new index_js_1.SensError({
25
+ code: 400,
26
+ type: "Bad Request",
27
+ message: "알림톡 동시 발송 범위 오류",
28
+ invalidInputs: [
29
+ {
30
+ type: "not-valid.args",
31
+ message: `메세지 동시 발송은 최소 1명, 최대 ${config.maxRecipients}명까지 가능합니다.`,
32
+ },
33
+ ],
34
+ });
35
+ }
36
+ const result = messages.map((message) => {
37
+ if (message.content.length > config.maxContentLength) {
38
+ throw new index_js_1.SensError({
17
39
  code: 400,
18
40
  type: "Bad Request",
19
- message: "Invalid Params",
20
- description: "Please Check Kakao ServiceId",
41
+ message: "알림톡 최대 길이 초과",
42
+ invalidInputs: [{ type: "not-valid.args", message: `메세지 최대 길이는 ${config.maxContentLength}글자입니다` }],
21
43
  });
22
- let request = await serializeIngestkorea_restJson_SendAlimtalkCommand(input, config);
23
- return request;
24
- }
25
- async deserialize(response) {
26
- let output = await deserializeIngestkorea_restJson_SendAlimtalkCommand(response);
27
- return output;
28
- }
29
- }
30
- const resolveAlimtalkMessage = (messages) => {
31
- const ALIMTALK_MAX = 1000;
32
- const lastError = new IngestkoreaError({
33
- code: 400,
34
- type: "Bad Request",
35
- message: "Invalid Params",
36
- description: `Maximum message length is ${ALIMTALK_MAX}`,
37
- });
38
- const result = messages.map((message) => {
39
- if (message.content.length > ALIMTALK_MAX)
40
- throw lastError;
44
+ }
41
45
  return {
42
46
  to: message.to.replace(/\-/gi, ""),
43
47
  content: message.content,
48
+ useSmsFailover: message.useSmsFailover != undefined ? message.useSmsFailover : false,
44
49
  ...(message.buttons && message.buttons.length && { buttons: message.buttons }),
45
50
  };
46
51
  });
@@ -1,119 +1,89 @@
1
- import { SensCommand } from "../models";
2
- import { serializeIngestkorea_restJson_SendMMSCommand, deserializeIngestkorea_restJson_SendMMSCommand, } from "../protocols/SendMMS";
3
- import { IngestkoreaError } from "@ingestkorea/util-error-handler";
4
- import { LMS_MAX, MMS_FILE_MAX, trimText, prettyPhoneNum, getContentLength } from "./constants";
5
- import { parse } from "node:path";
6
- import { randomUUID } from "node:crypto";
7
- import { readFileSync, existsSync } from "node:fs";
8
- export class SendMMSCommand extends SensCommand {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendMMSCommand = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const node_crypto_1 = require("node:crypto");
6
+ const node_fs_1 = require("node:fs");
7
+ const index_js_1 = require("../models/index.js");
8
+ const SendMMS_js_1 = require("../protocols/SendMMS.js");
9
+ const constants_1 = require("./constants");
10
+ const SendSMSCommand_js_1 = require("./SendSMSCommand.js");
11
+ class SendMMSCommand extends index_js_1.SensCommand {
9
12
  constructor(input) {
10
13
  super(input);
14
+ const content = input.content ? (0, constants_1.trimText)(input.content) : "내용없음";
15
+ const subject = input.subject ? (0, constants_1.trimText)(input.subject) : "제목없음";
16
+ const messages = (0, SendSMSCommand_js_1.resolveInputMessages)(input.messages, { defaultContent: content, defaultSubject: subject });
11
17
  this.input = {
12
- ...input,
13
- from: prettyPhoneNum(input.from),
14
- content: resolveInputContent(input.content),
15
- type: resolveInputMessageType(input.type),
16
- messages: resolveInputMessages(input.messages),
17
- files: resolveInputFiles(input.files),
18
+ from: (0, constants_1.prettyPhoneNum)(input.from),
19
+ content,
20
+ messages,
21
+ type: "MMS",
22
+ contentType: input.contentType ? input.contentType : "COMM",
23
+ countryCode: input.countryCode ? input.countryCode : "82",
24
+ subject,
25
+ files: (input.files || []).map((file) => {
26
+ return resolveSendFile(file, { maxKiB: index_js_1.MMS_MAX_SUPPORT_FILE_SIZE, supportExt: index_js_1.MMS_SUPPORT_FILE_EXTENSION });
27
+ }),
18
28
  };
19
- }
20
- async serialize(input, config) {
21
- if (!config.serviceId.sms)
22
- throw new IngestkoreaError({
23
- code: 400,
24
- type: "Bad Request",
25
- message: "Invalid Params",
26
- description: "Please Check SMS ServiceId",
27
- });
28
- let request = await serializeIngestkorea_restJson_SendMMSCommand(input, config);
29
- return request;
30
- }
31
- async deserialize(response) {
32
- let output = await deserializeIngestkorea_restJson_SendMMSCommand(response);
33
- return output;
29
+ this.serializer = SendMMS_js_1.se_SendMMSCommand;
30
+ this.deserializer = SendMMS_js_1.de_SendMMSCommand;
34
31
  }
35
32
  }
36
- const resolveInputContent = (content) => {
37
- const resolvedContent = trimText(content);
38
- const contentLength = getContentLength(resolvedContent);
39
- if (!contentLength)
40
- throw new IngestkoreaError({
33
+ exports.SendMMSCommand = SendMMSCommand;
34
+ const resolveSendFile = (file, options) => {
35
+ const parsed = (0, node_path_1.parse)(file.name); // { dir, name, ext, base }
36
+ const ext = parsed.ext.toLocaleLowerCase();
37
+ if (!options.supportExt.includes(ext)) {
38
+ throw new index_js_1.SensError({
41
39
  code: 400,
42
40
  type: "Bad Request",
43
- message: "Invalid Request",
44
- description: `Please check input message`,
41
+ message: "지원하지 않는 확장자입니다.",
42
+ invalidInputs: [
43
+ { type: "not-valid.args", message: `${options.supportExt.join(", ")} 형식의 첨부파일만 지원합니다.` },
44
+ ],
45
45
  });
46
- if (contentLength > LMS_MAX)
47
- throw new IngestkoreaError({
46
+ }
47
+ if (file.body) {
48
+ const buffer = Buffer.from(file.body, "base64");
49
+ checkSizeLimit(buffer, options.maxKiB);
50
+ const hash = (0, node_crypto_1.createHash)("md5").update(buffer).digest("hex");
51
+ return {
52
+ name: (0, node_path_1.format)({ name: hash, ext }),
53
+ body: file.body,
54
+ };
55
+ }
56
+ if (!(0, node_fs_1.existsSync)(file.name)) {
57
+ throw new index_js_1.SensError({
48
58
  code: 400,
49
59
  type: "Bad Request",
50
- message: "Invalid Request",
51
- description: `Maximum message length is ${LMS_MAX}bytes`,
60
+ message: "파일이 존재하지 않습니다.",
61
+ invalidInputs: [{ type: "not-valid.args", message: `${file.name} 파일이 존재하지 않습니다.` }],
52
62
  });
53
- return resolvedContent;
54
- };
55
- const resolveInputMessages = (messages) => messages.map((message) => {
63
+ }
64
+ const buffer = (0, node_fs_1.readFileSync)(file.name);
65
+ checkSizeLimit(buffer, options.maxKiB);
66
+ const hash = (0, node_crypto_1.createHash)("md5").update(buffer).digest("hex");
56
67
  return {
57
- to: prettyPhoneNum(message.to),
58
- ...(message.content != undefined && { content: resolveInputContent(message.content) }),
59
- ...(message.subject != undefined && { subject: trimText(message.subject) }),
68
+ name: (0, node_path_1.format)({ name: hash, ext }),
69
+ body: buffer.toString("base64"),
60
70
  };
61
- });
62
- const resolveInputMessageType = (type) => {
63
- if (type == "SMS" || type == "LMS")
64
- throw new IngestkoreaError({
65
- code: 400,
66
- type: "Bad Request",
67
- message: "Invalid Request",
68
- description: `Please Call SendSMSCommand`,
69
- });
70
- return "MMS";
71
71
  };
72
- const resolveInputFiles = (files) => {
73
- if (!files.length)
74
- throw new IngestkoreaError({
72
+ const checkSizeLimit = (buffer, maxKiB) => {
73
+ const byteSize = buffer.length;
74
+ const kibSize = Math.ceil(byteSize / 1024);
75
+ if (kibSize > maxKiB) {
76
+ throw new index_js_1.SensError({
75
77
  code: 400,
76
78
  type: "Bad Request",
77
- message: "Invalid Request",
78
- description: `Please Check Input Files`,
79
+ message: `최대 첨부가능 용량이 초과되었습니다.`,
80
+ invalidInputs: [
81
+ {
82
+ type: "not-valid.args",
83
+ message: `최대 ${maxKiB}KiB까지 전송 가능합니다. 현재 ${kibSize}KiB`,
84
+ },
85
+ ],
79
86
  });
80
- const output = files.map((file) => {
81
- const resolvedFileName = verifyFileName(file.name);
82
- const resolvedFileBody = file.body != undefined ? file.body : getFileBody(file.name);
83
- let byte = Buffer.from(resolvedFileBody, "base64").length;
84
- let kib = Math.ceil(byte / 1024);
85
- if (kib > MMS_FILE_MAX)
86
- throw new IngestkoreaError({
87
- code: 400,
88
- type: "Bad Request",
89
- message: "Invalid Request",
90
- description: `Input File is ${kib}KiByte. Maximum File Size is ${MMS_FILE_MAX}Kibyte`,
91
- });
92
- return { name: resolvedFileName, body: resolvedFileBody };
93
- });
94
- return output;
95
- };
96
- const verifyFileName = (fileName) => {
97
- let { ext } = parse(fileName);
98
- const uuid = randomUUID();
99
- const extension = ext.replace(/jpeg|jpg/gi, "jpg");
100
- if (extension != ".jpg")
101
- throw new IngestkoreaError({
102
- code: 400,
103
- type: "Bad Request",
104
- message: "Invalid Request",
105
- description: `File Extension is not .jpg or .jpeg`,
106
- });
107
- return [uuid, extension].join("");
108
- };
109
- /** @returns base64 */
110
- const getFileBody = (fileName) => {
111
- if (!existsSync(fileName))
112
- throw new IngestkoreaError({
113
- code: 400,
114
- type: "Bad Request",
115
- message: "Invalid Request",
116
- description: `${fileName} does not exist.`,
117
- });
118
- return readFileSync(fileName, { encoding: "base64" });
87
+ }
88
+ return;
119
89
  };