@carddb/browser 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,ne);}},G=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},U=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;}},Gt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},F=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},v=class extends y{constructor(e,t){super(e,t),this.name="RestrictedError";}},ce=class extends y{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},x=class extends y{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},O=class extends x{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},N=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Ot=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 Nt(e){return {eq:e}}function jt(e){return {neq:e}}function Ht(e){return {gt:e}}function Yt(e){return {gte:e}}function zt(e){return {lt:e}}function Wt(e){return {lte:e}}function Xt(e){return {in:e}}function Qt(e){return {nin:e}}function Zt(e){return {contains:e}}function er(e){return {like:e}}function tr(e){return {ilike:e}}function rr(){return {is_null:true}}function sr(){return {is_null:false}}var Ee=class oe{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,a]of Object.entries(t))this.conditions.push({[s]:a});return this}any(t){let r=new oe;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[a,n]of Object.entries(r))s[a]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[a,n]of Object.entries(r))s[a]=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 P(e){if(e!==void 0){if(typeof e=="function"){let t=new Ee;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 Re=new Set(["metadata","annotations"]);function I(e){return ue(e,"input")}function ue(e,t){if(!M(e))return e;let r={};for(let[s,a]of Object.entries(e)){let n=`${t}.${s}`;Re.has(s)?r[s]=xe(a,n):s==="entries"&&Array.isArray(a)?r[s]=a.map((c,o)=>ue(c,`${n}[${o}]`)):r[s]=a;}return r}function xe(e,t){if(e==null||M(e))return e;if(typeof e=="string")try{let r=JSON.parse(e);if(M(r))return r}catch{}throw new F(`${t} must be a JSON object`)}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var E=`
1
+ var f=class oe extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,oe);}},H=class extends f{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},L=class extends f{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;}},Qt=class extends f{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},R=class extends f{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},w=class extends f{constructor(e,t){super(e,t),this.name="RestrictedError";}},ue=class extends f{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},T=class extends f{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},Y=class extends T{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},z=class extends f{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Zt=class extends f{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 er(e){return {eq:e}}function tr(e){return {neq:e}}function rr(e){return {gt:e}}function sr(e){return {gte:e}}function ir(e){return {lt:e}}function ar(e){return {lte:e}}function nr(e){return {in:e}}function cr(e){return {nin:e}}function or(e){return {contains:e}}function ur(e){return {like:e}}function lr(e){return {ilike:e}}function dr(){return {is_null:true}}function hr(){return {is_null:false}}var qe=class le{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 le;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 _(e){if(e!==void 0){if(typeof e=="function"){let t=new qe;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 Ce=new Set(["metadata","annotations"]);function b(e){return de(e,"input")}function de(e,t){if(!N(e))return e;let r={};for(let[s,i]of Object.entries(e)){let n=`${t}.${s}`;Ce.has(s)?r[s]=xe(i,n):s==="entries"&&Array.isArray(i)?r[s]=i.map((c,o)=>de(c,`${n}[${o}]`)):r[s]=i;}return r}function xe(e,t){if(e==null||N(e))return e;if(typeof e=="string")try{let r=JSON.parse(e);if(N(r))return r}catch{}throw new R(`${t} must be a JSON object`)}function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var x=`
2
2
  id
3
3
  createdAt
4
4
  updatedAt
@@ -11,13 +11,13 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
11
11
  entityType
12
12
  entityId
13
13
  url
14
- `,Z=`
14
+ `,te=`
15
15
  file {
16
- ${E}
16
+ ${x}
17
17
  }
18
18
  uploadUrl
19
19
  expiresAt
20
- `,g=`
20
+ `,I=`
21
21
  id
22
22
  name
23
23
  slug
@@ -88,7 +88,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
88
88
  key
89
89
  name
90
90
  }
91
- `,qe=4;function le(e){return `
91
+ `,Ue=4;function he(e){return `
92
92
  key
93
93
  label
94
94
  description
@@ -121,12 +121,12 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
121
121
  isUnique
122
122
  ${e>0?`
123
123
  nestedFields {
124
- ${le(e-1)}
124
+ ${he(e-1)}
125
125
  }`:""}
126
- `}var w=`
126
+ `}var A=`
127
127
  schema {
128
128
  fields {
129
- ${le(qe)}
129
+ ${he(Ue)}
130
130
  }
131
131
  filterableFields
132
132
  searchableFields
@@ -142,7 +142,22 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
142
142
  isArray
143
143
  }
144
144
  }
145
- `,de=`
145
+ `,Ke=`
146
+ field
147
+ edges {
148
+ cursor
149
+ node {
150
+ value
151
+ count
152
+ }
153
+ }
154
+ pageInfo {
155
+ hasNextPage
156
+ hasPreviousPage
157
+ startCursor
158
+ endCursor
159
+ }
160
+ `,ye=`
146
161
  id
147
162
  objectTypeId
148
163
  key
@@ -176,7 +191,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
176
191
  parentFieldId
177
192
  createdAt
178
193
  updatedAt
179
- `,Ce=`
194
+ `,Te=`
180
195
  pricing {
181
196
  productId
182
197
  prices {
@@ -188,11 +203,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
188
203
  directLowPrice
189
204
  }
190
205
  }
191
- `;function b(e={}){return `
206
+ `;function k(e={}){return `
192
207
  id
193
208
  datasetId
194
209
  data
195
- ${e.includePricing?Ce:""}
210
+ ${e.includePricing?Te:""}
196
211
  createdAt
197
212
  updatedAt
198
213
  dataset {
@@ -202,7 +217,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
202
217
  gameId
203
218
  publisherId
204
219
  }
205
- `}var R=b(),j=`
220
+ `}var U=k(),E=`
206
221
  key
207
222
  label
208
223
  description
@@ -214,7 +229,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
214
229
  excludedFromDeckSize
215
230
  legalCardTypes
216
231
  metadata
217
- `,L=`
232
+ `,B=`
218
233
  id
219
234
  datasetId
220
235
  recordId
@@ -225,9 +240,9 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
225
240
  annotations
226
241
  display
227
242
  record {
228
- ${R}
243
+ ${U}
229
244
  }
230
- `,he=`
245
+ `,fe=`
231
246
  rulesetId
232
247
  rulesetVersionId
233
248
  rulesetVersionLabel
@@ -235,7 +250,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
235
250
  cardDatasetVersionId
236
251
  validatedAt
237
252
  validationResultSummary
238
- `,T=`
253
+ `,K=`
239
254
  code
240
255
  severity
241
256
  message
@@ -244,14 +259,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
244
259
  datasetId
245
260
  identifier
246
261
  metadata
247
- `,H=`
262
+ `,W=`
248
263
  deckId
249
264
  valid
250
265
  blockers {
251
- ${T}
266
+ ${K}
252
267
  }
253
268
  warnings {
254
- ${T}
269
+ ${K}
255
270
  }
256
271
  affectedEntries {
257
272
  entryId
@@ -262,17 +277,108 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
262
277
  quantity
263
278
  }
264
279
  validatedAgainst {
265
- ${he}
280
+ ${fe}
266
281
  }
267
282
  checkedAt
268
- `,ee=`
283
+ `,g=`
284
+ id
285
+ rulesetId
286
+ versionLabel
287
+ status
288
+ rules
289
+ sectionDefinitions {
290
+ ${E}
291
+ }
292
+ cardDatasetId
293
+ cardDatasetVersionId
294
+ sourceDatasetId
295
+ sourceDatasetVersionId
296
+ sourceDatasetRecordId
297
+ sourceRecordIdentifier
298
+ rulesFingerprint
299
+ effectiveAt
300
+ changelog
301
+ createdByAccountId
302
+ publishedByAccountId
303
+ publishedAt
304
+ supersededAt
305
+ createdAt
306
+ updatedAt
307
+ `,q=`
308
+ id
309
+ gameId
310
+ game {
311
+ id
312
+ key
313
+ name
314
+ }
315
+ key
316
+ name
317
+ description
318
+ tags
319
+ sortOrder
320
+ currentVersionId
321
+ currentVersion {
322
+ ${g}
323
+ }
324
+ archivedAt
325
+ isArchived
326
+ createdAt
327
+ updatedAt
328
+ `,Fe=`
329
+ rulesetId
330
+ rulesetVersionId
331
+ rulesetKey
332
+ rulesetVersionLabel
333
+ rules
334
+ sections {
335
+ ${E}
336
+ }
337
+ `,Ve=`
338
+ deckId
339
+ title
340
+ slug
341
+ state
342
+ hasUnpublishedChanges
343
+ valid
344
+ blockerCount
345
+ warningCount
346
+ affectedEntryCount
347
+ issues {
348
+ ${K}
349
+ }
350
+ `,Pe=`
351
+ rulesetId
352
+ rulesetVersionId
353
+ checkedAt
354
+ affectedDeckCount
355
+ invalidDeckCount
356
+ blockerCount
357
+ warningCount
358
+ results {
359
+ ${Ve}
360
+ }
361
+ `,Le=`
362
+ sourceDatasetId
363
+ sourceDatasetVersionId
364
+ sourceDatasetRecordId
365
+ sourceRecordIdentifier
366
+ rules
367
+ sectionDefinitions {
368
+ ${E}
369
+ }
370
+ rulesFingerprint
371
+ summary
372
+ sectionCount
373
+ copyLimitCount
374
+ `,re=`
269
375
  deckId
270
376
  fromVersionId
271
377
  toVersionId
272
378
  toDraftRevision
273
379
  hasChanges
274
380
  diff
275
- `,K=`
381
+ `,P=`
276
382
  id
277
383
  deckId
278
384
  versionNumber
@@ -294,18 +400,18 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
294
400
  validatedAt
295
401
  validationSummary
296
402
  validatedAgainst {
297
- ${he}
403
+ ${fe}
298
404
  }
299
405
  sectionDefinitions {
300
- ${j}
406
+ ${E}
301
407
  }
302
408
  publishedByAccountId
303
409
  publishedByApiApplicationId
304
410
  createdAt
305
411
  entries {
306
- ${L}
412
+ ${B}
307
413
  }
308
- `,te=`
414
+ `,se=`
309
415
  id
310
416
  deckId
311
417
  accountId
@@ -313,7 +419,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
313
419
  createdByAccountId
314
420
  createdAt
315
421
  updatedAt
316
- `,re=`
422
+ `,ie=`
317
423
  id
318
424
  apiApplicationId
319
425
  label
@@ -327,7 +433,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
327
433
  revokedAt
328
434
  createdAt
329
435
  updatedAt
330
- `,Te=`
436
+ `,_e=`
331
437
  id
332
438
  apiApplicationId
333
439
  issuerId
@@ -341,7 +447,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
341
447
  lastUsedAt
342
448
  createdAt
343
449
  updatedAt
344
- `,Y=`
450
+ `,X=`
345
451
  lineNumber
346
452
  raw
347
453
  datasetKey
@@ -353,14 +459,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
353
459
  sortOrder
354
460
  display
355
461
  record {
356
- ${R}
462
+ ${U}
357
463
  }
358
- `,ye=`
464
+ `,pe=`
359
465
  lineNumber
360
466
  raw
361
467
  code
362
468
  message
363
- `,z=`
469
+ `,Q=`
364
470
  lineNumber
365
471
  raw
366
472
  datasetKey
@@ -369,7 +475,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
369
475
  section
370
476
  code
371
477
  message
372
- `,W=`
478
+ `,Z=`
373
479
  lineNumber
374
480
  raw
375
481
  datasetKey
@@ -381,7 +487,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
381
487
  identifier
382
488
  display
383
489
  }
384
- `,k=`
490
+ `,v=`
385
491
  id
386
492
  gameId
387
493
  key
@@ -395,39 +501,39 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
395
501
  isArchived
396
502
  createdAt
397
503
  updatedAt
398
- `,fe=`
504
+ `,me=`
399
505
  formatId
400
506
  key
401
507
  name
402
508
  confidence
403
509
  reason
404
- `,Ke=`
510
+ `,Be=`
405
511
  detection {
406
- ${fe}
512
+ ${me}
407
513
  }
408
514
  entries {
409
- ${Y}
515
+ ${X}
410
516
  }
411
517
  parseErrors {
412
- ${ye}
518
+ ${pe}
413
519
  }
414
520
  unmatched {
415
- ${z}
521
+ ${Q}
416
522
  }
417
523
  ambiguous {
418
- ${W}
524
+ ${Z}
419
525
  }
