@ingestkorea/client-sens 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +99 -57
  2. package/dist-cjs/SensClient.js +42 -43
  3. package/dist-cjs/commands/GetAlimtalkResultCommand.js +3 -0
  4. package/dist-cjs/commands/GetAlimtalkStatusCommand.js +8 -1
  5. package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +3 -0
  6. package/dist-cjs/commands/GetSMSResultCommand.js +3 -0
  7. package/dist-cjs/commands/GetSMSStatusCommand.js +8 -1
  8. package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +3 -0
  9. package/dist-cjs/commands/ListAlimtalkStatusCommand.js +22 -10
  10. package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +3 -0
  11. package/dist-cjs/commands/ListSMSStatusCommand.js +21 -10
  12. package/dist-cjs/commands/SendAlimtalkCommand.js +15 -14
  13. package/dist-cjs/commands/SendMMSCommand.js +16 -23
  14. package/dist-cjs/commands/SendSMSCommand.js +28 -16
  15. package/dist-cjs/commands/constants.js +8 -19
  16. package/dist-cjs/index.js +1 -0
  17. package/dist-cjs/middleware/constants.js +2 -1
  18. package/dist-cjs/middleware/middleware-metadata.js +7 -12
  19. package/dist-cjs/middleware/middleware-retry.js +48 -38
  20. package/dist-cjs/middleware/middleware-sign.js +8 -12
  21. package/dist-cjs/models/SensApiError.js +21 -0
  22. package/dist-cjs/models/{SensErrorInfo.js → SensClientError.js} +6 -1
  23. package/dist-cjs/models/SensCommand.js +1 -0
  24. package/dist-cjs/models/index.js +2 -1
  25. package/dist-cjs/protocols/GetAlimtalkResult.js +14 -17
  26. package/dist-cjs/protocols/GetAlimtalkStatus.js +21 -17
  27. package/dist-cjs/protocols/GetAlimtalkTemplate.js +29 -17
  28. package/dist-cjs/protocols/GetSMSResult.js +16 -17
  29. package/dist-cjs/protocols/GetSMSStatus.js +10 -16
  30. package/dist-cjs/protocols/ListAlimtalkChannels.js +10 -16
  31. package/dist-cjs/protocols/ListAlimtalkStatus.js +10 -16
  32. package/dist-cjs/protocols/ListAlimtalkTemplates.js +12 -19
  33. package/dist-cjs/protocols/ListSMSStatus.js +10 -16
  34. package/dist-cjs/protocols/SendAlimtalk.js +10 -16
  35. package/dist-cjs/protocols/SendMMS.js +4 -13
  36. package/dist-cjs/protocols/SendSMS.js +11 -17
  37. package/dist-cjs/protocols/constants.js +124 -82
  38. package/dist-es/SensClient.js +37 -31
  39. package/dist-es/commands/GetAlimtalkResultCommand.js +8 -9
  40. package/dist-es/commands/GetAlimtalkStatusCommand.js +8 -9
  41. package/dist-es/commands/GetAlimtalkTemplateCommand.js +8 -9
  42. package/dist-es/commands/GetSMSResultCommand.js +8 -9
  43. package/dist-es/commands/GetSMSStatusCommand.js +8 -9
  44. package/dist-es/commands/ListAlimtalkChannelsCommand.js +8 -9
  45. package/dist-es/commands/ListAlimtalkStatusCommand.js +24 -28
  46. package/dist-es/commands/ListAlimtalkTemplatesCommand.js +8 -9
  47. package/dist-es/commands/ListSMSStatusCommand.js +25 -29
  48. package/dist-es/commands/SendAlimtalkCommand.js +18 -26
  49. package/dist-es/commands/SendMMSCommand.js +37 -48
  50. package/dist-es/commands/SendSMSCommand.js +25 -29
  51. package/dist-es/commands/constants.js +18 -39
  52. package/dist-es/commands/index.js +12 -28
  53. package/dist-es/index.js +3 -18
  54. package/dist-es/middleware/constants.js +8 -10
  55. package/dist-es/middleware/index.js +3 -19
  56. package/dist-es/middleware/middleware-metadata.js +4 -7
  57. package/dist-es/middleware/middleware-retry.js +47 -38
  58. package/dist-es/middleware/middleware-sign.js +9 -13
  59. package/dist-es/models/GetAlimtalkResult.js +1 -2
  60. package/dist-es/models/GetAlimtalkStatus.js +1 -2
  61. package/dist-es/models/GetAlimtalkTemplate.js +1 -2
  62. package/dist-es/models/GetSMSResult.js +1 -2
  63. package/dist-es/models/GetSMSStatus.js +1 -2
  64. package/dist-es/models/ListAlimtalkChannels.js +1 -2
  65. package/dist-es/models/ListAlimtalkStatus.js +1 -2
  66. package/dist-es/models/ListAlimtalkTemplates.js +1 -2
  67. package/dist-es/models/ListSMSStatus.js +1 -2
  68. package/dist-es/models/MetadataBearer.js +1 -2
  69. package/dist-es/models/SendAlimtalk.js +2 -5
  70. package/dist-es/models/SendMMS.js +2 -5
  71. package/dist-es/models/SendSMS.js +1 -2
  72. package/dist-es/models/SensApiError.js +18 -0
  73. package/dist-es/models/SensClient.js +1 -2
  74. package/dist-es/models/SensClientError.js +14 -0
  75. package/dist-es/models/SensCommand.js +2 -5
  76. package/dist-es/models/SensMiddleware.js +1 -2
  77. package/dist-es/models/index.js +18 -33
  78. package/dist-es/protocols/GetAlimtalkResult.js +11 -16
  79. package/dist-es/protocols/GetAlimtalkStatus.js +17 -24
  80. package/dist-es/protocols/GetAlimtalkTemplate.js +12 -17
  81. package/dist-es/protocols/GetSMSResult.js +11 -16
  82. package/dist-es/protocols/GetSMSStatus.js +15 -22
  83. package/dist-es/protocols/ListAlimtalkChannels.js +11 -16
  84. package/dist-es/protocols/ListAlimtalkStatus.js +11 -16
  85. package/dist-es/protocols/ListAlimtalkTemplates.js +15 -22
  86. package/dist-es/protocols/ListSMSStatus.js +11 -16
  87. package/dist-es/protocols/SendAlimtalk.js +12 -18
  88. package/dist-es/protocols/SendMMS.js +5 -10
  89. package/dist-es/protocols/SendSMS.js +12 -18
  90. package/dist-es/protocols/constants.js +126 -88
  91. package/dist-types/SensClient.d.ts +0 -1
  92. package/dist-types/index.d.ts +1 -0
  93. package/dist-types/middleware/constants.d.ts +1 -0
  94. package/dist-types/models/MetadataBearer.d.ts +1 -0
  95. package/dist-types/models/SensApiError.d.ts +55 -0
  96. package/dist-types/models/SensClient.d.ts +8 -1
  97. package/dist-types/models/SensClientError.d.ts +18 -0
  98. package/dist-types/models/index.d.ts +2 -1
  99. package/dist-types/protocols/constants.d.ts +1 -1
  100. package/package.json +4 -5
  101. package/dist-es/models/SensErrorInfo.js +0 -13
  102. package/dist-types/models/SensErrorInfo.d.ts +0 -21
