maplestory-openapi 1.0.1 → 1.1.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
@@ -13,7 +13,7 @@ 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.0.1 # Replace with the latest version
16
+ npm install maplestory-openapi@1.1.0 # Replace with the latest version
17
17
  ```
18
18
 
19
19
  ## Usage
package/dist/index.js CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  var axios = require('axios');
4
4
  var dayjs = require('dayjs');
5
+ var xml2js = require('xml2js');
5
6
 
6
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
8
 
8
9
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
9
10
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
11
+ var xml2js__default = /*#__PURE__*/_interopDefaultLegacy(xml2js);
10
12
 
11
13
  exports.PotentialOptionGrade = void 0;
12
14
  (function (PotentialOptionGrade) {
@@ -191,6 +193,35 @@ class CubeHistoryResponseDto {
191
193
  }
192
194
  }
193
195
 
196
+ /**
197
+ * 서버 점검 정보
198
+ */
199
+ class InspectionInfoDto {
200
+ /**
201
+ * 서비스 코드
202
+ */
203
+ serviceCode;
204
+ /**
205
+ * 점검 시작 시각
206
+ */
207
+ startDateTime;
208
+ /**
209
+ * 점검 종료 시각
210
+ */
211
+ endDateTime;
212
+ /**
213
+ * 점검 안내 제목
214
+ */
215
+ strObstacleContents;
216
+ constructor(obj) {
217
+ const inspectionInfoTag = obj["soap:Envelope"]['soap:Body'][0]['GetInspectionInfoResponse'][0]['GetInspectionInfoResult'][0]['diffgr:diffgram'][0]['NewDataSet'][0]['InspectionInfo'][0];
218
+ this.serviceCode = Number(inspectionInfoTag.serviceCode[0]);
219
+ this.startDateTime = new Date(inspectionInfoTag.startDateTime[0]);
220
+ this.endDateTime = new Date(inspectionInfoTag.endDateTime[0]);
221
+ this.strObstacleContents = inspectionInfoTag.strObstacleContents[0];
222
+ }
223
+ }
224
+
194
225
  /**
195
226
  * MapleStory OpenAPI error.<br>
196
227
  * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
@@ -273,6 +304,42 @@ class MapleStoryApi {
273
304
  throw e;
274
305
  }
275
306
  }
307
+ /**
308
+ * 서버 점검 정보를 조회합니다.
309
+ */
310
+ async getInspectionInfo() {
311
+ const xmlBuilder = new xml2js__default["default"].Builder();
312
+ const soapEnvelop = {
313
+ 'soap:Envelope': {
314
+ $: {
315
+ 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
316
+ 'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
317
+ 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/'
318
+ },
319
+ 'soap:Body': {
320
+ 'GetInspectionInfo': {
321
+ $: {
322
+ 'xmlns': 'https://api.maplestory.nexon.com/soap/'
323
+ }
324
+ }
325
+ }
326
+ }
327
+ };
328
+ const baseUrl = 'https://api.maplestory.nexon.com/';
329
+ const path = 'soap/maplestory.asmx';
330
+ const headers = {
331
+ 'SOAPAction': 'https://api.maplestory.nexon.com/soap/GetInspectionInfo',
332
+ 'Content-Type': 'text/xml; charset=utf-8'
333
+ };
334
+ const body = xmlBuilder.buildObject(soapEnvelop);
335
+ const response = await axios__default["default"].post(path, body, {
336
+ baseURL: baseUrl,
337
+ timeout: this.timeout,
338
+ headers,
339
+ });
340
+ const xml = await xml2js__default["default"].parseStringPromise(response.data);
341
+ return new InspectionInfoDto(xml);
342
+ }
276
343
  buildHeaders() {
277
344
  return {
278
345
  'authorization': this.apiKey
@@ -283,6 +350,7 @@ class MapleStoryApi {
283
350
  exports.CubeHistoryDto = CubeHistoryDto;
284
351
  exports.CubeHistoryResponseDto = CubeHistoryResponseDto;
285
352
  exports.CubeResultOptionDto = CubeResultOptionDto;
353
+ exports.InspectionInfoDto = InspectionInfoDto;
286
354
  exports.MapleStoryApi = MapleStoryApi;
287
355
  exports.MapleStoryApiError = MapleStoryApiError;
288
356
  exports.potentialOptionGradeFromString = potentialOptionGradeFromString;
package/dist/index.min.js CHANGED
@@ -1 +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}));
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}));
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import axios, { AxiosError } from 'axios';
2
2
  import dayjs from 'dayjs';
3
+ import xml2js from 'xml2js';
3
4
 
4
5
  var PotentialOptionGrade;
5
6
  (function (PotentialOptionGrade) {
@@ -184,6 +185,35 @@ class CubeHistoryResponseDto {
184
185
  }
185
186
  }
186
187
 
188
+ /**
189
+ * 서버 점검 정보
190
+ */
191
+ class InspectionInfoDto {
192
+ /**
193
+ * 서비스 코드
194
+ */
195
+ serviceCode;
196
+ /**
197
+ * 점검 시작 시각
198
+ */
199
+ startDateTime;
200
+ /**
201
+ * 점검 종료 시각
202
+ */
203
+ endDateTime;
204
+ /**
205
+ * 점검 안내 제목
206
+ */
207
+ strObstacleContents;
208
+ constructor(obj) {
209
+ const inspectionInfoTag = obj["soap:Envelope"]['soap:Body'][0]['GetInspectionInfoResponse'][0]['GetInspectionInfoResult'][0]['diffgr:diffgram'][0]['NewDataSet'][0]['InspectionInfo'][0];
210
+ this.serviceCode = Number(inspectionInfoTag.serviceCode[0]);
211
+ this.startDateTime = new Date(inspectionInfoTag.startDateTime[0]);
212
+ this.endDateTime = new Date(inspectionInfoTag.endDateTime[0]);
213
+ this.strObstacleContents = inspectionInfoTag.strObstacleContents[0];
214
+ }
215
+ }
216
+
187
217
  /**
188
218
  * MapleStory OpenAPI error.<br>
189
219
  * Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
@@ -266,6 +296,42 @@ class MapleStoryApi {
266
296
  throw e;
267
297
  }
268
298
  }
299
+ /**
300
+ * 서버 점검 정보를 조회합니다.
301
+ */
302
+ async getInspectionInfo() {
303
+ const xmlBuilder = new xml2js.Builder();
304
+ const soapEnvelop = {
305
+ 'soap:Envelope': {
306
+ $: {
307
+ 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
308
+ 'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
309
+ 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/'
310
+ },
311
+ 'soap:Body': {
312
+ 'GetInspectionInfo': {
313
+ $: {
314
+ 'xmlns': 'https://api.maplestory.nexon.com/soap/'
315
+ }
316
+ }
317
+ }
318
+ }
319
+ };
320
+ const baseUrl = 'https://api.maplestory.nexon.com/';
321
+ const path = 'soap/maplestory.asmx';
322
+ const headers = {
323
+ 'SOAPAction': 'https://api.maplestory.nexon.com/soap/GetInspectionInfo',
324
+ 'Content-Type': 'text/xml; charset=utf-8'
325
+ };
326
+ const body = xmlBuilder.buildObject(soapEnvelop);
327
+ const response = await axios.post(path, body, {
328
+ baseURL: baseUrl,
329
+ timeout: this.timeout,
330
+ headers,
331
+ });
332
+ const xml = await xml2js.parseStringPromise(response.data);
333
+ return new InspectionInfoDto(xml);
334
+ }
269
335
  buildHeaders() {
270
336
  return {
271
337
  'authorization': this.apiKey
@@ -273,4 +339,4 @@ class MapleStoryApi {
273
339
  }
274
340
  }
275
341
 
276
- export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
342
+ export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, InspectionInfoDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "maplestory-openapi",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
+ "description": "This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.",
4
5
  "keywords": [
5
6
  "maplestory",
6
7
  "maplestory openapi",
@@ -9,7 +10,6 @@
9
10
  "nexon",
10
11
  "nexon developers"
11
12
  ],
12
- "description": "This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.",
13
13
  "homepage": "https://github.com/SpiralMoon/maplestory.openapi",
14
14
  "bugs": {
15
15
  "url": "https://github.com/SpiralMoon/maplestory.openapi/issues"
@@ -45,11 +45,13 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "axios": "^1.6.0",
48
- "dayjs": "^1.11.10"
48
+ "dayjs": "^1.11.10",
49
+ "xml2js": "^0.6.2"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@rollup/plugin-commonjs": "^21.1.0",
52
53
  "@rollup/plugin-node-resolve": "13.1.3",
54
+ "@types/xml2js": "^0.4.14",
53
55
  "rollup": "2.66.1",
54
56
  "rollup-plugin-terser": "7.0.2",
55
57
  "rollup-plugin-typescript2": "0.27.1",
package/types/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './maplestory/api/mapleStoryApiError';
3
3
  export * from './maplestory/api/dto/cubeHistoryDto';
4
4
  export * from './maplestory/api/dto/cubeHistoryResponseDto';
5
5
  export * from './maplestory/api/dto/cubeResultOptionDto';
6
+ export * from './maplestory/api/dto/inspectionInfoDto';
6
7
  export * from './maplestory/api/dto/potentialOptionGrade';
@@ -0,0 +1,24 @@
1
+ import { InspectionInfoSoapBody } from "../response/inspectionInfoSoapBody";
2
+ /**
3
+ * 서버 점검 정보
4
+ */
5
+ declare class InspectionInfoDto {
6
+ /**
7
+ * 서비스 코드
8
+ */
9
+ serviceCode: number;
10
+ /**
11
+ * 점검 시작 시각
12
+ */
13
+ startDateTime: Date;
14
+ /**
15
+ * 점검 종료 시각
16
+ */
17
+ endDateTime: Date;
18
+ /**
19
+ * 점검 안내 제목
20
+ */
21
+ strObstacleContents: string;
22
+ constructor(obj: InspectionInfoSoapBody);
23
+ }
24
+ export { InspectionInfoDto };
@@ -1,4 +1,5 @@
1
1
  import { CubeHistoryResponseDto } from "./dto/cubeHistoryResponseDto";
2
+ import { InspectionInfoDto } from "./dto/inspectionInfoDto";
2
3
  declare class MapleStoryApi {
3
4
  private readonly apiKey;
4
5
  private static baseUrl;
@@ -31,6 +32,10 @@ declare class MapleStoryApi {
31
32
  * @param cursor
32
33
  */
33
34
  getCubeResult(count: number, cursor: string): Promise<CubeHistoryResponseDto>;
35
+ /**
36
+ * 서버 점검 정보를 조회합니다.
37
+ */
38
+ getInspectionInfo(): Promise<InspectionInfoDto>;
34
39
  private buildHeaders;
35
40
  }
36
41
  type DateOptions = {
@@ -0,0 +1,137 @@
1
+ type InspectionInfoSoapBody = {
2
+ 'soap:Envelope': {
3
+ "$": {
4
+ "xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/";
5
+ "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance";
6
+ "xmlns:xsd": "http://www.w3.org/2001/XMLSchema";
7
+ };
8
+ "soap:Body": [
9
+ {
10
+ "GetInspectionInfoResponse": [
11
+ {
12
+ "$": {
13
+ "xmlns": "https://api.maplestory.nexon.com/soap/";
14
+ };
15
+ "GetInspectionInfoResult": [
16
+ {
17
+ "xs:schema": [
18
+ {
19
+ "$": {
20
+ "id": "NewDataSet";
21
+ "xmlns": "";
22
+ "xmlns:xs": "http://www.w3.org/2001/XMLSchema";
23
+ "xmlns:msdata": "urn:schemas-microsoft-com:xml-msdata";
24
+ };
25
+ "xs:element": [
26
+ {
27
+ "$": {
28
+ "name": "NewDataSet";
29
+ "msdata:IsDataSet": "true";
30
+ "msdata:UseCurrentLocale": "true";
31
+ };
32
+ "xs:complexType": [
33
+ {
34
+ "xs:choice": [
35
+ {
36
+ "$": {
37
+ "minOccurs": "0";
38
+ "maxOccurs": "unbounded";
39
+ };
40
+ "xs:element": [
41
+ {
42
+ "$": {
43
+ "name": "InspectionInfo";
44
+ };
45
+ "xs:complexType": [
46
+ {
47
+ "xs:sequence": [
48
+ {
49
+ "xs:element": [
50
+ {
51
+ "$": {
52
+ "name": "serviceCode";
53
+ "type": "xs:unsignedByte";
54
+ "minOccurs": "0";
55
+ };
56
+ },
57
+ {
58
+ "$": {
59
+ "name": "startDateTime";
60
+ "type": "xs:dateTime";
61
+ "minOccurs": "0";
62
+ };
63
+ },
64
+ {
65
+ "$": {
66
+ "name": "endDateTime";
67
+ "type": "xs:dateTime";
68
+ "minOccurs": "0";
69
+ };
70
+ },
71
+ {
72
+ "$": {
73
+ "name": "strObstacleContents";
74
+ "type": "xs:string";
75
+ "minOccurs": "0";
76
+ };
77
+ }
78
+ ];
79
+ }
80
+ ];
81
+ }
82
+ ];
83
+ }
84
+ ];
85
+ }
86
+ ];
87
+ }
88
+ ];
89
+ }
90
+ ];
91
+ }
92
+ ];
93
+ "diffgr:diffgram": [
94
+ {
95
+ "$": {
96
+ "xmlns:msdata": "urn:schemas-microsoft-com:xml-msdata";
97
+ "xmlns:diffgr": "urn:schemas-microsoft-com:xml-diffgram-v1";
98
+ };
99
+ "NewDataSet": [
100
+ {
101
+ "$": {
102
+ "xmlns": "";
103
+ };
104
+ "InspectionInfo": [
105
+ {
106
+ "$": {
107
+ "diffgr:id": "InspectionInfo1";
108
+ "msdata:rowOrder": "0";
109
+ "diffgr:hasChanges": "inserted";
110
+ };
111
+ "serviceCode": [
112
+ string
113
+ ];
114
+ "startDateTime": [
115
+ string
116
+ ];
117
+ "endDateTime": [
118
+ string
119
+ ];
120
+ "strObstacleContents": [
121
+ string
122
+ ];
123
+ }
124
+ ];
125
+ }
126
+ ];
127
+ }
128
+ ];
129
+ }
130
+ ];
131
+ }
132
+ ];
133
+ }
134
+ ];
135
+ };
136
+ };
137
+ export type { InspectionInfoSoapBody };