@blizzard-api/core 0.0.4 → 0.0.6
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 +0 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -17
- package/dist/index.d.ts +20 -17
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -34,10 +34,6 @@ var endpoints = {
|
|
|
34
34
|
hostname: "https://eu.api.blizzard.com",
|
|
35
35
|
defaultLocale: "en_GB"
|
|
36
36
|
},
|
|
37
|
-
sea: {
|
|
38
|
-
hostname: "https://sea.api.blizzard.com",
|
|
39
|
-
defaultLocale: "en_US"
|
|
40
|
-
},
|
|
41
37
|
kr: {
|
|
42
38
|
hostname: "https://kr.api.blizzard.com",
|
|
43
39
|
defaultLocale: "ko_KR"
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/endpoint.ts"],"sourcesContent":["//Endpoint\r\nexport type { Origins, Locales } from './endpoint.js';\r\nexport { getEndpoint } from './endpoint.js';\r\n\r\n//Namespace\r\nexport type { BlizzardNamespaces } from './namespace.js';\r\n\r\n//
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/endpoint.ts"],"sourcesContent":["//Endpoint\r\nexport type { Origins, Locales } from './endpoint.js';\r\nexport { getEndpoint } from './endpoint.js';\r\n\r\n//Namespace\r\nexport type { BlizzardNamespaces } from './namespace.js';\r\n\r\n//Resource\r\nexport type { Resource, ResourceResponse } from './resource.js';\r\n","export type Origins = 'us' | 'eu' | '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 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 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 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\ninterface GetEndpoint<T extends Origins> {\r\n origin: Origins;\r\n locale: (typeof locales)[T][number];\r\n hostname: Endpoint<Origins>['hostname'];\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): GetEndpoint<typeof origin> {\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;;;ACmCA,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,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAQO,SAAS,YACd,QACA,QAC4B;AAC5B,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
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
type Origins = 'us' | 'eu' | '
|
|
1
|
+
type Origins = 'us' | 'eu' | 'kr' | 'tw';
|
|
2
2
|
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';
|
|
3
3
|
declare const locales: {
|
|
4
4
|
readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
|
|
5
5
|
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
|
|
6
|
-
readonly sea: ["en_US", "multi"];
|
|
7
6
|
readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
|
|
8
7
|
readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
|
|
9
8
|
};
|
|
@@ -20,22 +19,26 @@ declare function getEndpoint<T extends Origins>(origin: T, locale?: (typeof loca
|
|
|
20
19
|
|
|
21
20
|
type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface Resource<_Response = void> {
|
|
22
|
+
/**
|
|
23
|
+
* Represents a resource that can be requested from the Blizzard API
|
|
24
|
+
* @param _Response The response type of the resource
|
|
25
|
+
* @param ProtectedResource Whether the resource requires a token to be requested
|
|
26
|
+
*/
|
|
27
|
+
type Resource<_Response, ProtectedResource extends boolean = false> = {
|
|
32
28
|
path: string;
|
|
33
29
|
namespace?: BlizzardNamespaces;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type ResourceOptions<T = unknown> = Partial<ClientOptions> & T;
|
|
37
|
-
type ProtectedResourceOptions<T = unknown> = Partial<ClientOptions> & {
|
|
30
|
+
parameters?: Record<string, string | number>;
|
|
31
|
+
} & (ProtectedResource extends true ? {
|
|
38
32
|
token: string;
|
|
39
|
-
}
|
|
33
|
+
} : unknown);
|
|
34
|
+
/**
|
|
35
|
+
* Represents the response of a resource
|
|
36
|
+
* @param T The response type of the resource
|
|
37
|
+
* @example
|
|
38
|
+
* type response = ResourceResponse<{ id: number }>;
|
|
39
|
+
* const response: response = Promise.resolve({ id: 1 });
|
|
40
|
+
* response.then((data) => console.log(data.id));
|
|
41
|
+
*/
|
|
42
|
+
type ResourceResponse<T = unknown> = Promise<T>;
|
|
40
43
|
|
|
41
|
-
export { type BlizzardNamespaces, type
|
|
44
|
+
export { type BlizzardNamespaces, type Locales, type Origins, type Resource, type ResourceResponse, getEndpoint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
type Origins = 'us' | 'eu' | '
|
|
1
|
+
type Origins = 'us' | 'eu' | 'kr' | 'tw';
|
|
2
2
|
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';
|
|
3
3
|
declare const locales: {
|
|
4
4
|
readonly us: ["en_US", "es_MX", "pt_BR", "multi"];
|
|
5
5
|
readonly eu: ["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT", "multi"];
|
|
6
|
-
readonly sea: ["en_US", "multi"];
|
|
7
6
|
readonly kr: ["ko_KR", "en_GB", "en_US", "multi"];
|
|
8
7
|
readonly tw: ["zh_TW", "en_GB", "en_US", "multi"];
|
|
9
8
|
};
|
|
@@ -20,22 +19,26 @@ declare function getEndpoint<T extends Origins>(origin: T, locale?: (typeof loca
|
|
|
20
19
|
|
|
21
20
|
type BlizzardNamespaces = 'profile' | 'static' | 'dynamic' | 'static-classic' | 'dynamic-classic' | 'static-classic1x' | 'dynamic-classic1x';
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface Resource<_Response = void> {
|
|
22
|
+
/**
|
|
23
|
+
* Represents a resource that can be requested from the Blizzard API
|
|
24
|
+
* @param _Response The response type of the resource
|
|
25
|
+
* @param ProtectedResource Whether the resource requires a token to be requested
|
|
26
|
+
*/
|
|
27
|
+
type Resource<_Response, ProtectedResource extends boolean = false> = {
|
|
32
28
|
path: string;
|
|
33
29
|
namespace?: BlizzardNamespaces;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type ResourceOptions<T = unknown> = Partial<ClientOptions> & T;
|
|
37
|
-
type ProtectedResourceOptions<T = unknown> = Partial<ClientOptions> & {
|
|
30
|
+
parameters?: Record<string, string | number>;
|
|
31
|
+
} & (ProtectedResource extends true ? {
|
|
38
32
|
token: string;
|
|
39
|
-
}
|
|
33
|
+
} : unknown);
|
|
34
|
+
/**
|
|
35
|
+
* Represents the response of a resource
|
|
36
|
+
* @param T The response type of the resource
|
|
37
|
+
* @example
|
|
38
|
+
* type response = ResourceResponse<{ id: number }>;
|
|
39
|
+
* const response: response = Promise.resolve({ id: 1 });
|
|
40
|
+
* response.then((data) => console.log(data.id));
|
|
41
|
+
*/
|
|
42
|
+
type ResourceResponse<T = unknown> = Promise<T>;
|
|
40
43
|
|
|
41
|
-
export { type BlizzardNamespaces, type
|
|
44
|
+
export { type BlizzardNamespaces, type Locales, type Origins, type Resource, type ResourceResponse, getEndpoint };
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoint.ts"],"sourcesContent":["export type Origins = 'us' | 'eu' | '
|
|
1
|
+
{"version":3,"sources":["../src/endpoint.ts"],"sourcesContent":["export type Origins = 'us' | 'eu' | '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 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 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 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\ninterface GetEndpoint<T extends Origins> {\r\n origin: Origins;\r\n locale: (typeof locales)[T][number];\r\n hostname: Endpoint<Origins>['hostname'];\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): GetEndpoint<typeof origin> {\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":";AAmCA,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,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,IAAI;AAAA,IACF,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAQO,SAAS,YACd,QACA,QAC4B;AAC5B,QAAM,WAAW,UAAU,MAAM;AAEjC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,QAAQ,UAAU,SAAS;AAAA,EAC7B;AACF;","names":[]}
|