@@ -1,95 +1,112 @@
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.convertToUtc = exports.compact = exports.parseErrorBody = exports.parseBody = exports.deserializeMetadata = void 0;
13
4
  const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
5
  const index_js_1 = require("../models/index.js");
15
6
  const constants_js_1 = require("../middleware/constants.js");
7
+ const ALLOWED_CONTENT_TYPES = ["application/json"];
8
+ const SENS_ERROR_BODY_SPEC = [
9
+ ["status", "number", true],
10
+ ["errorMessage", "string", false],
11
+ ["errors", "object", false],
12
+ ];
13
+ const NCLOUD_ERROR_BODY_SPEC = [
14
+ ["errorCode", "string", true],
15
+ ["message", "string", false],
16
+ ["details", "string", false],
17
+ ];
16
18
  const deserializeMetadata = (response) => {
17
19
  const attempts = response.headers[constants_js_1.INGESTKOREA_RETRY] || "1";
18
20
  const totalRetryDelay = response.headers[constants_js_1.INGESTKOREA_RETRY_DELAY] || "0";
21
+ const traceId = response.headers[constants_js_1.NCP_TRACE_ID] || undefined;
19
22
  return {
20
23
  httpStatusCode: response.statusCode,
21
24
  attempts: Number(attempts),
22
25
  totalRetryDelay: Number(totalRetryDelay),
26
+ ...(traceId && { traceId }),
23
27
  };
24
28
  };
