serialstation 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/LICENSE +21 -0
- package/README.md +272 -0
- package/dist/api/companies/index.d.mts +16 -0
- package/dist/api/companies/index.d.ts +16 -0
- package/dist/api/companies/index.js +41 -0
- package/dist/api/companies/index.js.map +1 -0
- package/dist/api/companies/index.mjs +16 -0
- package/dist/api/companies/index.mjs.map +1 -0
- package/dist/api/content-ids/index.d.mts +20 -0
- package/dist/api/content-ids/index.d.ts +20 -0
- package/dist/api/content-ids/index.js +47 -0
- package/dist/api/content-ids/index.js.map +1 -0
- package/dist/api/content-ids/index.mjs +22 -0
- package/dist/api/content-ids/index.mjs.map +1 -0
- package/dist/api/franchises/index.d.mts +16 -0
- package/dist/api/franchises/index.d.ts +16 -0
- package/dist/api/franchises/index.js +41 -0
- package/dist/api/franchises/index.js.map +1 -0
- package/dist/api/franchises/index.mjs +16 -0
- package/dist/api/franchises/index.mjs.map +1 -0
- package/dist/api/games/index.d.mts +20 -0
- package/dist/api/games/index.d.ts +20 -0
- package/dist/api/games/index.js +47 -0
- package/dist/api/games/index.js.map +1 -0
- package/dist/api/games/index.mjs +22 -0
- package/dist/api/games/index.mjs.map +1 -0
- package/dist/api/title-ids/index.d.mts +32 -0
- package/dist/api/title-ids/index.d.ts +32 -0
- package/dist/api/title-ids/index.js +58 -0
- package/dist/api/title-ids/index.js.map +1 -0
- package/dist/api/title-ids/index.mjs +33 -0
- package/dist/api/title-ids/index.mjs.map +1 -0
- package/dist/client/BaseClient.d.mts +76 -0
- package/dist/client/BaseClient.d.ts +76 -0
- package/dist/client/BaseClient.js +136 -0
- package/dist/client/BaseClient.js.map +1 -0
- package/dist/client/BaseClient.mjs +101 -0
- package/dist/client/BaseClient.mjs.map +1 -0
- package/dist/index.d.mts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +263 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +220 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.d.mts +23 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-BjzcHkoc.d.mts +25 -0
- package/dist/types-BjzcHkoc.d.ts +25 -0
- package/dist/types-BnaHEIcd.d.mts +41 -0
- package/dist/types-BnaHEIcd.d.ts +41 -0
- package/dist/types-Dv-1DNPu.d.mts +60 -0
- package/dist/types-Dv-1DNPu.d.ts +60 -0
- package/dist/types-KwGU8D6g.d.mts +66 -0
- package/dist/types-KwGU8D6g.d.ts +66 -0
- package/dist/types-axGWx6HR.d.mts +25 -0
- package/dist/types-axGWx6HR.d.ts +25 -0
- package/package.json +103 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SerialStationClientConfig } from './client/BaseClient.mjs';
|
|
2
|
+
export { SerialStationClient } from './client/BaseClient.mjs';
|
|
3
|
+
import { TitleIDsAPI } from './api/title-ids/index.mjs';
|
|
4
|
+
import { ContentIDsAPI } from './api/content-ids/index.mjs';
|
|
5
|
+
import { GamesAPI } from './api/games/index.mjs';
|
|
6
|
+
import { FranchisesAPI } from './api/franchises/index.mjs';
|
|
7
|
+
import { CompaniesAPI } from './api/companies/index.mjs';
|
|
8
|
+
export { PagedResponse } from './types/index.mjs';
|
|
9
|
+
export { C as Console, O as OrderDirection, P as PagedTitleIDSchema, T as TitleIDFilterParams, a as TitleIDGameSchema, b as TitleIDOrderFields, c as TitleIDSchema } from './types-KwGU8D6g.mjs';
|
|
10
|
+
export { C as ContentIDFilterParams, a as ContentIDOrderFields, b as ContentIDSchema, P as PagedContentIDSchema } from './types-BnaHEIcd.mjs';
|
|
11
|
+
export { G as GameCompanySchema, a as GameFilterParams, b as GameFranchiseSchema, c as GameOrderFields, d as GameSchema, P as PagedGameSchema } from './types-Dv-1DNPu.mjs';
|
|
12
|
+
export { F as FranchiseFilterParams, a as FranchiseSchema, P as PagedFranchiseSchema } from './types-axGWx6HR.mjs';
|
|
13
|
+
export { C as CompanyFilterParams, a as CompanySchema, P as PagedCompanySchema } from './types-BjzcHkoc.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Main API client for interacting with the SerialStation API.
|
|
17
|
+
* Provides access to all available API endpoints through specialized API classes.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const api = new SerialStationAPI({ baseURL: 'https://api.serialstation.com/v1' });
|
|
22
|
+
* const titleIds = await api.titleIds.listTitleIDs({ system: 'PS4' });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare class SerialStationAPI {
|
|
26
|
+
/** API for title ID information */
|
|
27
|
+
titleIds: TitleIDsAPI;
|
|
28
|
+
/** API for content ID information */
|
|
29
|
+
contentIds: ContentIDsAPI;
|
|
30
|
+
/** API for game information */
|
|
31
|
+
games: GamesAPI;
|
|
32
|
+
/** API for franchise information */
|
|
33
|
+
franchises: FranchisesAPI;
|
|
34
|
+
/** API for company information (developers, publishers) */
|
|
35
|
+
companies: CompaniesAPI;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new SerialStationAPI instance.
|
|
38
|
+
*
|
|
39
|
+
* @param config - Configuration options for the API client
|
|
40
|
+
*/
|
|
41
|
+
constructor(config?: SerialStationClientConfig);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { CompaniesAPI, ContentIDsAPI, FranchisesAPI, GamesAPI, SerialStationAPI, TitleIDsAPI, SerialStationAPI as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SerialStationClientConfig } from './client/BaseClient.js';
|
|
2
|
+
export { SerialStationClient } from './client/BaseClient.js';
|
|
3
|
+
import { TitleIDsAPI } from './api/title-ids/index.js';
|
|
4
|
+
import { ContentIDsAPI } from './api/content-ids/index.js';
|
|
5
|
+
import { GamesAPI } from './api/games/index.js';
|
|
6
|
+
import { FranchisesAPI } from './api/franchises/index.js';
|
|
7
|
+
import { CompaniesAPI } from './api/companies/index.js';
|
|
8
|
+
export { PagedResponse } from './types/index.js';
|
|
9
|
+
export { C as Console, O as OrderDirection, P as PagedTitleIDSchema, T as TitleIDFilterParams, a as TitleIDGameSchema, b as TitleIDOrderFields, c as TitleIDSchema } from './types-KwGU8D6g.js';
|
|
10
|
+
export { C as ContentIDFilterParams, a as ContentIDOrderFields, b as ContentIDSchema, P as PagedContentIDSchema } from './types-BnaHEIcd.js';
|
|
11
|
+
export { G as GameCompanySchema, a as GameFilterParams, b as GameFranchiseSchema, c as GameOrderFields, d as GameSchema, P as PagedGameSchema } from './types-Dv-1DNPu.js';
|
|
12
|
+
export { F as FranchiseFilterParams, a as FranchiseSchema, P as PagedFranchiseSchema } from './types-axGWx6HR.js';
|
|
13
|
+
export { C as CompanyFilterParams, a as CompanySchema, P as PagedCompanySchema } from './types-BjzcHkoc.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Main API client for interacting with the SerialStation API.
|
|
17
|
+
* Provides access to all available API endpoints through specialized API classes.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const api = new SerialStationAPI({ baseURL: 'https://api.serialstation.com/v1' });
|
|
22
|
+
* const titleIds = await api.titleIds.listTitleIDs({ system: 'PS4' });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare class SerialStationAPI {
|
|
26
|
+
/** API for title ID information */
|
|
27
|
+
titleIds: TitleIDsAPI;
|
|
28
|
+
/** API for content ID information */
|
|
29
|
+
contentIds: ContentIDsAPI;
|
|
30
|
+
/** API for game information */
|
|
31
|
+
games: GamesAPI;
|
|
32
|
+
/** API for franchise information */
|
|
33
|
+
franchises: FranchisesAPI;
|
|
34
|
+
/** API for company information (developers, publishers) */
|
|
35
|
+
companies: CompaniesAPI;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new SerialStationAPI instance.
|
|
38
|
+
*
|
|
39
|
+
* @param config - Configuration options for the API client
|
|
40
|
+
*/
|
|
41
|
+
constructor(config?: SerialStationClientConfig);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { CompaniesAPI, ContentIDsAPI, FranchisesAPI, GamesAPI, SerialStationAPI, TitleIDsAPI, SerialStationAPI as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
CompaniesAPI: () => CompaniesAPI,
|
|
34
|
+
ContentIDsAPI: () => ContentIDsAPI,
|
|
35
|
+
FranchisesAPI: () => FranchisesAPI,
|
|
36
|
+
GamesAPI: () => GamesAPI,
|
|
37
|
+
SerialStationAPI: () => SerialStationAPI,
|
|
38
|
+
SerialStationClient: () => SerialStationClient,
|
|
39
|
+
TitleIDsAPI: () => TitleIDsAPI,
|
|
40
|
+
default: () => index_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
|
+
|
|
44
|
+
// src/client/BaseClient.ts
|
|
45
|
+
var import_axios = __toESM(require("axios"));
|
|
46
|
+
var SerialStationClient = class {
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new SerialStationClient instance.
|
|
49
|
+
*
|
|
50
|
+
* @param config - Configuration options for the client
|
|
51
|
+
*/
|
|
52
|
+
constructor(config = {}) {
|
|
53
|
+
this.client = import_axios.default.create({
|
|
54
|
+
baseURL: config.baseURL || "https://api.serialstation.com/v1",
|
|
55
|
+
timeout: config.timeout || 1e4,
|
|
56
|
+
headers: {
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
|
+
"Accept": "application/json",
|
|
59
|
+
...config.headers
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.retries = config.retries || 3;
|
|
63
|
+
this.retryDelay = config.retryDelay || 1e3;
|
|
64
|
+
this.client.interceptors.response.use(
|
|
65
|
+
(response) => response,
|
|
66
|
+
async (error) => {
|
|
67
|
+
if (error.response?.status && (error.response?.status === 429 || error.response?.status >= 500)) {
|
|
68
|
+
return this.retryRequest(error.config);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Retries a failed request with exponential backoff.
|
|
76
|
+
*
|
|
77
|
+
* @param config - The Axios request configuration to retry
|
|
78
|
+
* @param retryCount - Current retry attempt number
|
|
79
|
+
* @returns Promise resolving to the Axios response
|
|
80
|
+
* @throws Error if max retries exceeded
|
|
81
|
+
*/
|
|
82
|
+
async retryRequest(config, retryCount = 0) {
|
|
83
|
+
if (retryCount >= this.retries) {
|
|
84
|
+
throw new Error(`Max retries (${this.retries}) exceeded`);
|
|
85
|
+
}
|
|
86
|
+
await new Promise((resolve) => setTimeout(resolve, this.retryDelay * (retryCount + 1)));
|
|
87
|
+
try {
|
|
88
|
+
return await this.client.request(config);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return this.retryRequest(config, retryCount + 1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Performs a GET request to the specified endpoint.
|
|
95
|
+
*
|
|
96
|
+
* @param endpoint - The API endpoint path
|
|
97
|
+
* @param params - Query parameters to include in the request
|
|
98
|
+
* @returns Promise resolving to the response data
|
|
99
|
+
*/
|
|
100
|
+
async get(endpoint, params) {
|
|
101
|
+
const response = await this.client.get(endpoint, { params });
|
|
102
|
+
return response.data;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Performs a POST request to the specified endpoint.
|
|
106
|
+
*
|
|
107
|
+
* @param endpoint - The API endpoint path
|
|
108
|
+
* @param data - Request body data
|
|
109
|
+
* @returns Promise resolving to the response data
|
|
110
|
+
*/
|
|
111
|
+
async post(endpoint, data) {
|
|
112
|
+
const response = await this.client.post(endpoint, data);
|
|
113
|
+
return response.data;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Updates the base URL for all subsequent requests.
|
|
117
|
+
*
|
|
118
|
+
* @param baseURL - The new base URL
|
|
119
|
+
*/
|
|
120
|
+
setBaseURL(baseURL) {
|
|
121
|
+
this.client.defaults.baseURL = baseURL;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sets a header value for all subsequent requests.
|
|
125
|
+
*
|
|
126
|
+
* @param key - Header name
|
|
127
|
+
* @param value - Header value
|
|
128
|
+
*/
|
|
129
|
+
setHeader(key, value) {
|
|
130
|
+
this.client.defaults.headers.common[key] = value;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes a header from all subsequent requests.
|
|
134
|
+
*
|
|
135
|
+
* @param key - Header name to remove
|
|
136
|
+
*/
|
|
137
|
+
removeHeader(key) {
|
|
138
|
+
delete this.client.defaults.headers.common[key];
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// src/api/title-ids/index.ts
|
|
143
|
+
var TitleIDsAPI = class {
|
|
144
|
+
/**
|
|
145
|
+
* Creates a new TitleIDsAPI instance.
|
|
146
|
+
*
|
|
147
|
+
* @param client - The SerialStation client instance to use for requests
|
|
148
|
+
*/
|
|
149
|
+
constructor(client) {
|
|
150
|
+
this.client = client;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Lists title IDs with optional filtering and pagination.
|
|
154
|
+
*
|
|
155
|
+
* @param params - Optional parameters for filtering and pagination
|
|
156
|
+
* @returns Promise resolving to a paginated list of title IDs
|
|
157
|
+
*/
|
|
158
|
+
async listTitleIDs(params) {
|
|
159
|
+
return this.client.get("/title-ids/", params);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves title ID information by its unique identifier.
|
|
163
|
+
*
|
|
164
|
+
* @param titleId - The unique title ID (hexadecimal string)
|
|
165
|
+
* @returns Promise resolving to the title ID schema
|
|
166
|
+
*/
|
|
167
|
+
async getTitleID(titleId) {
|
|
168
|
+
return this.client.get(`/title-ids/${titleId}`);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/api/content-ids/index.ts
|
|
173
|
+
var ContentIDsAPI = class {
|
|
174
|
+
constructor(client) {
|
|
175
|
+
this.client = client;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Lists content IDs with optional filtering and pagination.
|
|
179
|
+
*/
|
|
180
|
+
async listContentIDs(params) {
|
|
181
|
+
return this.client.get("/content-ids/", params);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves content ID information by its unique identifier (36-char UUID).
|
|
185
|
+
*/
|
|
186
|
+
async getContentID(contentId) {
|
|
187
|
+
return this.client.get(`/content-ids/${contentId}`);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/api/games/index.ts
|
|
192
|
+
var GamesAPI = class {
|
|
193
|
+
constructor(client) {
|
|
194
|
+
this.client = client;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Lists games with optional filtering and pagination.
|
|
198
|
+
*/
|
|
199
|
+
async listGames(params) {
|
|
200
|
+
return this.client.get("/games/", params);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Retrieves game information by its UUID.
|
|
204
|
+
*/
|
|
205
|
+
async getGame(gameId) {
|
|
206
|
+
return this.client.get(`/games/${gameId}`);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// src/api/franchises/index.ts
|
|
211
|
+
var FranchisesAPI = class {
|
|
212
|
+
constructor(client) {
|
|
213
|
+
this.client = client;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Lists franchises with optional pagination.
|
|
217
|
+
*/
|
|
218
|
+
async listFranchises(params) {
|
|
219
|
+
return this.client.get("/franchises/", params);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// src/api/companies/index.ts
|
|
224
|
+
var CompaniesAPI = class {
|
|
225
|
+
constructor(client) {
|
|
226
|
+
this.client = client;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Lists companies with optional pagination.
|
|
230
|
+
*/
|
|
231
|
+
async listCompanies(params) {
|
|
232
|
+
return this.client.get("/companies/", params);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// src/index.ts
|
|
237
|
+
var SerialStationAPI = class {
|
|
238
|
+
/**
|
|
239
|
+
* Creates a new SerialStationAPI instance.
|
|
240
|
+
*
|
|
241
|
+
* @param config - Configuration options for the API client
|
|
242
|
+
*/
|
|
243
|
+
constructor(config = {}) {
|
|
244
|
+
const client = new SerialStationClient(config);
|
|
245
|
+
this.titleIds = new TitleIDsAPI(client);
|
|
246
|
+
this.contentIds = new ContentIDsAPI(client);
|
|
247
|
+
this.games = new GamesAPI(client);
|
|
248
|
+
this.franchises = new FranchisesAPI(client);
|
|
249
|
+
this.companies = new CompaniesAPI(client);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var index_default = SerialStationAPI;
|
|
253
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
254
|
+
0 && (module.exports = {
|
|
255
|
+
CompaniesAPI,
|
|
256
|
+
ContentIDsAPI,
|
|
257
|
+
FranchisesAPI,
|
|
258
|
+
GamesAPI,
|
|
259
|
+
SerialStationAPI,
|
|
260
|
+
SerialStationClient,
|
|
261
|
+
TitleIDsAPI
|
|
262
|
+
});
|
|
263
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client/BaseClient.ts","../src/api/title-ids/index.ts","../src/api/content-ids/index.ts","../src/api/games/index.ts","../src/api/franchises/index.ts","../src/api/companies/index.ts"],"sourcesContent":["import { SerialStationClient, SerialStationClientConfig } from './client/BaseClient';\r\nimport { TitleIDsAPI } from './api/title-ids';\r\nimport { ContentIDsAPI } from './api/content-ids';\r\nimport { GamesAPI } from './api/games';\r\nimport { FranchisesAPI } from './api/franchises';\r\nimport { CompaniesAPI } from './api/companies';\r\n\r\n/**\r\n * Main API client for interacting with the SerialStation API.\r\n * Provides access to all available API endpoints through specialized API classes.\r\n *\r\n * @example\r\n * ```typescript\r\n * const api = new SerialStationAPI({ baseURL: 'https://api.serialstation.com/v1' });\r\n * const titleIds = await api.titleIds.listTitleIDs({ system: 'PS4' });\r\n * ```\r\n */\r\nexport class SerialStationAPI {\r\n /** API for title ID information */\r\n public titleIds: TitleIDsAPI;\r\n /** API for content ID information */\r\n public contentIds: ContentIDsAPI;\r\n /** API for game information */\r\n public games: GamesAPI;\r\n /** API for franchise information */\r\n public franchises: FranchisesAPI;\r\n /** API for company information (developers, publishers) */\r\n public companies: CompaniesAPI;\r\n\r\n /**\r\n * Creates a new SerialStationAPI instance.\r\n *\r\n * @param config - Configuration options for the API client\r\n */\r\n constructor(config: SerialStationClientConfig = {}) {\r\n const client = new SerialStationClient(config);\r\n this.titleIds = new TitleIDsAPI(client);\r\n this.contentIds = new ContentIDsAPI(client);\r\n this.games = new GamesAPI(client);\r\n this.franchises = new FranchisesAPI(client);\r\n this.companies = new CompaniesAPI(client);\r\n }\r\n}\r\n\r\nexport {\r\n SerialStationClient,\r\n TitleIDsAPI,\r\n ContentIDsAPI,\r\n GamesAPI,\r\n FranchisesAPI,\r\n CompaniesAPI\r\n};\r\n\r\nexport * from './types';\r\n\r\nexport type {\r\n TitleIDSchema,\r\n PagedTitleIDSchema,\r\n TitleIDFilterParams,\r\n TitleIDGameSchema,\r\n Console\r\n} from './api/title-ids/types';\r\n\r\nexport type {\r\n ContentIDSchema,\r\n PagedContentIDSchema,\r\n ContentIDFilterParams\r\n} from './api/content-ids/types';\r\n\r\nexport type {\r\n GameSchema,\r\n PagedGameSchema,\r\n GameFilterParams,\r\n GameCompanySchema,\r\n GameFranchiseSchema\r\n} from './api/games/types';\r\n\r\nexport type {\r\n FranchiseSchema,\r\n PagedFranchiseSchema,\r\n FranchiseFilterParams\r\n} from './api/franchises/types';\r\n\r\nexport type {\r\n CompanySchema,\r\n PagedCompanySchema,\r\n CompanyFilterParams\r\n} from './api/companies/types';\r\n\r\nexport default SerialStationAPI;\r\n","import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';\r\n\r\n/**\r\n * Configuration options for the SerialStation API client.\r\n */\r\nexport interface SerialStationClientConfig {\r\n /** Base URL for API requests. Defaults to 'https://api.serialstation.com/v1' */\r\n baseURL?: string;\r\n /** Request timeout in milliseconds. Defaults to 10000 */\r\n timeout?: number;\r\n /** Additional HTTP headers to include with requests */\r\n headers?: Record<string, string>;\r\n /** Number of retry attempts for failed requests. Defaults to 3 */\r\n retries?: number;\r\n /** Delay between retries in milliseconds. Defaults to 1000 */\r\n retryDelay?: number;\r\n}\r\n\r\n/**\r\n * Base HTTP client for making requests to the SerialStation API.\r\n * Handles retries, error handling, and request configuration.\r\n */\r\nexport class SerialStationClient {\r\n private client: AxiosInstance;\r\n private retries: number;\r\n private retryDelay: number;\r\n\r\n /**\r\n * Creates a new SerialStationClient instance.\r\n * \r\n * @param config - Configuration options for the client\r\n */\r\n constructor(config: SerialStationClientConfig = {}) {\r\n this.client = axios.create({\r\n baseURL: config.baseURL || 'https://api.serialstation.com/v1',\r\n timeout: config.timeout || 10000,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Accept': 'application/json',\r\n ...config.headers\r\n }\r\n });\r\n\r\n this.retries = config.retries || 3;\r\n this.retryDelay = config.retryDelay || 1000;\r\n\r\n this.client.interceptors.response.use(\r\n (response) => response,\r\n async (error: AxiosError) => {\r\n if (error.response?.status && (error.response?.status === 429 || error.response?.status >= 500)) {\r\n return this.retryRequest(error.config!);\r\n }\r\n throw error;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Retries a failed request with exponential backoff.\r\n * \r\n * @param config - The Axios request configuration to retry\r\n * @param retryCount - Current retry attempt number\r\n * @returns Promise resolving to the Axios response\r\n * @throws Error if max retries exceeded\r\n */\r\n private async retryRequest(config: AxiosRequestConfig, retryCount = 0): Promise<AxiosResponse> {\r\n if (retryCount >= this.retries) {\r\n throw new Error(`Max retries (${this.retries}) exceeded`);\r\n }\r\n\r\n await new Promise(resolve => setTimeout(resolve, this.retryDelay * (retryCount + 1)));\r\n\r\n try {\r\n return await this.client.request(config);\r\n } catch (error) {\r\n return this.retryRequest(config, retryCount + 1);\r\n }\r\n }\r\n\r\n /**\r\n * Performs a GET request to the specified endpoint.\r\n * \r\n * @param endpoint - The API endpoint path\r\n * @param params - Query parameters to include in the request\r\n * @returns Promise resolving to the response data\r\n */\r\n async get<T>(endpoint: string, params?: any): Promise<T> {\r\n const response: AxiosResponse<T> = await this.client.get(endpoint, { params });\r\n return response.data;\r\n }\r\n\r\n /**\r\n * Performs a POST request to the specified endpoint.\r\n * \r\n * @param endpoint - The API endpoint path\r\n * @param data - Request body data\r\n * @returns Promise resolving to the response data\r\n */\r\n async post<T>(endpoint: string, data?: any): Promise<T> {\r\n const response: AxiosResponse<T> = await this.client.post(endpoint, data);\r\n return response.data;\r\n }\r\n\r\n /**\r\n * Updates the base URL for all subsequent requests.\r\n * \r\n * @param baseURL - The new base URL\r\n */\r\n setBaseURL(baseURL: string): void {\r\n this.client.defaults.baseURL = baseURL;\r\n }\r\n\r\n /**\r\n * Sets a header value for all subsequent requests.\r\n * \r\n * @param key - Header name\r\n * @param value - Header value\r\n */\r\n setHeader(key: string, value: string): void {\r\n this.client.defaults.headers.common[key] = value;\r\n }\r\n\r\n /**\r\n * Removes a header from all subsequent requests.\r\n * \r\n * @param key - Header name to remove\r\n */\r\n removeHeader(key: string): void {\r\n delete this.client.defaults.headers.common[key];\r\n }\r\n}","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { TitleIDSchema, PagedTitleIDSchema, TitleIDFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing title ID information.\r\n * Provides methods to query and retrieve PlayStation title ID data.\r\n */\r\nexport class TitleIDsAPI {\r\n /**\r\n * Creates a new TitleIDsAPI instance.\r\n * \r\n * @param client - The SerialStation client instance to use for requests\r\n */\r\n constructor(private client: SerialStationClient) {}\r\n \r\n /**\r\n * Lists title IDs with optional filtering and pagination.\r\n * \r\n * @param params - Optional parameters for filtering and pagination\r\n * @returns Promise resolving to a paginated list of title IDs\r\n */\r\n async listTitleIDs(params?: TitleIDFilterParams): Promise<PagedTitleIDSchema> {\r\n return this.client.get<PagedTitleIDSchema>('/title-ids/', params);\r\n }\r\n \r\n /**\r\n * Retrieves title ID information by its unique identifier.\r\n * \r\n * @param titleId - The unique title ID (hexadecimal string)\r\n * @returns Promise resolving to the title ID schema\r\n */\r\n async getTitleID(titleId: string): Promise<TitleIDSchema> {\r\n return this.client.get<TitleIDSchema>(`/title-ids/${titleId}`);\r\n }\r\n}","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { ContentIDSchema, PagedContentIDSchema, ContentIDFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing content ID information.\r\n */\r\nexport class ContentIDsAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists content IDs with optional filtering and pagination.\r\n */\r\n async listContentIDs(params?: ContentIDFilterParams): Promise<PagedContentIDSchema> {\r\n return this.client.get<PagedContentIDSchema>('/content-ids/', params);\r\n }\r\n\r\n /**\r\n * Retrieves content ID information by its unique identifier (36-char UUID).\r\n */\r\n async getContentID(contentId: string): Promise<ContentIDSchema> {\r\n return this.client.get<ContentIDSchema>(`/content-ids/${contentId}`);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { GameSchema, PagedGameSchema, GameFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing game information.\r\n */\r\nexport class GamesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists games with optional filtering and pagination.\r\n */\r\n async listGames(params?: GameFilterParams): Promise<PagedGameSchema> {\r\n return this.client.get<PagedGameSchema>('/games/', params);\r\n }\r\n\r\n /**\r\n * Retrieves game information by its UUID.\r\n */\r\n async getGame(gameId: string): Promise<GameSchema> {\r\n return this.client.get<GameSchema>(`/games/${gameId}`);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { PagedFranchiseSchema, FranchiseFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing franchise information.\r\n */\r\nexport class FranchisesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists franchises with optional pagination.\r\n */\r\n async listFranchises(params?: FranchiseFilterParams): Promise<PagedFranchiseSchema> {\r\n return this.client.get<PagedFranchiseSchema>('/franchises/', params);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { PagedCompanySchema, CompanyFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing company information (developers, publishers).\r\n */\r\nexport class CompaniesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists companies with optional pagination.\r\n */\r\n async listCompanies(params?: CompanyFilterParams): Promise<PagedCompanySchema> {\r\n return this.client.get<PagedCompanySchema>('/companies/', params);\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAoF;AAsB7E,IAAM,sBAAN,MAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU7B,YAAY,SAAoC,CAAC,GAAG;AAChD,SAAK,SAAS,aAAAA,QAAM,OAAO;AAAA,MACvB,SAAS,OAAO,WAAW;AAAA,MAC3B,SAAS,OAAO,WAAW;AAAA,MAC3B,SAAS;AAAA,QACL,gBAAgB;AAAA,QAChB,UAAU;AAAA,QACV,GAAG,OAAO;AAAA,MACd;AAAA,IACJ,CAAC;AAED,SAAK,UAAU,OAAO,WAAW;AACjC,SAAK,aAAa,OAAO,cAAc;AAEvC,SAAK,OAAO,aAAa,SAAS;AAAA,MAC9B,CAAC,aAAa;AAAA,MACd,OAAO,UAAsB;AACzB,YAAI,MAAM,UAAU,WAAW,MAAM,UAAU,WAAW,OAAO,MAAM,UAAU,UAAU,MAAM;AAC7F,iBAAO,KAAK,aAAa,MAAM,MAAO;AAAA,QAC1C;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wB,eAAe,MAAM;AAAA,EAClE;AACF;;;ANEO,IAAM,mBAAN,MAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiB5B,YAAY,SAAoC,CAAC,GAAG;AAClD,UAAM,SAAS,IAAI,oBAAoB,MAAM;AAC7C,SAAK,WAAW,IAAI,YAAY,MAAM;AACtC,SAAK,aAAa,IAAI,cAAc,MAAM;AAC1C,SAAK,QAAQ,IAAI,SAAS,MAAM;AAChC,SAAK,aAAa,IAAI,cAAc,MAAM;AAC1C,SAAK,YAAY,IAAI,aAAa,MAAM;AAAA,EAC1C;AACF;AA+CA,IAAO,gBAAQ;","names":["axios"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// src/client/BaseClient.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var SerialStationClient = class {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new SerialStationClient instance.
|
|
6
|
+
*
|
|
7
|
+
* @param config - Configuration options for the client
|
|
8
|
+
*/
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.client = axios.create({
|
|
11
|
+
baseURL: config.baseURL || "https://api.serialstation.com/v1",
|
|
12
|
+
timeout: config.timeout || 1e4,
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
"Accept": "application/json",
|
|
16
|
+
...config.headers
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
this.retries = config.retries || 3;
|
|
20
|
+
this.retryDelay = config.retryDelay || 1e3;
|
|
21
|
+
this.client.interceptors.response.use(
|
|
22
|
+
(response) => response,
|
|
23
|
+
async (error) => {
|
|
24
|
+
if (error.response?.status && (error.response?.status === 429 || error.response?.status >= 500)) {
|
|
25
|
+
return this.retryRequest(error.config);
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Retries a failed request with exponential backoff.
|
|
33
|
+
*
|
|
34
|
+
* @param config - The Axios request configuration to retry
|
|
35
|
+
* @param retryCount - Current retry attempt number
|
|
36
|
+
* @returns Promise resolving to the Axios response
|
|
37
|
+
* @throws Error if max retries exceeded
|
|
38
|
+
*/
|
|
39
|
+
async retryRequest(config, retryCount = 0) {
|
|
40
|
+
if (retryCount >= this.retries) {
|
|
41
|
+
throw new Error(`Max retries (${this.retries}) exceeded`);
|
|
42
|
+
}
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, this.retryDelay * (retryCount + 1)));
|
|
44
|
+
try {
|
|
45
|
+
return await this.client.request(config);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return this.retryRequest(config, retryCount + 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Performs a GET request to the specified endpoint.
|
|
52
|
+
*
|
|
53
|
+
* @param endpoint - The API endpoint path
|
|
54
|
+
* @param params - Query parameters to include in the request
|
|
55
|
+
* @returns Promise resolving to the response data
|
|
56
|
+
*/
|
|
57
|
+
async get(endpoint, params) {
|
|
58
|
+
const response = await this.client.get(endpoint, { params });
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Performs a POST request to the specified endpoint.
|
|
63
|
+
*
|
|
64
|
+
* @param endpoint - The API endpoint path
|
|
65
|
+
* @param data - Request body data
|
|
66
|
+
* @returns Promise resolving to the response data
|
|
67
|
+
*/
|
|
68
|
+
async post(endpoint, data) {
|
|
69
|
+
const response = await this.client.post(endpoint, data);
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Updates the base URL for all subsequent requests.
|
|
74
|
+
*
|
|
75
|
+
* @param baseURL - The new base URL
|
|
76
|
+
*/
|
|
77
|
+
setBaseURL(baseURL) {
|
|
78
|
+
this.client.defaults.baseURL = baseURL;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sets a header value for all subsequent requests.
|
|
82
|
+
*
|
|
83
|
+
* @param key - Header name
|
|
84
|
+
* @param value - Header value
|
|
85
|
+
*/
|
|
86
|
+
setHeader(key, value) {
|
|
87
|
+
this.client.defaults.headers.common[key] = value;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Removes a header from all subsequent requests.
|
|
91
|
+
*
|
|
92
|
+
* @param key - Header name to remove
|
|
93
|
+
*/
|
|
94
|
+
removeHeader(key) {
|
|
95
|
+
delete this.client.defaults.headers.common[key];
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/api/title-ids/index.ts
|
|
100
|
+
var TitleIDsAPI = class {
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new TitleIDsAPI instance.
|
|
103
|
+
*
|
|
104
|
+
* @param client - The SerialStation client instance to use for requests
|
|
105
|
+
*/
|
|
106
|
+
constructor(client) {
|
|
107
|
+
this.client = client;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Lists title IDs with optional filtering and pagination.
|
|
111
|
+
*
|
|
112
|
+
* @param params - Optional parameters for filtering and pagination
|
|
113
|
+
* @returns Promise resolving to a paginated list of title IDs
|
|
114
|
+
*/
|
|
115
|
+
async listTitleIDs(params) {
|
|
116
|
+
return this.client.get("/title-ids/", params);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves title ID information by its unique identifier.
|
|
120
|
+
*
|
|
121
|
+
* @param titleId - The unique title ID (hexadecimal string)
|
|
122
|
+
* @returns Promise resolving to the title ID schema
|
|
123
|
+
*/
|
|
124
|
+
async getTitleID(titleId) {
|
|
125
|
+
return this.client.get(`/title-ids/${titleId}`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/api/content-ids/index.ts
|
|
130
|
+
var ContentIDsAPI = class {
|
|
131
|
+
constructor(client) {
|
|
132
|
+
this.client = client;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Lists content IDs with optional filtering and pagination.
|
|
136
|
+
*/
|
|
137
|
+
async listContentIDs(params) {
|
|
138
|
+
return this.client.get("/content-ids/", params);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves content ID information by its unique identifier (36-char UUID).
|
|
142
|
+
*/
|
|
143
|
+
async getContentID(contentId) {
|
|
144
|
+
return this.client.get(`/content-ids/${contentId}`);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/api/games/index.ts
|
|
149
|
+
var GamesAPI = class {
|
|
150
|
+
constructor(client) {
|
|
151
|
+
this.client = client;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Lists games with optional filtering and pagination.
|
|
155
|
+
*/
|
|
156
|
+
async listGames(params) {
|
|
157
|
+
return this.client.get("/games/", params);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Retrieves game information by its UUID.
|
|
161
|
+
*/
|
|
162
|
+
async getGame(gameId) {
|
|
163
|
+
return this.client.get(`/games/${gameId}`);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/api/franchises/index.ts
|
|
168
|
+
var FranchisesAPI = class {
|
|
169
|
+
constructor(client) {
|
|
170
|
+
this.client = client;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Lists franchises with optional pagination.
|
|
174
|
+
*/
|
|
175
|
+
async listFranchises(params) {
|
|
176
|
+
return this.client.get("/franchises/", params);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/api/companies/index.ts
|
|
181
|
+
var CompaniesAPI = class {
|
|
182
|
+
constructor(client) {
|
|
183
|
+
this.client = client;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Lists companies with optional pagination.
|
|
187
|
+
*/
|
|
188
|
+
async listCompanies(params) {
|
|
189
|
+
return this.client.get("/companies/", params);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/index.ts
|
|
194
|
+
var SerialStationAPI = class {
|
|
195
|
+
/**
|
|
196
|
+
* Creates a new SerialStationAPI instance.
|
|
197
|
+
*
|
|
198
|
+
* @param config - Configuration options for the API client
|
|
199
|
+
*/
|
|
200
|
+
constructor(config = {}) {
|
|
201
|
+
const client = new SerialStationClient(config);
|
|
202
|
+
this.titleIds = new TitleIDsAPI(client);
|
|
203
|
+
this.contentIds = new ContentIDsAPI(client);
|
|
204
|
+
this.games = new GamesAPI(client);
|
|
205
|
+
this.franchises = new FranchisesAPI(client);
|
|
206
|
+
this.companies = new CompaniesAPI(client);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var index_default = SerialStationAPI;
|
|
210
|
+
export {
|
|
211
|
+
CompaniesAPI,
|
|
212
|
+
ContentIDsAPI,
|
|
213
|
+
FranchisesAPI,
|
|
214
|
+
GamesAPI,
|
|
215
|
+
SerialStationAPI,
|
|
216
|
+
SerialStationClient,
|
|
217
|
+
TitleIDsAPI,
|
|
218
|
+
index_default as default
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client/BaseClient.ts","../src/api/title-ids/index.ts","../src/api/content-ids/index.ts","../src/api/games/index.ts","../src/api/franchises/index.ts","../src/api/companies/index.ts","../src/index.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';\r\n\r\n/**\r\n * Configuration options for the SerialStation API client.\r\n */\r\nexport interface SerialStationClientConfig {\r\n /** Base URL for API requests. Defaults to 'https://api.serialstation.com/v1' */\r\n baseURL?: string;\r\n /** Request timeout in milliseconds. Defaults to 10000 */\r\n timeout?: number;\r\n /** Additional HTTP headers to include with requests */\r\n headers?: Record<string, string>;\r\n /** Number of retry attempts for failed requests. Defaults to 3 */\r\n retries?: number;\r\n /** Delay between retries in milliseconds. Defaults to 1000 */\r\n retryDelay?: number;\r\n}\r\n\r\n/**\r\n * Base HTTP client for making requests to the SerialStation API.\r\n * Handles retries, error handling, and request configuration.\r\n */\r\nexport class SerialStationClient {\r\n private client: AxiosInstance;\r\n private retries: number;\r\n private retryDelay: number;\r\n\r\n /**\r\n * Creates a new SerialStationClient instance.\r\n * \r\n * @param config - Configuration options for the client\r\n */\r\n constructor(config: SerialStationClientConfig = {}) {\r\n this.client = axios.create({\r\n baseURL: config.baseURL || 'https://api.serialstation.com/v1',\r\n timeout: config.timeout || 10000,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Accept': 'application/json',\r\n ...config.headers\r\n }\r\n });\r\n\r\n this.retries = config.retries || 3;\r\n this.retryDelay = config.retryDelay || 1000;\r\n\r\n this.client.interceptors.response.use(\r\n (response) => response,\r\n async (error: AxiosError) => {\r\n if (error.response?.status && (error.response?.status === 429 || error.response?.status >= 500)) {\r\n return this.retryRequest(error.config!);\r\n }\r\n throw error;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Retries a failed request with exponential backoff.\r\n * \r\n * @param config - The Axios request configuration to retry\r\n * @param retryCount - Current retry attempt number\r\n * @returns Promise resolving to the Axios response\r\n * @throws Error if max retries exceeded\r\n */\r\n private async retryRequest(config: AxiosRequestConfig, retryCount = 0): Promise<AxiosResponse> {\r\n if (retryCount >= this.retries) {\r\n throw new Error(`Max retries (${this.retries}) exceeded`);\r\n }\r\n\r\n await new Promise(resolve => setTimeout(resolve, this.retryDelay * (retryCount + 1)));\r\n\r\n try {\r\n return await this.client.request(config);\r\n } catch (error) {\r\n return this.retryRequest(config, retryCount + 1);\r\n }\r\n }\r\n\r\n /**\r\n * Performs a GET request to the specified endpoint.\r\n * \r\n * @param endpoint - The API endpoint path\r\n * @param params - Query parameters to include in the request\r\n * @returns Promise resolving to the response data\r\n */\r\n async get<T>(endpoint: string, params?: any): Promise<T> {\r\n const response: AxiosResponse<T> = await this.client.get(endpoint, { params });\r\n return response.data;\r\n }\r\n\r\n /**\r\n * Performs a POST request to the specified endpoint.\r\n * \r\n * @param endpoint - The API endpoint path\r\n * @param data - Request body data\r\n * @returns Promise resolving to the response data\r\n */\r\n async post<T>(endpoint: string, data?: any): Promise<T> {\r\n const response: AxiosResponse<T> = await this.client.post(endpoint, data);\r\n return response.data;\r\n }\r\n\r\n /**\r\n * Updates the base URL for all subsequent requests.\r\n * \r\n * @param baseURL - The new base URL\r\n */\r\n setBaseURL(baseURL: string): void {\r\n this.client.defaults.baseURL = baseURL;\r\n }\r\n\r\n /**\r\n * Sets a header value for all subsequent requests.\r\n * \r\n * @param key - Header name\r\n * @param value - Header value\r\n */\r\n setHeader(key: string, value: string): void {\r\n this.client.defaults.headers.common[key] = value;\r\n }\r\n\r\n /**\r\n * Removes a header from all subsequent requests.\r\n * \r\n * @param key - Header name to remove\r\n */\r\n removeHeader(key: string): void {\r\n delete this.client.defaults.headers.common[key];\r\n }\r\n}","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { TitleIDSchema, PagedTitleIDSchema, TitleIDFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing title ID information.\r\n * Provides methods to query and retrieve PlayStation title ID data.\r\n */\r\nexport class TitleIDsAPI {\r\n /**\r\n * Creates a new TitleIDsAPI instance.\r\n * \r\n * @param client - The SerialStation client instance to use for requests\r\n */\r\n constructor(private client: SerialStationClient) {}\r\n \r\n /**\r\n * Lists title IDs with optional filtering and pagination.\r\n * \r\n * @param params - Optional parameters for filtering and pagination\r\n * @returns Promise resolving to a paginated list of title IDs\r\n */\r\n async listTitleIDs(params?: TitleIDFilterParams): Promise<PagedTitleIDSchema> {\r\n return this.client.get<PagedTitleIDSchema>('/title-ids/', params);\r\n }\r\n \r\n /**\r\n * Retrieves title ID information by its unique identifier.\r\n * \r\n * @param titleId - The unique title ID (hexadecimal string)\r\n * @returns Promise resolving to the title ID schema\r\n */\r\n async getTitleID(titleId: string): Promise<TitleIDSchema> {\r\n return this.client.get<TitleIDSchema>(`/title-ids/${titleId}`);\r\n }\r\n}","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { ContentIDSchema, PagedContentIDSchema, ContentIDFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing content ID information.\r\n */\r\nexport class ContentIDsAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists content IDs with optional filtering and pagination.\r\n */\r\n async listContentIDs(params?: ContentIDFilterParams): Promise<PagedContentIDSchema> {\r\n return this.client.get<PagedContentIDSchema>('/content-ids/', params);\r\n }\r\n\r\n /**\r\n * Retrieves content ID information by its unique identifier (36-char UUID).\r\n */\r\n async getContentID(contentId: string): Promise<ContentIDSchema> {\r\n return this.client.get<ContentIDSchema>(`/content-ids/${contentId}`);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { GameSchema, PagedGameSchema, GameFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing game information.\r\n */\r\nexport class GamesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists games with optional filtering and pagination.\r\n */\r\n async listGames(params?: GameFilterParams): Promise<PagedGameSchema> {\r\n return this.client.get<PagedGameSchema>('/games/', params);\r\n }\r\n\r\n /**\r\n * Retrieves game information by its UUID.\r\n */\r\n async getGame(gameId: string): Promise<GameSchema> {\r\n return this.client.get<GameSchema>(`/games/${gameId}`);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { PagedFranchiseSchema, FranchiseFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing franchise information.\r\n */\r\nexport class FranchisesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists franchises with optional pagination.\r\n */\r\n async listFranchises(params?: FranchiseFilterParams): Promise<PagedFranchiseSchema> {\r\n return this.client.get<PagedFranchiseSchema>('/franchises/', params);\r\n }\r\n}\r\n","import { SerialStationClient } from '../../client/BaseClient';\r\nimport { PagedCompanySchema, CompanyFilterParams } from './types';\r\n\r\n/**\r\n * API client for managing company information (developers, publishers).\r\n */\r\nexport class CompaniesAPI {\r\n constructor(private client: SerialStationClient) {}\r\n\r\n /**\r\n * Lists companies with optional pagination.\r\n */\r\n async listCompanies(params?: CompanyFilterParams): Promise<PagedCompanySchema> {\r\n return this.client.get<PagedCompanySchema>('/companies/', params);\r\n }\r\n}\r\n","import { SerialStationClient, SerialStationClientConfig } from './client/BaseClient';\r\nimport { TitleIDsAPI } from './api/title-ids';\r\nimport { ContentIDsAPI } from './api/content-ids';\r\nimport { GamesAPI } from './api/games';\r\nimport { FranchisesAPI } from './api/franchises';\r\nimport { CompaniesAPI } from './api/companies';\r\n\r\n/**\r\n * Main API client for interacting with the SerialStation API.\r\n * Provides access to all available API endpoints through specialized API classes.\r\n *\r\n * @example\r\n * ```typescript\r\n * const api = new SerialStationAPI({ baseURL: 'https://api.serialstation.com/v1' });\r\n * const titleIds = await api.titleIds.listTitleIDs({ system: 'PS4' });\r\n * ```\r\n */\r\nexport class SerialStationAPI {\r\n /** API for title ID information */\r\n public titleIds: TitleIDsAPI;\r\n /** API for content ID information */\r\n public contentIds: ContentIDsAPI;\r\n /** API for game information */\r\n public games: GamesAPI;\r\n /** API for franchise information */\r\n public franchises: FranchisesAPI;\r\n /** API for company information (developers, publishers) */\r\n public companies: CompaniesAPI;\r\n\r\n /**\r\n * Creates a new SerialStationAPI instance.\r\n *\r\n * @param config - Configuration options for the API client\r\n */\r\n constructor(config: SerialStationClientConfig = {}) {\r\n const client = new SerialStationClient(config);\r\n this.titleIds = new TitleIDsAPI(client);\r\n this.contentIds = new ContentIDsAPI(client);\r\n this.games = new GamesAPI(client);\r\n this.franchises = new FranchisesAPI(client);\r\n this.companies = new CompaniesAPI(client);\r\n }\r\n}\r\n\r\nexport {\r\n SerialStationClient,\r\n TitleIDsAPI,\r\n ContentIDsAPI,\r\n GamesAPI,\r\n FranchisesAPI,\r\n CompaniesAPI\r\n};\r\n\r\nexport * from './types';\r\n\r\nexport type {\r\n TitleIDSchema,\r\n PagedTitleIDSchema,\r\n TitleIDFilterParams,\r\n TitleIDGameSchema,\r\n Console\r\n} from './api/title-ids/types';\r\n\r\nexport type {\r\n ContentIDSchema,\r\n PagedContentIDSchema,\r\n ContentIDFilterParams\r\n} from './api/content-ids/types';\r\n\r\nexport type {\r\n GameSchema,\r\n PagedGameSchema,\r\n GameFilterParams,\r\n GameCompanySchema,\r\n GameFranchiseSchema\r\n} from './api/games/types';\r\n\r\nexport type {\r\n FranchiseSchema,\r\n PagedFranchiseSchema,\r\n FranchiseFilterParams\r\n} from './api/franchises/types';\r\n\r\nexport type {\r\n CompanySchema,\r\n PagedCompanySchema,\r\n CompanyFilterParams\r\n} from './api/companies/types';\r\n\r\nexport default SerialStationAPI;\r\n"],"mappings":";AAAA,OAAO,WAA6E;AAsB7E,IAAM,sBAAN,MAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU7B,YAAY,SAAoC,CAAC,GAAG;AAChD,SAAK,SAAS,MAAM,OAAO;AAAA,MACvB,SAAS,OAAO,WAAW;AAAA,MAC3B,SAAS,OAAO,WAAW;AAAA,MAC3B,SAAS;AAAA,QACL,gBAAgB;AAAA,QAChB,UAAU;AAAA,QACV,GAAG,OAAO;AAAA,MACd;AAAA,IACJ,CAAC;AAED,SAAK,UAAU,OAAO,WAAW;AACjC,SAAK,aAAa,OAAO,cAAc;AAEvC,SAAK,OAAO,aAAa,SAAS;AAAA,MAC9B,CAAC,aAAa;AAAA,MACd,OAAO,UAAsB;AACzB,YAAI,MAAM,UAAU,WAAW,MAAM,UAAU,WAAW,OAAO,MAAM,UAAU,UAAU,MAAM;AAC7F,iBAAO,KAAK,aAAa,MAAM,MAAO;AAAA,QAC1C;AACA,cAAM;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAc,aAAa,QAA4B,aAAa,GAA2B;AAC3F,QAAI,cAAc,KAAK,SAAS;AAC5B,YAAM,IAAI,MAAM,gBAAgB,KAAK,OAAO,Y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K,aAAa,IAAI,cAAc,MAAM;AAC1C,SAAK,QAAQ,IAAI,SAAS,MAAM;AAChC,SAAK,aAAa,IAAI,cAAc,MAAM;AAC1C,SAAK,YAAY,IAAI,aAAa,MAAM;AAAA,EAC1C;AACF;AA+CA,IAAO,gBAAQ;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { O as OrderDirection, P as PagedTitleIDSchema, T as TitleIDFilterParams, a as TitleIDGameSchema, b as TitleIDOrderFields, c as TitleIDSchema } from '../types-KwGU8D6g.mjs';
|
|
2
|
+
export { C as ContentIDFilterParams, a as ContentIDOrderFields, b as ContentIDSchema, P as PagedContentIDSchema } from '../types-BnaHEIcd.mjs';
|
|
3
|
+
export { G as GameCompanySchema, a as GameFilterParams, b as GameFranchiseSchema, c as GameOrderFields, d as GameSchema, P as PagedGameSchema } from '../types-Dv-1DNPu.mjs';
|
|
4
|
+
export { F as FranchiseFilterParams, a as FranchiseSchema, P as PagedFranchiseSchema } from '../types-axGWx6HR.mjs';
|
|
5
|
+
export { C as CompanyFilterParams, a as CompanySchema, P as PagedCompanySchema } from '../types-BjzcHkoc.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Console values supported by the API (PlayStation platforms).
|
|
9
|
+
*/
|
|
10
|
+
type Console = 'PS1' | 'PS2' | 'PS3' | 'PS4' | 'PS5' | 'PSP' | 'PSV' | 'PSM';
|
|
11
|
+
/**
|
|
12
|
+
* Generic paginated response structure.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of items in the response
|
|
15
|
+
*/
|
|
16
|
+
interface PagedResponse<T> {
|
|
17
|
+
/** Array of items in the current page */
|
|
18
|
+
items: T[];
|
|
19
|
+
/** Total count of items across all pages */
|
|
20
|
+
count: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type { Console, PagedResponse };
|