@carddb/browser 0.2.0 → 0.2.5

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.
@@ -1,4 +1,23 @@
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 $=`
1
+ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,re);}},B=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},q=class extends y{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;}},mt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},_=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},b=class extends y{constructor(e,t){super(e,t),this.name="RestrictedError";}},se=class extends y{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},E=class extends y{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},V=class extends E{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},J=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},gt=class extends y{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 kt(e){return {eq:e}}function It(e){return {neq:e}}function $t(e){return {gt:e}}function bt(e){return {gte:e}}function vt(e){return {lt:e}}function Dt(e){return {lte:e}}function wt(e){return {in:e}}function At(e){return {nin:e}}function Et(e){return {contains:e}}function St(e){return {like:e}}function xt(e){return {ilike:e}}function Rt(){return {is_null:true}}function qt(){return {is_null:false}}var be=class ie{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 ie;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;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 C(e){if(e!==void 0){if(typeof e=="function"){let t=new be;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 S=`
2
+ id
3
+ createdAt
4
+ updatedAt
5
+ key
6
+ filename
7
+ contentType
8
+ size
9
+ status
10
+ isPublic
11
+ entityType
12
+ entityId
13
+ url
14
+ `,ve=`
15
+ file {
16
+ ${S}
17
+ }
18
+ uploadUrl
19
+ expiresAt
20
+ `,g=`
2
21
  id
3
22
  name
4
23
  slug
@@ -15,12 +34,14 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
15
34
  id
16
35
  url
17
36
  }
18
- `,m=`
37
+ `,f=`
19
38
  id
20
39
  publisherId
21
40
  key
22
41
  name
23
42
  description
43
+ metafyGameUuid
44
+ metafyGameSlug
24
45
  website
25
46
  visibility
26
47
  isArchived
@@ -39,7 +60,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
39
60
  id
40
61
  url
41
62
  }
42
- `,I=`
63
+ `,p=`
43
64
  id
44
65
  publisherId
45
66
  gameId
@@ -47,8 +68,13 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
47
68
  name
48
69
  description
49
70
  purpose
71
+ activeVersionId
50
72
  tcgplayerProductIdFieldKey
51
73
  visibility
74
+ posX
75
+ posY
76
+ sortOrder
77
+ archivedAt
52
78
  isArchived
53
79
  createdAt
54
80
  updatedAt
@@ -62,7 +88,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
62
88
  key
63
89
  name
64
90
  }
65
- `,le=4;function J(e){return `
91
+ `,De=4;function ae(e){return `
66
92
  key
67
93
  label
68
94
  description
@@ -71,18 +97,36 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
71
97
  filterable
72
98
  searchable
73
99
  isIdentifier
100
+ sortOrder
74
101
  itemType
102
+ linkDatasetId
103
+ linkDatasetKey
104
+ linkDatasetName
105
+ linkFieldKey
106
+ linkAlias
107
+ linkDirection
75
108
  displayFormat
76
109
  semanticType
110
+ placeholder
111
+ isHidden
112
+ isComputed
113
+ isSystemField
114
+ defaultValue
77
115
  allowedValues
116
+ minLength
117
+ maxLength
118
+ minValue
119
+ maxValue
120
+ pattern
121
+ isUnique
78
122
  ${e>0?`
79
123
  nestedFields {
80
- ${J(e-1)}
124
+ ${ae(e-1)}
81
125
  }`:""}
82
- `}var O=`
126
+ `}var D=`
83
127
  schema {
84
128
  fields {
85
- ${J(le)}
129
+ ${ae(De)}
86
130
  }
87
131
  filterableFields
88
132
  searchableFields
@@ -92,9 +136,47 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
92
136
  targetDatasetKey
93
137
  targetDatasetName
94
138
  targetDatasetId
139
+ targetFieldKey
140
+ linkAlias
141
+ linkDirection
142
+ isArray
95
143
  }
96
144
  }
97
- `,de=`
145
+ `,ne=`
146
+ id
147
+ objectTypeId
148
+ key
149
+ label
150
+ dataType
151
+ isRequired
152
+ isFilterable
153
+ isSearchable
154
+ isIdentifier
155
+ sortOrder
156
+ description
157
+ placeholder
158
+ displayFormat
159
+ semanticType
160
+ isHidden
161
+ isComputed
162
+ isSystemField
163
+ defaultValue
164
+ allowedValues
165
+ minLength
166
+ maxLength
167
+ minValue
168
+ maxValue
169
+ pattern
170
+ isUnique
171
+ itemType
172
+ linkDatasetId
173
+ linkFieldKey
174
+ linkAlias
175
+ linkDirection
176
+ parentFieldId
177
+ createdAt
178
+ updatedAt
179
+ `,we=`
98
180
  pricing {
99
181
  productId
100
182
  prices {
@@ -106,11 +188,11 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
106
188
  directLowPrice
107
189
  }
108
190
  }
109
- `;function p(e={}){return `
191
+ `;function k(e={}){return `
110
192
  id
111
193
  datasetId
112
194
  data
113
- ${e.includePricing?de:""}
195
+ ${e.includePricing?we:""}
114
196
  createdAt
115
197
  updatedAt
116
198
  dataset {
@@ -120,7 +202,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
120
202
  gameId
121
203
  publisherId
122
204
  }
123
- `}var z=p(),P=`
205
+ `}var A=k(),O=`
124
206
  key
125
207
  label
126
208
  description
@@ -132,7 +214,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
132
214
  excludedFromDeckSize
133
215
  legalCardTypes
134
216
  metadata
135
- `,A=`
217
+ `,K=`
136
218
  id
137
219
  datasetId
138
220
  recordId
@@ -143,9 +225,9 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
143
225
  annotations
144
226
  display
145
227
  record {
146
- ${z}
228
+ ${A}
147
229
  }
148
- `,Z=`
230
+ `,ce=`
149
231
  rulesetId
150
232
  rulesetVersionId
151
233
  rulesetVersionLabel
@@ -153,7 +235,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
153
235
  cardDatasetVersionId
154
236
  validatedAt
155
237
  validationResultSummary
156
- `,v=`
238
+ `,x=`
157
239
  code
158
240
  severity
159
241
  message
@@ -162,14 +244,14 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
162
244
  datasetId
163
245
  identifier
164
246
  metadata
165
- `,U=`
247
+ `,G=`
166
248
  deckId
167
249
  valid
168
250
  blockers {
169
- ${v}
251
+ ${x}
170
252
  }
171
253
  warnings {
172
- ${v}
254
+ ${x}
173
255
  }
174
256
  affectedEntries {
175
257
  entryId
@@ -180,17 +262,17 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
180
262
  quantity
181
263
  }
182
264
  validatedAgainst {
183
- ${Z}
265
+ ${ce}
184
266
  }
185
267
  checkedAt
186
- `,M=`
268
+ `,W=`
187
269
  deckId
188
270
  fromVersionId
189
271
  toVersionId
190
272
  toDraftRevision
191
273
  hasChanges
192
274
  diff
193
- `,b=`
275
+ `,R=`
194
276
  id
195
277
  deckId
196
278
  versionNumber
@@ -212,18 +294,18 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
212
294
  validatedAt
213
295
  validationSummary
214
296
  validatedAgainst {
215
- ${Z}
297
+ ${ce}
216
298
  }
217
299
  sectionDefinitions {
218
- ${P}
300
+ ${O}
219
301
  }
220
302
  publishedByAccountId
221
303
  publishedByApiApplicationId
222
304
  createdAt
223
305
  entries {
224
- ${A}
306
+ ${K}
225
307
  }
226
- `,G=`
308
+ `,Q=`
227
309
  id
228
310
  deckId
229
311
  accountId
@@ -231,7 +313,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
231
313
  createdByAccountId
232
314
  createdAt
233
315
  updatedAt
234
- `,j=`
316
+ `,z=`
235
317
  id
236
318
  deckId
237
319
  label
@@ -240,7 +322,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
240
322
  lastUsedAt
