@carddb/core 0.4.1 → 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.cjs CHANGED
@@ -303,6 +303,47 @@ function resolveFilter(input) {
303
303
  }
304
304
 
305
305
  // src/query-builder.ts
306
+ var DECK_JSON_OBJECT_KEYS = /* @__PURE__ */ new Set(["metadata", "annotations"]);
307
+ function normalizeDeckJsonInput(input) {
308
+ return normalizeDeckJsonValue(input, "input");
309
+ }
310
+ function normalizeDeckJsonValue(value, path) {
311
+ if (!isRecord(value)) {
312
+ return value;
313
+ }
314
+ const normalized = {};
315
+ for (const [key, child] of Object.entries(value)) {
316
+ const childPath = `${path}.${key}`;
317
+ if (DECK_JSON_OBJECT_KEYS.has(key)) {
318
+ normalized[key] = normalizeJsonObject(child, childPath);
319
+ } else if (key === "entries" && Array.isArray(child)) {
320
+ normalized[key] = child.map(
321
+ (entry, index) => normalizeDeckJsonValue(entry, `${childPath}[${index}]`)
322
+ );
323
+ } else {
324
+ normalized[key] = child;
325
+ }
326
+ }
327
+ return normalized;
328
+ }
329
+ function normalizeJsonObject(value, path) {
330
+ if (value == null || isRecord(value)) {
331
+ return value;
332
+ }
333
+ if (typeof value === "string") {
334
+ try {
335
+ const parsed = JSON.parse(value);
336
+ if (isRecord(parsed)) {
337
+ return parsed;
338
+ }
339
+ } catch {
340
+ }
341
+ }
342
+ throw new ValidationError(`${path} must be a JSON object`);
343
+ }
344
+ function isRecord(value) {
345
+ return typeof value === "object" && value !== null && !Array.isArray(value);
346
+ }
306
347
  var FILE_FIELDS = `
307
348
  id
308
349
  createdAt
@@ -643,36 +684,12 @@ var DECK_COLLABORATOR_FIELDS = `
643
684
  createdAt
644
685
  updatedAt
645
686
  `;
646
- var DECK_PREVIEW_TOKEN_FIELDS = `
687
+ var DECK_TOKEN_ISSUER_FIELDS = `
647
688
  id
648
- deckId
649
- label
650
- expiresAt
651
- revokedAt
652
- lastUsedAt
653
- createdAt
654
- updatedAt
655
- `;
656
- var DECK_EMBED_TOKEN_FIELDS = `
657
- id
658
- deckId
659
- apiApplicationId
660
- label
661
- readMode
662
- allowedOrigins
663
- externalSubject
664
- expiresAt
665
- revokedAt
666
- lastUsedAt
667
- createdAt
668
- updatedAt
669
- `;
670
- var DECK_ACCESS_TOKEN_ISSUER_FIELDS = `
671
- id
672
- deckId
673
689
  apiApplicationId
674
690
  label
675
- readModes
691
+ allowedScopes
692
+ allowedRepresentations
676
693
  maxTokenLifetimeSeconds
677
694
  directSigningAlg
678
695
  directSigningKeyId
@@ -682,13 +699,15 @@ var DECK_ACCESS_TOKEN_ISSUER_FIELDS = `
682
699
  createdAt
683
700
  updatedAt
684
701
  `;
685
- var DECK_ACCESS_TOKEN_FIELDS = `
702
+ var DECK_TOKEN_FIELDS = `
686
703
  id
687
- deckId
688
704
  apiApplicationId
689
705
  issuerId
690
- readMode
706
+ deckId
707
+ gameId
691
708
  externalSubject
709
+ scopes
710
+ representation
692
711
  expiresAt
693
712
  revokedAt
694
713
  lastUsedAt
@@ -1336,7 +1355,14 @@ var SCAN_METRICS_FIELDS = `
1336
1355
  completedJobs
1337
1356
  failedJobs
1338
1357
  failureRate
1358
+ noMatchCount
1359
+ noMatchRate
1339
1360
  averageShortlistSize
1361
+ vectorQueryCount
1362
+ vectorFallbackCount
1363
+ averageVectorCandidates
1364
+ averageVectorQueryMs
1365
+ averageEmbeddingMs
1340
1366
  confidenceDistribution
