@dchighs/dbgames 0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.js +30 -0
- package/dist/dbgames.d.ts +28 -0
- package/dist/dbgames.js +175 -0
- package/dist/enums/alphabet.enum.d.ts +28 -0
- package/dist/enums/alphabet.enum.js +32 -0
- package/dist/enums/dragon-element.enum.d.ts +22 -0
- package/dist/enums/dragon-element.enum.js +26 -0
- package/dist/enums/dragon-rarity.enum.d.ts +8 -0
- package/dist/enums/dragon-rarity.enum.js +12 -0
- package/dist/enums/dragons-sort-by.enum.d.ts +10 -0
- package/dist/enums/dragons-sort-by.enum.js +14 -0
- package/dist/enums/index.d.ts +5 -0
- package/dist/enums/index.js +21 -0
- package/dist/enums/order-by.enum.d.ts +4 -0
- package/dist/enums/order-by.enum.js +8 -0
- package/dist/helpers/regex.helper.d.ts +7 -0
- package/dist/helpers/regex.helper.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/interfaces/dragons-list.interface.d.ts +24 -0
- package/dist/interfaces/dragons-list.interface.js +2 -0
- package/dist/interfaces/full-data-dragon.interface.d.ts +34 -0
- package/dist/interfaces/full-data-dragon.interface.js +2 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +19 -0
- package/dist/interfaces/preview-dragon.interface.d.ts +21 -0
- package/dist/interfaces/preview-dragon.interface.js +2 -0
- package/dist/parsing-models/dragon-page.model.d.ts +70 -0
- package/dist/parsing-models/dragon-page.model.js +73 -0
- package/dist/parsing-models/dragon.model.d.ts +48 -0
- package/dist/parsing-models/dragon.model.js +51 -0
- package/dist/parsing-models/dragons-page.model.d.ts +54 -0
- package/dist/parsing-models/dragons-page.model.js +12 -0
- package/dist/transforming-models/dragon-page.model.d.ts +2 -0
- package/dist/transforming-models/dragon-page.model.js +257 -0
- package/dist/transforming-models/dragon.model.d.ts +2 -0
- package/dist/transforming-models/dragon.model.js +166 -0
- package/dist/transforming-models/dragons-page.model.d.ts +2 -0
- package/dist/transforming-models/dragons-page.model.js +12 -0
- package/dist/utils/extract-attack-id-from-name-key.util.d.ts +1 -0
- package/dist/utils/extract-attack-id-from-name-key.util.js +15 -0
- package/dist/utils/extract-dragon-page-slug.util.d.ts +1 -0
- package/dist/utils/extract-dragon-page-slug.util.js +10 -0
- package/dist/utils/extract-page-number-from-url.util.d.ts +1 -0
- package/dist/utils/extract-page-number-from-url.util.js +15 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/pick-keys.util.d.ts +1 -0
- package/dist/utils/pick-keys.util.js +10 -0
- package/dist/utils/string-duration-to-seconds.util.d.ts +1 -0
- package/dist/utils/string-duration-to-seconds.util.js +22 -0
- package/dist/utils/string-time-to-seconds.util.d.ts +1 -0
- package/dist/utils/string-time-to-seconds.util.js +11 -0
- package/dist/utils/value-of-enum.util.d.ts +1 -0
- package/dist/utils/value-of-enum.util.js +2 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcuth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @dchighs/dbgames-scraper
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const baseUrl = "https://dbgames.info/dragoncity";
|
|
2
|
+
export type FetchOptions = {
|
|
3
|
+
path: string;
|
|
4
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
5
|
+
};
|
|
6
|
+
export declare class Client {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor();
|
|
9
|
+
fetch({ path, params }: FetchOptions): Promise<import("@xcrap/extractor").HtmlParser>;
|
|
10
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = exports.baseUrl = void 0;
|
|
4
|
+
const axios_client_1 = require("@xcrap/axios-client");
|
|
5
|
+
exports.baseUrl = "https://dbgames.info/dragoncity";
|
|
6
|
+
class Client {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.client = new axios_client_1.AxiosClient({
|
|
9
|
+
rateLimit: {
|
|
10
|
+
maxRPS: 20,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async fetch({ path, params }) {
|
|
15
|
+
const query = new URLSearchParams();
|
|
16
|
+
for (const [key, value] of Object.entries(params !== null && params !== void 0 ? params : {})) {
|
|
17
|
+
if (value === undefined)
|
|
18
|
+
continue;
|
|
19
|
+
if (key === "p" && Number(value) < 2)
|
|
20
|
+
continue;
|
|
21
|
+
query.append(key, String(value));
|
|
22
|
+
}
|
|
23
|
+
const url = `${exports.baseUrl}${path}?${query.toString()}`;
|
|
24
|
+
console.log(url);
|
|
25
|
+
const response = await this.client.fetch({ url: url });
|
|
26
|
+
const parser = response.asHtmlParser();
|
|
27
|
+
return parser;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Localization } from "@dchighs/dc-localization";
|
|
2
|
+
import { ValueOfEnum } from "./utils";
|
|
3
|
+
import { Alphabet, DragonElement, DragonRarity, DragonstSortBy, OrderBy } from "./enums";
|
|
4
|
+
import { FullDataDragon, DragonsList } from "./interfaces";
|
|
5
|
+
import { Client } from "./client";
|
|
6
|
+
export type DbgamesOptions = {
|
|
7
|
+
localization: Localization;
|
|
8
|
+
};
|
|
9
|
+
export type GetDragonsOptions = {
|
|
10
|
+
elements?: ValueOfEnum<DragonElement>[];
|
|
11
|
+
rarities?: ValueOfEnum<DragonRarity>[];
|
|
12
|
+
startsWith?: ValueOfEnum<Alphabet>;
|
|
13
|
+
sortBy?: ValueOfEnum<DragonstSortBy>;
|
|
14
|
+
orderBy?: ValueOfEnum<OrderBy>;
|
|
15
|
+
description?: string;
|
|
16
|
+
page?: number;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
export type GetDragonOptions = {
|
|
20
|
+
slug: string;
|
|
21
|
+
};
|
|
22
|
+
export declare class Dbgames {
|
|
23
|
+
readonly client: Client;
|
|
24
|
+
readonly localization: Localization;
|
|
25
|
+
constructor({ localization }: DbgamesOptions);
|
|
26
|
+
getDragon({ slug }: GetDragonOptions): Promise<FullDataDragon<true>>;
|
|
27
|
+
getDragons({ elements, rarities, startsWith, sortBy, page, name, orderBy, description, }: GetDragonsOptions): Promise<DragonsList>;
|
|
28
|
+
}
|
package/dist/dbgames.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dbgames = void 0;
|
|
4
|
+
const transformer_1 = require("@xcrap/transformer");
|
|
5
|
+
const extractor_1 = require("@xcrap/extractor");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const dragons_page_model_1 = require("./transforming-models/dragons-page.model");
|
|
8
|
+
const dragon_page_model_1 = require("./transforming-models/dragon-page.model");
|
|
9
|
+
const dragons_page_model_2 = require("./parsing-models/dragons-page.model");
|
|
10
|
+
const dragon_page_model_2 = require("./parsing-models/dragon-page.model");
|
|
11
|
+
const client_1 = require("./client");
|
|
12
|
+
const previewDragonKeysInOrder = [
|
|
13
|
+
"id",
|
|
14
|
+
"name",
|
|
15
|
+
"name_key",
|
|
16
|
+
"group_type",
|
|
17
|
+
"hatching_time",
|
|
18
|
+
"breeding_time",
|
|
19
|
+
"description",
|
|
20
|
+
"description_key",
|
|
21
|
+
"xp",
|
|
22
|
+
"starting_coins",
|
|
23
|
+
"coins_added",
|
|
24
|
+
"dragon_rarity",
|
|
25
|
+
"attributes",
|
|
26
|
+
"img_name",
|
|
27
|
+
];
|
|
28
|
+
const fullDataDragonKeysInOrder = [
|
|
29
|
+
"id",
|
|
30
|
+
"name",
|
|
31
|
+
"name_key",
|
|
32
|
+
"group_type",
|
|
33
|
+
"hatching_time",
|
|
34
|
+
"breeding_time",
|
|
35
|
+
"description",
|
|
36
|
+
"description_key",
|
|
37
|
+
"xp",
|
|
38
|
+
"starting_coins",
|
|
39
|
+
"coins_added",
|
|
40
|
+
"dragon_rarity",
|
|
41
|
+
"attacks",
|
|
42
|
+
"attributes",
|
|
43
|
+
"trainable_attacks",
|
|
44
|
+
"img_name",
|
|
45
|
+
];
|
|
46
|
+
class Dbgames {
|
|
47
|
+
constructor({ localization }) {
|
|
48
|
+
this.client = new client_1.Client();
|
|
49
|
+
this.localization = localization;
|
|
50
|
+
}
|
|
51
|
+
async getDragon({ slug }) {
|
|
52
|
+
const parser = await this.client.fetch({
|
|
53
|
+
path: `/dragons/${slug}`,
|
|
54
|
+
});
|
|
55
|
+
const rawDragon = await parser.extractModel({ model: dragon_page_model_2.dragonPageExtractionModel });
|
|
56
|
+
const transformer = new transformer_1.Transformer(rawDragon);
|
|
57
|
+
const transformedDragonData = (await transformer.transform(dragon_page_model_1.dragonPageTransformingModel));
|
|
58
|
+
const transformedAggregated = {
|
|
59
|
+
data: {
|
|
60
|
+
...transformedDragonData,
|
|
61
|
+
attacks: transformedDragonData.attacks.map((attack) => {
|
|
62
|
+
const attackNameKey = this.localization.getKeyFromValue(attack.name);
|
|
63
|
+
if (!attackNameKey) {
|
|
64
|
+
throw new Error(`Not found attack name key from: ${attack.name}`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
id: (0, utils_1.extractAttackIdFromNameKey)(attackNameKey),
|
|
68
|
+
name: attack.name,
|
|
69
|
+
name_key: attackNameKey,
|
|
70
|
+
type: attack.type,
|
|
71
|
+
element: attack.element,
|
|
72
|
+
training_time: attack.training_time,
|
|
73
|
+
ui_damage: attack.ui_damage,
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
trainable_attacks: transformedDragonData.trainable_attacks.map((attack) => {
|
|
77
|
+
const attackNameKey = this.localization.getKeyFromValue(attack.name);
|
|
78
|
+
if (!attackNameKey) {
|
|
79
|
+
throw new Error(`Not found attack name key from: ${attack.name}`);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
id: (0, utils_1.extractAttackIdFromNameKey)(attackNameKey),
|
|
83
|
+
name: attack.name,
|
|
84
|
+
name_key: attackNameKey,
|
|
85
|
+
type: attack.type,
|
|
86
|
+
element: attack.element,
|
|
87
|
+
training_time: attack.training_time,
|
|
88
|
+
ui_damage: attack.ui_damage,
|
|
89
|
+
};
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
meta: {
|
|
93
|
+
pageUrl: `${client_1.baseUrl}/dragons/${slug}`,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
data: (0, utils_1.pickKeys)(transformedAggregated.data, fullDataDragonKeysInOrder),
|
|
98
|
+
meta: transformedAggregated.meta,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async getDragons({ elements, rarities, startsWith, sortBy, page, name, orderBy, description, }) {
|
|
102
|
+
var _a;
|
|
103
|
+
const parser = await this.client.fetch({
|
|
104
|
+
path: "/dragons",
|
|
105
|
+
params: {
|
|
106
|
+
name: name,
|
|
107
|
+
element: elements === null || elements === void 0 ? void 0 : elements.join(","),
|
|
108
|
+
rarity: rarities === null || rarities === void 0 ? void 0 : rarities.join(","),
|
|
109
|
+
startswith: startsWith,
|
|
110
|
+
sortby: sortBy,
|
|
111
|
+
sortorder: orderBy,
|
|
112
|
+
description: description,
|
|
113
|
+
p: page,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
const rawDragons = await parser.extractModel({ model: dragons_page_model_2.dragonsPageExtractionModel });
|
|
117
|
+
const pageUrls = await parser.extractValues({
|
|
118
|
+
query: (0, extractor_1.css)(".result-data .subtitle:first-child a"),
|
|
119
|
+
extractor: (0, extractor_1.extract)("href"),
|
|
120
|
+
});
|
|
121
|
+
const nextPageUrl = await parser.extractValue({
|
|
122
|
+
query: (0, extractor_1.xpath)("//a[text()='Next >']"),
|
|
123
|
+
extractor: (0, extractor_1.extract)("href"),
|
|
124
|
+
default: null,
|
|
125
|
+
});
|
|
126
|
+
const lastPageUrl = await parser.extractValue({
|
|
127
|
+
query: (0, extractor_1.xpath)("//a[contains(text(), 'Last')]"),
|
|
128
|
+
extractor: (0, extractor_1.extract)("href"),
|
|
129
|
+
default: null,
|
|
130
|
+
});
|
|
131
|
+
const previousPageUrl = await parser.extractValue({
|
|
132
|
+
query: (0, extractor_1.xpath)("//a[contains(text(), '< Prev')]"),
|
|
133
|
+
extractor: (0, extractor_1.extract)("href"),
|
|
134
|
+
default: null,
|
|
135
|
+
});
|
|
136
|
+
const currentPageUrl = await parser.extractValue({
|
|
137
|
+
query: (0, extractor_1.css)("a.active"),
|
|
138
|
+
extractor: (0, extractor_1.extract)("href"),
|
|
139
|
+
});
|
|
140
|
+
const nextPageNumber = (0, utils_1.extractPageNumberFromUrl)(nextPageUrl);
|
|
141
|
+
const lastPageNumber = (0, utils_1.extractPageNumberFromUrl)(lastPageUrl);
|
|
142
|
+
const currentPageNumber = (_a = (0, utils_1.extractPageNumberFromUrl)(currentPageUrl)) !== null && _a !== void 0 ? _a : (page && !isNaN(Number(page)) ? Number(page) : 1);
|
|
143
|
+
const previousPageNumber = (0, utils_1.extractPageNumberFromUrl)(previousPageUrl);
|
|
144
|
+
const transformer = new transformer_1.Transformer(rawDragons);
|
|
145
|
+
const transformedDragons = (await transformer.transform(dragons_page_model_1.dragonsPageTransformingModel));
|
|
146
|
+
const lastPage = lastPageNumber !== null && lastPageNumber !== void 0 ? lastPageNumber : currentPageNumber;
|
|
147
|
+
const itemsPerPage = 10;
|
|
148
|
+
return {
|
|
149
|
+
data: transformedDragons.dragons.map((dragon, i) => ({
|
|
150
|
+
data: (0, utils_1.pickKeys)(dragon, previewDragonKeysInOrder),
|
|
151
|
+
meta: {
|
|
152
|
+
pageUrl: transformer_1.StringTransformer.resolveUrl(client_1.baseUrl)(pageUrls[i]),
|
|
153
|
+
},
|
|
154
|
+
})),
|
|
155
|
+
meta: {
|
|
156
|
+
totalEstimated: itemsPerPage * lastPage,
|
|
157
|
+
lastPage: lastPage,
|
|
158
|
+
currentPage: currentPageNumber,
|
|
159
|
+
perPage: itemsPerPage,
|
|
160
|
+
prev: previousPageNumber,
|
|
161
|
+
next: nextPageNumber,
|
|
162
|
+
},
|
|
163
|
+
params: {
|
|
164
|
+
elements: elements,
|
|
165
|
+
rarities: rarities,
|
|
166
|
+
startsWith: startsWith,
|
|
167
|
+
sortBy: sortBy,
|
|
168
|
+
orderBy: orderBy,
|
|
169
|
+
description: description,
|
|
170
|
+
name: name,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.Dbgames = Dbgames;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum Alphabet {
|
|
2
|
+
A = "a",
|
|
3
|
+
B = "b",
|
|
4
|
+
C = "c",
|
|
5
|
+
D = "d",
|
|
6
|
+
E = "e",
|
|
7
|
+
F = "f",
|
|
8
|
+
G = "g",
|
|
9
|
+
H = "h",
|
|
10
|
+
I = "i",
|
|
11
|
+
J = "j",
|
|
12
|
+
K = "k",
|
|
13
|
+
L = "l",
|
|
14
|
+
M = "m",
|
|
15
|
+
N = "n",
|
|
16
|
+
O = "o",
|
|
17
|
+
P = "p",
|
|
18
|
+
Q = "q",
|
|
19
|
+
R = "r",
|
|
20
|
+
S = "s",
|
|
21
|
+
T = "t",
|
|
22
|
+
U = "u",
|
|
23
|
+
V = "v",
|
|
24
|
+
W = "w",
|
|
25
|
+
X = "x",
|
|
26
|
+
Y = "y",
|
|
27
|
+
Z = "z"
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Alphabet = void 0;
|
|
4
|
+
var Alphabet;
|
|
5
|
+
(function (Alphabet) {
|
|
6
|
+
Alphabet["A"] = "a";
|
|
7
|
+
Alphabet["B"] = "b";
|
|
8
|
+
Alphabet["C"] = "c";
|
|
9
|
+
Alphabet["D"] = "d";
|
|
10
|
+
Alphabet["E"] = "e";
|
|
11
|
+
Alphabet["F"] = "f";
|
|
12
|
+
Alphabet["G"] = "g";
|
|
13
|
+
Alphabet["H"] = "h";
|
|
14
|
+
Alphabet["I"] = "i";
|
|
15
|
+
Alphabet["J"] = "j";
|
|
16
|
+
Alphabet["K"] = "k";
|
|
17
|
+
Alphabet["L"] = "l";
|
|
18
|
+
Alphabet["M"] = "m";
|
|
19
|
+
Alphabet["N"] = "n";
|
|
20
|
+
Alphabet["O"] = "o";
|
|
21
|
+
Alphabet["P"] = "p";
|
|
22
|
+
Alphabet["Q"] = "q";
|
|
23
|
+
Alphabet["R"] = "r";
|
|
24
|
+
Alphabet["S"] = "s";
|
|
25
|
+
Alphabet["T"] = "t";
|
|
26
|
+
Alphabet["U"] = "u";
|
|
27
|
+
Alphabet["V"] = "v";
|
|
28
|
+
Alphabet["W"] = "w";
|
|
29
|
+
Alphabet["X"] = "x";
|
|
30
|
+
Alphabet["Y"] = "y";
|
|
31
|
+
Alphabet["Z"] = "z";
|
|
32
|
+
})(Alphabet || (exports.Alphabet = Alphabet = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum DragonElement {
|
|
2
|
+
Beauty = "beauty",
|
|
3
|
+
Chaos = "chaos",
|
|
4
|
+
Dark = "dark",
|
|
5
|
+
Dream = "dream",
|
|
6
|
+
Electric = "electric",
|
|
7
|
+
Flame = "flame",
|
|
8
|
+
Happy = "happy",
|
|
9
|
+
Ice = "ice",
|
|
10
|
+
Legend = "legend",
|
|
11
|
+
Light = "light",
|
|
12
|
+
Magic = "magic",
|
|
13
|
+
Metal = "metal",
|
|
14
|
+
Nature = "nature",
|
|
15
|
+
Primal = "primal",
|
|
16
|
+
Pure = "pure",
|
|
17
|
+
Sea = "sea",
|
|
18
|
+
Soul = "soul",
|
|
19
|
+
Terra = "terra",
|
|
20
|
+
War = "war",
|
|
21
|
+
Wind = "wind"
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DragonElement = void 0;
|
|
4
|
+
var DragonElement;
|
|
5
|
+
(function (DragonElement) {
|
|
6
|
+
DragonElement["Beauty"] = "beauty";
|
|
7
|
+
DragonElement["Chaos"] = "chaos";
|
|
8
|
+
DragonElement["Dark"] = "dark";
|
|
9
|
+
DragonElement["Dream"] = "dream";
|
|
10
|
+
DragonElement["Electric"] = "electric";
|
|
11
|
+
DragonElement["Flame"] = "flame";
|
|
12
|
+
DragonElement["Happy"] = "happy";
|
|
13
|
+
DragonElement["Ice"] = "ice";
|
|
14
|
+
DragonElement["Legend"] = "legend";
|
|
15
|
+
DragonElement["Light"] = "light";
|
|
16
|
+
DragonElement["Magic"] = "magic";
|
|
17
|
+
DragonElement["Metal"] = "metal";
|
|
18
|
+
DragonElement["Nature"] = "nature";
|
|
19
|
+
DragonElement["Primal"] = "primal";
|
|
20
|
+
DragonElement["Pure"] = "pure";
|
|
21
|
+
DragonElement["Sea"] = "sea";
|
|
22
|
+
DragonElement["Soul"] = "soul";
|
|
23
|
+
DragonElement["Terra"] = "terra";
|
|
24
|
+
DragonElement["War"] = "war";
|
|
25
|
+
DragonElement["Wind"] = "wind";
|
|
26
|
+
})(DragonElement || (exports.DragonElement = DragonElement = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DragonRarity = void 0;
|
|
4
|
+
var DragonRarity;
|
|
5
|
+
(function (DragonRarity) {
|
|
6
|
+
DragonRarity["Common"] = "common";
|
|
7
|
+
DragonRarity["Rare"] = "rare";
|
|
8
|
+
DragonRarity["VeryRare"] = "very rare";
|
|
9
|
+
DragonRarity["Epic"] = "epic";
|
|
10
|
+
DragonRarity["Legendary"] = "legendary";
|
|
11
|
+
DragonRarity["Heroic"] = "heroic";
|
|
12
|
+
})(DragonRarity || (exports.DragonRarity = DragonRarity = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DragonstSortBy = void 0;
|
|
4
|
+
var DragonstSortBy;
|
|
5
|
+
(function (DragonstSortBy) {
|
|
6
|
+
DragonstSortBy["Name"] = "name";
|
|
7
|
+
DragonstSortBy["Id"] = "id";
|
|
8
|
+
DragonstSortBy["BreedingTime"] = "breedingtime";
|
|
9
|
+
DragonstSortBy["HatchingTime"] = "hatchingtime";
|
|
10
|
+
DragonstSortBy["GoldIncome"] = "earnings";
|
|
11
|
+
DragonstSortBy["GoldIncomeIncrement"] = "increase";
|
|
12
|
+
DragonstSortBy["HatchingExperience"] = "exp";
|
|
13
|
+
DragonstSortBy["Rarity"] = "rarity";
|
|
14
|
+
})(DragonstSortBy || (exports.DragonstSortBy = DragonstSortBy = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dragon-rarity.enum"), exports);
|
|
18
|
+
__exportStar(require("./dragon-element.enum"), exports);
|
|
19
|
+
__exportStar(require("./alphabet.enum"), exports);
|
|
20
|
+
__exportStar(require("./dragons-sort-by.enum"), exports);
|
|
21
|
+
__exportStar(require("./order-by.enum"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.regexHelper = void 0;
|
|
4
|
+
exports.regexHelper = {
|
|
5
|
+
dragonId: /\[(\d+)\]/,
|
|
6
|
+
dragonName: /^\s*(.+?)\s*\[(\d+)\]\s*$/,
|
|
7
|
+
dragonStartingCoins: /^(\d+)/,
|
|
8
|
+
dragonCoinsIncome: /\((\d+)\s*x/,
|
|
9
|
+
dragonAttackId: /^tid_attack_name_(?<id>\d+)$/,
|
|
10
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.extractDragonPageSlug = exports.extractAttackIdFromNameKey = void 0;
|
|
18
|
+
__exportStar(require("./dbgames"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
var utils_1 = require("./utils");
|
|
22
|
+
Object.defineProperty(exports, "extractAttackIdFromNameKey", { enumerable: true, get: function () { return utils_1.extractAttackIdFromNameKey; } });
|
|
23
|
+
Object.defineProperty(exports, "extractDragonPageSlug", { enumerable: true, get: function () { return utils_1.extractDragonPageSlug; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Alphabet, DragonElement, DragonRarity, DragonstSortBy, OrderBy } from "../enums";
|
|
2
|
+
import { PreviewDragon } from "./preview-dragon.interface";
|
|
3
|
+
import { ValueOfEnum } from "../utils/value-of-enum.util";
|
|
4
|
+
import { GetDragonsOptions } from "../dbgames";
|
|
5
|
+
export interface DragonsListMeta {
|
|
6
|
+
elements?: ValueOfEnum<DragonElement>[];
|
|
7
|
+
rarities?: ValueOfEnum<DragonRarity>[];
|
|
8
|
+
startsWith?: ValueOfEnum<Alphabet>;
|
|
9
|
+
sortBy?: ValueOfEnum<DragonstSortBy>;
|
|
10
|
+
orderBy?: ValueOfEnum<OrderBy>;
|
|
11
|
+
description?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
totalEstimated: number;
|
|
14
|
+
lastPage: number;
|
|
15
|
+
currentPage: number;
|
|
16
|
+
perPage: number;
|
|
17
|
+
prev: number | null;
|
|
18
|
+
next: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface DragonsList {
|
|
21
|
+
data: PreviewDragon[];
|
|
22
|
+
meta: DragonsListMeta;
|
|
23
|
+
params: GetDragonsOptions;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type Attack<Aggregate extends boolean> = {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
element: string;
|
|
5
|
+
ui_damage: number;
|
|
6
|
+
training_time: number;
|
|
7
|
+
} & (Aggregate extends true ? {
|
|
8
|
+
id: number | null;
|
|
9
|
+
name_key: string;
|
|
10
|
+
} : {});
|
|
11
|
+
export interface FullDataDragon<Aggregate extends boolean> {
|
|
12
|
+
data: {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
name_key: string;
|
|
16
|
+
group_type: string;
|
|
17
|
+
hatching_time: number;
|
|
18
|
+
breeding_time: number;
|
|
19
|
+
description: string;
|
|
20
|
+
description_key: string;
|
|
21
|
+
xp: number;
|
|
22
|
+
starting_coins: number;
|
|
23
|
+
coins_added: number;
|
|
24
|
+
dragon_rarity: string;
|
|
25
|
+
attributes: Array<string>;
|
|
26
|
+
img_name: string;
|
|
27
|
+
attacks: Attack<Aggregate>[];
|
|
28
|
+
trainable_attacks: Attack<Aggregate>[];
|
|
29
|
+
};
|
|
30
|
+
meta: {
|
|
31
|
+
pageUrl: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./preview-dragon.interface"), exports);
|
|
18
|
+
__exportStar(require("./full-data-dragon.interface"), exports);
|
|
19
|
+
__exportStar(require("./dragons-list.interface"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PreviewDragon {
|
|
2
|
+
data: {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
name_key: string;
|
|
6
|
+
group_type: string;
|
|
7
|
+
hatching_time: number;
|
|
8
|
+
breeding_time: number;
|
|
9
|
+
description: string;
|
|
10
|
+
description_key: string;
|
|
11
|
+
xp: number;
|
|
12
|
+
starting_coins: number;
|
|
13
|
+
coins_added: number;
|
|
14
|
+
dragon_rarity: string;
|
|
15
|
+
attributes: Array<string>;
|
|
16
|
+
img_name: string;
|
|
17
|
+
};
|
|
18
|
+
meta: {
|
|
19
|
+
pageUrl: string;
|
|
20
|
+
};
|
|
21
|
+
}
|