@carddb/node 0.1.5 → 0.2.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/README.md +53 -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,58 @@ 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
|
+
|
|
62
|
+
## Publisher Management
|
|
63
|
+
|
|
64
|
+
Use `secretKey` in trusted server runtimes for publisher workflows such as game management, import formats, import jobs, record upserts/deletes, file-backed imports, and exports.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const client = new CardDBClient({ secretKey: process.env.CARDDB_SECRET_KEY })
|
|
68
|
+
|
|
69
|
+
const game = await client.games.create({
|
|
70
|
+
publisherId: 'publisher_uuid',
|
|
71
|
+
key: 'tcg',
|
|
72
|
+
name: 'Example TCG',
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const upsert = await client.records.upsertBatch({
|
|
76
|
+
gameId: game.id,
|
|
77
|
+
datasetKey: 'cards',
|
|
78
|
+
records: [{ code: 'CARD-001', name: 'Example Card' }],
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
if (upsert.job) {
|
|
82
|
+
await client.imports.waitForJob(upsert.job.id)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const exportJob = await client.exports.run({ gameId: game.id, datasetKey: 'cards' })
|
|
86
|
+
await client.exports.waitForJob(exportJob.id)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See the main README for direct payload, uploaded file, source URL, advanced schema-creating import, bulk delete preview/execution, export URL refresh, and release-prep examples. See `publisher-content-pipeline.example.ts` for a CI/CD-style content sync script.
|
|
90
|
+
|
|
39
91
|
## MemoryCache
|
|
40
92
|
|
|
41
93
|
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.5",
|
|
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.5",
|
|
54
|
+
"@carddb/core": "0.2.5"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0.0"
|