maplestory-openapi 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/maplestory-openapi)](https://www.npmjs.com/package/maplestory-openapi)
4
4
 
5
- This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.
5
+ This JavaScript library enables the use of the MapleStory OpenAPI of Nexon.
6
6
 
7
7
  Packages written in other languages can be found [HERE](https://github.com/SpiralMoon/maplestory.openapi).
8
8
 
@@ -13,11 +13,15 @@ Packages written in other languages can be found [HERE](https://github.com/Spira
13
13
  Install the latest version of the JavaScript/TypeScript library in your npm project:
14
14
 
15
15
  ```bash
16
- npm install maplestory-openapi@1.1.0 # Replace with the latest version
16
+ npm install maplestory-openapi@2.0.0 # Replace with the latest version
17
17
  ```
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### API Key
22
+
23
+ Before using the library, register your application and obtain an **api key** from the [Nexon Open API Console](https://openapi.nexon.com/my-application/).
24
+
21
25
  ### Supports
22
26
 
23
27
  1. **CommonJS, ESM Support**: The library supports both CommonJS and ESM usage.
@@ -45,7 +49,7 @@ api.getCubeResult(1000, {
45
49
  day: 15
46
50
  })
47
51
  .then((dto) => {
48
- const {count, cubeHistories, nextCursor} = dto;
52
+ const {count, cubeHistory, nextCursor} = dto;
49
53
 
50
54
  console.log('You used ' + count + ' cubes.');
51
55
  })
@@ -62,17 +66,18 @@ api.getCubeResult(1000, {
62
66
 
63
67
  ### Exception Handling
64
68
 
65
- Handle `MapleStoryApiError` to safely make calls, ensuring that specific Status defined in the [MapleStory OpenAPI Guide](https://developers.nexon.com/Maplestory/guides) are not encountered.
69
+ Handle `MapleStoryApiError` to safely make calls, ensuring that specific Status defined in the [MapleStory OpenAPI Guide](https://openapi.nexon.com/guide/request-api) are not encountered.
66
70
 
67
71
  While `MapleStoryApi` is designed to prevent the occurrence of certain Status, exceptions may arise due to developer mistakes.
68
72
 
69
- Therefore, it's recommended to use `MapleStoryApiError` for exception handling based on the Status list described in the table below.
70
-
71
- | Status | Message |
72
- |--------|---------------------------------------------------------|
73
- | 400 | Request format error (incorrect parameter input) |
74
- | 401 | Unauthorized service (unsupported service, service type) |
75
- | 403 | Unauthorized AccessToken usage |
76
- | 429 | AccessToken's request allowance (Rate Limit) exceeded |
77
- | 500 | Internal server error |
78
- | 504 | Internal server processing timeout |
73
+ Therefore, it's recommended to use `MapleStoryApiError` for exception handling based on the `MapleStoryApiErrorCode` list described in the table below.
74
+
75
+ | ErrorCode | Description |
76
+ |--------------|-------------------------------------------------|
77
+ | OPENAPI00001 | Internal server error |
78
+ | OPENAPI00002 | Access denied |
79
+ | OPENAPI00003 | Invalid identifier |
80
+ | OPENAPI00004 | Request format error (incorrect parameter input) |
81
+ | OPENAPI00005 | Invalid api key |
82
+ | OPENAPI00006 | Invalid api path |
83
+ | OPENAPI00007 | Request allowance (Rate Limit) exceeded |
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ const potentialOptionGradeFromString = (text) => {
41
41
  */
42
42
  class CubeResultOptionDto {
43
43
  /**
44
- * 옵션 이름
44
+ * 옵션
45
45
  */
46
46
  value;
47
47
  /**
@@ -59,31 +59,31 @@ class CubeResultOptionDto {
59
59
  }
60
60
 
61
61
  /**
62
- * 큐브히스토리 정보
62
+ * 큐브 히스토리
63
63
  */
64
64
  class CubeHistoryDto {
65
65
  /**
66
- * 큐브 사용 내역에 대한 고유 식별자
66
+ * 큐브 히스토리 식별자
67
67
  */
68
68
  id;
69
69
  /**
70
- * 캐릭터이름
70
+ * 캐릭터 명
71
71
  */
72
72
  characterName;
73
73
  /**
74
- * 월드 이름
74
+ * 월드
75
75
  */
76
76
  worldName;
77
77
  /**
78
- * 큐브 사용 날짜
78
+ * 사용 일시
79
79
  */
80
- createDate;
80
+ dateCreate;
81
81
  /**
82
- * 사용한 큐브
82
+ * 사용 큐브
83
83
  */
84
84
  cubeType;
85
85
  /**
86
- * 큐브 사용 결과
86
+ * 사용 결과
87
87
  */
88
88
  itemUpgradeResult;
89
89
  /**
@@ -93,13 +93,13 @@ class CubeHistoryDto {
93
93
  /**
94
94
  * 장비 분류
95
95
  */
96
- itemEquipPart;
96
+ itemEquipmentPart;
97
97
  /**
98
98
  * 장비 레벨
99
99
  */
100
100
  itemLevel;
101
101
  /**
102
- * 큐브를 사용한 장비
102
+ * 큐브 사용한 장비
103
103
  */
104
104
  targetItem;
105
105
  /**
@@ -119,41 +119,41 @@ class CubeHistoryDto {
119
119
  */
120
120
  upgradeGuaranteeCount;
121
121
  /**
122
- * 큐브 사용 전 잠재능력 옵션
122
+ * 사용 전 잠재능력 옵션
123
123
  */
124
- beforePotentialOptions;
124
+ beforePotentialOption;
125
125
  /**
126
- * 큐브 사용 전 에디셔널 잠재능력 옵션
126
+ * 사용 전 에디셔널 잠재능력 옵션
127
127
  */
128
- beforeAdditionalPotentialOptions;
128
+ beforeAdditionalPotentialOption;
129
129
  /**
130
- * 큐브 사용 후 잠재능력 옵션
130
+ * 사용 후 잠재능력 옵션
131
131
  */
132
- afterPotentialOptions;
132
+ afterPotentialOption;
133
133
  /**
134
- * 큐브 사용 후 에디셔널 잠재능력 옵션
134
+ * 사용 후 에디셔널 잠재능력 옵션
135
135
  */
136
- afterAdditionalPotentialOptions;
136
+ afterAdditionalPotentialOption;
137
137
  constructor(obj) {
138
- const { id, character_name, world_name, create_date, cube_type, item_upgrade_result, miracle_time_flag, item_equip_part, item_level, target_item, potential_option_grade, additional_potential_option_grade, upgradeguarantee, upgradeguaranteecount, before_potential_options, before_additional_potential_options, after_potential_options, after_additional_potential_options } = obj;
138
+ const { id, character_name, world_name, date_create, cube_type, item_upgrade_result, miracle_time_flag, item_equipment_part, item_level, target_item, potential_option_grade, additional_potential_option_grade, upgrade_guarantee, upgrade_guarantee_count, before_potential_option, before_additional_potential_option, after_potential_option, after_additional_potential_option } = obj;
139
139
  this.id = id;
140
140
  this.characterName = character_name;
141
141
  this.worldName = world_name;
142
- this.createDate = create_date;
142
+ this.dateCreate = new Date(date_create);
143
143
  this.cubeType = cube_type;
144
144
  this.itemUpgradeResult = item_upgrade_result;
145
145
  this.miracleTimeFlag = miracle_time_flag;
146
- this.itemEquipPart = item_equip_part;
146
+ this.itemEquipmentPart = item_equipment_part;
147
147
  this.itemLevel = item_level;
148
148
  this.targetItem = target_item;
149
149
  this.potentialOptionGrade = potential_option_grade;
150
150
  this.additionalPotentialOptionGrade = additional_potential_option_grade;
151
- this.upgradeGuarantee = upgradeguarantee;
152
- this.upgradeGuaranteeCount = upgradeguaranteecount;
153
- this.beforePotentialOptions = before_potential_options.map(origin => new CubeResultOptionDto(origin));
154
- this.beforeAdditionalPotentialOptions = before_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
155
- this.afterPotentialOptions = after_potential_options.map(origin => new CubeResultOptionDto(origin));
156
- this.afterAdditionalPotentialOptions = after_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
151
+ this.upgradeGuarantee = upgrade_guarantee;
152
+ this.upgradeGuaranteeCount = upgrade_guarantee_count;
153
+ this.beforePotentialOption = before_potential_option.map(origin => new CubeResultOptionDto(origin));
154
+ this.beforeAdditionalPotentialOption = before_additional_potential_option.map(origin => new CubeResultOptionDto(origin));
155
+ this.afterPotentialOption = after_potential_option.map(origin => new CubeResultOptionDto(origin));
156
+ this.afterAdditionalPotentialOption = after_additional_potential_option.map(origin => new CubeResultOptionDto(origin));
157
157
  }
158
158
  get isItemUpgrade() {
159
159
  return this.itemUpgradeResult === '성공';
@@ -170,7 +170,7 @@ class CubeHistoryDto {
170
170
  }
171
171
 
172
172
  /**
173
- * 큐브히스토리 응답 정보
173
+ * 큐브 히스토리 응답 정보
174
174
  */
175
175
  class CubeHistoryResponseDto {
176
176
  /**
@@ -180,15 +180,15 @@ class CubeHistoryResponseDto {
180
180
  /**
181
181
  * 큐브 히스토리
182
182
  */
183
- cubeHistories;
183
+ cubeHistory;
184
184
  /**
185
185
  * 페이징 처리를 위한 cursor
186
186
  */
187
187
  nextCursor;
188
188
  constructor(obj) {
189
- const { count, cube_histories, next_cursor } = obj;
189
+ const { count, cube_history, next_cursor } = obj;
190
190
  this.count = count;
191
- this.cubeHistories = cube_histories.map(origin => new CubeHistoryDto(origin));
191
+ this.cubeHistory = cube_history.map(origin => new CubeHistoryDto(origin));
192
192
  this.nextCursor = next_cursor;
193
193
  }
194
194
  }
@@ -224,19 +224,42 @@ class InspectionInfoDto {
224
224
 
225
225
  /**
226
226
  * MapleStory OpenAPI error.<br>
227
- * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
227
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error details.
228
228
  */
229
229
  class MapleStoryApiError extends Error {
230
230
  name = 'MapleStoryApiError';
231
- status;
231
+ errorCode;
232
232
  message;
233
- constructor(params) {
234
- const { status, message } = params;
233
+ constructor(errorBody) {
234
+ const { name, message } = errorBody.error;
235
235
  super(message);
236
- this.status = status;
236
+ this.errorCode = errorMap[name];
237
237
  this.message = message;
238
238
  }
239
239
  }
240
+ /**
241
+ * MapleStory OpenAPI error codes.<br>
242
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error code details.
243
+ */
244
+ exports.MapleStoryApiErrorCode = void 0;
245
+ (function (MapleStoryApiErrorCode) {
246
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00001"] = 0] = "OPENAPI00001";
247
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00002"] = 1] = "OPENAPI00002";
248
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00003"] = 2] = "OPENAPI00003";
249
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00004"] = 3] = "OPENAPI00004";
250
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00005"] = 4] = "OPENAPI00005";
251
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00006"] = 5] = "OPENAPI00006";
252
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00007"] = 6] = "OPENAPI00007";
253
+ })(exports.MapleStoryApiErrorCode || (exports.MapleStoryApiErrorCode = {}));
254
+ const errorMap = {
255
+ ['OPENAPI00001']: exports.MapleStoryApiErrorCode.OPENAPI00001,
256
+ ['OPENAPI00002']: exports.MapleStoryApiErrorCode.OPENAPI00002,
257
+ ['OPENAPI00003']: exports.MapleStoryApiErrorCode.OPENAPI00003,
258
+ ['OPENAPI00004']: exports.MapleStoryApiErrorCode.OPENAPI00004,
259
+ ['OPENAPI00005']: exports.MapleStoryApiErrorCode.OPENAPI00005,
260
+ ['OPENAPI00006']: exports.MapleStoryApiErrorCode.OPENAPI00006,
261
+ ['OPENAPI00007']: exports.MapleStoryApiErrorCode.OPENAPI00007,
262
+ };
240
263
 
241
264
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
242
265
 
@@ -258,9 +281,13 @@ var utc = utc$1.exports;
258
281
 
259
282
  dayjs__default["default"].extend(timezone);
260
283
  dayjs__default["default"].extend(utc);
284
+ /**
285
+ * MapleStory OpenAPI client.<br>
286
+ * This is an implementation of <a href="https://openapi.nexon.com/game/maplestory">MapleStory API</a>
287
+ */
261
288
  class MapleStoryApi {
262
289
  apiKey;
263
- static baseUrl = 'https://public.api.nexon.com/';
290
+ static BASE_URL = 'https://open.api.nexon.com/';
264
291
  static kstOffset = 540;
265
292
  timeout;
266
293
  constructor(apiKey) {
@@ -280,16 +307,16 @@ class MapleStoryApi {
280
307
  throw new Error('You can only retrieve data after 2022-11-25.');
281
308
  }
282
309
  const date = dayjs__default["default"](`${year}-${month}-${day}`).utcOffset(MapleStoryApi.kstOffset);
283
- query.date = date.format('YYYY-MM-DD');
310
+ query.date_kst = date.format('YYYYMMDD');
284
311
  }
285
312
  else {
286
313
  const now = dayjs__default["default"]().utcOffset(MapleStoryApi.kstOffset);
287
- query.date = now.format('YYYY-MM-DD');
314
+ query.date_kst = now.format('YYYYMMDD');
288
315
  }
289
316
  try {
290
- const path = 'openapi/maplestory/v1/cube-use-results';
317
+ const path = 'maplestory/v1/history/cube';
291
318
  const response = await axios__default["default"].get(path, {
292
- baseURL: MapleStoryApi.baseUrl,
319
+ baseURL: MapleStoryApi.BASE_URL,
293
320
  timeout: this.timeout,
294
321
  headers: this.buildHeaders(),
295
322
  params: query
@@ -342,7 +369,7 @@ class MapleStoryApi {
342
369
  }
343
370
  buildHeaders() {
344
371
  return {
345
- 'authorization': this.apiKey
372
+ 'x-nxopen-api-key': this.apiKey
346
373
  };
347
374
  }
348
375
  }
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("dayjs"),require("xml2js")):"function"==typeof define&&define.amd?define(["exports","axios","dayjs","xml2js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["maplestory-openapi"]={},t.axios,t.dayjs,t.xml2js)}(this,(function(t,e,i,a){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n,s=o(e),r=o(i),u=o(a);t.PotentialOptionGrade=void 0,(n=t.PotentialOptionGrade||(t.PotentialOptionGrade={}))[n.RARE=0]="RARE",n[n.EPIC=1]="EPIC",n[n.UNIQUE=2]="UNIQUE",n[n.LEGENDARY=3]="LEGENDARY";const l=e=>{const i={"레어":t.PotentialOptionGrade.RARE,"에픽":t.PotentialOptionGrade.EPIC,"유니크":t.PotentialOptionGrade.UNIQUE,"레전드리":t.PotentialOptionGrade.LEGENDARY}[e];if(!i)throw new TypeError("No enum constant for string: "+e);return i};class f{value;grade;constructor(t){const{value:e,grade:i}=t;this.value=e,this.grade=i}get gradeEnum(){return l(this.grade)}}class c{id;characterName;worldName;createDate;cubeType;itemUpgradeResult;miracleTimeFlag;itemEquipPart;itemLevel;targetItem;potentialOptionGrade;additionalPotentialOptionGrade;upgradeGuarantee;upgradeGuaranteeCount;beforePotentialOptions;beforeAdditionalPotentialOptions;afterPotentialOptions;afterAdditionalPotentialOptions;constructor(t){const{id:e,character_name:i,world_name:a,create_date:o,cube_type:n,item_upgrade_result:s,miracle_time_flag:r,item_equip_part:u,item_level:l,target_item:c,potential_option_grade:d,additional_potential_option_grade:p,upgradeguarantee:h,upgradeguaranteecount:m,before_potential_options:g,before_additional_potential_options:v,after_potential_options:$,after_additional_potential_options:O}=t;this.id=e,this.characterName=i,this.worldName=a,this.createDate=o,this.cubeType=n,this.itemUpgradeResult=s,this.miracleTimeFlag=r,this.itemEquipPart=u,this.itemLevel=l,this.targetItem=c,this.potentialOptionGrade=d,this.additionalPotentialOptionGrade=p,this.upgradeGuarantee=h,this.upgradeGuaranteeCount=m,this.beforePotentialOptions=g.map((t=>new f(t))),this.beforeAdditionalPotentialOptions=v.map((t=>new f(t))),this.afterPotentialOptions=$.map((t=>new f(t))),this.afterAdditionalPotentialOptions=O.map((t=>new f(t)))}get isItemUpgrade(){return"성공"===this.itemUpgradeResult}get isMiracleTimeFlag(){return"이벤트 적용되지 않음"!==this.miracleTimeFlag}get potentialOptionGradeEnum(){return l(this.potentialOptionGrade)}get additionalPotentialOptionGradeEnum(){return l(this.additionalPotentialOptionGrade)}}class d{count;cubeHistories;nextCursor;constructor(t){const{count:e,cube_histories:i,next_cursor:a}=t;this.count=e,this.cubeHistories=i.map((t=>new c(t))),this.nextCursor=a}}class p{serviceCode;startDateTime;endDateTime;strObstacleContents;constructor(t){const e=t["soap:Envelope"]["soap:Body"][0].GetInspectionInfoResponse[0].GetInspectionInfoResult[0]["diffgr:diffgram"][0].NewDataSet[0].InspectionInfo[0];this.serviceCode=Number(e.serviceCode[0]),this.startDateTime=new Date(e.startDateTime[0]),this.endDateTime=new Date(e.endDateTime[0]),this.strObstacleContents=e.strObstacleContents[0]}}class h extends Error{name="MapleStoryApiError";status;message;constructor(t){const{status:e,message:i}=t;super(i),this.status=e,this.message=i}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var m={exports:{}};!function(t,e){var i,a;t.exports=(i={year:0,month:1,day:2,hour:3,minute:4,second:5},a={},function(t,e,o){var n,s=function(t,e,i){void 0===i&&(i={});var o=new Date(t),n=function(t,e){void 0===e&&(e={});var i=e.timeZoneName||"short",o=t+"|"+i,n=a[o];return n||(n=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),a[o]=n),n}(e,i);return n.formatToParts(o)},r=function(t,e){for(var a=s(t,e),n=[],r=0;r<a.length;r+=1){var u=a[r],l=u.type,f=u.value,c=i[l];c>=0&&(n[c]=parseInt(f,10))}var d=n[3],p=24===d?0:d,h=n[0]+"-"+n[1]+"-"+n[2]+" "+p+":"+n[4]+":"+n[5]+":000",m=+t;return(o.utc(h).valueOf()-(m-=m%1e3))/6e4},u=e.prototype;u.tz=function(t,e){void 0===t&&(t=n);var i=this.utcOffset(),a=this.toDate(),s=a.toLocaleString("en-US",{timeZone:t}),r=Math.round((a-new Date(s))/1e3/60),u=o(s,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-r,!0);if(e){var l=u.utcOffset();u=u.add(i-l,"minute")}return u.$x.$timezone=t,u},u.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),i=s(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return i&&i.value};var l=u.startOf;u.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return l.call(this,t,e);var i=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return l.call(i,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,i){var a=i&&e,s=i||e||n,u=r(+o(),s);if("string"!=typeof t)return o(t).tz(s);var l=function(t,e,i){var a=t-60*e*1e3,o=r(a,i);if(e===o)return[a,e];var n=r(a-=60*(o-e)*1e3,i);return o===n?[a,o]:[t-60*Math.min(o,n)*1e3,Math.max(o,n)]}(o.utc(t,a).valueOf(),u,s),f=l[0],c=l[1],d=o(f).utcOffset(c);return d.$x.$timezone=s,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){n=t}})}(m);var g=m.exports,v={exports:{}};!function(t,e){var i,a,o;t.exports=(i="minute",a=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g,function(t,e,n){var s=e.prototype;n.utc=function(t){return new e({date:t,utc:!0,args:arguments})},s.utc=function(t){var e=n(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),i):e},s.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var u=s.init;s.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var l=s.utcOffset;s.utcOffset=function(t,e){var n=this.$utils().u;if(n(t))return this.$u?0:n(this.$offset)?l.call(this):this.$offset;if("string"==typeof t&&(t=function(t){void 0===t&&(t="");var e=t.match(a);if(!e)return null;var i=(""+e[0]).match(o)||["-",0,0],n=i[0],s=60*+i[1]+ +i[2];return 0===s?0:"+"===n?s:-s}(t),null===t))return this;var s=Math.abs(t)<=16?60*t:t,r=this;if(e)return r.$offset=s,r.$u=0===t,r;if(0!==t){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(r=this.local().add(s+u,i)).$offset=s,r.$x.$localOffset=u}else r=this.utc();return r};var f=s.format;s.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var c=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():c.call(this)};var d=s.diff;s.diff=function(t,e,i){if(t&&this.$u===t.$u)return d.call(this,t,e,i);var a=this.local(),o=n(t).local();return d.call(a,o,e,i)}})}(v);var $=v.exports;r.default.extend(g),r.default.extend($);class O{apiKey;static baseUrl="https://public.api.nexon.com/";static kstOffset=540;timeout;constructor(t){this.apiKey=t,this.timeout=5e3}async getCubeResult(t,i){const a={count:t};if("string"==typeof i)a.cursor=i;else if("object"==typeof i){const{year:t,month:e,day:o}=i;if(t<=2022&&e<=11&&o<25)throw new Error("You can only retrieve data after 2022-11-25.");const n=r.default(`${t}-${e}-${o}`).utcOffset(O.kstOffset);a.date=n.format("YYYY-MM-DD")}else{const t=r.default().utcOffset(O.kstOffset);a.date=t.format("YYYY-MM-DD")}try{const t="openapi/maplestory/v1/cube-use-results",e=await s.default.get(t,{baseURL:O.baseUrl,timeout:this.timeout,headers:this.buildHeaders(),params:a});return new d(e.data)}catch(t){if(t instanceof e.AxiosError){const e=t.response.data;throw new h(e)}throw t}}async getInspectionInfo(){const t=(new u.default.Builder).buildObject({"soap:Envelope":{$:{"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:xsd":"http://www.w3.org/2001/XMLSchema","xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"},"soap:Body":{GetInspectionInfo:{$:{xmlns:"https://api.maplestory.nexon.com/soap/"}}}}}),e=await s.default.post("soap/maplestory.asmx",t,{baseURL:"https://api.maplestory.nexon.com/",timeout:this.timeout,headers:{SOAPAction:"https://api.maplestory.nexon.com/soap/GetInspectionInfo","Content-Type":"text/xml; charset=utf-8"}}),i=await u.default.parseStringPromise(e.data);return new p(i)}buildHeaders(){return{authorization:this.apiKey}}}t.CubeHistoryDto=c,t.CubeHistoryResponseDto=d,t.CubeResultOptionDto=f,t.InspectionInfoDto=p,t.MapleStoryApi=O,t.MapleStoryApiError=h,t.potentialOptionGradeFromString=l}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("dayjs"),require("xml2js")):"function"==typeof define&&define.amd?define(["exports","axios","dayjs","xml2js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["maplestory-openapi"]={},t.axios,t.dayjs,t.xml2js)}(this,(function(t,e,i,o){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r,n=a(e),s=a(i),u=a(o);t.PotentialOptionGrade=void 0,(r=t.PotentialOptionGrade||(t.PotentialOptionGrade={}))[r.RARE=0]="RARE",r[r.EPIC=1]="EPIC",r[r.UNIQUE=2]="UNIQUE",r[r.LEGENDARY=3]="LEGENDARY";const l=e=>{const i={"레어":t.PotentialOptionGrade.RARE,"에픽":t.PotentialOptionGrade.EPIC,"유니크":t.PotentialOptionGrade.UNIQUE,"레전드리":t.PotentialOptionGrade.LEGENDARY}[e];if(!i)throw new TypeError("No enum constant for string: "+e);return i};class f{value;grade;constructor(t){const{value:e,grade:i}=t;this.value=e,this.grade=i}get gradeEnum(){return l(this.grade)}}class d{id;characterName;worldName;dateCreate;cubeType;itemUpgradeResult;miracleTimeFlag;itemEquipmentPart;itemLevel;targetItem;potentialOptionGrade;additionalPotentialOptionGrade;upgradeGuarantee;upgradeGuaranteeCount;beforePotentialOption;beforeAdditionalPotentialOption;afterPotentialOption;afterAdditionalPotentialOption;constructor(t){const{id:e,character_name:i,world_name:o,date_create:a,cube_type:r,item_upgrade_result:n,miracle_time_flag:s,item_equipment_part:u,item_level:l,target_item:d,potential_option_grade:p,additional_potential_option_grade:c,upgrade_guarantee:h,upgrade_guarantee_count:m,before_potential_option:O,before_additional_potential_option:g,after_potential_option:P,after_additional_potential_option:y}=t;this.id=e,this.characterName=i,this.worldName=o,this.dateCreate=new Date(a),this.cubeType=r,this.itemUpgradeResult=n,this.miracleTimeFlag=s,this.itemEquipmentPart=u,this.itemLevel=l,this.targetItem=d,this.potentialOptionGrade=p,this.additionalPotentialOptionGrade=c,this.upgradeGuarantee=h,this.upgradeGuaranteeCount=m,this.beforePotentialOption=O.map((t=>new f(t))),this.beforeAdditionalPotentialOption=g.map((t=>new f(t))),this.afterPotentialOption=P.map((t=>new f(t))),this.afterAdditionalPotentialOption=y.map((t=>new f(t)))}get isItemUpgrade(){return"성공"===this.itemUpgradeResult}get isMiracleTimeFlag(){return"이벤트 적용되지 않음"!==this.miracleTimeFlag}get potentialOptionGradeEnum(){return l(this.potentialOptionGrade)}get additionalPotentialOptionGradeEnum(){return l(this.additionalPotentialOptionGrade)}}class p{count;cubeHistory;nextCursor;constructor(t){const{count:e,cube_history:i,next_cursor:o}=t;this.count=e,this.cubeHistory=i.map((t=>new d(t))),this.nextCursor=o}}class c{serviceCode;startDateTime;endDateTime;strObstacleContents;constructor(t){const e=t["soap:Envelope"]["soap:Body"][0].GetInspectionInfoResponse[0].GetInspectionInfoResult[0]["diffgr:diffgram"][0].NewDataSet[0].InspectionInfo[0];this.serviceCode=Number(e.serviceCode[0]),this.startDateTime=new Date(e.startDateTime[0]),this.endDateTime=new Date(e.endDateTime[0]),this.strObstacleContents=e.strObstacleContents[0]}}class h extends Error{name="MapleStoryApiError";errorCode;message;constructor(t){const{name:e,message:i}=t.error;super(i),this.errorCode=O[e],this.message=i}}var m;t.MapleStoryApiErrorCode=void 0,(m=t.MapleStoryApiErrorCode||(t.MapleStoryApiErrorCode={}))[m.OPENAPI00001=0]="OPENAPI00001",m[m.OPENAPI00002=1]="OPENAPI00002",m[m.OPENAPI00003=2]="OPENAPI00003",m[m.OPENAPI00004=3]="OPENAPI00004",m[m.OPENAPI00005=4]="OPENAPI00005",m[m.OPENAPI00006=5]="OPENAPI00006",m[m.OPENAPI00007=6]="OPENAPI00007";const O={OPENAPI00001:t.MapleStoryApiErrorCode.OPENAPI00001,OPENAPI00002:t.MapleStoryApiErrorCode.OPENAPI00002,OPENAPI00003:t.MapleStoryApiErrorCode.OPENAPI00003,OPENAPI00004:t.MapleStoryApiErrorCode.OPENAPI00004,OPENAPI00005:t.MapleStoryApiErrorCode.OPENAPI00005,OPENAPI00006:t.MapleStoryApiErrorCode.OPENAPI00006,OPENAPI00007:t.MapleStoryApiErrorCode.OPENAPI00007};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var g={exports:{}};!function(t,e){var i,o;t.exports=(i={year:0,month:1,day:2,hour:3,minute:4,second:5},o={},function(t,e,a){var r,n=function(t,e,i){void 0===i&&(i={});var a=new Date(t),r=function(t,e){void 0===e&&(e={});var i=e.timeZoneName||"short",a=t+"|"+i,r=o[a];return r||(r=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),o[a]=r),r}(e,i);return r.formatToParts(a)},s=function(t,e){for(var o=n(t,e),r=[],s=0;s<o.length;s+=1){var u=o[s],l=u.type,f=u.value,d=i[l];d>=0&&(r[d]=parseInt(f,10))}var p=r[3],c=24===p?0:p,h=r[0]+"-"+r[1]+"-"+r[2]+" "+c+":"+r[4]+":"+r[5]+":000",m=+t;return(a.utc(h).valueOf()-(m-=m%1e3))/6e4},u=e.prototype;u.tz=function(t,e){void 0===t&&(t=r);var i=this.utcOffset(),o=this.toDate(),n=o.toLocaleString("en-US",{timeZone:t}),s=Math.round((o-new Date(n))/1e3/60),u=a(n,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(o.getTimezoneOffset()/15)-s,!0);if(e){var l=u.utcOffset();u=u.add(i-l,"minute")}return u.$x.$timezone=t,u},u.offsetName=function(t){var e=this.$x.$timezone||a.tz.guess(),i=n(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return i&&i.value};var l=u.startOf;u.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return l.call(this,t,e);var i=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return l.call(i,t,e).tz(this.$x.$timezone,!0)},a.tz=function(t,e,i){var o=i&&e,n=i||e||r,u=s(+a(),n);if("string"!=typeof t)return a(t).tz(n);var l=function(t,e,i){var o=t-60*e*1e3,a=s(o,i);if(e===a)return[o,e];var r=s(o-=60*(a-e)*1e3,i);return a===r?[o,a]:[t-60*Math.min(a,r)*1e3,Math.max(a,r)]}(a.utc(t,o).valueOf(),u,n),f=l[0],d=l[1],p=a(f).utcOffset(d);return p.$x.$timezone=n,p},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(t){r=t}})}(g);var P=g.exports,y={exports:{}};!function(t,e){var i,o,a;t.exports=(i="minute",o=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g,function(t,e,r){var n=e.prototype;r.utc=function(t){return new e({date:t,utc:!0,args:arguments})},n.utc=function(t){var e=r(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),i):e},n.local=function(){return r(this.toDate(),{locale:this.$L,utc:!1})};var s=n.parse;n.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),s.call(this,t)};var u=n.init;n.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var l=n.utcOffset;n.utcOffset=function(t,e){var r=this.$utils().u;if(r(t))return this.$u?0:r(this.$offset)?l.call(this):this.$offset;if("string"==typeof t&&(t=function(t){void 0===t&&(t="");var e=t.match(o);if(!e)return null;var i=(""+e[0]).match(a)||["-",0,0],r=i[0],n=60*+i[1]+ +i[2];return 0===n?0:"+"===r?n:-n}(t),null===t))return this;var n=Math.abs(t)<=16?60*t:t,s=this;if(e)return s.$offset=n,s.$u=0===t,s;if(0!==t){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(s=this.local().add(n+u,i)).$offset=n,s.$x.$localOffset=u}else s=this.utc();return s};var f=n.format;n.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},n.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},n.isUTC=function(){return!!this.$u},n.toISOString=function(){return this.toDate().toISOString()},n.toString=function(){return this.toDate().toUTCString()};var d=n.toDate;n.toDate=function(t){return"s"===t&&this.$offset?r(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var p=n.diff;n.diff=function(t,e,i){if(t&&this.$u===t.$u)return p.call(this,t,e,i);var o=this.local(),a=r(t).local();return p.call(o,a,e,i)}})}(y);var E=y.exports;s.default.extend(P),s.default.extend(E);class v{apiKey;static BASE_URL="https://open.api.nexon.com/";static kstOffset=540;timeout;constructor(t){this.apiKey=t,this.timeout=5e3}async getCubeResult(t,i){const o={count:t};if("string"==typeof i)o.cursor=i;else if("object"==typeof i){const{year:t,month:e,day:a}=i;if(t<=2022&&e<=11&&a<25)throw new Error("You can only retrieve data after 2022-11-25.");const r=s.default(`${t}-${e}-${a}`).utcOffset(v.kstOffset);o.date_kst=r.format("YYYYMMDD")}else{const t=s.default().utcOffset(v.kstOffset);o.date_kst=t.format("YYYYMMDD")}try{const t="maplestory/v1/history/cube",e=await n.default.get(t,{baseURL:v.BASE_URL,timeout:this.timeout,headers:this.buildHeaders(),params:o});return new p(e.data)}catch(t){if(t instanceof e.AxiosError){const e=t.response.data;throw new h(e)}throw t}}async getInspectionInfo(){const t=(new u.default.Builder).buildObject({"soap:Envelope":{$:{"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:xsd":"http://www.w3.org/2001/XMLSchema","xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"},"soap:Body":{GetInspectionInfo:{$:{xmlns:"https://api.maplestory.nexon.com/soap/"}}}}}),e=await n.default.post("soap/maplestory.asmx",t,{baseURL:"https://api.maplestory.nexon.com/",timeout:this.timeout,headers:{SOAPAction:"https://api.maplestory.nexon.com/soap/GetInspectionInfo","Content-Type":"text/xml; charset=utf-8"}}),i=await u.default.parseStringPromise(e.data);return new c(i)}buildHeaders(){return{"x-nxopen-api-key":this.apiKey}}}t.CubeHistoryDto=d,t.CubeHistoryResponseDto=p,t.CubeResultOptionDto=f,t.InspectionInfoDto=c,t.MapleStoryApi=v,t.MapleStoryApiError=h,t.potentialOptionGradeFromString=l}));
package/dist/index.mjs CHANGED
@@ -33,7 +33,7 @@ const potentialOptionGradeFromString = (text) => {
33
33
  */
34
34
  class CubeResultOptionDto {
35
35
  /**
36
- * 옵션 이름
36
+ * 옵션
37
37
  */
38
38
  value;
39
39
  /**
@@ -51,31 +51,31 @@ class CubeResultOptionDto {
51
51
  }
52
52
 
53
53
  /**
54
- * 큐브히스토리 정보
54
+ * 큐브 히스토리
55
55
  */
56
56
  class CubeHistoryDto {
57
57
  /**
58
- * 큐브 사용 내역에 대한 고유 식별자
58
+ * 큐브 히스토리 식별자
59
59
  */
60
60
  id;
61
61
  /**
62
- * 캐릭터이름
62
+ * 캐릭터 명
63
63
  */
64
64
  characterName;
65
65
  /**
66
- * 월드 이름
66
+ * 월드
67
67
  */
68
68
  worldName;
69
69
  /**
70
- * 큐브 사용 날짜
70
+ * 사용 일시
71
71
  */
72
- createDate;
72
+ dateCreate;
73
73
  /**
74
- * 사용한 큐브
74
+ * 사용 큐브
75
75
  */
76
76
  cubeType;
77
77
  /**
78
- * 큐브 사용 결과
78
+ * 사용 결과
79
79
  */
80
80
  itemUpgradeResult;
81
81
  /**
@@ -85,13 +85,13 @@ class CubeHistoryDto {
85
85
  /**
86
86
  * 장비 분류
87
87
  */
88
- itemEquipPart;
88
+ itemEquipmentPart;
89
89
  /**
90
90
  * 장비 레벨
91
91
  */
92
92
  itemLevel;
93
93
  /**
94
- * 큐브를 사용한 장비
94
+ * 큐브 사용한 장비
95
95
  */
96
96
  targetItem;
97
97
  /**
@@ -111,41 +111,41 @@ class CubeHistoryDto {
111
111
  */
112
112
  upgradeGuaranteeCount;
113
113
  /**
114
- * 큐브 사용 전 잠재능력 옵션
114
+ * 사용 전 잠재능력 옵션
115
115
  */
116
- beforePotentialOptions;
116
+ beforePotentialOption;
117
117
  /**
118
- * 큐브 사용 전 에디셔널 잠재능력 옵션
118
+ * 사용 전 에디셔널 잠재능력 옵션
119
119
  */
120
- beforeAdditionalPotentialOptions;
120
+ beforeAdditionalPotentialOption;
121
121
  /**
122
- * 큐브 사용 후 잠재능력 옵션
122
+ * 사용 후 잠재능력 옵션
123
123
  */
124
- afterPotentialOptions;
124
+ afterPotentialOption;
125
125
  /**
126
- * 큐브 사용 후 에디셔널 잠재능력 옵션
126
+ * 사용 후 에디셔널 잠재능력 옵션
127
127
  */
128
- afterAdditionalPotentialOptions;
128
+ afterAdditionalPotentialOption;
129
129
  constructor(obj) {
130
- const { id, character_name, world_name, create_date, cube_type, item_upgrade_result, miracle_time_flag, item_equip_part, item_level, target_item, potential_option_grade, additional_potential_option_grade, upgradeguarantee, upgradeguaranteecount, before_potential_options, before_additional_potential_options, after_potential_options, after_additional_potential_options } = obj;
130
+ const { id, character_name, world_name, date_create, cube_type, item_upgrade_result, miracle_time_flag, item_equipment_part, item_level, target_item, potential_option_grade, additional_potential_option_grade, upgrade_guarantee, upgrade_guarantee_count, before_potential_option, before_additional_potential_option, after_potential_option, after_additional_potential_option } = obj;
131
131
  this.id = id;
132
132
  this.characterName = character_name;
133
133
  this.worldName = world_name;
134
- this.createDate = create_date;
134
+ this.dateCreate = new Date(date_create);
135
135
  this.cubeType = cube_type;
136
136
  this.itemUpgradeResult = item_upgrade_result;
137
137
  this.miracleTimeFlag = miracle_time_flag;
138
- this.itemEquipPart = item_equip_part;
138
+ this.itemEquipmentPart = item_equipment_part;
139
139
  this.itemLevel = item_level;
140
140
  this.targetItem = target_item;
141
141
  this.potentialOptionGrade = potential_option_grade;
142
142
  this.additionalPotentialOptionGrade = additional_potential_option_grade;
143
- this.upgradeGuarantee = upgradeguarantee;
144
- this.upgradeGuaranteeCount = upgradeguaranteecount;
145
- this.beforePotentialOptions = before_potential_options.map(origin => new CubeResultOptionDto(origin));
146
- this.beforeAdditionalPotentialOptions = before_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
147
- this.afterPotentialOptions = after_potential_options.map(origin => new CubeResultOptionDto(origin));
148
- this.afterAdditionalPotentialOptions = after_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
143
+ this.upgradeGuarantee = upgrade_guarantee;
144
+ this.upgradeGuaranteeCount = upgrade_guarantee_count;
145
+ this.beforePotentialOption = before_potential_option.map(origin => new CubeResultOptionDto(origin));
146
+ this.beforeAdditionalPotentialOption = before_additional_potential_option.map(origin => new CubeResultOptionDto(origin));
147
+ this.afterPotentialOption = after_potential_option.map(origin => new CubeResultOptionDto(origin));
148
+ this.afterAdditionalPotentialOption = after_additional_potential_option.map(origin => new CubeResultOptionDto(origin));
149
149
  }
150
150
  get isItemUpgrade() {
151
151
  return this.itemUpgradeResult === '성공';
@@ -162,7 +162,7 @@ class CubeHistoryDto {
162
162
  }
163
163
 
164
164
  /**
165
- * 큐브히스토리 응답 정보
165
+ * 큐브 히스토리 응답 정보
166
166
  */
167
167
  class CubeHistoryResponseDto {
168
168
  /**
@@ -172,15 +172,15 @@ class CubeHistoryResponseDto {
172
172
  /**
173
173
  * 큐브 히스토리
174
174
  */
175
- cubeHistories;
175
+ cubeHistory;
176
176
  /**
177
177
  * 페이징 처리를 위한 cursor
178
178
  */
179
179
  nextCursor;
180
180
  constructor(obj) {
181
- const { count, cube_histories, next_cursor } = obj;
181
+ const { count, cube_history, next_cursor } = obj;
182
182
  this.count = count;
183
- this.cubeHistories = cube_histories.map(origin => new CubeHistoryDto(origin));
183
+ this.cubeHistory = cube_history.map(origin => new CubeHistoryDto(origin));
184
184
  this.nextCursor = next_cursor;
185
185
  }
186
186
  }
@@ -216,19 +216,42 @@ class InspectionInfoDto {
216
216
 
217
217
  /**
218
218
  * MapleStory OpenAPI error.<br>
219
- * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
219
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error details.
220
220
  */
221
221
  class MapleStoryApiError extends Error {
222
222
  name = 'MapleStoryApiError';
223
- status;
223
+ errorCode;
224
224
  message;
225
- constructor(params) {
226
- const { status, message } = params;
225
+ constructor(errorBody) {
226
+ const { name, message } = errorBody.error;
227
227
  super(message);
228
- this.status = status;
228
+ this.errorCode = errorMap[name];
229
229
  this.message = message;
230
230
  }
231
231
  }
232
+ /**
233
+ * MapleStory OpenAPI error codes.<br>
234
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error code details.
235
+ */
236
+ var MapleStoryApiErrorCode;
237
+ (function (MapleStoryApiErrorCode) {
238
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00001"] = 0] = "OPENAPI00001";
239
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00002"] = 1] = "OPENAPI00002";
240
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00003"] = 2] = "OPENAPI00003";
241
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00004"] = 3] = "OPENAPI00004";
242
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00005"] = 4] = "OPENAPI00005";
243
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00006"] = 5] = "OPENAPI00006";
244
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00007"] = 6] = "OPENAPI00007";
245
+ })(MapleStoryApiErrorCode || (MapleStoryApiErrorCode = {}));
246
+ const errorMap = {
247
+ ['OPENAPI00001']: MapleStoryApiErrorCode.OPENAPI00001,
248
+ ['OPENAPI00002']: MapleStoryApiErrorCode.OPENAPI00002,
249
+ ['OPENAPI00003']: MapleStoryApiErrorCode.OPENAPI00003,
250
+ ['OPENAPI00004']: MapleStoryApiErrorCode.OPENAPI00004,
251
+ ['OPENAPI00005']: MapleStoryApiErrorCode.OPENAPI00005,
252
+ ['OPENAPI00006']: MapleStoryApiErrorCode.OPENAPI00006,
253
+ ['OPENAPI00007']: MapleStoryApiErrorCode.OPENAPI00007,
254
+ };
232
255
 
233
256
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
234
257
 
@@ -250,9 +273,13 @@ var utc = utc$1.exports;
250
273
 
251
274
  dayjs.extend(timezone);
252
275
  dayjs.extend(utc);
276
+ /**
277
+ * MapleStory OpenAPI client.<br>
278
+ * This is an implementation of <a href="https://openapi.nexon.com/game/maplestory">MapleStory API</a>
279
+ */
253
280
  class MapleStoryApi {
254
281
  apiKey;
255
- static baseUrl = 'https://public.api.nexon.com/';
282
+ static BASE_URL = 'https://open.api.nexon.com/';
256
283
  static kstOffset = 540;
257
284
  timeout;
258
285
  constructor(apiKey) {
@@ -272,16 +299,16 @@ class MapleStoryApi {
272
299
  throw new Error('You can only retrieve data after 2022-11-25.');
273
300
  }
274
301
  const date = dayjs(`${year}-${month}-${day}`).utcOffset(MapleStoryApi.kstOffset);
275
- query.date = date.format('YYYY-MM-DD');
302
+ query.date_kst = date.format('YYYYMMDD');
276
303
  }
277
304
  else {
278
305
  const now = dayjs().utcOffset(MapleStoryApi.kstOffset);
279
- query.date = now.format('YYYY-MM-DD');
306
+ query.date_kst = now.format('YYYYMMDD');
280
307
  }
281
308
  try {
282
- const path = 'openapi/maplestory/v1/cube-use-results';
309
+ const path = 'maplestory/v1/history/cube';
283
310
  const response = await axios.get(path, {
284
- baseURL: MapleStoryApi.baseUrl,
311
+ baseURL: MapleStoryApi.BASE_URL,
285
312
  timeout: this.timeout,
286
313
  headers: this.buildHeaders(),
287
314
  params: query
@@ -334,9 +361,9 @@ class MapleStoryApi {
334
361
  }
335
362
  buildHeaders() {
336
363
  return {
337
- 'authorization': this.apiKey
364
+ 'x-nxopen-api-key': this.apiKey
338
365
  };
339
366
  }
340
367
  }
341
368
 
342
- export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, InspectionInfoDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
369
+ export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, InspectionInfoDto, MapleStoryApi, MapleStoryApiError, MapleStoryApiErrorCode, PotentialOptionGrade, potentialOptionGradeFromString };
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "maplestory-openapi",
3
- "version": "1.1.0",
4
- "description": "This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.",
3
+ "version": "2.0.0",
4
+ "description": "This JavaScript library enables the use of the MapleStory OpenAPI of Nexon.",
5
5
  "keywords": [
6
6
  "maplestory",
7
7
  "maplestory openapi",
8
8
  "maplestory api",
9
9
  "cube",
10
10
  "nexon",
11
- "nexon developers"
11
+ "nexon developers",
12
+ "nexon openapi"
12
13
  ],
13
14
  "homepage": "https://github.com/SpiralMoon/maplestory.openapi",
14
15
  "bugs": {
@@ -2,31 +2,31 @@ import { CubeResultOptionDto } from "./cubeResultOptionDto";
2
2
  import { CubeHistoryDtoBody } from "../response/cubeHistoryDtoBody";
3
3
  import { PotentialOptionGrade } from "./potentialOptionGrade";
4
4
  /**
5
- * 큐브히스토리 정보
5
+ * 큐브 히스토리
6
6
  */
7
7
  declare class CubeHistoryDto {
8
8
  /**
9
- * 큐브 사용 내역에 대한 고유 식별자
9
+ * 큐브 히스토리 식별자
10
10
  */
11
11
  id: string;
12
12
  /**
13
- * 캐릭터이름
13
+ * 캐릭터 명
14
14
  */
15
15
  characterName: string;
16
16
  /**
17
- * 월드 이름
17
+ * 월드
18
18
  */
19
19
  worldName: string;
20
20
  /**
21
- * 큐브 사용 날짜
21
+ * 사용 일시
22
22
  */
23
- createDate: string;
23
+ dateCreate: Date;
24
24
  /**
25
- * 사용한 큐브
25
+ * 사용 큐브
26
26
  */
27
27
  cubeType: string;
28
28
  /**
29
- * 큐브 사용 결과
29
+ * 사용 결과
30
30
  */
31
31
  itemUpgradeResult: string;
32
32
  /**
@@ -36,13 +36,13 @@ declare class CubeHistoryDto {
36
36
  /**
37
37
  * 장비 분류
38
38
  */
39
- itemEquipPart: string;
39
+ itemEquipmentPart: string;
40
40
  /**
41
41
  * 장비 레벨
42
42
  */
43
43
  itemLevel: number;
44
44
  /**
45
- * 큐브를 사용한 장비
45
+ * 큐브 사용한 장비
46
46
  */
47
47
  targetItem: string;
48
48
  /**
@@ -62,21 +62,21 @@ declare class CubeHistoryDto {
62
62
  */
63
63
  upgradeGuaranteeCount: number;
64
64
  /**
65
- * 큐브 사용 전 잠재능력 옵션
65
+ * 사용 전 잠재능력 옵션
66
66
  */
67
- beforePotentialOptions: CubeResultOptionDto[];
67
+ beforePotentialOption: CubeResultOptionDto[];
68
68
  /**
69
- * 큐브 사용 전 에디셔널 잠재능력 옵션
69
+ * 사용 전 에디셔널 잠재능력 옵션
70
70
  */
71
- beforeAdditionalPotentialOptions: CubeResultOptionDto[];
71
+ beforeAdditionalPotentialOption: CubeResultOptionDto[];
72
72
  /**
73
- * 큐브 사용 후 잠재능력 옵션
73
+ * 사용 후 잠재능력 옵션
74
74
  */
75
- afterPotentialOptions: CubeResultOptionDto[];
75
+ afterPotentialOption: CubeResultOptionDto[];
76
76
  /**
77
- * 큐브 사용 후 에디셔널 잠재능력 옵션
77
+ * 사용 후 에디셔널 잠재능력 옵션
78
78
  */
79
- afterAdditionalPotentialOptions: CubeResultOptionDto[];
79
+ afterAdditionalPotentialOption: CubeResultOptionDto[];
80
80
  constructor(obj: CubeHistoryDtoBody);
81
81
  get isItemUpgrade(): boolean;
82
82
  get isMiracleTimeFlag(): boolean;
@@ -1,7 +1,7 @@
1
1
  import { CubeHistoryDto } from "./cubeHistoryDto";
2
2
  import { CubeHistoryResponseDtoBody } from "../response/cubeHistoryResponseDtoBody";
3
3
  /**
4
- * 큐브히스토리 응답 정보
4
+ * 큐브 히스토리 응답 정보
5
5
  */
6
6
  declare class CubeHistoryResponseDto {
7
7
  /**
@@ -11,7 +11,7 @@ declare class CubeHistoryResponseDto {
11
11
  /**
12
12
  * 큐브 히스토리
13
13
  */
14
- cubeHistories: CubeHistoryDto[];
14
+ cubeHistory: CubeHistoryDto[];
15
15
  /**
16
16
  * 페이징 처리를 위한 cursor
17
17
  */
@@ -5,7 +5,7 @@ import { PotentialOptionGrade } from "./potentialOptionGrade";
5
5
  */
6
6
  declare class CubeResultOptionDto {
7
7
  /**
8
- * 옵션 이름
8
+ * 옵션
9
9
  */
10
10
  value: string;
11
11
  /**
@@ -1,35 +1,42 @@
1
1
  import { CubeHistoryResponseDto } from "./dto/cubeHistoryResponseDto";
2
2
  import { InspectionInfoDto } from "./dto/inspectionInfoDto";
3
+ /**
4
+ * MapleStory OpenAPI client.<br>
5
+ * This is an implementation of <a href="https://openapi.nexon.com/game/maplestory">MapleStory API</a>
6
+ */
3
7
  declare class MapleStoryApi {
4
8
  private readonly apiKey;
5
- private static baseUrl;
9
+ private static BASE_URL;
6
10
  private static kstOffset;
7
11
  timeout: number;
8
12
  constructor(apiKey: string);
9
13
  /**
10
- * 오늘 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
11
- * 데이터는 일단위로 갱신되며, 오전 4 조회 시 전일 데이터를 조회할 수 있습니다.<br>
12
- * 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
14
+ * 오늘 날짜의 큐브 사용 결과를 조회합니다.<br>
15
+ * 큐브 사용 결과 데이터는 매일 오전 4시, 전일 데이터가 갱신됩니다.<br>
16
+ * 큐브 사용 결과 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
17
+ * e.g. 오늘 오후 3시 5분 큐브 확률 정보 조회 시, 어제의 큐브 확률 정보 데이터를 조회할 수 있습니다.<br>
13
18
  *
14
- * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
19
+ * @param count 한번에 가져오려는 결과의 개수(최소 10, 최대 1000)
15
20
  */
16
21
  getCubeResult(count: number): Promise<CubeHistoryResponseDto>;
17
22
  /**
18
- * 지목한 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
19
- * 데이터는 일단위로 갱신되며, 오전 4 조회 시 전일 데이터를 조회할 수 있습니다.<br>
20
- * 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
23
+ * 지목한 날짜의 큐브 사용 결과를 조회합니다.<br>
24
+ * 큐브 사용 결과 데이터는 매일 오전 4시, 전일 데이터가 갱신됩니다.<br>
25
+ * 큐브 사용 결과 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
26
+ * e.g. 오늘 오후 3시 5분 큐브 확률 정보 조회 시, 어제의 큐브 확률 정보 데이터를 조회할 수 있습니다.<br>
21
27
  *
22
- * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
23
- * @param dateOptions 조회할 연월일 날짜 정보
28
+ * @param count 한번에 가져오려는 결과의 개수(최소 10, 최대 1000)
29
+ * @param dateOptions 조회 기준일 (KST)
24
30
  */
25
31
  getCubeResult(count: number, dateOptions: DateOptions): Promise<CubeHistoryResponseDto>;
26
32
  /**
27
- * 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
28
- * 데이터는 일단위로 갱신되며, 오전 4 조회 시 전일 데이터를 조회할 수 있습니다.<br>
29
- * 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
33
+ * 큐브 사용 결과를 조회합니다.<br>
34
+ * 큐브 사용 결과 데이터는 매일 오전 4시, 전일 데이터가 갱신됩니다.<br>
35
+ * 큐브 사용 결과 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
36
+ * e.g. 오늘 오후 3시 5분 큐브 확률 정보 조회 시, 어제의 큐브 확률 정보 데이터를 조회할 수 있습니다.<br>
30
37
  *
31
- * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
32
- * @param cursor
38
+ * @param count 한번에 가져오려는 결과의 개수(최소 10, 최대 1000)
39
+ * @param cursor 페이징 처리를 위한 cursor
33
40
  */
34
41
  getCubeResult(count: number, cursor: string): Promise<CubeHistoryResponseDto>;
35
42
  /**
@@ -43,4 +50,10 @@ type DateOptions = {
43
50
  month: number;
44
51
  day: number;
45
52
  };
46
- export { MapleStoryApi };
53
+ type MapleStoryErrorBody = {
54
+ error: {
55
+ name: string;
56
+ message: string;
57
+ };
58
+ };
59
+ export { MapleStoryApi, MapleStoryErrorBody };
@@ -1,14 +1,25 @@
1
+ import { MapleStoryErrorBody } from "./mapleStoryApi";
1
2
  /**
2
3
  * MapleStory OpenAPI error.<br>
3
- * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
4
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error details.
4
5
  */
5
6
  declare class MapleStoryApiError extends Error {
6
7
  readonly name = "MapleStoryApiError";
7
- readonly status: number;
8
+ readonly errorCode: MapleStoryApiErrorCode;
8
9
  readonly message: string;
9
- constructor(params: {
10
- status: number;
11
- message: string;
12
- });
10
+ constructor(errorBody: MapleStoryErrorBody);
13
11
  }
14
- export { MapleStoryApiError };
12
+ /**
13
+ * MapleStory OpenAPI error codes.<br>
14
+ * Please refer to <a href="https://openapi.nexon.com/guide/request-api/">MapleStory API guide</a> for the error code details.
15
+ */
16
+ declare enum MapleStoryApiErrorCode {
17
+ OPENAPI00001 = 0,
18
+ OPENAPI00002 = 1,
19
+ OPENAPI00003 = 2,
20
+ OPENAPI00004 = 3,
21
+ OPENAPI00005 = 4,
22
+ OPENAPI00006 = 5,
23
+ OPENAPI00007 = 6
24
+ }
25
+ export { MapleStoryApiError, MapleStoryApiErrorCode };
@@ -3,20 +3,20 @@ type CubeHistoryDtoBody = {
3
3
  id: string;
4
4
  character_name: string;
5
5
  world_name: string;
6
- create_date: string;
6
+ date_create: string;
7
7
  cube_type: string;
8
8
  item_upgrade_result: string;
9
9
  miracle_time_flag: string;
10
- item_equip_part: string;
10
+ item_equipment_part: string;
11
11
  item_level: number;
12
12
  target_item: string;
13
13
  potential_option_grade: string;
14
14
  additional_potential_option_grade: string;
15
- upgradeguarantee: boolean;
16
- upgradeguaranteecount: number;
17
- before_potential_options: CubeResultOptionDtoBody[];
18
- before_additional_potential_options: CubeResultOptionDtoBody[];
19
- after_potential_options: CubeResultOptionDtoBody[];
20
- after_additional_potential_options: CubeResultOptionDtoBody[];
15
+ upgrade_guarantee: boolean;
16
+ upgrade_guarantee_count: number;
17
+ before_potential_option: CubeResultOptionDtoBody[];
18
+ before_additional_potential_option: CubeResultOptionDtoBody[];
19
+ after_potential_option: CubeResultOptionDtoBody[];
20
+ after_additional_potential_option: CubeResultOptionDtoBody[];
21
21
  };
22
22
  export type { CubeHistoryDtoBody };
@@ -1,7 +1,7 @@
1
1
  import { CubeHistoryDtoBody } from "./cubeHistoryDtoBody";
2
2
  type CubeHistoryResponseDtoBody = {
3
3
  count: number;
4
- cube_histories: CubeHistoryDtoBody[];
4
+ cube_history: CubeHistoryDtoBody[];
5
5
  next_cursor: string;
6
6
  };
7
7
  export type { CubeHistoryResponseDtoBody };