dnf-api 0.5.22 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +313 -313
  3. package/bun.lockb +0 -0
  4. package/dist/index.js +22 -35
  5. package/jest.config.js +12 -12
  6. package/package.json +37 -41
  7. package/src/api/auction.ts +67 -61
  8. package/src/api/characters.equip.ts +81 -53
  9. package/src/api/characters.skill.ts +52 -52
  10. package/src/api/characters.ts +91 -60
  11. package/src/api/index.ts +9 -9
  12. package/src/api/items.ts +27 -9
  13. package/src/api/server.ts +9 -9
  14. package/src/api/setitems.ts +34 -29
  15. package/src/index.ts +29 -18
  16. package/src/model/character.ts +51 -3
  17. package/src/model/index.ts +86 -62
  18. package/src/model/item.ts +74 -22
  19. package/src/model/setitem.ts +31 -31
  20. package/src/util/config.ts +20 -19
  21. package/src/util/index.ts +6 -6
  22. package/src/util/params.ts +14 -5
  23. package/src/util/query.ts +103 -109
  24. package/src/util/static.ts +51 -45
  25. package/dist/api/auction.d.ts +0 -24
  26. package/dist/api/auction.js +0 -58
  27. package/dist/api/characters.d.ts +0 -32
  28. package/dist/api/characters.equip.d.ts +0 -29
  29. package/dist/api/characters.equip.js +0 -51
  30. package/dist/api/characters.js +0 -58
  31. package/dist/api/characters.skill.d.ts +0 -29
  32. package/dist/api/characters.skill.js +0 -51
  33. package/dist/api/index.d.ts +0 -8
  34. package/dist/api/index.js +0 -23
  35. package/dist/api/items.d.ts +0 -15
  36. package/dist/api/items.js +0 -40
  37. package/dist/api/server.d.ts +0 -2
  38. package/dist/api/server.js +0 -9
  39. package/dist/api/setitems.d.ts +0 -15
  40. package/dist/api/setitems.js +0 -28
  41. package/dist/index.d.ts +0 -14
  42. package/dist/model/character.d.ts +0 -41
  43. package/dist/model/character.js +0 -2
  44. package/dist/model/index.d.ts +0 -56
  45. package/dist/model/index.js +0 -15
  46. package/dist/model/item.d.ts +0 -45
  47. package/dist/model/item.js +0 -2
  48. package/dist/model/setitem.d.ts +0 -24
  49. package/dist/model/setitem.js +0 -2
  50. package/dist/util/config.d.ts +0 -11
  51. package/dist/util/config.js +0 -12
  52. package/dist/util/index.d.ts +0 -5
  53. package/dist/util/index.js +0 -20
  54. package/dist/util/params.d.ts +0 -67
  55. package/dist/util/params.js +0 -2
  56. package/dist/util/query.d.ts +0 -14
  57. package/dist/util/query.js +0 -132
  58. package/dist/util/static.d.ts +0 -44
  59. package/dist/util/static.js +0 -53
  60. package/src/index.tmp.js +0 -48
