@ingestkorea/client-naver-commerce 0.3.1

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -0
  3. package/dist-cjs/NaverCommerceClient.js +77 -0
  4. package/dist-cjs/commands/CreateAccessTokenCommand.js +14 -0
  5. package/dist-cjs/commands/GetAccountInfoCommand.js +14 -0
  6. package/dist-cjs/commands/ListChangedOrderStatusesCommand.js +44 -0
  7. package/dist-cjs/commands/index.js +19 -0
  8. package/dist-cjs/index.js +18 -0
  9. package/dist-cjs/middleware/constants.js +9 -0
  10. package/dist-cjs/middleware/index.js +19 -0
  11. package/dist-cjs/middleware/middleware-auth.js +18 -0
  12. package/dist-cjs/middleware/middleware-metadata.js +18 -0
  13. package/dist-cjs/middleware/middleware-retry.js +64 -0
  14. package/dist-cjs/models/CommerceClient.js +2 -0
  15. package/dist-cjs/models/CommerceCommand.js +9 -0
  16. package/dist-cjs/models/CommerceErrorInfo.js +14 -0
  17. package/dist-cjs/models/CommerceMiddleware.js +2 -0
  18. package/dist-cjs/models/CreateAccessToken.js +2 -0
  19. package/dist-cjs/models/GetAccountInfo.js +2 -0
  20. package/dist-cjs/models/ListChangedOrderStatuses.js +36 -0
  21. package/dist-cjs/models/MetadataBearer.js +2 -0
  22. package/dist-cjs/models/index.js +24 -0
  23. package/dist-cjs/protocols/CreateAccessToken.js +61 -0
  24. package/dist-cjs/protocols/GetAccountInfo.js +47 -0
  25. package/dist-cjs/protocols/ListChangedOrderStatuses.js +81 -0
  26. package/dist-cjs/protocols/constants.js +116 -0
  27. package/dist-es/NaverCommerceClient.js +66 -0
  28. package/dist-es/commands/CreateAccessTokenCommand.js +14 -0
  29. package/dist-es/commands/GetAccountInfoCommand.js +14 -0
  30. package/dist-es/commands/ListChangedOrderStatusesCommand.js +49 -0
  31. package/dist-es/commands/index.js +19 -0
  32. package/dist-es/index.js +18 -0
  33. package/dist-es/middleware/constants.js +9 -0
  34. package/dist-es/middleware/index.js +19 -0
  35. package/dist-es/middleware/middleware-auth.js +12 -0
  36. package/dist-es/middleware/middleware-metadata.js +12 -0
  37. package/dist-es/middleware/middleware-retry.js +61 -0
  38. package/dist-es/models/CommerceClient.js +2 -0
  39. package/dist-es/models/CommerceCommand.js +9 -0
  40. package/dist-es/models/CommerceErrorInfo.js +14 -0
  41. package/dist-es/models/CommerceMiddleware.js +2 -0
  42. package/dist-es/models/CreateAccessToken.js +2 -0
  43. package/dist-es/models/GetAccountInfo.js +2 -0
  44. package/dist-es/models/ListChangedOrderStatuses.js +36 -0
  45. package/dist-es/models/MetadataBearer.js +2 -0
  46. package/dist-es/models/index.js +24 -0
  47. package/dist-es/protocols/CreateAccessToken.js +55 -0
  48. package/dist-es/protocols/GetAccountInfo.js +41 -0
  49. package/dist-es/protocols/ListChangedOrderStatuses.js +79 -0
  50. package/dist-es/protocols/constants.js +113 -0
  51. package/dist-types/NaverCommerceClient.d.ts +8 -0
  52. package/dist-types/commands/CreateAccessTokenCommand.d.ts +11 -0
  53. package/dist-types/commands/GetAccountInfoCommand.d.ts +11 -0
  54. package/dist-types/commands/ListChangedOrderStatusesCommand.d.ts +11 -0
  55. package/dist-types/commands/index.d.ts +3 -0
  56. package/dist-types/index.d.ts +2 -0
  57. package/dist-types/middleware/constants.d.ts +6 -0
  58. package/dist-types/middleware/index.d.ts +3 -0
  59. package/dist-types/middleware/middleware-auth.d.ts +2 -0
  60. package/dist-types/middleware/middleware-metadata.d.ts +2 -0
  61. package/dist-types/middleware/middleware-retry.d.ts +2 -0
  62. package/dist-types/models/CommerceClient.d.ts +13 -0
  63. package/dist-types/models/CommerceCommand.d.ts +9 -0
  64. package/dist-types/models/CommerceErrorInfo.d.ts +19 -0
  65. package/dist-types/models/CommerceMiddleware.d.ts +8 -0
  66. package/dist-types/models/CreateAccessToken.d.ts +7 -0
  67. package/dist-types/models/GetAccountInfo.d.ts +7 -0
  68. package/dist-types/models/ListChangedOrderStatuses.d.ts +68 -0
  69. package/dist-types/models/MetadataBearer.d.ts +10 -0
  70. package/dist-types/models/index.d.ts +8 -0
  71. package/dist-types/protocols/CreateAccessToken.d.ts +4 -0
  72. package/dist-types/protocols/GetAccountInfo.d.ts +4 -0
  73. package/dist-types/protocols/ListChangedOrderStatuses.d.ts +4 -0
  74. package/dist-types/protocols/constants.d.ts +5 -0
  75. package/package.json +56 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLAIM_TYPE = exports.PRODUCT_ORDER_STATUS_TYPE = exports.LAST_CHANGED_TYPE = void 0;