241
323
  createdAt
242
324
  updatedAt
243
- `,Y=`
325
+ `,Z=`
244
326
  id
245
327
  deckId
246
328
  apiApplicationId
@@ -253,7 +335,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
253
335
  lastUsedAt
254
336
  createdAt
255
337
  updatedAt
256
- `,E=`
338
+ `,T=`
257
339
  id
258
340
  deckId
259
341
  apiApplicationId
@@ -267,7 +349,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
267
349
  revokedAt
268
350
  createdAt
269
351
  updatedAt
270
- `,he=`
352
+ `,Ae=`
271
353
  id
272
354
  deckId
273
355
  apiApplicationId
@@ -279,7 +361,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
279
361
  lastUsedAt
280
362
  createdAt
281
363
  updatedAt
282
- `,F=`
364
+ `,M=`
283
365
  lineNumber
284
366
  raw
285
367
  datasetKey
@@ -291,14 +373,14 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
291
373
  sortOrder
292
374
  display
293
375
  record {
294
- ${z}
376
+ ${A}
295
377
  }
296
- `,ee=`
378
+ `,oe=`
297
379
  lineNumber
298
380
  raw
299
381
  code
300
382
  message
301
- `,L=`
383
+ `,N=`
302
384
  lineNumber
303
385
  raw
304
386
  datasetKey
@@ -307,7 +389,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
307
389
  section
308
390
  code
309
391
  message
310
- `,B=`
392
+ `,j=`
311
393
  lineNumber
312
394
  raw
313
395
  datasetKey
@@ -319,7 +401,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
319
401
  identifier
320
402
  display
321
403
  }
322
- `,f=`
404
+ `,I=`
323
405
  id
324
406
  gameId
325
407
  key
@@ -333,39 +415,39 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
333
415
  isArchived
334
416
  createdAt
335
417
  updatedAt
336
- `,te=`
418
+ `,ue=`
337
419
  formatId
338
420
  key
339
421
  name
340
422
  confidence
341
423
  reason
342
- `,ye=`
424
+ `,Ee=`
343
425
  detection {
344
- ${te}
426
+ ${ue}
345
427
  }
346
428
  entries {
347
- ${F}
429
+ ${M}
348
430
  }
349
431
  parseErrors {
350
- ${ee}
432
+ ${oe}
351
433
  }
352
434
  unmatched {
353
- ${L}
435
+ ${N}
354
436
  }
355
437
  ambiguous {
356
- ${B}
438
+ ${j}
357
439
  }
358
- `,fe=`
440
+ `,Se=`
359
441
  entries {
360
- ${F}
442
+ ${M}
361
443
  }
362
444
  unmatched {
363
- ${L}
445
+ ${N}
364
446
  }
365
447
  ambiguous {
366
- ${B}
448
+ ${j}
367
449
  }
368
- `,ke=`
450
+ `,xe=`
369
451
  deckId
370
452
  format
371
453
  text
@@ -400,10 +482,10 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
400
482
  sourceUrl
401
483
  metadata
402
484
  sectionDefinitions {
403
- ${P}
485
+ ${O}
404
486
  }
405
487
  latestPublishedVersion {
406
- ${b}
488
+ ${R}
407
489
  }
408
490
  publishedAt
409
491
  draftRevision
@@ -414,28 +496,28 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
414
496
  createdAt
415
497
  updatedAt
416
498
  game {
417
- ${m}
499
+ ${f}
418
500
  }
419
501
  entries {
420
- ${A}
502
+ ${K}
421
503
  }
422
- `,H=`
504
+ `,ee=`
423
505
  deck {
424
506
  ${u}
425
507
  }
426
508
  retainedAppAccess
427
- `,pe=`
509
+ `,Re=`
428
510
  deck {
429
511
  ${u}
430
512
  }
431
513
  copiedFromDeckId
432
514
  retainedAppAccess
433
- `,ge=`
515
+ `,qe=`
434
516
  id
435
517
  name
436
518
  description
437
519
  revokedAt
438
- `,R=`
520
+ `,U=`
439
521
  id
440
522
  deckId
441
523
  deck {
@@ -443,7 +525,7 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
443
525
  }
444
526
  apiApplicationId
445
527
  apiApplication {
446
- ${ge}
528
+ ${qe}
447
529
  }
448
530
  role
449
531
  grantSource
@@ -453,37 +535,37 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
453
535
  revokedAt
454
536
  createdAt
455
537
  updatedAt
456
- `,me=`
538
+ `,Ce=`
457
539
  deck {
458
540
  ${u}
459
541
  }
460
542
  version {
461
- ${b}
543
+ ${R}
462
544
  }
463
545
  validation {
464
- ${U}
546
+ ${G}
465
547
  }
466
548
  blockers {
467
- ${v}
549
+ ${x}
468
550
  }
469
551
  warnings {
470
- ${v}
552
+ ${x}
471
553
  }
472
- `,S=`
554
+ `,F=`
473
555
  deck {
474
556
  ${u}
475
557
  }
476
558
  entry {
477
- ${A}
559
+ ${K}
478
560
  }
479
- `,re=`
561
+ `,de=`
480
562
  deck {
481
563
  ${u}
482
564
  }
483
565
  entries {
484
- ${A}
566
+ ${K}
485
567
  }
486
- `,De=re,$e=`
568
+ `,Ke=de,Te=`
487
569
  deck {
488
570
  ${u}
489
571
  }
@@ -492,27 +574,27 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
492
574
  replace
493
575
  format
494
576
  importFormat {
495
- ${f}
577
+ ${I}
496
578
  }
497
579
  detection {
498
- ${te}
580
+ ${ue}
499
581
  }
500
582
  entries {
501
- ${F}
583
+ ${M}
502
584
  }
503
585
  parseErrors {
504
- ${ee}
586
+ ${oe}
505
587
  }
506
588
  unmatched {
507
- ${L}
589
+ ${N}
508
590
  }
509
591
  ambiguous {
510
- ${B}
592
+ ${j}
511
593
  }
512
594
  validation {
513
- ${U}
595
+ ${G}
514
596
  }
515
- `,Ie=`
597
+ `,te=`
516
598
  resolvedLinks {
517
599
  field
518
600
  linkFieldKey
@@ -523,7 +605,290 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
523
605
  data
524
606
  }
525
607
  }