25
29
  exports.deserializeMetadata = deserializeMetadata;
26
- const parseBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
30
+ const parseBody = async (output) => {
27
31
  const { statusCode, headers, body: streamBody } = output;
28
- if (!isJsonResponse(headers["content-type"])) {
29
- yield (0, util_http_handler_1.destroyStream)(streamBody);
32
+ if (!isSupportContentType(ALLOWED_CONTENT_TYPES, headers["content-type"])) {
33
+ await (0, util_http_handler_1.destroyStream)(streamBody);
30
34
  throw new index_js_1.SensError({
31
- code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
32
- type: "Bad Request",
33
- message: "response content-type is not application/json",
35
+ code: statusCode,
36
+ type: "SDK.REQUEST_ERROR",
37
+ message: `response content-type is not ${ALLOWED_CONTENT_TYPES.join(" or ")}`,
34
38
  });
35
39
  }
36
- const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
37
- if (data.length) {
38
- try {
39
- return JSON.parse(data);
40
- }
41
- catch (e) {
42
- yield (0, util_http_handler_1.destroyStream)(streamBody);
43
- throw new index_js_1.SensError({
44
- code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
45
- type: "Bad Request",
46
- message: "parse response body error",
47
- });
48
- }
40
+ try {
41
+ const data = await (0, util_http_handler_1.collectBodyString)(streamBody);
42
+ return data.length ? JSON.parse(data) : {};
49
43
  }
50
- return {};
51
- });
44
+ catch (e) {
45
+ throw new index_js_1.SensError({
46
+ code: -1,
47
+ type: "SDK.REQUEST_ERROR",
48
+ message: "parse response body error",
49
+ });
50
+ }
51
+ };
52
52
  exports.parseBody = parseBody;
53
- const parseErrorBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
53
+ const parseErrorBody = async (output) => {
54
54
  const { statusCode, headers, body: streamBody } = output;
55
- const error = new index_js_1.SensError({
56
- code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
57
- type: "Bad Request",
58
- message: "something wrong",
59
- });
60
- if (!isJsonResponse(headers["content-type"])) {
61
- yield (0, util_http_handler_1.destroyStream)(streamBody);
62
- error.message = "response content-type is not application/json";
63
- throw error;
55
+ if (!isSupportContentType(ALLOWED_CONTENT_TYPES, headers["content-type"])) {
56
+ await (0, util_http_handler_1.destroyStream)(streamBody);
57
+ throw new index_js_1.SensError({
58
+ code: -1,
59
+ type: "SDK.REQUEST_ERROR",
60
+ message: `response content-type is not ${ALLOWED_CONTENT_TYPES.join(" or ")}`,
61
+ });
64
62
  }
65
- const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
66
- yield (0, util_http_handler_1.destroyStream)(streamBody);
67
- const sensErrorBody = isSensErrorBody(data);
68
- if (!sensErrorBody) {
69
- throw error;
63
+ try {
64
+ const data = await (0, util_http_handler_1.collectBodyString)(streamBody);
65
+ const sensContent = isSensErrorResponse(data);
66
+ const nCloudContent = isNCloudErrorResponse(data);
67
+ if (sensContent) {
68
+ throw handleSensError(sensContent, statusCode);
69
+ }
70
+ if (nCloudContent) {
71
+ throw handleNCloudError(nCloudContent, statusCode);
72
+ }
73
+ const summary = data ? data.slice(0, 100).trim() : "empty response";
74
+ throw new index_js_1.SensError({
75
+ code: -1,
76
+ type: "SDK.UNKNOWN_ERROR",
77
+ message: "Invalid Naver Cloud Platform response format",
78
+ errors: [`HTTP ${statusCode} - ${summary}...`],
79
+ });
70
80
  }
71
- throw new index_js_1.SensError(Object.assign({ code: sensErrorBody.status, type: SENS_ERROR_CODE_SPEC[sensErrorBody.status] || "Unknown Error", message: sensErrorBody.errorMessage || "Something wrong" }, (sensErrorBody.errors &&
72
- Array.isArray(sensErrorBody.errors) && {
73
- invalidInputs: sensErrorBody.errors.map((msg) => {
74
- return { type: "not-valid.args", message: msg };
75
- }),
76
- })));
77
- });
81
+ catch (e) {
82
+ await (0, util_http_handler_1.destroyStream)(streamBody);
83
+ throw e;
84
+ }
85
+ };
78
86
  exports.parseErrorBody = parseErrorBody;
