dnf-api 0.6.4 → 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/src/index.ts CHANGED
@@ -1,29 +1,35 @@
1
- import * as Request from "./api";
2
- import * as Model from "./model/index";
3
- import * as Util from "./util";
1
+ import * as request from "./api";
2
+ import * as model from "./model/index";
4
3
 
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";
4
+ import config from "./util/config";
5
+ import * as params from "./util/params";
6
+ import * as query from "./util/query";
7
+ import * as staticUtil from "./util/static";
9
8
 
10
- // biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
11
- export default class DnfApi {
12
- public static Util = Util;
13
- public static Request = Request;
14
- }
9
+ const serverNames = staticUtil.server;
10
+ const rarityNames = staticUtil.rarity;
15
11
 
16
- const ServerNames = Static.Server;
17
- const RarityNames = Static.Rarity;
12
+ const dnf = {
13
+ api: request,
14
+ request,
15
+ config,
16
+ staticUtil,
17
+ serverNames,
18
+ rarityNames,
19
+ query,
20
+ params,
21
+ model,
22
+ };
18
23
 
19
24
  export {
20
- Request as Api,
21
- Request,
22
- Config,
23
- Static,
24
- ServerNames,
25
- RarityNames,
26
- Query,
27
- Params,
28
- Model,
25
+ request as api,
26
+ request,
27
+ config,
28
+ staticUtil,
29
+ serverNames,
30
+ rarityNames,
31
+ query,
32
+ params,
33
+ model,
29
34
  };
35
+ export default dnf;
@@ -1,8 +1,9 @@
1
- import type { Static } from "../util";
2
- import type { NameValue } from "./";
1
+ import type { staticUtil } from "../util";
2
+ import type { INameValue } from "./";
3
3
 
