@carddb/core 0.4.2 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -250,6 +250,47 @@ function resolveFilter(input) {
250
250
  }
251
251
 
252
252
  // src/query-builder.ts
253
+ var DECK_JSON_OBJECT_KEYS = /* @__PURE__ */ new Set(["metadata", "annotations"]);
254
+ function normalizeDeckJsonInput(input) {
255
+ return normalizeDeckJsonValue(input, "input");
256
+ }
257
+ function normalizeDeckJsonValue(value, path) {
258
+ if (!isRecord(value)) {
259
+ return value;
260
+ }
261
+ const normalized = {};
262
+ for (const [key, child] of Object.entries(value)) {
263
+ const childPath = `${path}.${key}`;
264
+ if (DECK_JSON_OBJECT_KEYS.has(key)) {
265
+ normalized[key] = normalizeJsonObject(child, childPath);
266
+ } else if (key === "entries" && Array.isArray(child)) {
267
+ normalized[key] = child.map(
268
+ (entry, index) => normalizeDeckJsonValue(entry, `${childPath}[${index}]`)
269
+ );
270
+ } else {
271
+ normalized[key] = child;
272
+ }
273
+ }
274
+ return normalized;
275
+ }
276
+ function normalizeJsonObject(value, path) {
277
+ if (value == null || isRecord(value)) {
278
+ return value;
279
+ }
280
+ if (typeof value === "string") {
281
+ try {
282
+ const parsed = JSON.parse(value);
283
+ if (isRecord(parsed)) {
284
+ return parsed;
285
+ }
286
+ } catch {
287
+ }
288
+ }
289
+ throw new ValidationError(`${path} must be a JSON object`);
290
+ }
291
+ function isRecord(value) {
292
+ return typeof value === "object" && value !== null && !Array.isArray(value);
293
+ }
253
294
  var FILE_FIELDS = `
254
295
  id
255
296
  createdAt
@@ -590,36 +631,12 @@ var DECK_COLLABORATOR_FIELDS = `
590
631
  createdAt
591
632
  updatedAt
592
633
  `;
593
- var DECK_PREVIEW_TOKEN_FIELDS = `
634
+ var DECK_TOKEN_ISSUER_FIELDS = `
594
635
  id
595
- deckId
596
- label
597
- expiresAt
598
- revokedAt
599
- lastUsedAt
600
- createdAt
601
- updatedAt
602
- `;
603
- var DECK_EMBED_TOKEN_FIELDS = `
604
- id
605
- deckId
606
- apiApplicationId
607
- label
608
- readMode
609
- allowedOrigins
610
- externalSubject
611
- expiresAt
612
- revokedAt
613
- lastUsedAt
614
- createdAt
615
- updatedAt
616
- `;
617
- var DECK_ACCESS_TOKEN_ISSUER_FIELDS = `
618
- id
619
- deckId
620
636
  apiApplicationId
621
637
  label
622
- readModes
638
+ allowedScopes
639
+ allowedRepresentations
623
640
  maxTokenLifetimeSeconds
624
641
  directSigningAlg
625
642
  directSigningKeyId
@@ -629,13 +646,15 @@ var DECK_ACCESS_TOKEN_ISSUER_FIELDS = `
629
646
  createdAt
630
647
  updatedAt
631
648
  `;
632
- var DECK_ACCESS_TOKEN_FIELDS = `
649
+ var DECK_TOKEN_FIELDS = `
633
650
  id
634
- deckId
635
651
  apiApplicationId
636
652
  issuerId
637
- readMode
653
+ deckId
654
+ gameId
638
655
  externalSubject
656
+ scopes
657
+ representation
639
658
  expiresAt
640
659
  revokedAt
641
660
  lastUsedAt
@@ -2759,8 +2778,8 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2759
2778
  deckById() {
2760
2779
  return {
2761
2780
  query: `
