@ingestkorea/client-sens 1.7.0 → 1.8.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 (148) 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 +9 -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 +8 -33
  9. package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +6 -33
  10. package/dist-cjs/commands/ListAlimtalkStatusCommand.js +19 -35
  11. package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +5 -32
  12. package/dist-cjs/commands/SendAlimtalkCommand.js +35 -43
  13. package/dist-cjs/commands/SendMMSCommand.js +67 -103
  14. package/dist-cjs/commands/SendSMSCommand.js +38 -71
  15. package/dist-cjs/commands/constants.js +1 -15
  16. package/dist-cjs/commands/index.js +11 -11
  17. package/dist-cjs/index.js +2 -2
  18. package/dist-cjs/middleware/constants.js +10 -0
  19. package/dist-cjs/middleware/index.js +3 -4
  20. package/dist-cjs/middleware/middleware-metadata.js +4 -5
  21. package/dist-cjs/middleware/middleware-retry.js +32 -27
  22. package/dist-cjs/middleware/middleware-sign.js +10 -9
  23. package/dist-cjs/models/SendAlimtalk.js +3 -0
  24. package/dist-cjs/models/SendMMS.js +3 -0
  25. package/dist-cjs/models/SensErrorInfo.js +13 -0
  26. package/dist-cjs/models/SensMiddleware.js +2 -0
  27. package/dist-cjs/models/index.js +16 -14
  28. package/dist-cjs/protocols/GetAlimtalkResult.js +19 -22
  29. package/dist-cjs/protocols/GetAlimtalkStatus.js +36 -37
  30. package/dist-cjs/protocols/GetAlimtalkTemplate.js +56 -90
  31. package/dist-cjs/protocols/GetSMSResult.js +30 -48
  32. package/dist-cjs/protocols/GetSMSStatus.js +31 -34
  33. package/dist-cjs/protocols/ListAlimtalkChannels.js +27 -31
  34. package/dist-cjs/protocols/ListAlimtalkStatus.js +22 -19
  35. package/dist-cjs/protocols/ListAlimtalkTemplates.js +31 -23
  36. package/dist-cjs/protocols/SendAlimtalk.js +22 -26
  37. package/dist-cjs/protocols/SendMMS.js +8 -38
  38. package/dist-cjs/protocols/SendSMS.js +19 -21
  39. package/dist-cjs/protocols/constants.js +98 -34
  40. package/dist-es/SensClient.js +63 -30
  41. package/dist-es/commands/GetAlimtalkResultCommand.js +9 -19
  42. package/dist-es/commands/GetAlimtalkStatusCommand.js +14 -19
  43. package/dist-es/commands/GetAlimtalkTemplateCommand.js +9 -19
  44. package/dist-es/commands/GetSMSResultCommand.js +10 -20
  45. package/dist-es/commands/GetSMSStatusCommand.js +10 -20
  46. package/dist-es/commands/ListAlimtalkChannelsCommand.js +10 -22
  47. package/dist-es/commands/ListAlimtalkStatusCommand.js +28 -27
  48. package/dist-es/commands/ListAlimtalkTemplatesCommand.js +9 -19
  49. package/dist-es/commands/SendAlimtalkCommand.js +34 -30
  50. package/dist-es/commands/SendMMSCommand.js +70 -100
  51. package/dist-es/commands/SendSMSCommand.js +51 -66
  52. package/dist-es/commands/constants.js +9 -16
  53. package/dist-es/commands/index.js +27 -11
  54. package/dist-es/index.js +18 -2
  55. package/dist-es/middleware/constants.js +10 -0
  56. package/dist-es/middleware/index.js +19 -4
  57. package/dist-es/middleware/middleware-metadata.js +11 -5
  58. package/dist-es/middleware/middleware-retry.js +39 -30
  59. package/dist-es/middleware/middleware-sign.js +19 -14
  60. package/dist-es/models/GetAlimtalkResult.js +2 -1
  61. package/dist-es/models/GetAlimtalkStatus.js +2 -1
  62. package/dist-es/models/GetAlimtalkTemplate.js +2 -1
  63. package/dist-es/models/GetSMSResult.js +2 -1
  64. package/dist-es/models/GetSMSStatus.js +2 -1
  65. package/dist-es/models/ListAlimtalkChannels.js +2 -1
  66. package/dist-es/models/ListAlimtalkStatus.js +2 -1
  67. package/dist-es/models/ListAlimtalkTemplates.js +2 -1
  68. package/dist-es/models/MetadataBearer.js +2 -1
  69. package/dist-es/models/SendAlimtalk.js +5 -1
  70. package/dist-es/models/SendMMS.js +5 -1
  71. package/dist-es/models/SendSMS.js +2 -1
  72. package/dist-es/models/SensClient.js +2 -0
  73. package/dist-es/models/SensCommand.js +5 -1
  74. package/dist-es/models/SensErrorInfo.js +13 -0
  75. package/dist-es/models/SensMiddleware.js +2 -0
  76. package/dist-es/models/index.js +32 -14
  77. package/dist-es/protocols/GetAlimtalkResult.js +24 -23
  78. package/dist-es/protocols/GetAlimtalkStatus.js +40 -36
  79. package/dist-es/protocols/GetAlimtalkTemplate.js +78 -87
  80. package/dist-es/protocols/GetSMSResult.js +44 -47
  81. package/dist-es/protocols/GetSMSStatus.js +35 -34
  82. package/dist-es/protocols/ListAlimtalkChannels.js +31 -31
  83. package/dist-es/protocols/ListAlimtalkStatus.js +26 -32
  84. package/dist-es/protocols/ListAlimtalkTemplates.js +35 -22
  85. package/dist-es/protocols/SendAlimtalk.js +26 -25
  86. package/dist-es/protocols/SendMMS.js +10 -49
  87. package/dist-es/protocols/SendSMS.js +23 -30
  88. package/dist-es/protocols/constants.js +112 -37
  89. package/dist-types/SensClient.d.ts +3 -20
  90. package/dist-types/commands/GetAlimtalkResultCommand.d.ts +5 -10
  91. package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +5 -10
  92. package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +5 -10
  93. package/dist-types/commands/GetSMSResultCommand.d.ts +5 -10
  94. package/dist-types/commands/GetSMSStatusCommand.d.ts +5 -10
  95. package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +5 -10
  96. package/dist-types/commands/ListAlimtalkStatusCommand.d.ts +5 -10
  97. package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +5 -10
  98. package/dist-types/commands/SendAlimtalkCommand.d.ts +5 -10
  99. package/dist-types/commands/SendMMSCommand.d.ts +5 -10
  100. package/dist-types/commands/SendSMSCommand.d.ts +9 -10
  101. package/dist-types/commands/constants.d.ts +0 -7
  102. package/dist-types/commands/index.d.ts +11 -11
  103. package/dist-types/index.d.ts +2 -2
  104. package/dist-types/middleware/constants.d.ts +7 -0
  105. package/dist-types/middleware/index.d.ts +3 -4
  106. package/dist-types/middleware/middleware-metadata.d.ts +2 -2
  107. package/dist-types/middleware/middleware-retry.d.ts +2 -2
  108. package/dist-types/middleware/middleware-sign.d.ts +2 -2
  109. package/dist-types/models/GetAlimtalkResult.d.ts +3 -3
  110. package/dist-types/models/GetAlimtalkStatus.d.ts +8 -5
  111. package/dist-types/models/GetAlimtalkTemplate.d.ts +5 -5
  112. package/dist-types/models/GetSMSResult.d.ts +5 -9
  113. package/dist-types/models/GetSMSStatus.d.ts +4 -4
  114. package/dist-types/models/ListAlimtalkChannels.d.ts +4 -4
  115. package/dist-types/models/ListAlimtalkStatus.d.ts +8 -8
  116. package/dist-types/models/ListAlimtalkTemplates.d.ts +2 -2
  117. package/dist-types/models/MetadataBearer.d.ts +3 -3
  118. package/dist-types/models/SendAlimtalk.d.ts +6 -4
  119. package/dist-types/models/SendMMS.d.ts +5 -3
  120. package/dist-types/models/SendSMS.d.ts +2 -2
  121. package/dist-types/models/SensClient.d.ts +17 -0
  122. package/dist-types/models/SensCommand.d.ts +4 -6
  123. package/dist-types/models/SensErrorInfo.d.ts +21 -0
  124. package/dist-types/models/SensMiddleware.d.ts +8 -0
  125. package/dist-types/models/index.d.ts +16 -14
  126. package/dist-types/protocols/GetAlimtalkResult.d.ts +4 -11
  127. package/dist-types/protocols/GetAlimtalkStatus.d.ts +6 -12
  128. package/dist-types/protocols/GetAlimtalkTemplate.d.ts +4 -14
  129. package/dist-types/protocols/GetSMSResult.d.ts +4 -12
  130. package/dist-types/protocols/GetSMSStatus.d.ts +5 -11
  131. package/dist-types/protocols/ListAlimtalkChannels.d.ts +4 -11
  132. package/dist-types/protocols/ListAlimtalkStatus.d.ts +4 -10
  133. package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -12
  134. package/dist-types/protocols/SendAlimtalk.d.ts +5 -12
  135. package/dist-types/protocols/SendMMS.d.ts +4 -10
  136. package/dist-types/protocols/SendSMS.d.ts +5 -10
  137. package/dist-types/protocols/constants.d.ts +3 -2
  138. package/package.json +20 -4
  139. package/.github/pull_request_template.md +0 -19
  140. package/dist-cjs/middleware/middleware-sort-headers.js +0 -25
  141. package/dist-cjs/protocols/index.js +0 -28
  142. package/dist-es/middleware/middleware-sort-headers.js +0 -12
  143. package/dist-es/models/Middleware.js +0 -1
  144. package/dist-es/protocols/index.js +0 -12
  145. package/dist-types/middleware/middleware-sort-headers.d.ts +0 -2
  146. package/dist-types/models/Middleware.d.ts +0 -12
  147. package/dist-types/protocols/index.d.ts +0 -12
  148. /package/dist-cjs/models/{Middleware.js → SensClient.js} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 INGESTKOREA LLC.
