dnf-api 0.5.21 → 0.6.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.
Files changed (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +313 -313
  3. package/bun.lockb +0 -0
  4. package/jest.config.js +12 -12
  5. package/package.json +37 -41
  6. package/src/api/auction.ts +67 -61
  7. package/src/api/characters.equip.ts +81 -53
  8. package/src/api/characters.skill.ts +52 -52
  9. package/src/api/characters.ts +91 -60
  10. package/src/api/index.ts +9 -9
  11. package/src/api/items.ts +27 -9
  12. package/src/api/server.ts +9 -9
  13. package/src/api/setitems.ts +34 -29
  14. package/src/index.ts +29 -18
  15. package/src/model/character.ts +51 -3
  16. package/src/model/index.ts +86 -62
  17. package/src/model/item.ts +74 -22
  18. package/src/model/setitem.ts +31 -31
  19. package/src/util/config.ts +20 -19
  20. package/src/util/index.ts +6 -6
  21. package/src/util/params.ts +14 -5
  22. package/src/util/query.ts +103 -109
  23. package/src/util/static.ts +51 -45
  24. package/dist/api/auction.d.ts +0 -24
  25. package/dist/api/auction.js +0 -58
  26. package/dist/api/characters.d.ts +0 -32
  27. package/dist/api/characters.equip.d.ts +0 -29
  28. package/dist/api/characters.equip.js +0 -51
  29. package/dist/api/characters.js +0 -58
  30. package/dist/api/characters.skill.d.ts +0 -29
  31. package/dist/api/characters.skill.js +0 -51
  32. package/dist/api/index.d.ts +0 -8
  33. package/dist/api/index.js +0 -23
  34. package/dist/api/items.d.ts +0 -15
  35. package/dist/api/items.js +0 -40
  36. package/dist/api/server.d.ts +0 -2
  37. package/dist/api/server.js +0 -9
  38. package/dist/api/setitems.d.ts +0 -15
  39. package/dist/api/setitems.js +0 -28
  40. package/dist/index.d.ts +0 -14
  41. package/dist/index.js +0 -35
  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
package/src/api/items.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Query, Static, Params } from "../util";
2
- import * as Model from "../model";
1
+ import type * as Model from "../model";
2
+ import { type Params, Query, Static } from "../util";
3
3
 
4
4
  /**
5
5
  * 현재 인게임에서 획득 가능한 아이템의 경우만 검색 가능합니다.
@@ -7,25 +7,43 @@ import * as Model from "../model";
7
7
  * @param {string} itemName 검색할 아이템의 명칭
8
8
  * @param {string} params 선택적 요청변수의 Object입니다.
9
9
  */