420
- `,Ue=`
526
+ `,Me=`
421
527
  entries {
422
- ${Y}
528
+ ${X}
423
529
  }
424
530
  unmatched {
425
- ${z}
531
+ ${Q}
426
532
  }
427
533
  ambiguous {
428
- ${W}
534
+ ${Z}
429
535
  }
430
- `,Fe=`
536
+ `,Je=`
431
537
  deckId
432
538
  format
433
539
  text
@@ -462,10 +568,10 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
462
568
  sourceUrl
463
569
  metadata
464
570
  sectionDefinitions {
465
- ${j}
571
+ ${E}
466
572
  }
467
573
  latestPublishedVersion {
468
- ${K}
574
+ ${P}
469
575
  }
470
576
  publishedAt
471
577
  draftRevision
@@ -479,25 +585,25 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
479
585
  ${p}
480
586
  }
481
587
  entries {
482
- ${L}
588
+ ${B}
483
589
  }
484
- `,se=`
590
+ `,ae=`
485
591
  deck {
486
592
  ${u}
487
593
  }
488
594
  retainedAppAccess
489
- `,Pe=`
595
+ `,Oe=`
490
596
  deck {
491
597
  ${u}
492
598
  }
493
599
  copiedFromDeckId
494
600
  retainedAppAccess
495
- `,Le=`
601
+ `,Ge=`
496
602
  id
497
603
  name
498
604
  description
499
605
  revokedAt
500
- `,V=`
606
+ `,J=`
501
607
  id
502
608
  deckId
503
609
  deck {
@@ -505,7 +611,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
505
611
  }
506
612
  apiApplicationId
507
613
  apiApplication {
508
- ${Le}
614
+ ${Ge}
509
615
  }
510
616
  role
511
617
  grantSource
@@ -515,37 +621,37 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
515
621
  revokedAt
516
622
  createdAt
517
623
  updatedAt
518
- `,Ve=`
624
+ `,Ne=`
519
625
  deck {
520
626
  ${u}
521
627
  }
522
628
  version {
523
- ${K}
629
+ ${P}
524
630
  }
525
631
  validation {
526
- ${H}
632
+ ${W}
527
633
  }
528
634
  blockers {
529
- ${T}
635
+ ${K}
530
636
  }
531
637
  warnings {
532
- ${T}
638
+ ${K}
533
639
  }
534
- `,B=`
640
+ `,O=`
535
641
  deck {
536
642
  ${u}
537
643
  }
538
644
  entry {
539
- ${L}
645
+ ${B}
540
646
  }
541
- `,pe=`
647
+ `,ge=`
542
648
  deck {
543
649
  ${u}
544
650
  }
545
651
  entries {
546
- ${L}
652
+ ${B}
547
653
  }
548
- `,Be=pe,_e=`
654
+ `,je=ge,He=`
549
655
  deck {
550
656
  ${u}
551
657
  }
@@ -554,27 +660,27 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
554
660
  replace
555
661
  format
556
662
  importFormat {
557
- ${k}
663
+ ${v}
558
664
  }
559
665
  detection {
560
- ${fe}
666
+ ${me}
561
667
  }
562
668
  entries {
563
- ${Y}
669
+ ${X}
564
670
  }
565
671
  parseErrors {
566
- ${ye}
672
+ ${pe}
567
673
  }
568
674
  unmatched {
569
- ${z}
675
+ ${Q}
570
676
  }
571
677
  ambiguous {
572
- ${W}
678
+ ${Z}
573
679
  }
574
680
  validation {
575
- ${H}
681
+ ${W}
576
682
  }
577
- `,ae=`
683
+ `,ne=`
578
684
  resolvedLinks {
579
685
  field
580
686
  linkFieldKey
@@ -585,7 +691,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
585
691
  data
586
692
  }
587
693
  }
588
- `,me=`
694
+ `,Ie=`
589
695
  datasetKey
590
696
  index
591
697
  errors {
@@ -593,45 +699,45 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
593
699
  message
594
700
  details
595
701
  }
596
- `,Me=`
702
+ `,Ye=`
597
703
  total
598
704
  inserted
599
705
  updated
600
706
  skipped
601
707
  failed
602
- `,ge=`
708
+ `,$e=`
603
709
  inserted {
604
- ${R}
710
+ ${U}
605
711
  }
606
712
  updated {
607
- ${R}
713
+ ${U}
608
714
  }
609
715
  skipped
610
716
  errors {
611
- ${me}
717
+ ${Ie}
612
718
  }
613
719
  createdFields {
614
- ${de}
720
+ ${ye}
615
721
  }
616
722
  stats {
617
- ${Me}
723
+ ${Ye}
618
724
  }
619
- `,Ie=`
725
+ `,be=`
620
726
  fileId
621
727
  filename
622
728
  file {
623
- ${E}
729
+ ${x}
624
730
  }
625
- `,$=`
731
+ `,D=`
626
732
  id
627
733
  publisherId
628
734
  publisher {
629
- ${g}
735
+ ${I}
630
736
  }
631
737
  datasetId
632
738
  dataset {
633
739
  ${m}
634
- ${w}
740
+ ${A}
635
741
  }
636
742
  accountId
637
743
  status
@@ -647,14 +753,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
647
753
  skippedCount
648
754
  failedCount
649
755
  createdFields {
650
- ${de}
756
+ ${ye}
651
757
  }
652
758
  errors {
653
- ${me}
759
+ ${Ie}
654
760
  }
655
761
  errorMessage
656
762
  assets {
657
- ${Ie}
763
+ ${be}
658
764
  }
659
765
  startedAt
660
766
  completedAt
@@ -665,7 +771,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
665
771
  imagesPending
666
772
  imagesCompleted
667
773
  imagesFailed
668
- `,Je=`
774
+ `,ze=`
669
775
  id
670
776
  importJobId
671
777
  level
@@ -675,24 +781,24 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
675
781
  fieldKey
676
782
  details
677
783
  createdAt
678
- `,Ge=`
784
+ `,We=`
679
785
  job {
680
- ${$}
786
+ ${D}
681
787
  }
682
788
  dryRunResult {
683
- ${ge}
789
+ ${$e}
684
790
  }
685
- `,Oe=`
791
+ `,Xe=`
686
792
  target
687
793
  recordId
688
794
  identifier
689
795
  status
690
796
  message
691
- `,_=`
797
+ `,G=`
692
798
  id
693
799
  publisherId
694
800
  publisher {
695
- ${g}
801
+ ${I}
696
802
  }
697
803
  datasetId
698
804
  dataset {
@@ -712,14 +818,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
712
818
  blockedCount
713
819
  failedCount
714
820
  results {
715
- ${Oe}
821
+ ${Xe}
716
822
  }
717
823
  errorMessage
718
824
  startedAt
719
825
  completedAt
720
826
  createdAt
721
827
  updatedAt
722
- `,be=`
828
+ `,ke=`
723
829
  sourceField
724
830
  targetField
725
831
  targetFieldLabel
@@ -745,30 +851,30 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
745
851
  targetFieldType
746
852
  sampleValues
747
853
  status
748
- `,J=`
854
+ `,j=`
749
855
  datasetKey
750
856
  field
751
857
  message
752
858
  severity
753
- `,Ne=`
859
+ `,Qe=`
754
860
  datasetKey
755
861
  datasetName
756
862
  datasetId
757
863
  exists
758
864
  recordCount
759
865
  fieldMappings {
760
- ${be}
866
+ ${ke}
761
867
  }
762
868
  warnings {
763
- ${J}
869
+ ${j}
764
870
  }
765
871
  canProceed
766
872
  sampleRecords
767
873
  availableDatasets {
768
874
  ${m}
769
- ${w}
875
+ ${A}
770
876
  }
771
- `,je=`
877
+ `,Ze=`
772
878
  datasets {
773
879
  datasetKey
774
880
  datasetName
@@ -776,19 +882,19 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
776
882
  exists
777
883
  recordCount
778
884
  fieldMappings {
779
- ${be}
885
+ ${ke}
780
886
  }
781
887
  warnings {
782
- ${J}
888
+ ${j}
783
889
  }
784
890
  sampleRecords
785
891
  }
786
892
  importOrder
787
893
  warnings {
788
- ${J}
894
+ ${j}
789
895
  }
790
896
  canProceed
791
- `,He=`
897
+ `,et=`
792
898
  datasetKey
793
899
  datasetId
794
900
  datasetName
@@ -799,11 +905,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
799
905
  skippedCount
800
906
  failedCount
801
907
  errorMessage
802
- `,D=`
908
+ `,S=`
803
909
  id
804
910
  publisherId
805
911
  publisher {
806
- ${g}
912
+ ${I}
807
913
  }
808
914
  gameId
809
915
  game {
@@ -815,14 +921,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
815
921
  onConflict
816
922
  fileId
817
923
  assets {
818
- ${Ie}
924
+ ${be}
819
925
  }
820
926
  totalDatasets
821
927
  completedDatasets
822
928
  progress
823
929
  importOrder
824
930
  datasetStatuses {
825
- ${He}
931
+ ${et}
826
932
  }
827
933
  errorMessage
828
934
  startedAt
@@ -842,11 +948,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
842
948
  linkBuildingCompletedDatasets
843
949
  linkBuildingProcessedRecords
844
950
  linkBuildingTotalRecords
845
- `,A=`
951
+ `,C=`
846
952
  id
847
953
  publisherId
848
954
  publisher {
849
- ${g}
955
+ ${I}
850
956
  }
851
957
  datasetId
852
958
  dataset {
@@ -868,13 +974,13 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
868
974
  createdAt
869
975
  updatedAt
870
976
  lastCheckpointIndex
871
- `,Ye=`
977
+ `,tt=`
872
978
  recordId
873
979
  rank
874
980
  score
875
981
  confidence
876
982
  reasons
877
- `,ze=`
983
+ `,rt=`
878
984
  configured
879
985
  url
880
986
  latestDeliveryId
@@ -885,7 +991,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
885
991
  deliveredAt
886
992
  lastStatusCode
887
993
  lastError
888
- `,We=`
994
+ `,st=`
889
995
  featureVersion
890
996
  candidateCount
891
997
  confidenceScore
@@ -898,7 +1004,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
898
1004
  details
899
1005
  }
900
1006
  timings
901
- `,ie=`
1007
+ `,ce=`
902
1008
  jobId
903
1009
  status
904
1010
  publisherSlug
@@ -914,14 +1020,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
914
1020
  confidence
915
1021
  }
916
1022
  candidates {
917
- ${Ye}
1023
+ ${tt}
918
1024
  }
919
1025
  extracted
920
1026
  metrics {
921
- ${We}
1027
+ ${st}
922
1028
  }
923
1029
  webhook {
924
- ${ze}
1030
+ ${rt}
925
1031
  }
926
1032
  error {
927
1033
  code
@@ -931,7 +1037,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
931
1037
  updatedAt
932
1038
  startedAt
933
1039
  completedAt
934
- `,Xe=`
1040
+ `,it=`
935
1041
  publisherSlug
936
1042
  gameKey
937
1043
  datasetKey
@@ -976,11 +1082,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
976
1082
  correctedFeedback
977
1083
  feedbackAccuracy
978
1084
  }
979
- `,q=`
1085
+ `,F=`
980
1086
  code
981
1087
  region
982
1088
  message
983
- `,Qe=`
1089
+ `,at=`
984
1090
  id
985
1091
  key
986
1092
  label
@@ -993,7 +1099,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
993
1099
  isRequired
994
1100
  weight
995
1101
  config
996
- `,C=`
1102
+ `,V=`
997
1103
  id
998
1104
  key
999
1105
  name
@@ -1009,11 +1115,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1009
1115
  notes
1010
1116
  config
1011
1117
  regions {
1012
- ${Qe}
1118
+ ${at}
1013
1119
  }
1014
1120
  createdAt
1015
1121
  updatedAt
1016
- `,Ze=`
1122
+ `,nt=`
1017
1123
  key
1018
1124
  label
1019
1125
  semanticType
@@ -1024,7 +1130,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1024
1130
  source
1025
1131
  status
1026
1132
  confidence
1027
- `,et=`
1133
+ `,ct=`
1028
1134
  id
1029
1135
  key
1030
1136
  name
@@ -1048,32 +1154,32 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1048
1154
  ${e}
1049
1155
  }
1050
1156
  }