3
+ Copyright (c) 2024-2026 INGESTKOREA LLC. All Rights Reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,7 +7,15 @@
7
7
 
8
8
  ## Description
9
9
 
10
- INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
10
+ INGESTKOREA SDK - Naver Cloud Platform SENS Client for Node.js.
11
+
12
+ INGESTKOREA SDK - SENS Client for Node.js is a lightweight library that contains only the essential features frequently used in SENS.
13
+
14
+ This SDK performs tasks such as the following automatically.
15
+
16
+ - Authentication using an API Signature
17
+ - Retrying requests
18
+ - Handling error responses
11
19
 
12
20
  ## Installing
13
21
 
@@ -47,8 +55,12 @@ npm install @ingestkorea/client-sens
47
55
 
48
56
  ### Import
49
57
 
58
+ The INGESTKOREA SDK - SENS Client is modulized by `client` and `commands`.
59
+
60
+ To send a request, you only need to import the SensClient and the commands you need, for example SendMessageCommand:
61
+
50
62
  ```ts
51
- import { SensClient, SendAlimtalkCommand, SendSMSCommand, SendMMSCommand } from "@ingestkorea/client-sens";
63
+ import { SensClient, SendAlimtalkCommand } from "@ingestkorea/client-sens";
52
64
  ```