1341
1367
  feedback {
1342
1368
  total
@@ -1350,8 +1376,14 @@ var SCAN_METRICS_FIELDS = `
1350
1376
  jobCount
1351
1377
  completedJobs
1352
1378
  failedJobs
1379
+ noMatchCount
1353
1380
  averageConfidence
1354
1381
  averageShortlistSize
1382
+ vectorQueryCount
1383
+ vectorFallbackCount
1384
+ averageVectorCandidates
1385
+ averageVectorQueryMs
1386
+ averageEmbeddingMs
1355
1387
  feedbackCount
1356
1388
  correctFeedback
1357
1389
  correctedFeedback
@@ -2799,8 +2831,8 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2799
2831
  deckById() {
2800
2832
  return {
2801
2833
  query: `
2802
- query Deck($id: UUID!) {
2803
- deck(id: $id) {
2834
+ query Deck($id: UUID!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
2835
+ deck(id: $id, readState: $readState, version: $version) {
2804
2836
  ${DECK_FIELDS}
2805
2837
  }
2806
2838
  }
@@ -2854,8 +2886,8 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2854
2886
  deckByExternalRef() {
2855
2887
  return {
2856
2888
  query: `
2857
- query DeckByExternalRef($externalRef: String!) {
2858
- deckByExternalRef(externalRef: $externalRef) {
2889
+ query DeckByExternalRef($externalRef: String!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
2890
+ deckByExternalRef(externalRef: $externalRef, readState: $readState, version: $version) {
2859
2891
  ${DECK_FIELDS}
2860
2892
  }
2861
2893
  }
@@ -2898,39 +2930,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
2898
2930
  variables
2899
2931
  };
2900
2932
  },
2901
- deckPreview() {
2902
- return {
2903
- query: `
2904
- query DeckPreview($token: String!) {
2905
- deckPreview(token: $token) {
2906
- ${DECK_FIELDS}
2907
- }
2908
- }
2909
- `
2910
- };
2911
- },
2912
- deckEmbed() {
2913
- return {
2914
- query: `
2915
- query DeckEmbed($token: String!) {
2916
- deckEmbed(token: $token) {
2917
- ${DECK_FIELDS}
2918
- }
2919
- }
2920
- `
2921
- };
2922
- },
2923
- deckAccess() {
2924
- return {
2925
- query: `
2926
- query DeckAccess($token: String!) {
2927
- deckAccess(token: $token) {
2928
- ${DECK_FIELDS}
2929
- }
2930
- }
2931
- `
2932
- };
2933
- },
2934
2933
  deckDraftDiff() {
2935
2934
  return {
2936
2935
  query: `
@@ -3039,28 +3038,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3039
3038
  `
3040
3039
  };
3041
3040
  },
3042
- deckEmbedTokens() {
3043
- return {
3044
- query: `
3045
- query DeckEmbedTokens($deckId: UUID!) {
3046
- deckEmbedTokens(deckId: $deckId) {
3047
- ${DECK_EMBED_TOKEN_FIELDS}
3048
- }
3049
- }
3050
- `
3051
- };
3052
- },
3053
- deckAccessTokenIssuers() {
3054
- return {
3055
- query: `
3056
- query DeckAccessTokenIssuers($deckId: UUID!) {
3057
- deckAccessTokenIssuers(deckId: $deckId) {
3058
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3059
- }
3060
- }
3061
- `
3062
- };
3063
- },
3064
3041
  deckApiApplicationAccesses() {
3065
3042
  return {
3066
3043
  query: `
@@ -3147,17 +3124,6 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3147
3124
  `
3148
3125
  };
3149
3126
  },
3150
- deckPreviewTokens() {
3151
- return {
3152
- query: `
3153
- query DeckPreviewTokens($deckId: UUID!) {
3154
- deckPreviewTokens(deckId: $deckId) {
3155
- ${DECK_PREVIEW_TOKEN_FIELDS}
3156
- }
3157
- }
3158
- `
3159
- };
3160
- },
3161
3127
  createDeck() {
3162
3128
  return {
3163
3129
  query: `
@@ -3422,120 +3388,58 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3422
3388
  `
3423
3389
  };
3424
3390
  },
3425
- createDeckPreviewToken() {
3426
- return {
3427
- query: `
3428
- mutation DeckPreviewTokenCreate($input: DeckPreviewTokenCreateInput!) {
3429
- deckPreviewTokenCreate(input: $input) {
3430
- token
3431
- previewToken {
3432
- ${DECK_PREVIEW_TOKEN_FIELDS}
3433
- }
3434
- }
3435
- }
3436
- `
3437
- };
3438
- },
3439
- revokeDeckPreviewToken() {
3440
- return {
3441
- query: `
3442
- mutation DeckPreviewTokenRevoke($id: UUID!) {
3443
- deckPreviewTokenRevoke(id: $id)
3444
- }
3445
- `
3446
- };
3447
- },
3448
- createDeckEmbedToken() {
3449
- return {
3450
- query: `
3451
- mutation DeckEmbedTokenCreate($input: DeckEmbedTokenCreateInput!) {
3452
- deckEmbedTokenCreate(input: $input) {
3453
- token
3454
- embedToken {
3455
- ${DECK_EMBED_TOKEN_FIELDS}
3456
- }
3457
- }
3458
- }
3459
- `
3460
- };
3461
- },
3462
- revokeDeckEmbedToken() {
3391
+ createDeckTokenIssuer() {
3463
3392
  return {
3464
3393
  query: `
3465
- mutation DeckEmbedTokenRevoke($id: UUID!) {
3466
- deckEmbedTokenRevoke(id: $id)
3467
- }
3468
- `
3469
- };
3470
- },
3471
- createDeckAccessTokenIssuer() {
3472
- return {
3473
- query: `
3474
- mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
3475
- deckAccessTokenIssuerCreate(input: $input) {
3476
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3394
+ mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
3395
+ deckTokenIssuerCreate(input: $input) {
3396
+ ${DECK_TOKEN_ISSUER_FIELDS}
3477
3397
  }
3478
3398
  }
3479
3399
  `
3480
3400
  };
3481
3401
  },
3482
- revokeDeckAccessTokenIssuer() {
3402
+ revokeDeckTokenIssuer() {
3483
3403
  return {
3484
3404
  query: `
3485
- mutation DeckAccessTokenIssuerRevoke($id: UUID!) {
3486
- deckAccessTokenIssuerRevoke(id: $id)
3405
+ mutation DeckTokenIssuerRevoke($id: UUID!) {
3406
+ deckTokenIssuerRevoke(id: $id)
3487
3407
  }
3488
3408
  `
3489
3409
  };
3490
3410
  },
3491
- revokeDeckAccessTokenIssuerSigningKey() {
3411
+ revokeDeckTokenIssuerSigningKey() {
3492
3412
  return {
3493
3413
  query: `
3494
- mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
3495
- deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
3496
- ${DECK_ACCESS_TOKEN_ISSUER_FIELDS}
3414
+ mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
3415
+ deckTokenIssuerSigningKeyRevoke(id: $id) {
3416
+ ${DECK_TOKEN_ISSUER_FIELDS}
3497
3417
  }
3498
3418
  }
3499
3419
  `
3500
3420
  };
3501
3421
  },
3502
- exchangeDeckAccessToken() {
3422
+ exchangeDeckToken() {
3503
3423
  return {
3504
3424
  query: `
3505
- mutation DeckAccessTokenExchange($input: DeckAccessTokenExchangeInput!) {
3506
- deckAccessTokenExchange(input: $input) {
3425
+ mutation DeckTokenExchange($input: DeckTokenExchangeInput!) {
3426
+ deckTokenExchange(input: $input) {
3507
3427
  token
3508
- accessToken {
3509
- ${DECK_ACCESS_TOKEN_FIELDS}
3428
+ deckToken {
3429
+ ${DECK_TOKEN_FIELDS}
3510
3430
  }
3511
3431
  }
3512
3432
  }
3513
3433
  `
3514
3434
  };
3515
3435
  },
3516
- exchangeDeckSessionToken() {
3436
+ revokeDeckToken() {
3517
3437
  return {
3518
3438
  query: `
3519
- mutation DeckSessionTokenExchange($input: DeckSessionTokenExchangeInput!) {
3520
- deckSessionTokenExchange(input: $input) {
3521
- token
3522
- sessionToken {
3523
- id
3524
- accountId
3525
- apiApplicationId
3526
- gameId
3527
- environment
3528
- externalSubject
3529
- scopes
3530
- expiresAt
3531
- revokedAt
3532
- lastUsedAt
3533
- createdAt
3534
- updatedAt
3535
- }
3536
- }
3537
- }
3538
- `
3439
+ mutation DeckTokenRevoke($id: UUID!) {
3440
+ deckTokenRevoke(id: $id)
3441
+ }
3442
+ `
3539
3443
  };
3540
3444
  },
3541
3445
  grantDeckApiApplicationAccess() {
@@ -3558,26 +3462,17 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3558
3462
  `
3559
3463
  };
3560
3464
  },
3561
- revokeDeckAccessToken() {
3562
- return {
3563
- query: `
3564
- mutation DeckAccessTokenRevoke($id: UUID!) {
3565
- deckAccessTokenRevoke(id: $id)
3566
- }
3567
- `
3568
- };
3569
- },
3570
3465
  deckCreateVariables(input) {
3571
- return { input };
3466
+ return { input: normalizeDeckJsonInput(input) };
3572
3467
  },
3573
3468
  deckUpdateVariables(id, input) {
3574
- return { id, input };
3469
+ return { id, input: normalizeDeckJsonInput(input) };
3575
3470
  },
3576
3471
  deckEntryAddVariables(input) {
3577
- return { input };
3472
+ return { input: normalizeDeckJsonInput(input) };
3578
3473
  },
3579
3474
  deckEntryUpdateVariables(id, input) {
3580
- return { id, input };
3475
+ return { id, input: normalizeDeckJsonInput(input) };
3581
3476
  },
3582
3477
  deckEntryRemoveVariables(id, expectedDraftRevision) {
3583
3478
  return { id, expectedDraftRevision };
@@ -3586,7 +3481,7 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3586
3481
  return { deckId, input };
3587
3482
  },
3588
3483
  deckEntriesReplaceVariables(deckId, input) {
3589
- return { deckId, input };
3484
+ return { deckId, input: normalizeDeckJsonInput(input) };
3590
3485
  },
3591
3486
  deckImportVariables(input) {
3592
3487
  return { input };
@@ -3601,7 +3496,13 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3601
3496
  return { input };
3602
3497
  },
3603
3498
  deckUpsertByExternalRefVariables(input) {
3604
- return { input };
3499
+ return { input: normalizeDeckJsonInput(input) };
3500
+ },
3501
+ deckReadVariables(id, readState, version) {
3502
+ return { id, readState, version };
3503
+ },
3504
+ deckExternalRefReadVariables(externalRef, readState, version) {
3505
+ return { externalRef, readState, version };
3605
3506
  },
3606
3507
  deckClaimVariables(id, input) {
3607
3508
  return { id, input };
@@ -3622,7 +3523,7 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3622
3523
  return { id, input };
3623
3524
  },
3624
3525
  deckHydrateEntriesVariables(input) {
3625
- return { input };
3526
+ return { input: normalizeDeckJsonInput(input) };
3626
3527
  },
3627
3528
  deckExportVariables(id, format) {
3628
3529
  return { id, format };
@@ -3633,19 +3534,10 @@ ${RESOLVED_LINKS_FIELDS}` : selectedRecordFields;
3633
3534
  deckCollaboratorVariables(deckId, accountId, role) {
3634
3535
  return role === void 0 ? { deckId, accountId } : { deckId, accountId, role };
3635
3536
  },
3636
- deckPreviewTokenCreateVariables(input) {
3637
- return { input };
3638
- },
3639
- deckEmbedTokenCreateVariables(input) {
3640
- return { input };
3641
- },
3642
- deckAccessTokenIssuerCreateVariables(input) {
3643
- return { input };
3644
- },
3645
- deckAccessTokenExchangeVariables(input) {
3537
+ deckTokenIssuerCreateVariables(input) {
3646
3538
  return { input };
3647
3539
  },
3648
- deckSessionTokenExchangeVariables(input) {
3540
+ deckTokenExchangeVariables(input) {
3649
3541
  return { input };
3650
3542
  },
3651
3543
  deckApiApplicationAccessesVariables(deckId, includeRevoked) {