carddb 0.3.0 → 0.3.10

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.
@@ -109,6 +109,61 @@ module CardDB
109
109
  GRAPHQL
110
110
  end
111
111
 
112
+ def list_games(publisher_id:, first: nil, after: nil, include_archived: nil)
113
+ args = build_args(
114
+ { publisherId: publisher_id, first: first, after: after, includeArchived: include_archived },
115
+ required: [:publisherId]
116
+ )
117
+
118
+ <<~GRAPHQL
119
+ query Games#{args[:definition]} {
120
+ games#{args[:call]} {
121
+ #{game_connection_fields}
122
+ }
123
+ }
124
+ GRAPHQL
125
+ end
126
+
127
+ def game(id: nil, publisher_id: nil, publisher_slug: nil, game_key: nil, game_slug: nil)
128
+ args = build_args(
129
+ {
130
+ id: id,
131
+ publisherId: publisher_id,
132
+ publisherSlug: publisher_slug,
133
+ gameKey: game_key,
134
+ gameSlug: game_slug
135
+ }
136
+ )
137
+
138
+ <<~GRAPHQL
139
+ query Game#{args[:definition]} {
140
+ game#{args[:call]} {
141
+ #{game_fields}
142
+ }
143
+ }
144
+ GRAPHQL
145
+ end
146
+
147
+ def create_game
148
+ <<~GRAPHQL
149
+ mutation GameCreate($input: GameCreateInput!) {
150
+ gameCreate(input: $input) {
151
+ #{game_fields}
152
+ }
153
+ }
154
+ GRAPHQL
155
+ end
156
+
157
+ def update_game
158
+ <<~GRAPHQL
159
+ mutation GameUpdate($id: UUID!, $input: GameUpdateInput!) {
160
+ gameUpdate(id: $id, input: $input) {
161
+ #{game_fields}
162
+ }
163
+ }
164
+ GRAPHQL
165
+ end
166
+
112
167
  # Builds a searchDatasets query
113
168
  def search_datasets(publisher_slug: nil, game_key: nil, search: nil, purpose: nil, first: nil, after: nil)
114
169
  args = build_args({
@@ -164,6 +219,55 @@ module CardDB
164
219
  GRAPHQL
165
220
  end
166
221
 
222
+ def list_datasets(
223
+ publisher_id:,
224
+ game_id: nil,
225
+ purpose: nil,
226
+ first: nil,
227
+ after: nil,
228
+ include_archived: nil
229
+ )
230
+ args = build_args(
231
+ {
232
+ publisherId: publisher_id,
233
+ gameId: game_id,
234
+ purpose: purpose,
235
+ first: first,
236
+ after: after,
237
+ includeArchived: include_archived
238
+ },
239
+ required: [:publisherId]
240
+ )
241
+
242
+ <<~GRAPHQL
243
+ query Datasets#{args[:definition]} {
244
+ datasets#{args[:call]} {
245
+ #{dataset_connection_fields(include_schema: true)}
246
+ }
247
+ }
248
+ GRAPHQL
249
+ end
250
+
251
+ def dataset(id: nil, publisher_id: nil, game_id: nil, dataset_key: nil)
252
+ args = build_args(
253
+ {
254
+ id: id,
255
+ publisherId: publisher_id,
256
+ gameId: game_id,
257
+ datasetKey: dataset_key
258
+ }
259
+ )
260
+
261
+ <<~GRAPHQL
262
+ query Dataset#{args[:definition]} {
263
+ dataset#{args[:call]} {
264
+ #{dataset_fields}
265
+ #{schema_fields}
266
+ }
267
+ }
268
+ GRAPHQL
269
+ end
270
+
167
271
  # Builds a searchRecords query
168
272
  # rubocop:disable Metrics/ParameterLists
