@carddb/node 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/README.md +24 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ deno add npm:@carddb/node
|
|
|
18
18
|
import { CardDBClient, MemoryCache, gte, ilike } from '@carddb/node'
|
|
19
19
|
|
|
20
20
|
const client = new CardDBClient({
|
|
21
|
-
|
|
21
|
+
secretKey: 'carddb_sk_xxx...', // Server-side API key
|
|
22
22
|
cache: new MemoryCache(), // Optional in-memory caching
|
|
23
23
|
defaultPublisher: 'pokemon',
|
|
24
24
|
defaultGame: 'tcg',
|
|
@@ -36,6 +36,29 @@ for await (const card of cards) {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## App-Owned Decks
|
|
40
|
+
|
|
41
|
+
Use `secretKey` only in trusted server runtimes. App-owned deck helpers such as external-reference upsert and deck access token exchange require `secretKey` or the legacy `apiKey` option. If `accessToken` or `publishableKey` would be sent instead, those secret-only helpers fail before making a request.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const upsert = await client.decks.upsertByExternalRef({
|
|
45
|
+
externalRef: 'metafy:guide:123:deck:456',
|
|
46
|
+
idempotencyKey: 'sync-123',
|
|
47
|
+
publisherSlug: 'pokemon',
|
|
48
|
+
gameKey: 'tcg',
|
|
49
|
+
title: 'Course Deck',
|
|
50
|
+
accessMode: 'AUTHORIZED_TOKEN',
|
|
51
|
+
discoverability: 'UNLISTED',
|
|
52
|
+
entries: [{ datasetKey: 'cards', identifier: 'CARD-001', quantity: 4 }],
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const exchange = await client.decks.exchangeAccessToken({
|
|
56
|
+
deckId: upsert.deck.id,
|
|
57
|
+
readMode: 'FULL',
|
|
58
|
+
externalSubject: 'user_123',
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
39
62
|
## MemoryCache
|
|
40
63
|
|
|
41
64
|
Simple in-memory cache with TTL support:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carddb/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CardDB client for Node.js, Bun, and Deno",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"url": "https://github.com/carddb/carddb-js/issues"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@carddb/client": "0.
|
|
54
|
-
"@carddb/core": "0.
|
|
53
|
+
"@carddb/client": "0.2.0",
|
|
54
|
+
"@carddb/core": "0.2.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0.0"
|