526
- `;function y(e){return `
608
+ `,le=`
609
+ datasetKey
610
+ index
611
+ errors {
612
+ field
613
+ message
614
+ details
615
+ }
616
+ `,Ue=`
617
+ total
618
+ inserted
619
+ updated
620
+ skipped
621
+ failed
622
+ `,he=`
623
+ inserted {
624
+ ${A}
625
+ }
626
+ updated {
627
+ ${A}
628
+ }
629
+ skipped
630
+ errors {
631
+ ${le}
632
+ }
633
+ createdFields {
634
+ ${ne}
635
+ }
636
+ stats {
637
+ ${Ue}
638
+ }
639
+ `,ye=`
640
+ fileId
641
+ filename
642
+ file {
643
+ ${S}
644
+ }
645
+ `,$=`
646
+ id
647
+ publisherId
648
+ publisher {
649
+ ${g}
650
+ }
651
+ datasetId
652
+ dataset {
653
+ ${p}
654
+ ${D}
655
+ }
656
+ accountId
657
+ status
658
+ mode
659
+ onConflict
660
+ format
661
+ fileId
662
+ progress
663
+ totalRecords
664
+ processedRecords
665
+ insertedCount
666
+ updatedCount
667
+ skippedCount
668
+ failedCount
669
+ createdFields {
670
+ ${ne}
671
+ }
672
+ errors {
673
+ ${le}
674
+ }
675
+ errorMessage
676
+ assets {
677
+ ${ye}
678
+ }
679
+ startedAt
680
+ completedAt
681
+ createdAt
682
+ updatedAt
683
+ lastCheckpointIndex
684
+ isResumed
685
+ imagesPending
686
+ imagesCompleted
687
+ imagesFailed
688
+ `,Fe=`
689
+ id
690
+ importJobId
691
+ level
692
+ message
693
+ datasetKey
694
+ recordIndex
695
+ fieldKey
696
+ details
697
+ createdAt
698
+ `,Pe=`
699
+ job {
700
+ ${$}
701
+ }
702
+ dryRunResult {
703
+ ${he}
704
+ }
705
+ `,Le=`
706
+ target
707
+ recordId
708
+ identifier
709
+ status
710
+ message
711
+ `,P=`
712
+ id
713
+ publisherId
714
+ publisher {
715
+ ${g}
716
+ }
717
+ datasetId
718
+ dataset {
719
+ ${p}
720
+ }
721
+ accountId
722
+ status
723
+ targetType
724
+ dryRun
725
+ targets
726
+ progress
727
+ totalTargets
728
+ processedTargets
729
+ matchedCount
730
+ deletedCount
731
+ missingCount
732
+ blockedCount
733
+ failedCount
734
+ results {
735
+ ${Le}
736
+ }
737
+ errorMessage
738
+ startedAt
739
+ completedAt
740
+ createdAt
741
+ updatedAt
742
+ `,fe=`
743
+ sourceField
744
+ targetField
745
+ targetFieldLabel
746
+ inferredType
747
+ inferredItemType
748
+ inferredChildren {
749
+ key
750
+ label
751
+ type
752
+ required
753
+ itemType
754
+ children {
755
+ key
756
+ label
757
+ type
758
+ required
759
+ itemType
760
+ }
761
+ }
762
+ inferredLinkDataset
763
+ inferredLinkFieldKey
764
+ inferredLinkDirection
765
+ targetFieldType
766
+ sampleValues
767
+ status
768
+ `,L=`
769
+ datasetKey
770
+ field
771
+ message
772
+ severity
773
+ `,Be=`
774
+ datasetKey
775
+ datasetName
776
+ datasetId
777
+ exists
778
+ recordCount
779
+ fieldMappings {
780
+ ${fe}
781
+ }
782
+ warnings {
783
+ ${L}
784
+ }
785
+ canProceed
786
+ sampleRecords
787
+ availableDatasets {
788
+ ${p}
789
+ ${D}
790
+ }
791
+ `,_e=`
792
+ datasets {
793
+ datasetKey
794
+ datasetName
795
+ datasetId
796
+ exists
797
+ recordCount
798
+ fieldMappings {
799
+ ${fe}
800
+ }
801
+ warnings {
802
+ ${L}
803
+ }
804
+ sampleRecords
805
+ }
806
+ importOrder
807
+ warnings {
808
+ ${L}
809
+ }
810
+ canProceed
811
+ `,Ve=`
812
+ datasetKey
813
+ datasetId
814
+ datasetName
815
+ status
816
+ recordCount
817
+ insertedCount
818
+ updatedCount
819
+ skippedCount
820
+ failedCount
821
+ errorMessage
822
+ `,v=`
823
+ id
824
+ publisherId
825
+ publisher {
826
+ ${g}
827
+ }
828
+ gameId
829
+ game {
830
+ ${f}
831
+ }
832
+ accountId
833
+ status
834
+ mode
835
+ onConflict
836
+ fileId
837
+ assets {
838
+ ${ye}
839
+ }
840
+ totalDatasets
841
+ completedDatasets
842
+ progress
843
+ importOrder
844
+ datasetStatuses {
845
+ ${Ve}
846
+ }
847
+ errorMessage
848
+ startedAt
849
+ completedAt
850
+ createdAt
851
+ updatedAt
852
+ completedDatasetKeys
853
+ currentDatasetKey
854
+ lastCheckpointIndex
855
+ isResumed
856
+ imagesPending
857
+ imagesCompleted
858
+ imagesFailed
859
+ phase
860
+ linkBuildingDataset
861
+ linkBuildingTotalDatasets
862
+ linkBuildingCompletedDatasets
863
+ linkBuildingProcessedRecords
864
+ linkBuildingTotalRecords
865
+ `,w=`
866
+ id
867
+ publisherId
868
+ publisher {
869
+ ${g}
870
+ }
871
+ datasetId
872
+ dataset {
873
+ ${p}
874
+ }
875
+ accountId
876
+ status
877
+ format
878
+ filter
879
+ totalRecords
880
+ processedRecords
881
+ progress
882
+ fileId
883
+ downloadUrl
884
+ downloadExpiresAt
885
+ errorMessage
886
+ startedAt
887
+ completedAt
888
+ createdAt
889
+ updatedAt
890
+ lastCheckpointIndex
891
+ `;function l(e){return `
527
892
  totalCount
528
893
  pageInfo {
529
894
  hasNextPage
@@ -537,133 +902,358 @@ var h=class X extends Error{response;constructor(t,r){super(t),this.name="CardDB
537
902
  ${e}
538
903
  }
539
904
  }
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:`
905
+ `}var a={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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
541
906
  query SearchPublishers${i} {
542
- searchPublishers${c} {
543
- ${y($)}
907
+ searchPublishers${n} {
908
+ ${l(g)}
544
909
  }
545
910
  }
546
911
  `,variables:t}},fetchPublisherById(){return {query:`
547
912
  query FetchPublisher($id: UUID!) {
548
913
  fetchPublisher(id: $id) {
549
- ${$}
914
+ ${g}
550
915
  }
551
916
  }
552
917
  `}},fetchPublisherBySlug(){return {query:`
553
918
  query FetchPublisher($slug: String!) {
554
919
  fetchPublisher(slug: $slug) {
555
- ${$}
920
+ ${g}
556
921
  }
557
922
  }
558
923
  `}},fetchPublishers(){return {query:`
559
924
  query FetchPublishers($slugs: [String!]!) {
560
925
  fetchPublishers(slugs: $slugs) {
561
- ${$}
926
+ ${g}
562
927
  }
563
928
  }
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:`
929
+ `}},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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
565
930
  query SearchGames${i} {
566
- searchGames${c} {
567
- ${y(m)}
931
+ searchGames${n} {
932
+ ${l(f)}
568
933
  }
569
934
  }
570
935
  `,variables:t}},fetchGameById(){return {query:`
571
936
  query FetchGame($id: UUID!) {
572
937
  fetchGame(id: $id) {
573
- ${m}
938
+ ${f}
574
939
  }
575
940
  }
576
941
  `}},fetchGameByKeys(){return {query:`
577
942
  query FetchGame($publisherSlug: String!, $gameKey: String!) {
578
943
  fetchGame(publisherSlug: $publisherSlug, gameKey: $gameKey) {
579
- ${m}
944
+ ${f}
580
945
  }
581
946
  }
582
947
  `}},fetchGames(){return {query:`
583
948
  query FetchGames($ids: [UUID!]!) {
584
949
  fetchGames(ids: $ids) {
585
- ${m}
950
+ ${f}
951
+ }
952
+ }
953
+ `}},listGames(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return 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),{query:`
954
+ query Games(${s.join(", ")}) {
955
+ games(${r.join(", ")}) {
956
+ ${l(f)}
957
+ }
958
+ }
959
+ `,variables:t}},game(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),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.gameSlug!==void 0&&(s.push("$gameSlug: String"),r.push("gameSlug: $gameSlug"),t.gameSlug=e.gameSlug),{query:`
960
+ query Game(${s.join(", ")}) {
961
+ game(${r.join(", ")}) {
962
+ ${f}
963
+ }
964
+ }
965
+ `,variables:t}},createGame(){return {query:`
966
+ mutation GameCreate($input: GameCreateInput!) {
967
+ gameCreate(input: $input) {
968
+ ${f}
969
+ }
970
+ }
971
+ `}},updateGame(){return {query:`
972
+ mutation GameUpdate($id: UUID!, $input: GameUpdateInput!) {
973
+ gameUpdate(id: $id, input: $input) {
974
+ ${f}
586
975
  }
587
976
  }
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:`
977
+ `}},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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
589
978
  query SearchDatasets${i} {
590
- searchDatasets${c} {
591
- ${y(I)}
979
+ searchDatasets${n} {
980
+ ${l(p)}
592
981
  }
593
982
  }
594
983
  `,variables:t}},fetchDatasetById(){return {query:`
595
984
  query FetchDataset($id: UUID!) {
596
985
  fetchDataset(id: $id) {
597
- ${I}
598
- ${O}
986
+ ${p}
987
+ ${D}
599
988
  }
600
989
  }
601
990
  `}},fetchDatasetByKeys(){return {query:`
602
991
  query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
603
992
  fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
604
- ${I}
605
- ${O}
993
+ ${p}
994
+ ${D}
606
995
  }
