@blizzard-api/core 0.0.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.
- package/dist/index.cjs +62 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
getEndpoint: () => getEndpoint
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/endpoint.ts
|
|
28
|
+
var endpoints = {
|
|
29
|
+
us: {
|
|
30
|
+
hostname: "https://us.api.blizzard.com",
|
|
31
|
+
defaultLocale: "en_US"
|
|
32
|
+
},
|
|
33
|
+
eu: {
|
|
34
|
+
hostname: "https://eu.api.blizzard.com",
|
|
35
|
+
defaultLocale: "en_GB"
|
|
36
|
+
},
|
|
37
|
+
sea: {
|
|
38
|
+
hostname: "https://sea.api.blizzard.com",
|
|
39
|
+
defaultLocale: "en_US"
|
|
40
|
+
},
|
|
41
|
+
kr: {
|
|
42
|
+
hostname: "https://kr.api.blizzard.com",
|
|
43
|
+
defaultLocale: "ko_KR"
|
|
44
|
+
},
|
|
45
|
+
tw: {
|
|
46
|
+
hostname: "https://tw.api.blizzard.com",
|
|
47
|
+
defaultLocale: "zh_TW"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function getEndpoint(origin, locale) {
|
|
51
|
+
const endpoint = endpoints[origin];
|
|
52
|
+
return {
|
|
53
|
+
origin,
|
|
54
|
+
hostname: endpoint.hostname,
|
|
55
|
+
locale: locale ?? endpoint.defaultLocale
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getEndpoint
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/endpoint.ts"],"sourcesContent":["//Resource\r\nexport type { BlizzardNamespaces } from './resource.js';\r\n//Endpoint\r\nexport type { Origins, Locales } from './endpoint.js';\r\nexport { getEndpoint } from './endpoint.js';\r\n","export type Origins = 'us' | 'eu' | 'sea' | 'kr' | 'tw';\r\nexport type Locales =\r\n | 'en_US'\r\n | 'es_MX'\r\n | 'pt_BR'\r\n | 'en_GB'\r\n | 'es_ES'\r\n | 'fr_FR'\r\n | 'ru_RU'\r\n | 'de_DE'\r\n | 'pt_PT'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'zh_TW'\r\n | 'multi';\r\n\r\nconst locales = {\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n sea: ['en_US', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\ninterface Endpoint<T extends Origins> {\r\n hostname: `https://${T}.api.blizzard.com`;\r\n defaultLocale: (typeof locales)[T][number];\r\n}\r\n\r\ninterface Endpoints {\r\n us: Endpoint<'us'>;\r\n eu: Endpoint<'eu'>;\r\n sea: Endpoint<'sea'>;\r\n kr: Endpoint<'kr'>;\r\n tw: Endpoint<'tw'>;\r\n}\r\n\r\nconst endpoints: Endpoints = {\r\n us: {\r\n hostname: 'https://us.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n eu: {\r\n hostname: 'https://eu.api.blizzard.com',\r\n defaultLocale: 'en_GB',\r\n },\r\n sea: {\r\n hostname: 'https://sea.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n kr: {\r\n hostname: 'https://kr.api.blizzard.com',\r\n defaultLocale: 'ko_KR',\r\n },\r\n tw: {\r\n hostname: 'https://tw.api.blizzard.com',\r\n defaultLocale: 'zh_TW',\r\n },\r\n};\r\n\r\nexport function getEndpoint<T extends Origins>(\r\n origin: T,\r\n locale?: (typeof locales)[typeof origin][number],\r\n): { origin: Origins; locale: (typeof locales)[typeof origin][number]; hostname: Endpoint<Origins>['hostname'] } {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n origin,\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n };\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqCA,IAAM,YAAuB;AAAA,EAC3B,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,KAAK;AAAA,IACH,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,SAAS,YACd,QACA,QAC+G;AAC/G,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,EAC7B;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
|
|
2
|
+
|
|
3
|
+
type Origins = 'us' | 'eu' | 'sea' | 'kr' | 'tw';
|
|
4
|
+
type Locales = 'en_US' | 'es_MX' | 'pt_BR' | 'en_GB' | 'es_ES' | 'fr_FR' | 'ru_RU' | 'de_DE' | 'pt_PT' | 'it_IT' | 'ko_KR' | 'zh_TW' | 'multi';
|
|
5
|
+
declare const locales: {
|
|
6
|
+
readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
|
|
7
|
+
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
|
|
8
|
+
readonly sea: ["en_US", "multi"];
|
|
9
|
+
readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
|
|
10
|
+
readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
|
|
11
|
+
};
|
|
12
|
+
interface Endpoint<T extends Origins> {
|
|
13
|
+
hostname: `https://${T}.api.blizzard.com`;
|
|
14
|
+
defaultLocale: (typeof locales)[T][number];
|
|
15
|
+
}
|
|
16
|
+
declare function getEndpoint<T extends Origins>(origin: T, locale?: (typeof locales)[typeof origin][number]): {
|
|
17
|
+
origin: Origins;
|
|
18
|
+
locale: (typeof locales)[typeof origin][number];
|
|
19
|
+
hostname: Endpoint<Origins>['hostname'];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { type BlizzardNamespaces, type Locales, type Origins, getEndpoint };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
|
|
2
|
+
|
|
3
|
+
type Origins = 'us' | 'eu' | 'sea' | 'kr' | 'tw';
|
|
4
|
+
type Locales = 'en_US' | 'es_MX' | 'pt_BR' | 'en_GB' | 'es_ES' | 'fr_FR' | 'ru_RU' | 'de_DE' | 'pt_PT' | 'it_IT' | 'ko_KR' | 'zh_TW' | 'multi';
|
|
5
|
+
declare const locales: {
|
|
6
|
+
readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
|
|
7
|
+
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
|
|
8
|
+
readonly sea: ["en_US", "multi"];
|
|
9
|
+
readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
|
|
10
|
+
readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
|
|
11
|
+
};
|
|
12
|
+
interface Endpoint<T extends Origins> {
|
|
13
|
+
hostname: `https://${T}.api.blizzard.com`;
|
|
14
|
+
defaultLocale: (typeof locales)[T][number];
|
|
15
|
+
}
|
|
16
|
+
declare function getEndpoint<T extends Origins>(origin: T, locale?: (typeof locales)[typeof origin][number]): {
|
|
17
|
+
origin: Origins;
|
|
18
|
+
locale: (typeof locales)[typeof origin][number];
|
|
19
|
+
hostname: Endpoint<Origins>['hostname'];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { type BlizzardNamespaces, type Locales, type Origins, getEndpoint };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/endpoint.ts
|
|
2
|
+
var endpoints = {
|
|
3
|
+
us: {
|
|
4
|
+
hostname: "https://us.api.blizzard.com",
|
|
5
|
+
defaultLocale: "en_US"
|
|
6
|
+
},
|
|
7
|
+
eu: {
|
|
8
|
+
hostname: "https://eu.api.blizzard.com",
|
|
9
|
+
defaultLocale: "en_GB"
|
|
10
|
+
},
|
|
11
|
+
sea: {
|
|
12
|
+
hostname: "https://sea.api.blizzard.com",
|
|
13
|
+
defaultLocale: "en_US"
|
|
14
|
+
},
|
|
15
|
+
kr: {
|
|
16
|
+
hostname: "https://kr.api.blizzard.com",
|
|
17
|
+
defaultLocale: "ko_KR"
|
|
18
|
+
},
|
|
19
|
+
tw: {
|
|
20
|
+
hostname: "https://tw.api.blizzard.com",
|
|
21
|
+
defaultLocale: "zh_TW"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function getEndpoint(origin, locale) {
|
|
25
|
+
const endpoint = endpoints[origin];
|
|
26
|
+
return {
|
|
27
|
+
origin,
|
|
28
|
+
hostname: endpoint.hostname,
|
|
29
|
+
locale: locale ?? endpoint.defaultLocale
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
getEndpoint
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/endpoint.ts"],"sourcesContent":["export type Origins = 'us' | 'eu' | 'sea' | 'kr' | 'tw';\r\nexport type Locales =\r\n | 'en_US'\r\n | 'es_MX'\r\n | 'pt_BR'\r\n | 'en_GB'\r\n | 'es_ES'\r\n | 'fr_FR'\r\n | 'ru_RU'\r\n | 'de_DE'\r\n | 'pt_PT'\r\n | 'it_IT'\r\n | 'ko_KR'\r\n | 'zh_TW'\r\n | 'multi';\r\n\r\nconst locales = {\r\n us: ['en_US', 'es_MX', 'pt_BR', 'multi'],\r\n eu: ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT', 'multi'],\r\n sea: ['en_US', 'multi'],\r\n kr: ['ko_KR', 'en_GB', 'en_US', 'multi'],\r\n tw: ['zh_TW', 'en_GB', 'en_US', 'multi'],\r\n} as const satisfies Record<Origins, Array<Locales>>;\r\n\r\ninterface Endpoint<T extends Origins> {\r\n hostname: `https://${T}.api.blizzard.com`;\r\n defaultLocale: (typeof locales)[T][number];\r\n}\r\n\r\ninterface Endpoints {\r\n us: Endpoint<'us'>;\r\n eu: Endpoint<'eu'>;\r\n sea: Endpoint<'sea'>;\r\n kr: Endpoint<'kr'>;\r\n tw: Endpoint<'tw'>;\r\n}\r\n\r\nconst endpoints: Endpoints = {\r\n us: {\r\n hostname: 'https://us.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n eu: {\r\n hostname: 'https://eu.api.blizzard.com',\r\n defaultLocale: 'en_GB',\r\n },\r\n sea: {\r\n hostname: 'https://sea.api.blizzard.com',\r\n defaultLocale: 'en_US',\r\n },\r\n kr: {\r\n hostname: 'https://kr.api.blizzard.com',\r\n defaultLocale: 'ko_KR',\r\n },\r\n tw: {\r\n hostname: 'https://tw.api.blizzard.com',\r\n defaultLocale: 'zh_TW',\r\n },\r\n};\r\n\r\nexport function getEndpoint<T extends Origins>(\r\n origin: T,\r\n locale?: (typeof locales)[typeof origin][number],\r\n): { origin: Origins; locale: (typeof locales)[typeof origin][number]; hostname: Endpoint<Origins>['hostname'] } {\r\n const endpoint = endpoints[origin];\r\n\r\n return {\r\n origin,\r\n hostname: endpoint.hostname,\r\n locale: locale ?? endpoint.defaultLocale,\r\n };\r\n}\r\n"],"mappings":";AAqCA,IAAM,YAAuB;AAAA,EAC3B,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,KAAK;AAAA,IACH,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,SAAS,YACd,QACA,QAC+G;AAC/G,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,EAC7B;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blizzard-api/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Putro",
|
|
6
|
+
"description": "The core helpers used by all @blizzard-api/* packages.",
|
|
7
|
+
"repository": "https://github.com/Pewtro/blizzard/packages/core",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18 <19 || >=20"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"blizzard",
|
|
28
|
+
"battlenet",
|
|
29
|
+
"battle.net",
|
|
30
|
+
"bnet",
|
|
31
|
+
"api",
|
|
32
|
+
"world of warcraft",
|
|
33
|
+
"warcraft",
|
|
34
|
+
"wow",
|
|
35
|
+
"classic",
|
|
36
|
+
"retail",
|
|
37
|
+
"starcraft",
|
|
38
|
+
"sc2",
|
|
39
|
+
"diablo",
|
|
40
|
+
"d3",
|
|
41
|
+
"hs",
|
|
42
|
+
"hearthstone",
|
|
43
|
+
"ow",
|
|
44
|
+
"overwatch"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {},
|
|
47
|
+
"devDependencies": {},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"debv": "tsup --watch",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:coverage": "pnpm test -- --coverage",
|
|
53
|
+
"test:watch": "vitest watch"
|
|
54
|
+
}
|
|
55
|
+
}
|