53
65
 
54
66
  ### Usage
@@ -60,106 +72,123 @@ To send a request, you:
60
72
  - Call `send` operation on client with command object as input.
61
73
 
62
74
  ```ts
63
- // a client can be shared by different commands.
64
75
  const client = new SensClient({
76
+ /**
77
+ * AccessKey, SecretKey: https://www.ncloud.com/mypage/manage/authkey
78
+ * serviceId: https://console.ncloud.com/sens/project
79
+ */
65
80
  credentials: {
66
- accessKey: ACCESS_KEY,
67
- secretKey: SECRET_KEY,
81
+ accessKey: "YOUR_ACCESS_KEY",
82
+ secretKey: "YOUR_SECRET_KEY",
68
83
  },
84
+ /**
85
+ * at least one serviceId required
86
+ * if you call send operation without serviceId, sdk throw error
87
+ */
69
88
  serviceId: {
70
- sms: "ncp:sms:kr:123456789xxx:your-service-name", // optional
71
- kakao: "ncp:kkobizmsg:kr:9876xxx:your-service-name", // optional
89
+ kakao: "ncp:kkobizmsg:kr:xxxxxx:your-service-name",
90
+ sms: "ncp:sms:kr:xxxxxx:your-service-name",
72
91
  },
73
92
  });
74
-
75
- /**
76
- * accessKey, secretKey: https://www.ncloud.com/mypage/manage/authkey
77
- * serviceId: https://console.ncloud.com/sens/project
78
- *
79
- * at least one serviceId required
80
- * if you call send operation without serviceId, sdk throw error
81
- */
82
93
  ```