169
273
  def search_records(
@@ -219,34 +323,421 @@ module CardDB
219
323
  GRAPHQL
220
324
  end
221
325
 
222
- # Builds a fetchRecordsByIdentifier query
223
- def fetch_records_by_identifier(include_pricing: false)
326
+ # Builds a fetchRecordsByIdentifier query
327
+ def fetch_records_by_identifier(include_pricing: false)
328
+ <<~GRAPHQL
329
+ query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
330
+ fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
331
+ #{record_fields(include_pricing: include_pricing)}
332
+ }
333
+ }
334
+ GRAPHQL
335
+ end
336
+
337
+ # Builds a fetchRecord query
338
+ def fetch_record(include_pricing: false)
339
+ <<~GRAPHQL
340
+ query FetchRecord($id: UUID!) {
341
+ fetchRecord(id: $id) {
342
+ #{record_fields(include_pricing: include_pricing)}
343
+ }
344
+ }
345
+ GRAPHQL
346
+ end
347
+
348
+ # Builds a fetchRecords query
349
+ def fetch_records(include_pricing: false)
350
+ <<~GRAPHQL
351
+ query FetchRecords($ids: [UUID!]!) {
352
+ fetchRecords(ids: $ids) {
353
+ #{record_fields(include_pricing: include_pricing)}
354
+ }
355
+ }
356
+ GRAPHQL
357
+ end
358
+
359
+ def list_dataset_records(
360
+ dataset_id:,
361
+ filter: nil,
362
+ order_by: nil,
363
+ first: nil,
364
+ after: nil,
365
+ last: nil,
366
+ before: nil,
367
+ validate_schema: nil
368
+ )
369
+ args = build_args(
370
+ {
371
+ datasetId: dataset_id,
372
+ filter: filter,
373
+ orderBy: order_by,
374
+ first: first,
375
+ after: after,
376
+ last: last,
377
+ before: before,
378
+ validateSchema: validate_schema
379
+ },
380
+ required: [:datasetId],
381
+ type_overrides: { orderBy: 'DatasetRecordOrderByInput' }
382
+ )
383
+
384
+ <<~GRAPHQL
385
+ query DatasetRecords#{args[:definition]} {
386
+ datasetRecords#{args[:call]} {
387
+ #{record_connection_fields}
388
+ }
389
+ }
390
+ GRAPHQL
391
+ end
392
+
393
+ def dataset_record(**params)
394
+ args = build_args(
395
+ {
396
+ id: params[:id],
397
+ datasetId: params[:dataset_id],
398
+ identifier: params[:identifier],
399
+ publisherSlug: params[:publisher_slug],
400
+ gameKey: params[:game_key],
401
+ datasetKey: params[:dataset_key],
402
+ recordId: params[:record_id],
403
+ resolveLinks: params[:resolve_links],
404
+ validateSchema: params[:validate_schema]
405
+ }
406
+ )
407
+ include_links = params[:resolve_links]&.any?
408
+ links_fields = resolved_links_fields if include_links
409
+
410
+ <<~GRAPHQL
411
+ query DatasetRecord#{args[:definition]} {
412
+ datasetRecord#{args[:call]} {
413
+ #{record_fields(include_pricing: params.fetch(:include_pricing, false))}
414
+ #{links_fields}
415
+ }
416
+ }
417
+ GRAPHQL
418
+ end
419
+
420
+ def upsert_dataset_records
421
+ <<~GRAPHQL
422
+ mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
423
+ datasetRecordsUpsert(input: $input) {
424
+ #{dataset_records_upsert_payload_fields}
425
+ }
426
+ }
427
+ GRAPHQL
428
+ end
429
+
430
+ def delete_dataset_records
431
+ <<~GRAPHQL
432
+ mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
433
+ datasetRecordsDelete(input: $input) {
434
+ #{dataset_record_delete_job_fields}
435
+ }
436
+ }
437
+ GRAPHQL
438
+ end
439
+
440
+ def dataset_record_delete_job
441
+ <<~GRAPHQL
442
+ query DatasetRecordDeleteJob($id: UUID!) {
443
+ datasetRecordDeleteJob(id: $id) {
444
+ #{dataset_record_delete_job_fields}
445
+ }
446
+ }
447
+ GRAPHQL
448
+ end
449
+
450
+ def dataset_record_delete_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil)
451
+ args = build_args(
452
+ { publisherId: publisher_id, datasetId: dataset_id, status: status, first: first, after: after },
453
+ required: [:publisherId],
454
+ type_overrides: { status: 'DatasetRecordDeleteJobStatus' }
455
+ )
456
+
457
+ <<~GRAPHQL
458
+ query DatasetRecordDeleteJobs#{args[:definition]} {
459
+ datasetRecordDeleteJobs#{args[:call]} {
460
+ #{dataset_record_delete_job_connection_fields}
461
+ }
462
+ }
463
+ GRAPHQL
464
+ end
465
+
466
+ def dataset_import_preview
467
+ <<~GRAPHQL
468
+ query DatasetImportPreview($input: DatasetImportPreviewInput!) {
469
+ datasetImportPreview(input: $input) {
470
+ #{dataset_import_preview_fields}
471
+ }
472
+ }
473
+ GRAPHQL
474
+ end
475
+
476
+ def dataset_import_validate
477
+ <<~GRAPHQL
478
+ query DatasetImportValidate($input: DatasetImportValidateInput!) {
479
+ datasetImportValidate(input: $input) {
480
+ #{bulk_import_result_fields}
481
+ }
482
+ }
483
+ GRAPHQL
484
+ end
485
+
486
+ def dataset_import_from_file
487
+ <<~GRAPHQL
488
+ mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
489
+ datasetImportFromFile(input: $input) {
490
+ #{import_job_fields}
491
+ }
492
+ }
493
+ GRAPHQL
494
+ end
495
+
496
+ def dataset_import_from_payload
497
+ <<~GRAPHQL
498
+ mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
499
+ datasetImportFromPayload(input: $input) {
500
+ #{import_job_fields}
501
+ }
502
+ }
503
+ GRAPHQL
504
+ end
505
+
506
+ def dataset_import_from_url
507
+ <<~GRAPHQL
508
+ mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
509
+ datasetImportFromUrl(input: $input) {
510
+ #{import_job_fields}
511
+ }
512
+ }
513
+ GRAPHQL
514
+ end
515
+
516
+ def import_job
517
+ <<~GRAPHQL
518
+ query ImportJob($id: UUID!) {
519
+ importJob(id: $id) {
520
+ #{import_job_fields}
521
+ }
522
+ }
523
+ GRAPHQL
524
+ end
525
+
526
+ def import_jobs(publisher_id:, dataset_id: nil, status: nil, first: nil, after: nil)
527
+ args = build_args(
528
+ { publisherId: publisher_id, datasetId: dataset_id, status: status, first: first, after: after },
529
+ required: [:publisherId],
530
+ type_overrides: { status: 'ImportJobStatus' }
531
+ )
532
+
533
+ <<~GRAPHQL
534
+ query ImportJobs#{args[:definition]} {
535
+ importJobs#{args[:call]} {
536
+ #{import_job_connection_fields}
537
+ }
538
+ }
539
+ GRAPHQL
540
+ end
541
+
542
+ def import_job_cancel
543
+ <<~GRAPHQL
544
+ mutation ImportJobCancel($id: UUID!) {
545
+ importJobCancel(id: $id) {
546
+ #{import_job_fields}
547
+ }
548
+ }
549
+ GRAPHQL
550
+ end
551
+
552
+ def import_job_logs(level: nil, dataset_key: nil, first: nil, after: nil)
553
+ log_args = build_args(
554
+ { level: level, datasetKey: dataset_key, first: first, after: after },
555
+ type_overrides: { level: 'ImportLogLevel' }
556
+ )
557
+
558
+ <<~GRAPHQL
559
+ query ImportJobLogs($importJobId: UUID!#{log_args[:definition].sub('(', ', ').sub(')', '')}) {
560
+ importJob(id: $importJobId) {
561
+ logs#{log_args[:call]} {
562
+ #{import_job_log_connection_fields}
563
+ }
564
+ }
565
+ }
566
+ GRAPHQL
567
+ end
568
+
569
+ def game_import_preview
570
+ <<~GRAPHQL
571
+ query GameImportPreview($input: GameImportPreviewInput!) {
572
+ gameImportPreview(input: $input) {
573
+ #{game_import_preview_fields}
574
+ }
575
+ }
576
+ GRAPHQL
577
+ end
578
+
579
+ def game_import_from_file
580
+ <<~GRAPHQL
581
+ mutation GameImportFromFile($input: GameImportFromFileInput!) {
582
+ gameImportFromFile(input: $input) {
583
+ #{game_import_job_fields}
584
+ }
585
+ }
586
+ GRAPHQL
587
+ end
588
+
589
+ def game_import_from_payload
590
+ <<~GRAPHQL
591
+ mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
592
+ gameImportFromPayload(input: $input) {
593
+ #{game_import_job_fields}
594
+ }
595
+ }
596
+ GRAPHQL
597
+ end
598
+
599
+ def game_import_from_url
600
+ <<~GRAPHQL
601
+ mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
602
+ gameImportFromUrl(input: $input) {
603
+ #{game_import_job_fields}
604
+ }
605
+ }
606
+ GRAPHQL
607
+ end
608
+
609
+ def game_import_job
610
+ <<~GRAPHQL
611
+ query GameImportJob($id: UUID!) {
612
+ gameImportJob(id: $id) {
613
+ #{game_import_job_fields}
614
+ }
615
+ }
616
+ GRAPHQL
617
+ end
618
+
619
+ def game_import_jobs(game_id:, status: nil, first: nil, after: nil)
620
+ args = build_args(
621
+ { gameId: game_id, status: status, first: first, after: after },
622
+ required: [:gameId],
623
+ type_overrides: { status: 'ImportJobStatus' }
624
+ )
625
+
626
+ <<~GRAPHQL
627
+ query GameImportJobs#{args[:definition]} {
628
+ gameImportJobs#{args[:call]} {
629
+ #{game_import_job_connection_fields}
630
+ }
631
+ }
632
+ GRAPHQL
633
+ end
634
+
635
+ def game_import_job_cancel
636
+ <<~GRAPHQL
637
+ mutation GameImportJobCancel($id: UUID!) {
638
+ gameImportJobCancel(id: $id) {
639
+ #{game_import_job_fields}
640
+ }
641
+ }
642
+ GRAPHQL
643
+ end
644
+
645
+ def file
646
+ <<~GRAPHQL
647
+ query File($id: UUID!) {
648
+ file(id: $id) {
649
+ #{file_fields}
650
+ }
651
+ }
652
+ GRAPHQL
653
+ end
654
+
655
+ def file_upload_request
656
+ <<~GRAPHQL
657
+ mutation FileUploadRequest($input: FileUploadInput!) {
658
+ fileUploadRequest(input: $input) {
659
+ #{presigned_upload_fields}
660
+ }
661
+ }
662
+ GRAPHQL
663
+ end
664
+
665
+ def file_upload_confirm
666
+ <<~GRAPHQL
667
+ mutation FileUploadConfirm($id: UUID!) {
668
+ fileUploadConfirm(id: $id) {
669
+ #{file_fields}
670
+ }
671
+ }
672
+ GRAPHQL
673
+ end
674
+
675
+ def file_delete
676
+ <<~GRAPHQL
677
+ mutation FileDelete($id: UUID!) {
678
+ fileDelete(id: $id)
679
+ }
680
+ GRAPHQL
681
+ end
682
+
683
+ def export_job
684
+ <<~GRAPHQL
685
+ query ExportJob($id: UUID!) {
686
+ exportJob(id: $id) {
687
+ #{export_job_fields}
688
+ }
689
+ }
690
+ GRAPHQL
691
+ end
692
+
693
+ def export_jobs(publisher_id:, game_id: nil, dataset_id: nil, status: nil, first: nil, after: nil)
694
+ args = build_args(
695
+ {
696
+ publisherId: publisher_id,
697
+ gameId: game_id,
698
+ datasetId: dataset_id,
699
+ status: status,
700
+ first: first,
701
+ after: after
702
+ },
703
+ required: [:publisherId],
704
+ type_overrides: { status: 'ExportJobStatus' }
705
+ )
706
+
707
+ <<~GRAPHQL
708
+ query ExportJobs#{args[:definition]} {
709
+ exportJobs#{args[:call]} {
710
+ #{export_job_connection_fields}
711
+ }
712
+ }
713
+ GRAPHQL
714
+ end
715
+
716
+ def dataset_export
224
717
  <<~GRAPHQL