4
- export type Character = {
5
- serverId: Static.Server;
4
+ /** 캐릭터 정보 인터페이스 */
5
+ export interface ICharacter {
6
+ serverId: staticUtil.server;
6
7
  characterId: string;
7
8
  characterName: string;
8
9
  level: number;
@@ -11,10 +12,11 @@ export type Character = {
11
12
  jobName: string;
12
13
  jobGrowName: string;
13
14
  fame: number;
14
- };
15
+ }
15
16
 
16
- export type Info = {
17
- serverId: Static.Server;
17
+ /** 캐릭터 상세 정보 인터페이스 */
18
+ export interface IInfo {
19
+ serverId: staticUtil.server;
18
20
  characterId: string;
19
21
  characterName: string;
20
22
  level: number;
@@ -26,10 +28,11 @@ export type Info = {
26
28
  adventureName: string;
27
29
  guildId: string | null;
28
30
  guildName: string | null;
29
- };
31
+ }
30
32
 
31
- export type Timeline = {
32
- serverId: Static.Server;
33
+ /** 캐릭터 타임라인 인터페이스 */
34
+ export interface ITimeline {
35
+ serverId: staticUtil.server;
33
36
  characterId: string;
34
37
  characterName: string;
35
38
  level: number;
@@ -46,29 +49,32 @@ export type Timeline = {
46
49
  end: Date;
47
50
  };
48
51
  next: string;
49
- rows: TimeLineRow[];
52
+ rows: ITimeLineRow[];
50
53
  };
51
- };
54
+ }
52
55
 
53
- export type TimeLineRow = {
56
+ /** 타임라인 인터페이스 */
57
+ export interface ITimeLineRow {
54
58
  code: number;
55
59
  name: string;
56
60
  date: string;
57
- data: TimeLineRowData;
58
- };
61
+ data: ITimeLineRowData;
62
+ }
59
63
 
60
- export type TimeLineRowData = {
64
+ /** 타임라인 데이터 인터페이스 */
65
+ export interface ITimeLineRowData {
61
66
  itemId: string;
62
67
  itemName: string;
63
- itemRarity: Static.Rarity;
68
+ itemRarity: staticUtil.rarity;
64
69
  channelName: string;
65
70
  channelNo: number;
66
71
  dungeonName: string;
67
72
  mistGear: boolean;
68
- };
73
+ }
69
74
 
70
- export type CharacterStatus = {
71
- serverId: Static.Server;
75
+ /** 캐릭터 상태 인터페이스 */
76
+ export interface ICharacterStatus {
77
+ serverId: staticUtil.server;
72
78
  characterId: string;
73
79
  characterName: string;
74
80
  level: number;
@@ -80,12 +86,13 @@ export type CharacterStatus = {
80
86
  adventureName: string;
81
87
  guildId: string | null;
82
88
  guildName: string | null;
83
- buff: Buff[];
84
- status: NameValue[];
85
- };
89
+ buff: IBuff[];
90
+ status: INameValue[];
91
+ }
86
92
 
87
- export type Buff = {
93
+ /** 버프 정보 인터페이스 */
94
+ export interface IBuff {
88
95
  name: string;
89
96
  level?: number;
90
- status: NameValue[];
91
- };
97
+ status: INameValue[];
98
+ }
@@ -1,30 +1,35 @@
1
- import * as Char from "./character";
2
- import * as Item from "./item";
3
- import * as SetItem from "./setitem";
1
+ import * as char from "./character";
2
+ import * as item from "./item";
3
+ import * as setItem from "./setitem";
4
4
 
5
- export { Char, Item, SetItem };
5
+ export { char, item, setItem };
6
6
 
7
- export type DnfErrorResponse = {
7
+ /** 에러 응답 인터페이스 */
8
+ export interface IDnfErrorResponse {
8
9
  url: string;
9
10
  status: number;
10
11
  statusText: string;
11
12
  code: string;
12
13
  message: string;
13
- };
14
+ }
14
15
 
15
- export type DnfSuccess<T> = {
16
+ /** 성공 응답 인터페이스 */
17
+ export interface IDnfSuccess<T> {
16
18
  data: T;
17
19
  error?: never;
18
- };
20
+ }
19
21
 
20
- export type DnfError = {
22
+ /** 에러 정보 인터페이스 */
23
+ export interface IDnfError {
21
24
  data?: never;
22
- error: DnfErrorResponse;
23
- };
25
+ error: IDnfErrorResponse;
26
+ }
24
27
 
25
- export type DnfResponse<T> = DnfSuccess<T> | DnfError;
28
+ /** 응답 타입(합성 타입) */
29
+ export type IDnfResponse<T> = IDnfSuccess<T> | IDnfError;
26
30
 
27
- export type Auction = {
31
+ /** 경매장 아이템 인터페이스 */
32
+ export interface IAuction {
28
33
  auctionNo: number;
29
34
  regDate: Date;
30
35
  expireDate: Date;
@@ -48,9 +53,10 @@ export type Auction = {
48
53
  averagePrice: number;
49
54
  upgrade?: number;
50
55
  upgradeMax?: number;
51
- };
56
+ }
52
57
 
53
- export type AuctionSolid = {
58
+ /** 판매 완료 아이템 인터페이스 */
59
+ export interface IAuctionSolid {
54
60
  soldDate: string;
55
61
  itemId: string;
56
62
  itemName: string;
@@ -69,18 +75,21 @@ export type AuctionSolid = {
69
75
  unitPrice: number;
70
76
  upgrade?: number;
71
77
  upgradeMax?: number;
72
- };
78
+ }
73
79
 
74
- export type Rows<T> = {
80
+ /** 배열 인터페이스 */
81
+ export interface IRows<T> {
75
82
  rows: T[];
76
- };
83
+ }
77
84
 
78
- export type Server = {
85
+ /** 서버 정보 인터페이스 */
86
+ export interface IServer {
79
87
  serverId: string;
80
88
  serverName: string;
81
- };
89
+ }
82
90
 
83
- export type NameValue = {
91
+ /** 이름-값 인터페이스 */
92
+ export interface INameValue {
84
93
  name: string;
85
94
  value: string | number;
86
- };
95
+ }
package/src/model/item.ts CHANGED
@@ -1,23 +1,26 @@
1
1
  import type * as Static from "../util/static";
2
- import type { NameValue } from "./";
2
+ import type { INameValue } from "./";
3
3
 
4
4
  export enum ItemDetailKind {
5
5
  Material = "material",
6
6
  Equip = "equip",
7
7
  }
8
8
 
9
- export type Item = {
9
+ /** 아이템 인터페이스 */
10
+ export interface IItem {
10
11
  itemId: string;
11
12
  itemName: string;
12
- itemRarity: Static.Rarity;
13
+ itemRarity: Static.rarity;
13
14
  itemType: string;
14
15
  itemTypeDetail: string;
15
16
  itemAvailableLevel: number;
16
- };
17
+ }
17
18
 
18
- export type Detail = MaterialDetail | EquipDetail;
19
+ /** 아이템 상세 인터페이스(합성 타입) */
20
+ export type IDetail = IMaterialDetail | IEquipDetail;
19
21
 
20
- export type MaterialDetail = {
22
+ /** 재료 아이템 상세 인터페이스 */
23
+ export interface IMaterialDetail {
21
24
  kind: ItemDetailKind.Material;
22
25
  itemId: string;
23
26
  itemName: string;
@@ -33,10 +36,11 @@ export type MaterialDetail = {
33
36
  fame: number;
34
37
  setItemId: string | null;
35
38
  setItemName: string | null;
36
- obtainInfo: ObtainInfo;
37
- };
39
+ obtainInfo: IObtainInfo;
40
+ }
38
41
 
39
- export type EquipDetail = {
42
+ /** 장비 아이템 상세 인터페이스 */
43
+ export interface IEquipDetail {
40
44
  kind: ItemDetailKind.Equip;
41
45
  itemId: string;
42
46
  itemName: string;
@@ -52,53 +56,62 @@ export type EquipDetail = {
52
56
  fame: number;
53
57
  setItemId: string | null;
54
58
  setItemName: string | null;
55
- itemStatus: NameValue[];
56
- tune: Tune;
57
- itemBuff: ItemBuff;
59
+ itemStatus: INameValue[];
60
+ tune: ITune;
61
+ itemBuff: IItemBuff;
58
62
  hashtag: string[];
59
- obtainInfo: ObtainInfoDetail;
60
- };
63
+ obtainInfo: IObtainInfoDetail;
64
+ }
61
65
 
62
- export type Tune = {
66
+ /** 정보 인터페이스 */
67
+ export interface ITune {
63
68
  level: number;
64
69
  setPoint: number;
65
- };
70
+ }
66
71
 
67
- export type ItemBuff = {
72
+ /** 아이템 버프 인터페이스 */
73
+ export interface IItemBuff {
68
74
  explain: string;
69
75
  explainDetail: string;
70
76
  reinforceSkill: any[];
71
77
  status: any | null;
72
- };
78
+ }
73
79
 
74
- export type ObtainInfo = {
80
+ /** 획득 정보 인터페이스 */
81
+ export interface IObtainInfo {
75
82
  dungeon: string | null;
76
- shop: ShopInfo[];
77
- };
83
+ shop: IShopInfo[];
84
+ }
78
85
 
79
- export type ObtainInfoDetail = {
80
- dungeon: Dungeon[];
81
- shop: ShopDetail[];
82
- };
86
+ /** 획득 상세 정보 인터페이스 */
87
+ export interface IObtainInfoDetail {
88
+ dungeon: IDungeon[];
89
+ shop: IShopDetail[];
90
+ }
83
91
 
84
- export type Dungeon = {
92
+ /** 던전 정보 인터페이스 */
93
+ export interface IDungeon {
85
94
  type: string;
86
- rows: DungeonRow[];
87
- };
95
+ rows: IDungeonRow[];
96
+ }
88
97
 
89
- export type DungeonRow = {
98
+ /** 던전 인터페이스 */
99
+ export interface IDungeonRow {
90
100
  name: string;
91
- };
101
+ }
92
102
 
93
- export type ShopInfo = {
103
+ /** 상점 정보 인터페이스 */
104
+ export interface IShopInfo {
94
105
  type: string;
95
- };
106
+ }
96
107
 
97
- export type ShopDetail = {
98
- rows: ShopRow[];
99
- };
108
+ /** 상점 상세 정보 인터페이스 */
109
+ export interface IShopDetail {
110
+ rows: IShopRow[];
111
+ }
100
112
 
101
- export type ShopRow = {
113
+ /** 상점 인터페이스 */
114
+ export interface IShopRow {
102
115
  name: string;
103
116
  details: string[];
104
- };
117
+ }
@@ -1,9 +1,11 @@
1
- export type SetItem = {
1
+ /** 세트 아이템 인터페이스 */
2
+ export interface ISetItem {
2
3
  setItemId: string;
3
4
  setItemName: string;
4
- };
5
+ }
5
6
 
6
- export type Detail = {
7
+ /** 세트 아이템 상세 인터페이스 */
8
+ export interface IDetail {
7
9
  setItemId: string;
8
10
  setItemName: string;
9
11
  setItems: [
@@ -28,4 +30,4 @@ export type Detail = {
28
30
  ];
29
31
  }
30
32
  ];
31
- };
33
+ }
package/src/util/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Config from "./config";
2
- import * as Params from "./params";
3
- import Query from "./query";
4
- import * as Static from "./static";
1
+ import config from "./config";
2
+ import * as params from "./params";
3
+ import query from "./query";
4
+ import * as staticUtil from "./static";
5
5
 
6
- export { Config, Query, Static, Params };
6
+ export { config, query, staticUtil, params };
@@ -1,4 +1,4 @@
1
- import type * as Static from "./static";
1
+ import type * as staticUtil from "./static";
2
2
  export interface QueryOptions<T = any> {
3
3
  base: string;
4
4
  params?: T;
@@ -8,12 +8,12 @@ export interface ICharParams {
8
8
  jobId?: string;
9
9
  jobGrowId?: string;
10
10
  isAllJobGrow?: boolean;
11
- wordType?: Static.CharactersWordType;
11
+ wordType?: staticUtil.charactersWordType;
12
12
  limit?: number;
13
13
  }
14
14
 
15
15
  export interface ITimeLine {
16
- serverId?: Static.Server;
16
+ serverId?: staticUtil.server;
17
17
  characterId?: string;
18
18
  startDate?: Date;
19
19
  endDate?: Date;
@@ -27,20 +27,20 @@ export interface IAuction {
27
27
  sort?: IAuctionSort;
28
28
  itemId?: string;
29
29
  itemName?: string;
30
- wordType?: Static.AuctionWordType;
30
+ wordType?: staticUtil.auctionWordType;
31
31
  wordShort?: boolean;
32
32
  q?: IAuctionQuery;
33
33
  }
34
34
  export interface IAuctionSort {
35
- unitPrice?: Static.Sort;
36
- reinforce?: Static.Sort;
37
- auctionNo?: Static.Sort;
35
+ unitPrice?: staticUtil.sort;
36
+ reinforce?: staticUtil.sort;
37
+ auctionNo?: staticUtil.sort;
38
38
  }
39
39
  export interface IAuctionQuery {
40
40
  minLevel?: number;
41
41
  maxLevel?: number;
42
- raity?: Static.Rarity;
43
- reinforceTypeId: Static.reinforceType;
42
+ raity?: staticUtil.rarity;
43
+ reinforceTypeId: staticUtil.reinforceType;
44
44
  minReinforce?: number;
45
45
  maxReinforce?: number;
46
46
  minRefine?: number;
@@ -51,7 +51,7 @@ export interface IAuctionQuery {
51
51
 
52
52
  export interface IActionSoldOption {
53
53
  limit?: number;
54
- wordType?: Static.AuctionWordType;
54
+ wordType?: staticUtil.auctionWordType;
55
55
  wordShort?: boolean;
56
56
  itemId?: string;
57
57
  itemName?: string;
@@ -61,20 +61,20 @@ export interface IItem {
61
61
  limit?: number;
62
62
  itemName?: string;
63
63
  hashtag?: string[];
64
- wordType?: Static.AuctionWordType;
64
+ wordType?: staticUtil.auctionWordType;
65
65
  q?: IItemQuery;
66
66
  }
67
67
  export interface IItemQuery {
68
68
  minLevel?: number;
69
69
  maxLevel?: number;
70
- rarity?: Static.Rarity;
70
+ rarity?: staticUtil.rarity;
71
71
  // trade?: boolean;
72
72
  }
73
73
 
74
74
  export interface ISetItem {
75
75
  setItemName?: string;
76
76
  limit?: number;
77
- wordType?: Static.AuctionWordType;
77
+ wordType?: staticUtil.auctionWordType;
78
78
  }
79
79
  export interface ISkill {
80
80
  jobGrowId: string;
package/src/util/query.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import consola from "consola";
2
2
  import querystring from "query-string";
3
- import { Client, request } from "undici";
3
+ import { request } from "undici";
4
4
 
5
- import type * as Model from "../model";
5
+ import type * as model from "../model";
6
6
  import * as Util from "./";
7
7
 
8
8
  const apiUrl = new URL("https://api.neople.co.kr");
@@ -12,7 +12,7 @@ const apiUrl = new URL("https://api.neople.co.kr");
12
12
  // });
13
13
 
14
14
  const sender = async <T>(path: string, method: "GET" | "POST", query: any) => {
15
- // const res = await client.request<Model.DnfResponse<T>>({
15
+ // const res = await client.request<model.DnfResponse<T>>({
16
16
  // const res = await client.request<T>({
17
17
  // path,
18
18
  // method,
@@ -21,14 +21,14 @@ const sender = async <T>(path: string, method: "GET" | "POST", query: any) => {
21
21
  apiUrl.pathname = path;
22
22
  apiUrl.search = querystring.stringify(query);
23
23
 
24
- const res = await request<Model.DnfResponse<T>>(apiUrl.href, {
24
+ const res = await request<model.IDnfResponse<T>>(apiUrl.href, {
25
25
  method,
26
26
  });
27
27
  return res;
28
28
  };
29
29
  const showUrl = (url: string): string => {
30
- if (Util.Config.key) {
31
- return url?.replace(Util.Config.key, Util.Config.hideKeyText);
30
+ if (Util.config.key) {
31
+ return url?.replace(Util.config.key, Util.config.hideKeyText);
32
32
  } else {
33
33
  return url;
34
34
  }
@@ -56,31 +56,31 @@ export default class Request {
56
56
  */
57
57
  public static async Request<T>(
58
58
  opt: any = {},
59
- method: "GET" | "POST" = "GET",
60
- ): Promise<Model.DnfResponse<T>> {
61
- if (!Util.Config.key || Util.Config.key === "") {
59
+ method: "GET" | "POST" = "GET"
60
+ ): Promise<model.IDnfResponse<T>> {
61
+ if (!Util.config.key || Util.config.key === "") {
62
62
  consola.error("Please change to your api key. ");
63
63
  }
64
64
 
65
65
  if (opt.params === undefined) opt.params = {};
66
66
  if (opt.params.q) opt.params.q = Request.QueryBuilder(opt.params.q);
67
67
 
68
- opt.params.apikey = Util.Config.key;
68
+ opt.params.apikey = Util.config.key;
69
69
 
70
- if (Util.Config.showURL)
70
+ if (Util.config.showURL)
71
71
  consola.log(
72
72
  "request url:",
73
- showUrl(`${opt.base}?${querystring.stringify(opt.params)}`),
73
+ showUrl(`${opt.base}?${querystring.stringify(opt.params)}`)
74
74
  );
75
75
 
76
- const res = await sender<Model.DnfResponse<T>>(
76
+ const res = await sender<model.IDnfResponse<T>>(
77
77
  opt.base,
78
78
  method,
79
- opt.params,
79
+ opt.params
80
80
  );
81
81
  if (res.statusCode !== 200) {
82
- const resBody = (await res.body.json()) as Model.DnfResponse<T>;
83
- const error: Model.DnfErrorResponse = {
82
+ const resBody = (await res.body.json()) as model.IDnfResponse<T>;
83
+ const error: model.IDnfErrorResponse = {
84
84
  url: showUrl(opt.url ?? ""),
85
85
  status: res.statusCode || 0,
86
86
  statusText: "",
@@ -1,4 +1,4 @@
1
- export enum Server {
1
+ export enum server {
2
2
  Cain = "cain",
3
3
  Diregie = "diregie",
4
4
  Siroco = "siroco",
@@ -8,11 +8,11 @@ export enum Server {
8
8
  Anton = "anton",
9
9
  Bakal = "bakal",
10
10
  }
11
- export enum Sort {
11
+ export enum sort {
12
12
  Asc = "asc",
13
13
  Desc = "desc",
14
14
  }
15
- export enum Rarity {
15
+ export enum rarity {
16
16
  Common = "커먼",
17
17
  Uncommon = "언커먼",
18
18
  Rare = "레어",
@@ -22,26 +22,27 @@ export enum Rarity {
22
22
  Legendary = "레전더리",
23
23
  }
24
24
 
25
- export enum AuctionWordType {
25
+ export enum auctionWordType {
26
26
  Match = "match",
27
27
  Front = "front",
28
28
  Full = "full",
29
29
  }
30
- export enum WordType {
30
+ export enum wordType {
31
31
  Match = "match",
32
32
  Front = "front",
33
33
  Full = "full",
34
34
  }
35
- export enum CharactersWordType {
35
+ export enum charactersWordType {
36
36
  Match = "match",
37
37
  Full = "full",
38
38
  }
39
- export enum BaseUri {
39
+ export enum baseUri {
40
40
  Servers = "df/servers",
41
41
  Auction = "df/auction",
42
42
  AuctionSold = "df/auction-sold",
43
43
  Item = "df/items",
44
44
  SetItem = "df/setitems",
45
+ Multi = "df/multi",
45
46
  }
46
47
 
47
48
  export enum reinforceType {