@carddb/client 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/dist/index.js ADDED
@@ -0,0 +1,1219 @@
1
+ import { RestrictedError, RateLimitError, ServerError, ConnectionError, TimeoutError, CardDBError, AuthenticationError, GraphQLError, ValidationError, QueryBuilder, Collection, resolveFilter } from '@carddb/core';
2
+ export * from '@carddb/core';
3
+
4
+ // src/client.ts
5
+ var DEFAULT_ENDPOINT = "https://carddb.xtda.org/query";
6
+ var DEFAULT_TIMEOUT = 3e4;
7
+ var DEFAULT_OPEN_TIMEOUT = 1e4;
8
+ var DEFAULT_CACHE_TTL = 300;
9
+ var DEFAULT_MAX_RETRIES = 3;
10
+ var DEFAULT_MAX_NETWORK_RETRIES = 2;
11
+ var DEFAULT_RETRY_BASE_DELAY = 1e3;
12
+ var DEFAULT_RETRY_MAX_DELAY = 3e4;
13
+ var Configuration = class _Configuration {
14
+ apiKey;
15
+ endpoint;
16
+ timeout;
17
+ openTimeout;
18
+ defaultPublisher;
19
+ defaultGame;
20
+ allowedPublishers;
21
+ allowedGames;
22
+ logger;
23
+ logLevel;
24
+ retryOnRateLimit;
25
+ maxRetries;
26
+ retryOnNetworkError;
27
+ maxNetworkRetries;
28
+ retryBaseDelay;
29
+ retryMaxDelay;
30
+ cache;
31
+ cacheTtl;
32
+ cacheTtls;
33
+ constructor(config = {}) {
34
+ this.apiKey = config.apiKey;
35
+ this.endpoint = config.endpoint ?? DEFAULT_ENDPOINT;
36
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
37
+ this.openTimeout = config.openTimeout ?? DEFAULT_OPEN_TIMEOUT;
38
+ this.defaultPublisher = config.defaultPublisher;
39
+ this.defaultGame = config.defaultGame;
40
+ this.allowedPublishers = config.allowedPublishers;
41
+ this.allowedGames = config.allowedGames;
42
+ this.logger = config.logger;
43
+ this.logLevel = config.logLevel ?? "info";
44
+ this.retryOnRateLimit = config.retryOnRateLimit ?? false;
45
+ this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
46
+ this.retryOnNetworkError = config.retryOnNetworkError ?? true;
47
+ this.maxNetworkRetries = config.maxNetworkRetries ?? DEFAULT_MAX_NETWORK_RETRIES;
48
+ this.retryBaseDelay = config.retryBaseDelay ?? DEFAULT_RETRY_BASE_DELAY;
49
+ this.retryMaxDelay = config.retryMaxDelay ?? DEFAULT_RETRY_MAX_DELAY;
50
+ this.cache = config.cache;
51
+ this.cacheTtl = config.cacheTtl ?? DEFAULT_CACHE_TTL;
52
+ this.cacheTtls = config.cacheTtls ?? {};
53
+ }
54
+ /**
55
+ * Calculate delay for exponential backoff
56
+ * @param attempt - The attempt number (0-indexed)
57
+ * @returns Delay in milliseconds with jitter
58
+ */
59
+ calculateRetryDelay(attempt) {
60
+ const exponentialDelay = this.retryBaseDelay * Math.pow(2, attempt);
61
+ const cappedDelay = Math.min(exponentialDelay, this.retryMaxDelay);
62
+ const jitter = cappedDelay * 0.25 * (Math.random() * 2 - 1);
63
+ return Math.round(cappedDelay + jitter);
64
+ }
65
+ /**
66
+ * Get the cache TTL for a specific resource type
67
+ */
68
+ cacheTtlFor(resource) {
69
+ return this.cacheTtls[resource] ?? this.cacheTtl;
70
+ }
71
+ /**
72
+ * Resolve publisher slug, using default if not provided
73
+ */
74
+ resolvePublisher(publisherSlug) {
75
+ return publisherSlug ?? this.defaultPublisher;
76
+ }
77
+ /**
78
+ * Resolve game key, using default if not provided
79
+ */
80
+ resolveGame(gameKey) {
81
+ return gameKey ?? this.defaultGame;
82
+ }
83
+ /**
84
+ * Validate that a publisher is allowed by the configuration
85
+ */
86
+ validatePublisher(publisherSlug) {
87
+ if (!this.allowedPublishers) return;
88
+ if (this.allowedPublishers.includes(publisherSlug)) return;
89
+ throw new RestrictedError(
90
+ `Publisher '${publisherSlug}' is not in the allowed publishers list`
91
+ );
92
+ }
93
+ /**
94
+ * Validate that a game is allowed by the configuration
95
+ */
96
+ validateGame(publisherSlug, gameKey) {
97
+ if (!this.allowedGames) return;
98
+ const allowedForPublisher = this.allowedGames[publisherSlug];
99
+ if (!allowedForPublisher) return;
100
+ if (allowedForPublisher.includes(gameKey)) return;
101
+ throw new RestrictedError(
102
+ `Game '${gameKey}' is not allowed for publisher '${publisherSlug}'`
103
+ );
104
+ }
105
+ /**
106
+ * Validate both publisher and game access
107
+ */
108
+ validateAccess(publisherSlug, gameKey) {
109
+ if (publisherSlug) {
110
+ this.validatePublisher(publisherSlug);
111
+ if (gameKey) {
112
+ this.validateGame(publisherSlug, gameKey);
113
+ }
114
+ }
115
+ }
116
+ /**
117
+ * Check if a log level should be logged
118
+ */
119
+ shouldLog(level) {
120
+ const levels = {
121
+ debug: 0,
122
+ info: 1,
123
+ warn: 2,
124
+ error: 3
125
+ };
126
+ return levels[level] >= levels[this.logLevel];
127
+ }
128
+ /**
129
+ * Create a copy of this configuration with overrides
130
+ */
131
+ merge(overrides) {
132
+ return new _Configuration({
133
+ apiKey: overrides.apiKey ?? this.apiKey,
134
+ endpoint: overrides.endpoint ?? this.endpoint,
135
+ timeout: overrides.timeout ?? this.timeout,
136
+ openTimeout: overrides.openTimeout ?? this.openTimeout,
137
+ defaultPublisher: overrides.defaultPublisher ?? this.defaultPublisher,
138
+ defaultGame: overrides.defaultGame ?? this.defaultGame,
139
+ allowedPublishers: overrides.allowedPublishers ?? this.allowedPublishers,
140
+ allowedGames: overrides.allowedGames ?? this.allowedGames,
141
+ logger: overrides.logger ?? this.logger,
142
+ logLevel: overrides.logLevel ?? this.logLevel,
143
+ retryOnRateLimit: overrides.retryOnRateLimit ?? this.retryOnRateLimit,
144
+ maxRetries: overrides.maxRetries ?? this.maxRetries,
145
+ retryOnNetworkError: overrides.retryOnNetworkError ?? this.retryOnNetworkError,
146
+ maxNetworkRetries: overrides.maxNetworkRetries ?? this.maxNetworkRetries,
147
+ retryBaseDelay: overrides.retryBaseDelay ?? this.retryBaseDelay,
148
+ retryMaxDelay: overrides.retryMaxDelay ?? this.retryMaxDelay,
149
+ cache: overrides.cache ?? this.cache,
150
+ cacheTtl: overrides.cacheTtl ?? this.cacheTtl,
151
+ cacheTtls: overrides.cacheTtls ?? this.cacheTtls
152
+ });
153
+ }
154
+ };
155
+
156
+ // src/user-agent.ts
157
+ var SDK_VERSION = "0.1.0";
158
+ function detectRuntime() {
159
+ if (typeof globalThis !== "undefined" && "Bun" in globalThis) {
160
+ const bunVersion = globalThis.Bun && typeof globalThis.Bun === "object" && globalThis.Bun.version;
161
+ return {
162
+ name: "bun",
163
+ version: typeof bunVersion === "string" ? bunVersion : "unknown"
164
+ };
165
+ }
166
+ if (typeof globalThis !== "undefined" && "Deno" in globalThis) {
167
+ const denoVersion = globalThis.Deno && typeof globalThis.Deno === "object" && globalThis.Deno.version && typeof globalThis.Deno.version === "object" && globalThis.Deno.version.deno;
168
+ return {
169
+ name: "deno",
170
+ version: typeof denoVersion === "string" ? denoVersion : "unknown"
171
+ };
172
+ }
173
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
174
+ return {
175
+ name: "node",
176
+ version: process.versions.node
177
+ };
178
+ }
179
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
180
+ return detectBrowser(navigator.userAgent);
181
+ }
182
+ return { name: "unknown", version: "unknown" };
183
+ }
184
+ function detectBrowser(userAgent) {
185
+ const edgeMatch = userAgent.match(/Edg\/(\d+(?:\.\d+)*)/);
186
+ if (edgeMatch) {
187
+ return { name: "edge", version: edgeMatch[1] };
188
+ }
189
+ const chromeMatch = userAgent.match(/Chrome\/(\d+(?:\.\d+)*)/);
190
+ if (chromeMatch && !userAgent.includes("Edg/")) {
191
+ return { name: "chrome", version: chromeMatch[1] };
192
+ }
193
+ const firefoxMatch = userAgent.match(/Firefox\/(\d+(?:\.\d+)*)/);
194
+ if (firefoxMatch) {
195
+ return { name: "firefox", version: firefoxMatch[1] };
196
+ }
197
+ const safariMatch = userAgent.match(/Version\/(\d+(?:\.\d+)*).*Safari/);
198
+ if (safariMatch) {
199
+ return { name: "safari", version: safariMatch[1] };
200
+ }
201
+ return { name: "browser", version: "unknown" };
202
+ }
203
+ function getUserAgent() {
204
+ const runtime = detectRuntime();
205
+ return `CardDB-SDK/js/${SDK_VERSION} (${runtime.name}/${runtime.version})`;
206
+ }
207
+ function getSDKVersion() {
208
+ return SDK_VERSION;
209
+ }
210
+
211
+ // src/connection.ts
212
+ var lastRateLimitInfo = null;
213
+ function getRateLimitInfo() {
214
+ return lastRateLimitInfo;
215
+ }
216
+ var Connection = class {
217
+ config;
218
+ constructor(config) {
219
+ this.config = config;
220
+ }
221
+ /**
222
+ * Execute a GraphQL query
223
+ */
224
+ async execute(query, variables = {}) {
225
+ const operationName = this.extractOperationName(query);
226
+ let rateLimitRetries = 0;
227
+ let networkRetries = 0;
228
+ while (true) {
229
+ try {
230
+ const startTime = Date.now();
231
+ this.logRequest(operationName, variables);
232
+ const response = await this.fetch(query, variables);
233
+ const duration = Date.now() - startTime;
234
+ const result = await this.handleResponse(response);
235
+ this.logResponse(operationName, duration);
236
+ return result;
237
+ } catch (error) {
238
+ if (error instanceof RateLimitError) {
239
+ if (this.config.retryOnRateLimit && rateLimitRetries < this.config.maxRetries) {
240
+ rateLimitRetries++;
241
+ const sleepTime = error.retryAfter ?? 60;
242
+ this.logRateLimitRetry(operationName, rateLimitRetries, sleepTime);
243
+ await this.sleep(sleepTime * 1e3);
244
+ continue;
245
+ }
246
+ }
247
+ if (this.isRetryableNetworkError(error)) {
248
+ if (this.config.retryOnNetworkError && networkRetries < this.config.maxNetworkRetries) {
249
+ const delay = this.config.calculateRetryDelay(networkRetries);
250
+ this.logNetworkRetry(operationName, networkRetries + 1, delay, error);
251
+ networkRetries++;
252
+ await this.sleep(delay);
253
+ continue;
254
+ }
255
+ }
256
+ if (error instanceof ServerError) {
257
+ if (this.config.retryOnNetworkError && networkRetries < this.config.maxNetworkRetries) {
258
+ const delay = this.config.calculateRetryDelay(networkRetries);
259
+ this.logNetworkRetry(operationName, networkRetries + 1, delay, error);
260
+ networkRetries++;
261
+ await this.sleep(delay);
262
+ continue;
263
+ }
264
+ }
265
+ throw error;
266
+ }
267
+ }
268
+ }
269
+ /**
270
+ * Check if an error is a retryable network error
271
+ */
272
+ isRetryableNetworkError(error) {
273
+ return error instanceof ConnectionError || error instanceof TimeoutError;
274
+ }
275
+ async fetch(query, variables) {
276
+ const controller = new AbortController();
277
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
278
+ try {
279
+ const response = await fetch(this.config.endpoint, {
280
+ method: "POST",
281
+ headers: {
282
+ "Content-Type": "application/json",
283
+ Accept: "application/json",
284
+ "User-Agent": getUserAgent(),
285
+ ...this.config.apiKey ? { "X-API-Key": this.config.apiKey } : {}
286
+ },
287
+ body: JSON.stringify({ query, variables }),
288
+ signal: controller.signal
289
+ });
290
+ return response;
291
+ } catch (error) {
292
+ if (error instanceof Error) {
293
+ if (error.name === "AbortError") {
294
+ this.logError("Request timed out");
295
+ throw new TimeoutError("Request timed out");
296
+ }
297
+ this.logError(`Connection failed: ${error.message}`);
298
+ throw new ConnectionError(`Connection failed: ${error.message}`);
299
+ }
300
+ throw new ConnectionError("Connection failed");
301
+ } finally {
302
+ clearTimeout(timeoutId);
303
+ }
304
+ }
305
+ async handleResponse(response) {
306
+ this.extractRateLimitInfo(response);
307
+ switch (response.status) {
308
+ case 200:
309
+ return this.handleSuccessResponse(response);
310
+ case 401:
311
+ throw new AuthenticationError("Invalid or missing API key");
312
+ case 429:
313
+ return this.handleRateLimitResponse(response);
314
+ default:
315
+ if (response.status >= 400 && response.status < 500) {
316
+ return this.handleClientError(response);
317
+ }
318
+ if (response.status >= 500) {
319
+ const body = await this.parseBody(response);
320
+ throw new ServerError(`Server error (${response.status})`, {
321
+ status: response.status,
322
+ response: body
323
+ });
324
+ }
325
+ throw new CardDBError(`Unexpected response status: ${response.status}`);
326
+ }
327
+ }
328
+ async handleSuccessResponse(response) {
329
+ const body = await this.parseBody(response);
330
+ if (body.errors && body.errors.length > 0) {
331
+ this.handleGraphQLErrors(body.errors, body);
332
+ }
333
+ return body.data ?? {};
334
+ }
335
+ handleGraphQLErrors(errors, body) {
336
+ const firstError = errors[0];
337
+ const message = firstError.message || "GraphQL error";
338
+ const code = firstError.extensions?.["code"];
339
+ switch (code) {
340
+ case "UNAUTHENTICATED":
341
+ throw new AuthenticationError(message, body);
342
+ case "RATE_LIMITED":
343
+ throw new RateLimitError(message, { response: body });
344
+ case "NOT_FOUND":
345
+ throw new CardDBError(message, body);
346
+ case "VALIDATION_ERROR":
347
+ case "BAD_USER_INPUT":
348
+ throw new ValidationError(message, { errors, response: body });
349
+ default:
350
+ throw new GraphQLError(message, { errors, response: body });
351
+ }
352
+ }
353
+ async handleRateLimitResponse(response) {
354
+ const retryAfter = parseInt(response.headers.get("Retry-After") ?? "60", 10);
355
+ const limit = parseInt(response.headers.get("X-RateLimit-Limit") ?? "", 10) || null;
356
+ const remaining = parseInt(response.headers.get("X-RateLimit-Remaining") ?? "", 10) || null;
357
+ const reset = parseInt(response.headers.get("X-RateLimit-Reset") ?? "", 10) || null;
358
+ const resetAt = reset ? new Date(reset * 1e3) : null;
359
+ const body = await this.parseBody(response);
360
+ throw new RateLimitError("Rate limit exceeded", {
361
+ retryAfter,
362
+ limit,
363
+ remaining,
364
+ resetAt,
365
+ response: body
366
+ });
367
+ }
368
+ async handleClientError(response) {
369
+ const body = await this.parseBody(response);
370
+ const message = body.errors?.[0]?.message ?? `Client error (${response.status})`;
371
+ throw new ValidationError(message, { response: body });
372
+ }
373
+ async parseBody(response) {
374
+ try {
375
+ return await response.json();
376
+ } catch {
377
+ return { raw: await response.text() };
378
+ }
379
+ }
380
+ extractRateLimitInfo(response) {
381
+ const limit = parseInt(response.headers.get("X-RateLimit-Limit") ?? "", 10) || null;
382
+ const remaining = parseInt(response.headers.get("X-RateLimit-Remaining") ?? "", 10) || null;
383
+ const reset = parseInt(response.headers.get("X-RateLimit-Reset") ?? "", 10) || null;
384
+ lastRateLimitInfo = { limit, remaining, reset };
385
+ }
386
+ extractOperationName(query) {
387
+ const match = query.match(/(?:query|mutation)\s+(\w+)/);
388
+ return match ? match[1] : "Unknown";
389
+ }
390
+ sleep(ms) {
391
+ return new Promise((resolve) => setTimeout(resolve, ms));
392
+ }
393
+ // Logging helpers
394
+ logRequest(operationName, variables) {
395
+ if (!this.config.logger || !this.config.shouldLog("debug")) return;
396
+ this.config.logger.debug(`[CardDB] Executing ${operationName}`, { variables });
397
+ }
398
+ logResponse(operationName, duration) {
399
+ if (!this.config.logger || !this.config.shouldLog("info")) return;
400
+ this.config.logger.info(`[CardDB] ${operationName} completed in ${duration}ms`);
401
+ }
402
+ logRateLimitRetry(operationName, retry, sleepTime) {
403
+ if (!this.config.logger || !this.config.shouldLog("warn")) return;
404
+ this.config.logger.warn(
405
+ `[CardDB] Rate limited on ${operationName}, retry ${retry}/${this.config.maxRetries} after ${sleepTime}s`
406
+ );
407
+ }
408
+ logNetworkRetry(operationName, retry, delay, error) {
409
+ if (!this.config.logger || !this.config.shouldLog("warn")) return;
410
+ const errorType = error instanceof Error ? error.name : "Unknown";
411
+ this.config.logger.warn(
412
+ `[CardDB] ${errorType} on ${operationName}, retry ${retry}/${this.config.maxNetworkRetries} after ${delay}ms`
413
+ );
414
+ }
415
+ logError(message) {
416
+ if (!this.config.logger || !this.config.shouldLog("error")) return;
417
+ this.config.logger.error(`[CardDB] ${message}`);
418
+ }
419
+ };
420
+
421
+ // src/cache.ts
422
+ function cacheKey(resource, method, params) {
423
+ const sortedParams = Object.entries(params).filter(([, v]) => v !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}=${JSON.stringify(v)}`).join("&");
424
+ return `carddb:${resource}:${method}:${sortedParams}`;
425
+ }
426
+ async function readCache(cache, key) {
427
+ const result = cache.get(key);
428
+ if (result instanceof Promise) {
429
+ return result;
430
+ }
431
+ return result;
432
+ }
433
+ async function writeCache(cache, key, value, ttl) {
434
+ const result = cache.set(key, value, ttl);
435
+ if (result instanceof Promise) {
436
+ await result;
437
+ }
438
+ }
439
+
440
+ // src/resources/base.ts
441
+ var BaseResource = class {
442
+ connection;
443
+ config;
444
+ constructor(connection, config) {
445
+ this.connection = connection;
446
+ this.config = config;
447
+ }
448
+ /**
449
+ * Resolve publisher slug, using default if not provided
450
+ */
451
+ resolvePublisher(publisherSlug) {
452
+ const resolved = this.config.resolvePublisher(publisherSlug);
453
+ if (!resolved) {
454
+ throw new Error("publisher_slug is required (no default configured)");
455
+ }
456
+ return resolved;
457
+ }
458
+ /**
459
+ * Resolve game key, using default if not provided
460
+ */
461
+ resolveGame(gameKey) {
462
+ const resolved = this.config.resolveGame(gameKey);
463
+ if (!resolved) {
464
+ throw new Error("game_key is required (no default configured)");
465
+ }
466
+ return resolved;
467
+ }
468
+ /**
469
+ * Validate access to publisher/game
470
+ */
471
+ validateAccess(publisherSlug, gameKey) {
472
+ this.config.validateAccess(publisherSlug, gameKey);
473
+ }
474
+ /**
475
+ * Execute a query with optional caching
476
+ */
477
+ async withCache(key, resource, options, fn) {
478
+ const useCache = options.cache ?? !!this.config.cache;
479
+ const cache = this.config.cache;
480
+ if (!useCache || !cache) {
481
+ return fn();
482
+ }
483
+ const cached = await readCache(cache, key);
484
+ if (cached !== null) {
485
+ return cached;
486
+ }
487
+ const result = await fn();
488
+ if (result !== null && result !== void 0) {
489
+ const ttl = this.config.cacheTtlFor(resource);
490
+ await writeCache(cache, key, result, ttl);
491
+ }
492
+ return result;
493
+ }
494
+ /**
495
+ * Generate a cache key
496
+ */
497
+ cacheKey(resource, method, params) {
498
+ return cacheKey(resource, method, params);
499
+ }
500
+ };
501
+
502
+ // src/resources/publishers.ts
503
+ var PublishersResource = class extends BaseResource {
504
+ constructor(connection, config) {
505
+ super(connection, config);
506
+ }
507
+ /**
508
+ * Search for publishers
509
+ *
510
+ * @example
511
+ * const publishers = await client.publishers.search({ search: 'pokemon' })
512
+ * for await (const publisher of publishers) {
513
+ * console.log(publisher.name)
514
+ * }
515
+ */
516
+ async search(options = {}) {
517
+ const { query, variables } = QueryBuilder.searchPublishers({
518
+ search: options.search,
519
+ first: options.first,
520
+ after: options.after
521
+ });
522
+ const key = this.cacheKey("publishers", "search", variables);
523
+ const data = await this.withCache(key, "publishers", options, async () => {
524
+ const result = await this.connection.execute(query, variables);
525
+ return result["searchPublishers"];
526
+ });
527
+ return new Collection(data, {
528
+ nextPageLoader: async (cursor) => {
529
+ return this.search({ ...options, after: cursor });
530
+ }
531
+ });
532
+ }
533
+ /**
534
+ * Get a single publisher by slug or ID
535
+ *
536
+ * @example
537
+ * const publisher = await client.publishers.get('pokemon')
538
+ * const publisher = await client.publishers.get('550e8400-e29b-41d4-a716-446655440000')
539
+ */
540
+ async get(slugOrId, options = {}) {
541
+ const isUUID = this.isUUID(slugOrId);
542
+ const key = this.cacheKey("publishers", "get", { [isUUID ? "id" : "slug"]: slugOrId });
543
+ return this.withCache(key, "publishers", options, async () => {
544
+ if (isUUID) {
545
+ const { query } = QueryBuilder.fetchPublisherById();
546
+ const result = await this.connection.execute(query, { id: slugOrId });
547
+ return result["fetchPublisher"] ?? null;
548
+ } else {
549
+ const { query } = QueryBuilder.fetchPublisherBySlug();
550
+ const result = await this.connection.execute(query, { slug: slugOrId });
551
+ return result["fetchPublisher"] ?? null;
552
+ }
553
+ });
554
+ }
555
+ /**
556
+ * Get multiple publishers by slug
557
+ *
558
+ * @example
559
+ * const publishers = await client.publishers.getMany(['pokemon', 'wizards'])
560
+ */
561
+ async getMany(slugs, options = {}) {
562
+ if (slugs.length === 0) return [];
563
+ const key = this.cacheKey("publishers", "getMany", { slugs });
564
+ return this.withCache(key, "publishers", options, async () => {
565
+ const { query } = QueryBuilder.fetchPublishers();
566
+ const result = await this.connection.execute(query, { slugs });
567
+ return result["fetchPublishers"] ?? [];
568
+ });
569
+ }
570
+ /**
571
+ * Check if a string is a valid UUID
572
+ */
573
+ isUUID(value) {
574
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
575
+ return uuidRegex.test(value);
576
+ }
577
+ };
578
+ var GamesResource = class extends BaseResource {
579
+ constructor(connection, config) {
580
+ super(connection, config);
581
+ }
582
+ /**
583
+ * Search for games
584
+ *
585
+ * @example
586
+ * // Search all games
587
+ * const games = await client.games.search({ search: 'trading card' })
588
+ *
589
+ * // Search games from a specific publisher
590
+ * const games = await client.games.search({ publisherSlug: 'pokemon' })
591
+ */
592
+ async search(options = {}) {
593
+ const publisherSlug = this.config.resolvePublisher(options.publisherSlug);
594
+ if (publisherSlug) {
595
+ this.validateAccess(publisherSlug);
596
+ }
597
+ const { query, variables } = QueryBuilder.searchGames({
598
+ publisherSlug,
599
+ search: options.search,
600
+ first: options.first,
601
+ after: options.after
602
+ });
603
+ const key = this.cacheKey("games", "search", variables);
604
+ const data = await this.withCache(key, "games", options, async () => {
605
+ const result = await this.connection.execute(query, variables);
606
+ return result["searchGames"];
607
+ });
608
+ return new Collection(data, {
609
+ nextPageLoader: async (cursor) => {
610
+ return this.search({ ...options, after: cursor });
611
+ }
612
+ });
613
+ }
614
+ async get(idOrPublisherSlug, gameKeyOrOptions, options) {
615
+ if (typeof gameKeyOrOptions === "string") {
616
+ const publisherSlug = idOrPublisherSlug;
617
+ const gameKey = gameKeyOrOptions;
618
+ const opts = options ?? {};
619
+ this.validateAccess(publisherSlug, gameKey);
620
+ const key = this.cacheKey("games", "getByKeys", { publisherSlug, gameKey });
621
+ return this.withCache(key, "games", opts, async () => {
622
+ const { query } = QueryBuilder.fetchGameByKeys();
623
+ const result = await this.connection.execute(query, { publisherSlug, gameKey });
624
+ return result["fetchGame"] ?? null;
625
+ });
626
+ } else {
627
+ const id = idOrPublisherSlug;
628
+ const opts = gameKeyOrOptions ?? {};
629
+ const key = this.cacheKey("games", "get", { id });
630
+ return this.withCache(key, "games", opts, async () => {
631
+ const { query } = QueryBuilder.fetchGameById();
632
+ const result = await this.connection.execute(query, { id });
633
+ return result["fetchGame"] ?? null;
634
+ });
635
+ }
636
+ }
637
+ /**
638
+ * Get multiple games by ID
639
+ *
640
+ * @example
641
+ * const games = await client.games.getMany(['id1', 'id2', 'id3'])
642
+ */
643
+ async getMany(ids, options = {}) {
644
+ if (ids.length === 0) return [];
645
+ const key = this.cacheKey("games", "getMany", { ids });
646
+ return this.withCache(key, "games", options, async () => {
647
+ const { query } = QueryBuilder.fetchGames();
648
+ const result = await this.connection.execute(query, { ids });
649
+ return result["fetchGames"] ?? [];
650
+ });
651
+ }
652
+ };
653
+ var DatasetsResource = class extends BaseResource {
654
+ constructor(connection, config) {
655
+ super(connection, config);
656
+ }
657
+ /**
658
+ * Search for datasets
659
+ *
660
+ * @example
661
+ * // Search all datasets
662
+ * const datasets = await client.datasets.search({ search: 'cards' })
663
+ *
664
+ * // Search datasets from a specific publisher and game
665
+ * const datasets = await client.datasets.search({
666
+ * publisherSlug: 'pokemon',
667
+ * gameKey: 'tcg'
668
+ * })
669
+ */
670
+ async search(options = {}) {
671
+ const publisherSlug = this.config.resolvePublisher(options.publisherSlug);
672
+ const gameKey = this.config.resolveGame(options.gameKey);
673
+ if (publisherSlug) {
674
+ this.validateAccess(publisherSlug, gameKey);
675
+ }
676
+ const { query, variables } = QueryBuilder.searchDatasets({
677
+ publisherSlug,
678
+ gameKey,
679
+ search: options.search,
680
+ purpose: options.purpose,
681
+ first: options.first,
682
+ after: options.after
683
+ });
684
+ const key = this.cacheKey("datasets", "search", variables);
685
+ const data = await this.withCache(key, "datasets", options, async () => {
686
+ const result = await this.connection.execute(query, variables);
687
+ return result["searchDatasets"];
688
+ });
689
+ return new Collection(data, {
690
+ nextPageLoader: async (cursor) => {
691
+ return this.search({ ...options, after: cursor });
692
+ }
693
+ });
694
+ }
695
+ async get(idOrPublisherSlug, gameKeyOrOptions, datasetKey, options) {
696
+ if (typeof gameKeyOrOptions === "string" && typeof datasetKey === "string") {
697
+ const publisherSlug = idOrPublisherSlug;
698
+ const gameKey = gameKeyOrOptions;
699
+ const opts = options ?? {};
700
+ this.validateAccess(publisherSlug, gameKey);
701
+ const key = this.cacheKey("datasets", "getByKeys", { publisherSlug, gameKey, datasetKey });
702
+ return this.withCache(key, "datasets", opts, async () => {
703
+ const { query } = QueryBuilder.fetchDatasetByKeys();
704
+ const result = await this.connection.execute(query, { publisherSlug, gameKey, datasetKey });
705
+ return result["fetchDataset"] ?? null;
706
+ });
707
+ } else {
708
+ const id = idOrPublisherSlug;
709
+ const opts = gameKeyOrOptions ?? {};
710
+ const key = this.cacheKey("datasets", "get", { id });
711
+ return this.withCache(key, "datasets", opts, async () => {
712
+ const { query } = QueryBuilder.fetchDatasetById();
713
+ const result = await this.connection.execute(query, { id });
714
+ return result["fetchDataset"] ?? null;
715
+ });
716
+ }
717
+ }
718
+ /**
719
+ * Get multiple datasets by ID
720
+ *
721
+ * @example
722
+ * const datasets = await client.datasets.getMany(['id1', 'id2', 'id3'])
723
+ */
724
+ async getMany(ids, options = {}) {
725
+ if (ids.length === 0) return [];
726
+ const key = this.cacheKey("datasets", "getMany", { ids });
727
+ return this.withCache(key, "datasets", options, async () => {
728
+ const { query } = QueryBuilder.fetchDatasets();
729
+ const result = await this.connection.execute(query, { ids });
730
+ return result["fetchDatasets"] ?? [];
731
+ });
732
+ }
733
+ };
734
+ var DecksResource = class extends BaseResource {
735
+ constructor(connection, config) {
736
+ super(connection, config);
737
+ }
738
+ /**
739
+ * Fetch a hosted deck by CardDB UUID.
740
+ */
741
+ async fetch(id, options = {}) {
742
+ const key = this.cacheKey("decks", "fetch", { id });
743
+ return this.withCache(key, "decks", options, async () => {
744
+ const { query } = QueryBuilder.fetchDeckById();
745
+ const result = await this.connection.execute(query, { id });
746
+ return result["fetchDeck"] ?? null;
747
+ });
748
+ }
749
+ /**
750
+ * Fetch a hosted deck by external reference for the current API application.
751
+ */
752
+ async fetchByExternalRef(externalRef, options = {}) {
753
+ const key = this.cacheKey("decks", "fetchByExternalRef", { externalRef });
754
+ return this.withCache(key, "decks", options, async () => {
755
+ const { query } = QueryBuilder.fetchDeckByExternalRef();
756
+ const result = await this.connection.execute(query, { externalRef });
757
+ return result["fetchDeckByExternalRef"] ?? null;
758
+ });
759
+ }
760
+ /**
761
+ * List decks owned by the current account or API application.
762
+ */
763
+ async listMine(options = {}) {
764
+ const { query, variables } = QueryBuilder.listMyDecks({
765
+ first: options.first,
766
+ after: options.after
767
+ });
768
+ const key = this.cacheKey("decks", "listMine", variables);
769
+ const data = await this.withCache(key, "decks", options, async () => {
770
+ const result = await this.connection.execute(query, variables);
771
+ return result["myDecks"];
772
+ });
773
+ return new Collection(data, {
774
+ nextPageLoader: async (cursor) => this.listMine({ ...options, after: cursor })
775
+ });
776
+ }
777
+ /**
778
+ * Create a hosted deck.
779
+ */
780
+ async create(input) {
781
+ const { query } = QueryBuilder.createDeck();
782
+ const variables = QueryBuilder.deckCreateVariables(input);
783
+ const result = await this.connection.execute(query, variables);
784
+ return result["deckCreate"];
785
+ }
786
+ /**
787
+ * Update a hosted deck.
788
+ */
789
+ async update(id, input) {
790
+ const { query } = QueryBuilder.updateDeck();
791
+ const variables = QueryBuilder.deckUpdateVariables(id, input);
792
+ const result = await this.connection.execute(query, variables);
793
+ return result["deckUpdate"];
794
+ }
795
+ /**
796
+ * Delete a hosted deck.
797
+ */
798
+ async delete(id) {
799
+ const { query } = QueryBuilder.deleteDeck();
800
+ const result = await this.connection.execute(query, { id });
801
+ return Boolean(result["deckDelete"]);
802
+ }
803
+ /**
804
+ * Hydrate third-party-owned deck entries without storing them in CardDB.
805
+ */
806
+ async hydrateEntries(options) {
807
+ if (options.entries.length === 0) return [];
808
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
809
+ const gameKey = this.resolveGame(options.gameKey);
810
+ this.validateAccess(publisherSlug, gameKey);
811
+ const identifiers = options.entries.map((entry) => entry.identifier);
812
+ const key = this.cacheKey("decks", "hydrateEntries", {
813
+ publisherSlug,
814
+ gameKey,
815
+ datasetKey: options.datasetKey,
816
+ identifiers
817
+ });
818
+ const records = await this.withCache(key, "decks", options, async () => {
819
+ const { query } = QueryBuilder.fetchRecordsByIdentifier();
820
+ const result = await this.connection.execute(query, {
821
+ publisherSlug,
822
+ gameKey,
823
+ datasetKey: options.datasetKey,
824
+ identifiers
825
+ });
826
+ return result["fetchRecordsByIdentifier"];
827
+ });
828
+ const recordsByIdentifier = recordsByDeckIdentifier(records, identifiers, options.identifierField);
829
+ return options.entries.map((entry) => ({
830
+ ...entry,
831
+ record: recordsByIdentifier.get(entry.identifier) ?? null
832
+ }));
833
+ }
834
+ };
835
+ function recordsByDeckIdentifier(records, identifiers, identifierField) {
836
+ const remaining = new Set(identifiers);
837
+ const recordsByIdentifier = /* @__PURE__ */ new Map();
838
+ for (const record of records) {
839
+ const identifier = identifierField ? record.data[identifierField] : Object.values(record.data).find((value) => remaining.has(String(value)));
840
+ if (identifier === void 0 || identifier === null) continue;
841
+ const key = String(identifier);
842
+ if (!remaining.has(key)) continue;
843
+ recordsByIdentifier.set(key, record);
844
+ remaining.delete(key);
845
+ }
846
+ return recordsByIdentifier;
847
+ }
848
+ var RecordsResource = class extends BaseResource {
849
+ constructor(connection, config) {
850
+ super(connection, config);
851
+ }
852
+ /**
853
+ * Search for records in a dataset with filtering, search, and pagination
854
+ *
855
+ * @example Basic search
856
+ * const records = await client.records.search({
857
+ * publisherSlug: 'pokemon',
858
+ * gameKey: 'tcg',
859
+ * datasetKey: 'cards',
860
+ * })
861
+ *
862
+ * @example With defaults configured
863
+ * // If client has defaultPublisher: 'pokemon', defaultGame: 'tcg'
864
+ * const records = await client.records.search({ datasetKey: 'cards' })
865
+ *
866
+ * @example With filtering (object literal)
867
+ * const records = await client.records.search({
868
+ * datasetKey: 'cards',
869
+ * filter: {
870
+ * hp: { gte: 100 },
871
+ * types: { contains: 'Fire' }
872
+ * }
873
+ * })
874
+ *
875
+ * @example With filtering (builder function)
876
+ * const records = await client.records.search({
877
+ * datasetKey: 'cards',
878
+ * filter: f => f
879
+ * .where('hp', gte(100))
880
+ * .where('types', contains('Fire'))
881
+ * .any(or => or
882
+ * .where('rarity', 'Rare')
883
+ * .where('rarity', 'Rare Holo')
884
+ * )
885
+ * })
886
+ *
887
+ * @example With link resolution
888
+ * const records = await client.records.search({
889
+ * datasetKey: 'cards',
890
+ * resolveLinks: ['set_id'],
891
+ * filter: f => f.whereLink('set_id', { code: 'BASE' })
892
+ * })
893
+ *
894
+ * @example Iterate through all results
895
+ * const records = await client.records.search({ datasetKey: 'cards' })
896
+ * for await (const record of records) {
897
+ * console.log(record.data.name)
898
+ * }
899
+ */
900
+ async search(options) {
901
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
902
+ const gameKey = this.resolveGame(options.gameKey);
903
+ this.validateAccess(publisherSlug, gameKey);
904
+ const filter = resolveFilter(options.filter);
905
+ const { query, variables } = QueryBuilder.searchRecords({
906
+ publisherSlug,
907
+ gameKey,
908
+ datasetKey: options.datasetKey,
909
+ filter,
910
+ search: options.search,
911
+ orderBy: options.orderBy,
912
+ resolveLinks: options.resolveLinks,
913
+ first: options.first,
914
+ after: options.after,
915
+ validateSchema: options.validateSchema
916
+ });
917
+ const key = this.cacheKey("records", "search", variables);
918
+ const data = await this.withCache(key, "records", options, async () => {
919
+ const result = await this.connection.execute(query, variables);
920
+ return result["searchRecords"];
921
+ });
922
+ return new Collection(data, {
923
+ nextPageLoader: async (cursor) => {
924
+ return this.search({ ...options, after: cursor });
925
+ }
926
+ });
927
+ }
928
+ /**
929
+ * Get a single record by ID
930
+ *
931
+ * @example
932
+ * const record = await client.records.get('550e8400-e29b-41d4-a716-446655440000')
933
+ */
934
+ async get(id, options = {}) {
935
+ const key = this.cacheKey("records", "get", { id });
936
+ return this.withCache(key, "records", options, async () => {
937
+ const { query } = QueryBuilder.fetchRecordById();
938
+ const result = await this.connection.execute(query, { id });
939
+ return result["fetchRecord"] ?? null;
940
+ });
941
+ }
942
+ /**
943
+ * Get a record by its identifier field value
944
+ *
945
+ * The identifier field is defined in the dataset schema (the field marked as isIdentifier)
946
+ *
947
+ * @example
948
+ * const record = await client.records.getByIdentifier({
949
+ * publisherSlug: 'pokemon',
950
+ * gameKey: 'tcg',
951
+ * datasetKey: 'cards',
952
+ * identifier: 'base1-4'
953
+ * })
954
+ *
955
+ * @example With defaults configured
956
+ * const record = await client.records.getByIdentifier({
957
+ * datasetKey: 'cards',
958
+ * identifier: 'base1-4'
959
+ * })
960
+ */
961
+ async getByIdentifier(options) {
962
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
963
+ const gameKey = this.resolveGame(options.gameKey);
964
+ this.validateAccess(publisherSlug, gameKey);
965
+ const key = this.cacheKey("records", "getByIdentifier", {
966
+ publisherSlug,
967
+ gameKey,
968
+ datasetKey: options.datasetKey,
969
+ identifier: options.identifier
970
+ });
971
+ return this.withCache(key, "records", options, async () => {
972
+ const { query } = QueryBuilder.fetchRecordByIdentifier();
973
+ const result = await this.connection.execute(query, {
974
+ publisherSlug,
975
+ gameKey,
976
+ datasetKey: options.datasetKey,
977
+ identifier: options.identifier
978
+ });
979
+ return result["fetchRecordByIdentifier"] ?? null;
980
+ });
981
+ }
982
+ /**
983
+ * Get multiple records by their identifier field values
984
+ *
985
+ * Missing identifiers are omitted from the result.
986
+ *
987
+ * @example
988
+ * const records = await client.records.getManyByIdentifier({
989
+ * publisherSlug: 'pokemon',
990
+ * gameKey: 'tcg',
991
+ * datasetKey: 'cards',
992
+ * identifiers: ['base1-4', 'base1-5']
993
+ * })
994
+ *
995
+ * @example With defaults configured
996
+ * const records = await client.records.getManyByIdentifier({
997
+ * datasetKey: 'cards',
998
+ * identifiers: ['base1-4', 'base1-5']
999
+ * })
1000
+ */
1001
+ async getManyByIdentifier(options) {
1002
+ if (options.identifiers.length === 0) return [];
1003
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
1004
+ const gameKey = this.resolveGame(options.gameKey);
1005
+ this.validateAccess(publisherSlug, gameKey);
1006
+ const key = this.cacheKey("records", "getManyByIdentifier", {
1007
+ publisherSlug,
1008
+ gameKey,
1009
+ datasetKey: options.datasetKey,
1010
+ identifiers: options.identifiers
1011
+ });
1012
+ return this.withCache(key, "records", options, async () => {
1013
+ const { query } = QueryBuilder.fetchRecordsByIdentifier();
1014
+ const result = await this.connection.execute(query, {
1015
+ publisherSlug,
1016
+ gameKey,
1017
+ datasetKey: options.datasetKey,
1018
+ identifiers: options.identifiers
1019
+ });
1020
+ return result["fetchRecordsByIdentifier"] ?? [];
1021
+ });
1022
+ }
1023
+ /**
1024
+ * Get multiple records by ID
1025
+ *
1026
+ * @example
1027
+ * const records = await client.records.getMany(['id1', 'id2', 'id3'])
1028
+ */
1029
+ async getMany(ids, options = {}) {
1030
+ if (ids.length === 0) return [];
1031
+ const key = this.cacheKey("records", "getMany", { ids });
1032
+ return this.withCache(key, "records", options, async () => {
1033
+ const { query } = QueryBuilder.fetchRecords();
1034
+ const result = await this.connection.execute(query, { ids });
1035
+ return result["fetchRecords"] ?? [];
1036
+ });
1037
+ }
1038
+ };
1039
+ var RulesResource = class extends BaseResource {
1040
+ constructor(connection, config) {
1041
+ super(connection, config);
1042
+ }
1043
+ /**
1044
+ * List rule-related datasets for a game.
1045
+ *
1046
+ * @example
1047
+ * const datasets = await client.rules.datasets({ publisherSlug: 'wotc', gameKey: 'magic' })
1048
+ */
1049
+ async datasets(options = {}) {
1050
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
1051
+ const gameKey = this.resolveGame(options.gameKey);
1052
+ this.validateAccess(publisherSlug, gameKey);
1053
+ const { query, variables } = QueryBuilder.searchDatasets({
1054
+ publisherSlug,
1055
+ gameKey,
1056
+ search: options.search,
1057
+ purpose: "RULES",
1058
+ first: options.first,
1059
+ after: options.after
1060
+ });
1061
+ const key = this.cacheKey("rules", "datasets", variables);
1062
+ const data = await this.withCache(key, "datasets", options, async () => {
1063
+ const result = await this.connection.execute(query, variables);
1064
+ return result["searchDatasets"];
1065
+ });
1066
+ return new Collection(data, {
1067
+ nextPageLoader: async (cursor) => this.datasets({ ...options, after: cursor })
1068
+ });
1069
+ }
1070
+ /**
1071
+ * List rules from the game's rules dataset.
1072
+ *
1073
+ * @example
1074
+ * const rules = await client.rules.list({ first: 100 })
1075
+ */
1076
+ async list(options = {}) {
1077
+ return this.searchRuleRecords("rules", options);
1078
+ }
1079
+ /**
1080
+ * List deck/game formats from the game's formats dataset.
1081
+ *
1082
+ * @example
1083
+ * const formats = await client.rules.formats({ first: 100 })
1084
+ * const names = formats.items.map(format => format.data.name)
1085
+ */
1086
+ async formats(options = {}) {
1087
+ return this.searchRuleRecords(options.datasetKey ?? "formats", options);
1088
+ }
1089
+ async searchRuleRecords(defaultDatasetKey, options) {
1090
+ const publisherSlug = this.resolvePublisher(options.publisherSlug);
1091
+ const gameKey = this.resolveGame(options.gameKey);
1092
+ const datasetKey = options.datasetKey ?? defaultDatasetKey;
1093
+ this.validateAccess(publisherSlug, gameKey);
1094
+ const filter = resolveFilter(options.filter);
1095
+ const { query, variables } = QueryBuilder.searchRecords({
1096
+ publisherSlug,
1097
+ gameKey,
1098
+ datasetKey,
1099
+ filter,
1100
+ search: options.search,
1101
+ orderBy: options.orderBy,
1102
+ resolveLinks: options.resolveLinks,
1103
+ first: options.first,
1104
+ after: options.after,
1105
+ validateSchema: options.validateSchema
1106
+ });
1107
+ const key = this.cacheKey("rules", "records", variables);
1108
+ const data = await this.withCache(key, "records", options, async () => {
1109
+ const result = await this.connection.execute(query, variables);
1110
+ return result["searchRecords"];
1111
+ });
1112
+ return new Collection(data, {
1113
+ nextPageLoader: async (cursor) => this.searchRuleRecords(defaultDatasetKey, { ...options, after: cursor })
1114
+ });
1115
+ }
1116
+ };
1117
+
1118
+ // src/client.ts
1119
+ var CardDBClient = class _CardDBClient {
1120
+ config;
1121
+ connection;
1122
+ /** Publishers resource for searching and fetching publishers */
1123
+ publishers;
1124
+ /** Games resource for searching and fetching games */
1125
+ games;
1126
+ /** Datasets resource for searching and fetching datasets */
1127
+ datasets;
1128
+ /** Records resource for searching and fetching records */
1129
+ records;
1130
+ /** Decks resource for hosted decks and external deck hydration */
1131
+ decks;
1132
+ /** Rules resource for game rules and deck formats */
1133
+ rules;
1134
+ /**
1135
+ * Create a new CardDB client
1136
+ *
1137
+ * @param config - Client configuration options
1138
+ */
1139
+ constructor(config = {}) {
1140
+ this.config = new Configuration(config);
1141
+ this.connection = new Connection(this.config);
1142
+ this.publishers = new PublishersResource(this.connection, this.config);
1143
+ this.games = new GamesResource(this.connection, this.config);
1144
+ this.datasets = new DatasetsResource(this.connection, this.config);
1145
+ this.records = new RecordsResource(this.connection, this.config);
1146
+ this.decks = new DecksResource(this.connection, this.config);
1147
+ this.rules = new RulesResource(this.connection, this.config);
1148
+ }
1149
+ /**
1150
+ * Get information about the current API key
1151
+ *
1152
+ * Returns null if no API key is configured or the key is invalid.
1153
+ *
1154
+ * @example
1155
+ * const info = await client.me()
1156
+ * if (info) {
1157
+ * console.log(`Logged in as: ${info.account.displayName}`)
1158
+ * console.log(`Application: ${info.application.name}`)
1159
+ * }
1160
+ */
1161
+ async me() {
1162
+ const { query } = QueryBuilder.fetchMe();
1163
+ const result = await this.connection.execute(query);
1164
+ return result["fetchMe"] ?? null;
1165
+ }
1166
+ /**
1167
+ * Get rate limit information from the last request
1168
+ *
1169
+ * @example
1170
+ * await client.publishers.search()
1171
+ * const rateLimit = client.getRateLimitInfo()
1172
+ * console.log(`Remaining: ${rateLimit?.remaining}/${rateLimit?.limit}`)
1173
+ */
1174
+ getRateLimitInfo() {
1175
+ return getRateLimitInfo();
1176
+ }
1177
+ /**
1178
+ * Create a new client with configuration overrides
1179
+ *
1180
+ * Useful for creating scoped clients with different defaults.
1181
+ *
1182
+ * @example
1183
+ * const pokemonClient = client.withConfig({
1184
+ * defaultPublisher: 'pokemon',
1185
+ * defaultGame: 'tcg'
1186
+ * })
1187
+ *
1188
+ * // Now all queries use these defaults
1189
+ * const cards = await pokemonClient.records.search({ datasetKey: 'cards' })
1190
+ */
1191
+ withConfig(overrides) {
1192
+ const mergedConfig = this.config.merge(overrides);
1193
+ return new _CardDBClient({
1194
+ apiKey: mergedConfig.apiKey,
1195
+ endpoint: mergedConfig.endpoint,
1196
+ timeout: mergedConfig.timeout,
1197
+ openTimeout: mergedConfig.openTimeout,
1198
+ defaultPublisher: mergedConfig.defaultPublisher,
1199
+ defaultGame: mergedConfig.defaultGame,
1200
+ allowedPublishers: mergedConfig.allowedPublishers,
1201
+ allowedGames: mergedConfig.allowedGames,
1202
+ logger: mergedConfig.logger,
1203
+ logLevel: mergedConfig.logLevel,
1204
+ retryOnRateLimit: mergedConfig.retryOnRateLimit,
1205
+ maxRetries: mergedConfig.maxRetries,
1206
+ retryOnNetworkError: mergedConfig.retryOnNetworkError,
1207
+ maxNetworkRetries: mergedConfig.maxNetworkRetries,
1208
+ retryBaseDelay: mergedConfig.retryBaseDelay,
1209
+ retryMaxDelay: mergedConfig.retryMaxDelay,
1210
+ cache: mergedConfig.cache,
1211
+ cacheTtl: mergedConfig.cacheTtl,
1212
+ cacheTtls: mergedConfig.cacheTtls
1213
+ });
1214
+ }
1215
+ };
1216
+
1217
+ export { BaseResource, CardDBClient, Configuration, Connection, DEFAULT_CACHE_TTL, DEFAULT_ENDPOINT, DEFAULT_MAX_NETWORK_RETRIES, DEFAULT_MAX_RETRIES, DEFAULT_OPEN_TIMEOUT, DEFAULT_RETRY_BASE_DELAY, DEFAULT_RETRY_MAX_DELAY, DEFAULT_TIMEOUT, DatasetsResource, DecksResource, GamesResource, PublishersResource, RecordsResource, RulesResource, cacheKey, getRateLimitInfo, getSDKVersion, getUserAgent, readCache, writeCache };
1218
+ //# sourceMappingURL=index.js.map
1219
+ //# sourceMappingURL=index.js.map