1051
- `}var i={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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1052
- query SearchPublishers${a} {
1157
+ `}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:`
1158
+ query SearchPublishers${i} {
1053
1159
  searchPublishers${n} {
1054
- ${d(g)}
1160
+ ${d(I)}
1055
1161
  }
1056
1162
  }
1057
1163
  `,variables:t}},fetchPublisherById(){return {query:`
1058
1164
  query FetchPublisher($id: UUID!) {
1059
1165
  fetchPublisher(id: $id) {
1060
- ${g}
1166
+ ${I}
1061
1167
  }
1062
1168
  }
1063
1169
  `}},fetchPublisherBySlug(){return {query:`
1064
1170
  query FetchPublisher($slug: String!) {
1065
1171
  fetchPublisher(slug: $slug) {
1066
- ${g}
1172
+ ${I}
1067
1173
  }
1068
1174
  }
1069
1175
  `}},fetchPublishers(){return {query:`
1070
1176
  query FetchPublishers($slugs: [String!]!) {
1071
1177
  fetchPublishers(slugs: $slugs) {
1072
- ${g}
1178
+ ${I}
1073
1179
  }
1074
1180
  }
1075
- `}},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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1076
- query SearchGames${a} {
1181
+ `}},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:`
1182
+ query SearchGames${i} {
1077
1183
  searchGames${n} {
1078
1184
  ${d(p)}
1079
1185
  }
@@ -1120,8 +1226,8 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1120
1226
  ${p}
1121
1227
  }
1122
1228
  }
1123
- `}},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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1124
- query SearchDatasets${a} {
1229
+ `}},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:`
1230
+ query SearchDatasets${i} {
1125
1231
  searchDatasets${n} {
1126
1232
  ${d(m)}
1127
1233
  }
@@ -1130,14 +1236,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1130
1236
  query FetchDataset($id: UUID!) {
1131
1237
  fetchDataset(id: $id) {
1132
1238
  ${m}
1133
- ${w}
1239
+ ${A}
1134
1240
  }
1135
1241
  }
1136
1242
  `}},fetchDatasetByKeys(){return {query:`
1137
1243
  query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
1138
1244
  fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
1139
1245
  ${m}
1140
- ${w}
1246
+ ${A}
1141
1247
  }
1142
1248
  }
1143
1249
  `}},fetchDatasets(){return {query:`
@@ -1146,22 +1252,30 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1146
1252
  ${m}
1147
1253
  }
1148
1254
  }
1149
- `}},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:`
1255
+ `}},fetchDatasetFilterValues(e){if(e.fields.length===0)throw new R("fields must contain at least one field key");let t=e.id!==void 0,r=e.publisherSlug!==void 0&&e.gameKey!==void 0&&e.datasetKey!==void 0;if(!t&&!r)throw new R("provide either id or publisherSlug, gameKey, and datasetKey");let s=["$fields: [String!]!"],i=["fields: $fields"],n={fields:e.fields};e.search!==void 0&&(s.push("$search: String"),i.push("search: $search"),n.search=e.search),e.includeCounts!==void 0&&(s.push("$includeCounts: Boolean"),i.push("includeCounts: $includeCounts"),n.includeCounts=e.includeCounts),e.first!==void 0&&(s.push("$first: Int"),i.push("first: $first"),n.first=e.first),e.after!==void 0&&(s.push("$after: String"),i.push("after: $after"),n.after=e.after);let c=[];return t?(s.push("$id: UUID!"),c.push("id: $id"),n.id=e.id):(s.push("$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"),c.push("publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"),n.publisherSlug=e.publisherSlug,n.gameKey=e.gameKey,n.datasetKey=e.datasetKey),{query:`
1256
+ query FetchDatasetFilterValues(${s.join(", ")}) {
1257
+ fetchDataset(${c.join(", ")}) {
1258
+ filterValues(${i.join(", ")}) {
1259
+ ${Ke}
1260
+ }
1261
+ }
1262
+ }
1263
+ `,variables:n}},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:`
1150
1264
  query Datasets(${s.join(", ")}) {
1151
1265
  datasets(${r.join(", ")}) {
1152
1266
  ${d(`${m}
1153
- ${w}`)}
1267
+ ${A}`)}
1154
1268
  }
1155
1269
  }
1156
1270
  `,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:`
1157
1271
  query Dataset(${s.join(", ")}) {
1158
1272
  dataset(${r.join(", ")}) {
1159
1273
  ${m}
1160
- ${w}
1274
+ ${A}
1161
1275
  }
1162
1276
  }
1163
- `,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 a=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=a?`${n}
1164
- ${ae}`:n;return {query:`
1277
+ `,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}
1278
+ ${ne}`:n;return {query:`
1165
1279
  query SearchRecords(${s.join(", ")}) {
1166
1280
  searchRecords(${r.join(", ")}) {
1167
1281
  ${d(c)}
@@ -1170,35 +1284,35 @@ ${ae}`:n;return {query:`
1170
1284
  `,variables:t}},fetchRecordById(e={}){return {query:`
1171
1285
  query FetchRecord($id: UUID!) {
1172
1286
  fetchRecord(id: $id) {
1173
- ${b(e)}
1287
+ ${k(e)}
1174
1288
  }
1175
1289
  }
1176
1290
  `}},fetchRecordByIdentifier(e={}){return {query:`
1177
1291
  query FetchRecordByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifier: String!) {
1178
1292
  fetchRecordByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifier: $identifier) {
1179
- ${b(e)}
1293
+ ${k(e)}
1180
1294
  }
1181
1295
  }
1182
1296
  `}},fetchRecordsByIdentifier(e={}){return {query:`
1183
1297
  query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
1184
1298
  fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
1185
- ${b(e)}
1299
+ ${k(e)}
1186
1300
  }
1187
1301
  }
1188
1302
  `}},fetchRecords(e={}){return {query:`
1189
1303
  query FetchRecords($ids: [UUID!]!) {
1190
1304
  fetchRecords(ids: $ids) {
1191
- ${b(e)}
1305
+ ${k(e)}
1192
1306
  }
1193
1307
  }
1194
1308
  `}},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:`
1195
1309
  query DatasetRecords(${s.join(", ")}) {
1196
1310
  datasetRecords(${r.join(", ")}) {
1197
- ${d(R)}
1311
+ ${d(U)}
1198
1312
  }
1199
1313
  }
1200
- `,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 a=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=a?`${n}
1201
- ${ae}`:n;return {query:`
1314
+ `,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}
1315
+ ${ne}`:n;return {query:`
1202
1316
  query DatasetRecord(${s.join(", ")}) {
1203
1317
  datasetRecord(${r.join(", ")}) {
1204
1318
  ${c}
@@ -1207,141 +1321,141 @@ ${ae}`:n;return {query:`
1207
1321
  `,variables:t}},upsertDatasetRecords(){return {query:`
1208
1322
  mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
1209
1323
  datasetRecordsUpsert(input: $input) {
1210
- ${Ge}
1324
+ ${We}
1211
1325
  }
1212
1326
  }
1213
1327
  `}},deleteDatasetRecords(){return {query:`
1214
1328
  mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
1215
1329
  datasetRecordsDelete(input: $input) {
1216
- ${_}
1330
+ ${G}
1217
1331
  }
1218
1332
  }
1219
1333
  `}},datasetRecordDeleteJob(){return {query:`
1220
1334
  query DatasetRecordDeleteJob($id: UUID!) {
1221
1335
  datasetRecordDeleteJob(id: $id) {
1222
- ${_}
1336
+ ${G}
1223
1337
  }
1224
1338
  }
1225
1339
  `}},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:`
1226
1340
  query DatasetRecordDeleteJobs(${s.join(", ")}) {
1227
1341
  datasetRecordDeleteJobs(${r.join(", ")}) {
1228
- ${d(_)}
1342
+ ${d(G)}
1229
1343
  }
1230
1344
  }
1231
1345
  `,variables:t}},datasetImportPreview(){return {query:`
1232
1346
  query DatasetImportPreview($input: DatasetImportPreviewInput!) {
1233
1347
  datasetImportPreview(input: $input) {
1234
- ${Ne}
1348
+ ${Qe}
1235
1349
  }
1236
1350
  }
1237
1351
  `}},datasetImportValidate(){return {query:`
1238
1352
  query DatasetImportValidate($input: DatasetImportValidateInput!) {
1239
1353
  datasetImportValidate(input: $input) {
1240
- ${ge}
1354
+ ${$e}
1241
1355
  }
1242
1356
  }
1243
1357
  `}},datasetImportFromFile(){return {query:`
1244
1358
  mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
1245
1359
  datasetImportFromFile(input: $input) {
1246
- ${$}
1360
+ ${D}
1247
1361
  }
1248
1362
  }
1249
1363
  `}},datasetImportFromPayload(){return {query:`
1250
1364
  mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
1251
1365
  datasetImportFromPayload(input: $input) {
1252
- ${$}
1366
+ ${D}
1253
1367
  }
1254
1368
  }
1255
1369
  `}},datasetImportFromUrl(){return {query:`
1256
1370
  mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
1257
1371
  datasetImportFromUrl(input: $input) {
1258
- ${$}
1372
+ ${D}
1259
1373
  }
1260
1374
  }
1261
1375
  `}},importJob(){return {query:`
1262
1376
  query ImportJob($id: UUID!) {
1263
1377
  importJob(id: $id) {
1264
- ${$}
1378
+ ${D}
1265
1379
  }
1266
1380
  }
1267
1381
  `}},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:`
1268
1382
  query ImportJobs(${s.join(", ")}) {
1269
1383
  importJobs(${r.join(", ")}) {
1270
- ${d($)}
1384
+ ${d(D)}
1271
1385
  }
1272
1386
  }
1273
1387
  `,variables:t}},importJobCancel(){return {query:`
1274
1388
  mutation ImportJobCancel($id: UUID!) {
1275
1389
  importJobCancel(id: $id) {
1276
- ${$}
1390
+ ${D}
1277
1391
  }
1278
1392
  }
1279
- `}},importJobLogs(e){let t={importJobId:e.importJobId},r=["id: $importJobId"],s=[],a=["$importJobId: UUID!"];e.level!==void 0&&(a.push("$level: ImportLogLevel"),s.push("level: $level"),t.level=e.level),e.datasetKey!==void 0&&(a.push("$datasetKey: String"),s.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.first!==void 0&&(a.push("$first: Int"),s.push("first: $first"),t.first=e.first),e.after!==void 0&&(a.push("$after: String"),s.push("after: $after"),t.after=e.after);let n=s.length>0?`(${s.join(", ")})`:"";return {query:`
1280
- query ImportJobLogs(${a.join(", ")}) {
1393
+ `}},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:`
1394
+ query ImportJobLogs(${i.join(", ")}) {
1281
1395
  importJob(${r.join(", ")}) {
1282
1396
  logs${n} {
1283
- ${d(Je)}
1397
+ ${d(ze)}
1284
1398
  }
1285
1399
  }
1286
1400
  }
1287
1401
  `,variables:t}},gameImportPreview(){return {query:`
1288
1402
  query GameImportPreview($input: GameImportPreviewInput!) {
1289
1403
  gameImportPreview(input: $input) {
1290
- ${je}
1404
+ ${Ze}
1291
1405
  }
1292
1406
  }
1293
1407
  `}},gameImportFromFile(){return {query:`
1294
1408
  mutation GameImportFromFile($input: GameImportFromFileInput!) {
1295
1409
  gameImportFromFile(input: $input) {
1296
- ${D}
1410
+ ${S}
1297
1411
  }
1298
1412
  }
1299
1413
  `}},gameImportFromPayload(){return {query:`
1300
1414
  mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
1301
1415
  gameImportFromPayload(input: $input) {
1302
- ${D}
1416
+ ${S}
1303
1417
  }
1304
1418
  }
1305
1419
  `}},gameImportFromUrl(){return {query:`
1306
1420
  mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
1307
1421
  gameImportFromUrl(input: $input) {
1308
- ${D}
1422
+ ${S}
1309
1423
  }
1310
1424
  }
1311
1425
  `}},gameImportJob(){return {query:`
1312
1426
  query GameImportJob($id: UUID!) {
1313
1427
  gameImportJob(id: $id) {
1314
- ${D}
1428
+ ${S}
1315
1429
  }
1316
1430
  }
1317
1431
  `}},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:`