225
- query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
226
- fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
227
- #{record_fields(include_pricing: include_pricing)}
718
+ mutation DatasetExport($input: DatasetExportInput!) {
719
+ datasetExport(input: $input) {
720
+ #{export_job_fields}
228
721
  }
229
722
  }
230
723
  GRAPHQL
231
724
  end
232
725
 
233
- # Builds a fetchRecord query
234
- def fetch_record(include_pricing: false)
726
+ def export_job_cancel
235
727
  <<~GRAPHQL
236
- query FetchRecord($id: UUID!) {
237
- fetchRecord(id: $id) {
238
- #{record_fields(include_pricing: include_pricing)}
728
+ mutation ExportJobCancel($id: UUID!) {
729
+ exportJobCancel(id: $id) {
730
+ #{export_job_fields}
239
731
  }
240
732
  }
241
733
  GRAPHQL
242
734
  end
243
735
 
244
- # Builds a fetchRecords query
245
- def fetch_records(include_pricing: false)
736
+ def export_job_refresh_url
246
737
  <<~GRAPHQL
247
- query FetchRecords($ids: [UUID!]!) {
248
- fetchRecords(ids: $ids) {
249
- #{record_fields(include_pricing: include_pricing)}
738
+ mutation ExportJobRefreshUrl($id: UUID!) {
739
+ exportJobRefreshUrl(id: $id) {
740
+ #{export_job_fields}
250
741
  }
251
742
  }
252
743
  GRAPHQL
@@ -569,10 +1060,9 @@ module CardDB
569
1060
  GRAPHQL
570
1061
  end
571
1062
 
572
- def deck_import_formats(game_id:, include_archived: nil, first: nil, after: nil)
1063
+ def deck_import_formats(publisher_id: nil, game_id: nil, include_archived: nil, first: nil, after: nil)
573
1064
  args = build_args(
574
- { gameId: game_id, includeArchived: include_archived, first: first, after: after },
575
- required: [:gameId]
1065
+ { publisherId: publisher_id, gameId: game_id, includeArchived: include_archived, first: first, after: after }
576
1066
  )
577
1067
 
578
1068
  <<~GRAPHQL
@@ -586,8 +1076,8 @@ module CardDB
586
1076
 
587
1077
  def deck_import_format
588
1078
  <<~GRAPHQL
589
- query DeckImportFormat($id: UUID!) {
590
- deckImportFormat(id: $id) {
1079
+ query DeckImportFormat($id: UUID, $gameId: UUID, $key: String) {
1080
+ deckImportFormat(id: $id, gameId: $gameId, key: $key) {
591
1081
  #{deck_import_format_definition_fields}
592
1082
  }
593
1083
  }
@@ -926,6 +1416,30 @@ module CardDB
926
1416
  GRAPHQL
927
1417
  end
928
1418
 
1419
+ def exchange_deck_session_token
1420
+ <<~GRAPHQL
1421
+ mutation DeckSessionTokenExchange($input: DeckSessionTokenExchangeInput!) {
1422
+ deckSessionTokenExchange(input: $input) {
1423
+ token
1424
+ sessionToken {
1425
+ id
1426
+ accountId
1427
+ apiApplicationId
1428
+ gameId
1429
+ environment
1430
+ externalSubject
1431
+ scopes
1432
+ expiresAt
1433
+ revokedAt
1434
+ lastUsedAt
1435
+ createdAt
1436
+ updatedAt
1437
+ }
1438
+ }
1439
+ }
1440
+ GRAPHQL
1441
+ end
1442
+
929
1443
  def revoke_deck_access_token
930
1444
  <<~GRAPHQL
931
1445
  mutation DeckAccessTokenRevoke($id: UUID!) {
@@ -990,6 +1504,7 @@ module CardDB
990
1504
 
991
1505
  private
992
1506
 
1507
+ # rubocop:disable Metrics/MethodLength
993
1508
  def build_args(params, required: [], type_overrides: {})
994
1509
  # Filter out nil values
995
1510
  params = params.compact
@@ -999,14 +1514,21 @@ module CardDB
999
1514
  # Map Ruby types to GraphQL types (base types, without !)
1000
1515
  type_map = {
1001
1516
  publisherSlug: 'String',
1517
+ publisherId: 'UUID',
1002
1518
  gameKey: 'String',
1519
+ gameSlug: 'String',
1003
1520
  datasetKey: 'String',
1521
+ datasetId: 'UUID',
1522
+ recordId: 'UUID',
1523
+ identifier: 'String',
1004
1524
  search: 'String',
1005
1525
  orderBy: 'String',
1006
1526
  filter: 'JSON',
1007
1527
  resolveLinks: '[String!]',
1008
1528
  first: 'Int',
1009
1529
  after: 'String',
1530
+ last: 'Int',
1531
+ before: 'String',
1010
1532
  includeArchived: 'Boolean',
1011
1533
  externalRef: 'String',
1012
1534
  deckId: 'UUID!',
@@ -1015,6 +1537,9 @@ module CardDB
1015
1537
  rulesetVersionId: 'UUID',
1016
1538
  validateSchema: 'Boolean',
1017
1539
  purpose: 'DatasetPurpose',
1540
+ status: 'String',
1541
+ level: 'String',
1542
+ key: 'String',
1018
1543
  id: 'UUID!',
1019
1544
  ids: '[UUID!]!'
1020
1545
  }
@@ -1032,6 +1557,34 @@ module CardDB
1032
1557
  call: "(#{calls.join(', ')})"
1033
1558
  }
1034
1559
  end
1560
+ # rubocop:enable Metrics/MethodLength
1561
+
1562
+ def file_fields
1563
+ <<~FIELDS
1564
+ id
1565
+ createdAt
1566
+ updatedAt
1567
+ key
1568
+ filename
1569
+ contentType
1570
+ size
1571
+ status
1572
+ isPublic
1573
+ entityType
1574
+ entityId
1575
+ url
1576
+ FIELDS
1577
+ end
1578
+
1579
+ def presigned_upload_fields
1580
+ <<~FIELDS
1581
+ file {
1582
+ #{file_fields}
1583
+ }
1584
+ uploadUrl
1585
+ expiresAt
1586
+ FIELDS
1587
+ end
1035
1588
 
1036
1589
  def publisher_fields
1037
1590
  <<~FIELDS
@@ -1079,8 +1632,11 @@ module CardDB
1079
1632
  key
1080
1633
  name
1081
1634
  description
1635
+ metafyGameUuid
1636
+ metafyGameSlug
1082
1637
  website
1083
1638
  visibility
1639
+ archivedAt
1084
1640
  isArchived
1085
1641
  createdAt
1086
1642
  updatedAt
@@ -1127,8 +1683,13 @@ module CardDB
1127
1683
  name
1128
1684
  description
1129
1685
  purpose
1686
+ activeVersionId
1130
1687
  tcgplayerProductIdFieldKey
1131
1688
  visibility
1689
+ posX
1690
+ posY
1691
+ sortOrder
1692
+ archivedAt
1132
1693
  isArchived
1133
1694
  createdAt
1134
1695
  updatedAt
@@ -1159,11 +1720,16 @@ module CardDB
1159
1720
  targetDatasetKey
1160
1721
  targetDatasetName
1161
1722
  targetDatasetId
1723
+ targetFieldKey
1724
+ linkAlias
1725
+ linkDirection
1726
+ isArray
1162
1727
  }
1163
1728
  }
1164
1729
  FIELDS
1165
1730
  end
1166
1731
 
1732
+ # rubocop:disable Metrics/MethodLength
1167
1733
  def field_info_fields(depth:)
1168
1734
  nested_fields = if depth.positive?
1169
1735
  <<~FIELDS
@@ -1182,15 +1748,36 @@ module CardDB
1182
1748
  filterable
1183
1749
  searchable
1184
1750
  isIdentifier
1751
+ sortOrder
1185
1752
  itemType
1753
+ linkDatasetId
1754
+ linkDatasetKey
1755
+ linkDatasetName
1756
+ linkFieldKey
1757
+ linkAlias
1758
+ linkDirection
1186
1759
  displayFormat
1187
1760
  semanticType
1761
+ placeholder
1762
+ isHidden
1763
+ isComputed
1764
+ isSystemField
1765
+ defaultValue
1188
1766
  allowedValues
1767
+ minLength
1768
+ maxLength
1769
+ minValue
1770
+ maxValue
1771
+ pattern
1772
+ isUnique
1189
1773
  #{nested_fields}
1190
1774
  FIELDS
1191
1775
  end
1776
+ # rubocop:enable Metrics/MethodLength
1777
+
1778
+ def dataset_connection_fields(include_schema: false)
1779
+ node_fields = include_schema ? "#{dataset_fields}\n#{schema_fields}" : dataset_fields
1192
1780
 
1193
- def dataset_connection_fields
1194
1781
  <<~FIELDS
1195
1782
  totalCount
1196
1783
  pageInfo {
@@ -1202,7 +1789,7 @@ module CardDB
1202
1789
  edges {
1203
1790
  cursor
1204
1791
  node {
1205
- #{dataset_fields}
1792
+ #{node_fields}
1206
1793
  }
1207
1794
  }
1208
1795
  FIELDS
@@ -1245,22 +1832,7 @@ module CardDB
1245
1832
  end
1246
1833
 
1247
1834
  def record_connection_fields(include_resolved_links: false, include_pricing: false)
1248
- resolved_links_field = if include_resolved_links
1249
- <<~FIELDS
1250
- resolvedLinks {
1251
- field
1252
- linkFieldKey
1253
- values
1254
- records {
1255
- id
1256
- datasetId
1257
- data
1258
- }
1259
- }
1260
- FIELDS
1261
- else
1262
- ''
1263
- end
1835
+ resolved_links_field = include_resolved_links ? resolved_links_fields : ''
1264
1836
 
1265
1837
  <<~FIELDS
1266
1838
  totalCount
@@ -1280,6 +1852,444 @@ module CardDB
1280
1852
  FIELDS
1281
1853
  end
1282
1854
 
1855
+ def resolved_links_fields
1856
+ <<~FIELDS
1857
+ resolvedLinks {
1858
+ field
1859
+ linkFieldKey
1860
+ values
1861
+ records {
1862
+ id
1863
+ datasetId
1864
+ data
1865
+ }
1866
+ }
1867
+ FIELDS
1868
+ end
1869
+
1870
+ def object_field_fields
1871
+ <<~FIELDS
1872
+ id
1873
+ objectTypeId
1874
+ key
1875
+ label
1876
+ dataType
1877
+ isRequired
1878
+ isFilterable
1879
+ isSearchable
1880
+ isIdentifier
1881
+ sortOrder
1882
+ description
1883
+ placeholder
1884
+ displayFormat
1885
+ semanticType
1886
+ isHidden
1887
+ isComputed
1888
+ isSystemField
1889
+ defaultValue
1890
+ allowedValues
1891
+ minLength
1892
+ maxLength
1893
+ minValue
1894
+ maxValue
1895
+ pattern
1896
+ isUnique
1897
+ itemType
1898
+ linkDatasetId
1899
+ linkFieldKey
1900
+ linkAlias
1901
+ linkDirection
1902
+ parentFieldId
1903
+ createdAt
1904
+ updatedAt
1905
+ FIELDS
1906
+ end
1907
+
1908
+ def bulk_record_error_fields
1909
+ <<~FIELDS
1910
+ datasetKey
1911
+ index
1912
+ errors {
1913
+ field
1914
+ message
1915
+ details
1916
+ }
1917
+ FIELDS
1918
+ end
1919
+
1920
+ def import_stats_fields
1921
+ <<~FIELDS
1922
+ total
1923
+ inserted
1924
+ updated
1925
+ skipped
1926
+ failed
1927
+ FIELDS
1928
+ end
1929
+
1930
+ def bulk_import_result_fields
1931
+ <<~FIELDS
1932
+ inserted {
1933
+ #{record_fields}
1934
+ }
1935
+ updated {
1936
+ #{record_fields}
1937
+ }
1938
+ skipped
1939
+ errors {
1940
+ #{bulk_record_error_fields}
1941
+ }
1942
+ createdFields {
1943
+ #{object_field_fields}
1944
+ }
1945
+ stats {
1946
+ #{import_stats_fields}
1947
+ }
1948
+ FIELDS
1949
+ end
1950
+
1951
+ def import_job_asset_fields
1952
+ <<~FIELDS
1953
+ fileId
1954
+ filename
1955
+ file {
1956
+ #{file_fields}
1957
+ }
1958
+ FIELDS
1959
+ end
1960
+
1961
+ def import_job_fields
1962
+ <<~FIELDS
1963
+ id
1964
+ publisherId
1965
+ publisher {
1966
+ #{publisher_fields}
1967
+ }
1968
+ datasetId
1969
+ dataset {
1970
+ #{dataset_fields}
1971
+ #{schema_fields}
1972
+ }
1973
+ accountId
1974
+ status
1975
+ mode
1976
+ onConflict
1977
+ format
1978
+ fileId
1979
+ progress
1980
+ totalRecords
1981
+ processedRecords
1982
+ insertedCount
1983
+ updatedCount
1984
+ skippedCount
1985
+ failedCount
1986
+ createdFields {
1987
+ #{object_field_fields}
1988
+ }
1989
+ errors {
1990
+ #{bulk_record_error_fields}
1991
+ }
1992
+ errorMessage
1993
+ assets {
1994
+ #{import_job_asset_fields}
1995
+ }
1996
+ startedAt
1997
+ completedAt
1998
+ createdAt
1999
+ updatedAt
2000
+ lastCheckpointIndex
2001
+ isResumed
2002
+ imagesPending
2003
+ imagesCompleted
2004
+ imagesFailed
2005
+ FIELDS
2006
+ end
2007
+
2008
+ def import_job_log_fields
2009
+ <<~FIELDS
2010
+ id
2011
+ importJobId
2012
+ level
2013
+ message
2014
+ datasetKey
2015
+ recordIndex
2016
+ fieldKey
2017
+ details
2018
+ createdAt
2019
+ FIELDS
2020
+ end
2021
+
2022
+ def dataset_records_upsert_payload_fields
2023
+ <<~FIELDS
2024
+ job {
2025
+ #{import_job_fields}
2026
+ }
2027
+ dryRunResult {
2028
+ #{bulk_import_result_fields}
2029
+ }
2030
+ FIELDS
2031
+ end
2032
+
2033
+ def dataset_record_delete_job_result_fields
2034
+ <<~FIELDS
2035
+ target
2036
+ recordId
2037
+ identifier
2038
+ status
2039
+ message
2040
+ FIELDS
2041
+ end
2042
+
2043
+ def dataset_record_delete_job_fields
2044
+ <<~FIELDS
2045
+ id
2046
+ publisherId
2047
+ publisher {
2048
+ #{publisher_fields}
2049
+ }
2050
+ datasetId
2051
+ dataset {
2052
+ #{dataset_fields}
2053
+ }
2054
+ accountId
2055
+ status
2056
+ targetType
2057
+ dryRun
2058
+ targets
2059
+ progress
2060
+ totalTargets
2061
+ processedTargets
2062
+ matchedCount
2063
+ deletedCount
2064
+ missingCount
2065
+ blockedCount
2066
+ failedCount
2067
+ results {
2068
+ #{dataset_record_delete_job_result_fields}
2069
+ }
2070
+ errorMessage
2071
+ startedAt
2072
+ completedAt
2073
+ createdAt
2074
+ updatedAt
2075
+ FIELDS
2076
+ end
2077
+
2078
+ def field_mapping_fields
2079
+ <<~FIELDS
2080
+ sourceField
2081
+ targetField
2082
+ targetFieldLabel
2083
+ inferredType
2084
+ inferredItemType
2085
+ inferredChildren {
2086
+ key
2087
+ label
2088
+ type
2089
+ required
2090
+ itemType
2091
+ children {
2092
+ key
2093
+ label
2094
+ type
2095
+ required
2096
+ itemType
2097
+ }
2098
+ }
2099
+ inferredLinkDataset
2100
+ inferredLinkFieldKey
2101
+ inferredLinkDirection
2102
+ targetFieldType
2103
+ sampleValues
2104
+ status
2105
+ FIELDS
2106
+ end
2107
+
2108
+ def import_warning_fields
2109
+ <<~FIELDS
2110
+ datasetKey
2111
+ field
2112
+ message
2113
+ severity
2114
+ FIELDS
2115
+ end
2116
+
2117
+ def dataset_import_preview_fields
2118
+ <<~FIELDS
2119
+ datasetKey
2120
+ datasetName
2121
+ datasetId
2122
+ exists
2123
+ recordCount
2124
+ fieldMappings {
2125
+ #{field_mapping_fields}
2126
+ }
2127
+ warnings {
2128
+ #{import_warning_fields}
2129
+ }
2130
+ canProceed
2131
+ sampleRecords
2132
+ availableDatasets {
2133
+ #{dataset_fields}
2134
+ #{schema_fields}
2135
+ }
2136
+ FIELDS
2137
+ end
2138
+
2139
+ def game_import_preview_fields
2140
+ <<~FIELDS
2141
+ datasets {
2142
+ datasetKey
2143
+ datasetName
2144
+ datasetId
2145
+ exists
2146
+ recordCount
2147
+ fieldMappings {
2148
+ #{field_mapping_fields}
2149
+ }
2150
+ warnings {
2151
+ #{import_warning_fields}
2152
+ }
2153
+ sampleRecords
2154
+ }
2155
+ importOrder
2156
+ warnings {
2157
+ #{import_warning_fields}
2158
+ }
2159
+ canProceed
2160
+ FIELDS
2161
+ end
2162
+
2163
+ def game_import_dataset_status_fields
2164
+ <<~FIELDS
2165
+ datasetKey
2166
+ datasetId
2167
+ datasetName
2168
+ status
2169
+ recordCount
2170
+ insertedCount
2171
+ updatedCount
2172
+ skippedCount
2173
+ failedCount
2174
+ errorMessage
2175
+ FIELDS
2176
+ end
2177
+
2178
+ def game_import_job_fields
2179
+ <<~FIELDS
2180
+ id
2181
+ publisherId
2182
+ publisher {
2183
+ #{publisher_fields}
2184
+ }
2185
+ gameId
2186
+ game {
2187
+ #{game_fields}
2188
+ }
2189
+ accountId
2190
+ status
2191
+ mode
2192
+ onConflict
2193
+ fileId
2194
+ assets {
2195
+ #{import_job_asset_fields}
2196
+ }
2197
+ totalDatasets
2198
+ completedDatasets
2199
+ progress
2200
+ importOrder
2201
+ datasetStatuses {
2202
+ #{game_import_dataset_status_fields}
2203
+ }
2204
+ errorMessage
2205
+ startedAt
2206
+ completedAt
2207
+ createdAt
2208
+ updatedAt
2209
+ completedDatasetKeys
2210
+ currentDatasetKey
2211
+ lastCheckpointIndex
2212
+ isResumed
2213
+ imagesPending
2214
+ imagesCompleted
2215
+ imagesFailed
2216
+ phase
2217
+ linkBuildingDataset
2218
+ linkBuildingTotalDatasets
2219
+ linkBuildingCompletedDatasets
2220
+ linkBuildingProcessedRecords
2221
+ linkBuildingTotalRecords
2222
+ FIELDS
2223
+ end
2224
+
2225
+ def export_job_fields
2226
+ <<~FIELDS
2227
+ id
2228
+ publisherId
2229
+ publisher {
2230
+ #{publisher_fields}
2231
+ }
2232
+ datasetId
2233
+ dataset {
2234
+ #{dataset_fields}
2235
+ }
2236
+ accountId
2237
+ status
2238
+ format
2239
+ filter
2240
+ totalRecords
2241
+ processedRecords
2242
+ progress
2243
+ fileId
2244
+ downloadUrl
2245
+ downloadExpiresAt
2246
+ errorMessage
2247
+ startedAt
2248
+ completedAt
2249
+ createdAt
2250
+ updatedAt
2251
+ lastCheckpointIndex
2252
+ FIELDS
2253
+ end
2254
+
2255
+ def import_job_connection_fields
2256
+ connection_fields(import_job_fields)
2257
+ end
2258
+
2259
+ def import_job_log_connection_fields
2260
+ connection_fields(import_job_log_fields)
2261
+ end
2262
+
2263
+ def game_import_job_connection_fields
2264
+ connection_fields(game_import_job_fields)
2265
+ end
2266
+
2267
+ def dataset_record_delete_job_connection_fields
2268
+ connection_fields(dataset_record_delete_job_fields)
2269
+ end
2270
+
2271
+ def export_job_connection_fields
2272
+ connection_fields(export_job_fields)
2273
+ end
2274
+
2275
+ def connection_fields(node_fields)
2276
+ <<~FIELDS
2277
+ totalCount
2278
+ pageInfo {
2279
+ hasNextPage
2280
+ hasPreviousPage
2281
+ startCursor
2282
+ endCursor
2283
+ }
2284
+ edges {
2285
+ cursor
2286
+ node {
2287
+ #{node_fields}
2288
+ }
2289
+ }
2290
+ FIELDS
2291
+ end
2292
+
1283
2293
  def deck_section_definition_fields
1284
2294
  <<~FIELDS
1285
2295
  key