607
996
  }
608
997
  `}},fetchDatasets(){return {query:`
609
998
  query FetchDatasets($ids: [UUID!]!) {
610
999
  fetchDatasets(ids: $ids) {
611
- ${I}
1000
+ ${p}
1001
+ }
1002
+ }
1003
+ `}},listDatasets(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),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),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),{query:`
1004
+ query Datasets(${s.join(", ")}) {
1005
+ datasets(${r.join(", ")}) {
1006
+ ${l(`${p}
1007
+ ${D}`)}
1008
+ }
1009
+ }
1010
+ `,variables:t}},dataset(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),{query:`
1011
+ query Dataset(${s.join(", ")}) {
1012
+ dataset(${r.join(", ")}) {
1013
+ ${p}
1014
+ ${D}
612
1015
  }
613
1016
  }
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:`
1017
+ `,variables:t}},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,n=k({includePricing:e.includePricing}),c=i?`${n}
1018
+ ${te}`:n;return {query:`
616
1019
  query SearchRecords(${s.join(", ")}) {
617
1020
  searchRecords(${r.join(", ")}) {
618
- ${y(a)}
1021
+ ${l(c)}
619
1022
  }
620
1023
  }
621
1024
  `,variables:t}},fetchRecordById(e={}){return {query:`
622
1025
  query FetchRecord($id: UUID!) {
623
1026
  fetchRecord(id: $id) {
624
- ${p(e)}
1027
+ ${k(e)}
625
1028
  }
626
1029
  }
627
1030
  `}},fetchRecordByIdentifier(e={}){return {query:`
628
1031
  query FetchRecordByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifier: String!) {
629
1032
  fetchRecordByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifier: $identifier) {
630
- ${p(e)}
1033
+ ${k(e)}
631
1034
  }
632
1035
  }
633
1036
  `}},fetchRecordsByIdentifier(e={}){return {query:`
634
1037
  query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
635
1038
  fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
636
- ${p(e)}
1039
+ ${k(e)}
637
1040
  }
638
1041
  }
639
1042
  `}},fetchRecords(e={}){return {query:`
640
1043
  query FetchRecords($ids: [UUID!]!) {
641
1044
  fetchRecords(ids: $ids) {
642
- ${p(e)}
1045
+ ${k(e)}
1046
+ }
1047
+ }
1048
+ `}},listDatasetRecords(e){let t={datasetId:e.datasetId},r=["datasetId: $datasetId"],s=["$datasetId: UUID!"];return e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.orderBy!==void 0&&(s.push("$orderBy: DatasetRecordOrderByInput"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),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.last!==void 0&&(s.push("$last: Int"),r.push("last: $last"),t.last=e.last),e.before!==void 0&&(s.push("$before: String"),r.push("before: $before"),t.before=e.before),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema),{query:`
1049
+ query DatasetRecords(${s.join(", ")}) {
1050
+ datasetRecords(${r.join(", ")}) {
1051
+ ${l(A)}
1052
+ }
1053
+ }
1054
+ `,variables:t}},datasetRecord(e){let t={},r=[],s=[];e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.identifier!==void 0&&(s.push("$identifier: String"),r.push("identifier: $identifier"),t.identifier=e.identifier),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.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.recordId!==void 0&&(s.push("$recordId: UUID"),r.push("recordId: $recordId"),t.recordId=e.recordId),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,n=k({includePricing:e.includePricing}),c=i?`${n}
1055
+ ${te}`:n;return {query:`
1056
+ query DatasetRecord(${s.join(", ")}) {
1057
+ datasetRecord(${r.join(", ")}) {
1058
+ ${c}
1059
+ }
1060
+ }
1061
+ `,variables:t}},upsertDatasetRecords(){return {query:`
1062
+ mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
1063
+ datasetRecordsUpsert(input: $input) {
1064
+ ${Pe}
1065
+ }
1066
+ }
1067
+ `}},deleteDatasetRecords(){return {query:`
1068
+ mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
1069
+ datasetRecordsDelete(input: $input) {
1070
+ ${P}
1071
+ }
1072
+ }
1073
+ `}},datasetRecordDeleteJob(){return {query:`
1074
+ query DatasetRecordDeleteJob($id: UUID!) {
1075
+ datasetRecordDeleteJob(id: $id) {
1076
+ ${P}
1077
+ }
1078
+ }
1079
+ `}},datasetRecordDeleteJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: DatasetRecordDeleteJobStatus"),r.push("status: $status"),t.status=e.status),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:`
1080
+ query DatasetRecordDeleteJobs(${s.join(", ")}) {
1081
+ datasetRecordDeleteJobs(${r.join(", ")}) {
1082
+ ${l(P)}
1083
+ }
1084
+ }
1085
+ `,variables:t}},datasetImportPreview(){return {query:`
1086
+ query DatasetImportPreview($input: DatasetImportPreviewInput!) {
1087
+ datasetImportPreview(input: $input) {
1088
+ ${Be}
1089
+ }
1090
+ }
1091
+ `}},datasetImportValidate(){return {query:`
1092
+ query DatasetImportValidate($input: DatasetImportValidateInput!) {
1093
+ datasetImportValidate(input: $input) {
1094
+ ${he}
1095
+ }
1096
+ }
1097
+ `}},datasetImportFromFile(){return {query:`
1098
+ mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
1099
+ datasetImportFromFile(input: $input) {
1100
+ ${$}
1101
+ }
1102
+ }
1103
+ `}},datasetImportFromPayload(){return {query:`
1104
+ mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
1105
+ datasetImportFromPayload(input: $input) {
1106
+ ${$}
1107
+ }
1108
+ }
1109
+ `}},datasetImportFromUrl(){return {query:`
1110
+ mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
1111
+ datasetImportFromUrl(input: $input) {
1112
+ ${$}
1113
+ }
1114
+ }
1115
+ `}},importJob(){return {query:`
1116
+ query ImportJob($id: UUID!) {
1117
+ importJob(id: $id) {
1118
+ ${$}
1119
+ }
1120
+ }
1121
+ `}},importJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),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:`
1122
+ query ImportJobs(${s.join(", ")}) {
1123
+ importJobs(${r.join(", ")}) {
1124
+ ${l($)}
1125
+ }
1126
+ }
1127
+ `,variables:t}},importJobCancel(){return {query:`
1128
+ mutation ImportJobCancel($id: UUID!) {
1129
+ importJobCancel(id: $id) {
1130
+ ${$}
1131
+ }
1132
+ }
1133
+ `}},importJobLogs(e){let t={importJobId:e.importJobId},r=["id: $importJobId"],s=[],i=["$importJobId: UUID!"];e.level!==void 0&&(i.push("$level: ImportLogLevel"),s.push("level: $level"),t.level=e.level),e.datasetKey!==void 0&&(i.push("$datasetKey: String"),s.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.first!==void 0&&(i.push("$first: Int"),s.push("first: $first"),t.first=e.first),e.after!==void 0&&(i.push("$after: String"),s.push("after: $after"),t.after=e.after);let n=s.length>0?`(${s.join(", ")})`:"";return {query:`
1134
+ query ImportJobLogs(${i.join(", ")}) {
1135
+ importJob(${r.join(", ")}) {
1136
+ logs${n} {
1137
+ ${l(Fe)}
1138
+ }
1139
+ }
1140
+ }
1141
+ `,variables:t}},gameImportPreview(){return {query:`
1142
+ query GameImportPreview($input: GameImportPreviewInput!) {
1143
+ gameImportPreview(input: $input) {
1144
+ ${_e}
1145
+ }
1146
+ }
1147
+ `}},gameImportFromFile(){return {query:`
1148
+ mutation GameImportFromFile($input: GameImportFromFileInput!) {
1149
+ gameImportFromFile(input: $input) {
1150
+ ${v}
1151
+ }
1152
+ }
1153
+ `}},gameImportFromPayload(){return {query:`
1154
+ mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
1155
+ gameImportFromPayload(input: $input) {
1156
+ ${v}
643
1157
  }