83
94
 
84
95
  #### SendAlimtalk
85
96
 
86
97
  ```ts
87
- let command = new SendAlimtalkCommand({
88
- plusFriendId: PLUS_FRIEND_ID,
89
- templateCode: TEMPLATE_CODE,
90
- messages: [{ to: "01012345678", content: CONTENT }],
98
+ const command = new SendAlimtalkCommand({
99
+ /** Required: Kakao PlusFriend ID (e.g., @kakao) */
100
+ plusFriendId: "PLUS_FRIEND_ID",
101
+
102
+ /** Required: Kakao Alimtalk TemplateCode ID (e.g., welcomeTemplate) */
103
+ templateCode: "TEMPLATE_CODE",
104
+
105
+ /** Required: List of messages to send (Max 100) */
106
+ messages: [
107
+ /** Recipient phone number (digits only), Message content */
108
+ { to: "01012345678", content: "YOUR_CONTENT" },
109
+ ],
91
110
  });
92
111
  ```
93
112
 
94
113
  #### ListAlimtalkStatus
95
114
 
96
115
  ```ts
97
- let command = new ListAlimtalkStatusCommand({
98
- plusFriendId: CHANNEL_ID,
99
- requestStartTime: "yyyy-MM-ddTHH:mm:ss.SSS", // Optional(KST) // default: current - 24hours
100
- requestEndTime: "yyyy-MM-ddTHH:mm:ss.SSS", // Optional(KST) // default: current
116
+ const command = new ListAlimtalkStatusCommand({
117
+ /** Required: Kakao PlusFriend ID (e.g., @kakao) */
118
+ plusFriendId: "CHANNEL_ID",
119
+
120
+ /**
121
+ * Optional: Start time in KST (Format: yyyy-MM-ddTHH:mm:ss.SSS)
122
+ * Defaults to 24 hours prior to requestEndTime if not provided.
123
+ */
124
+ requestStartTime: "yyyy-MM-ddTHH:mm:ss.SSS",
125
+
126
+ /**
127
+ * Optional: End time in KST (Format: yyyy-MM-ddTHH:mm:ss.SSS)
128
+ * Defaults to the current system time if not provided.
129
+ */
130
+ requestEndTime: "yyyy-MM-ddTHH:mm:ss.SSS",
101
131
  });
102
132
  ```
103
133
 
104
134
  #### GetAlimtalkStatus
105
135
 
106
136
  ```ts
107
- let command = new GetAlimtalkStatusCommand({
108
- requestId: REQUEST_ID,
109
- });
137
+ const command = new GetAlimtalkStatusCommand({ requestId: "ALIMTALK_REQUEST_ID" });
110
138
  ```
111
139
 
112
140
  #### SendSMS (SMS, LMS)
113
141
 
