@carddb/client 0.1.4 → 0.2.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.
package/dist/index.cjs CHANGED
@@ -13,6 +13,11 @@ var DEFAULT_RETRY_BASE_DELAY = 1e3;
13
13
  var DEFAULT_RETRY_MAX_DELAY = 3e4;
14
14
  var Configuration = class _Configuration {
15
15
  apiKey;
16
+ publishableKey;
17
+ secretKey;
18
+ accessToken;
19
+ legacyApiKey;
20
+ environment;
16
21
  endpoint;
17
22
  timeout;
18
23
  openTimeout;
@@ -32,7 +37,12 @@ var Configuration = class _Configuration {
32
37
  cacheTtl;
33
38
  cacheTtls;
34
39
  constructor(config = {}) {
35
- this.apiKey = config.apiKey;
40
+ this.legacyApiKey = config.apiKey;
41
+ this.publishableKey = config.publishableKey;
42
+ this.secretKey = config.secretKey;
43
+ this.accessToken = config.accessToken;
44
+ this.apiKey = config.apiKey ?? config.publishableKey ?? config.secretKey;
45
+ this.environment = config.environment;
36
46
  this.endpoint = config.endpoint ?? DEFAULT_ENDPOINT;
37
47
  this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
38
48
  this.openTimeout = config.openTimeout ?? DEFAULT_OPEN_TIMEOUT;
@@ -110,6 +120,27 @@ var Configuration = class _Configuration {
110
120
  }
111
121
  }
112
122
  }
123
+ /**
124
+ * Secret-key-only helpers are for server runtimes and trusted backend workflows.
125
+ */
126
+ requireSecretCredential(operation) {
127
+ if (!this.accessToken && (this.legacyApiKey || this.secretKey && !this.publishableKey)) return;
128
+ throw new core.RestrictedError(
129
+ `${operation} requires a server-side secretKey or legacy apiKey credential`
130
+ );
131
+ }
132
+ /**
133
+ * API key sent on requests when no OAuth bearer token is configured.
134
+ */
135
+ requestApiKey() {
136
+ return this.legacyApiKey ?? this.publishableKey ?? this.secretKey;
137
+ }
138
+ /**
139
+ * Explicit legacy apiKey supplied by the caller, excluding publishable/secret aliases.
140
+ */
141
+ configApiKey() {
142
+ return this.legacyApiKey;
143
+ }
113
144
  /**
114
145
  * Check if a log level should be logged
115
146
  */
@@ -127,7 +158,11 @@ var Configuration = class _Configuration {
127
158
  */
128
159
  merge(overrides) {
129
160
  return new _Configuration({
130
- apiKey: overrides.apiKey ?? this.apiKey,
161
+ apiKey: overrides.apiKey ?? this.legacyApiKey,
162
+ publishableKey: overrides.publishableKey ?? this.publishableKey,
163
+ secretKey: overrides.secretKey ?? this.secretKey,
164
+ accessToken: overrides.accessToken ?? this.accessToken,
165
+ environment: overrides.environment ?? this.environment,
131
166
  endpoint: overrides.endpoint ?? this.endpoint,
132
167
  timeout: overrides.timeout ?? this.timeout,
133
168
  openTimeout: overrides.openTimeout ?? this.openTimeout,
@@ -272,6 +307,7 @@ var Connection = class {
272
307
  async fetch(query, variables) {
273
308
  const controller = new AbortController();
274
309
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
310
+ const apiKey = this.config.requestApiKey();
275
311
  try {
276
312
  const response = await fetch(this.config.endpoint, {
277
313
  method: "POST",
@@ -279,7 +315,8 @@ var Connection = class {
279
315
  "Content-Type": "application/json",
280
316
  Accept: "application/json",
281
317
  "User-Agent": getUserAgent(),
282
- ...this.config.apiKey ? { "X-API-Key": this.config.apiKey } : {}
318
+ ...this.config.accessToken ? { Authorization: `Bearer ${this.config.accessToken}` } : {},
319
+ ...!this.config.accessToken && apiKey ? { "X-API-Key": apiKey } : {}
283
320
  },
284
321
  body: JSON.stringify({ query, variables }),
285
322
  signal: controller.signal
@@ -743,6 +780,17 @@ var DecksResource = class extends BaseResource {
743
780
  return result["fetchDeck"] ?? null;
744
781
  });
745
782
  }
783
+ /**
784
+ * Fetch a deck by UUID using the ownership-aware `deck` API.
785
+ */
786
+ async get(id, options = {}) {
787
+ const key = this.cacheKey("decks", "get", { id });
788
+ return this.withCache(key, "decks", options, async () => {
789
+ const { query } = core.QueryBuilder.deckById();
790
+ const result = await this.connection.execute(query, { id });
791
+ return result["deck"] ?? null;
792
+ });
793
+ }
746
794
  /**
747
795
  * Fetch one deck owned by the current account or API application.
748
796
  */
@@ -765,6 +813,17 @@ var DecksResource = class extends BaseResource {
765
813
  return result["fetchDeckBySlug"] ?? null;
766
814
  });
767
815
  }
816
+ /**
817
+ * Fetch by slug using the ownership-aware `deckBySlug` API.
818
+ */
819
+ async getBySlug(publisherSlug, gameKey, slug, options = {}) {
820
+ const key = this.cacheKey("decks", "getBySlug", { publisherSlug, gameKey, slug });
821
+ return this.withCache(key, "decks", options, async () => {
822
+ const { query } = core.QueryBuilder.deckBySlug();
823
+ const result = await this.connection.execute(query, { publisherSlug, gameKey, slug });
824
+ return result["deckBySlug"] ?? null;
825
+ });
826
+ }
768
827
  /**
769
828
  * Fetch a hosted deck by external reference for the current API application.
770
829
  */
@@ -776,13 +835,25 @@ var DecksResource = class extends BaseResource {
776
835
  return result["fetchDeckByExternalRef"] ?? null;
777
836
  });
778
837
  }
838
+ /**
839
+ * Fetch by external reference using the ownership-aware `deckByExternalRef` API.
840
+ */
841
+ async getByExternalRef(externalRef, options = {}) {
842
+ const key = this.cacheKey("decks", "getByExternalRef", { externalRef });
843
+ return this.withCache(key, "decks", options, async () => {
844
+ const { query } = core.QueryBuilder.deckByExternalRef();
845
+ const result = await this.connection.execute(query, { externalRef });
846
+ return result["deckByExternalRef"] ?? null;
847
+ });
848
+ }
779
849
  /**
780
850
  * List decks owned by the current account or API application.
781
851
  */
782
852
  async listMine(options = {}) {
783
853
  const { query, variables } = core.QueryBuilder.listMyDecks({
784
854
  first: options.first,
785
- after: options.after
855
+ after: options.after,
856
+ includeArchived: options.includeArchived
786
857
  });
787
858
  const key = this.cacheKey("decks", "listMine", variables);
788
859
  const data = await this.withCache(key, "decks", options, async () => {
@@ -793,6 +864,61 @@ var DecksResource = class extends BaseResource {
793
864
  nextPageLoader: async (cursor) => this.listMine({ ...options, after: cursor })
794
865
  });
795
866
  }
867
+ /**
868
+ * List decks owned by the current account or OAuth grant.
869
+ */
870
+ async listViewer(options = {}) {
871
+ const { query, variables } = core.QueryBuilder.viewerDecks({
872
+ filter: options.filter,
873
+ first: options.first,
874
+ after: options.after
875
+ });
876
+ const key = this.cacheKey("decks", "listViewer", variables);
877
+ const data = await this.withCache(key, "decks", options, async () => {
878
+ const result = await this.connection.execute(query, variables);
879
+ return result["viewerDecks"];
880
+ });
881
+ return new core.Collection(data, {
882
+ nextPageLoader: async (cursor) => this.listViewer({ ...options, after: cursor })
883
+ });
884
+ }
885
+ /**
886
+ * List app-owned decks for the current secret-key API application.
887
+ */
888
+ async listApp(options = {}) {
889
+ this.config.requireSecretCredential("decks.listApp");
890
+ const { query, variables } = core.QueryBuilder.appDecks({
891
+ filter: options.filter,
892
+ first: options.first,
893
+ after: options.after
894
+ });
895
+ const key = this.cacheKey("decks", "listApp", variables);
896
+ const data = await this.withCache(key, "decks", options, async () => {
897
+ const result = await this.connection.execute(query, variables);
898
+ return result["appDecks"];
899
+ });
900
+ return new core.Collection(data, {
901
+ nextPageLoader: async (cursor) => this.listApp({ ...options, after: cursor })
902
+ });
903
+ }
904
+ /**
905
+ * List published live decks eligible for public discovery.
906
+ */
907
+ async listPublic(options = {}) {
908
+ const { query, variables } = core.QueryBuilder.publicDecks({
909
+ filter: options.filter,
910
+ first: options.first,
911
+ after: options.after
912
+ });
913
+ const key = this.cacheKey("decks", "listPublic", variables);
914
+ const data = await this.withCache(key, "decks", options, async () => {
915
+ const result = await this.connection.execute(query, variables);
916
+ return result["publicDecks"];
917
+ });
918
+ return new core.Collection(data, {
919
+ nextPageLoader: async (cursor) => this.listPublic({ ...options, after: cursor })
920
+ });
921
+ }
796
922
  /**
797
923
  * Fetch one immutable published deck version.
798
924
  */
@@ -833,6 +959,104 @@ var DecksResource = class extends BaseResource {
833
959
  return result["deckPreview"] ?? null;
834
960
  });
835
961
  }
962
+ /**
963
+ * Fetch published embed data using a revocable embed token.
964
+ */
965
+ async embed(token, options = {}) {
966
+ const key = this.cacheKey("decks", "embed", { token });
967
+ return this.withCache(key, "decks", options, async () => {
968
+ const { query } = core.QueryBuilder.deckEmbed();
969
+ const result = await this.connection.execute(query, { token });
970
+ return result["deckEmbed"] ?? null;
971
+ });
972
+ }
973
+ /**
974
+ * Fetch token-authorized published data using an exchanged access token.
975
+ */
976
+ async access(token, options = {}) {
977
+ const key = this.cacheKey("decks", "access", { token });
978
+ return this.withCache(key, "decks", options, async () => {
979
+ const { query } = core.QueryBuilder.deckAccess();
980
+ const result = await this.connection.execute(query, { token });
981
+ return result["deckAccess"] ?? null;
982
+ });
983
+ }
984
+ /**
985
+ * Compare the current draft against the latest published version.
986
+ */
987
+ async draftDiff(id, options = {}) {
988
+ const key = this.cacheKey("decks", "draftDiff", { id });
989
+ return this.withCache(key, "decks", options, async () => {
990
+ const { query } = core.QueryBuilder.deckDraftDiff();
991
+ const result = await this.connection.execute(query, { id });
992
+ return result["deckDraftDiff"];
993
+ });
994
+ }
995
+ /**
996
+ * Compare any two readable immutable deck versions from the same deck.
997
+ */
998
+ async versionDiff(fromVersionId, toVersionId, options = {}) {
999
+ const variables = core.QueryBuilder.deckVersionDiffVariables(fromVersionId, toVersionId);
1000
+ const key = this.cacheKey("decks", "versionDiff", variables);
1001
+ return this.withCache(key, "decks", options, async () => {
1002
+ const { query } = core.QueryBuilder.deckVersionDiff();
1003
+ const result = await this.connection.execute(query, variables);
1004
+ return result["deckVersionDiff"];
1005
+ });
1006
+ }
1007
+ /**
1008
+ * Validate a draft against current or explicitly requested immutable rules/data.
1009
+ */
1010
+ async validate(id, input, options = {}) {
1011
+ const variables = core.QueryBuilder.deckValidateVariables(id, input);
1012
+ const key = this.cacheKey("decks", "validate", variables);
1013
+ return this.withCache(key, "decks", options, async () => {
1014
+ const { query } = core.QueryBuilder.deckValidate();
1015
+ const result = await this.connection.execute(query, variables);
1016
+ return result["deckValidate"];
1017
+ });
1018
+ }
1019
+ /**
1020
+ * Hydrate unpersisted deck entries against a stored deck's game without mutating the deck.
1021
+ */
1022
+ async hydrateDeckEntries(input, options = {}) {
1023
+ const variables = core.QueryBuilder.deckHydrateEntriesVariables(input);
1024
+ const key = this.cacheKey("decks", "hydrateDeckEntries", variables);
1025
+ return this.withCache(key, "decks", options, async () => {
1026
+ const { query } = core.QueryBuilder.deckHydrateEntries();
1027
+ const result = await this.connection.execute(query, variables);
1028
+ return result["deckHydrateEntries"];
1029
+ });
1030
+ }
1031
+ /**
1032
+ * Export a readable deck representation in a deterministic text format.
1033
+ */
1034
+ async exportDeck(id, format = "SIMPLE_TEXT", options = {}) {
1035
+ const variables = core.QueryBuilder.deckExportVariables(id, format);
1036
+ const key = this.cacheKey("decks", "exportDeck", variables);
1037
+ return this.withCache(key, "decks", options, async () => {
1038
+ const { query } = core.QueryBuilder.deckExport();
1039
+ const result = await this.connection.execute(query, variables);
1040
+ return result["deckExport"];
1041
+ });
1042
+ }
1043
+ /**
1044
+ * Resolve current or historical ruleset section definitions.
1045
+ */
1046
+ async sectionDefinitions(options = {}) {
1047
+ const { query, variables } = core.QueryBuilder.deckSectionDefinitions({
1048
+ publisherSlug: options.publisherSlug,
1049
+ gameKey: options.gameKey,
1050
+ gameId: options.gameId,
1051
+ rulesetKey: options.rulesetKey,
1052
+ rulesetVersionId: options.rulesetVersionId
1053
+ });
1054
+ const key = this.cacheKey("decks", "sectionDefinitions", variables);
1055
+ return this.withCache(key, "decks", options, async () => {
1056
+ const result = await this.connection.execute(query, variables);
1057
+ return result["deckSectionDefinitions"];
1058
+ });
1059
+ }
836
1060
  /**
837
1061
  * List collaborators for a deck.
838
1062
  */
@@ -855,6 +1079,55 @@ var DecksResource = class extends BaseResource {
855
1079
  return result["deckPreviewTokens"];
856
1080
  });
857
1081
  }
1082
+ /**
1083
+ * List published embed tokens for a deck.
1084
+ */
1085
+ async listEmbedTokens(deckId, options = {}) {
1086
+ const key = this.cacheKey("decks", "listEmbedTokens", { deckId });
1087
+ return this.withCache(key, "decks", options, async () => {
1088
+ const { query } = core.QueryBuilder.deckEmbedTokens();
1089
+ const result = await this.connection.execute(query, { deckId });
1090
+ return result["deckEmbedTokens"];
1091
+ });
1092
+ }
1093
+ /**
1094
+ * List trusted access token issuers for a deck.
1095
+ */
1096
+ async listAccessTokenIssuers(deckId, options = {}) {
1097
+ const key = this.cacheKey("decks", "listAccessTokenIssuers", { deckId });
1098
+ return this.withCache(key, "decks", options, async () => {
1099
+ const { query } = core.QueryBuilder.deckAccessTokenIssuers();
1100
+ const result = await this.connection.execute(query, { deckId });
1101
+ return result["deckAccessTokenIssuers"];
1102
+ });
1103
+ }
1104
+ /**
1105
+ * List API applications with explicit access to one owned deck.
1106
+ */
1107
+ async listApiApplicationAccesses(deckId, options = {}) {
1108
+ const variables = core.QueryBuilder.deckApiApplicationAccessesVariables(
1109
+ deckId,
1110
+ options.includeRevoked
1111
+ );
1112
+ const key = this.cacheKey("decks", "listApiApplicationAccesses", variables);
1113
+ return this.withCache(key, "decks", options, async () => {
1114
+ const { query } = core.QueryBuilder.deckApiApplicationAccesses();
1115
+ const result = await this.connection.execute(query, variables);
1116
+ return result["deckApiApplicationAccesses"];
1117
+ });
1118
+ }
1119
+ /**
1120
+ * List selected-deck grants for the current account.
1121
+ */
1122
+ async listMyApiApplicationAccesses(options = {}) {
1123
+ const variables = core.QueryBuilder.myDeckApiApplicationAccessesVariables(options.applicationId);
1124
+ const key = this.cacheKey("decks", "listMyApiApplicationAccesses", variables);
1125
+ return this.withCache(key, "decks", options, async () => {
1126
+ const { query } = core.QueryBuilder.myDeckApiApplicationAccesses();
1127
+ const result = await this.connection.execute(query, variables);
1128
+ return result["myDeckApiApplicationAccesses"];
1129
+ });
1130
+ }
858
1131
  /**
859
1132
  * Create a hosted deck.
860
1133
  */
@@ -873,6 +1146,176 @@ var DecksResource = class extends BaseResource {
873
1146
  const result = await this.connection.execute(query, variables);
874
1147
  return result["deckUpdate"];
875
1148
  }
1149
+ /**
1150
+ * Update deck-level metadata without mutating entries.
1151
+ */
1152
+ async updateMetadata(id, input) {
1153
+ return this.update(id, input);
1154
+ }
1155
+ /**
1156
+ * Create or replace a draft by API-application external reference.
1157
+ */
1158
+ async upsertByExternalRef(input) {
1159
+ this.config.requireSecretCredential("decks.upsertByExternalRef");
1160
+ const { query } = core.QueryBuilder.upsertDeckByExternalRef();
1161
+ const variables = core.QueryBuilder.deckUpsertByExternalRefVariables(input);
1162
+ const result = await this.connection.execute(query, variables);
1163
+ return result["deckUpsertByExternalRef"];
1164
+ }
1165
+ /**
1166
+ * Claim an app-owned deck into the consenting OAuth user's account.
1167
+ */
1168
+ async claim(id, input) {
1169
+ const { query } = core.QueryBuilder.claimDeck();
1170
+ const variables = core.QueryBuilder.deckClaimVariables(id, input);
1171
+ const result = await this.connection.execute(query, variables);
1172
+ return result["deckClaim"];
1173
+ }
1174
+ /**
1175
+ * Transfer a deck to another account.
1176
+ */
1177
+ async transferOwnership(id, input) {
1178
+ const { query } = core.QueryBuilder.transferDeckOwnership();
1179
+ const variables = core.QueryBuilder.deckTransferOwnershipVariables(id, input);
1180
+ const result = await this.connection.execute(query, variables);
1181
+ return result["deckTransferOwnership"];
1182
+ }
1183
+ /**
1184
+ * Copy a deck into the current principal's ownership namespace.
1185
+ */
1186
+ async copy(id, input) {
1187
+ const { query } = core.QueryBuilder.copyDeck();
1188
+ const variables = core.QueryBuilder.deckCopyVariables(id, input);
1189
+ const result = await this.connection.execute(query, variables);
1190
+ return result["deckCopy"];
1191
+ }
1192
+ /**
1193
+ * Add one entry to a deck draft.
1194
+ */
1195
+ async addEntry(input) {
1196
+ const { query } = core.QueryBuilder.addDeckEntry();
1197
+ const variables = core.QueryBuilder.deckEntryAddVariables(input);
1198
+ const result = await this.connection.execute(query, variables);
1199
+ return result["deckEntryAdd"];
1200
+ }
1201
+ /**
1202
+ * Update one stable deck entry.
1203
+ */
1204
+ async updateEntry(id, input) {
1205
+ const { query } = core.QueryBuilder.updateDeckEntry();
1206
+ const variables = core.QueryBuilder.deckEntryUpdateVariables(id, input);
1207
+ const result = await this.connection.execute(query, variables);
1208
+ return result["deckEntryUpdate"];
1209
+ }
1210
+ /**
1211
+ * Remove one stable deck entry.
1212
+ */
1213
+ async removeEntry(id, expectedDraftRevision) {
1214
+ const { query } = core.QueryBuilder.removeDeckEntry();
1215
+ const variables = core.QueryBuilder.deckEntryRemoveVariables(id, expectedDraftRevision);
1216
+ const result = await this.connection.execute(query, variables);
1217
+ return result["deckEntryRemove"];
1218
+ }
1219
+ /**
1220
+ * Reorder deck entries within or across sections.
1221
+ */
1222
+ async reorderEntries(deckId, input) {
1223
+ const { query } = core.QueryBuilder.reorderDeckEntries();
1224
+ const variables = core.QueryBuilder.deckEntryReorderVariables(deckId, input);
1225
+ const result = await this.connection.execute(query, variables);
1226
+ return result["deckEntryReorder"];
1227
+ }
1228
+ /**
1229
+ * Explicitly replace all deck entries for import or repair flows.
1230
+ */
1231
+ async replaceEntries(deckId, input) {
1232
+ const { query } = core.QueryBuilder.replaceDeckEntries();
1233
+ const variables = core.QueryBuilder.deckEntriesReplaceVariables(deckId, input);
1234
+ const result = await this.connection.execute(query, variables);
1235
+ return result["deckEntriesReplace"];
1236
+ }
1237
+ /**
1238
+ * Import a decklist into an existing deck or dry-run resolution.
1239
+ */
1240
+ async importDeck(input) {
1241
+ const { query } = core.QueryBuilder.importDeck();
1242
+ const variables = core.QueryBuilder.deckImportVariables(input);
1243
+ const result = await this.connection.execute(query, variables);
1244
+ return result["deckImport"];
1245
+ }
1246
+ /**
1247
+ * List publisher-managed configured import formats for a game.
1248
+ */
1249
+ async listImportFormats(gameId, options = {}) {
1250
+ const { query, variables } = core.QueryBuilder.deckImportFormats({
1251
+ gameId,
1252
+ includeArchived: options.includeArchived,
1253
+ first: options.first,
1254
+ after: options.after
1255
+ });
1256
+ const key = this.cacheKey("decks", "listImportFormats", variables);
1257
+ const data = await this.withCache(key, "decks", options, async () => {
1258
+ const result = await this.connection.execute(query, variables);
1259
+ return result["deckImportFormats"];
1260
+ });
1261
+ return new core.Collection(data, {
1262
+ nextPageLoader: async (cursor) => this.listImportFormats(gameId, { ...options, after: cursor })
1263
+ });
1264
+ }
1265
+ /**
1266
+ * Fetch one configured import format by UUID.
1267
+ */
1268
+ async fetchImportFormat(id, options = {}) {
1269
+ const key = this.cacheKey("decks", "fetchImportFormat", { id });
1270
+ return this.withCache(key, "decks", options, async () => {
1271
+ const { query } = core.QueryBuilder.deckImportFormat();
1272
+ const result = await this.connection.execute(query, { id });
1273
+ return result["deckImportFormat"] ?? null;
1274
+ });
1275
+ }
1276
+ /**
1277
+ * Preview configured import-format parsing and record resolution.
1278
+ */
1279
+ async testImportFormat(input) {
1280
+ const { query } = core.QueryBuilder.deckImportFormatTest();
1281
+ const variables = core.QueryBuilder.deckImportFormatTestVariables(input);
1282
+ const result = await this.connection.execute(query, variables);
1283
+ return result["deckImportFormatTest"];
1284
+ }
1285
+ /**
1286
+ * Create a publisher-managed configured import format.
1287
+ */
1288
+ async createImportFormat(input) {
1289
+ const { query } = core.QueryBuilder.createDeckImportFormat();
1290
+ const variables = core.QueryBuilder.deckImportFormatCreateVariables(input);
1291
+ const result = await this.connection.execute(query, variables);
1292
+ return result["deckImportFormatCreate"];
1293
+ }
1294
+ /**
1295
+ * Update a publisher-managed configured import format.
1296
+ */
1297
+ async updateImportFormat(id, input) {
1298
+ const { query } = core.QueryBuilder.updateDeckImportFormat();
1299
+ const variables = core.QueryBuilder.deckImportFormatUpdateVariables(id, input);
1300
+ const result = await this.connection.execute(query, variables);
1301
+ return result["deckImportFormatUpdate"];
1302
+ }
1303
+ /**
1304
+ * Archive a configured import format.
1305
+ */
1306
+ async archiveImportFormat(id) {
1307
+ const { query } = core.QueryBuilder.archiveDeckImportFormat();
1308
+ const result = await this.connection.execute(query, { id });
1309
+ return result["deckImportFormatArchive"];
1310
+ }
1311
+ /**
1312
+ * Restore an archived configured import format.
1313
+ */
1314
+ async unarchiveImportFormat(id) {
1315
+ const { query } = core.QueryBuilder.unarchiveDeckImportFormat();
1316
+ const result = await this.connection.execute(query, { id });
1317
+ return result["deckImportFormatUnarchive"];
1318
+ }
876
1319
  /**
877
1320
  * Delete a hosted deck.
878
1321
  */
@@ -881,15 +1324,48 @@ var DecksResource = class extends BaseResource {
881
1324
  const result = await this.connection.execute(query, { id });
882
1325
  return Boolean(result["deckDelete"]);
883
1326
  }
1327
+ /**
1328
+ * Recoverably hide a deck from normal owner and public lists.
1329
+ */
1330
+ async archive(id) {
1331
+ const { query } = core.QueryBuilder.archiveDeck();
1332
+ const result = await this.connection.execute(query, { id });
1333
+ return result["deckArchive"];
1334
+ }
1335
+ /**
1336
+ * Restore an archived deck to draft or published state.
1337
+ */
1338
+ async restore(id) {
1339
+ const { query } = core.QueryBuilder.restoreDeck();
1340
+ const result = await this.connection.execute(query, { id });
1341
+ return result["deckRestore"];
1342
+ }
1343
+ /**
1344
+ * Remove the current public published pointer while keeping version history.
1345
+ */
1346
+ async unpublish(id) {
1347
+ const { query } = core.QueryBuilder.unpublishDeck();
1348
+ const result = await this.connection.execute(query, { id });
1349
+ return result["deckUnpublish"];
1350
+ }
884
1351
  /**
885
1352
  * Publish the current draft as an immutable deck version.
886
1353
  */
887
- async publish(id, input = {}) {
1354
+ async publish(id, input) {
888
1355
  const { query } = core.QueryBuilder.publishDeck();
889
1356
  const variables = core.QueryBuilder.deckPublishVariables(id, input);
890
1357
  const result = await this.connection.execute(query, variables);
891
1358
  return result["deckPublish"];
892
1359
  }
1360
+ /**
1361
+ * Remove draft entries that fail card-reference validation.
1362
+ */
1363
+ async removeInvalidEntries(id, input) {
1364
+ const { query } = core.QueryBuilder.removeInvalidDeckEntries();
1365
+ const variables = core.QueryBuilder.deckRemoveInvalidEntriesVariables(id, input);
1366
+ const result = await this.connection.execute(query, variables);
1367
+ return result["deckRemoveInvalidEntries"];
1368
+ }
893
1369
  /**
894
1370
  * Create or update a deck collaborator.
895
1371
  */
@@ -925,6 +1401,85 @@ var DecksResource = class extends BaseResource {
925
1401
  const result = await this.connection.execute(query, { id });
926
1402
  return Boolean(result["deckPreviewTokenRevoke"]);
927
1403
  }
1404
+ /**
1405
+ * Create a revocable published embed token.
1406
+ */
1407
+ async createEmbedToken(input) {
1408
+ const { query } = core.QueryBuilder.createDeckEmbedToken();
1409
+ const variables = core.QueryBuilder.deckEmbedTokenCreateVariables(input);
1410
+ const result = await this.connection.execute(query, variables);
1411
+ return result["deckEmbedTokenCreate"];
1412
+ }
1413
+ /**
1414
+ * Revoke a published embed token.
1415
+ */
1416
+ async revokeEmbedToken(id) {
1417
+ const { query } = core.QueryBuilder.revokeDeckEmbedToken();
1418
+ const result = await this.connection.execute(query, { id });
1419
+ return Boolean(result["deckEmbedTokenRevoke"]);
1420
+ }
1421
+ /**
1422
+ * Trust the current API application to exchange short-lived deck access tokens.
1423
+ */
1424
+ async createAccessTokenIssuer(input) {
1425
+ const { query } = core.QueryBuilder.createDeckAccessTokenIssuer();
1426
+ const variables = core.QueryBuilder.deckAccessTokenIssuerCreateVariables(input);
1427
+ const result = await this.connection.execute(query, variables);
1428
+ return result["deckAccessTokenIssuerCreate"];
1429
+ }
1430
+ /**
1431
+ * Revoke a trusted deck access token issuer.
1432
+ */
1433
+ async revokeAccessTokenIssuer(id) {
1434
+ const { query } = core.QueryBuilder.revokeDeckAccessTokenIssuer();
1435
+ const result = await this.connection.execute(query, { id });
1436
+ return Boolean(result["deckAccessTokenIssuerRevoke"]);
1437
+ }
1438
+ /**
1439
+ * Revoke only the direct signing key for a trusted deck access token issuer.
1440
+ */
1441
+ async revokeAccessTokenIssuerSigningKey(id) {
1442
+ const { query } = core.QueryBuilder.revokeDeckAccessTokenIssuerSigningKey();
1443
+ const result = await this.connection.execute(query, { id });
1444
+ return result["deckAccessTokenIssuerSigningKeyRevoke"];
1445
+ }
1446
+ /**
1447
+ * Grant or update one OAuth app's selected-deck access.
1448
+ */
1449
+ async grantApiApplicationAccess(input) {
1450
+ const { query } = core.QueryBuilder.grantDeckApiApplicationAccess();
1451
+ const variables = core.QueryBuilder.deckApiApplicationAccessGrantVariables(input);
1452
+ const result = await this.connection.execute(query, variables);
1453
+ return result["deckApiApplicationAccessGrant"];
1454
+ }
1455
+ /**
1456
+ * Revoke one OAuth app's selected-deck access.
1457
+ */
1458
+ async revokeApiApplicationAccess(deckId, apiApplicationId) {
1459
+ const { query } = core.QueryBuilder.revokeDeckApiApplicationAccess();
1460
+ const variables = core.QueryBuilder.deckApiApplicationAccessRevokeVariables(deckId, apiApplicationId);
1461
+ const result = await this.connection.execute(query, variables);
1462
+ return Boolean(result["deckApiApplicationAccessRevoke"]);
1463
+ }
1464
+ /**
1465
+ * Exchange the current trusted API application credential for a deck access token.
1466
+ */
1467
+ async exchangeAccessToken(input) {
1468
+ this.config.requireSecretCredential("decks.exchangeAccessToken");
1469
+ const { query } = core.QueryBuilder.exchangeDeckAccessToken();
1470
+ const variables = core.QueryBuilder.deckAccessTokenExchangeVariables(input);
1471
+ const result = await this.connection.execute(query, variables);
1472
+ return result["deckAccessTokenExchange"];
1473
+ }
1474
+ /**
1475
+ * Revoke an exchanged deck access token.
1476
+ */
1477
+ async revokeAccessToken(id) {
1478
+ this.config.requireSecretCredential("decks.revokeAccessToken");
1479
+ const { query } = core.QueryBuilder.revokeDeckAccessToken();
1480
+ const result = await this.connection.execute(query, { id });
1481
+ return Boolean(result["deckAccessTokenRevoke"]);
1482
+ }
928
1483
  /**
929
1484
  * Hydrate third-party-owned deck entries without storing them in CardDB.
930
1485
  */
@@ -1041,9 +1596,13 @@ var RecordsResource = class extends BaseResource {
1041
1596
  resolveLinks: options.resolveLinks,
1042
1597
  first: options.first,
1043
1598
  after: options.after,
1044
- validateSchema: options.validateSchema
1599
+ validateSchema: options.validateSchema,
1600
+ includePricing: options.includePricing
1601
+ });
1602
+ const key = this.cacheKey("records", "search", {
1603
+ ...variables,
1604
+ includePricing: options.includePricing ?? false
1045
1605
  });
1046
- const key = this.cacheKey("records", "search", variables);
1047
1606
  const data = await this.withCache(key, "records", options, async () => {
1048
1607
  const result = await this.connection.execute(query, variables);
1049
1608
  return result["searchRecords"];
@@ -1061,9 +1620,12 @@ var RecordsResource = class extends BaseResource {
1061
1620
  * const record = await client.records.get('550e8400-e29b-41d4-a716-446655440000')
1062
1621
  */
1063
1622
  async get(id, options = {}) {
1064
- const key = this.cacheKey("records", "get", { id });
1623
+ const key = this.cacheKey("records", "get", {
1624
+ id,
1625
+ includePricing: options.includePricing ?? false
1626
+ });
1065
1627
  return this.withCache(key, "records", options, async () => {
1066
- const { query } = core.QueryBuilder.fetchRecordById();
1628
+ const { query } = core.QueryBuilder.fetchRecordById({ includePricing: options.includePricing });
1067
1629
  const result = await this.connection.execute(query, { id });
1068
1630
  return result["fetchRecord"] ?? null;
1069
1631
  });
@@ -1095,10 +1657,13 @@ var RecordsResource = class extends BaseResource {
1095
1657
  publisherSlug,
1096
1658
  gameKey,
1097
1659
  datasetKey: options.datasetKey,
1098
- identifier: options.identifier
1660
+ identifier: options.identifier,
1661
+ includePricing: options.includePricing ?? false
1099
1662
  });
1100
1663
  return this.withCache(key, "records", options, async () => {
1101
- const { query } = core.QueryBuilder.fetchRecordByIdentifier();
1664
+ const { query } = core.QueryBuilder.fetchRecordByIdentifier({
1665
+ includePricing: options.includePricing
1666
+ });
1102
1667
  const result = await this.connection.execute(query, {
1103
1668
  publisherSlug,
1104
1669
  gameKey,
@@ -1136,10 +1701,13 @@ var RecordsResource = class extends BaseResource {
1136
1701
  publisherSlug,
1137
1702
  gameKey,
1138
1703
  datasetKey: options.datasetKey,
1139
- identifiers: options.identifiers
1704
+ identifiers: options.identifiers,
1705
+ includePricing: options.includePricing ?? false
1140
1706
  });
1141
1707
  return this.withCache(key, "records", options, async () => {
1142
- const { query } = core.QueryBuilder.fetchRecordsByIdentifier();
1708
+ const { query } = core.QueryBuilder.fetchRecordsByIdentifier({
1709
+ includePricing: options.includePricing
1710
+ });
1143
1711
  const result = await this.connection.execute(query, {
1144
1712
  publisherSlug,
1145
1713
  gameKey,
@@ -1157,9 +1725,12 @@ var RecordsResource = class extends BaseResource {
1157
1725
  */
1158
1726
  async getMany(ids, options = {}) {
1159
1727
  if (ids.length === 0) return [];
1160
- const key = this.cacheKey("records", "getMany", { ids });
1728
+ const key = this.cacheKey("records", "getMany", {
1729
+ ids,
1730
+ includePricing: options.includePricing ?? false
1731
+ });
1161
1732
  return this.withCache(key, "records", options, async () => {
1162
- const { query } = core.QueryBuilder.fetchRecords();
1733
+ const { query } = core.QueryBuilder.fetchRecords({ includePricing: options.includePricing });
1163
1734
  const result = await this.connection.execute(query, { ids });
1164
1735
  return result["fetchRecords"] ?? [];
1165
1736
  });
@@ -1320,7 +1891,11 @@ var CardDBClient = class _CardDBClient {
1320
1891
  withConfig(overrides) {
1321
1892
  const mergedConfig = this.config.merge(overrides);
1322
1893
  return new _CardDBClient({
1323
- apiKey: mergedConfig.apiKey,
1894
+ apiKey: mergedConfig.configApiKey(),
1895
+ publishableKey: mergedConfig.publishableKey,
1896
+ secretKey: mergedConfig.secretKey,
1897
+ accessToken: mergedConfig.accessToken,
1898
+ environment: mergedConfig.environment,
1324
1899
  endpoint: mergedConfig.endpoint,
1325
1900
  timeout: mergedConfig.timeout,
1326
1901
  openTimeout: mergedConfig.openTimeout,