644
1158
  }
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:`
1159
+ `}},gameImportFromUrl(){return {query:`
1160
+ mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
1161
+ gameImportFromUrl(input: $input) {
1162
+ ${v}
1163
+ }
1164
+ }
1165
+ `}},gameImportJob(){return {query:`
1166
+ query GameImportJob($id: UUID!) {
1167
+ gameImportJob(id: $id) {
1168
+ ${v}
1169
+ }
1170
+ }
1171
+ `}},gameImportJobs(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),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:`
1172
+ query GameImportJobs(${s.join(", ")}) {
1173
+ gameImportJobs(${r.join(", ")}) {
1174
+ ${l(v)}
1175
+ }
1176
+ }
1177
+ `,variables:t}},gameImportJobCancel(){return {query:`
1178
+ mutation GameImportJobCancel($id: UUID!) {
1179
+ gameImportJobCancel(id: $id) {
1180
+ ${v}
1181
+ }
1182
+ }
1183
+ `}},file(){return {query:`
1184
+ query File($id: UUID!) {
1185
+ file(id: $id) {
1186
+ ${S}
1187
+ }
1188
+ }
1189
+ `}},fileUploadRequest(){return {query:`
1190
+ mutation FileUploadRequest($input: FileUploadInput!) {
1191
+ fileUploadRequest(input: $input) {
1192
+ ${ve}
1193
+ }
1194
+ }
1195
+ `}},fileUploadConfirm(){return {query:`
1196
+ mutation FileUploadConfirm($id: UUID!) {
1197
+ fileUploadConfirm(id: $id) {
1198
+ ${S}
1199
+ }
1200
+ }
1201
+ `}},fileDelete(){return {query:`
1202
+ mutation FileDelete($id: UUID!) {
1203
+ fileDelete(id: $id)
1204
+ }
1205
+ `}},exportJob(){return {query:`
1206
+ query ExportJob($id: UUID!) {
1207
+ exportJob(id: $id) {
1208
+ ${w}
1209
+ }
1210
+ }
1211
+ `}},exportJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ExportJobStatus"),r.push("status: $status"),t.status=e.status),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:`
1212
+ query ExportJobs(${s.join(", ")}) {
1213
+ exportJobs(${r.join(", ")}) {
1214
+ ${l(w)}
1215
+ }
1216
+ }
1217
+ `,variables:t}},datasetExport(){return {query:`
1218
+ mutation DatasetExport($input: DatasetExportInput!) {
1219
+ datasetExport(input: $input) {
1220
+ ${w}
1221
+ }
1222
+ }
1223
+ `}},exportJobCancel(){return {query:`
1224
+ mutation ExportJobCancel($id: UUID!) {
1225
+ exportJobCancel(id: $id) {
1226
+ ${w}
1227
+ }
1228
+ }
1229
+ `}},exportJobRefreshUrl(){return {query:`
1230
+ mutation ExportJobRefreshUrl($id: UUID!) {
1231
+ exportJobRefreshUrl(id: $id) {
1232
+ ${w}
1233
+ }
1234
+ }
1235
+ `}},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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
646
1236
  query MyDecks${i} {
647
- myDecks${c} {
648
- ${y(u)}
1237
+ myDecks${n} {
1238
+ ${l(u)}
649
1239
  }
650
1240
  }
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:`
1241
+ `,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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
652
1242
  query ViewerDecks${i} {
653
- viewerDecks${c} {
654
- ${y(u)}
1243
+ viewerDecks${n} {
1244
+ ${l(u)}
655
1245
  }
656
1246
  }
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:`
1247
+ `,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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
658
1248
  query AppDecks${i} {
659
- appDecks${c} {
660
- ${y(u)}
1249
+ appDecks${n} {
1250
+ ${l(u)}
661
1251
  }
662
1252
  }
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:`
1253
+ `,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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
664
1254
  query PublicDecks${i} {
665
- publicDecks${c} {
666
- ${y(u)}
1255
+ publicDecks${n} {
1256
+ ${l(u)}
667
1257
  }
668
1258
  }
669
1259
  `,variables:t}},fetchDeckById(){return {query:`
@@ -711,13 +1301,13 @@ ${Ie}`:c;return {query:`
711
1301
  `}},deckVersion(){return {query:`
712
1302
  query DeckVersion($id: UUID!) {
713
1303
  deckVersion(id: $id) {
714
- ${b}
1304
+ ${R}
715
1305
  }
716
1306
  }
717
1307
  `}},deckVersions(e={}){let t={},r=["deckId: $deckId"],s=["$deckId: UUID!"];return 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:`
718
1308
  query DeckVersions(${s.join(", ")}) {
719
1309
  deckVersions(${r.join(", ")}) {
720
- ${y(b)}
1310
+ ${l(R)}
721
1311
  }
722
1312
  }
723
1313
  `,variables:t}},deckPreview(){return {query:`
@@ -741,91 +1331,91 @@ ${Ie}`:c;return {query:`
741
1331
  `}},deckDraftDiff(){return {query:`
742
1332
  query DeckDraftDiff($id: UUID!) {
743
1333
  deckDraftDiff(id: $id) {
744
- ${M}
1334
+ ${W}
745
1335
  }
746
1336
  }
747
1337
  `}},deckVersionDiff(){return {query:`
748
1338
  query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
749
1339
  deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
750
- ${M}
1340
+ ${W}
751
1341
  }
752
1342
  }
753
1343
  `}},deckHydrateEntries(){return {query:`
754
1344
  query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
755
1345
  deckHydrateEntries(input: $input) {
756
- ${fe}
1346
+ ${Se}
757
1347
  }
758
1348
  }
759
1349
  `}},deckExport(){return {query:`
760
1350
  query DeckExport($id: UUID!, $format: DeckExportFormat!) {
761
1351
  deckExport(id: $id, format: $format) {
762
- ${ke}
1352
+ ${xe}
763
1353
  }
764
1354
  }
765
1355
  `}},deckValidate(){return {query:`
766
1356
  query DeckValidate($id: UUID!, $input: DeckValidateInput) {
767
1357
  deckValidate(id: $id, input: $input) {
768
- ${U}
1358
+ ${G}
769
1359
  }
770
1360
  }
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:`
1361
+ `}},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(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
772
1362
  query DeckSectionDefinitions${i} {
773
- deckSectionDefinitions${c} {
774
- ${P}
1363
+ deckSectionDefinitions${n} {
1364
+ ${O}
775
1365
  }
776
1366
  }
777
1367
  `,variables:t}},deckCollaborators(){return {query:`
778
1368
  query DeckCollaborators($deckId: UUID!) {
779
1369
  deckCollaborators(deckId: $deckId) {
780
- ${G}
1370
+ ${Q}
781
1371
  }
782
1372
  }
783
1373
  `}},deckEmbedTokens(){return {query:`
784
1374
  query DeckEmbedTokens($deckId: UUID!) {
785
1375
  deckEmbedTokens(deckId: $deckId) {
786
- ${Y}
1376
+ ${Z}
787
1377
  }
788
1378
  }
789
1379
  `}},deckAccessTokenIssuers(){return {query:`
790
1380
  query DeckAccessTokenIssuers($deckId: UUID!) {
791
1381
  deckAccessTokenIssuers(deckId: $deckId) {
792
- ${E}
1382
+ ${T}
793
1383
  }
794
1384
  }
795
1385
  `}},deckApiApplicationAccesses(){return {query:`
796
1386
  query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
797
1387
  deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
798
- ${R}
1388
+ ${U}
799
1389
  }
800
1390
  }
801
1391
  `}},myDeckApiApplicationAccesses(){return {query:`
802
1392
  query MyDeckApiApplicationAccesses($applicationId: UUID) {
803
1393
  myDeckApiApplicationAccesses(applicationId: $applicationId) {
804
- ${R}
1394
+ ${U}
805
1395
  }
806
1396
  }
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)}
1397
+ `}},deckImportFormats(e){let t={},r=[],s=[];e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),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);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1398
+ query DeckImportFormats${i} {
1399
+ deckImportFormats${n} {
1400
+ ${l(I)}
811
1401
  }
812
1402
  }