79
- const SENS_ERROR_CODE_SPEC = {
80
- 400: "Bad Request",
81
- 401: "Unauthorized",
82
- 403: "Forbidden",
83
- 404: "Not Found",
84
- 429: "Too Many Requests",
85
- 500: "Internal Server Error",
87
+ const compact = (obj) => {
88
+ if (Array.isArray(obj)) {
89
+ return obj.map((item) => (0, exports.compact)(item));
90
+ }
91
+ if (typeof obj === "object" && obj !== null) {
92
+ return Object.fromEntries(Object.entries(obj)
93
+ .filter(([_, value]) => value !== undefined) // undefined 필드 제거
94
+ .map(([key, value]) => [key, (0, exports.compact)(value)]) // 내부 값 재귀 처리
95
+ );
96
+ }
97
+ return obj;
86
98
  };
87
- const SENS_ERROR_BODY_SPEC = [
88
- ["status", "number", true],
89
- ["errorMessage", "string", false],
90
- ["errors", "object", false],
91
- ];
92
- const isSensErrorBody = (input) => {
99
+ exports.compact = compact;
100
+ const convertToUtc = (input) => {
101
+ const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
102
+ return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
103
+ };
104
+ exports.convertToUtc = convertToUtc;
105
+ const isSupportContentType = (allowedTypes, contentType) => {
106
+ const matchedType = allowedTypes.find((type) => contentType?.toLowerCase().includes(type));
107
+ return !!matchedType;
108
+ };
109
+ const isSensErrorResponse = (input) => {
93
110
  if (typeof input !== "string")
94
111
  return null;
95
112
  try {
@@ -106,28 +123,53 @@ const isSensErrorBody = (input) => {
106
123
  });
107
124
  return isValid ? data : null;
108
125
  }
109
- catch (_a) {
126
+ catch {
110
127
  return null;
111
128
  }
112
129
  };
113
- const compact = (obj) => {
114
- if (Array.isArray(obj)) {
115
- return obj.map((item) => (0, exports.compact)(item));
130
+ const isNCloudErrorResponse = (input) => {
131
+ if (typeof input !== "string")
132
+ return null;
133
+ try {
134
+ const data = JSON.parse(input);
135
+ if (!(data && typeof data == "object" && typeof data.error == "object"))
136
+ return null;
137
+ const isValid = NCLOUD_ERROR_BODY_SPEC.every(([key, type, required]) => {
138
+ const value = data.error[key];
139
+ if (required && (value === undefined || value === null))
140
+ return false;
141
+ if (value !== undefined && typeof value !== type)
142
+ return false;
143
+ return true;
144
+ });
145
+ return isValid ? data : null;
116
146
  }
117
- if (typeof obj === "object" && obj !== null) {
118
- return Object.fromEntries(Object.entries(obj)
119
- .filter(([_, value]) => value !== undefined) // undefined 필드 제거
120
- .map(([key, value]) => [key, (0, exports.compact)(value)]) // 내부 값 재귀 처리
121
- );
147
+ catch {
148
+ return null;
122
149
  }
123
- return obj;
124
150
  };
125
- exports.compact = compact;
126
- const convertToUtc = (input) => {
127
- const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
128
- return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
151
+ const isSensErrorCode = (code) => {
152
+ return code in index_js_1.SENS_ERROR_CODE_SPEC;
129
153
  };
130
- exports.convertToUtc = convertToUtc;
131
- const isJsonResponse = (contentType) => {
132
- return /application\/json/gi.exec(contentType || "") ? true : false;
154
+ const isNCloudErrorCode = (code) => {
155
+ return code in index_js_1.NCLOUD_ERROR_CODE_SPEC;
156
+ };
157
+ const handleSensError = (data, httpStatusCode) => {
158
+ return new index_js_1.SensError({
159
+ code: httpStatusCode,
160
+ type: isSensErrorCode(data.status) ? index_js_1.SENS_ERROR_CODE_SPEC[data.status] : "SDK.UNKNOWN_ERROR",
161
+ message: data.errorMessage || "something wrong",
162
+ ...(Array.isArray(data?.errors) && {
163
+ errors: data.errors.filter((d) => !!d).map((d) => String(d)),
164
+ }),
165
+ });
166
+ };
167
+ const handleNCloudError = (data, httpStatusCode) => {
168
+ const { errorCode, message, details } = data.error;
169
+ throw new index_js_1.SensError({
170
+ code: httpStatusCode,
171
+ type: isNCloudErrorCode(errorCode) ? index_js_1.NCLOUD_ERROR_CODE_SPEC[errorCode].type : "SDK.UNKNOWN_ERROR",
172
+ message: message || "something wrong",
173
+ ...(typeof details == "string" && { errors: [details] }),
174
+ });
133
175
  };
@@ -1,34 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SensClient = void 0;
4
- const util_http_handler_1 = require("@ingestkorea/util-http-handler");
5
- const index_js_1 = require("./models/index.js");
6
- const index_js_2 = require("./middleware/index.js");
7
- class SensClient {
1
+ import { NodeHttpHandler } from "@ingestkorea/util-http-handler";
2
+ import { SensError, } from "./models/index.js";
3
+ import { middlewareIngestkoreaMetadata, middlewareNcpSign, middlewareRetry } from "./middleware/index.js";
4
+ export class SensClient {
5
+ config;
6
+ httpHandler;
8
7
  constructor(config) {
9
- this.httpHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
10
- this.requestHandler = async (input, context) => this.httpHandler.handle(input.request);
11
8
  this.config = {
12
9
  credentials: resolveCredentials(config),
13
10
  serviceId: resolveServiceId(config),
11
+ httpHandler: {
12
+ connectionTimeout: config.httpHandler?.connectionTimeout ?? 2000,
13
+ socketTimeout: config.httpHandler?.socketTimeout ?? 3000,
14
+ keepAlive: config.httpHandler?.keepAlive ?? false,
15
+ family: 4,
16
+ },
14
17
  };
18
+ this.httpHandler = new NodeHttpHandler(this.config.httpHandler);
15
19
  }
16
20
  async send(command) {
17
21
  const { input, serializer, deserializer } = command;
18
- const middlewares = [index_js_2.middlewareIngestkoreaMetadata, index_js_2.middlewareNcpSign, index_js_2.middlewareRetry];
19
- const handler = composeMiddleware(middlewares, this.requestHandler);
22
+ const middlewares = [middlewareIngestkoreaMetadata, middlewareNcpSign, middlewareRetry];
23
+ const finalHandler = async (input, context) => this.httpHandler.handle(input.request);
24
+ const handler = composeMiddleware(middlewares, finalHandler);
20
25
  try {
21
26
  const request = await serializer(input, this.config);
22
27
  const { response } = await handler({ request }, this.config);
23
28
  const output = await deserializer(response, this.config);
24
29
  return output;
25
30
  }
26
- catch (e) {
27
- throw e;
31
+ catch (error) {
32
+ if (error instanceof SensError)
33
+ throw error;
34
+ throw new SensError({
35
+ code: -1,
36
+ type: "SDK.UNKNOWN_ERROR",
37
+ message: error instanceof Error ? error.message : "unknown error",
38
+ });
28
39
  }
29
40
  }
30
41
  }
31
- exports.SensClient = SensClient;
32
42
  const composeMiddleware = (middlewares, finalHandler) => {
33
43
  const handler = middlewares.reduceRight((next, middleware) => {
34
44
  return middleware(next);
@@ -37,20 +47,19 @@ const composeMiddleware = (middlewares, finalHandler) => {
37
47
  };
38
48
  const resolveCredentials = (config) => {
39
49
  const { credentials } = config;
40
- let error = new index_js_1.SensError({
41
- code: 401,
42
- type: "Unauthorized",
43
- message: "Invalid Credentials",
44
- invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 인증 정보를 확인해주세요" }],
50
+ const error = new SensError({
51
+ code: -1,
52
+ type: "SDK.AUTH_ERROR",
53
+ message: "SensClient 초기화시 인증 정보를 입력해주세요.",
45
54
  });
46
55
  if (!credentials)
47
56
  throw error;
48
57
  if (!credentials.accessKey) {
49
- error.invalidInputs[0].message = "AccessKey 정보를 확인해주세요";
58
+ error.message = "AccessKey 정보를 확인해주세요.";
50
59
  throw error;
51
60
  }
52
61
  if (!credentials.secretKey) {
53
- error.invalidInputs[0].message = "SecretKey 정보를 확인해주세요";
62
+ error.message = "SecretKey 정보를 확인해주세요.";
54
63
  throw error;
55
64
  }
56
65
  return {
@@ -59,24 +68,21 @@ const resolveCredentials = (config) => {
59
68
  };
60
69
  };
61
70
  const resolveServiceId = (config) => {
62
- var _a, _b, _c;
63
71
  const { serviceId } = config;
64
- let error = new index_js_1.SensError({
65
- code: 400,
66
- type: "Bad Request",
67
- message: "Invalid ServiceId",
68
- invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 서비스 정보를 확인해주세요" }],
72
+ const error = new SensError({
73
+ code: -1,
74
+ type: "SDK.GENERAL_ERROR",
75
+ message: "SensClient 초기화시 사용할 서비스 정보를 입력해주세요.",
69
76
  });
70
77
  if (!serviceId)
71
78
  throw error;
72
79
  const isReady = !!Object.values(serviceId).filter((d) => !!d).length;
73
80
  if (!isReady) {
74
- error.invalidInputs[0].message = "최소 1개 이상의 서비스 정보가 필요합니다";
81
+ error.message = "최소 1개 이상의 서비스 정보가 필요합니다";
75
82
  throw error;
76
83
  }
77
84
  return {
78
- kakao: (_a = serviceId.kakao) !== null && _a !== void 0 ? _a : "",
79
- push: (_b = serviceId.push) !== null && _b !== void 0 ? _b : "",
80
- sms: (_c = serviceId.sms) !== null && _c !== void 0 ? _c : "",
85
+ kakao: serviceId.kakao ?? "",
86
+ sms: serviceId.sms ?? "",
81
87
  };
82
88
  };
@@ -1,16 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAlimtalkResultCommand = void 0;
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 {
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_GetAlimtalkResultCommand, de_GetAlimtalkResultCommand } from "../protocols/GetAlimtalkResult.js";
3
+ export class GetAlimtalkResultCommand extends SensCommand {
4
+ input;
5
+ serializer;
6
+ deserializer;
7
7
  constructor(input) {
8
8
  super(input);
9
9
  this.input = {
10
10
  messageId: input.messageId,
11
11
  };
12
- this.serializer = GetAlimtalkResult_js_1.se_GetAlimtalkResultCommand;
13
- this.deserializer = GetAlimtalkResult_js_1.de_GetAlimtalkResultCommand;
12
+ this.serializer = se_GetAlimtalkResultCommand;
13
+ this.deserializer = de_GetAlimtalkResultCommand;
14
14
  }
15
15
  }
16
- exports.GetAlimtalkResultCommand = GetAlimtalkResultCommand;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAlimtalkStatusCommand = void 0;
4
- const index_js_1 = require("../models/index.js");
5
- const GetAlimtalkStatus_js_1 = require("../protocols/GetAlimtalkStatus.js");
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_GetAlimtalkStatusCommand, de_GetAlimtalkStatusCommand } from "../protocols/GetAlimtalkStatus.js";
6
3
  const MAX_LIMIT = 100;
7
- class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
4
+ export class GetAlimtalkStatusCommand extends SensCommand {
5
+ input;
6
+ serializer;
7
+ deserializer;
8
8
  constructor(input) {
9
9
  super(input);
10
10
  this.input = {
@@ -12,8 +12,7 @@ class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
12
12
  pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT,
13
13
  ...(input.nextToken && { nextToken: input.nextToken }),
14
14
  };
15
- this.serializer = GetAlimtalkStatus_js_1.se_GetAlimtalkStatusCommand;
16
- this.deserializer = GetAlimtalkStatus_js_1.de_GetAlimtalkStatusCommand;
15
+ this.serializer = se_GetAlimtalkStatusCommand;
16
+ this.deserializer = de_GetAlimtalkStatusCommand;
17
17
  }
18
18
  }
19
- exports.GetAlimtalkStatusCommand = GetAlimtalkStatusCommand;
@@ -1,17 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAlimtalkTemplateCommand = void 0;
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 {
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_GetAlimtalkTemplateCommand, de_GetAlimtalkTemplateCommand } from "../protocols/GetAlimtalkTemplate.js";
3
+ export class GetAlimtalkTemplateCommand extends SensCommand {
4
+ input;
5
+ serializer;
6
+ deserializer;
7
7
  constructor(input) {
8
8
  super(input);
9
9
  this.input = {
10
10
  channelId: input.channelId,
11
11
  templateCode: input.templateCode,
12
12
  };
13
- this.serializer = GetAlimtalkTemplate_js_1.se_GetAlimtalkTemplateCommand;
14
- this.deserializer = GetAlimtalkTemplate_js_1.de_GetAlimtalkTemplateCommand;
13
+ this.serializer = se_GetAlimtalkTemplateCommand;
14
+ this.deserializer = de_GetAlimtalkTemplateCommand;
15
15
  }
16
16
  }
17
- exports.GetAlimtalkTemplateCommand = GetAlimtalkTemplateCommand;
@@ -1,16 +1,15 @@
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 {
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_GetSMSResultCommand, de_GetSMSResultCommand } from "../protocols/GetSMSResult.js";
3
+ export class GetSMSResultCommand extends SensCommand {
4
+ input;
5
+ serializer;
6
+ deserializer;
7
7
  constructor(input) {
8
8
  super(input);
9
9
  this.input = {
10
10
  messageId: input.messageId,
11
11
  };
12
- this.serializer = GetSMSResult_js_1.se_GetSMSResultCommand;
13
- this.deserializer = GetSMSResult_js_1.de_GetSMSResultCommand;
12
+ this.serializer = se_GetSMSResultCommand;
13
+ this.deserializer = de_GetSMSResultCommand;
14
14
  }
15
15
  }
16
- exports.GetSMSResultCommand = GetSMSResultCommand;
@@ -1,10 +1,10 @@
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");
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_GetSMSStatusCommand, de_GetSMSStatusCommand } from "../protocols/GetSMSStatus.js";
6
3
  const MAX_LIMIT = 100;
7
- class GetSMSStatusCommand extends index_js_1.SensCommand {
4
+ export class GetSMSStatusCommand extends SensCommand {
5
+ input;
6
+ serializer;
7
+ deserializer;
8
8
  constructor(input) {
9
9
  super(input);
10
10
  this.input = {
@@ -12,8 +12,7 @@ class GetSMSStatusCommand extends index_js_1.SensCommand {
12
12
  pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT,
13
13
  ...(input.nextToken && { nextToken: input.nextToken }),
14
14
  };
15
- this.serializer = GetSMSStatus_js_1.se_GetSMSStatusCommand;
16
- this.deserializer = GetSMSStatus_js_1.de_GetSMSStatusCommand;
15
+ this.serializer = se_GetSMSStatusCommand;
16
+ this.deserializer = de_GetSMSStatusCommand;
17
17
  }
18
18
  }
19
- exports.GetSMSStatusCommand = GetSMSStatusCommand;
@@ -1,14 +1,13 @@
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 {
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_ListAlimtalkChannelsCommand, de_ListAlimtalkChannelsCommand } from "../protocols/ListAlimtalkChannels.js";
3
+ export class ListAlimtalkChannelsCommand extends SensCommand {
4
+ input;
5
+ serializer;
6
+ deserializer;
7
7
  constructor(input) {
8
8
  super(input);
9
9
  this.input = {};
10
- this.serializer = ListAlimtalkChannels_js_1.se_ListAlimtalkChannelsCommand;
11
- this.deserializer = ListAlimtalkChannels_js_1.de_ListAlimtalkChannelsCommand;
10
+ this.serializer = se_ListAlimtalkChannelsCommand;
11
+ this.deserializer = de_ListAlimtalkChannelsCommand;
12
12
  }
13
13
  }
14
- exports.ListAlimtalkChannelsCommand = ListAlimtalkChannelsCommand;
@@ -1,49 +1,45 @@
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일 이내만 조회 가능
1
+ import { SensCommand, SensError, } from "../models/index.js";
2
+ import { se_ListAlimtalkStatusCommand, de_ListAlimtalkStatusCommand } from "../protocols/ListAlimtalkStatus.js";
3
+ import { getDefaultRequestDuration, resolveRequestDuration, convertToUtc, convertToKst, prettyPhoneNum, } from "./constants.js";
4
+ const DURATION_LIMIT_MS = 30 * 24 * 3_600_000; // 30일 이내만 조회 가능
8
5
  const MAX_LIMIT = 100;
9
6
  const DEFAULT_LIMIT = 20;
10
- class ListAlimtalkStatusCommand extends index_js_1.SensCommand {
7
+ export class ListAlimtalkStatusCommand extends SensCommand {
8
+ input;
9
+ serializer;
10
+ deserializer;
11
11
  constructor(input) {
12
- var _a;
13
12
  super(input);
14
13
  if (input.nextToken && (!input.requestStartTime || !input.requestEndTime)) {
15
- throw new index_js_1.SensError({
16
- code: 400,
17
- type: "Bad Request",
14
+ throw new SensError({
15
+ code: -1,
16
+ type: "SDK.GENERAL_ERROR",
18
17
  message: "페이지네이션 검색 조건 불일치",
19
- invalidInputs: [
20
- {
21
- type: "not-valid.args",
22
- message: "nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션(requestStartTime, requestEndTime, pageSize 등)이 모두 동일하게 유지되어야 합니다.",
23
- },
18
+ errors: [
19
+ "nextToken 사용 시 데이터 일관성을 위해 최초 요청 시의 옵션이 모두 동일하게 유지되어야 합니다.",
20
+ "requestStartTime, requestEndTime, pageSize 옵션을 확인해주세요.",
24
21
  ],
25
22
  });
26
23
  }
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,
24
+ const defaultDuration = getDefaultRequestDuration({ durationLimitMs: DURATION_LIMIT_MS });
25
+ const { startTimeMs, endTimeMs } = resolveRequestDuration({
26
+ startTime: input.requestStartTime ? convertToUtc(input.requestStartTime) : defaultDuration.startTime,
27
+ endTime: input.requestEndTime ? convertToUtc(input.requestEndTime) : defaultDuration.endTime,
31
28
  }, { durationLimitMs: DURATION_LIMIT_MS });
32
29
  this.input = {
33
30
  plusFriendId: input.plusFriendId,
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)),
31
+ requestStartTime: convertToKst(startTimeMs),
32
+ requestEndTime: convertToKst(endTimeMs),
33
+ pageSize: Math.min(MAX_LIMIT, Math.max(1, input.pageSize ?? DEFAULT_LIMIT)),
37
34
  ...(input.requestStatusName && { requestStatusName: input.requestStatusName }),
38
35
  ...(input.messageStatusName && { messageStatusName: input.messageStatusName }),
39
36
  ...(input.requestId && { requestId: input.requestId, pageSize: MAX_LIMIT }),
40
37
  ...(input.messageId && { messageId: input.messageId }),
41
38
  ...(input.templateCode && { templateCode: input.templateCode }),
42
- ...(input.to && { to: (0, constants_js_1.prettyPhoneNum)(input.to) }),
39
+ ...(input.to && { to: prettyPhoneNum(input.to) }),
43
40
  ...(input.nextToken && { nextToken: input.nextToken }),
44
41
  };
45
- this.serializer = ListAlimtalkStatus_js_1.se_ListAlimtalkStatusCommand;
46
- this.deserializer = ListAlimtalkStatus_js_1.de_ListAlimtalkStatusCommand;
42
+ this.serializer = se_ListAlimtalkStatusCommand;
43
+ this.deserializer = de_ListAlimtalkStatusCommand;
47
44
  }
48
45
  }
49
- exports.ListAlimtalkStatusCommand = ListAlimtalkStatusCommand;
@@ -1,16 +1,15 @@
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 {
1
+ import { SensCommand, } from "../models/index.js";
2
+ import { se_ListAlimtalkTemplatesCommand, de_ListAlimtalkTemplatesCommand, } from "../protocols/ListAlimtalkTemplates.js";
3
+ export class ListAlimtalkTemplatesCommand extends SensCommand {
4
+ input;
5
+ serializer;
6
+ deserializer;
7
7
  constructor(input) {
8
8
  super(input);
9
9
  this.input = {
10
10
  channelId: input.channelId,
11
11
  };
12
- this.serializer = ListAlimtalkTemplates_js_1.se_ListAlimtalkTemplatesCommand;
13
- this.deserializer = ListAlimtalkTemplates_js_1.de_ListAlimtalkTemplatesCommand;
12
+ this.serializer = se_ListAlimtalkTemplatesCommand;
13
+ this.deserializer = de_ListAlimtalkTemplatesCommand;
14
14
  }
15
15
  }
16
- exports.ListAlimtalkTemplatesCommand = ListAlimtalkTemplatesCommand;