1318
1432
  query GameImportJobs(${s.join(", ")}) {
1319
1433
  gameImportJobs(${r.join(", ")}) {
1320
- ${d(D)}
1434
+ ${d(S)}
1321
1435
  }
1322
1436
  }
1323
1437
  `,variables:t}},gameImportJobCancel(){return {query:`
1324
1438
  mutation GameImportJobCancel($id: UUID!) {
1325
1439
  gameImportJobCancel(id: $id) {
1326
- ${D}
1440
+ ${S}
1327
1441
  }
1328
1442
  }
1329
1443
  `}},file(){return {query:`
1330
1444
  query File($id: UUID!) {
1331
1445
  file(id: $id) {
1332
- ${E}
1446
+ ${x}
1333
1447
  }
1334
1448
  }
1335
1449
  `}},fileUploadRequest(){return {query:`
1336
1450
  mutation FileUploadRequest($input: FileUploadInput!) {
1337
1451
  fileUploadRequest(input: $input) {
1338
- ${Z}
1452
+ ${te}
1339
1453
  }
1340
1454
  }
1341
1455
  `}},fileUploadConfirm(){return {query:`
1342
1456
  mutation FileUploadConfirm($id: UUID!) {
1343
1457
  fileUploadConfirm(id: $id) {
1344
- ${E}
1458
+ ${x}
1345
1459
  }
1346
1460
  }
1347
1461
  `}},fileDelete(){return {query:`
@@ -1351,20 +1465,20 @@ ${ae}`:n;return {query:`
1351
1465
  `}},createScanUploadSession(){return {query:`
1352
1466
  mutation CreateScanUploadSession($input: CreateScanUploadSessionInput!) {
1353
1467
  createScanUploadSession(input: $input) {
1354
- ${Z}
1468
+ ${te}
1355
1469
  }
1356
1470
  }
1357
1471
  `}},confirmScanUpload(){return {query:`
1358
1472
  mutation ConfirmScanUpload($input: ConfirmScanUploadInput!) {
1359
1473
  confirmScanUpload(input: $input) {
1360
- ${E}
1474
+ ${x}
1361
1475
  }
1362
1476
  }
1363
1477
  `}},createScanJob(){return {query:`
1364
1478
  mutation CreateScanJob($input: CreateScanJobInput!) {
1365
1479
  createScanJob(input: $input) {
1366
1480
  job {
1367
- ${ie}
1481
+ ${ce}
1368
1482
  }
1369
1483
  created
1370
1484
  }
@@ -1372,7 +1486,7 @@ ${ae}`:n;return {query:`
1372
1486
  `}},scanJob(){return {query:`
1373
1487
  query ScanJob($id: UUID!) {
1374
1488
  scanJob(id: $id) {
1375
- ${ie}
1489
+ ${ce}
1376
1490
  }
1377
1491
  }
1378
1492
  `}},submitScanFeedback(){return {query:`
@@ -1392,17 +1506,17 @@ ${ae}`:n;return {query:`
1392
1506
  `}},scanMetrics(){return {query:`
1393
1507
  query ScanMetrics($input: ScanMetricsInput!) {
1394
1508
  scanMetrics(input: $input) {
1395
- ${Xe}
1509
+ ${it}
1396
1510
  }
1397
1511
  }
1398
1512
  `}},resolveScanTemplate(){return {query:`
1399
1513
  query ResolveScanTemplate($input: ResolveScanTemplateInput!) {
1400
1514
  resolveScanTemplate(input: $input) {
1401
1515
  template {
1402
- ${C}
1516
+ ${V}
1403
1517
  }
1404
1518
  warnings {
1405
- ${q}
1519
+ ${F}
1406
1520
  }
1407
1521
  }
1408
1522
  }
@@ -1410,7 +1524,7 @@ ${ae}`:n;return {query:`
1410
1524
  query ScanTemplates($input: ScanTemplatesInput!) {
1411
1525
  scanTemplates(input: $input) {
1412
1526
  templates {
1413
- ${C}
1527
+ ${V}
1414
1528
  }
1415
1529
  }
1416
1530
  }
@@ -1418,10 +1532,10 @@ ${ae}`:n;return {query:`
1418
1532
  mutation CreateScanTemplate($input: SaveScanTemplateInput!) {
1419
1533
  createScanTemplate(input: $input) {
1420
1534
  template {
1421
- ${C}
1535
+ ${V}
1422
1536
  }
1423
1537
  warnings {
1424
- ${q}
1538
+ ${F}
1425
1539
  }
1426
1540
  }
1427
1541
  }
@@ -1429,10 +1543,10 @@ ${ae}`:n;return {query:`
1429
1543
  mutation UpdateScanTemplate($id: UUID!, $input: SaveScanTemplateInput!) {
1430
1544
  updateScanTemplate(id: $id, input: $input) {
1431
1545
  template {
1432
- ${C}
1546
+ ${V}
1433
1547
  }
1434
1548
  warnings {
1435
- ${q}
1549
+ ${F}
1436
1550
  }
1437
1551
  }
1438
1552
  }
@@ -1440,10 +1554,10 @@ ${ae}`:n;return {query:`
1440
1554
  mutation PreviewScanTemplate($input: PreviewScanTemplateInput!) {
1441
1555
  previewScanTemplate(input: $input) {
1442
1556
  warnings {
1443
- ${q}
1557
+ ${F}
1444
1558
  }
1445
1559
  regions {
1446
- ${Ze}
1560
+ ${nt}
1447
1561
  }
1448
1562
  message
1449
1563
  }
@@ -1451,59 +1565,153 @@ ${ae}`:n;return {query:`
1451
1565
  `}},gameScanRegions(){return {query:`
1452
1566
  query GameScanRegions($publisherSlug: String!, $gameKey: String!, $includeInactive: Boolean) {
1453
1567
  gameScanRegions(publisherSlug: $publisherSlug, gameKey: $gameKey, includeInactive: $includeInactive) {
1454
- ${et}
1568
+ ${ct}
1455
1569
  }
1456
1570
  }
1457
1571
  `}},exportJob(){return {query:`
1458
1572
  query ExportJob($id: UUID!) {
1459
1573
  exportJob(id: $id) {
1460
- ${A}
1574
+ ${C}
1461
1575
  }
1462
1576
  }
1463
1577
  `}},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:`
1464
1578
  query ExportJobs(${s.join(", ")}) {
1465
1579
  exportJobs(${r.join(", ")}) {
1466
- ${d(A)}
1580
+ ${d(C)}
1467
1581
  }
1468
1582
  }
1469
1583
  `,variables:t}},datasetExport(){return {query:`
1470
1584
  mutation DatasetExport($input: DatasetExportInput!) {
1471
1585
  datasetExport(input: $input) {
1472
- ${A}
1586
+ ${C}
1473
1587
  }
1474
1588
  }
1475
1589
  `}},exportJobCancel(){return {query:`
1476
1590
  mutation ExportJobCancel($id: UUID!) {
1477
1591
  exportJobCancel(id: $id) {
1478
- ${A}
1592
+ ${C}
1479
1593
  }
1480
1594
  }
1481
1595
  `}},exportJobRefreshUrl(){return {query:`
1482
1596
  mutation ExportJobRefreshUrl($id: UUID!) {
1483
1597
  exportJobRefreshUrl(id: $id) {
1484
- ${A}
1598
+ ${C}
1599
+ }
1600
+ }
1601
+ `}},rulesets(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:`
1602
+ query Rulesets(${s.join(", ")}) {
1603
+ rulesets(${r.join(", ")}) {
1604
+ ${d(q)}
1605
+ }
1606
+ }
1607
+ `,variables:t}},publicRulesets(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: 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:`
1608
+ query PublicRulesets(${s.join(", ")}) {
1609
+ publicRulesets(${r.join(", ")}) {
1610
+ ${d(q)}
1611
+ }
1612
+ }
1613
+ `,variables:t}},ruleset(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.key!==void 0&&(s.push("$key: String"),r.push("key: $key"),t.key=e.key),{query:`
1614
+ query Ruleset(${s.join(", ")}) {
1615
+ ruleset(${r.join(", ")}) {
1616
+ ${q}
1617
+ }
1618
+ }
1619
+ `,variables:t}},rulesetVersions(e){let t={rulesetId:e.rulesetId},r=["rulesetId: $rulesetId"],s=["$rulesetId: UUID!"];return e.status!==void 0&&(s.push("$status: RulesetVersionStatus"),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:`
1620
+ query RulesetVersions(${s.join(", ")}) {
1621
+ rulesetVersions(${r.join(", ")}) {
1622
+ ${d(g)}
1623
+ }
1624
+ }
1625
+ `,variables:t}},rulesetVersion(){return {query:`
1626
+ query RulesetVersion($id: UUID!) {
1627
+ rulesetVersion(id: $id) {
1628
+ ${g}
1629
+ }
1630
+ }
1631
+ `}},rulesetValidationRules(){return {query:`
1632
+ query RulesetValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
1633
+ rulesetValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId)
1634
+ }
1635
+ `}},deckValidationRules(){return {query:`
1636
+ query DeckValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
1637
+ deckValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId) {
1638
+ ${Fe}
1639
+ }
1640
+ }
1641
+ `}},rulesetVersionDraftImportPreview(){return {query:`
1642
+ query RulesetVersionDraftImportPreview($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
1643
+ rulesetVersionDraftImportPreview(rulesetId: $rulesetId, input: $input) {
1644
+ ${Le}
1645
+ }
1646
+ }
1647
+ `}},rulesetValidationImpact(e){let t={rulesetVersionId:e.rulesetVersionId},r=["rulesetVersionId: $rulesetVersionId"],s=["$rulesetVersionId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),{query:`
1648
+ query RulesetValidationImpact(${s.join(", ")}) {
1649
+ rulesetValidationImpact(${r.join(", ")}) {
1650
+ ${Pe}
1651
+ }
1652
+ }
1653
+ `,variables:t}},createRuleset(){return {query:`
1654
+ mutation RulesetCreate($input: RulesetCreateInput!) {
1655
+ rulesetCreate(input: $input) {
1656
+ ${q}
1657
+ }
1658
+ }
1659
+ `}},updateRuleset(){return {query:`
1660
+ mutation RulesetUpdate($id: UUID!, $input: RulesetUpdateInput!) {
1661
+ rulesetUpdate(id: $id, input: $input) {
1662
+ ${q}
1663
+ }
1664
+ }
1665
+ `}},createRulesetVersionDraft(){return {query:`
1666
+ mutation RulesetVersionDraftCreate($rulesetId: UUID!, $input: RulesetVersionDraftCreateInput!) {
1667
+ rulesetVersionDraftCreate(rulesetId: $rulesetId, input: $input) {
1668
+ ${g}
1669
+ }
1670
+ }
1671
+ `}},importRulesetVersionDraftFromDatasetRecord(){return {query:`
1672
+ mutation RulesetVersionDraftImportFromDatasetRecord($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
1673
+ rulesetVersionDraftImportFromDatasetRecord(rulesetId: $rulesetId, input: $input) {
1674
+ ${g}
1485
1675
  }
1486
1676
  }