813
1403
  `,variables:t}},deckImportFormat(){return {query:`
814
- query DeckImportFormat($id: UUID!) {
815
- deckImportFormat(id: $id) {
816
- ${f}
1404
+ query DeckImportFormat($id: UUID, $gameId: UUID, $key: String) {
1405
+ deckImportFormat(id: $id, gameId: $gameId, key: $key) {
1406
+ ${I}
817
1407
  }
818
1408
  }
819
1409
  `}},deckImportFormatTest(){return {query:`
820
1410
  query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
821
1411
  deckImportFormatTest(input: $input) {
822
- ${ye}
1412
+ ${Ee}
823
1413
  }
824
1414
  }
825
1415
  `}},deckPreviewTokens(){return {query:`
826
1416
  query DeckPreviewTokens($deckId: UUID!) {
827
1417
  deckPreviewTokens(deckId: $deckId) {
828
- ${j}
1418
+ ${z}
829
1419
  }
830
1420
  }
831
1421
  `}},createDeck(){return {query:`
@@ -865,61 +1455,61 @@ ${Ie}`:c;return {query:`
865
1455
  `}},addDeckEntry(){return {query:`
866
1456
  mutation DeckEntryAdd($input: DeckEntryAddInput!) {
867
1457
  deckEntryAdd(input: $input) {
868
- ${S}
1458
+ ${F}
869
1459
  }
870
1460
  }
871
1461
  `}},updateDeckEntry(){return {query:`
872
1462
  mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
873
1463
  deckEntryUpdate(id: $id, input: $input) {
874
- ${S}
1464
+ ${F}
875
1465
  }
876
1466
  }
877
1467
  `}},removeDeckEntry(){return {query:`
878
1468
  mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
879
1469
  deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
880
- ${S}
1470
+ ${F}
881
1471
  }
882
1472
  }
883
1473
  `}},reorderDeckEntries(){return {query:`
884
1474
  mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
885
1475
  deckEntryReorder(deckId: $deckId, input: $input) {
886
- ${re}
1476
+ ${de}
887
1477
  }
888
1478
  }
889
1479
  `}},replaceDeckEntries(){return {query:`
890
1480
  mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
891
1481
  deckEntriesReplace(deckId: $deckId, input: $input) {
892
- ${De}
1482
+ ${Ke}
893
1483
  }
894
1484
  }
895
1485
  `}},importDeck(){return {query:`
896
1486
  mutation DeckImport($input: DeckImportInput!) {
897
1487
  deckImport(input: $input) {
898
- ${$e}
1488
+ ${Te}
899
1489
  }
900
1490
  }
901
1491
  `}},createDeckImportFormat(){return {query:`
902
1492
  mutation DeckImportFormatCreate($input: DeckImportFormatCreateInput!) {
903
1493
  deckImportFormatCreate(input: $input) {
904
- ${f}
1494
+ ${I}
905
1495
  }
906
1496
  }
907
1497
  `}},updateDeckImportFormat(){return {query:`
908
1498
  mutation DeckImportFormatUpdate($id: UUID!, $input: DeckImportFormatUpdateInput!) {
909
1499
  deckImportFormatUpdate(id: $id, input: $input) {
910
- ${f}
1500
+ ${I}
911
1501
  }
912
1502
  }
913
1503
  `}},archiveDeckImportFormat(){return {query:`
914
1504
  mutation DeckImportFormatArchive($id: UUID!) {
915
1505
  deckImportFormatArchive(id: $id) {
916
- ${f}
1506
+ ${I}
917
1507
  }
918
1508
  }
919
1509
  `}},unarchiveDeckImportFormat(){return {query:`
920
1510
  mutation DeckImportFormatUnarchive($id: UUID!) {
921
1511
  deckImportFormatUnarchive(id: $id) {
922
- ${f}
1512
+ ${I}
923
1513
  }
924
1514
  }
925
1515
  `}},upsertDeckByExternalRef(){return {query:`
@@ -935,25 +1525,25 @@ ${Ie}`:c;return {query:`
935
1525
  `}},claimDeck(){return {query:`
936
1526
  mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
937
1527
  deckClaim(id: $id, input: $input) {
938
- ${H}
1528
+ ${ee}
939
1529
  }
940
1530
  }
941
1531
  `}},transferDeckOwnership(){return {query:`
942
1532
  mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
943
1533
  deckTransferOwnership(id: $id, input: $input) {
944
- ${H}
1534
+ ${ee}
945
1535
  }
946
1536
  }
947
1537
  `}},copyDeck(){return {query:`
948
1538
  mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
949
1539
  deckCopy(id: $id, input: $input) {
950
- ${pe}
1540
+ ${Re}
951
1541
  }
952
1542
  }
953
1543
  `}},publishDeck(){return {query:`
954
1544
  mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
955
1545
  deckPublish(id: $id, input: $input) {
956
- ${me}
1546
+ ${Ce}
957
1547
  }
958
1548
  }
959
1549
  `}},removeInvalidDeckEntries(){return {query:`
@@ -965,7 +1555,7 @@ ${Ie}`:c;return {query:`
965
1555
  `}},upsertDeckCollaborator(){return {query:`
966
1556
  mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
967
1557
  deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
968
- ${G}
1558
+ ${Q}
969
1559
  }
970
1560
  }
971
1561
  `}},removeDeckCollaborator(){return {query:`
@@ -977,7 +1567,7 @@ ${Ie}`:c;return {query:`
977
1567
  deckPreviewTokenCreate(input: $input) {
978
1568
  token
979
1569
  previewToken {
980
- ${j}
1570
+ ${z}
981
1571
  }
982
1572
  }
983
1573
  }
@@ -990,7 +1580,7 @@ ${Ie}`:c;return {query:`
990
1580
  deckEmbedTokenCreate(input: $input) {
991
1581
  token
992
1582
  embedToken {
993
- ${Y}
1583
+ ${Z}
994
1584
  }
995
1585
  }
996
1586
  }
@@ -1001,7 +1591,7 @@ ${Ie}`:c;return {query:`
1001
1591
  `}},createDeckAccessTokenIssuer(){return {query:`
1002
1592
  mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
1003
1593
  deckAccessTokenIssuerCreate(input: $input) {
1004
- ${E}
1594
+ ${T}
1005
1595
  }
1006
1596
  }
1007
1597
  `}},revokeDeckAccessTokenIssuer(){return {query:`
@@ -1011,7 +1601,7 @@ ${Ie}`:c;return {query:`
1011
1601
  `}},revokeDeckAccessTokenIssuerSigningKey(){return {query:`
1012
1602
  mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
1013
1603
  deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
1014
- ${E}
1604
+ ${T}
1015
1605
  }
1016
1606
  }
1017
1607
  `}},exchangeDeckAccessToken(){return {query:`