2762
- query Deck($id: UUID!) {
2763
- deck(id: $id) {
2781
+ query Deck($id: UUID!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
2782
+ deck(id: $id, readState: $readState, version: $version) {
2764
2783
  ${DECK_FIELDS}
2765
2784
  }
2766
2785
  }
@@ -2814,8 +2833,8 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2814
2833
  deckByExternalRef() {
2815
2834
  return {
2816
2835
  query: `
2817
- query DeckByExternalRef($externalRef: String!) {
2818
- deckByExternalRef(externalRef: $externalRef) {
2836
+ query DeckByExternalRef($externalRef: String!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
2837
+ deckByExternalRef(externalRef: $externalRef, readState: $readState, version: $version) {
2819
2838
  ${DECK_FIELDS}
2820
2839
  }
2821
2840
  }
@@ -2858,39 +2877,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2858
2877
  variables
2859
2878
  };
2860
2879
  },
2861
- deckPreview() {
2862
- return {
2863
- query: `
2864
- query DeckPreview($token: String!) {
2865
- deckPreview(token: $token) {
2866
- ${DECK_FIELDS}
2867
- }
2868
- }
2869
- `
2870
- };
2871
- },
2872
- deckEmbed() {
2873
- return {
2874
- query: `
2875
- query DeckEmbed($token: String!) {
2876
- deckEmbed(token: $token) {
2877
- ${DECK_FIELDS}
2878
- }
2879
- }
2880
- `
2881
- };
2882
- },
2883
- deckAccess() {
2884
- return {
2885
- query: `
2886
- query DeckAccess($token: String!) {
2887
- deckAccess(token: $token) {
2888
- ${DECK_FIELDS}
2889
- }
2890
- }
2891
- `
2892
- };
2893
- },
2894
2880
  deckDraftDiff() {
2895
2881
  return {
2896
2882
  query: `
@@ -2999,28 +2985,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2999
2985
  `
3000
2986
  };
3001
2987
  },
3002
- deckEmbedTokens() {
3003
- return {
3004
- query: `
3005
- query DeckEmbedTokens($deckId: UUID!) {
3006
- deckEmbedTokens(deckId: $deckId) {
3007
- ${DECK_EMBED_TOKEN_FIELDS}
3008
- }
3009
- }
3010
- `
3011
- };
3012
- },
3013
- deckAccessTokenIssuers() {
3014
- return {
3015
- query: `
3016
- query DeckAccessTokenIssuers($deckId: UUID!) {
3017
- deckAccessTokenIssuers(deckId: $deckId) {
3018
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3019
- }
3020
- }
3021
- `
3022
- };
3023
- },
3024
2988
  deckApiApplicationAccesses() {
3025
2989
  return {
3026
2990
  query: `
@@ -3107,17 +3071,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3107
3071
  `
3108
3072
  };
3109
3073
  },
3110
- deckPreviewTokens() {
3111
- return {
3112
- query: `
3113
- query DeckPreviewTokens($deckId: UUID!) {
3114
- deckPreviewTokens(deckId: $deckId) {
3115
- ${DECK_PREVIEW_TOKEN_FIELDS}
3116
- }
3117
- }
3118
- `
3119
- };
3120
- },
3121
3074
  createDeck() {
3122
3075
  return {
3123
3076
  query: `
@@ -3382,120 +3335,58 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3382
3335
  `
3383
3336
  };
3384
3337
  },
3385
- createDeckPreviewToken() {
3386
- return {
3387
- query: `
3388
- mutation DeckPreviewTokenCreate($input: DeckPreviewTokenCreateInput!) {
3389
- deckPreviewTokenCreate(input: $input) {
3390
- token
3391
- previewToken {
3392
- ${DECK_PREVIEW_TOKEN_FIELDS}
3393
- }
3394
- }
3395
- }
3396
- `
3397
- };
3398
- },
3399
- revokeDeckPreviewToken() {
3400
- return {
3401
- query: `
3402
- mutation DeckPreviewTokenRevoke($id: UUID!) {
3403
- deckPreviewTokenRevoke(id: $id)
3404
- }
3405
- `
3406
- };
3407
- },
3408
- createDeckEmbedToken() {
3409
- return {
3410
- query: `
3411
- mutation DeckEmbedTokenCreate($input: DeckEmbedTokenCreateInput!) {
3412
- deckEmbedTokenCreate(input: $input) {
3413
- token
3414
- embedToken {
3415
- ${DECK_EMBED_TOKEN_FIELDS}
3416
- }
3417
- }
3418
- }
3419
- `
3420
- };
3421
- },
3422
- revokeDeckEmbedToken() {
3338
+ createDeckTokenIssuer() {
3423
3339
  return {
3424
3340
  query: `
3425
- mutation DeckEmbedTokenRevoke($id: UUID!) {
3426
- deckEmbedTokenRevoke(id: $id)
3427
- }
3428
- `
3429
- };
3430
- },
3431
- createDeckAccessTokenIssuer() {
3432
- return {
3433
- query: `
3434
- mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
3435
- deckAccessTokenIssuerCreate(input: $input) {
3436
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3341
+ mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
3342
+ deckTokenIssuerCreate(input: $input) {
3343
+ ${DECK_TOKEN_ISSUER_FIELDS}
3437
3344
  }
3438
3345
  }
3439
3346
  `
3440
3347
  };
3441
3348
  },
3442
- revokeDeckAccessTokenIssuer() {
3349
+ revokeDeckTokenIssuer() {
3443
3350
  return {
3444
3351
  query: `
3445
- mutation DeckAccessTokenIssuerRevoke($id: UUID!) {
3446
- deckAccessTokenIssuerRevoke(id: $id)
3352
+ mutation DeckTokenIssuerRevoke($id: UUID!) {
3353
+ deckTokenIssuerRevoke(id: $id)
3447
3354
  }
3448
3355
  `
3449
3356
  };
3450
3357
  },
3451
- revokeDeckAccessTokenIssuerSigningKey() {
3358
+ revokeDeckTokenIssuerSigningKey() {
3452
3359
  return {
3453
3360
  query: `
3454
- mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
3455
- deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
3456
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3361
+ mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
3362
+ deckTokenIssuerSigningKeyRevoke(id: $id) {
3363
+ ${DECK_TOKEN_ISSUER_FIELDS}
3457
3364
  }
3458
3365
  }
3459
3366
  `
3460
3367
  };
3461
3368
  },
3462
- exchangeDeckAccessToken() {
3369
+ exchangeDeckToken() {
3463
3370
  return {
3464
3371
  query: `
3465
- mutation DeckAccessTokenExchange($input: DeckAccessTokenExchangeInput!) {
3466
- deckAccessTokenExchange(input: $input) {
3372
+ mutation DeckTokenExchange($input: DeckTokenExchangeInput!) {
3373
+ deckTokenExchange(input: $input) {
3467
3374
  token
3468
- accessToken {
3469
- ${DECK_ACCESS_TOKEN_FIELDS}
3375
+ deckToken {
3376
+ ${DECK_TOKEN_FIELDS}
3470
3377
  }
3471
3378
  }
3472
3379
  }
3473
3380
  `
3474
3381
  };
3475
3382
  },
3476
- exchangeDeckSessionToken() {
3383
+ revokeDeckToken() {
3477
3384
  return {
3478
3385
  query: `
3479
- mutation DeckSessionTokenExchange($input: DeckSessionTokenExchangeInput!) {
3480
- deckSessionTokenExchange(input: $input) {
3481
- token
3482
- sessionToken {
3483
- id
3484
- accountId
3485
- apiApplicationId
3486
- gameId
3487
- environment
3488
- externalSubject
3489
- scopes
3490
- expiresAt
3491
- revokedAt
3492
- lastUsedAt
3493
- createdAt
3494
- updatedAt
3495
- }
3496
- }
3497
- }
3498
- `
3386
+ mutation DeckTokenRevoke($id: UUID!) {
3387
+ deckTokenRevoke(id: $id)
3388
+ }
3389
+ `
3499
3390
  };
3500
3391
  },
3501
3392
  grantDeckApiApplicationAccess() {
@@ -3518,26 +3409,17 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3518
3409
  `
3519
3410
  };
3520
3411
  },
3521
- revokeDeckAccessToken() {
3522
- return {
3523
- query: `
3524
- mutation DeckAccessTokenRevoke($id: UUID!) {
3525
- deckAccessTokenRevoke(id: $id)
3526
- }
3527
- `
3528
- };
3529
- },
3530
3412
  deckCreateVariables(input) {
3531
- return { input };
3413
+ return { input: normalizeDeckJsonInput(input) };
3532
3414
  },
3533
3415
  deckUpdateVariables(id, input) {
3534
- return { id, input };
3416
+ return { id, input: normalizeDeckJsonInput(input) };
3535
3417
  },
3536
3418
  deckEntryAddVariables(input) {
3537
- return { input };
3419
+ return { input: normalizeDeckJsonInput(input) };
3538
3420
  },
3539
3421
  deckEntryUpdateVariables(id, input) {
3540
- return { id, input };
3422
+ return { id, input: normalizeDeckJsonInput(input) };
3541
3423
  },
3542
3424
  deckEntryRemoveVariables(id, expectedDraftRevision) {
3543
3425
  return { id, expectedDraftRevision };
@@ -3546,7 +3428,7 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3546
3428
  return { deckId, input };
3547
3429
  },
3548
3430
  deckEntriesReplaceVariables(deckId, input) {
3549
- return { deckId, input };
3431
+ return { deckId, input: normalizeDeckJsonInput(input) };
3550
3432
  },
3551
3433
  deckImportVariables(input) {
3552
3434
  return { input };
@@ -3561,7 +3443,13 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3561
3443
  return { input };
3562
3444
  },
3563
3445
  deckUpsertByExternalRefVariables(input) {
3564
- return { input };
3446
+ return { input: normalizeDeckJsonInput(input) };
3447
+ },
3448
+ deckReadVariables(id, readState, version) {
3449
+ return { id, readState, version };
3450
+ },
3451
+ deckExternalRefReadVariables(externalRef, readState, version) {
3452
+ return { externalRef, readState, version };
3565
3453
  },
3566
3454
  deckClaimVariables(id, input) {
3567
3455
  return { id, input };
@@ -3582,7 +3470,7 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3582
3470
  return { id, input };
3583
3471
  },
3584
3472
  deckHydrateEntriesVariables(input) {
3585
- return { input };
3473
+ return { input: normalizeDeckJsonInput(input) };
3586
3474
  },
3587
3475
  deckExportVariables(id, format) {
3588
3476
  return { id, format };
@@ -3593,19 +3481,10 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3593
3481
  deckCollaboratorVariables(deckId, accountId, role) {
3594
3482
  return role === void 0 ? { deckId, accountId } : { deckId, accountId, role };
3595
3483
  },
3596
- deckPreviewTokenCreateVariables(input) {
3597
- return { input };
3598
- },
3599
- deckEmbedTokenCreateVariables(input) {
3600
- return { input };
3601
- },
3602
- deckAccessTokenIssuerCreateVariables(input) {
3603
- return { input };
3604
- },
3605
- deckAccessTokenExchangeVariables(input) {
3484
+ deckTokenIssuerCreateVariables(input) {
3606
3485
  return { input };
3607
3486
  },
3608
- deckSessionTokenExchangeVariables(input) {
3487
+ deckTokenExchangeVariables(input) {
3609
3488
  return { input };
3610
3489
  },
3611
3490
  deckApiApplicationAccessesVariables(deckId, includeRevoked) {