1487
- `}},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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1488
- query MyDecks${a} {
1677
+ `}},updateRulesetVersionDraft(){return {query:`
1678
+ mutation RulesetVersionDraftUpdate($id: UUID!, $input: RulesetVersionDraftUpdateInput!) {
1679
+ rulesetVersionDraftUpdate(id: $id, input: $input) {
1680
+ ${g}
1681
+ }
1682
+ }
1683
+ `}},publishRulesetVersion(){return {query:`
1684
+ mutation RulesetVersionPublish($id: UUID!, $input: RulesetVersionPublishInput) {
1685
+ rulesetVersionPublish(id: $id, input: $input) {
1686
+ ${g}
1687
+ }
1688
+ }
1689
+ `}},activateRulesetVersion(){return {query:`
1690
+ mutation RulesetVersionActivate($id: UUID!) {
1691
+ rulesetVersionActivate(id: $id) {
1692
+ ${g}
1693
+ }
1694
+ }
1695
+ `}},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:`
1696
+ query MyDecks${i} {
1489
1697
  myDecks${n} {
1490
1698
  ${d(u)}
1491
1699
  }
1492
1700
  }
1493
- `,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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1494
- query ViewerDecks${a} {
1701
+ `,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:`
1702
+ query ViewerDecks${i} {
1495
1703
  viewerDecks${n} {
1496
1704
  ${d(u)}
1497
1705
  }
1498
1706
  }
1499
- `,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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1500
- query AppDecks${a} {
1707
+ `,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:`
1708
+ query AppDecks${i} {
1501
1709
  appDecks${n} {
1502
1710
  ${d(u)}
1503
1711
  }
1504
1712
  }
1505
- `,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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1506
- query PublicDecks${a} {
1713
+ `,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:`
1714
+ query PublicDecks${i} {
1507
1715
  publicDecks${n} {
1508
1716
  ${d(u)}
1509
1717
  }
@@ -1553,85 +1761,85 @@ ${ae}`:n;return {query:`
1553
1761
  `}},deckVersion(){return {query:`
1554
1762
  query DeckVersion($id: UUID!) {
1555
1763
  deckVersion(id: $id) {
1556
- ${K}
1764
+ ${P}
1557
1765
  }
1558
1766
  }
1559
1767
  `}},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:`
1560
1768
  query DeckVersions(${s.join(", ")}) {
1561
1769
  deckVersions(${r.join(", ")}) {
1562
- ${d(K)}
1770
+ ${d(P)}
1563
1771
  }
1564
1772
  }
1565
1773
  `,variables:t}},deckDraftDiff(){return {query:`
1566
1774
  query DeckDraftDiff($id: UUID!) {
1567
1775
  deckDraftDiff(id: $id) {
1568
- ${ee}
1776
+ ${re}
1569
1777
  }
1570
1778
  }
1571
1779
  `}},deckVersionDiff(){return {query:`
1572
1780
  query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
1573
1781
  deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
1574
- ${ee}
1782
+ ${re}
1575
1783
  }
1576
1784
  }
1577
1785
  `}},deckHydrateEntries(){return {query:`
1578
1786
  query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
1579
1787
  deckHydrateEntries(input: $input) {
1580
- ${Ue}
1788
+ ${Me}
1581
1789
  }
1582
1790
  }
1583
1791
  `}},deckExport(){return {query:`
1584
1792
  query DeckExport($id: UUID!, $format: DeckExportFormat!) {
1585
1793
  deckExport(id: $id, format: $format) {
1586
- ${Fe}
1794
+ ${Je}
1587
1795
  }
1588
1796
  }
1589
1797
  `}},deckValidate(){return {query:`
1590
1798
  query DeckValidate($id: UUID!, $input: DeckValidateInput) {
1591
1799
  deckValidate(id: $id, input: $input) {
1592
- ${H}
1800
+ ${W}
1593
1801
  }
1594
1802
  }
1595
- `}},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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1596
- query DeckSectionDefinitions${a} {
1803
+ `}},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:`
1804
+ query DeckSectionDefinitions${i} {
1597
1805
  deckSectionDefinitions${n} {
1598
- ${j}
1806
+ ${E}
1599
1807
  }
1600
1808
  }
1601
1809
  `,variables:t}},deckCollaborators(){return {query:`
1602
1810
  query DeckCollaborators($deckId: UUID!) {
1603
1811
  deckCollaborators(deckId: $deckId) {
1604
- ${te}
1812
+ ${se}
1605
1813
  }
1606
1814
  }
1607
1815
  `}},deckApiApplicationAccesses(){return {query:`
1608
1816
  query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
1609
1817
  deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
1610
- ${V}
1818
+ ${J}
1611
1819
  }
1612
1820
  }
1613
1821
  `}},myDeckApiApplicationAccesses(){return {query:`
1614
1822
  query MyDeckApiApplicationAccesses($applicationId: UUID) {
1615
1823
  myDeckApiApplicationAccesses(applicationId: $applicationId) {
1616
- ${V}
1824
+ ${J}
1617
1825
  }
1618
1826
  }
1619
- `}},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 a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1620
- query DeckImportFormats${a} {
1827
+ `}},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:`
1828
+ query DeckImportFormats${i} {
1621
1829
  deckImportFormats${n} {
1622
- ${d(k)}
1830
+ ${d(v)}
1623
1831
  }
1624
1832
  }
1625
1833
  `,variables:t}},deckImportFormat(){return {query:`
1626
1834
  query DeckImportFormat($id: UUID, $gameId: UUID, $key: String) {
1627
1835
  deckImportFormat(id: $id, gameId: $gameId, key: $key) {
1628
- ${k}
1836
+ ${v}
1629
1837
  }
1630
1838
  }
1631
1839
  `}},deckImportFormatTest(){return {query:`
1632
1840
  query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
1633
1841
  deckImportFormatTest(input: $input) {
1634
- ${Ke}
1842
+ ${Be}
1635
1843
  }
1636
1844
  }
1637
1845
  `}},createDeck(){return {query:`
@@ -1671,61 +1879,61 @@ ${ae}`:n;return {query:`
1671
1879
  `}},addDeckEntry(){return {query:`
1672
1880
  mutation DeckEntryAdd($input: DeckEntryAddInput!) {
1673
1881
  deckEntryAdd(input: $input) {
1674
- ${B}
1882
+ ${O}
1675
1883
  }
1676
1884
  }
1677
1885
  `}},updateDeckEntry(){return {query:`
1678
1886
  mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
1679
1887
  deckEntryUpdate(id: $id, input: $input) {
1680
- ${B}
1888
+ ${O}
1681
1889
  }
1682
1890
  }
1683
1891
  `}},removeDeckEntry(){return {query:`
1684
1892
  mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
1685
1893
  deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
1686
- ${B}
1894
+ ${O}
1687
1895
  }
1688
1896
  }
1689
1897
  `}},reorderDeckEntries(){return {query:`
1690
1898
  mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
1691
1899
  deckEntryReorder(deckId: $deckId, input: $input) {
1692
- ${pe}
1900
+ ${ge}
1693
1901
  }
1694
1902
  }
1695
1903
  `}},replaceDeckEntries(){return {query:`
1696
1904
  mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
1697
1905
  deckEntriesReplace(deckId: $deckId, input: $input) {
1698
- ${Be}
1906
+ ${je}
1699
1907
  }
1700
1908
  }
1701
1909
  `}},importDeck(){return {query:`
1702
1910
  mutation DeckImport($input: DeckImportInput!) {
1703
1911
  deckImport(input: $input) {
1704
- ${_e}
1912
+ ${He}
1705
1913
  }
1706
1914
  }
1707
1915
  `}},createDeckImportFormat(){return {query:`
1708
1916
  mutation DeckImportFormatCreate($input: DeckImportFormatCreateInput!) {
1709
1917
  deckImportFormatCreate(input: $input) {
1710
- ${k}
1918
+ ${v}
1711
1919
  }
1712
1920
  }
1713
1921
  `}},updateDeckImportFormat(){return {query:`
1714
1922
  mutation DeckImportFormatUpdate($id: UUID!, $input: DeckImportFormatUpdateInput!) {
1715
1923
  deckImportFormatUpdate(id: $id, input: $input) {
1716
- ${k}
1924
+ ${v}
1717
1925
  }
1718
1926
  }
1719
1927
  `}},archiveDeckImportFormat(){return {query:`
1720
1928
  mutation DeckImportFormatArchive($id: UUID!) {
1721
1929
  deckImportFormatArchive(id: $id) {
1722
- ${k}
1930
+ ${v}
1723
1931
  }
1724
1932
  }
1725
1933
  `}},unarchiveDeckImportFormat(){return {query:`
1726
1934
  mutation DeckImportFormatUnarchive($id: UUID!) {
1727
1935
  deckImportFormatUnarchive(id: $id) {
1728
- ${k}
1936
+ ${v}
1729
1937
  }
1730
1938
  }
1731
1939
  `}},upsertDeckByExternalRef(){return {query:`
@@ -1741,25 +1949,25 @@ ${ae}`:n;return {query:`
1741
1949
  `}},claimDeck(){return {query:`
1742
1950
  mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
1743
1951
  deckClaim(id: $id, input: $input) {
1744
- ${se}
1952
+ ${ae}
1745
1953
  }
1746
1954
  }
1747
1955
  `}},transferDeckOwnership(){return {query:`
1748
1956
  mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
1749
1957
  deckTransferOwnership(id: $id, input: $input) {
1750
- ${se}
1958
+ ${ae}
1751
1959
  }
1752
1960
  }
1753
1961
  `}},copyDeck(){return {query:`
1754
1962
  mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
1755
1963
  deckCopy(id: $id, input: $input) {
1756
- ${Pe}
1964
+ ${Oe}
1757
1965
  }
1758
1966
  }
1759
1967
  `}},publishDeck(){return {query:`
1760
1968
  mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
1761
1969
  deckPublish(id: $id, input: $input) {
1762
- ${Ve}
1970
+ ${Ne}
1763
1971
  }
1764
1972
  }
1765
1973
  `}},removeInvalidDeckEntries(){return {query:`
@@ -1771,7 +1979,7 @@ ${ae}`:n;return {query:`
1771
1979
  `}},upsertDeckCollaborator(){return {query:`
1772
1980
  mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
1773
1981
  deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
1774
- ${te}
1982
+ ${se}
1775
1983
  }
1776
1984
  }
1777
1985
  `}},removeDeckCollaborator(){return {query:`
@@ -1781,7 +1989,7 @@ ${ae}`:n;return {query:`
1781
1989
  `}},createDeckTokenIssuer(){return {query:`
1782
1990
  mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
1783
1991
  deckTokenIssuerCreate(input: $input) {
1784
- ${re}
1992
+ ${ie}
1785
1993
  }
1786
1994
  }
1787
1995
  `}},revokeDeckTokenIssuer(){return {query:`
@@ -1791,7 +1999,7 @@ ${ae}`:n;return {query:`
1791
1999
  `}},revokeDeckTokenIssuerSigningKey(){return {query:`
1792
2000
  mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
1793
2001
  deckTokenIssuerSigningKeyRevoke(id: $id) {
1794
- ${re}
2002
+ ${ie}
1795
2003
  }
1796
2004
  }
1797
2005
  `}},exchangeDeckToken(){return {query:`
@@ -1799,7 +2007,7 @@ ${ae}`:n;return {query:`
1799
2007
  deckTokenExchange(input: $input) {
1800
2008
  token
1801
2009
  deckToken {
1802
- ${Te}
2010
+ ${_e}
1803
2011
  }
1804
2012
  }
1805
2013
  }
@@ -1810,14 +2018,14 @@ ${ae}`:n;return {query:`
1810
2018
  `}},grantDeckApiApplicationAccess(){return {query:`
1811
2019
  mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
1812
2020
  deckApiApplicationAccessGrant(input: $input) {
1813
- ${V}
2021
+ ${J}
1814
2022
  }
1815
2023
  }
1816
2024
  `}},revokeDeckApiApplicationAccess(){return {query:`
1817
2025
  mutation DeckApiApplicationAccessRevoke($deckId: UUID!, $apiApplicationId: UUID!) {
1818
2026
  deckApiApplicationAccessRevoke(deckId: $deckId, apiApplicationId: $apiApplicationId)
1819
2027
  }
