@carddb/browser 0.1.4 → 0.2.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/README.md +15 -1
- package/dist/browser/index.js +699 -88
- package/dist/browser/index.js.map +1 -1
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -2
- package/dist/index.d.ts +45 -2
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,X);}},x=class extends h{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},w=class extends h{retryAfter;limit;remaining;resetAt;constructor(e="Rate limit exceeded",t={}){super(e,t.response),this.name="RateLimitError",this.retryAfter=t.retryAfter??null,this.limit=t.limit??null,this.remaining=t.remaining??null,this.resetAt=t.resetAt??null;}},Ye=class extends h{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},T=class extends h{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},k=class extends h{constructor(e,t){super(e,t),this.name="RestrictedError";}},Q=class extends h{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},D=class extends h{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},K=class extends D{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},C=class extends h{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},He=class extends h{failures;partialResults;constructor(e="Some links could not be resolved",t={}){super(e,t.response),this.name="LinkResolutionError",this.failures=t.failures??[],this.partialResults=t.partialResults;}getFailuresForField(e){return this.failures.filter(t=>t.field===e)}hasFailuresForField(e){return this.failures.some(t=>t.field===e)}};function Xe(e){return {eq:e}}function Qe(e){return {neq:e}}function We(e){return {gt:e}}function Je(e){return {gte:e}}function ze(e){return {lt:e}}function Ze(e){return {lte:e}}function et(e){return {in:e}}function tt(e){return {nin:e}}function rt(e){return {contains:e}}function st(e){return {like:e}}function it(e){return {ilike:e}}function nt(){return {is_null:true}}function ct(){return {is_null:false}}var ue=class W{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,i]of Object.entries(t))this.conditions.push({[s]:i});return this}any(t){let r=new W;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[i,c]of Object.entries(r))s[i]=c;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[i,c]of Object.entries(r))s[i]=c;return this.conditions.push({[`${t}._any`]:s}),this}getConditions(){return this.conditions}build(){let t=[...this.conditions,...this.orGroups];return t.length===0?{}:t.length===1?t[0]:{$and:t}}};function q(e){if(e!==void 0){if(typeof e=="function"){let t=new ue;e(t);let r=t.build();return Object.keys(r).length>0?r:void 0}return Object.keys(e).length>0?e:void 0}}var $=`
|
|
2
2
|
id
|
|
3
3
|
name
|
|
4
4
|
slug
|
|
@@ -39,7 +39,7 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
39
39
|
id
|
|
40
40
|
url
|
|
41
41
|
}
|
|
42
|
-
`,
|
|
42
|
+
`,I=`
|
|
43
43
|
id
|
|
44
44
|
publisherId
|
|
45
45
|
gameId
|
|
@@ -47,6 +47,7 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
47
47
|
name
|
|
48
48
|
description
|
|
49
49
|
purpose
|
|
50
|
+
tcgplayerProductIdFieldKey
|
|
50
51
|
visibility
|
|
51
52
|
isArchived
|
|
52
53
|
createdAt
|
|
@@ -61,7 +62,7 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
61
62
|
key
|
|
62
63
|
name
|
|
63
64
|
}
|
|
64
|
-
`,
|
|
65
|
+
`,le=4;function J(e){return `
|
|
65
66
|
key
|
|
66
67
|
label
|
|
67
68
|
description
|
|
@@ -76,12 +77,12 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
76
77
|
allowedValues
|
|
77
78
|
${e>0?`
|
|
78
79
|
nestedFields {
|
|
79
|
-
${
|
|
80
|
+
${J(e-1)}
|
|
80
81
|
}`:""}
|
|
81
|
-
`}var
|
|
82
|
+
`}var O=`
|
|
82
83
|
schema {
|
|
83
84
|
fields {
|
|
84
|
-
${
|
|
85
|
+
${J(le)}
|
|
85
86
|
}
|
|
86
87
|
filterableFields
|
|
87
88
|
searchableFields
|
|
@@ -93,19 +94,102 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
93
94
|
targetDatasetId
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
`,
|
|
97
|
+
`,de=`
|
|
98
|
+
pricing {
|
|
99
|
+
productId
|
|
100
|
+
prices {
|
|
101
|
+
subTypeName
|
|
102
|
+
lowPrice
|
|
103
|
+
midPrice
|
|
104
|
+
highPrice
|
|
105
|
+
marketPrice
|
|
106
|
+
directLowPrice
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`;function p(e={}){return `
|
|
110
|
+
id
|
|
111
|
+
datasetId
|
|
112
|
+
data
|
|
113
|
+
${e.includePricing?de:""}
|
|
114
|
+
createdAt
|
|
115
|
+
updatedAt
|
|
116
|
+
dataset {
|
|
117
|
+
id
|
|
118
|
+
key
|
|
119
|
+
name
|
|
120
|
+
gameId
|
|
121
|
+
publisherId
|
|
122
|
+
}
|
|
123
|
+
`}var z=p(),P=`
|
|
124
|
+
key
|
|
125
|
+
label
|
|
126
|
+
description
|
|
127
|
+
order
|
|
128
|
+
default
|
|
129
|
+
aliases
|
|
130
|
+
minCards
|
|
131
|
+
maxCards
|
|
132
|
+
excludedFromDeckSize
|
|
133
|
+
legalCardTypes
|
|
134
|
+
metadata
|
|
135
|
+
`,A=`
|
|
97
136
|
id
|
|
98
137
|
datasetId
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
138
|
+
recordId
|
|
139
|
+
identifier
|
|
140
|
+
quantity
|
|
141
|
+
section
|
|
142
|
+
sortOrder
|
|
143
|
+
annotations
|
|
144
|
+
display
|
|
145
|
+
record {
|
|
146
|
+
${z}
|
|
147
|
+
}
|
|
148
|
+
`,Z=`
|
|
149
|
+
rulesetId
|
|
150
|
+
rulesetVersionId
|
|
151
|
+
rulesetVersionLabel
|
|
152
|
+
cardDatasetId
|
|
153
|
+
cardDatasetVersionId
|
|
154
|
+
validatedAt
|
|
155
|
+
validationResultSummary
|
|
156
|
+
`,v=`
|
|
157
|
+
code
|
|
158
|
+
severity
|
|
159
|
+
message
|
|
160
|
+
entryIds
|
|
161
|
+
section
|
|
162
|
+
datasetId
|
|
163
|
+
identifier
|
|
164
|
+
metadata
|
|
165
|
+
`,U=`
|
|
166
|
+
deckId
|
|
167
|
+
valid
|
|
168
|
+
blockers {
|
|
169
|
+
${v}
|
|
170
|
+
}
|
|
171
|
+
warnings {
|
|
172
|
+
${v}
|
|
173
|
+
}
|
|
174
|
+
affectedEntries {
|
|
175
|
+
entryId
|
|
176
|
+
datasetId
|
|
177
|
+
recordId
|
|
178
|
+
identifier
|
|
179
|
+
section
|
|
180
|
+
quantity
|
|
108
181
|
}
|
|
182
|
+
validatedAgainst {
|
|
183
|
+
${Z}
|
|
184
|
+
}
|
|
185
|
+
checkedAt
|
|
186
|
+
`,M=`
|
|
187
|
+
deckId
|
|
188
|
+
fromVersionId
|
|
189
|
+
toVersionId
|
|
190
|
+
toDraftRevision
|
|
191
|
+
hasChanges
|
|
192
|
+
diff
|
|
109
193
|
`,b=`
|
|
110
194
|
id
|
|
111
195
|
deckId
|
|
@@ -121,23 +205,25 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
121
205
|
metadata
|
|
122
206
|
publishNote
|
|
123
207
|
computedDiff
|
|
208
|
+
rulesetId
|
|
209
|
+
rulesetVersionId
|
|
210
|
+
cardDatasetId
|
|
211
|
+
cardDatasetVersionId
|
|
212
|
+
validatedAt
|
|
213
|
+
validationSummary
|
|
214
|
+
validatedAgainst {
|
|
215
|
+
${Z}
|
|
216
|
+
}
|
|
217
|
+
sectionDefinitions {
|
|
218
|
+
${P}
|
|
219
|
+
}
|
|
124
220
|
publishedByAccountId
|
|
125
221
|
publishedByApiApplicationId
|
|
126
222
|
createdAt
|
|
127
223
|
entries {
|
|
128
|
-
|
|
129
|
-
datasetId
|
|
130
|
-
recordId
|
|
131
|
-
identifier
|
|
132
|
-
quantity
|
|
133
|
-
section
|
|
134
|
-
sortOrder
|
|
135
|
-
annotations
|
|
136
|
-
record {
|
|
137
|
-
${f}
|
|
138
|
-
}
|
|
224
|
+
${A}
|
|
139
225
|
}
|
|
140
|
-
`,
|
|
226
|
+
`,G=`
|
|
141
227
|
id
|
|
142
228
|
deckId
|
|
143
229
|
accountId
|
|
@@ -145,7 +231,7 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
145
231
|
createdByAccountId
|
|
146
232
|
createdAt
|
|
147
233
|
updatedAt
|
|
148
|
-
`,
|
|
234
|
+
`,j=`
|
|
149
235
|
id
|
|
150
236
|
deckId
|
|
151
237
|
label
|
|
@@ -154,8 +240,144 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
154
240
|
lastUsedAt
|
|
155
241
|
createdAt
|
|
156
242
|
updatedAt
|
|
157
|
-
`,
|
|
243
|
+
`,Y=`
|
|
158
244
|
id
|
|
245
|
+
deckId
|
|
246
|
+
apiApplicationId
|
|
247
|
+
label
|
|
248
|
+
readMode
|
|
249
|
+
allowedOrigins
|
|
250
|
+
externalSubject
|
|
251
|
+
expiresAt
|
|
252
|
+
revokedAt
|
|
253
|
+
lastUsedAt
|
|
254
|
+
createdAt
|
|
255
|
+
updatedAt
|
|
256
|
+
`,E=`
|
|
257
|
+
id
|
|
258
|
+
deckId
|
|
259
|
+
apiApplicationId
|
|
260
|
+
label
|
|
261
|
+
readModes
|
|
262
|
+
maxTokenLifetimeSeconds
|
|
263
|
+
directSigningAlg
|
|
264
|
+
directSigningKeyId
|
|
265
|
+
directSigningPublicKey
|
|
266
|
+
directSigningKeyRevokedAt
|
|
267
|
+
revokedAt
|
|
268
|
+
createdAt
|
|
269
|
+
updatedAt
|
|
270
|
+
`,he=`
|
|
271
|
+
id
|
|
272
|
+
deckId
|
|
273
|
+
apiApplicationId
|
|
274
|
+
issuerId
|
|
275
|
+
readMode
|
|
276
|
+
externalSubject
|
|
277
|
+
expiresAt
|
|
278
|
+
revokedAt
|
|
279
|
+
lastUsedAt
|
|
280
|
+
createdAt
|
|
281
|
+
updatedAt
|
|
282
|
+
`,F=`
|
|
283
|
+
lineNumber
|
|
284
|
+
raw
|
|
285
|
+
datasetKey
|
|
286
|
+
datasetId
|
|
287
|
+
recordId
|
|
288
|
+
identifier
|
|
289
|
+
quantity
|
|
290
|
+
section
|
|
291
|
+
sortOrder
|
|
292
|
+
display
|
|
293
|
+
record {
|
|
294
|
+
${z}
|
|
295
|
+
}
|
|
296
|
+
`,ee=`
|
|
297
|
+
lineNumber
|
|
298
|
+
raw
|
|
299
|
+
code
|
|
300
|
+
message
|
|
301
|
+
`,L=`
|
|
302
|
+
lineNumber
|
|
303
|
+
raw
|
|
304
|
+
datasetKey
|
|
305
|
+
identifier
|
|
306
|
+
quantity
|
|
307
|
+
section
|
|
308
|
+
code
|
|
309
|
+
message
|
|
310
|
+
`,B=`
|
|
311
|
+
lineNumber
|
|
312
|
+
raw
|
|
313
|
+
datasetKey
|
|
314
|
+
identifier
|
|
315
|
+
quantity
|
|
316
|
+
section
|
|
317
|
+
candidates {
|
|
318
|
+
recordId
|
|
319
|
+
identifier
|
|
320
|
+
display
|
|
321
|
+
}
|
|
322
|
+
`,f=`
|
|
323
|
+
id
|
|
324
|
+
gameId
|
|
325
|
+
key
|
|
326
|
+
name
|
|
327
|
+
description
|
|
328
|
+
enabled
|
|
329
|
+
priority
|
|
330
|
+
datasetKey
|
|
331
|
+
config
|
|
332
|
+
archivedAt
|
|
333
|
+
isArchived
|
|
334
|
+
createdAt
|
|
335
|
+
updatedAt
|
|
336
|
+
`,te=`
|
|
337
|
+
formatId
|
|
338
|
+
key
|
|
339
|
+
name
|
|
340
|
+
confidence
|
|
341
|
+
reason
|
|
342
|
+
`,ye=`
|
|
343
|
+
detection {
|
|
344
|
+
${te}
|
|
345
|
+
}
|
|
346
|
+
entries {
|
|
347
|
+
${F}
|
|
348
|
+
}
|
|
349
|
+
parseErrors {
|
|
350
|
+
${ee}
|
|
351
|
+
}
|
|
352
|
+
unmatched {
|
|
353
|
+
${L}
|
|
354
|
+
}
|
|
355
|
+
ambiguous {
|
|
356
|
+
${B}
|
|
357
|
+
}
|
|
358
|
+
`,fe=`
|
|
359
|
+
entries {
|
|
360
|
+
${F}
|
|
361
|
+
}
|
|
362
|
+
unmatched {
|
|
363
|
+
${L}
|
|
364
|
+
}
|
|
365
|
+
ambiguous {
|
|
366
|
+
${B}
|
|
367
|
+
}
|
|
368
|
+
`,ke=`
|
|
369
|
+
deckId
|
|
370
|
+
format
|
|
371
|
+
text
|
|
372
|
+
entryCount
|
|
373
|
+
`,u=`
|
|
374
|
+
id
|
|
375
|
+
ownerType
|
|
376
|
+
ownerAccountId
|
|
377
|
+
ownerApiApplicationId
|
|
378
|
+
environment
|
|
379
|
+
createdByAccountId
|
|
380
|
+
createdByApiApplicationId
|
|
159
381
|
accountId
|
|
160
382
|
apiApplicationId
|
|
161
383
|
gameId
|
|
@@ -165,13 +387,29 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
165
387
|
description
|
|
166
388
|
formatKey
|
|
167
389
|
visibility
|
|
390
|
+
accessMode
|
|
391
|
+
discoverability
|
|
392
|
+
state
|
|
393
|
+
archivedAt
|
|
394
|
+
deletedAt
|
|
395
|
+
unpublishedAt
|
|
396
|
+
externalRefApiApplicationId
|
|
168
397
|
externalRef
|
|
398
|
+
externalSubjectRef
|
|
399
|
+
rulesetId
|
|
169
400
|
sourceUrl
|
|
170
401
|
metadata
|
|
402
|
+
sectionDefinitions {
|
|
403
|
+
${P}
|
|
404
|
+
}
|
|
171
405
|
latestPublishedVersion {
|
|
172
406
|
${b}
|
|
173
407
|
}
|
|
174
408
|
publishedAt
|
|
409
|
+
draftRevision
|
|
410
|
+
draftUpdatedAt
|
|
411
|
+
draftUpdatedByAccountId
|
|
412
|
+
draftUpdatedByApiApplicationId
|
|
175
413
|
hasUnpublishedChanges
|
|
176
414
|
createdAt
|
|
177
415
|
updatedAt
|
|
@@ -179,19 +417,102 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
179
417
|
${m}
|
|
180
418
|
}
|
|
181
419
|
entries {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
420
|
+
${A}
|
|
421
|
+
}
|
|
422
|
+
`,H=`
|
|
423
|
+
deck {
|
|
424
|
+
${u}
|
|
425
|
+
}
|
|
426
|
+
retainedAppAccess
|
|
427
|
+
`,pe=`
|
|
428
|
+
deck {
|
|
429
|
+
${u}
|
|
430
|
+
}
|
|
431
|
+
copiedFromDeckId
|
|
432
|
+
retainedAppAccess
|
|
433
|
+
`,ge=`
|
|
434
|
+
id
|
|
435
|
+
name
|
|
436
|
+
description
|
|
437
|
+
revokedAt
|
|
438
|
+
`,R=`
|
|
439
|
+
id
|
|
440
|
+
deckId
|
|
441
|
+
deck {
|
|
442
|
+
${u}
|
|
443
|
+
}
|
|
444
|
+
apiApplicationId
|
|
445
|
+
apiApplication {
|
|
446
|
+
${ge}
|
|
447
|
+
}
|
|
448
|
+
role
|
|
449
|
+
grantSource
|
|
450
|
+
externalRef
|
|
451
|
+
createdByAccountId
|
|
452
|
+
createdByApiApplicationId
|
|
453
|
+
revokedAt
|
|
454
|
+
createdAt
|
|
455
|
+
updatedAt
|
|
456
|
+
`,me=`
|
|
457
|
+
deck {
|
|
458
|
+
${u}
|
|
459
|
+
}
|
|
460
|
+
version {
|
|
461
|
+
${b}
|
|
462
|
+
}
|
|
463
|
+
validation {
|
|
464
|
+
${U}
|
|
465
|
+
}
|
|
466
|
+
blockers {
|
|
467
|
+
${v}
|
|
468
|
+
}
|
|
469
|
+
warnings {
|
|
470
|
+
${v}
|
|
471
|
+
}
|
|
472
|
+
`,S=`
|
|
473
|
+
deck {
|
|
474
|
+
${u}
|
|
475
|
+
}
|
|
476
|
+
entry {
|
|
477
|
+
${A}
|
|
478
|
+
}
|
|
479
|
+
`,re=`
|
|
480
|
+
deck {
|
|
481
|
+
${u}
|
|
482
|
+
}
|
|
483
|
+
entries {
|
|
484
|
+
${A}
|
|
485
|
+
}
|
|
486
|
+
`,De=re,$e=`
|
|
487
|
+
deck {
|
|
488
|
+
${u}
|
|
489
|
+
}
|
|
490
|
+
applied
|
|
491
|
+
dryRun
|
|
492
|
+
replace
|
|
493
|
+
format
|
|
494
|
+
importFormat {
|
|
495
|
+
${f}
|
|
496
|
+
}
|
|
497
|
+
detection {
|
|
498
|
+
${te}
|
|
499
|
+
}
|
|
500
|
+
entries {
|
|
501
|
+
${F}
|
|
502
|
+
}
|
|
503
|
+
parseErrors {
|
|
504
|
+
${ee}
|
|
505
|
+
}
|
|
506
|
+
unmatched {
|
|
507
|
+
${L}
|
|
193
508
|
}
|
|
194
|
-
|
|
509
|
+
ambiguous {
|
|
510
|
+
${B}
|
|
511
|
+
}
|
|
512
|
+
validation {
|
|
513
|
+
${U}
|
|
514
|
+
}
|
|
515
|
+
`,Ie=`
|
|
195
516
|
resolvedLinks {
|
|
196
517
|
field
|
|
197
518
|
linkFieldKey
|
|
@@ -216,33 +537,33 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
216
537
|
${e}
|
|
217
538
|
}
|
|
218
539
|
}
|
|
219
|
-
`}var
|
|
540
|
+
`}var n={searchPublishers(e={}){let t={},r=[],s=[];e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
220
541
|
query SearchPublishers${i} {
|
|
221
|
-
searchPublishers${
|
|
222
|
-
${y(
|
|
542
|
+
searchPublishers${c} {
|
|
543
|
+
${y($)}
|
|
223
544
|
}
|
|
224
545
|
}
|
|
225
546
|
`,variables:t}},fetchPublisherById(){return {query:`
|
|
226
547
|
query FetchPublisher($id: UUID!) {
|
|
227
548
|
fetchPublisher(id: $id) {
|
|
228
|
-
${
|
|
549
|
+
${$}
|
|
229
550
|
}
|
|
230
551
|
}
|
|
231
552
|
`}},fetchPublisherBySlug(){return {query:`
|
|
232
553
|
query FetchPublisher($slug: String!) {
|
|
233
554
|
fetchPublisher(slug: $slug) {
|
|
234
|
-
${
|
|
555
|
+
${$}
|
|
235
556
|
}
|
|
236
557
|
}
|
|
237
558
|
`}},fetchPublishers(){return {query:`
|
|
238
559
|
query FetchPublishers($slugs: [String!]!) {
|
|
239
560
|
fetchPublishers(slugs: $slugs) {
|
|
240
|
-
${
|
|
561
|
+
${$}
|
|
241
562
|
}
|
|
242
563
|
}
|
|
243
|
-
`}},searchGames(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",
|
|
564
|
+
`}},searchGames(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
244
565
|
query SearchGames${i} {
|
|
245
|
-
searchGames${
|
|
566
|
+
searchGames${c} {
|
|
246
567
|
${y(m)}
|
|
247
568
|
}
|
|
248
569
|
}
|
|
@@ -264,91 +585,127 @@ var $=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";thi
|
|
|
264
585
|
${m}
|
|
265
586
|
}
|
|
266
587
|
}
|
|
267
|
-
`}},searchDatasets(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",
|
|
588
|
+
`}},searchDatasets(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
268
589
|
query SearchDatasets${i} {
|
|
269
|
-
searchDatasets${
|
|
270
|
-
${y(
|
|
590
|
+
searchDatasets${c} {
|
|
591
|
+
${y(I)}
|
|
271
592
|
}
|
|
272
593
|
}
|
|
273
594
|
`,variables:t}},fetchDatasetById(){return {query:`
|
|
274
595
|
query FetchDataset($id: UUID!) {
|
|
275
596
|
fetchDataset(id: $id) {
|
|
276
|
-
${
|
|
277
|
-
${
|
|
597
|
+
${I}
|
|
598
|
+
${O}
|
|
278
599
|
}
|
|
279
600
|
}
|
|
280
601
|
`}},fetchDatasetByKeys(){return {query:`
|
|
281
602
|
query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
|
|
282
603
|
fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
|
|
283
|
-
${
|
|
284
|
-
${
|
|
604
|
+
${I}
|
|
605
|
+
${O}
|
|
285
606
|
}
|
|
286
607
|
}
|
|
287
608
|
`}},fetchDatasets(){return {query:`
|
|
288
609
|
query FetchDatasets($ids: [UUID!]!) {
|
|
289
610
|
fetchDatasets(ids: $ids) {
|
|
290
|
-
${
|
|
611
|
+
${I}
|
|
291
612
|
}
|
|
292
613
|
}
|
|
293
|
-
`}},searchRecords(e){let t={publisherSlug:e.publisherSlug,gameKey:e.gameKey,datasetKey:e.datasetKey},r=["publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"],s=["$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"];e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.orderBy!==void 0&&(s.push("$orderBy: String"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let
|
|
294
|
-
${
|
|
614
|
+
`}},searchRecords(e){let t={publisherSlug:e.publisherSlug,gameKey:e.gameKey,datasetKey:e.datasetKey},r=["publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"],s=["$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"];e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.orderBy!==void 0&&(s.push("$orderBy: String"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,c=p({includePricing:e.includePricing}),a=i?`${c}
|
|
615
|
+
${Ie}`:c;return {query:`
|
|
295
616
|
query SearchRecords(${s.join(", ")}) {
|
|
296
617
|
searchRecords(${r.join(", ")}) {
|
|
297
|
-
${y(
|
|
618
|
+
${y(a)}
|
|
298
619
|
}
|
|
299
620
|
}
|
|
300
|
-
`,variables:t}},fetchRecordById(){return {query:`
|
|
621
|
+
`,variables:t}},fetchRecordById(e={}){return {query:`
|
|
301
622
|
query FetchRecord($id: UUID!) {
|
|
302
623
|
fetchRecord(id: $id) {
|
|
303
|
-
${
|
|
624
|
+
${p(e)}
|
|
304
625
|
}
|
|
305
626
|
}
|
|
306
|
-
`}},fetchRecordByIdentifier(){return {query:`
|
|
627
|
+
`}},fetchRecordByIdentifier(e={}){return {query:`
|
|
307
628
|
query FetchRecordByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifier: String!) {
|
|
308
629
|
fetchRecordByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifier: $identifier) {
|
|
309
|
-
${
|
|
630
|
+
${p(e)}
|
|
310
631
|
}
|
|
311
632
|
}
|
|
312
|
-
`}},fetchRecordsByIdentifier(){return {query:`
|
|
633
|
+
`}},fetchRecordsByIdentifier(e={}){return {query:`
|
|
313
634
|
query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
|
|
314
635
|
fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
|
|
315
|
-
${
|
|
636
|
+
${p(e)}
|
|
316
637
|
}
|
|
317
638
|
}
|
|
318
|
-
`}},fetchRecords(){return {query:`
|
|
639
|
+
`}},fetchRecords(e={}){return {query:`
|
|
319
640
|
query FetchRecords($ids: [UUID!]!) {
|
|
320
641
|
fetchRecords(ids: $ids) {
|
|
321
|
-
${
|
|
642
|
+
${p(e)}
|
|
322
643
|
}
|
|
323
644
|
}
|
|
324
|
-
`}},listMyDecks(e={}){let t={},r=[],s=[];e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",
|
|
645
|
+
`}},listMyDecks(e={}){let t={},r=[],s=[];e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
325
646
|
query MyDecks${i} {
|
|
326
|
-
myDecks${
|
|
327
|
-
${y(
|
|
647
|
+
myDecks${c} {
|
|
648
|
+
${y(u)}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
`,variables:t}},viewerDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: ViewerDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
652
|
+
query ViewerDecks${i} {
|
|
653
|
+
viewerDecks${c} {
|
|
654
|
+
${y(u)}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
`,variables:t}},appDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: AppDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
658
|
+
query AppDecks${i} {
|
|
659
|
+
appDecks${c} {
|
|
660
|
+
${y(u)}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
`,variables:t}},publicDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: PublicDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
664
|
+
query PublicDecks${i} {
|
|
665
|
+
publicDecks${c} {
|
|
666
|
+
${y(u)}
|
|
328
667
|
}
|
|
329
668
|
}
|
|
330
669
|
`,variables:t}},fetchDeckById(){return {query:`
|
|
331
670
|
query FetchDeck($id: UUID!) {
|
|
332
671
|
fetchDeck(id: $id) {
|
|
333
|
-
${
|
|
672
|
+
${u}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
`}},deckById(){return {query:`
|
|
676
|
+
query Deck($id: UUID!) {
|
|
677
|
+
deck(id: $id) {
|
|
678
|
+
${u}
|
|
334
679
|
}
|
|
335
680
|
}
|
|
336
681
|
`}},myDeck(){return {query:`
|
|
337
682
|
query MyDeck($id: UUID!) {
|
|
338
683
|
myDeck(id: $id) {
|
|
339
|
-
${
|
|
684
|
+
${u}
|
|
340
685
|
}
|
|
341
686
|
}
|
|
342
687
|
`}},fetchDeckBySlug(){return {query:`
|
|
343
688
|
query FetchDeckBySlug($publisherSlug: String!, $gameKey: String!, $slug: String!) {
|
|
344
689
|
fetchDeckBySlug(publisherSlug: $publisherSlug, gameKey: $gameKey, slug: $slug) {
|
|
345
|
-
${
|
|
690
|
+
${u}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
`}},deckBySlug(){return {query:`
|
|
694
|
+
query DeckBySlug($publisherSlug: String!, $gameKey: String!, $slug: String!) {
|
|
695
|
+
deckBySlug(publisherSlug: $publisherSlug, gameKey: $gameKey, slug: $slug) {
|
|
696
|
+
${u}
|
|
346
697
|
}
|
|
347
698
|
}
|
|
348
699
|
`}},fetchDeckByExternalRef(){return {query:`
|
|
349
700
|
query FetchDeckByExternalRef($externalRef: String!) {
|
|
350
701
|
fetchDeckByExternalRef(externalRef: $externalRef) {
|
|
351
|
-
${
|
|
702
|
+
${u}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
`}},deckByExternalRef(){return {query:`
|
|
706
|
+
query DeckByExternalRef($externalRef: String!) {
|
|
707
|
+
deckByExternalRef(externalRef: $externalRef) {
|
|
708
|
+
${u}
|
|
352
709
|
}
|
|
353
710
|
}
|
|
354
711
|
`}},deckVersion(){return {query:`
|
|
@@ -366,47 +723,249 @@ ${O}`:f;return {query:`
|
|
|
366
723
|
`,variables:t}},deckPreview(){return {query:`
|
|
367
724
|
query DeckPreview($token: String!) {
|
|
368
725
|
deckPreview(token: $token) {
|
|
369
|
-
${
|
|
726
|
+
${u}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
`}},deckEmbed(){return {query:`
|
|
730
|
+
query DeckEmbed($token: String!) {
|
|
731
|
+
deckEmbed(token: $token) {
|
|
732
|
+
${u}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
`}},deckAccess(){return {query:`
|
|
736
|
+
query DeckAccess($token: String!) {
|
|
737
|
+
deckAccess(token: $token) {
|
|
738
|
+
${u}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
`}},deckDraftDiff(){return {query:`
|
|
742
|
+
query DeckDraftDiff($id: UUID!) {
|
|
743
|
+
deckDraftDiff(id: $id) {
|
|
744
|
+
${M}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
`}},deckVersionDiff(){return {query:`
|
|
748
|
+
query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
|
|
749
|
+
deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
|
|
750
|
+
${M}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
`}},deckHydrateEntries(){return {query:`
|
|
754
|
+
query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
|
|
755
|
+
deckHydrateEntries(input: $input) {
|
|
756
|
+
${fe}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
`}},deckExport(){return {query:`
|
|
760
|
+
query DeckExport($id: UUID!, $format: DeckExportFormat!) {
|
|
761
|
+
deckExport(id: $id, format: $format) {
|
|
762
|
+
${ke}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
`}},deckValidate(){return {query:`
|
|
766
|
+
query DeckValidate($id: UUID!, $input: DeckValidateInput) {
|
|
767
|
+
deckValidate(id: $id, input: $input) {
|
|
768
|
+
${U}
|
|
370
769
|
}
|
|
371
770
|
}
|
|
372
|
-
`}},
|
|
771
|
+
`}},deckSectionDefinitions(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.rulesetKey!==void 0&&(s.push("$rulesetKey: String"),r.push("rulesetKey: $rulesetKey"),t.rulesetKey=e.rulesetKey),e.rulesetVersionId!==void 0&&(s.push("$rulesetVersionId: UUID"),r.push("rulesetVersionId: $rulesetVersionId"),t.rulesetVersionId=e.rulesetVersionId);let i=s.length>0?`(${s.join(", ")})`:"",c=r.length>0?`(${r.join(", ")})`:"";return {query:`
|
|
772
|
+
query DeckSectionDefinitions${i} {
|
|
773
|
+
deckSectionDefinitions${c} {
|
|
774
|
+
${P}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
`,variables:t}},deckCollaborators(){return {query:`
|
|
373
778
|
query DeckCollaborators($deckId: UUID!) {
|
|
374
779
|
deckCollaborators(deckId: $deckId) {
|
|
375
|
-
${
|
|
780
|
+
${G}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
`}},deckEmbedTokens(){return {query:`
|
|
784
|
+
query DeckEmbedTokens($deckId: UUID!) {
|
|
785
|
+
deckEmbedTokens(deckId: $deckId) {
|
|
786
|
+
${Y}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
`}},deckAccessTokenIssuers(){return {query:`
|
|
790
|
+
query DeckAccessTokenIssuers($deckId: UUID!) {
|
|
791
|
+
deckAccessTokenIssuers(deckId: $deckId) {
|
|
792
|
+
${E}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
`}},deckApiApplicationAccesses(){return {query:`
|
|
796
|
+
query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
|
|
797
|
+
deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
|
|
798
|
+
${R}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
`}},myDeckApiApplicationAccesses(){return {query:`
|
|
802
|
+
query MyDeckApiApplicationAccesses($applicationId: UUID) {
|
|
803
|
+
myDeckApiApplicationAccesses(applicationId: $applicationId) {
|
|
804
|
+
${R}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
`}},deckImportFormats(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
|
|
808
|
+
query DeckImportFormats(${s.join(", ")}) {
|
|
809
|
+
deckImportFormats(${r.join(", ")}) {
|
|
810
|
+
${y(f)}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
`,variables:t}},deckImportFormat(){return {query:`
|
|
814
|
+
query DeckImportFormat($id: UUID!) {
|
|
815
|
+
deckImportFormat(id: $id) {
|
|
816
|
+
${f}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
`}},deckImportFormatTest(){return {query:`
|
|
820
|
+
query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
|
|
821
|
+
deckImportFormatTest(input: $input) {
|
|
822
|
+
${ye}
|
|
376
823
|
}
|
|
377
824
|
}
|
|
378
825
|
`}},deckPreviewTokens(){return {query:`
|
|
379
826
|
query DeckPreviewTokens($deckId: UUID!) {
|
|
380
827
|
deckPreviewTokens(deckId: $deckId) {
|
|
381
|
-
${
|
|
828
|
+
${j}
|
|
382
829
|
}
|
|
383
830
|
}
|
|
384
831
|
`}},createDeck(){return {query:`
|
|
385
832
|
mutation DeckCreate($input: DeckCreateInput!) {
|
|
386
833
|
deckCreate(input: $input) {
|
|
387
|
-
${
|
|
834
|
+
${u}
|
|
388
835
|
}
|
|
389
836
|
}
|
|
390
837
|
`}},updateDeck(){return {query:`
|
|
391
838
|
mutation DeckUpdate($id: UUID!, $input: DeckUpdateInput!) {
|
|
392
839
|
deckUpdate(id: $id, input: $input) {
|
|
393
|
-
${
|
|
840
|
+
${u}
|
|
394
841
|
}
|
|
395
842
|
}
|
|
396
843
|
`}},deleteDeck(){return {query:`
|
|
397
844
|
mutation DeckDelete($id: UUID!) {
|
|
398
845
|
deckDelete(id: $id)
|
|
399
846
|
}
|
|
847
|
+
`}},archiveDeck(){return {query:`
|
|
848
|
+
mutation DeckArchive($id: UUID!) {
|
|
849
|
+
deckArchive(id: $id) {
|
|
850
|
+
${u}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
`}},restoreDeck(){return {query:`
|
|
854
|
+
mutation DeckRestore($id: UUID!) {
|
|
855
|
+
deckRestore(id: $id) {
|
|
856
|
+
${u}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
`}},unpublishDeck(){return {query:`
|
|
860
|
+
mutation DeckUnpublish($id: UUID!) {
|
|
861
|
+
deckUnpublish(id: $id) {
|
|
862
|
+
${u}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
`}},addDeckEntry(){return {query:`
|
|
866
|
+
mutation DeckEntryAdd($input: DeckEntryAddInput!) {
|
|
867
|
+
deckEntryAdd(input: $input) {
|
|
868
|
+
${S}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
`}},updateDeckEntry(){return {query:`
|
|
872
|
+
mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
|
|
873
|
+
deckEntryUpdate(id: $id, input: $input) {
|
|
874
|
+
${S}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
`}},removeDeckEntry(){return {query:`
|
|
878
|
+
mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
|
|
879
|
+
deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
|
|
880
|
+
${S}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
`}},reorderDeckEntries(){return {query:`
|
|
884
|
+
mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
|
|
885
|
+
deckEntryReorder(deckId: $deckId, input: $input) {
|
|
886
|
+
${re}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
`}},replaceDeckEntries(){return {query:`
|
|
890
|
+
mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
|
|
891
|
+
deckEntriesReplace(deckId: $deckId, input: $input) {
|
|
892
|
+
${De}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
`}},importDeck(){return {query:`
|
|
896
|
+
mutation DeckImport($input: DeckImportInput!) {
|
|
897
|
+
deckImport(input: $input) {
|
|
898
|
+
${$e}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
`}},createDeckImportFormat(){return {query:`
|
|
902
|
+
mutation DeckImportFormatCreate($input: DeckImportFormatCreateInput!) {
|
|
903
|
+
deckImportFormatCreate(input: $input) {
|
|
904
|
+
${f}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
`}},updateDeckImportFormat(){return {query:`
|
|
908
|
+
mutation DeckImportFormatUpdate($id: UUID!, $input: DeckImportFormatUpdateInput!) {
|
|
909
|
+
deckImportFormatUpdate(id: $id, input: $input) {
|
|
910
|
+
${f}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
`}},archiveDeckImportFormat(){return {query:`
|
|
914
|
+
mutation DeckImportFormatArchive($id: UUID!) {
|
|
915
|
+
deckImportFormatArchive(id: $id) {
|
|
916
|
+
${f}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
`}},unarchiveDeckImportFormat(){return {query:`
|
|
920
|
+
mutation DeckImportFormatUnarchive($id: UUID!) {
|
|
921
|
+
deckImportFormatUnarchive(id: $id) {
|
|
922
|
+
${f}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
`}},upsertDeckByExternalRef(){return {query:`
|
|
926
|
+
mutation DeckUpsertByExternalRef($input: DeckUpsertByExternalRefInput!) {
|
|
927
|
+
deckUpsertByExternalRef(input: $input) {
|
|
928
|
+
deck {
|
|
929
|
+
${u}
|
|
930
|
+
}
|
|
931
|
+
created
|
|
932
|
+
idempotentReplay
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
`}},claimDeck(){return {query:`
|
|
936
|
+
mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
|
|
937
|
+
deckClaim(id: $id, input: $input) {
|
|
938
|
+
${H}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
`}},transferDeckOwnership(){return {query:`
|
|
942
|
+
mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
|
|
943
|
+
deckTransferOwnership(id: $id, input: $input) {
|
|
944
|
+
${H}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
`}},copyDeck(){return {query:`
|
|
948
|
+
mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
|
|
949
|
+
deckCopy(id: $id, input: $input) {
|
|
950
|
+
${pe}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
400
953
|
`}},publishDeck(){return {query:`
|
|
401
954
|
mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
|
|
402
955
|
deckPublish(id: $id, input: $input) {
|
|
403
|
-
${
|
|
956
|
+
${me}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
`}},removeInvalidDeckEntries(){return {query:`
|
|
960
|
+
mutation DeckRemoveInvalidEntries($id: UUID!, $input: DeckRemoveInvalidEntriesInput!) {
|
|
961
|
+
deckRemoveInvalidEntries(id: $id, input: $input) {
|
|
962
|
+
${u}
|
|
404
963
|
}
|
|
405
964
|
}
|
|
406
965
|
`}},upsertDeckCollaborator(){return {query:`
|
|
407
966
|
mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
|
|
408
967
|
deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
|
|
409
|
-
${
|
|
968
|
+
${G}
|
|
410
969
|
}
|
|
411
970
|
}
|
|
412
971
|
`}},removeDeckCollaborator(){return {query:`
|
|
@@ -418,7 +977,7 @@ ${O}`:f;return {query:`
|
|
|
418
977
|
deckPreviewTokenCreate(input: $input) {
|
|
419
978
|
token
|
|
420
979
|
previewToken {
|
|
421
|
-
${
|
|
980
|
+
${j}
|
|
422
981
|
}
|
|
423
982
|
}
|
|
424
983
|
}
|
|
@@ -426,7 +985,59 @@ ${O}`:f;return {query:`
|
|
|
426
985
|
mutation DeckPreviewTokenRevoke($id: UUID!) {
|
|
427
986
|
deckPreviewTokenRevoke(id: $id)
|
|
428
987
|
}
|
|
429
|
-
`}},
|
|
988
|
+
`}},createDeckEmbedToken(){return {query:`
|
|
989
|
+
mutation DeckEmbedTokenCreate($input: DeckEmbedTokenCreateInput!) {
|
|
990
|
+
deckEmbedTokenCreate(input: $input) {
|
|
991
|
+
token
|
|
992
|
+
embedToken {
|
|
993
|
+
${Y}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
`}},revokeDeckEmbedToken(){return {query:`
|
|
998
|
+
mutation DeckEmbedTokenRevoke($id: UUID!) {
|
|
999
|
+
deckEmbedTokenRevoke(id: $id)
|
|
1000
|
+
}
|
|
1001
|
+
`}},createDeckAccessTokenIssuer(){return {query:`
|
|
1002
|
+
mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
|
|
1003
|
+
deckAccessTokenIssuerCreate(input: $input) {
|
|
1004
|
+
${E}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
`}},revokeDeckAccessTokenIssuer(){return {query:`
|
|
1008
|
+
mutation DeckAccessTokenIssuerRevoke($id: UUID!) {
|
|
1009
|
+
deckAccessTokenIssuerRevoke(id: $id)
|
|
1010
|
+
}
|
|
1011
|
+
`}},revokeDeckAccessTokenIssuerSigningKey(){return {query:`
|
|
1012
|
+
mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
|
|
1013
|
+
deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
|
|
1014
|
+
${E}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
`}},exchangeDeckAccessToken(){return {query:`
|
|
1018
|
+
mutation DeckAccessTokenExchange($input: DeckAccessTokenExchangeInput!) {
|
|
1019
|
+
deckAccessTokenExchange(input: $input) {
|
|
1020
|
+
token
|
|
1021
|
+
accessToken {
|
|
1022
|
+
${he}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
`}},grantDeckApiApplicationAccess(){return {query:`
|
|
1027
|
+
mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
|
|
1028
|
+
deckApiApplicationAccessGrant(input: $input) {
|
|
1029
|
+
${R}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
`}},revokeDeckApiApplicationAccess(){return {query:`
|
|
1033
|
+
mutation DeckApiApplicationAccessRevoke($deckId: UUID!, $apiApplicationId: UUID!) {
|
|
1034
|
+
deckApiApplicationAccessRevoke(deckId: $deckId, apiApplicationId: $apiApplicationId)
|
|
1035
|
+
}
|
|
1036
|
+
`}},revokeDeckAccessToken(){return {query:`
|
|
1037
|
+
mutation DeckAccessTokenRevoke($id: UUID!) {
|
|
1038
|
+
deckAccessTokenRevoke(id: $id)
|
|
1039
|
+
}
|
|
1040
|
+
`}},deckCreateVariables(e){return {input:e}},deckUpdateVariables(e,t){return {id:e,input:t}},deckEntryAddVariables(e){return {input:e}},deckEntryUpdateVariables(e,t){return {id:e,input:t}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:t}},deckImportVariables(e){return {input:e}},deckImportFormatCreateVariables(e){return {input:e}},deckImportFormatUpdateVariables(e,t){return {id:e,input:t}},deckImportFormatTestVariables(e){return {input:e}},deckUpsertByExternalRefVariables(e){return {input:e}},deckClaimVariables(e,t){return {id:e,input:t}},deckTransferOwnershipVariables(e,t){return {id:e,input:t}},deckCopyVariables(e,t){return {id:e,input:t}},deckPublishVariables(e,t){return {id:e,input:t}},deckValidateVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckRemoveInvalidEntriesVariables(e,t){return {id:e,input:t}},deckHydrateEntriesVariables(e){return {input:e}},deckExportVariables(e,t){return {id:e,format:t}},deckVersionDiffVariables(e,t){return {fromVersionId:e,toVersionId:t}},deckCollaboratorVariables(e,t,r){return r===void 0?{deckId:e,accountId:t}:{deckId:e,accountId:t,role:r}},deckPreviewTokenCreateVariables(e){return {input:e}},deckEmbedTokenCreateVariables(e){return {input:e}},deckAccessTokenIssuerCreateVariables(e){return {input:e}},deckAccessTokenExchangeVariables(e){return {input:e}},deckApiApplicationAccessesVariables(e,t){return t===void 0?{deckId:e}:{deckId:e,includeRevoked:t}},myDeckApiApplicationAccessesVariables(e){return e===void 0?{}:{applicationId:e}},deckApiApplicationAccessGrantVariables(e){return {input:e}},deckApiApplicationAccessRevokeVariables(e,t){return {deckId:e,apiApplicationId:t}},fetchMe(){return {query:`
|
|
430
1041
|
query FetchMe {
|
|
431
1042
|
fetchMe {
|
|
432
1043
|
application {
|
|
@@ -448,6 +1059,6 @@ ${O}`:f;return {query:`
|
|
|
448
1059
|
}
|
|
449
1060
|
}
|
|
450
1061
|
}
|
|
451
|
-
`}}},h=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var j="https://carddb.xtda.org/query",X=3e4,Q=1e4,H=300,J=3,W=2,Y=1e3,z=3e4,Z=class F{apiKey;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.apiKey=t.apiKey,this.endpoint=t.endpoint??j,this.timeout=t.timeout??X,this.openTimeout=t.openTimeout??Q,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??J,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??W,this.retryBaseDelay=t.retryBaseDelay??Y,this.retryMaxDelay=t.retryMaxDelay??z,this.cache=t.cache,this.cacheTtl=t.cacheTtl??H,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new S(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new S(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new F({apiKey:t.apiKey??this.apiKey,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},N="0.1.0";function ee(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?te(navigator.userAgent):{name:"unknown",version:"unknown"}}function te(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let i=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return i?{name:"safari",version:i[1]}:{name:"browser",version:"unknown"}}function re(){let e=ee();return `CardDB-SDK/js/${N} (${e.name}/${e.version})`}function Oe(){return N}var G=null;function se(){return G}var ie=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,i=0;for(;;)try{let n=Date.now();this.logRequest(r,t);let a=await this.fetch(e,t),o=Date.now()-n,u=await this.handleResponse(a);return this.logResponse(r,o),u}catch(n){if(n instanceof p&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let a=n.retryAfter??60;this.logRateLimitRetry(r,s,a),await this.sleep(a*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let a=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,a,n),i++,await this.sleep(a);continue}if(n instanceof I&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let a=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,a,n),i++,await this.sleep(a);continue}throw n}}isRetryableNetworkError(e){return e instanceof k||e instanceof x}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout);try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":re(),...this.config.apiKey?{"X-API-Key":this.config.apiKey}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(i){throw i instanceof Error?i.name==="AbortError"?(this.logError("Request timed out"),new x("Request timed out")):(this.logError(`Connection failed: ${i.message}`),new k(`Connection failed: ${i.message}`)):new k("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new D("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new I(`Server error (${e.status})`,{status:e.status,response:t})}throw new l(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new D(s,t);case "RATE_LIMITED":throw new p(s,{response:t});case "NOT_FOUND":throw new l(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new R(s,{errors:e,response:t});default:throw new B(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=i?new Date(i*1e3):null,a=await this.parseBody(e);throw new p("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:a})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new R(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;G={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let i=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${i} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function ne(e,t,r){let s=Object.entries(r).filter(([,i])=>i!==void 0).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>`${i}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function ae(e,t){let r=e.get(t);return r}async function ce(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var g=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let i=r.cache??!!this.config.cache,n=this.config.cache;if(!i||!n)return s();let a=await ae(n,e);if(a!==null)return a;let o=await s();if(o!=null){let u=this.config.cacheTtlFor(t);await ce(n,e,o,u);}return o}cacheKey(e,t,r){return ne(e,t,r)}},oe=class extends g{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=c.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),i=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new h(i,{nextPageLoader:async n=>this.search({...e,after:n})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:i}=c.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=c.fetchPublisherBySlug();return (await this.connection.execute(i,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=c.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},ue=class extends g{constructor(e,t){super(e,t);}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=c.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),i=this.cacheKey("games","search",s),n=await this.withCache(i,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new h(n,{nextPageLoader:async a=>this.search({...e,after:a})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,n=r??{};this.validateAccess(s,i);let a=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(a,"games",n,async()=>{let{query:o}=c.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:i})).fetchGame??null})}else {let s=e,i=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",i,async()=>{let{query:a}=c.fetchGameById();return (await this.connection.execute(a,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=c.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},le=class extends g{constructor(e,t){super(e,t);}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:i}=c.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",i),a=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new h(a,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let i=e,n=t,a=s??{};this.validateAccess(i,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",a,async()=>{let{query:u}=c.fetchDatasetByKeys();return (await this.connection.execute(u,{publisherSlug:i,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let i=e,n=t??{},a=this.cacheKey("datasets","get",{id:i});return this.withCache(a,"datasets",n,async()=>{let{query:o}=c.fetchDatasetById();return (await this.connection.execute(o,{id:i})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=c.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},he=class extends g{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let i=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=c.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async listMine(e={}){let{query:t,variables:r}=c.listMyDecks({first:e.first,after:e.after}),s=this.cacheKey("decks","listMine",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new h(i,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=c.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},n=this.cacheKey("decks","listVersions",i),a=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new h(a,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async preview(e,t={}){let r=this.cacheKey("decks","preview",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.deckPreview();return (await this.connection.execute(s,{token:e})).deckPreview??null})}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listPreviewTokens(e,t={}){let r=this.cacheKey("decks","listPreviewTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=c.deckPreviewTokens();return (await this.connection.execute(s,{deckId:e})).deckPreviewTokens})}async create(e){let{query:t}=c.createDeck(),r=c.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=c.updateDeck(),s=c.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async delete(e){let{query:t}=c.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async publish(e,t={}){let{query:r}=c.publishDeck(),s=c.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async upsertCollaborator(e,t,r){let{query:s}=c.upsertDeckCollaborator(),i=c.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=c.removeDeckCollaborator(),s=c.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createPreviewToken(e){let{query:t}=c.createDeckPreviewToken(),r=c.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=c.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),i=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(i,"decks",e,async()=>{let{query:o}=c.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),a=de(n,s,e.identifierField);return e.entries.map(o=>({...o,record:a.get(o.identifier)??null}))}};function de(e,t,r){let s=new Set(t),i=new Map;for(let n of e){let a=r?n.data[r]:Object.values(n.data).find(u=>s.has(String(u)));if(a==null)continue;let o=String(a);s.has(o)&&(i.set(o,n),s.delete(o));}return i}var fe=class extends g{constructor(e,t){super(e,t);}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=E(e.filter),{query:i,variables:n}=c.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema}),a=this.cacheKey("records","search",n),o=await this.withCache(a,"records",e,async()=>(await this.connection.execute(i,n)).searchRecords);return new h(o,{nextPageLoader:async u=>this.search({...e,after:u})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=c.fetchRecordById();return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier});return this.withCache(s,"records",e,async()=>{let{query:i}=c.fetchRecordByIdentifier();return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers});return this.withCache(s,"records",e,async()=>{let{query:i}=c.fetchRecordsByIdentifier();return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e});return this.withCache(r,"records",t,async()=>{let{query:s}=c.fetchRecords();return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},ye=class extends g{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:i}=c.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",i),a=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new h(a,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),i=t.datasetKey??e;this.validateAccess(r,s);let n=E(t.filter),{query:a,variables:o}=c.searchRecords({publisherSlug:r,gameKey:s,datasetKey:i,filter:n,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),u=this.cacheKey("rules","records",o),C=await this.withCache(u,"records",t,async()=>(await this.connection.execute(a,o)).searchRecords);return new h(C,{nextPageLoader:async P=>this.searchRuleRecords(e,{...t,after:P})})}},je=class M{config;connection;publishers;games;datasets;records;decks;rules;constructor(t={}){this.config=new Z(t),this.connection=new ie(this.config),this.publishers=new oe(this.connection,this.config),this.games=new ue(this.connection,this.config),this.datasets=new le(this.connection,this.config),this.records=new fe(this.connection,this.config),this.decks=new he(this.connection,this.config),this.rules=new ye(this.connection,this.config);}async me(){let{query:t}=c.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return se()}withConfig(t){let r=this.config.merge(t);return new M({apiKey:r.apiKey,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};
|
|
452
|
-
export{
|
|
1062
|
+
`}}},d=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var ve="https://carddb.xtda.org/query",be=3e4,we=1e4,Ae=300,Ee=3,Re=2,Se=1e3,xe=3e4,Te=class se{apiKey;publishableKey;secretKey;accessToken;legacyApiKey;environment;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.legacyApiKey=t.apiKey,this.publishableKey=t.publishableKey,this.secretKey=t.secretKey,this.accessToken=t.accessToken,this.apiKey=t.apiKey??t.publishableKey??t.secretKey,this.environment=t.environment,this.endpoint=t.endpoint??ve,this.timeout=t.timeout??be,this.openTimeout=t.openTimeout??we,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??Ee,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??Re,this.retryBaseDelay=t.retryBaseDelay??Se,this.retryMaxDelay=t.retryMaxDelay??xe,this.cache=t.cache,this.cacheTtl=t.cacheTtl??Ae,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new k(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new k(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}requireSecretCredential(t){if(!(!this.accessToken&&(this.legacyApiKey||this.secretKey&&!this.publishableKey)))throw new k(`${t} requires a server-side secretKey or legacy apiKey credential`)}requestApiKey(){return this.legacyApiKey??this.publishableKey??this.secretKey}configApiKey(){return this.legacyApiKey}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new se({apiKey:t.apiKey??this.legacyApiKey,publishableKey:t.publishableKey??this.publishableKey,secretKey:t.secretKey??this.secretKey,accessToken:t.accessToken??this.accessToken,environment:t.environment??this.environment,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},ie="0.1.0";function Ke(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?Ce(navigator.userAgent):{name:"unknown",version:"unknown"}}function Ce(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let i=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return i?{name:"safari",version:i[1]}:{name:"browser",version:"unknown"}}function qe(){let e=Ke();return `CardDB-SDK/js/${ie} (${e.name}/${e.version})`}function $t(){return ie}var ne=null;function Pe(){return ne}var Ue=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,i=0;for(;;)try{let c=Date.now();this.logRequest(r,t);let a=await this.fetch(e,t),o=Date.now()-c,l=await this.handleResponse(a);return this.logResponse(r,o),l}catch(c){if(c instanceof w&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let a=c.retryAfter??60;this.logRateLimitRetry(r,s,a),await this.sleep(a*1e3);continue}if(this.isRetryableNetworkError(c)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let a=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,a,c),i++,await this.sleep(a);continue}if(c instanceof C&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let a=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,a,c),i++,await this.sleep(a);continue}throw c}}isRetryableNetworkError(e){return e instanceof D||e instanceof K}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),i=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":qe(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&i?{"X-API-Key":i}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(c){throw c instanceof Error?c.name==="AbortError"?(this.logError("Request timed out"),new K("Request timed out")):(this.logError(`Connection failed: ${c.message}`),new D(`Connection failed: ${c.message}`)):new D("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new x("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new C(`Server error (${e.status})`,{status:e.status,response:t})}throw new h(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new x(s,t);case "RATE_LIMITED":throw new w(s,{response:t});case "NOT_FOUND":throw new h(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new T(s,{errors:e,response:t});default:throw new Q(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,c=i?new Date(i*1e3):null,a=await this.parseBody(e);throw new w("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:c,response:a})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new T(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;ne={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let i=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${i} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function Fe(e,t,r){let s=Object.entries(r).filter(([,i])=>i!==void 0).sort(([i],[c])=>i.localeCompare(c)).map(([i,c])=>`${i}=${JSON.stringify(c)}`).join("&");return `carddb:${e}:${t}:${s}`}async function Le(e,t){let r=e.get(t);return r}async function Be(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var g=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let i=r.cache??!!this.config.cache,c=this.config.cache;if(!i||!c)return s();let a=await Le(c,e);if(a!==null)return a;let o=await s();if(o!=null){let l=this.config.cacheTtlFor(t);await Be(c,e,o,l);}return o}cacheKey(e,t,r){return Fe(e,t,r)}},_e=class extends g{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=n.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),i=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new d(i,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:i}=n.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=n.fetchPublisherBySlug();return (await this.connection.execute(i,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=n.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},Ve=class extends g{constructor(e,t){super(e,t);}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=n.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),i=this.cacheKey("games","search",s),c=await this.withCache(i,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new d(c,{nextPageLoader:async a=>this.search({...e,after:a})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,c=r??{};this.validateAccess(s,i);let a=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(a,"games",c,async()=>{let{query:o}=n.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:i})).fetchGame??null})}else {let s=e,i=t??{},c=this.cacheKey("games","get",{id:s});return this.withCache(c,"games",i,async()=>{let{query:a}=n.fetchGameById();return (await this.connection.execute(a,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=n.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},Ne=class extends g{constructor(e,t){super(e,t);}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:i}=n.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),c=this.cacheKey("datasets","search",i),a=await this.withCache(c,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(a,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let i=e,c=t,a=s??{};this.validateAccess(i,c);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:c,datasetKey:r});return this.withCache(o,"datasets",a,async()=>{let{query:l}=n.fetchDatasetByKeys();return (await this.connection.execute(l,{publisherSlug:i,gameKey:c,datasetKey:r})).fetchDataset??null})}else {let i=e,c=t??{},a=this.cacheKey("datasets","get",{id:i});return this.withCache(a,"datasets",c,async()=>{let{query:o}=n.fetchDatasetById();return (await this.connection.execute(o,{id:i})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=n.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},Oe=class extends g{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t={}){let r=this.cacheKey("decks","get",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckById();return (await this.connection.execute(s,{id:e})).deck??null})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let i=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:c}=n.fetchDeckBySlug();return (await this.connection.execute(c,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let i=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:c}=n.deckBySlug();return (await this.connection.execute(c,{publisherSlug:e,gameKey:t,slug:r})).deckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t={}){let r=this.cacheKey("decks","getByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).deckByExternalRef??null})}async listMine(e={}){let{query:t,variables:r}=n.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new d(i,{nextPageLoader:async c=>this.listMine({...e,after:c})})}async listViewer(e={}){let{query:t,variables:r}=n.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new d(i,{nextPageLoader:async c=>this.listViewer({...e,after:c})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=n.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new d(i,{nextPageLoader:async c=>this.listApp({...e,after:c})})}async listPublic(e={}){let{query:t,variables:r}=n.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new d(i,{nextPageLoader:async c=>this.listPublic({...e,after:c})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=n.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},c=this.cacheKey("decks","listVersions",i),a=await this.withCache(c,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new d(a,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async preview(e,t={}){let r=this.cacheKey("decks","preview",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckPreview();return (await this.connection.execute(s,{token:e})).deckPreview??null})}async embed(e,t={}){let r=this.cacheKey("decks","embed",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckEmbed();return (await this.connection.execute(s,{token:e})).deckEmbed??null})}async access(e,t={}){let r=this.cacheKey("decks","access",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckAccess();return (await this.connection.execute(s,{token:e})).deckAccess??null})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=n.deckVersionDiffVariables(e,t),i=this.cacheKey("decks","versionDiff",s);return this.withCache(i,"decks",r,async()=>{let{query:c}=n.deckVersionDiff();return (await this.connection.execute(c,s)).deckVersionDiff})}async validate(e,t,r={}){let s=n.deckValidateVariables(e,t),i=this.cacheKey("decks","validate",s);return this.withCache(i,"decks",r,async()=>{let{query:c}=n.deckValidate();return (await this.connection.execute(c,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=n.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=n.deckHydrateEntries();return (await this.connection.execute(i,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=n.deckExportVariables(e,t),i=this.cacheKey("decks","exportDeck",s);return this.withCache(i,"decks",r,async()=>{let{query:c}=n.deckExport();return (await this.connection.execute(c,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=n.deckSectionDefinitions({publisherSlug:e.publisherSlug,gameKey:e.gameKey,gameId:e.gameId,rulesetKey:e.rulesetKey,rulesetVersionId:e.rulesetVersionId}),s=this.cacheKey("decks","sectionDefinitions",r);return this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).deckSectionDefinitions)}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listPreviewTokens(e,t={}){let r=this.cacheKey("decks","listPreviewTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckPreviewTokens();return (await this.connection.execute(s,{deckId:e})).deckPreviewTokens})}async listEmbedTokens(e,t={}){let r=this.cacheKey("decks","listEmbedTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckEmbedTokens();return (await this.connection.execute(s,{deckId:e})).deckEmbedTokens})}async listAccessTokenIssuers(e,t={}){let r=this.cacheKey("decks","listAccessTokenIssuers",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckAccessTokenIssuers();return (await this.connection.execute(s,{deckId:e})).deckAccessTokenIssuers})}async listApiApplicationAccesses(e,t={}){let r=n.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=n.deckApiApplicationAccesses();return (await this.connection.execute(i,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=n.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=n.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=n.createDeck(),r=n.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=n.updateDeck(),s=n.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async updateMetadata(e,t){return this.update(e,t)}async upsertByExternalRef(e){this.config.requireSecretCredential("decks.upsertByExternalRef");let{query:t}=n.upsertDeckByExternalRef(),r=n.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=n.claimDeck(),s=n.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=n.transferDeckOwnership(),s=n.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=n.copyDeck(),s=n.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=n.addDeckEntry(),r=n.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=n.updateDeckEntry(),s=n.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=n.removeDeckEntry(),s=n.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=n.reorderDeckEntries(),s=n.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=n.replaceDeckEntries(),s=n.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=n.importDeck(),r=n.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=n.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("decks","listImportFormats",s),c=await this.withCache(i,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new d(c,{nextPageLoader:async a=>this.listImportFormats(e,{...t,after:a})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=n.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=n.deckImportFormatTest(),r=n.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=n.createDeckImportFormat(),r=n.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=n.updateDeckImportFormat(),s=n.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=n.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=n.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=n.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=n.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=n.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=n.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=n.publishDeck(),s=n.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=n.removeInvalidDeckEntries(),s=n.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=n.upsertDeckCollaborator(),i=n.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=n.removeDeckCollaborator(),s=n.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createPreviewToken(e){let{query:t}=n.createDeckPreviewToken(),r=n.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=n.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async createEmbedToken(e){let{query:t}=n.createDeckEmbedToken(),r=n.deckEmbedTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckEmbedTokenCreate}async revokeEmbedToken(e){let{query:t}=n.revokeDeckEmbedToken();return !!(await this.connection.execute(t,{id:e})).deckEmbedTokenRevoke}async createAccessTokenIssuer(e){let{query:t}=n.createDeckAccessTokenIssuer(),r=n.deckAccessTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenIssuerCreate}async revokeAccessTokenIssuer(e){let{query:t}=n.revokeDeckAccessTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenIssuerRevoke}async revokeAccessTokenIssuerSigningKey(e){let{query:t}=n.revokeDeckAccessTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckAccessTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=n.grantDeckApiApplicationAccess(),r=n.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=n.revokeDeckApiApplicationAccess(),s=n.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeAccessToken(e){this.config.requireSecretCredential("decks.exchangeAccessToken");let{query:t}=n.exchangeDeckAccessToken(),r=n.deckAccessTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenExchange}async revokeAccessToken(e){this.config.requireSecretCredential("decks.revokeAccessToken");let{query:t}=n.revokeDeckAccessToken();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),i=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),c=await this.withCache(i,"decks",e,async()=>{let{query:o}=n.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),a=Me(c,s,e.identifierField);return e.entries.map(o=>({...o,record:a.get(o.identifier)??null}))}};function Me(e,t,r){let s=new Set(t),i=new Map;for(let c of e){let a=r?c.data[r]:Object.values(c.data).find(l=>s.has(String(l)));if(a==null)continue;let o=String(a);s.has(o)&&(i.set(o,c),s.delete(o));}return i}var Ge=class extends g{constructor(e,t){super(e,t);}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=q(e.filter),{query:i,variables:c}=n.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema,includePricing:e.includePricing}),a=this.cacheKey("records","search",{...c,includePricing:e.includePricing??false}),o=await this.withCache(a,"records",e,async()=>(await this.connection.execute(i,c)).searchRecords);return new d(o,{nextPageLoader:async l=>this.search({...e,after:l})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=n.fetchRecordById({includePricing:t.includePricing});return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=n.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=n.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=n.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},je=class extends g{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:i}=n.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),c=this.cacheKey("rules","datasets",i),a=await this.withCache(c,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(a,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),i=t.datasetKey??e;this.validateAccess(r,s);let c=q(t.filter),{query:a,variables:o}=n.searchRecords({publisherSlug:r,gameKey:s,datasetKey:i,filter:c,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),l=this.cacheKey("rules","records",o),V=await this.withCache(l,"records",t,async()=>(await this.connection.execute(a,o)).searchRecords);return new d(V,{nextPageLoader:async N=>this.searchRuleRecords(e,{...t,after:N})})}},ce=class ae{config;connection;publishers;games;datasets;records;decks;rules;constructor(t={}){this.config=new Te(t),this.connection=new Ue(this.config),this.publishers=new _e(this.connection,this.config),this.games=new Ve(this.connection,this.config),this.datasets=new Ne(this.connection,this.config),this.records=new Ge(this.connection,this.config),this.decks=new Oe(this.connection,this.config),this.rules=new je(this.connection,this.config);}async me(){let{query:t}=n.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return Pe()}withConfig(t){let r=this.config.merge(t);return new ae({apiKey:r.configApiKey(),publishableKey:r.publishableKey,secretKey:r.secretKey,accessToken:r.accessToken,environment:r.environment,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};var _=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";this.storage=r==="sessionStorage"?globalThis.sessionStorage:globalThis.localStorage,this.prefix=t.prefix??"carddb:";}get(t){try{let r=this.storage.getItem(this.prefix+t);if(!r)return null;let s=JSON.parse(r);return s.expiresAt!==null&&Date.now()>s.expiresAt?(this.storage.removeItem(this.prefix+t),null):s.value}catch{return this.storage.removeItem(this.prefix+t),null}}set(t,r,s){try{let i={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(i));}catch(i){console.warn("[CardDB] Failed to write to cache:",i);}}delete(t){this.storage.removeItem(this.prefix+t);}clear(){let t=[];for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t.push(s);}for(let r of t)this.storage.removeItem(r);}has(t){return this.get(t)!==null}get size(){let t=0;for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t++;}return t}cleanup(){let t=Date.now(),r=[];for(let s=0;s<this.storage.length;s++){let i=this.storage.key(s);if(i&&i.startsWith(this.prefix))try{let c=this.storage.getItem(i);if(c){let a=JSON.parse(c);a.expiresAt!==null&&t>a.expiresAt&&r.push(i);}}catch{r.push(i);}}for(let s of r)this.storage.removeItem(s);}};var oe=class extends ce{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new k("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new k("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
|
|
1063
|
+
export{x as AuthenticationError,g as BaseResource,_ as BrowserCache,oe as CardDBClient,h as CardDBError,d as Collection,Te as Configuration,Ue as Connection,D as ConnectionError,Ae as DEFAULT_CACHE_TTL,ve as DEFAULT_ENDPOINT,Re as DEFAULT_MAX_NETWORK_RETRIES,Ee as DEFAULT_MAX_RETRIES,we as DEFAULT_OPEN_TIMEOUT,Se as DEFAULT_RETRY_BASE_DELAY,xe as DEFAULT_RETRY_MAX_DELAY,be as DEFAULT_TIMEOUT,Ne as DatasetsResource,Oe as DecksResource,ue as FilterBuilder,Ve as GamesResource,Q as GraphQLError,He as LinkResolutionError,Ye as NotFoundError,_e as PublishersResource,n as QueryBuilder,w as RateLimitError,Ge as RecordsResource,k as RestrictedError,je as RulesResource,C as ServerError,K as TimeoutError,T as ValidationError,Fe as cacheKey,rt as contains,Xe as eq,Pe as getRateLimitInfo,$t as getSDKVersion,qe as getUserAgent,We as gt,Je as gte,it as ilike,ct as isNotNull,nt as isNull,st as like,ze as lt,Ze as lte,Qe as neq,tt as notWithin,Le as readCache,q as resolveFilter,et as within,Be as writeCache};//# sourceMappingURL=index.js.map
|
|
453
1064
|
//# sourceMappingURL=index.js.map
|