@@ -1019,14 +1609,14 @@ ${Ie}`:c;return {query:`
1019
1609
  deckAccessTokenExchange(input: $input) {
1020
1610
  token
1021
1611
  accessToken {
1022
- ${he}
1612
+ ${Ae}
1023
1613
  }
1024
1614
  }
1025
1615
  }
1026
1616
  `}},grantDeckApiApplicationAccess(){return {query:`
1027
1617
  mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
1028
1618
  deckApiApplicationAccessGrant(input: $input) {
1029
- ${R}
1619
+ ${U}
1030
1620
  }
1031
1621
  }
1032
1622
  `}},revokeDeckApiApplicationAccess(){return {query:`
@@ -1037,7 +1627,7 @@ ${Ie}`:c;return {query:`
1037
1627
  mutation DeckAccessTokenRevoke($id: UUID!) {
1038
1628
  deckAccessTokenRevoke(id: $id)
1039
1629
  }
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:`
1630
+ `}},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}},gameCreateVariables(e){return {input:e}},gameUpdateVariables(e,t){return {id:e,input:t}},datasetImportPreviewVariables(e){return {input:e}},datasetImportValidateVariables(e){return {input:e}},datasetImportFromFileVariables(e){return {input:e}},datasetImportFromPayloadVariables(e){return {input:e}},datasetImportFromUrlVariables(e){return {input:e}},gameImportPreviewVariables(e){return {input:e}},gameImportFromFileVariables(e){return {input:e}},gameImportFromPayloadVariables(e){return {input:e}},gameImportFromUrlVariables(e){return {input:e}},datasetRecordsUpsertVariables(e){return {input:e}},datasetRecordsDeleteVariables(e){return {input:e}},fileUploadRequestVariables(e){return {input:e}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
1041
1631
  query FetchMe {
1042
1632
  fetchMe {
1043
1633
  application {
@@ -1059,6 +1649,6 @@ ${Ie}`:c;return {query:`
1059
1649
  }
1060
1650
  }
1061
1651
  }
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
1652
+ `}}},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 Je="https://carddb.xtda.org/query",Oe=3e4,Ge=1e4,Me=300,Ne=3,je=2,Ye=1e3,He=3e4,Xe=class pe{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??Je,this.timeout=t.timeout??Oe,this.openTimeout=t.openTimeout??Ge,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??Ne,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??je,this.retryBaseDelay=t.retryBaseDelay??Ye,this.retryMaxDelay=t.retryMaxDelay??He,this.cache=t.cache,this.cacheTtl=t.cacheTtl??Me,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 b(`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 b(`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 b(`${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 pe({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})}},me="0.1.0";function We(){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?Qe(navigator.userAgent):{name:"unknown",version:"unknown"}}function Qe(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 ze(){let e=We();return `CardDB-SDK/js/${me} (${e.name}/${e.version})`}function Mt(){return me}var ge=null;function Ze(){return ge}var et=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 c=await this.fetch(e,t),o=Date.now()-n,h=await this.handleResponse(c);return this.logResponse(r,o),h}catch(n){if(n instanceof q&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let c=n.retryAfter??60;this.logRateLimitRetry(r,s,c),await this.sleep(c*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}if(n instanceof J&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof E||e instanceof V}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":ze(),...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(n){throw n instanceof Error?n.name==="AbortError"?(this.logError("Request timed out"),new V("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new E(`Connection failed: ${n.message}`)):new E("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new B("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 J(`Server error (${e.status})`,{status:e.status,response:t})}throw new y(`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 B(s,t);case "RATE_LIMITED":throw new q(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new _(s,{errors:e,response:t});default:throw new se(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,c=await this.parseBody(e);throw new q("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:c})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new _(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;ge={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 tt(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 rt(e,t){let r=e.get(t);return r}async function st(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var m=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 c=await rt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await st(n,e,o,h);}return o}cacheKey(e,t,r){return tt(e,t,r)}},it=class extends m{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=a.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 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}=a.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=a.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}=a.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)}},at=class extends m{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),i=this.cacheKey("games","list",s),n=await this.withCache(i,"games",t,async()=>(await this.connection.execute(r,s)).games);return new d(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("games","getByKey",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameKey:e.gameKey});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async getBySlug(e){let t=this.cacheKey("games","getBySlug",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameSlug:e.gameSlug});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=a.createGame();return (await this.connection.execute(t,a.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=a.updateGame();return (await this.connection.execute(r,a.gameUpdateVariables(e,t))).gameUpdate}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=a.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 d(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,n=r??{};this.validateAccess(s,i);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(c,"games",n,async()=>{let{query:o}=a.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:c}=a.fetchGameById();return (await this.connection.execute(c,{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}=a.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},nt=class extends m{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),i=this.cacheKey("datasets","list",s),n=await this.withCache(i,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new d(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("datasets","getByKey",{publisherId:e.publisherId,gameId:e.gameId,datasetKey:e.datasetKey});return this.withCache(t,"datasets",e,async()=>{let{query:r,variables:s}=a.dataset(e);return (await this.connection.execute(r,s)).dataset??null})}async getSchema(e){return (typeof e=="string"?await this.withCache(this.cacheKey("datasets","getSchema",{id:e}),"datasets",{},async()=>{let{query:r,variables:s}=a.dataset({id:e});return (await this.connection.execute(r,s)).dataset??null}):await this.getByKey(e))?.schema??null}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}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(c,{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,c=s??{};this.validateAccess(i,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=a.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:i,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let i=e,n=t??{},c=this.cacheKey("datasets","get",{id:i});return this.withCache(c,"datasets",n,async()=>{let{query:o}=a.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}=a.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},ct=class extends m{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}=a.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}=a.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}=a.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}=a.fetchDeckBySlug();return (await this.connection.execute(n,{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:n}=a.deckBySlug();return (await this.connection.execute(n,{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}=a.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}=a.deckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).deckByExternalRef??null})}async listMine(e={}){let{query:t,variables:r}=a.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 n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=a.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 n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=a.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 n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=a.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 n=>this.listPublic({...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}=a.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=a.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},n=this.cacheKey("decks","listVersions",i),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new d(c,{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}=a.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}=a.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}=a.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}=a.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=a.deckVersionDiffVariables(e,t),i=this.cacheKey("decks","versionDiff",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=a.deckValidateVariables(e,t),i=this.cacheKey("decks","validate",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=a.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckHydrateEntries();return (await this.connection.execute(i,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=a.deckExportVariables(e,t),i=this.cacheKey("decks","exportDeck",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=a.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}=a.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}=a.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}=a.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}=a.deckAccessTokenIssuers();return (await this.connection.execute(s,{deckId:e})).deckAccessTokenIssuers})}async listApiApplicationAccesses(e,t={}){let r=a.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckApiApplicationAccesses();return (await this.connection.execute(i,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=a.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=a.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=a.createDeck(),r=a.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=a.updateDeck(),s=a.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}=a.upsertDeckByExternalRef(),r=a.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=a.claimDeck(),s=a.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=a.transferDeckOwnership(),s=a.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=a.copyDeck(),s=a.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=a.addDeckEntry(),r=a.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=a.updateDeckEntry(),s=a.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=a.removeDeckEntry(),s=a.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=a.reorderDeckEntries(),s=a.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=a.replaceDeckEntries(),s=a.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=a.importDeck(),r=a.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=a.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(i,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new d(n,{nextPageLoader:async c=>this.listImportFormats(e,{...t,after:c})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=a.deckImportFormatTest(),r=a.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=a.createDeckImportFormat(),r=a.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=a.updateDeckImportFormat(),s=a.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=a.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=a.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=a.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=a.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=a.publishDeck(),s=a.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=a.removeInvalidDeckEntries(),s=a.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=a.upsertDeckCollaborator(),i=a.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=a.removeDeckCollaborator(),s=a.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createPreviewToken(e){let{query:t}=a.createDeckPreviewToken(),r=a.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=a.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async createEmbedToken(e){let{query:t}=a.createDeckEmbedToken(),r=a.deckEmbedTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckEmbedTokenCreate}async revokeEmbedToken(e){let{query:t}=a.revokeDeckEmbedToken();return !!(await this.connection.execute(t,{id:e})).deckEmbedTokenRevoke}async createAccessTokenIssuer(e){let{query:t}=a.createDeckAccessTokenIssuer(),r=a.deckAccessTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenIssuerCreate}async revokeAccessTokenIssuer(e){let{query:t}=a.revokeDeckAccessTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenIssuerRevoke}async revokeAccessTokenIssuerSigningKey(e){let{query:t}=a.revokeDeckAccessTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckAccessTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=a.grantDeckApiApplicationAccess(),r=a.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=a.revokeDeckApiApplicationAccess(),s=a.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeAccessToken(e){this.config.requireSecretCredential("decks.exchangeAccessToken");let{query:t}=a.exchangeDeckAccessToken(),r=a.deckAccessTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenExchange}async revokeAccessToken(e){this.config.requireSecretCredential("decks.revokeAccessToken");let{query:t}=a.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}),n=await this.withCache(i,"decks",e,async()=>{let{query:o}=a.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=ot(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function ot(e,t,r){let s=new Set(t),i=new Map;for(let n of e){let c=r?n.data[r]:Object.values(n.data).find(h=>s.has(String(h)));if(c==null)continue;let o=String(c);s.has(o)&&(i.set(o,n),s.delete(o));}return i}var ut=class extends m{constructor(e,t){super(e,t);}async list(e){let t=C(e.filter),{query:r,variables:s}=a.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),i=this.cacheKey("records","list",s),n=await this.withCache(i,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new d(n,{nextPageLoader:async c=>this.list({...e,after:c})})}async getByDatasetIdentifier(e){let t=this.cacheKey("records","getByDatasetIdentifier",{datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(t,"records",e,async()=>{let{query:r,variables:s}=a.datasetRecord({datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing});return (await this.connection.execute(r,s)).datasetRecord??null})}async upsertBatch(e){this.config.requireSecretCredential("records.upsertBatch");let{query:t}=a.upsertDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=a.deleteDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsDeleteVariables(e))).datasetRecordsDelete}async getDeleteJob(e,t={}){let r=this.cacheKey("records","getDeleteJob",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=a.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=a.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(i,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new d(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getDeleteJob(e,{cache:false});if(!n)throw new Error(`Delete job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for delete job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=C(e.filter),{query:i,variables:n}=a.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}),c=this.cacheKey("records","search",{...n,includePricing:e.includePricing??false}),o=await this.withCache(c,"records",e,async()=>(await this.connection.execute(i,n)).searchRecords);return new d(o,{nextPageLoader:async h=>this.search({...e,after:h})})}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}=a.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}=a.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}=a.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}=a.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},dt=class extends m{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}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(c,{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=C(t.filter),{query:c,variables:o}=a.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}),h=this.cacheKey("rules","records",o),H=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new d(H,{nextPageLoader:async X=>this.searchRuleRecords(e,{...t,after:X})})}},lt=class extends m{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=a.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),i=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new d(i,{nextPageLoader:async n=>this.list({...e,after:n})})}async get(e,t={}){let r=this.cacheKey("importFormats","get",{id:e});return this.withCache(r,"importFormats",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async getByKey(e){let t=this.cacheKey("importFormats","getByKey",{gameId:e.gameId,formatKey:e.key});return this.withCache(t,"importFormats",e,async()=>{let{query:r}=a.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=a.deckImportFormatTest();return (await this.connection.execute(t,a.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=a.createDeckImportFormat();return (await this.connection.execute(t,a.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=a.updateDeckImportFormat();return (await this.connection.execute(r,a.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},ht=class extends m{constructor(e,t){super(e,t);}async preview(e){let{query:t}=a.datasetImportPreview();return (await this.connection.execute(t,a.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=a.datasetImportValidate();return (await this.connection.execute(t,a.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=a.datasetImportFromFile();return (await this.connection.execute(s,a.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.datasetImportFromUrl();return (await this.connection.execute(s,a.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=a.datasetImportFromPayload();return (await this.connection.execute(t,a.datasetImportFromPayloadVariables(e))).datasetImportFromPayload}async getJob(e,t={}){let r=this.cacheKey("imports","getJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new d(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=a.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=a.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??yt());return new d(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=a.gameImportPreview();return (await this.connection.execute(t,a.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=a.gameImportFromFile();return (await this.connection.execute(s,a.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.gameImportFromUrl();return (await this.connection.execute(s,a.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=a.gameImportFromPayload();return (await this.connection.execute(t,a.gameImportFromPayloadVariables(e))).gameImportFromPayload}async getGameJob(e,t={}){let r=this.cacheKey("imports","getGameJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=a.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new d(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=a.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getGameJob(e,{cache:false});if(!n)throw new Error(`Game import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function yt(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var ft=class extends m{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=a.datasetExport();return (await this.connection.execute(t,a.datasetExportVariables(e))).datasetExport}async create(e){return this.run(e)}async getJob(e,t={}){let r=this.cacheKey("exports","getJob",{id:e});return this.withCache(r,"exports",t,async()=>{let{query:s}=a.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("exports","listJobs",s),n=await this.withCache(i,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new d(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=a.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=a.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Export job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},pt=class extends m{constructor(e,t){super(e,t);}async get(e,t={}){let r=this.cacheKey("files","get",{id:e});return this.withCache(r,"files",t,async()=>{let{query:s}=a.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=a.fileUploadRequest();return (await this.connection.execute(t,a.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=a.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=a.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}},ke=class Ie{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;constructor(t={}){this.config=new Xe(t),this.connection=new et(this.config),this.publishers=new it(this.connection,this.config),this.games=new at(this.connection,this.config),this.datasets=new nt(this.connection,this.config),this.records=new ut(this.connection,this.config),this.decks=new ct(this.connection,this.config),this.rules=new dt(this.connection,this.config),this.importFormats=new lt(this.connection,this.config),this.imports=new ht(this.connection,this.config),this.exports=new ft(this.connection,this.config),this.files=new pt(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return Ze()}withConfig(t){let r=this.config.merge(t);return new Ie({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 Y=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 n=this.storage.getItem(i);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(i);}}catch{r.push(i);}}for(let s of r)this.storage.removeItem(s);}};var $e=class extends ke{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new b("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new b("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1653
+ export{B as AuthenticationError,m as BaseResource,Y as BrowserCache,$e as CardDBClient,y as CardDBError,d as Collection,Xe as Configuration,et as Connection,E as ConnectionError,Me as DEFAULT_CACHE_TTL,Je as DEFAULT_ENDPOINT,je as DEFAULT_MAX_NETWORK_RETRIES,Ne as DEFAULT_MAX_RETRIES,Ge as DEFAULT_OPEN_TIMEOUT,Ye as DEFAULT_RETRY_BASE_DELAY,He as DEFAULT_RETRY_MAX_DELAY,Oe as DEFAULT_TIMEOUT,nt as DatasetsResource,ct as DecksResource,ft as ExportsResource,pt as FilesResource,be as FilterBuilder,at as GamesResource,se as GraphQLError,lt as ImportFormatsResource,ht as ImportsResource,gt as LinkResolutionError,mt as NotFoundError,it as PublishersResource,a as QueryBuilder,q as RateLimitError,ut as RecordsResource,b as RestrictedError,dt as RulesResource,J as ServerError,V as TimeoutError,_ as ValidationError,tt as cacheKey,Et as contains,kt as eq,Ze as getRateLimitInfo,Mt as getSDKVersion,ze as getUserAgent,$t as gt,bt as gte,xt as ilike,qt as isNotNull,Rt as isNull,St as like,vt as lt,Dt as lte,It as neq,At as notWithin,rt as readCache,C as resolveFilter,wt as within,st as writeCache};//# sourceMappingURL=index.js.map
1064
1654
  //# sourceMappingURL=index.js.map