1820
- `}},deckCreateVariables(e){return {input:I(e)}},deckUpdateVariables(e,t){return {id:e,input:I(t)}},deckEntryAddVariables(e){return {input:I(e)}},deckEntryUpdateVariables(e,t){return {id:e,input:I(t)}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:I(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:I(e)}},deckReadVariables(e,t,r){return {id:e,readState:t,version:r}},deckExternalRefReadVariables(e,t,r){return {externalRef:e,readState:t,version:r}},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:I(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}},deckTokenIssuerCreateVariables(e){return {input:e}},deckTokenExchangeVariables(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}},createScanUploadSessionVariables(e){return {input:e}},confirmScanUploadVariables(e){return {input:e}},createScanJobVariables(e){return {input:e}},submitScanFeedbackVariables(e){return {input:e}},scanMetricsVariables(e){return {input:e}},resolveScanTemplateVariables(e){return {input:e}},scanTemplatesVariables(e){return {input:e}},createScanTemplateVariables(e){return {input:e}},updateScanTemplateVariables(e,t){return {id:e,input:t}},previewScanTemplateVariables(e){return {input:e}},gameScanRegionsVariables(e,t,r){return r===void 0?{publisherSlug:e,gameKey:t}:{publisherSlug:e,gameKey:t,includeInactive:r}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
2028
+ `}},rulesetValidationRulesVariables(e,t,r){return r===void 0?{gameId:e,rulesetKey:t}:{gameId:e,rulesetKey:t,rulesetVersionId:r}},rulesetVersionDraftImportPreviewVariables(e,t){return {rulesetId:e,input:t}},rulesetCreateVariables(e){return {input:e}},rulesetUpdateVariables(e,t){return {id:e,input:t}},rulesetVersionDraftCreateVariables(e,t){return {rulesetId:e,input:t}},rulesetVersionDraftImportFromDatasetRecordVariables(e,t){return {rulesetId:e,input:t}},rulesetVersionDraftUpdateVariables(e,t){return {id:e,input:t}},rulesetVersionPublishVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckCreateVariables(e){return {input:b(e)}},deckUpdateVariables(e,t){return {id:e,input:b(t)}},deckEntryAddVariables(e){return {input:b(e)}},deckEntryUpdateVariables(e,t){return {id:e,input:b(t)}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:b(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:b(e)}},deckReadVariables(e,t,r){return {id:e,readState:t,version:r}},deckExternalRefReadVariables(e,t,r){return {externalRef:e,readState:t,version:r}},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:b(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}},deckTokenIssuerCreateVariables(e){return {input:e}},deckTokenExchangeVariables(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}},createScanUploadSessionVariables(e){return {input:e}},confirmScanUploadVariables(e){return {input:e}},createScanJobVariables(e){return {input:e}},submitScanFeedbackVariables(e){return {input:e}},scanMetricsVariables(e){return {input:e}},resolveScanTemplateVariables(e){return {input:e}},scanTemplatesVariables(e){return {input:e}},createScanTemplateVariables(e){return {input:e}},updateScanTemplateVariables(e,t){return {id:e,input:t}},previewScanTemplateVariables(e){return {input:e}},gameScanRegionsVariables(e,t,r){return r===void 0?{publisherSlug:e,gameKey:t}:{publisherSlug:e,gameKey:t,includeInactive:r}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
1821
2029
  query FetchMe {
1822
2030
  fetchMe {
1823
2031
  application {
@@ -1839,6 +2047,6 @@ ${ae}`:n;return {query:`
1839
2047
  }
1840
2048
  }
1841
2049
  }
1842
- `}}},l=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 tt="https://carddb.dev/query",rt=3e4,st=1e4,at=300,it=3,nt=2,ct=1e3,ot=3e4,ut=class ke{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??tt,this.timeout=t.timeout??rt,this.openTimeout=t.openTimeout??st,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??it,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??nt,this.retryBaseDelay=t.retryBaseDelay??ct,this.retryMaxDelay=t.retryMaxDelay??ot,this.cache=t.cache,this.cacheTtl=t.cacheTtl??at,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),a=s*.25*(Math.random()*2-1);return Math.round(s+a)}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 v(`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 v(`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 v(`${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 ke({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})}},$e="0.4.1";function lt(){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?dt(navigator.userAgent):{name:"unknown",version:"unknown"}}function dt(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 a=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return a?{name:"safari",version:a[1]}:{name:"browser",version:"unknown"}}function ht(){let e=lt();return `CardDB-SDK/js/${$e} (${e.name}/${e.version})`}function gr(){return $e}var ve=null;function yt(){return ve}var ft=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,a=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 U&&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&&a<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(a);this.logNetworkRetry(r,a+1,c,n),a++,await this.sleep(c);continue}if(n instanceof N&&this.config.retryOnNetworkError&&a<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(a);this.logNetworkRetry(r,a+1,c,n),a++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof x||e instanceof O}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),a=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":ht(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&a?{"X-API-Key":a}:{}},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 O("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new x(`Connection failed: ${n.message}`)):new x("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new G("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 N(`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 G(s,t);case "RATE_LIMITED":throw new U(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new F(s,{errors:e,response:t});default:throw new ce(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,a=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=a?new Date(a*1e3):null,c=await this.parseBody(e);throw new U("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 F(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;ve={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 a=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${a} 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 pt(e,t,r){let s=Object.entries(r).filter(([,a])=>a!==void 0).sort(([a],[n])=>a.localeCompare(n)).map(([a,n])=>`${a}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function mt(e,t){let r=e.get(t);return r}async function gt(e,t,r,s){let a=e.set(t,r,s);a instanceof Promise&&await a;}var f=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 a=r.cache??!!this.config.cache,n=this.config.cache;if(!a||!n)return s();let c=await mt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await gt(n,e,o,h);}return o}cacheKey(e,t,r){return pt(e,t,r)}},It=class extends f{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=i.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),a=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new l(a,{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:a}=i.fetchPublisherById();return (await this.connection.execute(a,{id:e})).fetchPublisher??null}else {let{query:a}=i.fetchPublisherBySlug();return (await this.connection.execute(a,{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}=i.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)}},bt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=i.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),a=this.cacheKey("games","list",s),n=await this.withCache(a,"games",t,async()=>(await this.connection.execute(r,s)).games);return new l(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}=i.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}=i.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=i.createGame();return (await this.connection.execute(t,i.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=i.updateGame();return (await this.connection.execute(r,i.gameUpdateVariables(e,t))).gameUpdate}async getRegions(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=i.gameScanRegionsVariables(t,r,e.includeInactive),a=this.cacheKey("games","getRegions",s);return this.withCache(a,"games",e,async()=>{let{query:n}=i.gameScanRegions();return (await this.connection.execute(n,s)).gameScanRegions??[]})}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=i.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),a=this.cacheKey("games","search",s),n=await this.withCache(a,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new l(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,a=t,n=r??{};this.validateAccess(s,a);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:a});return this.withCache(c,"games",n,async()=>{let{query:o}=i.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:a})).fetchGame??null})}else {let s=e,a=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",a,async()=>{let{query:c}=i.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}=i.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},kt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=i.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),a=this.cacheKey("datasets","list",s),n=await this.withCache(a,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new l(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}=i.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}=i.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:a}=i.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",a),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,a)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let a=e,n=t,c=s??{};this.validateAccess(a,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:a,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=i.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:a,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let a=e,n=t??{},c=this.cacheKey("datasets","get",{id:a});return this.withCache(c,"datasets",n,async()=>{let{query:o}=i.fetchDatasetById();return (await this.connection.execute(o,{id:a})).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}=i.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},$t=class extends f{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}=i.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t){let r=i.deckReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","get",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckById();return (await this.connection.execute(a,r)).deck??null})}async getDraft(e,t={}){return this.get(e,{...t,readState:"DRAFT"})}async getPublished(e,t={}){return this.get(e,{...t,readState:"PUBLISHED",version:t.version})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let a=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(a,"decks",s,async()=>{let{query:n}=i.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let a=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(a,"decks",s,async()=>{let{query:n}=i.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}=i.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t){let r=i.deckExternalRefReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","getByExternalRef",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckByExternalRef();return (await this.connection.execute(a,r)).deckByExternalRef??null})}async getDraftByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"DRAFT"})}async getPublishedByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"PUBLISHED",version:t.version})}async listMine(e={}){let{query:t,variables:r}=i.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new l(a,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=i.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new l(a,{nextPageLoader:async n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=i.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new l(a,{nextPageLoader:async n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=i.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new l(a,{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}=i.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=i.deckVersions({first:t.first,after:t.after}),a={deckId:e,...s},n=this.cacheKey("decks","listVersions",a),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,a)).deckVersions);return new l(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=i.deckVersionDiffVariables(e,t),a=this.cacheKey("decks","versionDiff",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=i.deckValidateVariables(e,t),a=this.cacheKey("decks","validate",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=i.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckHydrateEntries();return (await this.connection.execute(a,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=i.deckExportVariables(e,t),a=this.cacheKey("decks","exportDeck",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=i.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}=i.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listApiApplicationAccesses(e,t={}){let r=i.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckApiApplicationAccesses();return (await this.connection.execute(a,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=i.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=i.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=i.createDeck(),r=i.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=i.updateDeck(),s=i.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}=i.upsertDeckByExternalRef(),r=i.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=i.claimDeck(),s=i.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=i.transferDeckOwnership(),s=i.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=i.copyDeck(),s=i.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=i.addDeckEntry(),r=i.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=i.updateDeckEntry(),s=i.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=i.removeDeckEntry(),s=i.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=i.reorderDeckEntries(),s=i.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=i.replaceDeckEntries(),s=i.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=i.importDeck(),r=i.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=i.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),a=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(a,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new l(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}=i.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=i.deckImportFormatTest(),r=i.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=i.createDeckImportFormat(),r=i.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=i.updateDeckImportFormat(),s=i.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=i.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=i.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=i.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=i.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=i.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=i.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=i.publishDeck(),s=i.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=i.removeInvalidDeckEntries(),s=i.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=i.upsertDeckCollaborator(),a=i.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,a)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=i.removeDeckCollaborator(),s=i.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createTokenIssuer(e){this.config.requireSecretCredential("decks.createTokenIssuer");let{query:t}=i.createDeckTokenIssuer(),r=i.deckTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckTokenIssuerCreate}async revokeTokenIssuer(e){this.config.requireSecretCredential("decks.revokeTokenIssuer");let{query:t}=i.revokeDeckTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckTokenIssuerRevoke}async revokeTokenIssuerSigningKey(e){this.config.requireSecretCredential("decks.revokeTokenIssuerSigningKey");let{query:t}=i.revokeDeckTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=i.grantDeckApiApplicationAccess(),r=i.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=i.revokeDeckApiApplicationAccess(),s=i.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeToken(e){this.config.requireSecretCredential("decks.exchangeToken");let{query:t}=i.exchangeDeckToken(),r=i.deckTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckTokenExchange}async revokeToken(e){this.config.requireSecretCredential("decks.revokeToken");let{query:t}=i.revokeDeckToken();return !!(await this.connection.execute(t,{id:e})).deckTokenRevoke}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),a=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(a,"decks",e,async()=>{let{query:o}=i.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=vt(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function vt(e,t,r){let s=new Set(t),a=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)&&(a.set(o,n),s.delete(o));}return a}var Dt=class extends f{constructor(e,t){super(e,t);}async list(e){let t=P(e.filter),{query:r,variables:s}=i.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),a=this.cacheKey("records","list",s),n=await this.withCache(a,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new l(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}=i.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}=i.upsertDatasetRecords();return (await this.connection.execute(t,i.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=i.deleteDatasetRecords();return (await this.connection.execute(t,i.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}=i.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=i.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(a,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new l(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=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()-a>=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=P(e.filter),{query:a,variables:n}=i.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(a,n)).searchRecords);return new l(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}=i.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:a}=i.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(a,{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:a}=i.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(a,{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}=i.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},wt=class extends f{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:a}=i.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",a),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,a)).searchDatasets);return new l(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),a=t.datasetKey??e;this.validateAccess(r,s);let n=P(t.filter),{query:c,variables:o}=i.searchRecords({publisherSlug:r,gameKey:s,datasetKey:a,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),S=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l(S,{nextPageLoader:async Q=>this.searchRuleRecords(e,{...t,after:Q})})}},St=class extends f{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=i.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),a=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new l(a,{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}=i.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}=i.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=i.deckImportFormatTest();return (await this.connection.execute(t,i.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=i.createDeckImportFormat();return (await this.connection.execute(t,i.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=i.updateDeckImportFormat();return (await this.connection.execute(r,i.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=i.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=i.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},At=class extends f{constructor(e,t){super(e,t);}async preview(e){let{query:t}=i.datasetImportPreview();return (await this.connection.execute(t,i.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=i.datasetImportValidate();return (await this.connection.execute(t,i.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=i.datasetImportFromFile();return (await this.connection.execute(s,i.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=i.datasetImportFromUrl();return (await this.connection.execute(s,i.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=i.datasetImportFromPayload();return (await this.connection.execute(t,i.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}=i.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=i.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("imports","listJobs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=i.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=i.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),a=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??Et());return new l(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=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()-a>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=i.gameImportPreview();return (await this.connection.execute(t,i.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=i.gameImportFromFile();return (await this.connection.execute(s,i.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=i.gameImportFromUrl();return (await this.connection.execute(s,i.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=i.gameImportFromPayload();return (await this.connection.execute(t,i.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}=i.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=i.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new l(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=i.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=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()-a>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function Et(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var Rt=class extends f{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=i.datasetExport();return (await this.connection.execute(t,i.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}=i.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=i.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("exports","listJobs",s),n=await this.withCache(a,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=i.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=i.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=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()-a>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},xt=class extends f{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}=i.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=i.fileUploadRequest();return (await this.connection.execute(t,i.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=i.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async upload(e){let t=e.size??Ct(e.body);if(!t||t<=0)throw new Error("files.upload requires a positive size or a body with an inferable size");let r=await this.requestUpload({filename:e.filename,contentType:e.contentType,size:t,isPublic:e.isPublic??false,entityType:e.entityType??Tt(e.purpose),entityId:e.entityId,publisherId:e.publisherId,datasetId:e.datasetId});return await qt(r.uploadUrl,e.contentType,e.body),this.confirmUpload(r.file.id)}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=i.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}};async function qt(e,t,r){let s=globalThis.fetch;if(!s)throw new Error("files.upload requires a runtime with fetch support");let a=await s(e,{method:"PUT",headers:{"Content-Type":t},body:r});if(!a.ok){let n=await a.text().catch(()=>"");throw new Error(`File upload failed with ${a.status} ${a.statusText}${n?`: ${n}`:""}`)}}function Ct(e){if(typeof e=="string")return new TextEncoder().encode(e).byteLength;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;if(typeof t?.size=="number")return t.size;if(typeof t?.byteLength=="number")return t.byteLength;if(typeof t?.length=="number")return t.length}function Tt(e){if(!(!e||e==="scan_image"))return e==="import"?"import":e==="scan_template_example"?"scan_template_example":e}var Kt=class extends f{constructor(e,t){super(e,t);}async createUploadSession(e){let t=this.resolveCreateUploadSessionInput(e),{query:r}=i.createScanUploadSession();return (await this.connection.execute(r,i.createScanUploadSessionVariables(t))).createScanUploadSession}async confirmUpload(e){let t=this.resolveConfirmUploadInput(e),{query:r}=i.confirmScanUpload();return (await this.connection.execute(r,i.confirmScanUploadVariables(t))).confirmScanUpload}async createJob(e){let t=this.resolveCreateJobInput(e),{query:r}=i.createScanJob();return (await this.connection.execute(r,i.createScanJobVariables(t))).createScanJob}async getJob(e,t={}){let r=this.cacheKey("scans","getJob",{id:e});return this.withCache(r,"scans",t,async()=>{let{query:s}=i.scanJob();return (await this.connection.execute(s,{id:e})).scanJob??null})}async pollJob(e,t={}){let r=t.timeoutMs??3e5,s=Math.max(t.backoffFactor??1.5,1),a=t.maxIntervalMs??1e4,n=Date.now(),c=Math.max(t.intervalMs??1e3,1);for(;;){Pt(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Ut(o.status))return o;let h=Date.now()-n,S=r-h;if(S<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Ft(Math.min(c,S)),c=Math.min(Math.ceil(c*s),a);}}async submitFeedback(e){let{query:t}=i.submitScanFeedback();return (await this.connection.execute(t,i.submitScanFeedbackVariables(e))).submitScanFeedback}async metrics(e){let t=this.resolveMetricsInput(e),{query:r}=i.scanMetrics();return (await this.connection.execute(r,i.scanMetricsVariables(t))).scanMetrics}async verifyWebhookSignature(e){let t=Lt(),r=await t.importKey("raw",De(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,Vt(e.body)),a=`sha256=${Bt(new Uint8Array(s))}`;return _t(e.signature.trim().toLowerCase(),a)}resolveCreateJobInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveCreateUploadSessionInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveConfirmUploadInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveMetricsInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Ut(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Ft(e){return new Promise(t=>setTimeout(t,e))}function Pt(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Lt(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function Vt(e){return typeof e=="string"?De(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function De(e){return new TextEncoder().encode(e)}function Bt(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function _t(e,t){let r=Math.max(e.length,t.length),s=e.length^t.length;for(let a=0;a<r;a++)s|=(e.charCodeAt(a)||0)^(t.charCodeAt(a)||0);return s===0}var Mt=class extends f{constructor(e,t){super(e,t);}async resolve(e){let t=this.resolveTemplateScope(e),r=this.cacheKey("scanTemplates","resolve",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=i.resolveScanTemplate();return (await this.connection.execute(s,i.resolveScanTemplateVariables(t))).resolveScanTemplate})}async list(e){let t=this.resolveListScope(e),r=this.cacheKey("scanTemplates","list",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=i.scanTemplates();return (await this.connection.execute(s,i.scanTemplatesVariables(t))).scanTemplates?.templates??[]})}async create(e){this.config.requireSecretCredential("scanTemplates.create");let t=this.resolveSaveInput(e),{query:r}=i.createScanTemplate();return (await this.connection.execute(r,i.createScanTemplateVariables(t))).createScanTemplate}async update(e,t){this.config.requireSecretCredential("scanTemplates.update");let r=typeof e=="string"?e:e.id,s=typeof e=="string"?t:Jt(e);if(!s)throw new Error("scan template input is required");let a=this.resolveSaveInput(s),{query:n}=i.updateScanTemplate();return (await this.connection.execute(n,i.updateScanTemplateVariables(r,a))).updateScanTemplate}async preview(e){let t=this.resolvePreviewInput(e),{query:r}=i.previewScanTemplate();return (await this.connection.execute(r,i.previewScanTemplateVariables(t))).previewScanTemplate}resolveTemplateScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,templateId:e.templateId}}resolveListScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,includeArchived:e.includeArchived}}resolveSaveInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolvePreviewInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Jt(e){let t={...e};return delete t.id,t}var we=class Se{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new ut(t),this.connection=new ft(this.config),this.publishers=new It(this.connection,this.config),this.games=new bt(this.connection,this.config),this.datasets=new kt(this.connection,this.config),this.records=new Dt(this.connection,this.config),this.decks=new $t(this.connection,this.config),this.rules=new wt(this.connection,this.config),this.importFormats=new St(this.connection,this.config),this.imports=new At(this.connection,this.config),this.exports=new Rt(this.connection,this.config),this.files=new xt(this.connection,this.config),this.scans=new Kt(this.connection,this.config),this.scanTemplates=new Mt(this.connection,this.config);}async me(){let{query:t}=i.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return yt()}withConfig(t){let r=this.config.merge(t);return new Se({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 X=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 a={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(a));}catch(a){console.warn("[CardDB] Failed to write to cache:",a);}}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 a=this.storage.key(s);if(a&&a.startsWith(this.prefix))try{let n=this.storage.getItem(a);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(a);}}catch{r.push(a);}}for(let s of r)this.storage.removeItem(s);}};var Ae=class extends we{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new v("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new v("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1843
- export{G as AuthenticationError,f as BaseResource,X as BrowserCache,Ae as CardDBClient,y as CardDBError,l as Collection,ut as Configuration,ft as Connection,x as ConnectionError,at as DEFAULT_CACHE_TTL,tt as DEFAULT_ENDPOINT,nt as DEFAULT_MAX_NETWORK_RETRIES,it as DEFAULT_MAX_RETRIES,st as DEFAULT_OPEN_TIMEOUT,ct as DEFAULT_RETRY_BASE_DELAY,ot as DEFAULT_RETRY_MAX_DELAY,rt as DEFAULT_TIMEOUT,kt as DatasetsResource,$t as DecksResource,Rt as ExportsResource,xt as FilesResource,Ee as FilterBuilder,bt as GamesResource,ce as GraphQLError,St as ImportFormatsResource,At as ImportsResource,Ot as LinkResolutionError,Gt as NotFoundError,It as PublishersResource,i as QueryBuilder,U as RateLimitError,Dt as RecordsResource,v as RestrictedError,wt as RulesResource,Mt as ScanTemplatesResource,Kt as ScansResource,N as ServerError,O as TimeoutError,F as ValidationError,pt as cacheKey,Zt as contains,Nt as eq,yt as getRateLimitInfo,gr as getSDKVersion,ht as getUserAgent,Ht as gt,Yt as gte,tr as ilike,sr as isNotNull,rr as isNull,er as like,zt as lt,Wt as lte,jt as neq,Qt as notWithin,mt as readCache,P as resolveFilter,Xt as within,gt as writeCache};//# sourceMappingURL=index.js.map
2050
+ `}}},l=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 ot="https://carddb.dev/query",ut=3e4,lt=1e4,dt=300,ht=3,yt=2,ft=1e3,pt=3e4,mt=class ve{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??ot,this.timeout=t.timeout??ut,this.openTimeout=t.openTimeout??lt,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??ht,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??yt,this.retryBaseDelay=t.retryBaseDelay??ft,this.retryMaxDelay=t.retryMaxDelay??pt,this.cache=t.cache,this.cacheTtl=t.cacheTtl??dt,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 w(`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 w(`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 w(`${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 ve({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})}},De="0.4.1";function gt(){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?It(navigator.userAgent):{name:"unknown",version:"unknown"}}function It(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 $t(){let e=gt();return `CardDB-SDK/js/${De} (${e.name}/${e.version})`}function Ar(){return De}var we=null;function bt(){return we}var kt=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 L&&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 z&&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 T||e instanceof Y}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":$t(),...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 Y("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new T(`Connection failed: ${n.message}`)):new T("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new H("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 z(`Server error (${e.status})`,{status:e.status,response:t})}throw new f(`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 H(s,t);case "RATE_LIMITED":throw new L(s,{response:t});case "NOT_FOUND":throw new f(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new R(s,{errors:e,response:t});default:throw new ue(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 L("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(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;we={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 vt(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 Dt(e,t){let r=e.get(t);return r}async function wt(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var y=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 Dt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await wt(n,e,o,h);}return o}cacheKey(e,t,r){return vt(e,t,r)}},St=class extends y{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 l(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 y{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 l(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 getRegions(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=a.gameScanRegionsVariables(t,r,e.includeInactive),i=this.cacheKey("games","getRegions",s);return this.withCache(i,"games",e,async()=>{let{query:n}=a.gameScanRegions();return (await this.connection.execute(n,s)).gameScanRegions??[]})}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 l(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??[]})}},Rt=class extends y{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 l(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 l(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??[]})}async filterValues(e,t,r,s,i){let n,c;Array.isArray(t)?(n={id:e,fields:t},c=r??{}):(n={publisherSlug:e,gameKey:t,datasetKey:r,fields:s},c=i??{},this.validateAccess(n.publisherSlug,n.gameKey));let{query:o,variables:h}=a.fetchDatasetFilterValues({...n,search:c.search,includeCounts:c.includeCounts,first:c.first,after:c.after}),$=this.cacheKey("datasets","filterValues",h);return this.withCache($,"datasets",c,async()=>(await this.connection.execute(o,h)).fetchDataset?.filterValues??[])}},Et=class extends y{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=a.deckReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","get",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckById();return (await this.connection.execute(i,r)).deck??null})}async getDraft(e,t={}){return this.get(e,{...t,readState:"DRAFT"})}async getPublished(e,t={}){return this.get(e,{...t,readState:"PUBLISHED",version:t.version})}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=a.deckExternalRefReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","getByExternalRef",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckByExternalRef();return (await this.connection.execute(i,r)).deckByExternalRef??null})}async getDraftByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"DRAFT"})}async getPublishedByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"PUBLISHED",version:t.version})}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 l(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 l(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 l(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 l(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 l(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}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 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 l(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 createTokenIssuer(e){this.config.requireSecretCredential("decks.createTokenIssuer");let{query:t}=a.createDeckTokenIssuer(),r=a.deckTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckTokenIssuerCreate}async revokeTokenIssuer(e){this.config.requireSecretCredential("decks.revokeTokenIssuer");let{query:t}=a.revokeDeckTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckTokenIssuerRevoke}async revokeTokenIssuerSigningKey(e){this.config.requireSecretCredential("decks.revokeTokenIssuerSigningKey");let{query:t}=a.revokeDeckTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckTokenIssuerSigningKeyRevoke}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 exchangeToken(e){this.config.requireSecretCredential("decks.exchangeToken");let{query:t}=a.exchangeDeckToken(),r=a.deckTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckTokenExchange}async revokeToken(e){this.config.requireSecretCredential("decks.revokeToken");let{query:t}=a.revokeDeckToken();return !!(await this.connection.execute(t,{id:e})).deckTokenRevoke}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=qt(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function qt(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 Ct=class extends y{constructor(e,t){super(e,t);}async list(e){let t=_(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 l(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 l(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=_(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 l(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??[]})}},xt=class extends y{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 l(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=_(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),$=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l($,{nextPageLoader:async M=>this.searchRuleRecords(e,{...t,after:M})})}},Ut=class extends y{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.rulesets({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("rulesets","list",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesets);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async listPublic(e,t={}){let{query:r,variables:s}=a.publicRulesets({gameId:e,first:t.first,after:t.after}),i=this.cacheKey("rulesets","listPublic",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).publicRulesets);return new l(n,{nextPageLoader:async c=>this.listPublic(e,{...t,after:c})})}async get(e,t={}){let r={id:e},s=this.cacheKey("rulesets","get",r);return this.withCache(s,"rulesets",t,async()=>{let{query:i,variables:n}=a.ruleset({id:e});return (await this.connection.execute(i,n)).ruleset??null})}async getByKey(e){let t={gameId:e.gameId,key:e.key},r=this.cacheKey("rulesets","getByKey",t);return this.withCache(r,"rulesets",e,async()=>{let{query:s,variables:i}=a.ruleset({gameId:e.gameId,key:e.key});return (await this.connection.execute(s,i)).ruleset??null})}async versions(e,t={}){let{query:r,variables:s}=a.rulesetVersions({rulesetId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("rulesets","versions",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesetVersions);return new l(n,{nextPageLoader:async c=>this.versions(e,{...t,after:c})})}async getVersion(e,t={}){let r=this.cacheKey("rulesets","getVersion",{id:e});return this.withCache(r,"rulesets",t,async()=>{let{query:s}=a.rulesetVersion();return (await this.connection.execute(s,{id:e})).rulesetVersion??null})}async validationRules(e,t,r={}){let s=a.rulesetValidationRulesVariables(e,t,r.rulesetVersionId),i=this.cacheKey("rulesets","validationRules",s);return this.withCache(i,"rulesets",r,async()=>{let{query:n}=a.rulesetValidationRules();return (await this.connection.execute(n,s)).rulesetValidationRules??null})}async deckValidationRules(e,t,r={}){let s=a.rulesetValidationRulesVariables(e,t,r.rulesetVersionId),i=this.cacheKey("rulesets","deckValidationRules",s);return this.withCache(i,"rulesets",r,async()=>{let{query:n}=a.deckValidationRules();return (await this.connection.execute(n,s)).deckValidationRules??null})}async previewImport(e,t){let{query:r}=a.rulesetVersionDraftImportPreview(),s=a.rulesetVersionDraftImportPreviewVariables(e,t);return (await this.connection.execute(r,s)).rulesetVersionDraftImportPreview}async validationImpact(e,t={}){let{query:r,variables:s}=a.rulesetValidationImpact({rulesetVersionId:e,first:t.first}),i=this.cacheKey("rulesets","validationImpact",s);return this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesetValidationImpact)}async create(e){this.config.requireSecretCredential("rulesets.create");let{query:t}=a.createRuleset();return (await this.connection.execute(t,a.rulesetCreateVariables(e))).rulesetCreate}async update(e,t){this.config.requireSecretCredential("rulesets.update");let{query:r}=a.updateRuleset();return (await this.connection.execute(r,a.rulesetUpdateVariables(e,t))).rulesetUpdate}async createDraft(e,t){this.config.requireSecretCredential("rulesets.createDraft");let{query:r}=a.createRulesetVersionDraft();return (await this.connection.execute(r,a.rulesetVersionDraftCreateVariables(e,t))).rulesetVersionDraftCreate}async importDraftFromDatasetRecord(e,t){this.config.requireSecretCredential("rulesets.importDraftFromDatasetRecord");let{query:r}=a.importRulesetVersionDraftFromDatasetRecord();return (await this.connection.execute(r,a.rulesetVersionDraftImportFromDatasetRecordVariables(e,t))).rulesetVersionDraftImportFromDatasetRecord}async updateDraft(e,t){this.config.requireSecretCredential("rulesets.updateDraft");let{query:r}=a.updateRulesetVersionDraft();return (await this.connection.execute(r,a.rulesetVersionDraftUpdateVariables(e,t))).rulesetVersionDraftUpdate}async publishVersion(e,t){this.config.requireSecretCredential("rulesets.publishVersion");let{query:r}=a.publishRulesetVersion();return (await this.connection.execute(r,a.rulesetVersionPublishVariables(e,t))).rulesetVersionPublish}async activateVersion(e){this.config.requireSecretCredential("rulesets.activateVersion");let{query:t}=a.activateRulesetVersion();return (await this.connection.execute(t,{id:e})).rulesetVersionActivate}},Kt=class extends y{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 l(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}},Tt=class extends y{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 l(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??Ft());return new l(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 l(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 Ft(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var Vt=class extends y{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 l(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 y{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 upload(e){let t=e.size??_t(e.body);if(!t||t<=0)throw new Error("files.upload requires a positive size or a body with an inferable size");let r=await this.requestUpload({filename:e.filename,contentType:e.contentType,size:t,isPublic:e.isPublic??false,entityType:e.entityType??Bt(e.purpose),entityId:e.entityId,publisherId:e.publisherId,datasetId:e.datasetId});return await Lt(r.uploadUrl,e.contentType,e.body),this.confirmUpload(r.file.id)}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=a.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}};async function Lt(e,t,r){let s=globalThis.fetch;if(!s)throw new Error("files.upload requires a runtime with fetch support");let i=await s(e,{method:"PUT",headers:{"Content-Type":t},body:r});if(!i.ok){let n=await i.text().catch(()=>"");throw new Error(`File upload failed with ${i.status} ${i.statusText}${n?`: ${n}`:""}`)}}function _t(e){if(typeof e=="string")return new TextEncoder().encode(e).byteLength;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;if(typeof t?.size=="number")return t.size;if(typeof t?.byteLength=="number")return t.byteLength;if(typeof t?.length=="number")return t.length}function Bt(e){if(!(!e||e==="scan_image"))return e==="import"?"import":e==="scan_template_example"?"scan_template_example":e}var Mt=class extends y{constructor(e,t){super(e,t);}async createUploadSession(e){let t=this.resolveCreateUploadSessionInput(e),{query:r}=a.createScanUploadSession();return (await this.connection.execute(r,a.createScanUploadSessionVariables(t))).createScanUploadSession}async confirmUpload(e){let t=this.resolveConfirmUploadInput(e),{query:r}=a.confirmScanUpload();return (await this.connection.execute(r,a.confirmScanUploadVariables(t))).confirmScanUpload}async createJob(e){let t=this.resolveCreateJobInput(e),{query:r}=a.createScanJob();return (await this.connection.execute(r,a.createScanJobVariables(t))).createScanJob}async getJob(e,t={}){let r=this.cacheKey("scans","getJob",{id:e});return this.withCache(r,"scans",t,async()=>{let{query:s}=a.scanJob();return (await this.connection.execute(s,{id:e})).scanJob??null})}async pollJob(e,t={}){let r=t.timeoutMs??3e5,s=Math.max(t.backoffFactor??1.5,1),i=t.maxIntervalMs??1e4,n=Date.now(),c=Math.max(t.intervalMs??1e3,1);for(;;){Gt(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Jt(o.status))return o;let h=Date.now()-n,$=r-h;if($<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Ot(Math.min(c,$)),c=Math.min(Math.ceil(c*s),i);}}async submitFeedback(e){let{query:t}=a.submitScanFeedback();return (await this.connection.execute(t,a.submitScanFeedbackVariables(e))).submitScanFeedback}async metrics(e){let t=this.resolveMetricsInput(e),{query:r}=a.scanMetrics();return (await this.connection.execute(r,a.scanMetricsVariables(t))).scanMetrics}async verifyWebhookSignature(e){let t=Nt(),r=await t.importKey("raw",Se(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,jt(e.body)),i=`sha256=${Ht(new Uint8Array(s))}`;return Yt(e.signature.trim().toLowerCase(),i)}resolveCreateJobInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveCreateUploadSessionInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveConfirmUploadInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveMetricsInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Jt(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Ot(e){return new Promise(t=>setTimeout(t,e))}function Gt(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Nt(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function jt(e){return typeof e=="string"?Se(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Se(e){return new TextEncoder().encode(e)}function Ht(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Yt(e,t){let r=Math.max(e.length,t.length),s=e.length^t.length;for(let i=0;i<r;i++)s|=(e.charCodeAt(i)||0)^(t.charCodeAt(i)||0);return s===0}var zt=class extends y{constructor(e,t){super(e,t);}async resolve(e){let t=this.resolveTemplateScope(e),r=this.cacheKey("scanTemplates","resolve",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.resolveScanTemplate();return (await this.connection.execute(s,a.resolveScanTemplateVariables(t))).resolveScanTemplate})}async list(e){let t=this.resolveListScope(e),r=this.cacheKey("scanTemplates","list",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.scanTemplates();return (await this.connection.execute(s,a.scanTemplatesVariables(t))).scanTemplates?.templates??[]})}async create(e){this.config.requireSecretCredential("scanTemplates.create");let t=this.resolveSaveInput(e),{query:r}=a.createScanTemplate();return (await this.connection.execute(r,a.createScanTemplateVariables(t))).createScanTemplate}async update(e,t){this.config.requireSecretCredential("scanTemplates.update");let r=typeof e=="string"?e:e.id,s=typeof e=="string"?t:Wt(e);if(!s)throw new Error("scan template input is required");let i=this.resolveSaveInput(s),{query:n}=a.updateScanTemplate();return (await this.connection.execute(n,a.updateScanTemplateVariables(r,i))).updateScanTemplate}async preview(e){let t=this.resolvePreviewInput(e),{query:r}=a.previewScanTemplate();return (await this.connection.execute(r,a.previewScanTemplateVariables(t))).previewScanTemplate}resolveTemplateScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,templateId:e.templateId}}resolveListScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,includeArchived:e.includeArchived}}resolveSaveInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolvePreviewInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Wt(e){let t={...e};return delete t.id,t}var Ae=class Re{config;connection;publishers;games;datasets;records;decks;rules;rulesets;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new mt(t),this.connection=new kt(this.config),this.publishers=new St(this.connection,this.config),this.games=new At(this.connection,this.config),this.datasets=new Rt(this.connection,this.config),this.records=new Ct(this.connection,this.config),this.decks=new Et(this.connection,this.config),this.rules=new xt(this.connection,this.config),this.rulesets=new Ut(this.connection,this.config),this.importFormats=new Kt(this.connection,this.config),this.imports=new Tt(this.connection,this.config),this.exports=new Vt(this.connection,this.config),this.files=new Pt(this.connection,this.config),this.scans=new Mt(this.connection,this.config),this.scanTemplates=new zt(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return bt()}withConfig(t){let r=this.config.merge(t);return new Re({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 ee=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 Ee=class extends Ae{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new w("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new w("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
2051
+ export{H as AuthenticationError,y as BaseResource,ee as BrowserCache,Ee as CardDBClient,f as CardDBError,l as Collection,mt as Configuration,kt as Connection,T as ConnectionError,dt as DEFAULT_CACHE_TTL,ot as DEFAULT_ENDPOINT,yt as DEFAULT_MAX_NETWORK_RETRIES,ht as DEFAULT_MAX_RETRIES,lt as DEFAULT_OPEN_TIMEOUT,ft as DEFAULT_RETRY_BASE_DELAY,pt as DEFAULT_RETRY_MAX_DELAY,ut as DEFAULT_TIMEOUT,Rt as DatasetsResource,Et as DecksResource,Vt as ExportsResource,Pt as FilesResource,qe as FilterBuilder,At as GamesResource,ue as GraphQLError,Kt as ImportFormatsResource,Tt as ImportsResource,Zt as LinkResolutionError,Qt as NotFoundError,St as PublishersResource,a as QueryBuilder,L as RateLimitError,Ct as RecordsResource,w as RestrictedError,xt as RulesResource,Ut as RulesetsResource,zt as ScanTemplatesResource,Mt as ScansResource,z as ServerError,Y as TimeoutError,R as ValidationError,vt as cacheKey,or as contains,er as eq,bt as getRateLimitInfo,Ar as getSDKVersion,$t as getUserAgent,rr as gt,sr as gte,lr as ilike,hr as isNotNull,dr as isNull,ur as like,ir as lt,ar as lte,tr as neq,cr as notWithin,Dt as readCache,_ as resolveFilter,nr as within,wt as writeCache};//# sourceMappingURL=index.js.map
1844
2052
  //# sourceMappingURL=index.js.map