10
- export const item = async (itemName: string, params: Params.IItem = {}): Promise<Model.DnfResponse<Model.Item.Item[]>> => {
10
+ export const item = async (itemName: string, params: Params.IItem = {}) => {
11
11
  // if (params === undefined) params = {};
12
12
  params.itemName = itemName;
13
13
  // if (query) params.q = Query.makeItemQuery(query);
14
14
  //let querystring =
15
- let opt = {
15
+ const opt = {
16
16
  base: Query.UriBuilder(Static.BaseUri.Item),
17
- params: params,
17
+ params: {
18
+ ...params,
19
+ ...(params.hashtag
20
+ ? { hashtag: Query.QueryBuilder(params.hashtag) }
21
+ : {}),
22
+ },
18
23
  };
19
- return await Query.Request<Model.Item.Item[]>(opt);
24
+ return await Query.Request<Model.Rows<Model.Item.Item>>(opt);
20
25
  };
21
26
  /**
22
27
  * 해당하는 아이템의 상세정보를 요청합니다.
23
28
  *
24
29
  * @param {string} itemId 검색할 아이템의 ID
25
30
  */
26
- export const detail = (itemId: string): Promise<Model.DnfResponse<Model.Item.Detail>> => {
27
- let opt = {
28
- base: Query.UriBuilder(Static.BaseUri.Item, itemId),
31
+ export const detail = (itemId: string) => {
32
+ const opt = {
33
+ base: Query.UriBuilder(Static.BaseUri.Item, itemId),
29
34
  };
30
35
  return Query.Request<Model.Item.Detail>(opt);
31
36
  };
37
+
38
+ /**
39
+ * 26. 아이템 상점 판매 정보 조회
40
+ * 인게임 백과사전 기준의 상점 판매 95레벨 에픽, 100레벨 이상 유니크, 레전더리, 에픽 장비가 조회 가능 합니다.
41
+ *
42
+ * @param {string} itemId 검색할 아이템의 ID
43
+ */
44
+ // export const shop = (itemId: string) => {
45
+ // const opt = {
46
+ // base: Query.UriBuilder(Static.BaseUri.Item, itemId),
47
+ // };
48
+ // return Query.Request<Model.Item.Detail>(opt);
49
+ // };
package/src/api/server.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Query, Static, Params } from "../util";
2
- import * as Model from "../model";
3
-
4
- export const List = (): Promise<Model.DnfResponse<Model.Server[]>> => {
5
- let opt = {
6
- base: Query.UriBuilder(Static.BaseUri.Servers),
7
- };
8
- return Query.Request<Model.Server[]>(opt);
9
- };
1
+ import type * as Model from "../model";
2
+ import { Query, Static } from "../util";
3
+
4
+ export const List = (): Promise<Model.DnfResponse<Model.Server[]>> => {
5
+ const opt = {
6
+ base: Query.UriBuilder(Static.BaseUri.Servers),
7
+ };
8
+ return Query.Request<Model.Server[]>(opt);
9
+ };
@@ -1,29 +1,34 @@
1
- import { Query, Static, Params } from "../util";
2
- import * as Model from "../model";
3
-
4
- /**
5
- * 세트 아이템 정보를 세트의 이름으로 검색합니다.
6
- *
7
- * @param {string} setItemName 세트 아이템의 이름입니다.
8
- * @param {object} params 선택적 요청변수의 Object입니다.
9
- */
10
- export const setitem = (setItemName: string, params: Params.ISetItem = {}): Promise<Model.DnfResponse<Model.SetItem.SetItem[]>> => {
11
- params.setItemName = setItemName;
12
- let opt = {
13
- base: Query.UriBuilder(Static.BaseUri.SetItem),
14
- params: params,
15
- };
16
- return Query.Request<Model.SetItem.SetItem[]>(opt);
17
- };
18
-
19
- /**
20
- * 세트 ID로 세트 아이템 정보를 받아옵니다.
21
- *
22
- * @param {string} setItemId 세트 아이템의 ID입니다.
23
- */
24
- export const detail = (setItemId: string): Promise<Model.DnfResponse<Model.SetItem.Detail>> => {
25
- let opt = {
26
- base: Query.UriBuilder(Static.BaseUri.SetItem, setItemId),
27
- };
28
- return Query.Request<Model.SetItem.Detail>(opt);
29
- };
1
+ import type * as Model from "../model";
2
+ import { type Params, Query, Static } from "../util";
3
+
4
+ /**
5
+ * 세트 아이템 정보를 세트의 이름으로 검색합니다.
6
+ *
7
+ * @param {string} setItemName 세트 아이템의 이름입니다.
8
+ * @param {object} params 선택적 요청변수의 Object입니다.
9
+ */
10
+ export const setitem = (
11
+ setItemName: string,
12
+ params: Params.ISetItem = {},
13
+ ): Promise<Model.DnfResponse<Model.SetItem.SetItem[]>> => {
14
+ params.setItemName = setItemName;
15
+ const opt = {
16
+ base: Query.UriBuilder(Static.BaseUri.SetItem),
17
+ params: params,
18
+ };
19
+ return Query.Request<Model.SetItem.SetItem[]>(opt);
20
+ };
21
+
22
+ /**
23
+ * 세트 ID로 세트 아이템 정보를 받아옵니다.
24
+ *
25
+ * @param {string} setItemId 세트 아이템의 ID입니다.
26
+ */
27
+ export const detail = (
28
+ setItemId: string,
29
+ ): Promise<Model.DnfResponse<Model.SetItem.Detail>> => {
30
+ const opt = {
31
+ base: Query.UriBuilder(Static.BaseUri.SetItem, setItemId),
32
+ };
33
+ return Query.Request<Model.SetItem.Detail>(opt);
34
+ };
package/src/index.ts CHANGED
@@ -1,18 +1,29 @@
1
- import * as Request from "./api";
2
- import * as Util from "./util";
3
- import * as Model from "./model/index";
4
-
5
- import * as Params from "./util/params";
6
- import Config from "./util/config";
7
- import * as Static from "./util/static";
8
- import * as Query from "./util/query";
9
-
10
- export default class DnfApi {
11
- public static Util = Util;
12
- public static Request = Request;
13
- }
14
-
15
- const ServerNames = Static.Server;
16
- const RarityNames = Static.Rarity;
17
-
18
- export { Request as Api, Request, Config, Static, ServerNames, RarityNames, Query, Params, Model };
1
+ import * as Request from "./api";
2
+ import * as Model from "./model/index";
3
+ import * as Util from "./util";
4
+
5
+ import Config from "./util/config";
6
+ import * as Params from "./util/params";
7
+ import * as Query from "./util/query";
8
+ import * as Static from "./util/static";
9
+
10
+ // biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
11
+ export default class DnfApi {
12
+ public static Util = Util;
13
+ public static Request = Request;
14
+ }
15
+
16
+ const ServerNames = Static.Server;
17
+ const RarityNames = Static.Rarity;
18
+
19
+ export {
20
+ Request as Api,
21
+ Request,
22
+ Config,
23
+ Static,
24
+ ServerNames,
25
+ RarityNames,
26
+ Query,
27
+ Params,
28
+ Model,
29
+ };
@@ -1,4 +1,8 @@
1
+ import type { Static } from "../util";
2
+ import type { NameValue } from "./";
3
+
1
4
  export type Character = {
5
+ serverId: Static.Server;
2
6
  characterId: string;
3
7
  characterName: string;
4
8
  level: number;
@@ -6,9 +10,11 @@ export type Character = {
6
10
  jobGrowId: string;
7
11
  jobName: string;
8
12
  jobGrowName: string;
13
+ fame: number;
9
14
  };
10
15
 
11
16
  export type Info = {
17
+ serverId: Static.Server;
12
18
  characterId: string;
13
19
  characterName: string;
14
20
  level: number;
@@ -16,12 +22,14 @@ export type Info = {
16
22
  jobGrowId: string;
17
23
  jobName: string;
18
24
  jobGrowName: string;
25
+ fame: number;
19
26
  adventureName: string;
20
- guildId: string;
21
- guildName: string;
27
+ guildId: string | null;
28
+ guildName: string | null;
22
29
  };
23
30
 
24
31
  export type Timeline = {
32
+ serverId: Static.Server;
25
33
  characterId: string;
26
34
  characterName: string;
27
35
  level: number;
@@ -38,6 +46,46 @@ export type Timeline = {
38
46
  end: Date;
39
47
  };
40
48
  next: string;
41
- rows: any[];
49
+ rows: TimeLineRow[];
42
50
  };
43
51
  };
52
+
53
+ export type TimeLineRow = {
54
+ code: number;
55
+ name: string;
56
+ date: string;
57
+ data: TimeLineRowData;
58
+ };
59
+
60
+ export type TimeLineRowData = {
61
+ itemId: string;
62
+ itemName: string;
63
+ itemRarity: Static.Rarity;
64
+ channelName: string;
65
+ channelNo: number;
66
+ dungeonName: string;
67
+ mistGear: boolean;
68
+ };
69
+
70
+ export type CharacterStatus = {
71
+ serverId: Static.Server;
72
+ characterId: string;
73
+ characterName: string;
74
+ level: number;
75
+ jobId: string;
76
+ jobGrowId: string;
77
+ jobName: string;
78
+ jobGrowName: string;
79
+ fame: number;
80
+ adventureName: string;
81
+ guildId: string | null;
82
+ guildName: string | null;
83
+ buff: Buff[];
84
+ status: NameValue[];
85
+ };
86
+
87
+ export type Buff = {
88
+ name: string;
89
+ level?: number;
90
+ status: NameValue[];
91
+ };
@@ -1,62 +1,86 @@
1
- import * as Char from "./character";
2
- import * as Item from "./item";
3
- import * as SetItem from "./setitem";
4
-
5
- export { Char, Item, SetItem };
6
-
7
- export type DnfErrorResponse = {
8
- url: string;
9
- status: number;
10
- statusText: string;
11
- code: string;
12
- message: string;
13
- };
14
- export type DnfResponse<T> = {
15
- data?: T;
16
- error?: DnfErrorResponse;
17
- };
18
-
19
- export type Auction = {
20
- auctionNo: number;
21
- regDate: Date;
22
- expireDate: Date;
23
- itemId: string;
24
- itemName: string;
25
- itemAvailableLevel: number;
26
- itemRarity: string;
27
- itemType: string;
28
- itemTypeDetail: string;
29
- refine: number;
30
- reinforce: number;
31
- amplificationName: string;
32
- count: number;
33
- price: number;
34
- currentPrice: number;
35
- unitPrice: number;
36
- averagePrice: number;
37
- };
38
-
39
- export type AuctionSolid = {
40
- soldDate: string;
41
- itemId: string;
42
- itemName: string;
43
- itemAvailableLevel: number;
44
- itemRarity: string;
45
- itemType: string;
46
- itemTypeDetail: string;
47
- refine: number;
48
- reinforce: number;
49
- amplificationName: string | null;
50
- count: number;
51
- price: number;
52
- unitPrice: number;
53
- };
54
-
55
- export type Rows<T> = {
56
- rows: T[];
57
- };
58
-
59
- export type Server = {
60
- serverId: string;
61
- serverName: string;
62
- };
1
+ import * as Char from "./character";
2
+ import * as Item from "./item";
3
+ import * as SetItem from "./setitem";
4
+
5
+ export { Char, Item, SetItem };
6
+
7
+ export type DnfErrorResponse = {
8
+ url: string;
9
+ status: number;
10
+ statusText: string;
11
+ code: string;
12
+ message: string;
13
+ };
14
+
15
+ export type DnfSuccess<T> = {
16
+ data: T;
17
+ error?: never;
18
+ };
19
+
20
+ export type DnfError = {
21
+ data?: never;
22
+ error: DnfErrorResponse;
23
+ };
24
+
25
+ export type DnfResponse<T> = DnfSuccess<T> | DnfError;
26
+
27
+ export type Auction = {
28
+ auctionNo: number;
29
+ regDate: Date;
30
+ expireDate: Date;
31
+ itemId: string;
32
+ itemName: string;
33
+ itemAvailableLevel: number;
34
+ itemRarity: string;
35
+ itemTypeId: string;
36
+ itemType: string;
37
+ itemTypeDetailId: string;
38
+ itemTypeDetail: string;
39
+ refine: number;
40
+ reinforce: number;
41
+ amplificationName: string;
42
+ fame: number;
43
+ count: number;
44
+ regCount: number;
45
+ price: number;
46
+ currentPrice: number;
47
+ unitPrice: number;
48
+ averagePrice: number;
49
+ upgrade?: number;
50
+ upgradeMax?: number;
51
+ };
52
+
53
+ export type AuctionSolid = {
54
+ soldDate: string;
55
+ itemId: string;
56
+ itemName: string;
57
+ itemAvailableLevel: number;
58
+ itemRarity: string;
59
+ itemTypeId: string;
60
+ itemType: string;
61
+ itemTypeDetailId: string;
62
+ itemTypeDetail: string;
63
+ refine: number;
64
+ reinforce: number;
65
+ amplificationName: string | null;
66
+ fame: number;
67
+ count: number;
68
+ price: number;
69
+ unitPrice: number;
70
+ upgrade?: number;
71
+ upgradeMax?: number;
72
+ };
73
+
74
+ export type Rows<T> = {
75
+ rows: T[];
76
+ };
77
+
78
+ export type Server = {
79
+ serverId: string;
80
+ serverName: string;
81
+ };
82
+
83
+ export type NameValue = {
84
+ name: string;
85
+ value: string | number;
86
+ };
package/src/model/item.ts CHANGED
@@ -1,4 +1,10 @@
1
- import * as Static from "../util/static";
1
+ import type * as Static from "../util/static";
2
+ import type { NameValue } from "./";
3
+
4
+ export enum ItemDetailKind {
5
+ Material = "material",
6
+ Equip = "equip",
7
+ }
2
8
 
3
9
  export type Item = {
4
10
  itemId: string;
@@ -9,44 +15,90 @@ export type Item = {
9
15
  itemAvailableLevel: number;
10
16
  };
11
17
 
12
- export type Detail = {
18
+ export type Detail = MaterialDetail | EquipDetail;
19
+
20
+ export type MaterialDetail = {
21
+ kind: ItemDetailKind.Material;
13
22
  itemId: string;
14
23
  itemName: string;
15
- itemRarity: Static.Rarity;
24
+ itemRarity: string;
25
+ itemTypeId: string;
16
26
  itemType: string;
27
+ itemTypeDetailId: string;
17
28
  itemTypeDetail: string;
18
29
  itemAvailableLevel: number;
19
- itemObtainInfo: string;
20
30
  itemExplain: string;
21
31
  itemExplainDetail: string;
22
32
  itemFlavorText: string;
23
- setItemId: string;
24
- setItemName: string;
25
- itemStatus?: itemStatus[];
26
- cardInfo?: cardInfo[];
33
+ fame: number;
34
+ setItemId: string | null;
35
+ setItemName: string | null;
36
+ obtainInfo: ObtainInfo;
27
37
  };
28
38
 
29
- export type itemStatus = {
30
- name: string;
31
- value: number;
39
+ export type EquipDetail = {
40
+ kind: ItemDetailKind.Equip;
41
+ itemId: string;
42
+ itemName: string;
43
+ itemRarity: string;
44
+ itemTypeId: string;
45
+ itemType: string;
46
+ itemTypeDetailId: string;
47
+ itemTypeDetail: string;
48
+ itemAvailableLevel: number;
49
+ itemExplain: string;
50
+ itemExplainDetail: string;
51
+ itemFlavorText: string;
52
+ fame: number;
53
+ setItemId: string | null;
54
+ setItemName: string | null;
55
+ itemStatus: NameValue[];
56
+ tune: Tune;
57
+ itemBuff: ItemBuff;
58
+ hashtag: string[];
59
+ obtainInfo: ObtainInfoDetail;
32
60
  };
33
61
 
34
- export type cardInfo = {
35
- slots: cardInfoSlot[];
36
- enchant: cardInfoEnchant[];
62
+ export type Tune = {
63
+ level: number;
64
+ setPoint: number;
65
+ };
66
+
67
+ export type ItemBuff = {
68
+ explain: string;
69
+ explainDetail: string;
70
+ reinforceSkill: any[];
71
+ status: any | null;
72
+ };
73
+
74
+ export type ObtainInfo = {
75
+ dungeon: string | null;
76
+ shop: ShopInfo[];
77
+ };
78
+
79
+ export type ObtainInfoDetail = {
80
+ dungeon: Dungeon[];
81
+ shop: ShopDetail[];
82
+ };
83
+
84
+ export type Dungeon = {
85
+ type: string;
86
+ rows: DungeonRow[];
87
+ };
88
+
89
+ export type DungeonRow = {
90
+ name: string;
37
91
  };
38
92
 
39
- export type cardInfoSlot = {
40
- slotId: string;
41
- slotName: string;
93
+ export type ShopInfo = {
94
+ type: string;
42
95
  };
43
96
 
44
- export type cardInfoEnchant = {
45
- status: cardInfoEnchantStatus[];
46
- upgrade: number;
97
+ export type ShopDetail = {
98
+ rows: ShopRow[];
47
99
  };
48
100
 
49
- export type cardInfoEnchantStatus = {
101
+ export type ShopRow = {
50
102
  name: string;
51
- value: number;
103
+ details: string[];
52
104
  };
@@ -1,31 +1,31 @@
1
- export type SetItem = {
2
- setItemId: string;
3
- setItemName: string;
4
- };
5
-
6
- export type Detail = {
7
- setItemId: string;
8
- setItemName: string;
9
- setItems: [
10
- {
11
- slotId: string;
12
- slotName: string;
13
- itemId: string;
14
- itemName: string;
15
- itemRarity: string;
16
- }
17
- ];
18
- setItemOption: [
19
- {
20
- optionNo: number;
21
- explain: string;
22
- detailExplain: string;
23
- status: [
24
- {
25
- name: string;
26
- value: number;
27
- }
28
- ];
29
- }
30
- ];
31
- };
1
+ export type SetItem = {
2
+ setItemId: string;
3
+ setItemName: string;
4
+ };
5
+
6
+ export type Detail = {
7
+ setItemId: string;
8
+ setItemName: string;
9
+ setItems: [
10
+ {
11
+ slotId: string;
12
+ slotName: string;
13
+ itemId: string;
14
+ itemName: string;
15
+ itemRarity: string;
16
+ }
17
+ ];
18
+ setItemOption: [
19
+ {
20
+ optionNo: number;
21
+ explain: string;
22
+ detailExplain: string;
23
+ status: [
24
+ {
25
+ name: string;
26
+ value: number;
27
+ }
28
+ ];
29
+ }
30
+ ];
31
+ };
@@ -1,19 +1,20 @@
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
- let defaultConfig: IConfig = {
11
- key: "",
12
- hideOnErrorApiKey: true,
13
- hidekeyText: "{HIDEKEY}",
14
- axiosTimeout: 5000,
15
- returnJSON: false,
16
- responeHeader: false,
17
- showURL: false
18
- };
19
- export default defaultConfig;
1
+ export interface IConfig {
2
+ key: string | undefined;
3
+ hideOnErrorApiKey: boolean;
4
+ hideKeyText: string;
5
+ timeout: number;
6
+ returnJSON: boolean;
7
+ responseHeader: boolean;
8
+ showURL: boolean;
9
+ }
10
+ // biome-ignore lint/style/useConst: <explanation>
11
+ let defaultConfig: IConfig = {
12
+ key: "",
13
+ hideOnErrorApiKey: true,
14
+ hideKeyText: "{HIDE_KEY}",
15
+ timeout: 5000,
16
+ returnJSON: false,
17
+ responseHeader: false,
18
+ showURL: false,
19
+ };
20
+ export default defaultConfig;
package/src/util/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Config from "./config";
2
- import Query from "./query";
3
- import * as Params from "./params";
4
- import * as Static from "./static";
5
-
6
- export { Config, Query, Static, Params };
1
+ import Config from "./config";
2
+ import * as Params from "./params";
3
+ import Query from "./query";
4
+ import * as Static from "./static";
5
+
6
+ export { Config, Query, Static, Params };