@@ -1,56 +0,0 @@
1
- import * as Char from "./character";
2
- import * as Item from "./item";
3
- import * as SetItem from "./setitem";
4
- export { Char, Item, SetItem };
5
- export declare type DnfErrorResponse = {
6
- url: string;
7
- status: number;
8
- statusText: string;
9
- code: string;
10
- message: string;
11
- };
12
- export declare type DnfResponse<T> = {
13
- data?: T;
14
- error?: DnfErrorResponse;
15
- };
16
- export declare type Auction = {
17
- auctionNo: number;
18
- regDate: Date;
19
- expireDate: Date;
20
- itemId: string;
21
- itemName: string;
22
- itemAvailableLevel: number;
23
- itemRarity: string;
24
- itemType: string;
25
- itemTypeDetail: string;
26
- refine: number;
27
- reinforce: number;
28
- amplificationName: string;
29
- count: number;
30
- price: number;
31
- currentPrice: number;
32
- unitPrice: number;
33
- averagePrice: number;
34
- };
35
- export declare type AuctionSolid = {
36
- soldDate: string;
37
- itemId: string;
38
- itemName: string;
39
- itemAvailableLevel: number;
40
- itemRarity: string;
41
- itemType: string;
42
- itemTypeDetail: string;
43
- refine: number;
44
- reinforce: number;
45
- amplificationName: string | null;
46
- count: number;
47
- price: number;
48
- unitPrice: number;
49
- };
50
- export declare type Rows<T> = {
51
- rows: T[];
52
- };
53
- export declare type Server = {
54
- serverId: string;
55
- serverName: string;
56
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importStar = (this && this.__importStar) || function (mod) {
3
- if (mod && mod.__esModule) return mod;
4
- var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
7
- return result;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const Char = __importStar(require("./character"));
11
- exports.Char = Char;
12
- const Item = __importStar(require("./item"));
13
- exports.Item = Item;
14
- const SetItem = __importStar(require("./setitem"));
15
- exports.SetItem = SetItem;
@@ -1,45 +0,0 @@
1
- import * as Static from "../util/static";
2
- export declare type Item = {
3
- itemId: string;
4
- itemName: string;
5
- itemRarity: Static.Rarity;
6
- itemType: string;
7
- itemTypeDetail: string;
8
- itemAvailableLevel: number;
9
- };
10
- export declare type Detail = {
11
- itemId: string;
12
- itemName: string;
13
- itemRarity: Static.Rarity;
14
- itemType: string;
15
- itemTypeDetail: string;
16
- itemAvailableLevel: number;
17
- itemObtainInfo: string;
18
- itemExplain: string;
19
- itemExplainDetail: string;
20
- itemFlavorText: string;
21
- setItemId: string;
22
- setItemName: string;
23
- itemStatus?: itemStatus[];
24
- cardInfo?: cardInfo[];
25
- };
26
- export declare type itemStatus = {
27
- name: string;
28
- value: number;
29
- };
30
- export declare type cardInfo = {
31
- slots: cardInfoSlot[];
32
- enchant: cardInfoEnchant[];
33
- };
34
- export declare type cardInfoSlot = {
35
- slotId: string;
36
- slotName: string;
37
- };
38
- export declare type cardInfoEnchant = {
39
- status: cardInfoEnchantStatus[];
40
- upgrade: number;
41
- };
42
- export declare type cardInfoEnchantStatus = {
43
- name: string;
44
- value: number;
45
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- export declare type SetItem = {
2
- setItemId: string;
3
- setItemName: string;
4
- };
5
- export declare type Detail = {
6
- setItemId: string;
7
- setItemName: string;
8
- setItems: [{
9
- slotId: string;
10
- slotName: string;
11
- itemId: string;
12
- itemName: string;
13
- itemRarity: string;
14
- }];
15
- setItemOption: [{
16
- optionNo: number;
17
- explain: string;
18
- detailExplain: string;
19
- status: [{
20
- name: string;
21
- value: number;
22
- }];
23
- }];
24
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- export interface IConfig {
2
- key: string;
3
- hideOnErrorApiKey: boolean;
4
- hidekeyText: string;
5
- axiosTimeout: number;
6
- returnJSON: boolean;
7
- responeHeader: boolean;
8
- showURL: boolean;
9
- }
10
- declare let defaultConfig: IConfig;
11
- export default defaultConfig;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- let defaultConfig = {
4
- key: "",
5
- hideOnErrorApiKey: true,
6
- hidekeyText: "{HIDEKEY}",
7
- axiosTimeout: 5000,
8
- returnJSON: false,
9
- responeHeader: false,
10
- showURL: false
11
- };
12
- exports.default = defaultConfig;
@@ -1,5 +0,0 @@
1
- import Config from "./config";
2
- import Query from "./query";
3
- import * as Params from "./params";
4
- import * as Static from "./static";
5
- export { Config, Query, Static, Params };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- var __importStar = (this && this.__importStar) || function (mod) {
6
- if (mod && mod.__esModule) return mod;
7
- var result = {};
8
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9
- result["default"] = mod;
10
- return result;
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- const config_1 = __importDefault(require("./config"));
14
- exports.Config = config_1.default;
15
- const query_1 = __importDefault(require("./query"));
16
- exports.Query = query_1.default;
17
- const Params = __importStar(require("./params"));
18
- exports.Params = Params;
19
- const Static = __importStar(require("./static"));
20
- exports.Static = Static;
@@ -1,67 +0,0 @@
1
- import * as Static from "./static";
2
- export interface QueryOptions {
3
- base: string;
4
- params?: any;
5
- }
6
- export interface ICharParams {
7
- characterName?: string;
8
- jobId?: string;
9
- jobGrowId?: string;
10
- wordType?: Static.CharactersWordType;
11
- limit?: number;
12
- }
13
- export interface ITimeLine {
14
- startDate?: Date;
15
- endDate?: Date;
16
- limit?: number;
17
- code?: string;
18
- next?: string;
19
- }
20
- export interface IAuction {
21
- limit?: number;
22
- sort?: IAuctionSort;
23
- itemId?: string;
24
- itemName?: string;
25
- wordType?: Static.AuctionWordType;
26
- }
27
- export interface IAuctionSort {
28
- unitPrice?: Static.Sort;
29
- reinforce?: Static.Sort;
30
- auctionNo?: Static.Sort;
31
- }
32
- export interface IAuctionQuery {
33
- minLevel?: number;
34
- maxLevel?: number;
35
- raity?: Static.Rarity;
36
- minReinforce?: number;
37
- maxReinforce?: number;
38
- minRefine?: number;
39
- maxRefine?: number;
40
- }
41
- export interface IActionSoldOption {
42
- limit?: number;
43
- wordType?: Static.AuctionWordType;
44
- wordShort?: boolean;
45
- itemId?: string;
46
- itemName?: string;
47
- }
48
- export interface IItem {
49
- limit?: number;
50
- itemName?: string;
51
- wordType?: Static.AuctionWordType;
52
- q?: IItemQuery;
53
- }
54
- export interface IItemQuery {
55
- minLevel?: number;
56
- maxLevel?: number;
57
- rarity?: Static.Rarity;
58
- trade?: boolean;
59
- }
60
- export interface ISetItem {
61
- setItemName?: string;
62
- limit?: number;
63
- wordType?: Static.AuctionWordType;
64
- }
65
- export interface ISkill {
66
- jobGrowId: string;
67
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +0,0 @@
1
- import * as Model from "../model";
2
- export default class Request {
3
- static UriBuilder(...args: any[]): string;
4
- static queryBuilder(query: any): string;
5
- /**
6
- * 던전앤파이터 API 서버에 응답을 요청하는 함수 입니다.
7
- * 해당 함수를 직접 호출 하는것을 권장하지 않습니다.
8
- *
9
- * @param {object} opt (요청을 보낼 Parameter값)
10
- * @returns
11
- */
12
- static Request<T>(opt?: any, method?: string): Promise<Model.DnfResponse<T>>;
13
- static makeItemQuery(query: any): string;
14
- }
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
18
- result["default"] = mod;
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- const axios_1 = __importDefault(require("axios"));
23
- const querystring_1 = __importDefault(require("querystring"));
24
- // import urlencode from "urlencode";
25
- // import consola from "consola";
26
- const consola = require("consola");
27
- const Util = __importStar(require("./"));
28
- const sender = axios_1.default.create({
29
- baseURL: "https://api.neople.co.kr",
30
- timeout: Util.Config.axiosTimeout,
31
- });
32
- const showUrl = (url) => {
33
- return url.replace(Util.Config.key, Util.Config.hidekeyText);
34
- };
35
- class Request {
36
- static UriBuilder(...args) {
37
- return args.join("/");
38
- }
39
- static queryBuilder(query) {
40
- let qString = [];
41
- for (let key in query) {
42
- qString.push(`${key}:${query[key]},`);
43
- }
44
- return qString.join(",");
45
- }
46
- /**
47
- * 던전앤파이터 API 서버에 응답을 요청하는 함수 입니다.
48
- * 해당 함수를 직접 호출 하는것을 권장하지 않습니다.
49
- *
50
- * @param {object} opt (요청을 보낼 Parameter값)
51
- * @returns
52
- */
53
- static Request(opt = {}, method = "GET") {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- if (!Util.Config.key || Util.Config.key == "") {
56
- consola.error("Please change to your api key. ");
57
- }
58
- if (opt.params == undefined)
59
- opt.params = {};
60
- if (opt.params.q)
61
- opt.params.q = this.queryBuilder(opt.params.q);
62
- opt.params.apikey = Util.Config.key;
63
- opt.url = `${opt.base}?${querystring_1.default.stringify(opt.params)}`;
64
- if (Util.Config.showURL)
65
- console.log(showUrl(opt.url));
66
- let responseData;
67
- switch (method.toLowerCase()) {
68
- case "post":
69
- responseData = yield sender
70
- .post(opt.url)
71
- .then((res) => {
72
- let data;
73
- if (res.data.rows)
74
- data = res.data.rows;
75
- else
76
- data = res.data;
77
- return { data };
78
- })
79
- .catch((err) => {
80
- if (err.response) {
81
- let error = {
82
- url: showUrl(opt.url),
83
- status: err.response.status || 0,
84
- statusText: err.response.statusText,
85
- code: err.response.data.error.code,
86
- message: err.response.data.error.message,
87
- };
88
- return { error };
89
- }
90
- else {
91
- return { err: err };
92
- }
93
- });
94
- break;
95
- case "get":
96
- default:
97
- responseData = yield sender
98
- .get(opt.url)
99
- .then((res) => {
100
- let data;
101
- if (res.data.rows)
102
- data = res.data.rows;
103
- else
104
- data = res.data;
105
- return { data };
106
- })
107
- .catch((err) => {
108
- if (err.response) {
109
- let error = {
110
- url: showUrl(opt.url),
111
- status: err.response.status || 0,
112
- statusText: err.response.statusText,
113
- code: err.response.data.error.code,
114
- message: err.response.data.error.message,
115
- };
116
- return { error };
117
- }
118
- else {
119
- return { err: err };
120
- }
121
- });
122
- break;
123
- }
124
- return responseData;
125
- });
126
- }
127
- static makeItemQuery(query) {
128
- // return JSON.stringify(query).replace(/\"|\{|\}/gi, "");
129
- return encodeURI(query);
130
- }
131
- }
132
- exports.default = Request;
@@ -1,44 +0,0 @@
1
- export declare enum Server {
2
- Cain = "cain",
3
- Diregie = "diregie",
4
- Siroco = "siroco",
5
- Prey = "prey",
6
- Casillas = "casillas",
7
- Hilder = "hilder",
8
- Anton = "anton",
9
- Bakal = "bakal"
10
- }
11
- export declare enum Sort {
12
- Asc = "asc",
13
- Desc = "desc"
14
- }
15
- export declare enum Rarity {
16
- Common = "\uCEE4\uBA3C",
17
- Uncommon = "\uC5B8\uCEE4\uBA3C",
18
- Rare = "\uB808\uC5B4",
19
- Unique = "\uC720\uB2C8\uD06C",
20
- Eqic = "\uC5D0\uD53D",
21
- Chronicle = "\uD06C\uB85C\uB2C8\uD074",
22
- Legendary = "\uB808\uC804\uB354\uB9AC"
23
- }
24
- export declare enum AuctionWordType {
25
- Match = "match",
26
- Front = "front",
27
- Full = "full"
28
- }
29
- export declare enum WordType {
30
- Match = "match",
31
- Front = "front",
32
- Full = "full"
33
- }
34
- export declare enum CharactersWordType {
35
- Match = "match",
36
- Full = "full"
37
- }
38
- export declare enum BaseUri {
39
- Servers = "df/servers",
40
- Auction = "df/auction",
41
- AuctionSold = "df/auction-sold",
42
- Item = "df/items",
43
- SetItem = "df/setitems"
44
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Server;
4
- (function (Server) {
5
- Server["Cain"] = "cain";
6
- Server["Diregie"] = "diregie";
7
- Server["Siroco"] = "siroco";
8
- Server["Prey"] = "prey";
9
- Server["Casillas"] = "casillas";
10
- Server["Hilder"] = "hilder";
11
- Server["Anton"] = "anton";
12
- Server["Bakal"] = "bakal";
13
- })(Server = exports.Server || (exports.Server = {}));
14
- var Sort;
15
- (function (Sort) {
16
- Sort["Asc"] = "asc";
17
- Sort["Desc"] = "desc";
18
- })(Sort = exports.Sort || (exports.Sort = {}));
19
- var Rarity;
20
- (function (Rarity) {
21
- Rarity["Common"] = "\uCEE4\uBA3C";
22
- Rarity["Uncommon"] = "\uC5B8\uCEE4\uBA3C";
23
- Rarity["Rare"] = "\uB808\uC5B4";
24
- Rarity["Unique"] = "\uC720\uB2C8\uD06C";
25
- Rarity["Eqic"] = "\uC5D0\uD53D";
26
- Rarity["Chronicle"] = "\uD06C\uB85C\uB2C8\uD074";
27
- Rarity["Legendary"] = "\uB808\uC804\uB354\uB9AC";
28
- })(Rarity = exports.Rarity || (exports.Rarity = {}));
29
- var AuctionWordType;
30
- (function (AuctionWordType) {
31
- AuctionWordType["Match"] = "match";
32
- AuctionWordType["Front"] = "front";
33
- AuctionWordType["Full"] = "full";
34
- })(AuctionWordType = exports.AuctionWordType || (exports.AuctionWordType = {}));
35
- var WordType;
36
- (function (WordType) {
37
- WordType["Match"] = "match";
38
- WordType["Front"] = "front";
39
- WordType["Full"] = "full";
40
- })(WordType = exports.WordType || (exports.WordType = {}));
41
- var CharactersWordType;
42
- (function (CharactersWordType) {
43
- CharactersWordType["Match"] = "match";
44
- CharactersWordType["Full"] = "full";
45
- })(CharactersWordType = exports.CharactersWordType || (exports.CharactersWordType = {}));
46
- var BaseUri;
47
- (function (BaseUri) {
48
- BaseUri["Servers"] = "df/servers";
49
- BaseUri["Auction"] = "df/auction";
50
- BaseUri["AuctionSold"] = "df/auction-sold";
51
- BaseUri["Item"] = "df/items";
52
- BaseUri["SetItem"] = "df/setitems";
53
- })(BaseUri = exports.BaseUri || (exports.BaseUri = {}));
package/src/index.tmp.js DELETED
@@ -1,48 +0,0 @@
1
- import config from "./config/config";
2
-
3
- import characters from "./api/characters";
4
- import auction from "./api/auction";
5
- import items from "./api/items";
6
- import setitems from "./api/setitems";
7
-
8
- import request from "./request";
9
-
10
- const dnfApi = {
11
- opt: {},
12
- servers: () => {
13
- let opt = {
14
- base: "df/servers",
15
- };
16
- return request(opt);
17
- },
18
- characters: characters,
19
- auction: auction,
20
- items: items,
21
- jobs: () => {
22
- let opt = {
23
- base: "df/jobs",
24
- };
25
- return request(opt);
26
- },
27
- setitems: setitems,
28
- setOptions: function(opt) {
29
- //자신의 API키
30
- this.opt.key = opt.key || "";
31
- //respone오류 에서 자신의 API KEY갑을 숨겨서 표시합니다.
32
- this.opt.hideOnErrorApiKey = opt.hideOnErrorApiKey || true;
33
- this.opt.hidekeyText = opt.hidekeyText || "{HIDEKEY}";
34
- //요청후 기다리는 최대 시간입니다 (ms)
35
- this.opt.axiosTimeout = opt.axiosTimeout || 5000;
36
- //응답에 대한 정보를 JSON형태로 받습니다.
37
- this.opt.returnJSON = opt.returnJSON || false;
38
- //응답내용을 상세하게 출력하도록 변경합니다.
39
- this.opt.responeHeader = opt.responeHeader || false;
40
- },
41
- };
42
-
43
- dnfApi.config = config;
44
- //dnfApi.prototype.config = config;
45
- //console.log(dnfApi.opt);
46
- //dnfApi.prototype.opt = dnfApi.opt;
47
-
48
- export default dnfApi;