142
+ - **Message Type Automation**: The SDK automatically determines the message type ('SMS' or 'LMS') based on the content length (EUC-KR encoding)
143
+
144
+ - SMS: Up to 90 bytes
145
+ - LMS: Up to 2,000 bytes
146
+
147
+ - **Default Value Policy**: If `subject` or `content` is not defined within the individual message object, the SDK uses the **top-level** `content` and the default subject ('제목없음').
148
+
114
149
  ```ts
115
- let command = new SendSMSCommand({
116
- from: '01012345678',
117
- content: DEFAULT_CONTENT,
150
+ const command = new SendSMSCommand({
151
+ /** Sender's phone number (digits only) for all messages in the batch. */
152
+ from: "01012345678",
153
+
154
+ /** Default message content */
155
+ content: "DEFAULT_CONTENT",
118
156
  messages: [
119
- { to: '0109182xxxx' },
120
- { to: '0104321xxxx', content?: ONTENT_01 }
121
- { to: '0108765xxxx', content?: CONTENT_02, subject?: SUBJECT_01 },
122
- ]
123
- });
157
+ /** Uses default message content */
158
+ { to: "0101111xxxx" },
124
159
 
125
- /**
126
- * Automatically set message type('SMS' | 'LMS') according to content-length(euc-kr)
127
- * SMS: max 90bytes
128
- * LMS: max 2000bytes
129
- */
160
+ /** Overrides with specific content */
161
+ { to: "0102222xxxx", content: "CONTENT_01" },
130
162
 
131
- /**
132
- * If you do not define the subject and content within the messages,
133
- * it is sent with the value specified as the default subject('제목없음') and content.
134
- */
163
+ /** Overrides content & subject */
164
+ { to: "0103333xxxx", content: "CONTENT_02", subject: "SUBJECT_01" },
165
+ ],
166
+ });
135
167
  ```
136
168
 
137
169
  #### SendMMS (MMS)
138
170
 
171
+ - **Multimedia Messaging**: Supports sending images along with your message. (Supported formats: `.jpg`, `.jpeg`)
172
+
173
+ - **Default Value Policy**: Same as `SendSMSCommand`, individual messages will inherit the top-level `content` and `subject` if not specified.
174
+
139
175
  ```ts
140
- import { readFileSync } from 'node:fs';
176
+ import { readFileSync } from "node:fs";
141
177
 
142
- let command = new SendMMSCommand({
143
- from: '01012345678',
144
- content: DEFAULT_CONTENT,
145
- messages: [
146
- { to: '0109182xxxx' },
147
- { to: '0104321xxxx', content?: CONTENT_01 }
148
- { to: '0108765xxxx', content?: CONTENT_02, subject?: SUBJECT_01 },
149
- ],
150
- files: [ // support jpg, jpeg
151
- { name: '/your/absolute/path/sample-image-1.jpg' },
178
+ const command = new SendMMSCommand({
179
+ /** Same as SendSMSCommand */
180
+ ...
181
+ files: [
182
+ // 1. Specify the absolute path (The SDK will handle the file reading)
183
+ { name: "/your/absolute/path/sample-image-1.jpg" },
184
+
185
+ // 2. Pass base64 encoded data directly
152
186
  {
153
- name: '/your/absolute/path/sample-image-2.jpg',
154
- body?: readFileSync('/your/absolute/path/sample-image-2.jpg', { encoding: 'base64' })
155
- }
156
- ]
187
+ name: "custom-image-name.jpg",
188
+ body: readFileSync("/your/absolute/path/sample-image-2.jpg", { encoding: "base64" }),
189
+ },
190
+ ],
157
191
  });
158
-
159
- /**
160
- * If you do not define the subject and content within the messages,
161
- * it is sent with the value specified as the default subject('제목없음') and content.
162
- */
163
192
  ```
164
193
 
165
194
  #### Async/await
@@ -184,6 +213,12 @@ client
184
213
  .catch((err) => console.dir(err, { depth: 4 }));
