@carddb/client 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 +67 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -61
- package/dist/index.d.ts +41 -61
- package/dist/index.js +67 -140
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -921,14 +921,27 @@ var DecksResource = class extends BaseResource {
|
|
|
921
921
|
/**
|
|
922
922
|
* Fetch a deck by UUID using the ownership-aware `deck` API.
|
|
923
923
|
*/
|
|
924
|
-
async get(id, options
|
|
925
|
-
const
|
|
924
|
+
async get(id, options) {
|
|
925
|
+
const variables = core.QueryBuilder.deckReadVariables(id, options.readState, options.version);
|
|
926
|
+
const key = this.cacheKey("decks", "get", variables);
|
|
926
927
|
return this.withCache(key, "decks", options, async () => {
|
|
927
928
|
const { query } = core.QueryBuilder.deckById();
|
|
928
|
-
const result = await this.connection.execute(query,
|
|
929
|
+
const result = await this.connection.execute(query, variables);
|
|
929
930
|
return result["deck"] ?? null;
|
|
930
931
|
});
|
|
931
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* Fetch mutable draft data for a deck by UUID.
|
|
935
|
+
*/
|
|
936
|
+
async getDraft(id, options = {}) {
|
|
937
|
+
return this.get(id, { ...options, readState: "DRAFT" });
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Fetch immutable published data for a deck by UUID.
|
|
941
|
+
*/
|
|
942
|
+
async getPublished(id, options = {}) {
|
|
943
|
+
return this.get(id, { ...options, readState: "PUBLISHED", version: options.version });
|
|
944
|
+
}
|
|
932
945
|
/**
|
|
933
946
|
* Fetch one deck owned by the current account or API application.
|
|
934
947
|
*/
|
|
@@ -976,14 +989,35 @@ var DecksResource = class extends BaseResource {
|
|
|
976
989
|
/**
|
|
977
990
|
* Fetch by external reference using the ownership-aware `deckByExternalRef` API.
|
|
978
991
|
*/
|
|
979
|
-
async getByExternalRef(externalRef, options
|
|
980
|
-
const
|
|
992
|
+
async getByExternalRef(externalRef, options) {
|
|
993
|
+
const variables = core.QueryBuilder.deckExternalRefReadVariables(
|
|
994
|
+
externalRef,
|
|
995
|
+
options.readState,
|
|
996
|
+
options.version
|
|
997
|
+
);
|
|
998
|
+
const key = this.cacheKey("decks", "getByExternalRef", variables);
|
|
981
999
|
return this.withCache(key, "decks", options, async () => {
|
|
982
1000
|
const { query } = core.QueryBuilder.deckByExternalRef();
|
|
983
|
-
const result = await this.connection.execute(query,
|
|
1001
|
+
const result = await this.connection.execute(query, variables);
|
|
984
1002
|
return result["deckByExternalRef"] ?? null;
|
|
985
1003
|
});
|
|
986
1004
|
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Fetch mutable draft data by API-application external reference.
|
|
1007
|
+
*/
|
|
1008
|
+
async getDraftByExternalRef(externalRef, options = {}) {
|
|
1009
|
+
return this.getByExternalRef(externalRef, { ...options, readState: "DRAFT" });
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Fetch immutable published data by API-application external reference.
|
|
1013
|
+
*/
|
|
1014
|
+
async getPublishedByExternalRef(externalRef, options = {}) {
|
|
1015
|
+
return this.getByExternalRef(externalRef, {
|
|
1016
|
+
...options,
|
|
1017
|
+
readState: "PUBLISHED",
|
|
1018
|
+
version: options.version
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
987
1021
|
/**
|
|
988
1022
|
* List decks owned by the current account or API application.
|
|
989
1023
|
*/
|
|
@@ -1086,39 +1120,6 @@ var DecksResource = class extends BaseResource {
|
|
|
1086
1120
|
nextPageLoader: async (cursor) => this.listVersions(deckId, { ...options, after: cursor })
|
|
1087
1121
|
});
|
|
1088
1122
|
}
|
|
1089
|
-
/**
|
|
1090
|
-
* Fetch current draft data using a revocable preview token.
|
|
1091
|
-
*/
|
|
1092
|
-
async preview(token, options = {}) {
|
|
1093
|
-
const key = this.cacheKey("decks", "preview", { token });
|
|
1094
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1095
|
-
const { query } = core.QueryBuilder.deckPreview();
|
|
1096
|
-
const result = await this.connection.execute(query, { token });
|
|
1097
|
-
return result["deckPreview"] ?? null;
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Fetch published embed data using a revocable embed token.
|
|
1102
|
-
*/
|
|
1103
|
-
async embed(token, options = {}) {
|
|
1104
|
-
const key = this.cacheKey("decks", "embed", { token });
|
|
1105
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1106
|
-
const { query } = core.QueryBuilder.deckEmbed();
|
|
1107
|
-
const result = await this.connection.execute(query, { token });
|
|
1108
|
-
return result["deckEmbed"] ?? null;
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
/**
|
|
1112
|
-
* Fetch token-authorized published data using an exchanged access token.
|
|
1113
|
-
*/
|
|
1114
|
-
async access(token, options = {}) {
|
|
1115
|
-
const key = this.cacheKey("decks", "access", { token });
|
|
1116
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1117
|
-
const { query } = core.QueryBuilder.deckAccess();
|
|
1118
|
-
const result = await this.connection.execute(query, { token });
|
|
1119
|
-
return result["deckAccess"] ?? null;
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
1123
|
/**
|
|
1123
1124
|
* Compare the current draft against the latest published version.
|
|
1124
1125
|
*/
|
|
@@ -1206,39 +1207,6 @@ var DecksResource = class extends BaseResource {
|
|
|
1206
1207
|
return result["deckCollaborators"];
|
|
1207
1208
|
});
|
|
1208
1209
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
* List draft preview tokens for a deck.
|
|
1211
|
-
*/
|
|
1212
|
-
async listPreviewTokens(deckId, options = {}) {
|
|
1213
|
-
const key = this.cacheKey("decks", "listPreviewTokens", { deckId });
|
|
1214
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1215
|
-
const { query } = core.QueryBuilder.deckPreviewTokens();
|
|
1216
|
-
const result = await this.connection.execute(query, { deckId });
|
|
1217
|
-
return result["deckPreviewTokens"];
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* List published embed tokens for a deck.
|
|
1222
|
-
*/
|
|
1223
|
-
async listEmbedTokens(deckId, options = {}) {
|
|
1224
|
-
const key = this.cacheKey("decks", "listEmbedTokens", { deckId });
|
|
1225
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1226
|
-
const { query } = core.QueryBuilder.deckEmbedTokens();
|
|
1227
|
-
const result = await this.connection.execute(query, { deckId });
|
|
1228
|
-
return result["deckEmbedTokens"];
|
|
1229
|
-
});
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* List trusted access token issuers for a deck.
|
|
1233
|
-
*/
|
|
1234
|
-
async listAccessTokenIssuers(deckId, options = {}) {
|
|
1235
|
-
const key = this.cacheKey("decks", "listAccessTokenIssuers", { deckId });
|
|
1236
|
-
return this.withCache(key, "decks", options, async () => {
|
|
1237
|
-
const { query } = core.QueryBuilder.deckAccessTokenIssuers();
|
|
1238
|
-
const result = await this.connection.execute(query, { deckId });
|
|
1239
|
-
return result["deckAccessTokenIssuers"];
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
1210
|
/**
|
|
1243
1211
|
* List API applications with explicit access to one owned deck.
|
|
1244
1212
|
*/
|
|
@@ -1523,63 +1491,32 @@ var DecksResource = class extends BaseResource {
|
|
|
1523
1491
|
return Boolean(result["deckCollaboratorRemove"]);
|
|
1524
1492
|
}
|
|
1525
1493
|
/**
|
|
1526
|
-
* Create a
|
|
1527
|
-
*/
|
|
1528
|
-
async createPreviewToken(input) {
|
|
1529
|
-
const { query } = core.QueryBuilder.createDeckPreviewToken();
|
|
1530
|
-
const variables = core.QueryBuilder.deckPreviewTokenCreateVariables(input);
|
|
1531
|
-
const result = await this.connection.execute(query, variables);
|
|
1532
|
-
return result["deckPreviewTokenCreate"];
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Revoke a draft preview token.
|
|
1536
|
-
*/
|
|
1537
|
-
async revokePreviewToken(id) {
|
|
1538
|
-
const { query } = core.QueryBuilder.revokeDeckPreviewToken();
|
|
1539
|
-
const result = await this.connection.execute(query, { id });
|
|
1540
|
-
return Boolean(result["deckPreviewTokenRevoke"]);
|
|
1541
|
-
}
|
|
1542
|
-
/**
|
|
1543
|
-
* Create a revocable published embed token.
|
|
1544
|
-
*/
|
|
1545
|
-
async createEmbedToken(input) {
|
|
1546
|
-
const { query } = core.QueryBuilder.createDeckEmbedToken();
|
|
1547
|
-
const variables = core.QueryBuilder.deckEmbedTokenCreateVariables(input);
|
|
1548
|
-
const result = await this.connection.execute(query, variables);
|
|
1549
|
-
return result["deckEmbedTokenCreate"];
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
* Revoke a published embed token.
|
|
1553
|
-
*/
|
|
1554
|
-
async revokeEmbedToken(id) {
|
|
1555
|
-
const { query } = core.QueryBuilder.revokeDeckEmbedToken();
|
|
1556
|
-
const result = await this.connection.execute(query, { id });
|
|
1557
|
-
return Boolean(result["deckEmbedTokenRevoke"]);
|
|
1558
|
-
}
|
|
1559
|
-
/**
|
|
1560
|
-
* Trust the current API application to exchange short-lived deck access tokens.
|
|
1494
|
+
* Create a unified deck token issuer for the current secret-key API application.
|
|
1561
1495
|
*/
|
|
1562
|
-
async
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1496
|
+
async createTokenIssuer(input) {
|
|
1497
|
+
this.config.requireSecretCredential("decks.createTokenIssuer");
|
|
1498
|
+
const { query } = core.QueryBuilder.createDeckTokenIssuer();
|
|
1499
|
+
const variables = core.QueryBuilder.deckTokenIssuerCreateVariables(input);
|
|
1565
1500
|
const result = await this.connection.execute(query, variables);
|
|
1566
|
-
return result["
|
|
1501
|
+
return result["deckTokenIssuerCreate"];
|
|
1567
1502
|
}
|
|
1568
1503
|
/**
|
|
1569
|
-
* Revoke a
|
|
1504
|
+
* Revoke a unified deck token issuer.
|
|
1570
1505
|
*/
|
|
1571
|
-
async
|
|
1572
|
-
|
|
1506
|
+
async revokeTokenIssuer(id) {
|
|
1507
|
+
this.config.requireSecretCredential("decks.revokeTokenIssuer");
|
|
1508
|
+
const { query } = core.QueryBuilder.revokeDeckTokenIssuer();
|
|
1573
1509
|
const result = await this.connection.execute(query, { id });
|
|
1574
|
-
return Boolean(result["
|
|
1510
|
+
return Boolean(result["deckTokenIssuerRevoke"]);
|
|
1575
1511
|
}
|
|
1576
1512
|
/**
|
|
1577
|
-
* Revoke only the direct signing key for a
|
|
1513
|
+
* Revoke only the direct signing key for a unified deck token issuer.
|
|
1578
1514
|
*/
|
|
1579
|
-
async
|
|
1580
|
-
|
|
1515
|
+
async revokeTokenIssuerSigningKey(id) {
|
|
1516
|
+
this.config.requireSecretCredential("decks.revokeTokenIssuerSigningKey");
|
|
1517
|
+
const { query } = core.QueryBuilder.revokeDeckTokenIssuerSigningKey();
|
|
1581
1518
|
const result = await this.connection.execute(query, { id });
|
|
1582
|
-
return result["
|
|
1519
|
+
return result["deckTokenIssuerSigningKeyRevoke"];
|
|
1583
1520
|
}
|
|
1584
1521
|
/**
|
|
1585
1522
|
* Grant or update one OAuth app's selected-deck access.
|
|
@@ -1600,33 +1537,23 @@ var DecksResource = class extends BaseResource {
|
|
|
1600
1537
|
return Boolean(result["deckApiApplicationAccessRevoke"]);
|
|
1601
1538
|
}
|
|
1602
1539
|
/**
|
|
1603
|
-
* Exchange the current
|
|
1604
|
-
*/
|
|
1605
|
-
async exchangeAccessToken(input) {
|
|
1606
|
-
this.config.requireSecretCredential("decks.exchangeAccessToken");
|
|
1607
|
-
const { query } = core.QueryBuilder.exchangeDeckAccessToken();
|
|
1608
|
-
const variables = core.QueryBuilder.deckAccessTokenExchangeVariables(input);
|
|
1609
|
-
const result = await this.connection.execute(query, variables);
|
|
1610
|
-
return result["deckAccessTokenExchange"];
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Exchange the current secret API application credential for an app-owned deck session token.
|
|
1540
|
+
* Exchange the current secret API application credential for a unified deck token.
|
|
1614
1541
|
*/
|
|
1615
|
-
async
|
|
1616
|
-
this.config.requireSecretCredential("decks.
|
|
1617
|
-
const { query } = core.QueryBuilder.
|
|
1618
|
-
const variables = core.QueryBuilder.
|
|
1542
|
+
async exchangeToken(input) {
|
|
1543
|
+
this.config.requireSecretCredential("decks.exchangeToken");
|
|
1544
|
+
const { query } = core.QueryBuilder.exchangeDeckToken();
|
|
1545
|
+
const variables = core.QueryBuilder.deckTokenExchangeVariables(input);
|
|
1619
1546
|
const result = await this.connection.execute(query, variables);
|
|
1620
|
-
return result["
|
|
1547
|
+
return result["deckTokenExchange"];
|
|
1621
1548
|
}
|
|
1622
1549
|
/**
|
|
1623
|
-
* Revoke an exchanged deck
|
|
1550
|
+
* Revoke an exchanged unified deck token.
|
|
1624
1551
|
*/
|
|
1625
|
-
async
|
|
1626
|
-
this.config.requireSecretCredential("decks.
|
|
1627
|
-
const { query } = core.QueryBuilder.
|
|
1552
|
+
async revokeToken(id) {
|
|
1553
|
+
this.config.requireSecretCredential("decks.revokeToken");
|
|
1554
|
+
const { query } = core.QueryBuilder.revokeDeckToken();
|
|
1628
1555
|
const result = await this.connection.execute(query, { id });
|
|
1629
|
-
return Boolean(result["
|
|
1556
|
+
return Boolean(result["deckTokenRevoke"]);
|
|
1630
1557
|
}
|
|
1631
1558
|
/**
|
|
1632
1559
|
* Hydrate third-party-owned deck entries without storing them in CardDB.
|