maplestory-openapi 1.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/dist/index.js ADDED
@@ -0,0 +1,288 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var dayjs = require('dayjs');
5
+
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+
8
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
9
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
10
+
11
+ exports.PotentialOptionGrade = void 0;
12
+ (function (PotentialOptionGrade) {
13
+ PotentialOptionGrade[PotentialOptionGrade["RARE"] = 0] = "RARE";
14
+ PotentialOptionGrade[PotentialOptionGrade["EPIC"] = 1] = "EPIC";
15
+ PotentialOptionGrade[PotentialOptionGrade["UNIQUE"] = 2] = "UNIQUE";
16
+ PotentialOptionGrade[PotentialOptionGrade["LEGENDARY"] = 3] = "LEGENDARY";
17
+ })(exports.PotentialOptionGrade || (exports.PotentialOptionGrade = {}));
18
+ /**
19
+ * 한글로 정의된 잠재옵션 등급을 PotentialOptionGrade으로 변환합니다.
20
+ *
21
+ * @param text support only "레어", "에픽", "유니크", "레전드리"
22
+ */
23
+ const potentialOptionGradeFromString = (text) => {
24
+ const potentialOptionGradeMap = {
25
+ '레어': exports.PotentialOptionGrade.RARE,
26
+ '에픽': exports.PotentialOptionGrade.EPIC,
27
+ '유니크': exports.PotentialOptionGrade.UNIQUE,
28
+ '레전드리': exports.PotentialOptionGrade.LEGENDARY,
29
+ };
30
+ const grade = potentialOptionGradeMap[text];
31
+ if (!grade) {
32
+ throw new TypeError('No enum constant for string: ' + text);
33
+ }
34
+ return grade;
35
+ };
36
+
37
+ /**
38
+ * 큐브 결과 옵션 정보
39
+ */
40
+ class CubeResultOptionDto {
41
+ /**
42
+ * 옵션 이름
43
+ */
44
+ value;
45
+ /**
46
+ * 옵션 등급
47
+ */
48
+ grade;
49
+ constructor(obj) {
50
+ const { value, grade } = obj;
51
+ this.value = value;
52
+ this.grade = grade;
53
+ }
54
+ get gradeEnum() {
55
+ return potentialOptionGradeFromString(this.grade);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * 큐브히스토리 정보
61
+ */
62
+ class CubeHistoryDto {
63
+ /**
64
+ * 큐브 사용 내역에 대한 고유 식별자
65
+ */
66
+ id;
67
+ /**
68
+ * 캐릭터이름
69
+ */
70
+ characterName;
71
+ /**
72
+ * 월드 이름
73
+ */
74
+ worldName;
75
+ /**
76
+ * 큐브 사용 날짜
77
+ */
78
+ createDate;
79
+ /**
80
+ * 사용한 큐브
81
+ */
82
+ cubeType;
83
+ /**
84
+ * 큐브 사용 결과
85
+ */
86
+ itemUpgradeResult;
87
+ /**
88
+ * 미라클 타임 적용 여부
89
+ */
90
+ miracleTimeFlag;
91
+ /**
92
+ * 장비 분류
93
+ */
94
+ itemEquipPart;
95
+ /**
96
+ * 장비 레벨
97
+ */
98
+ itemLevel;
99
+ /**
100
+ * 큐브를 사용한 장비
101
+ */
102
+ targetItem;
103
+ /**
104
+ * 잠재능력 등급
105
+ */
106
+ potentialOptionGrade;
107
+ /**
108
+ * 에디셔널 잠재능력 등급
109
+ */
110
+ additionalPotentialOptionGrade;
111
+ /**
112
+ * 천장에 도달하여 확정 등급 상승한 여부
113
+ */
114
+ upgradeGuarantee;
115
+ /**
116
+ * 현재까지 쌓은 스택
117
+ */
118
+ upgradeGuaranteeCount;
119
+ /**
120
+ * 큐브 사용 전 잠재능력 옵션
121
+ */
122
+ beforePotentialOptions;
123
+ /**
124
+ * 큐브 사용 전 에디셔널 잠재능력 옵션
125
+ */
126
+ beforeAdditionalPotentialOptions;
127
+ /**
128
+ * 큐브 사용 후 잠재능력 옵션
129
+ */
130
+ afterPotentialOptions;
131
+ /**
132
+ * 큐브 사용 후 에디셔널 잠재능력 옵션
133
+ */
134
+ afterAdditionalPotentialOptions;
135
+ constructor(obj) {
136
+ 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;
137
+ this.id = id;
138
+ this.characterName = character_name;
139
+ this.worldName = world_name;
140
+ this.createDate = create_date;
141
+ this.cubeType = cube_type;
142
+ this.itemUpgradeResult = item_upgrade_result;
143
+ this.miracleTimeFlag = miracle_time_flag;
144
+ this.itemEquipPart = item_equip_part;
145
+ this.itemLevel = item_level;
146
+ this.targetItem = target_item;
147
+ this.potentialOptionGrade = potential_option_grade;
148
+ this.additionalPotentialOptionGrade = additional_potential_option_grade;
149
+ this.upgradeGuarantee = upgradeguarantee;
150
+ this.upgradeGuaranteeCount = upgradeguaranteecount;
151
+ this.beforePotentialOptions = before_potential_options.map(origin => new CubeResultOptionDto(origin));
152
+ this.beforeAdditionalPotentialOptions = before_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
153
+ this.afterPotentialOptions = after_potential_options.map(origin => new CubeResultOptionDto(origin));
154
+ this.afterAdditionalPotentialOptions = after_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
155
+ }
156
+ get isItemUpgrade() {
157
+ return this.itemUpgradeResult === '성공';
158
+ }
159
+ get isMiracleTimeFlag() {
160
+ return this.miracleTimeFlag !== '이벤트 적용되지 않음';
161
+ }
162
+ get potentialOptionGradeEnum() {
163
+ return potentialOptionGradeFromString(this.potentialOptionGrade);
164
+ }
165
+ get additionalPotentialOptionGradeEnum() {
166
+ return potentialOptionGradeFromString(this.additionalPotentialOptionGrade);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * 큐브히스토리 응답 정보
172
+ */
173
+ class CubeHistoryResponseDto {
174
+ /**
175
+ * 결과 건 수
176
+ */
177
+ count;
178
+ /**
179
+ * 큐브 히스토리
180
+ */
181
+ cubeHistories;
182
+ /**
183
+ * 페이징 처리를 위한 cursor
184
+ */
185
+ nextCursor;
186
+ constructor(obj) {
187
+ const { count, cube_histories, next_cursor } = obj;
188
+ this.count = count;
189
+ this.cubeHistories = cube_histories.map(origin => new CubeHistoryDto(origin));
190
+ this.nextCursor = next_cursor;
191
+ }
192
+ }
193
+
194
+ /**
195
+ * MapleStory OpenAPI error.<br>
196
+ * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
197
+ */
198
+ class MapleStoryApiError extends Error {
199
+ name = 'MapleStoryApiError';
200
+ status;
201
+ message;
202
+ constructor(params) {
203
+ const { status, message } = params;
204
+ super(message);
205
+ this.status = status;
206
+ this.message = message;
207
+ }
208
+ }
209
+
210
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
211
+
212
+ var timezone$1 = {exports: {}};
213
+
214
+ (function (module, exports) {
215
+ !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];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}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10));}var d=r[3],l=24===d?0:d,h=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",v=+e;return (o.utc(h).valueOf()-(v-=v%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n=this.utcOffset(),i=this.toDate(),a=i.toLocaleString("en-US",{timeZone:t}),u=Math.round((i-new Date(a))/1e3/60),f=o(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-u,!0);if(e){var s=f.utcOffset();f=f.add(n-s,"minute");}return f.$x.$timezone=t,f},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return "timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return [i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t;};}}));
216
+ }(timezone$1));
217
+
218
+ var timezone = timezone$1.exports;
219
+
220
+ var utc$1 = {exports: {}};
221
+
222
+ (function (module, exports) {
223
+ !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.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 r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
224
+ }(utc$1));
225
+
226
+ var utc = utc$1.exports;
227
+
228
+ dayjs__default["default"].extend(timezone);
229
+ dayjs__default["default"].extend(utc);
230
+ class MapleStoryApi {
231
+ apiKey;
232
+ static baseUrl = 'https://public.api.nexon.com/';
233
+ static kstOffset = 540;
234
+ timeout;
235
+ constructor(apiKey) {
236
+ this.apiKey = apiKey;
237
+ this.timeout = 5000;
238
+ }
239
+ async getCubeResult(count, parameter) {
240
+ const query = {
241
+ count,
242
+ };
243
+ if (typeof parameter === 'string') {
244
+ query.cursor = parameter;
245
+ }
246
+ else if (typeof parameter === 'object') {
247
+ const { year, month, day } = parameter;
248
+ if (year <= 2022 && month <= 11 && day < 25) {
249
+ throw new Error('You can only retrieve data after 2022-11-25.');
250
+ }
251
+ const date = dayjs__default["default"](`${year}-${month}-${day}`).utcOffset(MapleStoryApi.kstOffset);
252
+ query.date = date.format('YYYY-MM-DD');
253
+ }
254
+ else {
255
+ const now = dayjs__default["default"]().utcOffset(MapleStoryApi.kstOffset);
256
+ query.date = now.format('YYYY-MM-DD');
257
+ }
258
+ try {
259
+ const path = 'openapi/maplestory/v1/cube-use-results';
260
+ const response = await axios__default["default"].get(path, {
261
+ baseURL: MapleStoryApi.baseUrl,
262
+ timeout: this.timeout,
263
+ headers: this.buildHeaders(),
264
+ params: query
265
+ });
266
+ return new CubeHistoryResponseDto(response.data);
267
+ }
268
+ catch (e) {
269
+ if (e instanceof axios.AxiosError) {
270
+ const errorBody = e.response.data;
271
+ throw new MapleStoryApiError(errorBody);
272
+ }
273
+ throw e;
274
+ }
275
+ }
276
+ buildHeaders() {
277
+ return {
278
+ 'authorization': this.apiKey
279
+ };
280
+ }
281
+ }
282
+
283
+ exports.CubeHistoryDto = CubeHistoryDto;
284
+ exports.CubeHistoryResponseDto = CubeHistoryResponseDto;
285
+ exports.CubeResultOptionDto = CubeResultOptionDto;
286
+ exports.MapleStoryApi = MapleStoryApi;
287
+ exports.MapleStoryApiError = MapleStoryApiError;
288
+ exports.potentialOptionGradeFromString = potentialOptionGradeFromString;
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("dayjs")):"function"==typeof define&&define.amd?define(["exports","axios","dayjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["maplestory-openapi"]={},t.axios,t.dayjs)}(this,(function(t,e,i){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o,n=a(e),r=a(i);t.PotentialOptionGrade=void 0,(o=t.PotentialOptionGrade||(t.PotentialOptionGrade={}))[o.RARE=0]="RARE",o[o.EPIC=1]="EPIC",o[o.UNIQUE=2]="UNIQUE",o[o.LEGENDARY=3]="LEGENDARY";const s=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 u{value;grade;constructor(t){const{value:e,grade:i}=t;this.value=e,this.grade=i}get gradeEnum(){return s(this.grade)}}class f{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:r,miracle_time_flag:s,item_equip_part:f,item_level:l,target_item:c,potential_option_grade:d,additional_potential_option_grade:h,upgradeguarantee:p,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=r,this.miracleTimeFlag=s,this.itemEquipPart=f,this.itemLevel=l,this.targetItem=c,this.potentialOptionGrade=d,this.additionalPotentialOptionGrade=h,this.upgradeGuarantee=p,this.upgradeGuaranteeCount=m,this.beforePotentialOptions=g.map((t=>new u(t))),this.beforeAdditionalPotentialOptions=v.map((t=>new u(t))),this.afterPotentialOptions=$.map((t=>new u(t))),this.afterAdditionalPotentialOptions=O.map((t=>new u(t)))}get isItemUpgrade(){return"성공"===this.itemUpgradeResult}get isMiracleTimeFlag(){return"이벤트 적용되지 않음"!==this.miracleTimeFlag}get potentialOptionGradeEnum(){return s(this.potentialOptionGrade)}get additionalPotentialOptionGradeEnum(){return s(this.additionalPotentialOptionGrade)}}class l{count;cubeHistories;nextCursor;constructor(t){const{count:e,cube_histories:i,next_cursor:a}=t;this.count=e,this.cubeHistories=i.map((t=>new f(t))),this.nextCursor=a}}class c 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 d={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,r=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)},s=function(t,e){for(var a=r(t,e),n=[],s=0;s<a.length;s+=1){var u=a[s],f=u.type,l=u.value,c=i[f];c>=0&&(n[c]=parseInt(l,10))}var d=n[3],h=24===d?0:d,p=n[0]+"-"+n[1]+"-"+n[2]+" "+h+":"+n[4]+":"+n[5]+":000",m=+t;return(o.utc(p).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(),r=a.toLocaleString("en-US",{timeZone:t}),s=Math.round((a-new Date(r))/1e3/60),u=o(r,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-s,!0);if(e){var f=u.utcOffset();u=u.add(i-f,"minute")}return u.$x.$timezone=t,u},u.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),i=r(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return i&&i.value};var f=u.startOf;u.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return f.call(this,t,e);var i=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(i,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,i){var a=i&&e,r=i||e||n,u=s(+o(),r);if("string"!=typeof t)return o(t).tz(r);var f=function(t,e,i){var a=t-60*e*1e3,o=s(a,i);if(e===o)return[a,e];var n=s(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,r),l=f[0],c=f[1],d=o(l).utcOffset(c);return d.$x.$timezone=r,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){n=t}})}(d);var h=d.exports,p={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 r=e.prototype;n.utc=function(t){return new e({date:t,utc:!0,args:arguments})},r.utc=function(t){var e=n(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),i):e},r.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var s=r.parse;r.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),s.call(this,t)};var u=r.init;r.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 f=r.utcOffset;r.utcOffset=function(t,e){var n=this.$utils().u;if(n(t))return this.$u?0:n(this.$offset)?f.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],r=60*+i[1]+ +i[2];return 0===r?0:"+"===n?r:-r}(t),null===t))return this;var r=Math.abs(t)<=16?60*t:t,s=this;if(e)return s.$offset=r,s.$u=0===t,s;if(0!==t){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(s=this.local().add(r+u,i)).$offset=r,s.$x.$localOffset=u}else s=this.utc();return s};var l=r.format;r.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,e)},r.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},r.isUTC=function(){return!!this.$u},r.toISOString=function(){return this.toDate().toISOString()},r.toString=function(){return this.toDate().toUTCString()};var c=r.toDate;r.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():c.call(this)};var d=r.diff;r.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)}})}(p);var m=p.exports;r.default.extend(h),r.default.extend(m);class g{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(g.kstOffset);a.date=n.format("YYYY-MM-DD")}else{const t=r.default().utcOffset(g.kstOffset);a.date=t.format("YYYY-MM-DD")}try{const t="openapi/maplestory/v1/cube-use-results",e=await n.default.get(t,{baseURL:g.baseUrl,timeout:this.timeout,headers:this.buildHeaders(),params:a});return new l(e.data)}catch(t){if(t instanceof e.AxiosError){const e=t.response.data;throw new c(e)}throw t}}buildHeaders(){return{authorization:this.apiKey}}}t.CubeHistoryDto=f,t.CubeHistoryResponseDto=l,t.CubeResultOptionDto=u,t.MapleStoryApi=g,t.MapleStoryApiError=c,t.potentialOptionGradeFromString=s}));
package/dist/index.mjs ADDED
@@ -0,0 +1,276 @@
1
+ import axios, { AxiosError } from 'axios';
2
+ import dayjs from 'dayjs';
3
+
4
+ var PotentialOptionGrade;
5
+ (function (PotentialOptionGrade) {
6
+ PotentialOptionGrade[PotentialOptionGrade["RARE"] = 0] = "RARE";
7
+ PotentialOptionGrade[PotentialOptionGrade["EPIC"] = 1] = "EPIC";
8
+ PotentialOptionGrade[PotentialOptionGrade["UNIQUE"] = 2] = "UNIQUE";
9
+ PotentialOptionGrade[PotentialOptionGrade["LEGENDARY"] = 3] = "LEGENDARY";
10
+ })(PotentialOptionGrade || (PotentialOptionGrade = {}));
11
+ /**
12
+ * 한글로 정의된 잠재옵션 등급을 PotentialOptionGrade으로 변환합니다.
13
+ *
14
+ * @param text support only "레어", "에픽", "유니크", "레전드리"
15
+ */
16
+ const potentialOptionGradeFromString = (text) => {
17
+ const potentialOptionGradeMap = {
18
+ '레어': PotentialOptionGrade.RARE,
19
+ '에픽': PotentialOptionGrade.EPIC,
20
+ '유니크': PotentialOptionGrade.UNIQUE,
21
+ '레전드리': PotentialOptionGrade.LEGENDARY,
22
+ };
23
+ const grade = potentialOptionGradeMap[text];
24
+ if (!grade) {
25
+ throw new TypeError('No enum constant for string: ' + text);
26
+ }
27
+ return grade;
28
+ };
29
+
30
+ /**
31
+ * 큐브 결과 옵션 정보
32
+ */
33
+ class CubeResultOptionDto {
34
+ /**
35
+ * 옵션 이름
36
+ */
37
+ value;
38
+ /**
39
+ * 옵션 등급
40
+ */
41
+ grade;
42
+ constructor(obj) {
43
+ const { value, grade } = obj;
44
+ this.value = value;
45
+ this.grade = grade;
46
+ }
47
+ get gradeEnum() {
48
+ return potentialOptionGradeFromString(this.grade);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * 큐브히스토리 정보
54
+ */
55
+ class CubeHistoryDto {
56
+ /**
57
+ * 큐브 사용 내역에 대한 고유 식별자
58
+ */
59
+ id;
60
+ /**
61
+ * 캐릭터이름
62
+ */
63
+ characterName;
64
+ /**
65
+ * 월드 이름
66
+ */
67
+ worldName;
68
+ /**
69
+ * 큐브 사용 날짜
70
+ */
71
+ createDate;
72
+ /**
73
+ * 사용한 큐브
74
+ */
75
+ cubeType;
76
+ /**
77
+ * 큐브 사용 결과
78
+ */
79
+ itemUpgradeResult;
80
+ /**
81
+ * 미라클 타임 적용 여부
82
+ */
83
+ miracleTimeFlag;
84
+ /**
85
+ * 장비 분류
86
+ */
87
+ itemEquipPart;
88
+ /**
89
+ * 장비 레벨
90
+ */
91
+ itemLevel;
92
+ /**
93
+ * 큐브를 사용한 장비
94
+ */
95
+ targetItem;
96
+ /**
97
+ * 잠재능력 등급
98
+ */
99
+ potentialOptionGrade;
100
+ /**
101
+ * 에디셔널 잠재능력 등급
102
+ */
103
+ additionalPotentialOptionGrade;
104
+ /**
105
+ * 천장에 도달하여 확정 등급 상승한 여부
106
+ */
107
+ upgradeGuarantee;
108
+ /**
109
+ * 현재까지 쌓은 스택
110
+ */
111
+ upgradeGuaranteeCount;
112
+ /**
113
+ * 큐브 사용 전 잠재능력 옵션
114
+ */
115
+ beforePotentialOptions;
116
+ /**
117
+ * 큐브 사용 전 에디셔널 잠재능력 옵션
118
+ */
119
+ beforeAdditionalPotentialOptions;
120
+ /**
121
+ * 큐브 사용 후 잠재능력 옵션
122
+ */
123
+ afterPotentialOptions;
124
+ /**
125
+ * 큐브 사용 후 에디셔널 잠재능력 옵션
126
+ */
127
+ afterAdditionalPotentialOptions;
128
+ constructor(obj) {
129
+ 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
+ this.id = id;
131
+ this.characterName = character_name;
132
+ this.worldName = world_name;
133
+ this.createDate = create_date;
134
+ this.cubeType = cube_type;
135
+ this.itemUpgradeResult = item_upgrade_result;
136
+ this.miracleTimeFlag = miracle_time_flag;
137
+ this.itemEquipPart = item_equip_part;
138
+ this.itemLevel = item_level;
139
+ this.targetItem = target_item;
140
+ this.potentialOptionGrade = potential_option_grade;
141
+ this.additionalPotentialOptionGrade = additional_potential_option_grade;
142
+ this.upgradeGuarantee = upgradeguarantee;
143
+ this.upgradeGuaranteeCount = upgradeguaranteecount;
144
+ this.beforePotentialOptions = before_potential_options.map(origin => new CubeResultOptionDto(origin));
145
+ this.beforeAdditionalPotentialOptions = before_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
146
+ this.afterPotentialOptions = after_potential_options.map(origin => new CubeResultOptionDto(origin));
147
+ this.afterAdditionalPotentialOptions = after_additional_potential_options.map(origin => new CubeResultOptionDto(origin));
148
+ }
149
+ get isItemUpgrade() {
150
+ return this.itemUpgradeResult === '성공';
151
+ }
152
+ get isMiracleTimeFlag() {
153
+ return this.miracleTimeFlag !== '이벤트 적용되지 않음';
154
+ }
155
+ get potentialOptionGradeEnum() {
156
+ return potentialOptionGradeFromString(this.potentialOptionGrade);
157
+ }
158
+ get additionalPotentialOptionGradeEnum() {
159
+ return potentialOptionGradeFromString(this.additionalPotentialOptionGrade);
160
+ }
161
+ }
162
+
163
+ /**
164
+ * 큐브히스토리 응답 정보
165
+ */
166
+ class CubeHistoryResponseDto {
167
+ /**
168
+ * 결과 건 수
169
+ */
170
+ count;
171
+ /**
172
+ * 큐브 히스토리
173
+ */
174
+ cubeHistories;
175
+ /**
176
+ * 페이징 처리를 위한 cursor
177
+ */
178
+ nextCursor;
179
+ constructor(obj) {
180
+ const { count, cube_histories, next_cursor } = obj;
181
+ this.count = count;
182
+ this.cubeHistories = cube_histories.map(origin => new CubeHistoryDto(origin));
183
+ this.nextCursor = next_cursor;
184
+ }
185
+ }
186
+
187
+ /**
188
+ * MapleStory OpenAPI error.<br>
189
+ * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
190
+ */
191
+ class MapleStoryApiError extends Error {
192
+ name = 'MapleStoryApiError';
193
+ status;
194
+ message;
195
+ constructor(params) {
196
+ const { status, message } = params;
197
+ super(message);
198
+ this.status = status;
199
+ this.message = message;
200
+ }
201
+ }
202
+
203
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
204
+
205
+ var timezone$1 = {exports: {}};
206
+
207
+ (function (module, exports) {
208
+ !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];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}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10));}var d=r[3],l=24===d?0:d,h=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",v=+e;return (o.utc(h).valueOf()-(v-=v%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n=this.utcOffset(),i=this.toDate(),a=i.toLocaleString("en-US",{timeZone:t}),u=Math.round((i-new Date(a))/1e3/60),f=o(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-u,!0);if(e){var s=f.utcOffset();f=f.add(n-s,"minute");}return f.$x.$timezone=t,f},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return "timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return [i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t;};}}));
209
+ }(timezone$1));
210
+
211
+ var timezone = timezone$1.exports;
212
+
213
+ var utc$1 = {exports: {}};
214
+
215
+ (function (module, exports) {
216
+ !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.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 r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
217
+ }(utc$1));
218
+
219
+ var utc = utc$1.exports;
220
+
221
+ dayjs.extend(timezone);
222
+ dayjs.extend(utc);
223
+ class MapleStoryApi {
224
+ apiKey;
225
+ static baseUrl = 'https://public.api.nexon.com/';
226
+ static kstOffset = 540;
227
+ timeout;
228
+ constructor(apiKey) {
229
+ this.apiKey = apiKey;
230
+ this.timeout = 5000;
231
+ }
232
+ async getCubeResult(count, parameter) {
233
+ const query = {
234
+ count,
235
+ };
236
+ if (typeof parameter === 'string') {
237
+ query.cursor = parameter;
238
+ }
239
+ else if (typeof parameter === 'object') {
240
+ const { year, month, day } = parameter;
241
+ if (year <= 2022 && month <= 11 && day < 25) {
242
+ throw new Error('You can only retrieve data after 2022-11-25.');
243
+ }
244
+ const date = dayjs(`${year}-${month}-${day}`).utcOffset(MapleStoryApi.kstOffset);
245
+ query.date = date.format('YYYY-MM-DD');
246
+ }
247
+ else {
248
+ const now = dayjs().utcOffset(MapleStoryApi.kstOffset);
249
+ query.date = now.format('YYYY-MM-DD');
250
+ }
251
+ try {
252
+ const path = 'openapi/maplestory/v1/cube-use-results';
253
+ const response = await axios.get(path, {
254
+ baseURL: MapleStoryApi.baseUrl,
255
+ timeout: this.timeout,
256
+ headers: this.buildHeaders(),
257
+ params: query
258
+ });
259
+ return new CubeHistoryResponseDto(response.data);
260
+ }
261
+ catch (e) {
262
+ if (e instanceof AxiosError) {
263
+ const errorBody = e.response.data;
264
+ throw new MapleStoryApiError(errorBody);
265
+ }
266
+ throw e;
267
+ }
268
+ }
269
+ buildHeaders() {
270
+ return {
271
+ 'authorization': this.apiKey
272
+ };
273
+ }
274
+ }
275
+
276
+ export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "maplestory-openapi",
3
+ "version": "1.0.0",
4
+ "keywords": [
5
+ "maplestory",
6
+ "maplestory openapi",
7
+ "maplestory api",
8
+ "cube",
9
+ "nexon",
10
+ "nexon developers"
11
+ ],
12
+ "homepage": "https://github.com/SpiralMoon/maplestory.openapi",
13
+ "bugs": {
14
+ "url": "https://github.com/SpiralMoon/maplestory.openapi/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/SpiralMoon/maplestory.openapi.git"
19
+ },
20
+ "license": "MIT",
21
+ "author": "SpiralMoon",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.mjs",
25
+ "require": "./dist/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "main": "dist/index.js",
30
+ "unpkg": "dist/index.min.js",
31
+ "module": "dist/index.mjs",
32
+ "types": "types/index.d.ts",
33
+ "files": [
34
+ "dist",
35
+ "types"
36
+ ],
37
+ "scripts": {
38
+ "build": "rollup -c",
39
+ "js_sample": "node sample/js_sample.js",
40
+ "prepublishOnly": "npm run build",
41
+ "test": "uvu -r tsm test",
42
+ "ts_sample": "ts-node sample/ts_sample.ts",
43
+ "types": "tsc --noEmit"
44
+ },
45
+ "dependencies": {
46
+ "axios": "^1.6.0",
47
+ "dayjs": "^1.11.10"
48
+ },
49
+ "devDependencies": {
50
+ "@rollup/plugin-commonjs": "^21.1.0",
51
+ "@rollup/plugin-node-resolve": "13.1.3",
52
+ "rollup": "2.66.1",
53
+ "rollup-plugin-terser": "7.0.2",
54
+ "rollup-plugin-typescript2": "0.27.1",
55
+ "ts-node": "^10.9.1",
56
+ "tsm": "2.2.1",
57
+ "typescript": "^5.2.2",
58
+ "uvu": "0.5.3"
59
+ },
60
+ "engines": {
61
+ "node": ">=12"
62
+ },
63
+ "email": "dev.spiralmoon@gmail.com",
64
+ "umd:name": "maplestory-openapi"
65
+ }
@@ -0,0 +1,6 @@
1
+ export * from './maplestory/api/mapleStoryApi';
2
+ export * from './maplestory/api/mapleStoryApiError';
3
+ export * from './maplestory/api/dto/cubeHistoryDto';
4
+ export * from './maplestory/api/dto/cubeHistoryResponseDto';
5
+ export * from './maplestory/api/dto/cubeResultOptionDto';
6
+ export * from './maplestory/api/dto/potentialOptionGrade';
@@ -0,0 +1,86 @@
1
+ import { CubeResultOptionDto } from "./cubeResultOptionDto";
2
+ import { CubeHistoryDtoBody } from "../response/cubeHistoryDtoBody";
3
+ import { PotentialOptionGrade } from "./potentialOptionGrade";
4
+ /**
5
+ * 큐브히스토리 정보
6
+ */
7
+ declare class CubeHistoryDto {
8
+ /**
9
+ * 큐브 사용 내역에 대한 고유 식별자
10
+ */
11
+ id: string;
12
+ /**
13
+ * 캐릭터이름
14
+ */
15
+ characterName: string;
16
+ /**
17
+ * 월드 이름
18
+ */
19
+ worldName: string;
20
+ /**
21
+ * 큐브 사용 날짜
22
+ */
23
+ createDate: string;
24
+ /**
25
+ * 사용한 큐브
26
+ */
27
+ cubeType: string;
28
+ /**
29
+ * 큐브 사용 결과
30
+ */
31
+ itemUpgradeResult: string;
32
+ /**
33
+ * 미라클 타임 적용 여부
34
+ */
35
+ miracleTimeFlag: string;
36
+ /**
37
+ * 장비 분류
38
+ */
39
+ itemEquipPart: string;
40
+ /**
41
+ * 장비 레벨
42
+ */
43
+ itemLevel: number;
44
+ /**
45
+ * 큐브를 사용한 장비
46
+ */
47
+ targetItem: string;
48
+ /**
49
+ * 잠재능력 등급
50
+ */
51
+ potentialOptionGrade: string;
52
+ /**
53
+ * 에디셔널 잠재능력 등급
54
+ */
55
+ additionalPotentialOptionGrade: string;
56
+ /**
57
+ * 천장에 도달하여 확정 등급 상승한 여부
58
+ */
59
+ upgradeGuarantee: boolean;
60
+ /**
61
+ * 현재까지 쌓은 스택
62
+ */
63
+ upgradeGuaranteeCount: number;
64
+ /**
65
+ * 큐브 사용 전 잠재능력 옵션
66
+ */
67
+ beforePotentialOptions: CubeResultOptionDto[];
68
+ /**
69
+ * 큐브 사용 전 에디셔널 잠재능력 옵션
70
+ */
71
+ beforeAdditionalPotentialOptions: CubeResultOptionDto[];
72
+ /**
73
+ * 큐브 사용 후 잠재능력 옵션
74
+ */
75
+ afterPotentialOptions: CubeResultOptionDto[];
76
+ /**
77
+ * 큐브 사용 후 에디셔널 잠재능력 옵션
78
+ */
79
+ afterAdditionalPotentialOptions: CubeResultOptionDto[];
80
+ constructor(obj: CubeHistoryDtoBody);
81
+ get isItemUpgrade(): boolean;
82
+ get isMiracleTimeFlag(): boolean;
83
+ get potentialOptionGradeEnum(): PotentialOptionGrade;
84
+ get additionalPotentialOptionGradeEnum(): PotentialOptionGrade;
85
+ }
86
+ export { CubeHistoryDto };
@@ -0,0 +1,21 @@
1
+ import { CubeHistoryDto } from "./cubeHistoryDto";
2
+ import { CubeHistoryResponseDtoBody } from "../response/cubeHistoryResponseDtoBody";
3
+ /**
4
+ * 큐브히스토리 응답 정보
5
+ */
6
+ declare class CubeHistoryResponseDto {
7
+ /**
8
+ * 결과 건 수
9
+ */
10
+ count: number;
11
+ /**
12
+ * 큐브 히스토리
13
+ */
14
+ cubeHistories: CubeHistoryDto[];
15
+ /**
16
+ * 페이징 처리를 위한 cursor
17
+ */
18
+ nextCursor: string;
19
+ constructor(obj: CubeHistoryResponseDtoBody);
20
+ }
21
+ export { CubeHistoryResponseDto };
@@ -0,0 +1,18 @@
1
+ import { CubeResultOptionDtoBody } from "../response/cubeResultOptionDtoBody";
2
+ import { PotentialOptionGrade } from "./potentialOptionGrade";
3
+ /**
4
+ * 큐브 결과 옵션 정보
5
+ */
6
+ declare class CubeResultOptionDto {
7
+ /**
8
+ * 옵션 이름
9
+ */
10
+ value: string;
11
+ /**
12
+ * 옵션 등급
13
+ */
14
+ grade: string;
15
+ constructor(obj: CubeResultOptionDtoBody);
16
+ get gradeEnum(): PotentialOptionGrade;
17
+ }
18
+ export { CubeResultOptionDto };
@@ -0,0 +1,13 @@
1
+ declare enum PotentialOptionGrade {
2
+ RARE = 0,
3
+ EPIC = 1,
4
+ UNIQUE = 2,
5
+ LEGENDARY = 3
6
+ }
7
+ /**
8
+ * 한글로 정의된 잠재옵션 등급을 PotentialOptionGrade으로 변환합니다.
9
+ *
10
+ * @param text support only "레어", "에픽", "유니크", "레전드리"
11
+ */
12
+ declare const potentialOptionGradeFromString: (text: string) => PotentialOptionGrade;
13
+ export { PotentialOptionGrade, potentialOptionGradeFromString };
@@ -0,0 +1,38 @@
1
+ import { CubeHistoryResponseDto } from "./dto/cubeHistoryResponseDto";
2
+ declare class MapleStoryApi {
3
+ private readonly apiKey;
4
+ private static baseUrl;
5
+ private static kstOffset;
6
+ timeout: number;
7
+ constructor(apiKey: string);
8
+ /**
9
+ * 오늘 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
10
+ * 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.
11
+ *
12
+ * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
13
+ */
14
+ getCubeResult(count: number): Promise<CubeHistoryResponseDto>;
15
+ /**
16
+ * 지목한 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
17
+ * 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.
18
+ *
19
+ * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
20
+ * @param dateOptions 조회할 연월일 날짜 정보
21
+ */
22
+ getCubeResult(count: number, dateOptions: DateOptions): Promise<CubeHistoryResponseDto>;
23
+ /**
24
+ * 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
25
+ * 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.
26
+ *
27
+ * @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
28
+ * @param cursor
29
+ */
30
+ getCubeResult(count: number, cursor: string): Promise<CubeHistoryResponseDto>;
31
+ private buildHeaders;
32
+ }
33
+ type DateOptions = {
34
+ year: number;
35
+ month: number;
36
+ day: number;
37
+ };
38
+ export { MapleStoryApi };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 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
+ */
5
+ declare class MapleStoryApiError extends Error {
6
+ readonly name = "MapleStoryApiError";
7
+ readonly status: number;
8
+ readonly message: string;
9
+ constructor(params: {
10
+ status: number;
11
+ message: string;
12
+ });
13
+ }
14
+ export { MapleStoryApiError };
@@ -0,0 +1,22 @@
1
+ import { CubeResultOptionDtoBody } from "./cubeResultOptionDtoBody";
2
+ type CubeHistoryDtoBody = {
3
+ id: string;
4
+ character_name: string;
5
+ world_name: string;
6
+ create_date: string;
7
+ cube_type: string;
8
+ item_upgrade_result: string;
9
+ miracle_time_flag: string;
10
+ item_equip_part: string;
11
+ item_level: number;
12
+ target_item: string;
13
+ potential_option_grade: string;
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[];
21
+ };
22
+ export type { CubeHistoryDtoBody };
@@ -0,0 +1,7 @@
1
+ import { CubeHistoryDtoBody } from "./cubeHistoryDtoBody";
2
+ type CubeHistoryResponseDtoBody = {
3
+ count: number;
4
+ cube_histories: CubeHistoryDtoBody[];
5
+ next_cursor: string;
6
+ };
7
+ export type { CubeHistoryResponseDtoBody };
@@ -0,0 +1,5 @@
1
+ type CubeResultOptionDtoBody = {
2
+ value: string;
3
+ grade: string;
4
+ };
5
+ export type { CubeResultOptionDtoBody };