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