4
+ exports.LAST_CHANGED_TYPE = {
5
+ PAY_WAITING: "PAY_WAITING",
6
+ PAYED: "PAYED",
7
+ EXCHANGE_OPTION: "EXCHANGE_OPTION",
8
+ DELIVERY_ADDRESS_CHANGED: "DELIVERY_ADDRESS_CHANGED",
9
+ GIFT_RECEIVED: "GIFT_RECEIVED",
10
+ CLAIM_REJECTED: "CLAIM_REJECTED",
11
+ DISPATCHED: "DISPATCHED",
12
+ CLAIM_REQUESTED: "CLAIM_REQUESTED",
13
+ COLLECT_DONE: "COLLECT_DONE",
14
+ CLAIM_COMPLETED: "CLAIM_COMPLETED",
15
+ PURCHASE_DECIDED: "PURCHASE_DECIDED",
16
+ HOPE_DELIVERY_INFO_CHANGED: "HOPE_DELIVERY_INFO_CHANGED",
17
+ CLAIM_REDELIVERING: "CLAIM_REDELIVERING",
18
+ };
19
+ exports.PRODUCT_ORDER_STATUS_TYPE = {
20
+ PAYMENT_WAITING: "PAYMENT_WAITING",
21
+ PAYED: "PAYED",
22
+ DELIVERING: "DELIVERING",
23
+ DELIVERED: "DELIVERED",
24
+ PURCHASE_DECIDED: "PURCHASE_DECIDED",
25
+ EXCHANGED: "EXCHANGED",
26
+ CANCELED: "CANCELED",
27
+ RETURNED: "RETURNED",
28
+ CANCELED_BY_NOPAYMENT: "CANCELED_BY_NOPAYMENT",
29
+ };
30
+ exports.CLAIM_TYPE = {
31
+ CANCEL: "CANCEL",
32
+ RETURN: "RETURN",
33
+ EXCHANGE: "EXCHANGE",
34
+ PURCHASE_DECISION_HOLDBACK: "PURCHASE_DECISION_HOLDBACK",
35
+ ADMIN_CANCEL: "ADMIN_CANCEL",
36
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CommerceClient.js"), exports);
18
+ __exportStar(require("./CommerceCommand.js"), exports);
19
+ __exportStar(require("./CommerceErrorInfo.js"), exports);
20
+ __exportStar(require("./CommerceMiddleware.js"), exports);
21
+ __exportStar(require("./CreateAccessToken.js"), exports);
22
+ __exportStar(require("./GetAccountInfo.js"), exports);
23
+ __exportStar(require("./ListChangedOrderStatuses.js"), exports);
24
+ __exportStar(require("./MetadataBearer.js"), exports);
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.de_CreateAccessTokenCommand = exports.se_CreateAccessTokenCommand = void 0;
4
+ const bcrypt_1 = require("bcrypt");
5
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
6
+ const constants_js_1 = require("./constants.js");
7
+ const se_CreateAccessTokenCommand = async (input, config) => {
8
+ const hostname = "api.commerce.naver.com";
9
+ const path = "/external/v1/oauth2/token";
10
+ const headers = {
11
+ host: hostname,
12
+ accept: "application/json",
13
+ "content-type": "application/x-www-form-urlencoded",
14
+ };
15
+ const timestamp = new Date().getTime().toString();
16
+ const password = `${config.credentials.appId}_${timestamp}`;
17
+ const hashed = (0, bcrypt_1.hashSync)(password, config.credentials.appSecret);
18
+ const signature = Buffer.from(hashed, "utf-8").toString("base64");
19
+ const body = (0, util_http_handler_1.buildQueryString)({
20
+ type: "SELF",
21
+ timestamp,
22
+ client_id: config.credentials.appId,
23
+ client_secret_sign: signature,
24
+ grant_type: "client_credentials",
25
+ });
26
+ return new util_http_handler_1.HttpRequest({
27
+ protocol: "https:",
28
+ method: "POST",
29
+ hostname: hostname,
30
+ path: path,
31
+ headers: headers,
32
+ body: body,
33
+ });
34
+ };
35
+ exports.se_CreateAccessTokenCommand = se_CreateAccessTokenCommand;
36
+ const de_CreateAccessTokenCommand = async (response, config) => {
37
+ if (response.statusCode >= 300)
38
+ await (0, constants_js_1.parseErrorBody)(response);
39
+ let data = await (0, constants_js_1.parseBody)(response);
40
+ let contents = {};
41
+ contents = de_CreateAccessTokenResult(data);
42
+ return {
43
+ $metadata: (0, constants_js_1.deserializeMetadata)(response),
44
+ ...contents,
45
+ };
46
+ };
47
+ exports.de_CreateAccessTokenCommand = de_CreateAccessTokenCommand;
48
+ const de_CreateAccessTokenResult = (output) => {
49
+ var _a, _b, _c;
50
+ return {
51
+ access_token: (_a = output.access_token) !== null && _a !== void 0 ? _a : "",
52
+ expires_in: (_b = Number(output.expires_in)) !== null && _b !== void 0 ? _b : 0,
53
+ token_type: (_c = output.token_type) !== null && _c !== void 0 ? _c : "",
54
+ };
55
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.de_GetAccountInfoCommand = exports.se_GetAccountInfoCommand = void 0;
4
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
5
+ const constants_js_1 = require("./constants.js");
6
+ const se_GetAccountInfoCommand = async (input, coifng) => {
7
+ const hostname = "api.commerce.naver.com";
8
+ const path = "/external/v1/seller/account";
9
+ const headers = {
10
+ host: hostname,
11
+ accept: "application/json",
12
+ };
13
+ return new util_http_handler_1.HttpRequest({
14
+ protocol: "https:",
15
+ method: "GET",
16
+ hostname: hostname,
17
+ path: path,
18
+ headers: headers,
19
+ });
20
+ };
21
+ exports.se_GetAccountInfoCommand = se_GetAccountInfoCommand;
22
+ const de_GetAccountInfoCommand = async (response, config) => {
23
+ if (response.statusCode >= 300)
24
+ await (0, constants_js_1.parseErrorBody)(response);
25
+ let data = await (0, constants_js_1.parseBody)(response);
26
+ let contents = {};
27
+ contents = de_GetAccountInfoResult(data);
28
+ return {
29
+ $metadata: (0, constants_js_1.deserializeMetadata)(response),
30
+ ...contents,
31
+ };
32
+ };
33
+ exports.de_GetAccountInfoCommand = de_GetAccountInfoCommand;
34
+ const de_GetAccountInfoResult = (output) => {
35
+ var _a, _b, _c;
36
+ return {
37
+ accountId: (_a = output.accountId) !== null && _a !== void 0 ? _a : "",
38
+ accountUid: (_b = output.accountUid) !== null && _b !== void 0 ? _b : "",
39
+ grade: (_c = output.grade) !== null && _c !== void 0 ? _c : "",
40
+ };
41
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.de_ListChangedOrderStatusesCommand = exports.se_ListChangedOrderStatusesCommand = void 0;
4
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
5
+ const constants_js_1 = require("./constants.js");
6
+ const se_ListChangedOrderStatusesCommand = async (input, config) => {
7
+ const hostname = "api.commerce.naver.com";
8
+ const path = "/external/v1/pay-order/seller/product-orders/last-changed-statuses";
9
+ const headers = {
10
+ host: hostname,
11
+ accept: "application/json",
12
+ };
13
+ const query = Object.entries(input).reduce((acc, [key, value]) => {
14
+ if (value !== undefined && value !== null) {
15
+ acc[key] = String(value); // 숫자(limitCount)나 Enum도 여기서 문자열이 됨
16
+ }
17
+ return acc;
18
+ }, {});
19
+ return new util_http_handler_1.HttpRequest({
20
+ protocol: "https:",
21
+ method: "GET",
22
+ hostname,
23
+ path,
24
+ headers,
25
+ query,
26
+ });
27
+ };
28
+ exports.se_ListChangedOrderStatusesCommand = se_ListChangedOrderStatusesCommand;
29
+ const de_ListChangedOrderStatusesCommand = async (response, config) => {
30
+ if (response.statusCode >= 300)
31
+ await (0, constants_js_1.parseErrorBody)(response);
32
+ const data = await (0, constants_js_1.parseBody)(response);
33
+ const contents = de_ListChangedOrderStatusesResult(data);
34
+ return {
35
+ $metadata: (0, constants_js_1.deserializeMetadata)(response),
36
+ ...contents,
37
+ };
38
+ };
39
+ exports.de_ListChangedOrderStatusesCommand = de_ListChangedOrderStatusesCommand;
40
+ const de_ListChangedOrderStatusesResult = (output) => {
41
+ var _a, _b, _c, _d, _e;
42
+ return {
43
+ timestamp: new Date((_a = output.timestamp) !== null && _a !== void 0 ? _a : new Date().getTime()).toISOString(),
44
+ traceId: (_b = output.traceId) !== null && _b !== void 0 ? _b : "",
45
+ data: {
46
+ count: (_d = (_c = output.data) === null || _c === void 0 ? void 0 : _c.count) !== null && _d !== void 0 ? _d : 0,
47
+ lastChangeStatuses: ((_e = output.data) === null || _e === void 0 ? void 0 : _e.lastChangedStatuses)
48
+ ? de_ChangedOrderStatusList(output.data.lastChangedStatuses)
49
+ : [],
50
+ ...(output.more && { more: de_More(output.more) }),
51
+ },
52
+ };
53
+ };
54
+ const de_ChangedOrderStatusList = (output) => {
55
+ const result = (output || []).filter((e) => e != null).map((entry) => de_ChangedOrderStatus(entry));
56
+ return result;
57
+ };
58
+ const de_ChangedOrderStatus = (output) => {
59
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
60
+ return {
61
+ orderId: (_a = output.orderId) !== null && _a !== void 0 ? _a : "",
62
+ lastChangedDate: output.lastChangedDate ? new Date(output.lastChangedDate).toISOString() : "",
63
+ lastChangedType: (_b = output.lastChangedType) !== null && _b !== void 0 ? _b : "",
64
+ productOrderId: (_c = output.productOrderId) !== null && _c !== void 0 ? _c : "",
65
+ productOrderStatus: (_d = output.productOrderStatus) !== null && _d !== void 0 ? _d : "",
66
+ receiverAddressChanged: (_e = output.receiverAddressChanged) !== null && _e !== void 0 ? _e : false,
67
+ paymentDate: (_f = output.paymentDate) !== null && _f !== void 0 ? _f : "",
68
+ claimType: (_g = output.claimType) !== null && _g !== void 0 ? _g : "",
69
+ claimStatus: (_h = output.claimStatus) !== null && _h !== void 0 ? _h : "",
70
+ giftReceivingStatus: (_j = output.giftReceivingStatus) !== null && _j !== void 0 ? _j : "",
71
+ };
72
+ };
73
+ const de_More = (output) => {
74
+ var _a;
75
+ return {
76
+ moreFrom: output.moreFrom ? new Date(output.moreFrom).toISOString() : "",
77
+ moreSequence: (_a = output.moreSequence) !== null && _a !== void 0 ? _a : "",
78
+ };
79
+ };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseErrorBody = exports.parseBody = exports.deserializeMetadata = void 0;
4
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
5
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
6
+ const index_js_1 = require("../models/index.js");
7
+ const constants_js_1 = require("../middleware/constants.js");
8
+ const deserializeMetadata = (response) => {
9
+ const attempts = response.headers[constants_js_1.INGESTKOREA_RETRY] || undefined;
10
+ const totalRetryDelay = response.headers[constants_js_1.INGESTKOREA_RETRY_DELAY] || undefined;
11
+ const traceId = response.headers[constants_js_1.NAVER_COMMERCE_TRACE_ID] || undefined;
12
+ const rateLimit = response.headers[constants_js_1.NAVER_COMMERCE_RATE_LIMIT] || undefined;
13
+ return {
14
+ httpStatusCode: response.statusCode,
15
+ ...(attempts && { attempts: Number(attempts) }),
16
+ ...(totalRetryDelay && { totalRetryDelay: Number(totalRetryDelay) }),
17
+ ...(traceId && { traceId }),
18
+ ...(rateLimit && { rateLimit: Number(rateLimit) }),
19
+ };
20
+ };
21
+ exports.deserializeMetadata = deserializeMetadata;
22
+ const parseBody = async (output) => {
23
+ const { statusCode, headers, body: streamBody } = output;
24
+ if (!isJsonResponse(headers["content-type"])) {
25
+ await (0, util_http_handler_1.destroyStream)(streamBody);
26
+ throw new util_error_handler_1.IngestkoreaError({
27
+ code: (0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode) ? statusCode : 400,
28
+ type: "Bad Request",
29
+ message: "Invalid Request",
30
+ description: "response content-type is not application/json",
31
+ });
32
+ }
33
+ const data = await (0, util_http_handler_1.collectBodyString)(streamBody);
34
+ if (data.length) {
35
+ try {
36
+ return JSON.parse(data);
37
+ }
38
+ catch (e) {
39
+ await (0, util_http_handler_1.destroyStream)(streamBody);
40
+ throw new util_error_handler_1.IngestkoreaError({
41
+ code: 500,
42
+ type: "Bad Request",
43
+ message: "Invalid Request",
44
+ description: "parse response body error",
45
+ });
46
+ }
47
+ }
48
+ return {};
49
+ };
50
+ exports.parseBody = parseBody;
51
+ const parseErrorBody = async (output) => {
52
+ const { statusCode, headers, body: streamBody } = output;
53
+ if (!isJsonResponse(headers["content-type"])) {
54
+ await (0, util_http_handler_1.destroyStream)(streamBody);
55
+ throw new util_error_handler_1.IngestkoreaError({
56
+ code: (0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode) ? statusCode : 400,
57
+ type: "Bad Request",
58
+ message: "Invalid Request",
59
+ description: "response content-type is not application/json",
60
+ });
61
+ }
62
+ const data = await (0, util_http_handler_1.collectBodyString)(streamBody);
63
+ await (0, util_http_handler_1.destroyStream)(streamBody);
64
+ const commerceError = isCommerceErrorInfo(data);
65
+ if (commerceError) {
66
+ throw new index_js_1.NaverCommerceError(commerceError);
67
+ }
68
+ throw new util_error_handler_1.IngestkoreaError({
69
+ code: (0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode) ? statusCode : 400,
70
+ type: "Bad Request",
71
+ message: "Invalid Request",
72
+ description: "something wrong",
73
+ });
74
+ };
75
+ exports.parseErrorBody = parseErrorBody;
76
+ const commerceErrorInfoSpec = [
77
+ ["code", "string"],
78
+ ["message", "string"],
79
+ ["timestamp", "string"],
80
+ ];
81
+ const isJsonResponse = (contentType) => {
82
+ return /application\/json/gi.exec(contentType || "") ? true : false;
83
+ };
84
+ const isCommerceErrorInfo = (input) => {
85
+ if (input === undefined || input === null || typeof input !== "string")
86
+ return null;
87
+ try {
88
+ const obj = JSON.parse(input);
89
+ for (const [key, expectedType] of commerceErrorInfoSpec) {
90
+ if (!(key in obj) || typeof obj[key] !== expectedType) {
91
+ return null;
92
+ }
93
+ }
94
+ const result = {
95
+ code: obj.code,
96
+ message: obj.message,
97
+ timestamp: obj.timestamp,
98
+ };
99
+ if (typeof obj.traceId === "string") {
100
+ result.traceId = obj.traceId;
101
+ }
102
+ if (Array.isArray(obj.invalidInputs)) {
103
+ const isValidArray = obj.invalidInputs.every((item) => typeof (item === null || item === void 0 ? void 0 : item.name) === "string" && typeof (item === null || item === void 0 ? void 0 : item.type) === "string" && typeof (item === null || item === void 0 ? void 0 : item.message) === "string");
104
+ if (isValidArray) {
105
+ result.invalidInputs = obj.invalidInputs;
106
+ }
107
+ }
108
+ return result;
109
+ }
110
+ catch (_a) {
111
+ return null;
112
+ }
113
+ };
@@ -0,0 +1,8 @@
1
+ import { CommerceClientConfig, CommerceClientResolvedConfig, CommerceCommand } from "./models/index.js";
2
+ export declare class NaverCommerceClient {
3
+ config: CommerceClientResolvedConfig;
4
+ private httpHandler;
5
+ private requestHandler;
6
+ constructor(config: CommerceClientConfig);
7
+ send<T, P>(command: CommerceCommand<T, P, CommerceClientResolvedConfig>): Promise<P>;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { CommerceClientResolvedConfig, CommerceCommand, CreateAccessTokenRequest, CreateAccessTokenResult, MetadataBearer, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ export interface CreateAccessTokenCommandInput extends CreateAccessTokenRequest {
3
+ }
4
+ export interface CreateAccessTokenCommandOutput extends MetadataBearer, CreateAccessTokenResult {
5
+ }
6
+ export declare class CreateAccessTokenCommand extends CommerceCommand<CreateAccessTokenCommandInput, CreateAccessTokenCommandOutput, CommerceClientResolvedConfig> {
7
+ input: CreateAccessTokenCommandInput;
8
+ serializer: RequestSerializer<CreateAccessTokenCommandInput, CommerceClientResolvedConfig>;
9
+ deserializer: ResponseDeserializer<CreateAccessTokenCommandOutput, CommerceClientResolvedConfig>;
10
+ constructor(input: CreateAccessTokenCommandInput);
11
+ }
@@ -0,0 +1,11 @@
1
+ import { CommerceClientResolvedConfig, CommerceCommand, GetAccountInfoRequest, GetAccountInfoResult, MetadataBearer, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ export interface GetAccountInfoCommandInput extends GetAccountInfoRequest {
3
+ }
4
+ export interface GetAccountInfoCommandOutput extends MetadataBearer, GetAccountInfoResult {
5
+ }
6
+ export declare class GetAccountInfoCommand extends CommerceCommand<GetAccountInfoCommandInput, GetAccountInfoCommandOutput, CommerceClientResolvedConfig> {
7
+ input: GetAccountInfoCommandInput;
8
+ serializer: RequestSerializer<GetAccountInfoCommandInput, CommerceClientResolvedConfig>;
9
+ deserializer: ResponseDeserializer<GetAccountInfoCommandOutput, CommerceClientResolvedConfig>;
10
+ constructor(input: GetAccountInfoCommandInput);
11
+ }
@@ -0,0 +1,11 @@
1
+ import { CommerceClientResolvedConfig, CommerceCommand, ListChangedOrderStatusesRequest, ListChangedOrderStatusesResult, MetadataBearer, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ export interface ListChangedOrderStatusesCommandInput extends ListChangedOrderStatusesRequest {
3
+ }
4
+ export interface ListChangedOrderStatusesCommandOutput extends MetadataBearer, ListChangedOrderStatusesResult {
5
+ }
6
+ export declare class ListChangedOrderStatusesCommand extends CommerceCommand<ListChangedOrderStatusesCommandInput, ListChangedOrderStatusesCommandOutput, CommerceClientResolvedConfig> {
7
+ input: ListChangedOrderStatusesCommandInput;
8
+ serializer: RequestSerializer<ListChangedOrderStatusesCommandInput, CommerceClientResolvedConfig>;
9
+ deserializer: ResponseDeserializer<ListChangedOrderStatusesCommandOutput, CommerceClientResolvedConfig>;
10
+ constructor(input: ListChangedOrderStatusesCommandInput);
11
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./CreateAccessTokenCommand.js";
2
+ export * from "./GetAccountInfoCommand.js";
3
+ export * from "./ListChangedOrderStatusesCommand.js";
@@ -0,0 +1,2 @@
1
+ export * from "./NaverCommerceClient.js";
2
+ export * from "./commands/index.js";
@@ -0,0 +1,6 @@
1
+ export declare const INGESTKOREA_USER_AGENT = "x-ingestkorea-user-agent";
2
+ export declare const INGESTKOREA_REQUEST_LOG = "x-ingestkorea-request";
3
+ export declare const INGESTKOREA_RETRY = "x-ingestkorea-attempts";
4
+ export declare const INGESTKOREA_RETRY_DELAY = "x-ingestkorea-total-retry-delay";
5
+ export declare const NAVER_COMMERCE_TRACE_ID = "gncp-gw-trace-id";
6
+ export declare const NAVER_COMMERCE_RATE_LIMIT = "gncp-gw-ratelimit-remaining";
@@ -0,0 +1,3 @@
1
+ export * from "./middleware-auth.js";
2
+ export * from "./middleware-metadata.js";
3
+ export * from "./middleware-retry.js";
@@ -0,0 +1,2 @@
1
+ import { Middleware } from "../models/index.js";
2
+ export declare const middlewareAuth: Middleware;
@@ -0,0 +1,2 @@
1
+ import { Middleware } from "../models/index.js";
2
+ export declare const middlewareIngestkoreaMetadata: Middleware;
@@ -0,0 +1,2 @@
1
+ import { Middleware } from "../models/index.js";
2
+ export declare const middlewareRetry: Middleware;
@@ -0,0 +1,13 @@
1
+ export type AppCredentials = {
2
+ appId: string;
3
+ appSecret: string;
4
+ };
5
+ export type APICredentials = {
6
+ accessToken: string;
7
+ };
8
+ export interface CommerceClientConfig {
9
+ credentials?: Partial<AppCredentials> & Partial<APICredentials>;
10
+ }
11
+ export interface CommerceClientResolvedConfig {
12
+ credentials: AppCredentials & APICredentials;
13
+ }
@@ -0,0 +1,9 @@
1
+ import { HttpRequest, HttpResponse } from "@ingestkorea/util-http-handler";
2
+ export type RequestSerializer<InputType, Config> = (input: InputType, config: Config) => Promise<HttpRequest>;
3
+ export type ResponseDeserializer<OutputType, Config> = (response: HttpResponse, config: Config) => Promise<OutputType>;
4
+ export declare abstract class CommerceCommand<ClientInput, ClientOutput, ClientResolvedConfig> {
5
+ input: ClientInput;
6
+ constructor(input: ClientInput);
7
+ abstract serializer: RequestSerializer<ClientInput, ClientResolvedConfig>;
8
+ abstract deserializer: ResponseDeserializer<ClientOutput, ClientResolvedConfig>;
9
+ }
@@ -0,0 +1,19 @@
1
+ export interface CommerceErrorInfo {
2
+ code: string;
3
+ message: string;
4
+ timestamp: string;
5
+ traceId?: string;
6
+ invalidInputs?: InvalidInputs[];
7
+ }
8
+ export type InvalidInputs = {
9
+ name: string;
10
+ type: string;
11
+ message: string;
12
+ };
13
+ export declare class NaverCommerceError extends Error {
14
+ readonly code: string;
15
+ readonly timestamp: string;
16
+ readonly traceId: string;
17
+ readonly invalidInputs: InvalidInputs[];
18
+ constructor(info: CommerceErrorInfo);
19
+ }
@@ -0,0 +1,8 @@
1
+ import { HttpRequest, HttpResponse } from "@ingestkorea/util-http-handler";
2
+ import { CommerceClientResolvedConfig } from "./CommerceClient.js";
3
+ export type Middleware = (next: Handler) => Handler;
4
+ export type Handler = (input: {
5
+ request: HttpRequest;
6
+ }, context: CommerceClientResolvedConfig) => Promise<{
7
+ response: HttpResponse;
8
+ }>;
@@ -0,0 +1,7 @@
1
+ export interface CreateAccessTokenRequest {
2
+ }
3
+ export interface CreateAccessTokenResult {
4
+ access_token: string;
5
+ expires_in: number;
6
+ token_type: string;
7
+ }
@@ -0,0 +1,7 @@
1
+ export interface GetAccountInfoRequest {
2
+ }
3
+ export interface GetAccountInfoResult {
4
+ accountId: string;
5
+ accountUid: string;
6
+ grade: string;
7
+ }
@@ -0,0 +1,68 @@
1
+ export interface ListChangedOrderStatusesRequest {
2
+ lastChangedFrom: string;
3
+ lastChangedTo?: string;
4
+ lastChangedType?: LastChangedType;
5
+ moreSequence?: string;
6
+ limitCount?: number;
7
+ }
8
+ export interface ListChangedOrderStatusesResult {
9
+ timestamp: string;
10
+ traceId: string;
11
+ data: {
12
+ count: number;
13
+ lastChangeStatuses: ChangedOrderStatus[];
14
+ more?: More;
15
+ };
16
+ }
17
+ export type ChangedOrderStatus = {
18
+ orderId: string;
19
+ lastChangedDate: string;
20
+ lastChangedType: LastChangedType;
21
+ productOrderId: string;
22
+ productOrderStatus: ProductOrderStatusType;
23
+ receiverAddressChanged: boolean;
24
+ paymentDate: string;
25
+ claimType: ClaimType;
26
+ claimStatus: string;
27
+ giftReceivingStatus: string;
28
+ };
29
+ export type More = {
30
+ moreFrom: string;
31
+ moreSequence: string;
32
+ };
33
+ export declare const LAST_CHANGED_TYPE: {
34
+ readonly PAY_WAITING: "PAY_WAITING";
35
+ readonly PAYED: "PAYED";
36
+ readonly EXCHANGE_OPTION: "EXCHANGE_OPTION";
37
+ readonly DELIVERY_ADDRESS_CHANGED: "DELIVERY_ADDRESS_CHANGED";
38
+ readonly GIFT_RECEIVED: "GIFT_RECEIVED";
39
+ readonly CLAIM_REJECTED: "CLAIM_REJECTED";
40
+ readonly DISPATCHED: "DISPATCHED";
41
+ readonly CLAIM_REQUESTED: "CLAIM_REQUESTED";
42
+ readonly COLLECT_DONE: "COLLECT_DONE";
43
+ readonly CLAIM_COMPLETED: "CLAIM_COMPLETED";
44
+ readonly PURCHASE_DECIDED: "PURCHASE_DECIDED";
45
+ readonly HOPE_DELIVERY_INFO_CHANGED: "HOPE_DELIVERY_INFO_CHANGED";
46
+ readonly CLAIM_REDELIVERING: "CLAIM_REDELIVERING";
47
+ };
48
+ export declare const PRODUCT_ORDER_STATUS_TYPE: {
49
+ readonly PAYMENT_WAITING: "PAYMENT_WAITING";
50
+ readonly PAYED: "PAYED";
51
+ readonly DELIVERING: "DELIVERING";
52
+ readonly DELIVERED: "DELIVERED";
53
+ readonly PURCHASE_DECIDED: "PURCHASE_DECIDED";
54
+ readonly EXCHANGED: "EXCHANGED";
55
+ readonly CANCELED: "CANCELED";
56
+ readonly RETURNED: "RETURNED";
57
+ readonly CANCELED_BY_NOPAYMENT: "CANCELED_BY_NOPAYMENT";
58
+ };
59
+ export declare const CLAIM_TYPE: {
60
+ readonly CANCEL: "CANCEL";
61
+ readonly RETURN: "RETURN";
62
+ readonly EXCHANGE: "EXCHANGE";
63
+ readonly PURCHASE_DECISION_HOLDBACK: "PURCHASE_DECISION_HOLDBACK";
64
+ readonly ADMIN_CANCEL: "ADMIN_CANCEL";
65
+ };
66
+ export type LastChangedType = (typeof LAST_CHANGED_TYPE)[keyof typeof LAST_CHANGED_TYPE];
67
+ export type ProductOrderStatusType = (typeof PRODUCT_ORDER_STATUS_TYPE)[keyof typeof PRODUCT_ORDER_STATUS_TYPE];
68
+ export type ClaimType = (typeof CLAIM_TYPE)[keyof typeof CLAIM_TYPE];
@@ -0,0 +1,10 @@
1
+ export interface MetadataBearer {
2
+ $metadata: ResponseMetadata;
3
+ }
4
+ export interface ResponseMetadata {
5
+ httpStatusCode?: number;
6
+ attempts?: number;
7
+ totalRetryDelay?: number;
8
+ traceId?: string;
9
+ rateLimit?: number;
10
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./CommerceClient.js";
2
+ export * from "./CommerceCommand.js";
3
+ export * from "./CommerceErrorInfo.js";
4
+ export * from "./CommerceMiddleware.js";
5
+ export * from "./CreateAccessToken.js";
6
+ export * from "./GetAccountInfo.js";
7
+ export * from "./ListChangedOrderStatuses.js";
8
+ export * from "./MetadataBearer.js";
@@ -0,0 +1,4 @@
1
+ import { CommerceClientResolvedConfig, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ import { CreateAccessTokenCommandInput, CreateAccessTokenCommandOutput } from "../commands/CreateAccessTokenCommand.js";
3
+ export declare const se_CreateAccessTokenCommand: RequestSerializer<CreateAccessTokenCommandInput, CommerceClientResolvedConfig>;
4
+ export declare const de_CreateAccessTokenCommand: ResponseDeserializer<CreateAccessTokenCommandOutput, CommerceClientResolvedConfig>;
@@ -0,0 +1,4 @@
1
+ import { CommerceClientResolvedConfig, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ import { GetAccountInfoCommandInput, GetAccountInfoCommandOutput } from "../commands/GetAccountInfoCommand.js";
3
+ export declare const se_GetAccountInfoCommand: RequestSerializer<GetAccountInfoCommandInput, CommerceClientResolvedConfig>;
4
+ export declare const de_GetAccountInfoCommand: ResponseDeserializer<GetAccountInfoCommandOutput, CommerceClientResolvedConfig>;
@@ -0,0 +1,4 @@
1
+ import { CommerceClientResolvedConfig, RequestSerializer, ResponseDeserializer } from "../models/index.js";
2
+ import { ListChangedOrderStatusesCommandInput, ListChangedOrderStatusesCommandOutput } from "../commands/ListChangedOrderStatusesCommand.js";
3
+ export declare const se_ListChangedOrderStatusesCommand: RequestSerializer<ListChangedOrderStatusesCommandInput, CommerceClientResolvedConfig>;
4
+ export declare const de_ListChangedOrderStatusesCommand: ResponseDeserializer<ListChangedOrderStatusesCommandOutput, CommerceClientResolvedConfig>;
@@ -0,0 +1,5 @@
1
+ import { HttpResponse } from "@ingestkorea/util-http-handler";
2
+ import { ResponseMetadata } from "../models/index.js";
3
+ export declare const deserializeMetadata: (response: HttpResponse) => ResponseMetadata;
4
+ export declare const parseBody: (output: HttpResponse) => Promise<any>;
5
+ export declare const parseErrorBody: (output: HttpResponse) => Promise<void>;