185
214
  ```
186
215
 
216
+ ## Getting Help
217
+
218
+ We use the GitHub issues for tracking bugs and feature requests.
219
+
220
+ If it turns out that you may have found a bug, please open an issue.
221
+
187
222
  ## License
188
223
 
189
224
  This SDK is distributed under the [MIT License](https://opensource.org/licenses/MIT), see LICENSE for more information.
@@ -11,54 +11,83 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SensClient = void 0;
13
13
  const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
- const middleware_1 = require("./middleware");
14
+ const index_js_1 = require("./models/index.js");
15
+ const index_js_2 = require("./middleware/index.js");
16
16
  class SensClient {
17
17
  constructor(config) {
18
+ this.httpHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
19
+ this.requestHandler = (input, context) => __awaiter(this, void 0, void 0, function* () { return this.httpHandler.handle(input.request); });
18
20
  this.config = {
19
21
  credentials: resolveCredentials(config),
20
22
  serviceId: resolveServiceId(config),
21
23
  };
22
- this.requestHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
23
24
  }
24
25
  send(command) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
26
- let input = command.input;
27
- let request = yield command.serialize(input, this.config);
28
- request = yield (0, middleware_1.middlewareNcpSigner)(request, this.config);
29
- request = yield (0, middleware_1.middlewareIngestkoreaMetadata)(request, this.config);
30
- request = yield (0, middleware_1.middlewareSortHeaders)(request, this.config);
31
- let response = yield (0, middleware_1.middlewareRetry)(request, this.config, this.requestHandler);
32
- let output = yield command.deserialize(response);
33
- return output;
27
+ const { input, serializer, deserializer } = command;
28
+ const middlewares = [index_js_2.middlewareIngestkoreaMetadata, index_js_2.middlewareNcpSign, index_js_2.middlewareRetry];
29
+ const handler = composeMiddleware(middlewares, this.requestHandler);
30
+ try {
31
+ const request = yield serializer(input, this.config);
32
+ const { response } = yield handler({ request }, this.config);
33
+ const output = yield deserializer(response, this.config);
34
+ return output;
35
+ }
36
+ catch (e) {
37
+ throw e;
38
+ }
34
39
  });
35
40
  }
36
41
  }
37
42
  exports.SensClient = SensClient;
43
+ const composeMiddleware = (middlewares, finalHandler) => {
44
+ const handler = middlewares.reduceRight((next, middleware) => {
45
+ return middleware(next);
46
+ }, finalHandler);
47
+ return handler;
48
+ };
38
49
  const resolveCredentials = (config) => {
39
50
  const { credentials } = config;
51
+ let error = new index_js_1.SensError({
52
+ code: 401,
53
+ type: "Unauthorized",
54
+ message: "Invalid Credentials",
55
+ invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 인증 정보를 확인해주세요" }],
56
+ });
40
57
  if (!credentials)
41
- throw new util_error_handler_1.IngestkoreaError({
42
- code: 401,
43
- type: "Unauthorized",
44
- message: "Invalid Credentials",
45
- description: "Invalid Credentials",
46
- });
47
- return credentials;
58
+ throw error;
59
+ if (!credentials.accessKey) {
60
+ error.invalidInputs[0].message = "AccessKey 정보를 확인해주세요";
61
+ throw error;
62
+ }
63
+ if (!credentials.secretKey) {
64
+ error.invalidInputs[0].message = "SecretKey 정보를 확인해주세요";
65
+ throw error;
66
+ }
67
+ return {
68
+ accessKey: credentials.accessKey,
69
+ secretKey: credentials.secretKey,
70
+ };
48
71
  };
49
72
  const resolveServiceId = (config) => {
73
+ var _a, _b, _c;
50
74
  const { serviceId } = config;
51
- const lastError = new util_error_handler_1.IngestkoreaError({
52
- code: 401,
53
- type: "Unauthorized",
54
- message: "Invalid Credentials",
55
- description: "Invalid ServiceId",
75
+ let error = new index_js_1.SensError({
76
+ code: 400,
77
+ type: "Bad Request",
78
+ message: "Invalid ServiceId",
79
+ invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 서비스 정보를 확인해주세요" }],
56
80
  });
57
- if (!serviceId || !Object.keys(serviceId).length)
58
- throw lastError;
81
+ if (!serviceId)
82
+ throw error;
83
+ const isReady = !!Object.values(serviceId).filter((d) => !!d).length;
84
+ if (!isReady) {
85
+ error.invalidInputs[0].message = "최소 1개 이상의 서비스 정보가 필요합니다";
86
+ throw error;
87
+ }
59
88
  return {
60
- push: serviceId.push != undefined ? serviceId.push : undefined,
61
- sms: serviceId.sms != undefined ? serviceId.sms : undefined,
62
- kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined,
89
+ kakao: (_a = serviceId.kakao) !== null && _a !== void 0 ? _a : "",
90
+ push: (_b = serviceId.push) !== null && _b !== void 0 ? _b : "",
91
+ sms: (_c = serviceId.sms) !== null && _c !== void 0 ? _c : "",
63
92
  };
64
93
  };
@@ -1,43 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkResultCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkResult_1 = require("../protocols/GetAlimtalkResult");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkResultCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetAlimtalkResult_js_1 = require("../protocols/GetAlimtalkResult.js");
6
+ class GetAlimtalkResultCommand extends index_js_1.SensCommand {
17
7
  constructor(input) {
18
8
  super(input);
19
9
  this.input = {
20
10
  messageId: input.messageId,
21
11
  };
22
- }
23
- serialize(input, config) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (!config.serviceId.kakao)
26
- throw new util_error_handler_1.IngestkoreaError({
27
- code: 400,
28
- type: "Bad Request",
29
- message: "Invalid Params",
30
- description: "Please Check Kakao ServiceId",
31
- });
32
- let request = yield (0, GetAlimtalkResult_1.serializeIngestkorea_restJson_GetAlimtalkResultCommand)(input, config);
33
- return request;
34
- });
35
- }
36
- deserialize(response) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- let output = yield (0, GetAlimtalkResult_1.deserializeIngestkorea_restJson_GetAlimtalkResultCommand)(response);
39
- return output;
40
- });
12
+ this.serializer = GetAlimtalkResult_js_1.se_GetAlimtalkResultCommand;
13
+ this.deserializer = GetAlimtalkResult_js_1.de_GetAlimtalkResultCommand;
41
14
  }
42
15
  }
43
16
  exports.GetAlimtalkResultCommand = GetAlimtalkResultCommand;
@@ -1,43 +1,17 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkStatusCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkStatus_1 = require("../protocols/GetAlimtalkStatus");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkStatusCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetAlimtalkStatus_js_1 = require("../protocols/GetAlimtalkStatus.js");
6
+ const MAX_LIMIT = 100;
7
+ const DEFAULT_LIMIT = 20;
8
+ class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
17
9
  constructor(input) {
10
+ var _a;
18
11
  super(input);
19
- this.input = {
20
- requestId: input.requestId,
21
- };
22
- }
23
- serialize(input, config) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (!config.serviceId.kakao)
26
- throw new util_error_handler_1.IngestkoreaError({
27
- code: 400,
28
- type: "Bad Request",
29
- message: "Invalid Params",
30
- description: "Please Check Kakao ServiceId",
31
- });
32
- let request = yield (0, GetAlimtalkStatus_1.serializeIngestkorea_restJson_GetAlimtalkStatusCommand)(input, config);
33
- return request;
34
- });
35
- }
36
- deserialize(response) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- let output = yield (0, GetAlimtalkStatus_1.deserializeIngestkorea_restJson_GetAlimtalkStatusCommand)(response);
39
- return output;
40
- });
12
+ this.input = Object.assign({ requestId: input.requestId, pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)) }, (input.nextToken && { nextToken: input.nextToken }));
13
+ this.serializer = GetAlimtalkStatus_js_1.se_GetAlimtalkStatusCommand;
14
+ this.deserializer = GetAlimtalkStatus_js_1.de_GetAlimtalkStatusCommand;
41
15
  }
42
16
  }
43
17
  exports.GetAlimtalkStatusCommand = GetAlimtalkStatusCommand;
@@ -1,44 +1,17 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkTemplateCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkTemplate_1 = require("../protocols/GetAlimtalkTemplate");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkTemplateCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetAlimtalkTemplate_js_1 = require("../protocols/GetAlimtalkTemplate.js");
6
+ class GetAlimtalkTemplateCommand extends index_js_1.SensCommand {
17
7
  constructor(input) {
18
8
  super(input);
19
9
  this.input = {
20
10
  channelId: input.channelId,
21
11
  templateCode: input.templateCode,
22
12
  };
23
- }
24
- serialize(input, config) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- if (!config.serviceId.kakao)
27
- throw new util_error_handler_1.IngestkoreaError({
28
- code: 400,
29
- type: "Bad Request",
30
- message: "Invalid Params",
31
- description: "Please Check Kakao ServiceId",
32
- });
33
- let request = yield (0, GetAlimtalkTemplate_1.serializeIngestkorea_restJson_GetAlimtalkTemplateCommand)(input, config);
34
- return request;
35
- });
36
- }
37
- deserialize(response) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- let output = yield (0, GetAlimtalkTemplate_1.deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand)(response);
40
- return output;
41
- });
13
+ this.serializer = GetAlimtalkTemplate_js_1.se_GetAlimtalkTemplateCommand;
14
+ this.deserializer = GetAlimtalkTemplate_js_1.de_GetAlimtalkTemplateCommand;
42
15
  }
43
16
  }
44
17
  exports.GetAlimtalkTemplateCommand = GetAlimtalkTemplateCommand;
@@ -1,41 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetSMSResultCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetSMSResult_1 = require("../protocols/GetSMSResult");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetSMSResultCommand extends models_1.SensCommand {
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 {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.sms)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check SMS ServiceId",
29
- });
30
- let request = yield (0, GetSMSResult_1.serializeIngestkorea_restJson_GetSMSResultCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetSMSResult_1.deserializeIngestkorea_restJson_GetSMSResultCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ messageId: input.messageId,
11
+ };
12
+ this.serializer = GetSMSResult_js_1.se_GetSMSResultCommand;
13
+ this.deserializer = GetSMSResult_js_1.de_GetSMSResultCommand;
39
14
  }
40
15
  }
41
16
  exports.GetSMSResultCommand = GetSMSResultCommand;
@@ -1,41 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetSMSStatusCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetSMSStatus_1 = require("../protocols/GetSMSStatus");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetSMSStatusCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetSMSStatus_js_1 = require("../protocols/GetSMSStatus.js");
6
+ class GetSMSStatusCommand extends index_js_1.SensCommand {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.sms)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check SMS ServiceId",
29
- });
30
- let request = yield (0, GetSMSStatus_1.serializeIngestkorea_restJson_GetSMSStatusCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetSMSStatus_1.deserializeIngestkorea_restJson_GetSMSStatusCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ requestId: input.requestId,
11
+ };
12
+ this.serializer = GetSMSStatus_js_1.se_GetSMSStatusCommand;
13
+ this.deserializer = GetSMSStatus_js_1.de_GetSMSStatusCommand;
39
14
  }
40
15
  }
41
16
  exports.GetSMSStatusCommand = GetSMSStatusCommand;
@@ -1,41 +1,14 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.ListAlimtalkChannelsCommand = void 0;
13
- const models_1 = require("../models");
14
- const ListAlimtalkChannels_1 = require("../protocols/ListAlimtalkChannels");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class ListAlimtalkChannelsCommand extends models_1.SensCommand {
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 {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.kakao)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check Kakao ServiceId",
29
- });
30
- let request = yield (0, ListAlimtalkChannels_1.serializeIngestkorea_restJson_ListAlimtalkChannelsCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, ListAlimtalkChannels_1.deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand)(response);
37
- return output;
38
- });
9
+ this.input = {};
10
+ this.serializer = ListAlimtalkChannels_js_1.se_ListAlimtalkChannelsCommand;
11
+ this.deserializer = ListAlimtalkChannels_js_1.de_ListAlimtalkChannelsCommand;
39
12
  }
40
13
  }
41
14
  exports.ListAlimtalkChannelsCommand = ListAlimtalkChannelsCommand;