@goodz-core/sdk 0.3.0 → 0.3.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @goodz-core/sdk
2
2
 
3
- Official SDK for **GoodZ.Core** — a type-safe API client for building GoodZ-powered applications. This package provides a zero-dependency HTTP client that speaks the tRPC wire protocol directly, along with OAuth helpers, Z-coin utilities, and full TypeScript type coverage.
3
+ Official SDK for the **GoodZ** ecosystem — a unified, type-safe API client for building GoodZ-powered applications. One package covers all five products: Core, Commerce, Exchange, Alive, and Shops. Stripe-style namespaces route requests to the correct service transparently.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,7 +10,7 @@ npm install @goodz-core/sdk
10
10
  pnpm add @goodz-core/sdk
11
11
  ```
12
12
 
13
- The SDK has only one runtime dependency (`superjson`) and requires Node.js 18+. It works in any JavaScript runtime that supports the Fetch API (Node.js, Deno, Bun, Cloudflare Workers, browsers).
13
+ Runtime dependency: `superjson` only. Works in Node.js 18+, Deno, Bun, Cloudflare Workers, and browsers (any runtime with Fetch API).
14
14
 
15
15
  ## Quick Start
16
16
 
@@ -21,11 +21,9 @@ const goodz = createGoodZClient({
21
21
  accessToken: "your-jwt-token",
22
22
  });
23
23
 
24
- // All methods are fully typed IDE autocomplete works out of the box
24
+ // Coresettlement
25
25
  const balance = await goodz.zcoin.getMyBalance();
26
- console.log(`Balance: ${balance.balance} hundredths`);
27
-
28
- const result = await goodz.zcoin.commercialTransfer({
26
+ const trade = await goodz.zcoin.commercialTransfer({
29
27
  instanceId: 90447,
30
28
  buyerUserId: 1,
31
29
  sellerUserId: 2,
@@ -34,118 +32,271 @@ const result = await goodz.zcoin.commercialTransfer({
34
32
  referenceId: "order-abc-123",
35
33
  appClientId: "od_myapp",
36
34
  });
37
- console.log(`Trade ID: ${result.tradeId}`);
35
+
36
+ // Commerce — create a shop and launch a campaign
37
+ const shop = await goodz.commerce.createShop({ name: "Frostpeak Store" });
38
+ const campaign = await goodz.commerce.launchCampaign({ shopId: shop.id, name: "Spring Drop" });
39
+ const order = await goodz.commerce.executePurchase({ campaignId: campaign.id, quantity: 1 });
40
+
41
+ // Exchange — list an item for sale
42
+ const listing = await goodz.exchange.createListing({
43
+ instanceId: 42,
44
+ listingType: "fixed_price",
45
+ askPrice: 2000,
46
+ });
47
+ const data = await goodz.exchange.getMarketData({ coreGoodzId: 42 });
48
+
49
+ // Alive — chat with a character
50
+ const reply = await goodz.alive.sendMessage({
51
+ instanceId: 1,
52
+ userId: 1,
53
+ message: "What's your favorite memory?",
54
+ });
38
55
  ```
39
56
 
40
57
  ## Architecture
41
58
 
42
- The SDK is designed around three principles:
43
-
44
- **Zero tRPC dependency.** Unlike a typical tRPC client that requires `@trpc/client` and `@trpc/server` as peer dependencies (and transitively pulls in the entire server type tree), this SDK speaks the tRPC HTTP wire protocol directly using `fetch` + `superjson`. This means consumers never need to install tRPC packages, and the DTS bundle is fully self-contained.
59
+ The SDK is built on three principles:
45
60
 
46
- **Hand-crafted types as API contract.** All input/output types are defined inside the SDK itself (in `src/types.ts`), mirroring the Zod schemas on the Core server. This is the same approach used by the Stripe SDK the types serve as both documentation and compile-time contract. When Core's API evolves, the SDK types are updated and a new version is published.
61
+ **One client, all services.** `createGoodZClient()` returns a single object with namespaces for every GoodZ product. Core uses tRPC HTTP wire protocol; sub-sites (Commerce, Exchange, Alive) use MCP JSON-RPC 2.0. The client handles routing transparently developers never need to know which protocol a method uses.
47
62
 
48
- **Namespace-based API surface.** Methods are organized into logical namespaces (`zcoin`, `inventory`, `collectible`, `user`, `auth`, `ip`) that mirror Core's tRPC router structure. Each namespace method is a thin wrapper around the transport layer, providing typed inputs and outputs.
63
+ **Hand-crafted types as API contract.** All input/output types are defined inside the SDK itself, mirroring the Zod schemas on Core and the MCP tool schemas on sub-sites. This is the same approach used by the Stripe SDK — types serve as both documentation and compile-time contract. When any service's API evolves, the SDK types are updated and a new version is published.
49
64
 
50
- ## API Reference
65
+ **Zero tRPC dependency.** The SDK speaks the tRPC wire protocol directly using `fetch` + `superjson`, and speaks MCP JSON-RPC natively. Consumers never need to install `@trpc/client`, `@trpc/server`, or any MCP client library.
51
66
 
52
- ### Client Configuration
67
+ ## Client Configuration
53
68
 
54
69
  ```ts
55
70
  interface GoodZClientConfig {
56
71
  coreUrl?: string; // Default: "https://goodzcore.manus.space"
72
+ commerceUrl?: string; // Default: "https://goodzcommerce.manus.space"
73
+ exchangeUrl?: string; // Default: "https://goodzexchange.manus.space"
74
+ aliveUrl?: string; // Default: "https://goodzalive.manus.space"
57
75
  accessToken?: string; // Static JWT token
58
76
  getAccessToken?: () => string | Promise<string>; // Dynamic token provider
59
77
  headers?: Record<string, string>; // Custom headers for every request
60
78
  }
61
79
  ```
62
80
 
63
- The `getAccessToken` function takes precedence over `accessToken` when both are provided. Use it for auto-refresh scenarios.
81
+ The `getAccessToken` function takes precedence over `accessToken` when both are provided. Use it for auto-refresh scenarios. Sub-site URLs default to production endpoints and rarely need to be changed.
64
82
 
65
- ### Namespaces
83
+ ## API Reference — Core Namespaces
66
84
 
67
- #### `goodz.zcoin` Z-coin Payment & Settlement
85
+ Core namespaces communicate via tRPC HTTP wire protocol with `goodzcore.manus.space`.
68
86
 
69
- The Z-coin namespace handles all monetary operations. These are the primary APIs that Commerce and Exchange apps use to process purchases.
87
+ ### `goodz.zcoin` — Z-coin Payment & Settlement
70
88
 
71
89
  | Method | Type | Description |
72
90
  |--------|------|-------------|
73
- | `getMyBalance()` | Query | Get authenticated user's Z-coin balance |
74
- | `getMyHistory(input?)` | Query | Get Z-coin transaction history with pagination |
75
- | `getDepositPackages(input?)` | Query | List available deposit packages with pricing |
76
- | `createDepositOrder(input)` | Mutation | Create a Stripe checkout session for Z-coin deposit |
91
+ | `getMyBalance()` | Query | Authenticated user's Z-coin balance |
92
+ | `getMyHistory(input?)` | Query | Transaction history with pagination |
93
+ | `getDepositPackages(input?)` | Query | Available deposit packages with pricing |
94
+ | `createDepositOrder(input)` | Mutation | Create Stripe checkout for Z-coin deposit |
77
95
  | `getDepositStatus(input)` | Query | Check deposit checkout session status |
78
- | `commercialTransfer(input)` | Mutation | Atomic Z-coin payment + ownership transfer |
79
- | `mintAndCharge(input)` | Mutation | Mint new instance + charge buyer atomically |
80
- | `chargeUser(input)` | Mutation | Charge user's Z-coin for in-app purchases |
81
- | `createDirectPurchaseOrder(input)` | Mutation | Create fiat-to-Z-coin direct purchase checkout |
96
+ | `commercialTransfer(input)` | Mutation | **Primary API for secondary market.** Atomic: debit buyer credit seller → transfer ownership |
97
+ | `mintAndCharge(input)` | Mutation | **Primary API for primary sales.** Atomic: mint instance charge buyer |
98
+ | `chargeUser(input)` | Mutation | Charge Z-coin for in-app purchases |
99
+ | `createDirectPurchaseOrder(input)` | Mutation | Fiat-to-Z-coin direct purchase checkout |
82
100
 
83
- **Key method: `commercialTransfer`** is the primary API for all secondary market transactions. It atomically debits the buyer's Z-coin balance, credits the seller (minus platform fee), and transfers card instance ownership — all in a single database transaction. The `referenceId` parameter provides idempotency, so duplicate calls (e.g., from retries) return the same result.
101
+ `commercialTransfer` is the most important method in the SDK. It atomically debits the buyer's Z-coin balance, credits the seller (minus platform fee), and transfers card instance ownership — all in a single database transaction. The `referenceId` parameter provides idempotency.
84
102
 
85
- **Key method: `mintAndCharge`** is the primary API for primary sales (gacha, direct-from-creator). It mints a new card instance and charges the buyer in one atomic operation. Requires prior mint authorization via `inventory.grantMintAuth`.
103
+ `mintAndCharge` is the primary API for primary sales (gacha, direct-from-creator). It mints a new card instance and charges the buyer in one atomic operation. Requires prior mint authorization via `inventory.grantMintAuth`.
86
104
 
87
- #### `goodz.inventory` — Card Instance Management
105
+ ### `goodz.inventory` — Card Instance Management
88
106
 
89
107
  | Method | Type | Description |
90
108
  |--------|------|-------------|
91
- | `getUserInventory(input)` | Query | Get a user's owned card instances |
109
+ | `getUserInventory(input)` | Query | User's owned card instances |
92
110
  | `confirmOwnership(input)` | Query | Check if user owns a specific card |
93
- | `mint(input)` | Mutation | Mint new card instances (requires authorization) |
94
- | `transfer(input)` | Mutation | Transfer a specific instance to another user |
95
- | `transferByCard(input)` | Mutation | Transfer instances by cardId (oldest first) |
96
- | `grantMintAuth(input)` | Mutation | Grant mint authorization to another user/app |
97
- | `transferHistory(input)` | Query | Get transfer/ownership history |
111
+ | `mint(input)` | Mutation | Mint new instances (requires authorization) |
112
+ | `transfer(input)` | Mutation | Transfer instance by instanceId |
113
+ | `transferByCard(input)` | Mutation | Transfer by cardId (oldest first) |
114
+ | `grantMintAuth(input)` | Mutation | Grant mint authorization to app/user |
115
+ | `transferHistory(input)` | Query | Ownership/transfer history |
98
116
 
99
- For commercial transactions (purchases, trades), always use `zcoin.commercialTransfer` or `zcoin.mintAndCharge` instead of the raw `transfer`/`mint` methods. The raw methods are intended for administrative operations and gift transfers only.
117
+ For commercial transactions, always use `zcoin.commercialTransfer` or `zcoin.mintAndCharge` instead of raw `transfer`/`mint`. The raw methods are for administrative operations and gift transfers only.
100
118
 
101
- #### `goodz.collectible` — Card & Instance Queries
119
+ ### `goodz.collectible` — Card & Instance Queries
102
120
 
103
121
  | Method | Type | Description |
104
122
  |--------|------|-------------|
105
- | `getInstanceById(input)` | Query | Get instance by numeric ID |
106
- | `getPublicInstance(input)` | Query | Get instance by instance code |
123
+ | `getInstanceById(input)` | Query | Instance by numeric ID |
124
+ | `getPublicInstance(input)` | Query | Instance by instance code |
107
125
  | `getPublicInstancesBatch(input)` | Query | Batch-fetch instances (max 100) |
108
- | `getCardProfile(input)` | Query | Get card metadata, rarity, series info |
109
- | `getShellImageUrl(input)` | Query | Get shell (packaging) image URL |
126
+ | `getCardProfile(input)` | Query | Card metadata, rarity, series info |
127
+ | `getShellImageUrl(input)` | Query | Shell (packaging) image URL |
110
128
 
111
- #### `goodz.user` — User Profiles
129
+ ### `goodz.ip` — IP Management (Franchise/Series/Card)
112
130
 
113
131
  | Method | Type | Description |
114
132
  |--------|------|-------------|
115
- | `getPublicProfile(input)` | Query | Get profile by openId |
116
- | `getPublicProfileById(input)` | Query | Get profile by internal userId |
133
+ | `getFranchise(input)` | Query | Franchise by ID or slug |
134
+ | `getSeries(input)` | Query | Series by ID or slug |
135
+ | `listSeriesByFranchise(input)` | Query | All series in a franchise |
136
+ | `getCard(input)` | Query | Card by ID |
137
+ | `listCardsBySeries(input)` | Query | All cards in a series |
117
138
 
118
- #### `goodz.auth` Authentication
139
+ ### `goodz.user` & `goodz.auth`
119
140
 
120
141
  | Method | Type | Description |
121
142
  |--------|------|-------------|
122
- | `me()` | Query | Get authenticated user's profile |
123
- | `getOAuthAppInfo(input)` | Query | Get OAuth app info by client ID |
143
+ | `user.getPublicProfile(input)` | Query | Profile by openId |
144
+ | `user.getPublicProfileById(input)` | Query | Profile by userId |
145
+ | `auth.me()` | Query | Authenticated user's profile |
146
+ | `auth.getOAuthAppInfo(input)` | Query | OAuth app info by clientId |
147
+
148
+ ## API Reference — Commerce Namespace
149
+
150
+ Commerce methods communicate via MCP JSON-RPC with `goodzcommerce.manus.space`. This namespace covers shop management, product assembly, campaigns, purchases, wholesale, and settlement.
151
+
152
+ ### Shop & Product Assembly
153
+
154
+ | Method | Description |
155
+ |--------|-------------|
156
+ | `createShop(input)` | Create a new shop |
157
+ | `getShopDashboard()` | Shop dashboard with stats |
158
+ | `createBatch(input)` | Create a product batch (fixed-price bundle) |
159
+ | `createGachaPool(input)` | Create a gacha/blind-box pool with probability weights |
160
+
161
+ ### Campaign Lifecycle
162
+
163
+ | Method | Description |
164
+ |--------|-------------|
165
+ | `launchCampaign(input)` | Launch a new sales campaign |
166
+ | `activateCampaign(input)` | Activate a paused campaign |
167
+ | `pauseCampaign(input)` | Pause an active campaign |
168
+ | `endCampaign(input)` | End a campaign permanently |
169
+ | `updateCampaign(input)` | Update campaign details |
170
+ | `getCampaignInfo(input)` | Get campaign info |
171
+ | `getCampaignItems(input)` | Get items in a campaign |
172
+
173
+ ### Purchase & Orders
174
+
175
+ | Method | Description |
176
+ |--------|-------------|
177
+ | `executePurchase(input)` | Execute a purchase (direct or gacha draw) |
178
+ | `getMyOrders()` | User's order history |
179
+
180
+ ### Wholesale
181
+
182
+ | Method | Description |
183
+ |--------|-------------|
184
+ | `publishToWholesale(input)` | Publish batch to wholesale market |
185
+ | `browseWholesale()` | Browse wholesale listings |
186
+ | `procureBatch(input)` | Procure a wholesale batch for resale |
187
+
188
+ ### Inventory & Fulfillment
189
+
190
+ | Method | Description |
191
+ |--------|-------------|
192
+ | `manageInventory(input)` | View/manage shop inventory |
193
+ | `registerInstances(input)` | Register minted instances to shop |
194
+ | `mintToInventory(input)` | Mint + register in one step |
195
+ | `redeemPhysical(input)` | Redeem a physical item |
196
+
197
+ ### Settlement & Discovery
198
+
199
+ | Method | Description |
200
+ |--------|-------------|
201
+ | `getSettlementReport()` | Revenue and settlement report |
202
+ | `searchMarketplace(input)` | Search across all shops |
203
+ | `getShopsByBlueprint(input)` | Find shops selling a specific card |
204
+
205
+ ### Webhooks & App Management
206
+
207
+ | Method | Description |
208
+ |--------|-------------|
209
+ | `registerWebhook(input)` | Register event webhook |
210
+ | `listWebhooks()` | List registered webhooks |
211
+ | `testWebhook(input)` | Test a webhook endpoint |
212
+ | `deleteWebhook(input)` | Delete a webhook |
213
+ | `registerApp(input)` | Register an app on Commerce |
214
+ | `updateApp(input)` | Update app details |
215
+ | `listMyApps()` | List your registered apps |
216
+ | `getAuthUrl()` | Get Commerce OAuth URL |
217
+
218
+ ### Commerce Escape Hatch
219
+
220
+ ```ts
221
+ // For MCP tools not yet in the typed API
222
+ const result = await goodz.commerce.rawTool("some_new_tool", { key: "value" });
223
+ ```
124
224
 
125
- #### `goodz.ip`IP Management (Franchise/Series/Card)
225
+ ## API Reference Exchange Namespace
126
226
 
127
- | Method | Type | Description |
128
- |--------|------|-------------|
129
- | `getFranchise(input)` | Query | Get franchise by ID or slug |
130
- | `getSeries(input)` | Query | Get series by ID or slug |
131
- | `listSeriesByFranchise(input)` | Query | List all series in a franchise |
132
- | `getCard(input)` | Query | Get card by ID |
133
- | `listCardsBySeries(input)` | Query | List all cards in a series |
227
+ Exchange methods communicate via MCP JSON-RPC with `goodzexchange.manus.space`. This namespace covers the secondary market: listings, auctions, want-to-buy requests, P2P trades, and market data.
228
+
229
+ ### Marketplace & Listings
230
+
231
+ | Method | Description |
232
+ |--------|-------------|
233
+ | `browseMarketplace(input?)` | Browse active listings with filters |
234
+ | `getListingDetail(input)` | Get listing details |
235
+ | `createListing(input)` | Create listing (fixed_price or auction). Core locks the instance |
236
+ | `cancelListing(input)` | Cancel listing. Core unlocks the instance |
237
+
238
+ ### Purchase & Bidding
239
+
240
+ | Method | Description |
241
+ |--------|-------------|
242
+ | `buyListing(input)` | Buy a fixed-price listing. Z-coin debit + ownership transfer |
243
+ | `placeBid(input)` | Bid on auction. If meets buy-now price → instant purchase |
244
+ | `getBids(input)` | All bids for an auction (highest first) |
245
+
246
+ ### Want-to-Buy (WTB)
247
+
248
+ | Method | Description |
249
+ |--------|-------------|
250
+ | `createWtb(input)` | Post a want-to-buy request |
251
+ | `fulfillWtb(input)` | Fulfill a WTB by offering your item |
252
+ | `cancelWtb(input)` | Cancel your WTB request |
134
253
 
135
- ### Raw Escape Hatches
254
+ ### P2P Trade
136
255
 
137
- For routes not yet covered by the typed namespaces, use the raw methods:
256
+ | Method | Description |
257
+ |--------|-------------|
258
+ | `proposeTrade(input)` | Propose an item swap (optional Z-coin compensation) |
259
+ | `respondToTrade(input)` | Accept/reject trade. If accepted → all items transfer atomically |
260
+
261
+ ### Watchlist & Market Data
262
+
263
+ | Method | Description |
264
+ |--------|-------------|
265
+ | `getWatchlist()` | Your watchlist |
266
+ | `addToWatchlist(input)` | Add to watchlist |
267
+ | `removeFromWatchlist(input)` | Remove from watchlist |
268
+ | `getMarketData(input)` | Price history, floor price, volume, trends |
269
+
270
+ ### Exchange Escape Hatch
138
271
 
139
272
  ```ts
140
- const data = await goodz.rawQuery("some.newRoute", { id: 123 });
141
- const result = await goodz.rawMutation("some.newMutation", { name: "test" });
273
+ const result = await goodz.exchange.rawTool("some_new_tool", { key: "value" });
142
274
  ```
143
275
 
144
- ## Authentication
276
+ ## API Reference — Alive Namespace
277
+
278
+ Alive methods communicate via MCP JSON-RPC with `goodzalive.manus.space`. This namespace powers AI companion interactions: memory, intimacy, context building, and conversation.
279
+
280
+ | Method | Description |
281
+ |--------|-------------|
282
+ | `storeMemory(input)` | Store a memory for a character-user pair |
283
+ | `recallMemories(input)` | Semantic search for relevant memories |
284
+ | `forgetMemory(input)` | Delete a specific memory |
285
+ | `getIntimacy(input)` | Get intimacy/affection state between character and user |
286
+ | `updateIntimacy(input)` | Update intimacy level after interaction |
287
+ | `buildContext(input)` | Build full AI context (profile + memories + history + system prompt) |
288
+ | `classifyIntent(input)` | Classify user message into intent category |
289
+ | `sendMessage(input)` | Send message → get character response (includes memory/intimacy processing) |
290
+
291
+ ### Alive Escape Hatch
292
+
293
+ ```ts
294
+ const result = await goodz.alive.rawTool("some_new_tool", { key: "value" });
295
+ ```
145
296
 
146
- ### Server-to-Server with Static Token
297
+ ## Authentication
147
298
 
148
- The simplest approach for backend services:
299
+ ### Static Token (simplest)
149
300
 
150
301
  ```ts
151
302
  const goodz = createGoodZClient({
@@ -169,7 +320,6 @@ const tokenManager = new TokenManager({
169
320
  expiresAt: savedExpiresAt,
170
321
  },
171
322
  onTokenRefresh: async (tokens) => {
172
- // Persist refreshed tokens to your database
173
323
  await db.update(appTokens).set({
174
324
  accessToken: tokens.accessToken,
175
325
  refreshToken: tokens.refreshToken,
@@ -198,7 +348,7 @@ const authUrl = buildAuthorizationUrl({
198
348
  state: crypto.randomUUID(),
199
349
  });
200
350
 
201
- // Step 2: Exchange code for tokens in your callback handler
351
+ // Step 2: Exchange code for tokens
202
352
  const tokens = await exchangeCode({
203
353
  clientId: "od_myapp",
204
354
  clientSecret: process.env.CLIENT_SECRET,
@@ -214,7 +364,7 @@ const userGoodz = createGoodZClient({
214
364
 
215
365
  ## Z-coin Precision
216
366
 
217
- GoodZ.Core stores Z-coin amounts in **hundredths** (1/100th of a Z-coin). For example, 10.50 Z-coin is stored as `1050`. The SDK provides utility functions to convert between display values and hundredths:
367
+ GoodZ stores Z-coin amounts in **hundredths** (1/100th of a Z-coin). For example, 10.50 Z-coin is stored as `1050`.
218
368
 
219
369
  ```ts
220
370
  import { toHundredths, toDisplay, formatZcoin } from "@goodz-core/sdk/zcoin";
@@ -224,7 +374,7 @@ toDisplay(1050); // → 10.5
224
374
  formatZcoin(1050); // → "10.50"
225
375
  ```
226
376
 
227
- Always use `toHundredths()` when constructing API inputs to avoid the off-by-100x error:
377
+ Always use `toHundredths()` when constructing API inputs:
228
378
 
229
379
  ```ts
230
380
  // ✅ Correct
@@ -242,7 +392,7 @@ await goodz.zcoin.commercialTransfer({
242
392
 
243
393
  ## Error Handling
244
394
 
245
- All API errors are thrown as `GoodZApiError` instances with structured fields:
395
+ All API errors are thrown as `GoodZApiError` instances:
246
396
 
247
397
  ```ts
248
398
  import { GoodZApiError } from "@goodz-core/sdk";
@@ -251,33 +401,26 @@ try {
251
401
  await goodz.zcoin.commercialTransfer({ /* ... */ });
252
402
  } catch (err) {
253
403
  if (err instanceof GoodZApiError) {
254
- console.error(err.code); // "BAD_REQUEST", "FORBIDDEN", "CONFLICT", etc.
255
- console.error(err.httpStatus); // 400, 403, 409, etc.
404
+ console.error(err.code); // "BAD_REQUEST", "FORBIDDEN", etc.
405
+ console.error(err.httpStatus); // 400, 403, etc.
256
406
  console.error(err.path); // "zcoin.commercialTransfer"
257
- console.error(err.message); // Human-readable error message
258
-
259
- // Zod validation errors (if input was malformed)
407
+ console.error(err.message); // Human-readable message
260
408
  if (err.zodErrors) {
261
409
  for (const fieldErr of err.zodErrors) {
262
410
  console.error(`${fieldErr.path.join(".")}: ${fieldErr.message}`);
263
411
  }
264
412
  }
265
-
266
- // Full detailed string for logging
267
- console.error(err.toDetailedString());
268
413
  }
269
414
  }
270
415
  ```
271
416
 
272
- Common error codes and recommended handling:
273
-
274
- | Code | HTTP | Meaning | Recommended Action |
275
- |------|------|---------|--------------------|
276
- | `BAD_REQUEST` | 400 | Invalid input or insufficient balance | Check input values, show user-friendly message |
277
- | `UNAUTHORIZED` | 401 | Missing or invalid token | Redirect to login or refresh token |
278
- | `FORBIDDEN` | 403 | No permission (e.g., not the owner) | Show permission denied message |
279
- | `NOT_FOUND` | 404 | Resource doesn't exist | Show 404 page or fallback |
280
- | `CONFLICT` | 409 | Version conflict (optimistic locking) | Retry the operation |
417
+ | Code | HTTP | Meaning | Action |
418
+ |------|------|---------|--------|
419
+ | `BAD_REQUEST` | 400 | Invalid input or insufficient balance | Check input values |
420
+ | `UNAUTHORIZED` | 401 | Missing or invalid token | Refresh token or re-login |
421
+ | `FORBIDDEN` | 403 | No permission | Show permission denied |
422
+ | `NOT_FOUND` | 404 | Resource doesn't exist | Show 404 or fallback |
423
+ | `CONFLICT` | 409 | Version conflict | Retry the operation |
281
424
 
282
425
  ## UI Components (React)
283
426
 
@@ -285,24 +428,20 @@ The SDK includes a React component for displaying GoodZ collectibles with full m
285
428
 
286
429
  ### GoodZCardFocus
287
430
 
288
- A "tap to focus, then tilt" component that opens a full-screen modal with holographic effects, gyroscope support, and material-accurate rendering for all 10 form factors.
289
-
290
431
  ```tsx
291
432
  import { GoodZCardFocus } from "@goodz-core/sdk/ui";
292
433
 
293
434
  <GoodZCardFocus
294
435
  imageUrl="https://goodzcore.manus.space/api/shell/42.png"
295
436
  cardName="Luna"
296
- rarity="SSR" // Controls holographic intensity
297
- formFactor="trading_card" // Controls material effect
437
+ rarity="SSR"
438
+ formFactor="trading_card"
298
439
  >
299
440
  <img src={thumbnailUrl} alt="Luna" className="w-full rounded-lg" />
300
441
  </GoodZCardFocus>
301
442
  ```
302
443
 
303
- **Supported form factors:** `trading_card`, `postcard`, `postcard_portrait`, `polaroid`, `laser_ticket`, `badge_small`, `badge_medium`, `badge_large`, `acrylic_stand_tall`, `acrylic_stand_chibi`.
304
-
305
- **Material effects by form factor:**
444
+ Supports all 10 form factors with unique material effects:
306
445
 
307
446
  | Form Factor | Material Effect |
308
447
  |---|---|
@@ -313,12 +452,7 @@ import { GoodZCardFocus } from "@goodz-core/sdk/ui";
313
452
  | `badge_*` | Circular clip + metal frame + dome highlight |
314
453
  | `acrylic_stand_*` | Transparent glass + edge refraction + caustic |
315
454
 
316
- **Interaction modes:**
317
- - Desktop: mouse position controls tilt (lerp-smoothed)
318
- - Mobile: gyroscope (auto-detected) or touch drag fallback
319
- - iOS: permission request button for gyroscope access
320
-
321
- **Requirements:** React 18+ and React DOM 18+ as peer dependencies. No CSS framework required — all styles are inline.
455
+ Interaction: desktop mouse tilt, mobile gyroscope (auto-detected), touch drag fallback, iOS permission prompt. React 18+ peer dependency. No CSS framework required.
322
456
 
323
457
  ### Form Factor Utilities
324
458
 
@@ -326,10 +460,7 @@ import { GoodZCardFocus } from "@goodz-core/sdk/ui";
326
460
  import { FORM_FACTORS, getAspectRatioCSS, getFormFactorSpec } from "@goodz-core/sdk/ui";
327
461
 
328
462
  getAspectRatioCSS("trading_card"); // "5 / 7"
329
- getAspectRatioCSS("badge_small"); // "1 / 1"
330
-
331
- const spec = getFormFactorSpec("polaroid");
332
- // { key: "polaroid", label: "Polaroid", aspectRatio: [3, 4], isCircle: false }
463
+ getFormFactorSpec("polaroid"); // { key, label, aspectRatio: [3, 4], isCircle: false }
333
464
  ```
334
465
 
335
466
  ## Subpath Imports
@@ -341,6 +472,9 @@ import { createGoodZClient } from "@goodz-core/sdk/core";
341
472
  import { TokenManager } from "@goodz-core/sdk/auth";
342
473
  import { toHundredths } from "@goodz-core/sdk/zcoin";
343
474
  import { GoodZCardFocus } from "@goodz-core/sdk/ui";
475
+ import { createCommerceNamespace } from "@goodz-core/sdk/commerce";
476
+ import { createExchangeNamespace } from "@goodz-core/sdk/exchange";
477
+ import { createAliveNamespace } from "@goodz-core/sdk/alive";
344
478
  ```
345
479
 
346
480
  The root import (`@goodz-core/sdk`) re-exports everything for convenience.
@@ -1,4 +1,4 @@
1
- import { X as TransportConfig } from '../transport-BOlScYEv.js';
1
+ import { Y as TransportConfig } from '../transport-BeRIHrA1.js';
2
2
 
3
3
  /**
4
4
  * @goodz-core/sdk — Alive API Type Definitions
@@ -1,4 +1,4 @@
1
- import { createCommerceNamespace } from './chunk-MUZDYQ67.js';
1
+ import { createCommerceNamespace } from './chunk-V73MMKHI.js';
2
2
  import { createExchangeNamespace } from './chunk-OUKZ2PRD.js';
3
3
  import { createAliveNamespace } from './chunk-JAVMQXJM.js';
4
4
  import { createMcpTransportConfig, callMutation, callQuery } from './chunk-4SU7SU7K.js';
@@ -98,5 +98,5 @@ function createGoodZClient(config = {}) {
98
98
  var createUserClient = createGoodZClient;
99
99
 
100
100
  export { createGoodZClient, createUserClient };
101
- //# sourceMappingURL=chunk-7O6UN2D2.js.map
102
- //# sourceMappingURL=chunk-7O6UN2D2.js.map
101
+ //# sourceMappingURL=chunk-GRHO47XL.js.map
102
+ //# sourceMappingURL=chunk-GRHO47XL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"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","file":"chunk-GRHO47XL.js","sourcesContent":["/**\n * @goodz-core/sdk/core — Unified GoodZ API Client\n *\n * One client, all services. Stripe-style namespace architecture:\n * goodz.zcoin.* → Core settlement & Z-coin\n * goodz.inventory.* → Core instance management\n * goodz.collectible.* → Core card queries\n * goodz.user.* → Core user profiles\n * goodz.auth.* → Core auth\n * goodz.ip.* → Core IP (franchise/series/card)\n * goodz.commerce.* → Commerce/Shops (MCP)\n * goodz.exchange.* → Exchange marketplace (MCP)\n * goodz.alive.* → Alive companions (MCP)\n *\n * Core uses tRPC HTTP wire protocol; sub-sites use MCP JSON-RPC 2.0.\n * The client handles routing transparently.\n *\n * @example\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk\";\n *\n * const goodz = createGoodZClient({\n * accessToken: \"your-jwt-token\",\n * });\n *\n * // Core APIs\n * const balance = await goodz.zcoin.getMyBalance();\n * const result = await goodz.zcoin.commercialTransfer({ ... });\n *\n * // Commerce APIs\n * const shop = await goodz.commerce.createShop({ name: \"My Shop\" });\n * const order = await goodz.commerce.executePurchase({ campaignId: 1, quantity: 1 });\n *\n * // Exchange APIs\n * const listing = await goodz.exchange.createListing({ ... });\n * const data = await goodz.exchange.getMarketData({ coreGoodzId: 42 });\n *\n * // Alive APIs\n * const chat = await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hello!\" });\n * const memories = await goodz.alive.recallMemories({ instanceId: 1, userId: 1, query: \"birthday\" });\n * ```\n *\n * @module\n */\n\nimport { callQuery, callMutation, GoodZApiError } from \"../transport\";\nimport type { TransportConfig } from \"../transport\";\nimport { createMcpTransportConfig } from \"../mcp-transport\";\nimport { createCommerceNamespace } from \"../commerce/index\";\nimport type { CommerceNamespace } from \"../commerce/index\";\nimport { createExchangeNamespace } from \"../exchange/index\";\nimport type { ExchangeNamespace } from \"../exchange/index\";\nimport { createAliveNamespace } from \"../alive/index\";\nimport type { AliveNamespace } from \"../alive/index\";\nimport type {\n // zcoin\n ZcoinGetMyBalanceOutput,\n ZcoinGetMyHistoryInput,\n ZcoinCommercialTransferInput,\n ZcoinCommercialTransferOutput,\n ZcoinMintAndChargeInput,\n ZcoinMintAndChargeOutput,\n ZcoinChargeUserInput,\n ZcoinChargeUserOutput,\n ZcoinCreateDirectPurchaseOrderInput,\n ZcoinCreateDirectPurchaseOrderOutput,\n ZcoinGetDepositPackagesInput,\n ZcoinDepositPackage,\n ZcoinCreateDepositOrderInput,\n ZcoinCreateDepositOrderOutput,\n ZcoinGetDepositStatusInput,\n ZcoinGetDepositStatusOutput,\n // inventory\n InventoryGetUserInventoryInput,\n InventoryItem,\n InventoryConfirmOwnershipInput,\n InventoryConfirmOwnershipOutput,\n InventoryMintInput,\n InventoryMintOutput,\n InventoryTransferInput,\n InventoryTransferOutput,\n InventoryTransferByCardInput,\n InventoryTransferByCardOutput,\n InventoryGrantMintAuthInput,\n InventoryTransferHistoryInput,\n // collectible\n CollectibleGetInstanceByIdInput,\n CollectibleGetPublicInstanceInput,\n CollectibleGetPublicInstancesBatchInput,\n CollectibleGetCardProfileInput,\n CollectibleGetShellImageUrlInput,\n // user\n UserGetPublicProfileInput,\n UserPublicProfile,\n UserGetPublicProfileByIdInput,\n // auth\n AuthGetOAuthAppInfoInput,\n AuthOAuthAppInfo,\n AuthUser,\n // ip\n FranchiseGetInput,\n SeriesGetInput,\n SeriesListByFranchiseInput,\n CardGetInput,\n CardListBySeriesInput,\n} from \"../types\";\n\n// ─── Re-export types and error class ─────────────────────────\n\nexport { GoodZApiError } from \"../transport\";\nexport type * from \"../types\";\nexport type * from \"../types-commerce\";\nexport type * from \"../types-exchange\";\nexport type * from \"../types-alive\";\nexport type { CommerceNamespace } from \"../commerce/index\";\nexport type { ExchangeNamespace } from \"../exchange/index\";\nexport type { AliveNamespace } from \"../alive/index\";\n\n// ─── Default sub-site URLs ──────────────────────────────────\n\nconst DEFAULT_CORE_URL = \"https://goodzcore.manus.space\";\nconst DEFAULT_COMMERCE_URL = \"https://goodzcommerce.manus.space\";\nconst DEFAULT_EXCHANGE_URL = \"https://goodzexchange.manus.space\";\nconst DEFAULT_ALIVE_URL = \"https://goodzalive.manus.space\";\n\n// ─── Client config ───────────────────────────────────────────\n\nexport interface GoodZClientConfig {\n /**\n * GoodZ.Core base URL.\n * @default \"https://goodzcore.manus.space\"\n */\n coreUrl?: string;\n\n /**\n * GoodZ.Commerce (Shops) base URL.\n * @default \"https://goodzcommerce.manus.space\"\n */\n commerceUrl?: string;\n\n /**\n * GoodZ.Exchange base URL.\n * @default \"https://goodzexchange.manus.space\"\n */\n exchangeUrl?: string;\n\n /**\n * GoodZ.Alive base URL.\n * @default \"https://goodzalive.manus.space\"\n */\n aliveUrl?: string;\n\n /**\n * Static access token (JWT) for authentication.\n * For server-to-server calls, obtain this via OAuth client_credentials flow.\n * For user-context calls, pass the user's access token.\n */\n accessToken?: string;\n\n /**\n * Dynamic token provider — called before every request.\n * Use this when tokens may rotate (e.g., auto-refresh).\n * Takes precedence over `accessToken` if both are set.\n */\n getAccessToken?: () => string | Promise<string>;\n\n /**\n * Custom headers to include in every request.\n * Useful for passing app identifiers or tracing headers.\n */\n headers?: Record<string, string>;\n}\n\n// ─── Core namespace interfaces (tRPC) ───────────────────────\n\nexport interface ZcoinNamespace {\n /** Get the authenticated user's Z-coin balance. */\n getMyBalance(): Promise<ZcoinGetMyBalanceOutput>;\n\n /** Get the authenticated user's Z-coin transaction history. */\n getMyHistory(input?: ZcoinGetMyHistoryInput): Promise<any[]>;\n\n /** Get available Z-coin deposit packages with pricing. */\n getDepositPackages(input?: ZcoinGetDepositPackagesInput): Promise<ZcoinDepositPackage[]>;\n\n /** Create a Stripe checkout session for Z-coin deposit. */\n createDepositOrder(input: ZcoinCreateDepositOrderInput): Promise<ZcoinCreateDepositOrderOutput>;\n\n /** Check the status of a deposit checkout session. */\n getDepositStatus(input: ZcoinGetDepositStatusInput): Promise<ZcoinGetDepositStatusOutput>;\n\n /**\n * Atomic commercial transfer: Z-coin payment + ownership transfer in one transaction.\n * This is the primary API for Commerce and Exchange purchase flows.\n *\n * Idempotent via referenceId — duplicate calls return the same result.\n *\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n * @throws {GoodZApiError} CONFLICT — version conflict (retry)\n * @throws {GoodZApiError} FORBIDDEN — seller doesn't own instance\n */\n commercialTransfer(input: ZcoinCommercialTransferInput): Promise<ZcoinCommercialTransferOutput>;\n\n /**\n * Mint a new card instance and charge the buyer in one atomic transaction.\n * Used by Commerce for gacha and direct-from-creator purchases.\n *\n * Requires mint authorization (granted via inventory.grantMintAuth).\n * Idempotent via referenceId.\n *\n * @throws {GoodZApiError} FORBIDDEN — no mint authorization\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n */\n mintAndCharge(input: ZcoinMintAndChargeInput): Promise<ZcoinMintAndChargeOutput>;\n\n /**\n * Charge a user's Z-coin balance for an in-app purchase.\n * Used by apps that sell non-GoodZ digital goods/services.\n *\n * Idempotent via appOrderId.\n *\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n * @throws {GoodZApiError} CONFLICT — version conflict\n */\n chargeUser(input: ZcoinChargeUserInput): Promise<ZcoinChargeUserOutput>;\n\n /**\n * Create a direct purchase checkout session (fiat → Z-coin → transfer).\n * Transparent intermediation: user sees fiat price, Core handles conversion.\n */\n createDirectPurchaseOrder(input: ZcoinCreateDirectPurchaseOrderInput): Promise<ZcoinCreateDirectPurchaseOrderOutput>;\n}\n\nexport interface InventoryNamespace {\n /** Get a user's inventory (owned card instances). */\n getUserInventory(input: InventoryGetUserInventoryInput): Promise<InventoryItem[]>;\n\n /** Check if a user owns at least one instance of a specific card. */\n confirmOwnership(input: InventoryConfirmOwnershipInput): Promise<InventoryConfirmOwnershipOutput>;\n\n /**\n * Mint new card instances. Requires franchise ownership or admin role.\n * For Commerce/Exchange, use zcoin.mintAndCharge instead (includes payment).\n */\n mint(input: InventoryMintInput): Promise<InventoryMintOutput>;\n\n /**\n * Transfer a specific card instance to another user.\n * For commercial transfers, use zcoin.commercialTransfer instead.\n *\n * @deprecated for reason=\"purchase\"|\"trade\" — use commercialTransfer\n */\n transfer(input: InventoryTransferInput): Promise<InventoryTransferOutput>;\n\n /**\n * Transfer card instances by cardId (transfers oldest instances).\n * For commercial transfers, use zcoin.commercialTransfer instead.\n *\n * @deprecated for reason=\"purchase\"|\"trade\" — use commercialTransfer\n */\n transferByCard(input: InventoryTransferByCardInput): Promise<InventoryTransferByCardOutput>;\n\n /**\n * Grant mint authorization to another user/app for a specific card.\n * Required before Commerce can call zcoin.mintAndCharge for that card.\n */\n grantMintAuth(input: InventoryGrantMintAuthInput): Promise<any>;\n\n /** Get transfer/ownership history for an instance, card, or user. */\n transferHistory(input: InventoryTransferHistoryInput): Promise<any[]>;\n}\n\nexport interface CollectibleNamespace {\n /** Get a card instance by its numeric ID. Returns full instance data with card chain. */\n getInstanceById(input: CollectibleGetInstanceByIdInput): Promise<any>;\n\n /** Get a card instance by its instance code (public-facing identifier). */\n getPublicInstance(input: CollectibleGetPublicInstanceInput): Promise<any>;\n\n /** Batch-fetch multiple card instances by their IDs (max 100). */\n getPublicInstancesBatch(input: CollectibleGetPublicInstancesBatchInput): Promise<any[]>;\n\n /** Get the card profile (metadata, rarity, series info). */\n getCardProfile(input: CollectibleGetCardProfileInput): Promise<any>;\n\n /** Get the shell (packaging) image URL for a card. */\n getShellImageUrl(input: CollectibleGetShellImageUrlInput): Promise<any>;\n}\n\nexport interface UserNamespace {\n /** Get a user's public profile by openId. */\n getPublicProfile(input: UserGetPublicProfileInput): Promise<UserPublicProfile>;\n\n /** Get a user's public profile by internal userId. */\n getPublicProfileById(input: UserGetPublicProfileByIdInput): Promise<UserPublicProfile>;\n}\n\nexport interface AuthNamespace {\n /** Get the authenticated user's profile. Returns null if not authenticated. */\n me(): Promise<AuthUser | null>;\n\n /** Get public info about an OAuth app by its client ID. */\n getOAuthAppInfo(input: AuthGetOAuthAppInfoInput): Promise<AuthOAuthAppInfo | null>;\n}\n\nexport interface IpNamespace {\n /** Get a franchise by ID or slug. */\n getFranchise(input: FranchiseGetInput): Promise<any>;\n\n /** Get a series by ID or slug. */\n getSeries(input: SeriesGetInput): Promise<any>;\n\n /** List all series in a franchise. */\n listSeriesByFranchise(input: SeriesListByFranchiseInput): Promise<any[]>;\n\n /** Get a card by ID. */\n getCard(input: CardGetInput): Promise<any>;\n\n /** List all cards in a series. */\n listCardsBySeries(input: CardListBySeriesInput): Promise<any[]>;\n}\n\n// ─── GoodZClient type ────────────────────────────────────────\n\nexport interface GoodZClient {\n // ── Core namespaces (tRPC) ──\n readonly zcoin: ZcoinNamespace;\n readonly inventory: InventoryNamespace;\n readonly collectible: CollectibleNamespace;\n readonly user: UserNamespace;\n readonly auth: AuthNamespace;\n readonly ip: IpNamespace;\n\n // ── Sub-site namespaces (MCP) ──\n readonly commerce: CommerceNamespace;\n readonly exchange: ExchangeNamespace;\n readonly alive: AliveNamespace;\n\n /**\n * Make a raw tRPC query call to Core. Use this for routes not yet covered\n * by the typed namespaces.\n */\n rawQuery<T = any>(path: string, input?: any): Promise<T>;\n\n /**\n * Make a raw tRPC mutation call to Core. Use this for routes not yet covered\n * by the typed namespaces.\n */\n rawMutation<T = any>(path: string, input?: any): Promise<T>;\n}\n\n// ─── Client factory ──────────────────────────────────────────\n\n/**\n * Create a unified GoodZ API client — one client for all services.\n *\n * @example Server-to-server with static token\n * ```ts\n * const goodz = createGoodZClient({\n * accessToken: process.env.CORE_ACCESS_TOKEN,\n * });\n *\n * // Core\n * const balance = await goodz.zcoin.getMyBalance();\n *\n * // Commerce\n * const shop = await goodz.commerce.createShop({ name: \"My Shop\" });\n *\n * // Exchange\n * const listings = await goodz.exchange.browseMarketplace();\n *\n * // Alive\n * const chat = await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hi!\" });\n * ```\n *\n * @example With dynamic token provider (auto-refresh)\n * ```ts\n * const goodz = createGoodZClient({\n * getAccessToken: async () => {\n * const token = await refreshTokenIfNeeded();\n * return token;\n * },\n * });\n * ```\n *\n * @example Custom sub-site URLs (e.g., staging environment)\n * ```ts\n * const goodz = createGoodZClient({\n * accessToken: \"...\",\n * coreUrl: \"https://staging-core.goodz.dev\",\n * commerceUrl: \"https://staging-commerce.goodz.dev\",\n * exchangeUrl: \"https://staging-exchange.goodz.dev\",\n * aliveUrl: \"https://staging-alive.goodz.dev\",\n * });\n * ```\n */\nexport function createGoodZClient(config: GoodZClientConfig = {}): GoodZClient {\n const {\n coreUrl = DEFAULT_CORE_URL,\n commerceUrl = DEFAULT_COMMERCE_URL,\n exchangeUrl = DEFAULT_EXCHANGE_URL,\n aliveUrl = DEFAULT_ALIVE_URL,\n accessToken,\n getAccessToken,\n headers: customHeaders,\n } = config;\n\n // Shared header builder — used by both tRPC and MCP transports\n const buildHeaders = async (): Promise<Record<string, string>> => {\n const h: Record<string, string> = { ...customHeaders };\n const token = getAccessToken ? await getAccessToken() : accessToken;\n if (token) {\n h[\"Authorization\"] = `Bearer ${token}`;\n }\n return h;\n };\n\n // ── Core transport (tRPC) ──\n const coreTransport: TransportConfig = {\n baseUrl: coreUrl.replace(/\\/$/, \"\"),\n getHeaders: buildHeaders,\n };\n\n // ── Sub-site transports (MCP) ──\n const commerceTransport = createMcpTransportConfig(commerceUrl, buildHeaders);\n const exchangeTransport = createMcpTransportConfig(exchangeUrl, buildHeaders);\n const aliveTransport = createMcpTransportConfig(aliveUrl, buildHeaders);\n\n // Helper shortcuts for Core tRPC\n const q = <I, O>(path: string) => (input?: I) => callQuery<I, O>(coreTransport, path, input);\n const m = <I, O>(path: string) => (input?: I) => callMutation<I, O>(coreTransport, path, input);\n\n return {\n // ── zcoin ──────────────────────────────────────────────\n zcoin: {\n getMyBalance: q<void, ZcoinGetMyBalanceOutput>(\"zcoin.getMyBalance\"),\n getMyHistory: q<ZcoinGetMyHistoryInput, any[]>(\"zcoin.getMyHistory\"),\n getDepositPackages: q<ZcoinGetDepositPackagesInput, ZcoinDepositPackage[]>(\"zcoin.getDepositPackages\"),\n createDepositOrder: m<ZcoinCreateDepositOrderInput, ZcoinCreateDepositOrderOutput>(\"zcoin.createDepositOrder\"),\n getDepositStatus: q<ZcoinGetDepositStatusInput, ZcoinGetDepositStatusOutput>(\"zcoin.getDepositStatus\"),\n commercialTransfer: m<ZcoinCommercialTransferInput, ZcoinCommercialTransferOutput>(\"zcoin.commercialTransfer\"),\n mintAndCharge: m<ZcoinMintAndChargeInput, ZcoinMintAndChargeOutput>(\"zcoin.mintAndCharge\"),\n chargeUser: m<ZcoinChargeUserInput, ZcoinChargeUserOutput>(\"zcoin.chargeUser\"),\n createDirectPurchaseOrder: m<ZcoinCreateDirectPurchaseOrderInput, ZcoinCreateDirectPurchaseOrderOutput>(\"zcoin.createDirectPurchaseOrder\"),\n },\n\n // ── inventory ──────────────────────────────────────────\n inventory: {\n getUserInventory: q<InventoryGetUserInventoryInput, InventoryItem[]>(\"inventory.getUserInventory\"),\n confirmOwnership: q<InventoryConfirmOwnershipInput, InventoryConfirmOwnershipOutput>(\"inventory.confirmOwnership\"),\n mint: m<InventoryMintInput, InventoryMintOutput>(\"inventory.mint\"),\n transfer: m<InventoryTransferInput, InventoryTransferOutput>(\"inventory.transfer\"),\n transferByCard: m<InventoryTransferByCardInput, InventoryTransferByCardOutput>(\"inventory.transferByCard\"),\n grantMintAuth: m<InventoryGrantMintAuthInput, any>(\"inventory.grantMintAuth\"),\n transferHistory: q<InventoryTransferHistoryInput, any[]>(\"inventory.transferHistory\"),\n },\n\n // ── collectible ────────────────────────────────────────\n collectible: {\n getInstanceById: q<CollectibleGetInstanceByIdInput, any>(\"collectible.getInstanceById\"),\n getPublicInstance: q<CollectibleGetPublicInstanceInput, any>(\"collectible.getPublicInstance\"),\n getPublicInstancesBatch: q<CollectibleGetPublicInstancesBatchInput, any[]>(\"collectible.getPublicInstancesBatch\"),\n getCardProfile: q<CollectibleGetCardProfileInput, any>(\"collectible.getCardProfile\"),\n getShellImageUrl: q<CollectibleGetShellImageUrlInput, any>(\"collectible.getShellImageUrl\"),\n },\n\n // ── user ───────────────────────────────────────────────\n user: {\n getPublicProfile: q<UserGetPublicProfileInput, UserPublicProfile>(\"user.getPublicProfile\"),\n getPublicProfileById: q<UserGetPublicProfileByIdInput, UserPublicProfile>(\"user.getPublicProfileById\"),\n },\n\n // ── auth ───────────────────────────────────────────────\n auth: {\n me: q<void, AuthUser | null>(\"auth.me\"),\n getOAuthAppInfo: q<AuthGetOAuthAppInfoInput, AuthOAuthAppInfo | null>(\"auth.getOAuthAppInfo\"),\n },\n\n // ── ip (franchise/series/card) ─────────────────────────\n ip: {\n getFranchise: q<FranchiseGetInput, any>(\"franchise.get\"),\n getSeries: q<SeriesGetInput, any>(\"series.get\"),\n listSeriesByFranchise: q<SeriesListByFranchiseInput, any[]>(\"series.listByFranchise\"),\n getCard: q<CardGetInput, any>(\"card.get\"),\n listCardsBySeries: q<CardListBySeriesInput, any[]>(\"card.listBySeries\"),\n },\n\n // ── commerce (MCP) ─────────────────────────────────────\n commerce: createCommerceNamespace(commerceTransport),\n\n // ── exchange (MCP) ─────────────────────────────────────\n exchange: createExchangeNamespace(exchangeTransport),\n\n // ── alive (MCP) ────────────────────────────────────────\n alive: createAliveNamespace(aliveTransport),\n\n // ── raw escape hatches (Core tRPC only) ────────────────\n rawQuery: <T = any>(path: string, input?: any) => callQuery<any, T>(coreTransport, path, input),\n rawMutation: <T = any>(path: string, input?: any) => callMutation<any, T>(coreTransport, path, input),\n };\n}\n\n/**\n * Alias for createGoodZClient — creates a client acting on behalf of a user.\n * Semantically identical, but makes the intent clearer in server-to-server code.\n */\nexport const createUserClient = createGoodZClient;\n"]}
@@ -8,7 +8,7 @@ function createCommerceNamespace(transport) {
8
8
  createShop: tool("create_shop"),
9
9
  getShopDashboard: tool("get_shop_dashboard"),
10
10
  // Product Assembly
11
- createBatch: tool("create_batch"),
11
+ createBatch: tool("assemble_batch"),
12
12
  createGachaPool: tool("create_gacha_pool"),
13
13
  // Campaign Lifecycle
14
14
  launchCampaign: tool("launch_sales_campaign"),
@@ -23,7 +23,7 @@ function createCommerceNamespace(transport) {
23
23
  getMyOrders: tool("get_my_orders"),
24
24
  // Wholesale
25
25
  publishToWholesale: tool("publish_to_wholesale"),
26
- browseWholesale: tool("browse_wholesale"),
26
+ browseWholesale: tool("browse_wholesale_market"),
27
27
  procureBatch: tool("procure_batch"),
28
28
  // Inventory
29
29
  manageInventory: tool("manage_inventory"),
@@ -52,5 +52,5 @@ function createCommerceNamespace(transport) {
52
52
  }
53
53
 
54
54
  export { createCommerceNamespace };
55
- //# sourceMappingURL=chunk-MUZDYQ67.js.map
56
- //# sourceMappingURL=chunk-MUZDYQ67.js.map
55
+ //# sourceMappingURL=chunk-V73MMKHI.js.map
56
+ //# sourceMappingURL=chunk-V73MMKHI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commerce/index.ts"],"names":[],"mappings":";;;AAuJO,SAAS,wBAAwB,SAAA,EAA+C;AACrF,EAAA,MAAM,IAAA,GAAO,CAAmC,IAAA,KAC9C,CAAC,UAAc,WAAA,CAAkB,SAAA,EAAW,MAAM,KAAU,CAAA;AAE9D,EAAA,OAAO;AAAA;AAAA,IAEL,UAAA,EAAY,KAA4C,aAAa,CAAA;AAAA,IACrE,gBAAA,EAAkB,KAA2D,oBAAoB,CAAA;AAAA;AAAA,IAGjG,WAAA,EAAa,KAA8C,gBAAgB,CAAA;AAAA,IAC3E,eAAA,EAAiB,KAAsD,mBAAmB,CAAA;AAAA;AAAA,IAG1F,cAAA,EAAgB,KAAoD,uBAAuB,CAAA;AAAA,IAC3F,gBAAA,EAAkB,KAAsD,mBAAmB,CAAA;AAAA,IAC3F,aAAA,EAAe,KAAmD,gBAAgB,CAAA;AAAA,IAClF,WAAA,EAAa,KAAiD,cAAc,CAAA;AAAA,IAC5E,cAAA,EAAgB,KAAoD,iBAAiB,CAAA;AAAA,IACrF,eAAA,EAAiB,KAAwC,mBAAmB,CAAA;AAAA,IAC5E,gBAAA,EAAkB,KAA4D,oBAAoB,CAAA;AAAA;AAAA,IAGlG,eAAA,EAAiB,KAAuD,kBAAkB,CAAA;AAAA,IAC1F,WAAA,EAAa,KAAgD,eAAe,CAAA;AAAA;AAAA,IAG5E,kBAAA,EAAoB,KAA2C,sBAAsB,CAAA;AAAA,IACrF,eAAA,EAAiB,KAA+D,yBAAyB,CAAA;AAAA,IACzG,YAAA,EAAc,KAAqC,eAAe,CAAA;AAAA;AAAA,IAGlE,eAAA,EAAiB,KAAwC,kBAAkB,CAAA;AAAA,IAC3E,iBAAA,EAAmB,KAA0C,oBAAoB,CAAA;AAAA,IACjF,eAAA,EAAiB,KAAwC,mBAAmB,CAAA;AAAA;AAAA,IAG5E,mBAAA,EAAqB,KAA4C,uBAAuB,CAAA;AAAA;AAAA,IAGxF,iBAAA,EAAmB,KAA4C,oBAAoB,CAAA;AAAA,IACnF,mBAAA,EAAqB,KAA8C,wBAAwB,CAAA;AAAA;AAAA,IAG3F,cAAA,EAAgB,KAAuC,uBAAuB,CAAA;AAAA;AAAA,IAG9E,eAAA,EAAiB,KAAoD,kBAAkB,CAAA;AAAA,IACvF,YAAA,EAAc,KAA+C,eAAe,CAAA;AAAA,IAC5E,WAAA,EAAa,KAAoC,cAAc,CAAA;AAAA,IAC/D,aAAA,EAAe,KAAsC,gBAAgB,CAAA;AAAA;AAAA,IAGrE,WAAA,EAAa,KAAoC,cAAc,CAAA;AAAA,IAC/D,SAAA,EAAW,KAAkC,YAAY,CAAA;AAAA,IACzD,UAAA,EAAY,KAAqC,cAAc,CAAA;AAAA,IAC/D,UAAA,EAAY,KAA+C,cAAc,CAAA;AAAA;AAAA,IAGzE,SAAS,CAAU,QAAA,EAAkB,SACnC,WAAA,CAAoC,SAAA,EAAW,UAAU,IAAI;AAAA,GACjE;AACF","file":"chunk-V73MMKHI.js","sourcesContent":["/**\n * @goodz-core/sdk — Commerce / Shops Namespace\n *\n * Provides typed access to GoodZ.Commerce MCP tools:\n * shop management, batches, gacha pools, campaigns,\n * wholesale, purchases, settlement, and webhooks.\n *\n * @module\n */\n\nimport { callMcpTool } from \"../mcp-transport\";\nimport type { TransportConfig } from \"../mcp-transport\";\nimport type {\n CommerceCreateShopInput,\n CommerceShop,\n CommerceGetShopDashboardInput,\n CommerceShopDashboard,\n CommerceCreateBatchInput,\n CommerceBatch,\n CommerceCreateGachaPoolInput,\n CommerceGachaPool,\n CommerceLaunchCampaignInput,\n CommerceCampaign,\n CommerceActivateCampaignInput,\n CommercePauseCampaignInput,\n CommerceEndCampaignInput,\n CommerceUpdateCampaignInput,\n CommerceGetCampaignInfoInput,\n CommerceGetCampaignItemsInput,\n CommerceCampaignItem,\n CommerceExecutePurchaseInput,\n CommerceDrawResult,\n CommerceGetMyOrdersInput,\n CommerceOrder,\n CommercePublishToWholesaleInput,\n CommerceBrowseWholesaleInput,\n CommerceWholesaleListing,\n CommerceProcureBatchInput,\n CommerceManageInventoryInput,\n CommerceRegisterInstancesInput,\n CommerceMintToInventoryInput,\n CommerceGetSettlementReportInput,\n CommerceSearchMarketplaceInput,\n CommerceGetShopsByBlueprintInput,\n CommerceRedeemPhysicalInput,\n CommerceRegisterWebhookInput,\n CommerceWebhook,\n CommerceTestWebhookInput,\n CommerceDeleteWebhookInput,\n CommerceRegisterAppInput,\n CommerceUpdateAppInput,\n CommerceListMyAppsInput,\n CommerceGetAuthUrlInput,\n} from \"../types-commerce\";\n\n// Re-export all Commerce types\nexport type * from \"../types-commerce\";\n\n// ─── Namespace interface ────────────────────────────────────\n\nexport interface CommerceNamespace {\n // Shop Management\n /** Create a new shop. */\n createShop(input: CommerceCreateShopInput): Promise<CommerceShop>;\n /** Get shop dashboard with stats, revenue, and recent orders. */\n getShopDashboard(input?: CommerceGetShopDashboardInput): Promise<CommerceShopDashboard>;\n\n // Product Assembly\n /** Create a batch (product assembly with tiers). Supports blind_box, ichiban_kuji, direct_sale. */\n createBatch(input: CommerceCreateBatchInput): Promise<CommerceBatch>;\n /** Create a gacha pool with weighted probabilities and optional pity mechanics. */\n createGachaPool(input: CommerceCreateGachaPoolInput): Promise<CommerceGachaPool>;\n\n // Campaign Lifecycle\n /** Launch a sales campaign in draft status. Connect a Batch or Gacha pool to the storefront. */\n launchCampaign(input: CommerceLaunchCampaignInput): Promise<CommerceCampaign>;\n /** Activate a draft/paused campaign — makes it live and purchasable. */\n activateCampaign(input: CommerceActivateCampaignInput): Promise<CommerceCampaign>;\n /** Pause an active campaign. Existing orders unaffected. */\n pauseCampaign(input: CommercePauseCampaignInput): Promise<CommerceCampaign>;\n /** Permanently end a campaign (terminal state). */\n endCampaign(input: CommerceEndCampaignInput): Promise<CommerceCampaign>;\n /** Update campaign configuration (editable fields depend on status). */\n updateCampaign(input: CommerceUpdateCampaignInput): Promise<CommerceCampaign>;\n /** Get detailed campaign info including batch/gacha config and tiers. */\n getCampaignInfo(input: CommerceGetCampaignInfoInput): Promise<any>;\n /** Get unified campaign items list (works for both batch and gacha campaigns). */\n getCampaignItems(input: CommerceGetCampaignItemsInput): Promise<CommerceCampaignItem[]>;\n\n // Purchase / Draw\n /** Execute a purchase or draw. Handles payment, draw mechanics, settlement, and ownership transfer. */\n executePurchase(input: CommerceExecutePurchaseInput): Promise<CommerceDrawResult>;\n /** Get the authenticated user's order history. */\n getMyOrders(input?: CommerceGetMyOrdersInput): Promise<CommerceOrder[]>;\n\n // Wholesale\n /** Publish a batch to the wholesale market for other shopkeepers to procure. */\n publishToWholesale(input: CommercePublishToWholesaleInput): Promise<any>;\n /** Browse available wholesale listings. */\n browseWholesale(input?: CommerceBrowseWholesaleInput): Promise<CommerceWholesaleListing[]>;\n /** Procure goods from the wholesale market. */\n procureBatch(input: CommerceProcureBatchInput): Promise<any>;\n\n // Inventory\n /** View and manage shop inventory (list or sync from Core). */\n manageInventory(input?: CommerceManageInventoryInput): Promise<any>;\n /** Register existing Core instances into shop inventory. */\n registerInstances(input: CommerceRegisterInstancesInput): Promise<any>;\n /** Mint new instances directly into shop inventory. */\n mintToInventory(input: CommerceMintToInventoryInput): Promise<any>;\n\n // Settlement\n /** Get settlement report with revenue breakdown. */\n getSettlementReport(input?: CommerceGetSettlementReportInput): Promise<any>;\n\n // Discovery\n /** Search the marketplace for campaigns. */\n searchMarketplace(input?: CommerceSearchMarketplaceInput): Promise<any[]>;\n /** Find shops selling a specific GoodZ card. */\n getShopsByBlueprint(input: CommerceGetShopsByBlueprintInput): Promise<any[]>;\n\n // Physical Redemption\n /** Request physical redemption for a purchased item. */\n redeemPhysical(input: CommerceRedeemPhysicalInput): Promise<any>;\n\n // Webhooks\n /** Register a webhook URL to receive shop event notifications. */\n registerWebhook(input: CommerceRegisterWebhookInput): Promise<CommerceWebhook>;\n /** List all registered webhook endpoints. */\n listWebhooks(): Promise<CommerceWebhook[]>;\n /** Send a test ping to a webhook endpoint. */\n testWebhook(input: CommerceTestWebhookInput): Promise<any>;\n /** Delete a webhook endpoint. */\n deleteWebhook(input: CommerceDeleteWebhookInput): Promise<any>;\n\n // OAuth App Management\n /** Register a new OAuth application with Commerce scopes. */\n registerApp(input: CommerceRegisterAppInput): Promise<any>;\n /** Update an existing OAuth application. */\n updateApp(input: CommerceUpdateAppInput): Promise<any>;\n /** List all OAuth applications owned by the user. */\n listMyApps(input?: CommerceListMyAppsInput): Promise<any[]>;\n /** Generate an OAuth authorization URL. */\n getAuthUrl(input?: CommerceGetAuthUrlInput): Promise<{ url: string }>;\n\n /** Call a raw MCP tool by name. Escape hatch for tools not yet in the typed API. */\n rawTool<T = any>(toolName: string, args?: Record<string, any>): Promise<T>;\n}\n\n// ─── Factory ────────────────────────────────────────────────\n\nexport function createCommerceNamespace(transport: TransportConfig): CommerceNamespace {\n const tool = <I extends Record<string, any>, O>(name: string) =>\n (input?: I) => callMcpTool<I, O>(transport, name, input as I);\n\n return {\n // Shop\n createShop: tool<CommerceCreateShopInput, CommerceShop>(\"create_shop\"),\n getShopDashboard: tool<CommerceGetShopDashboardInput, CommerceShopDashboard>(\"get_shop_dashboard\"),\n\n // Product Assembly\n createBatch: tool<CommerceCreateBatchInput, CommerceBatch>(\"assemble_batch\"),\n createGachaPool: tool<CommerceCreateGachaPoolInput, CommerceGachaPool>(\"create_gacha_pool\"),\n\n // Campaign Lifecycle\n launchCampaign: tool<CommerceLaunchCampaignInput, CommerceCampaign>(\"launch_sales_campaign\"),\n activateCampaign: tool<CommerceActivateCampaignInput, CommerceCampaign>(\"activate_campaign\"),\n pauseCampaign: tool<CommercePauseCampaignInput, CommerceCampaign>(\"pause_campaign\"),\n endCampaign: tool<CommerceEndCampaignInput, CommerceCampaign>(\"end_campaign\"),\n updateCampaign: tool<CommerceUpdateCampaignInput, CommerceCampaign>(\"update_campaign\"),\n getCampaignInfo: tool<CommerceGetCampaignInfoInput, any>(\"get_campaign_info\"),\n getCampaignItems: tool<CommerceGetCampaignItemsInput, CommerceCampaignItem[]>(\"get_campaign_items\"),\n\n // Purchase\n executePurchase: tool<CommerceExecutePurchaseInput, CommerceDrawResult>(\"execute_purchase\"),\n getMyOrders: tool<CommerceGetMyOrdersInput, CommerceOrder[]>(\"get_my_orders\"),\n\n // Wholesale\n publishToWholesale: tool<CommercePublishToWholesaleInput, any>(\"publish_to_wholesale\"),\n browseWholesale: tool<CommerceBrowseWholesaleInput, CommerceWholesaleListing[]>(\"browse_wholesale_market\"),\n procureBatch: tool<CommerceProcureBatchInput, any>(\"procure_batch\"),\n\n // Inventory\n manageInventory: tool<CommerceManageInventoryInput, any>(\"manage_inventory\"),\n registerInstances: tool<CommerceRegisterInstancesInput, any>(\"register_instances\"),\n mintToInventory: tool<CommerceMintToInventoryInput, any>(\"mint_to_inventory\"),\n\n // Settlement\n getSettlementReport: tool<CommerceGetSettlementReportInput, any>(\"get_settlement_report\"),\n\n // Discovery\n searchMarketplace: tool<CommerceSearchMarketplaceInput, any[]>(\"search_marketplace\"),\n getShopsByBlueprint: tool<CommerceGetShopsByBlueprintInput, any[]>(\"get_shops_by_blueprint\"),\n\n // Physical Redemption\n redeemPhysical: tool<CommerceRedeemPhysicalInput, any>(\"redeem_physical_goodz\"),\n\n // Webhooks\n registerWebhook: tool<CommerceRegisterWebhookInput, CommerceWebhook>(\"register_webhook\"),\n listWebhooks: tool<Record<string, never>, CommerceWebhook[]>(\"list_webhooks\"),\n testWebhook: tool<CommerceTestWebhookInput, any>(\"test_webhook\"),\n deleteWebhook: tool<CommerceDeleteWebhookInput, any>(\"delete_webhook\"),\n\n // OAuth App\n registerApp: tool<CommerceRegisterAppInput, any>(\"register_app\"),\n updateApp: tool<CommerceUpdateAppInput, any>(\"update_app\"),\n listMyApps: tool<CommerceListMyAppsInput, any[]>(\"list_my_apps\"),\n getAuthUrl: tool<CommerceGetAuthUrlInput, { url: string }>(\"get_auth_url\"),\n\n // Raw escape hatch\n rawTool: <T = any>(toolName: string, args?: Record<string, any>) =>\n callMcpTool<Record<string, any>, T>(transport, toolName, args),\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { X as TransportConfig } from '../transport-BOlScYEv.js';
1
+ import { Y as TransportConfig } from '../transport-BeRIHrA1.js';
2
2
 
3
3
  /**
4
4
  * @goodz-core/sdk — Commerce / Shops API Type Definitions
@@ -7,6 +7,8 @@ import { X as TransportConfig } from '../transport-BOlScYEv.js';
7
7
  * These cover shop management, batches, gacha pools, campaigns,
8
8
  * wholesale, purchases, and settlement.
9
9
  *
10
+ * Aligned with Commerce MCP as of 2026-03-20.
11
+ *
10
12
  * @module
11
13
  */
12
14
  type CampaignStatus = "draft" | "active" | "paused" | "ended" | "sold_out";
@@ -16,14 +18,16 @@ type IntegrationMode = "hosted" | "custom";
16
18
  interface CommerceCreateShopInput {
17
19
  name: string;
18
20
  description?: string;
19
- imageUrl?: string;
21
+ logoUrl?: string;
22
+ slug?: string;
20
23
  userId?: number;
21
24
  }
22
25
  interface CommerceShop {
23
26
  id: number;
24
27
  name: string;
25
28
  description: string | null;
26
- imageUrl: string | null;
29
+ logoUrl: string | null;
30
+ slug: string | null;
27
31
  ownerId: number;
28
32
  createdAt: string;
29
33
  }
@@ -57,6 +61,18 @@ interface CommerceCreateBatchInput {
57
61
  imageUrl?: string;
58
62
  saleMode: SaleMode;
59
63
  tiers: CommerceBatchTier[];
64
+ /** Core goods ID to link the batch to a specific IP/card blueprint */
65
+ coreGoodsId?: number;
66
+ /** Whether this batch has limited supply */
67
+ isLimited?: boolean;
68
+ /** Total supply across all tiers */
69
+ totalSupply?: number;
70
+ /** Retail price in cents (for the entire batch or per unit) */
71
+ retailPriceCents?: number;
72
+ /** Number of units per box (for blind-box sale mode) */
73
+ unitsPerBox?: number;
74
+ /** Number of boxes per batch */
75
+ boxesPerBatch?: number;
60
76
  userId?: number;
61
77
  }
62
78
  interface CommerceBatch {
@@ -148,6 +164,10 @@ interface CommerceUpdateCampaignInput {
148
164
  name?: string;
149
165
  description?: string;
150
166
  imageUrl?: string;
167
+ /** Link or update the batch for this campaign */
168
+ batchId?: number;
169
+ /** Link or update the gacha pool for this campaign */
170
+ gachaPoolId?: number;
151
171
  startsAt?: string;
152
172
  endsAt?: string;
153
173
  userId?: number;
@@ -245,31 +265,58 @@ interface CommerceManageInventoryInput {
245
265
  }
246
266
  interface CommerceRegisterInstancesInput {
247
267
  shopId?: number;
248
- instanceIds: number[];
268
+ /** Array of instance objects or IDs to register */
269
+ instances: Array<{
270
+ instanceId: number;
271
+ [key: string]: any;
272
+ }> | number[];
273
+ /** Source of the instances (e.g. "core_mint", "transfer", "import") */
274
+ source?: string;
249
275
  userId?: number;
250
276
  }
251
277
  interface CommerceMintToInventoryInput {
252
278
  shopId?: number;
253
279
  coreCardId: number;
254
280
  quantity?: number;
281
+ /** Display name for the minted instances */
282
+ name?: string;
255
283
  userId?: number;
256
284
  }
257
285
  interface CommerceGetSettlementReportInput {
258
286
  shopId?: number;
259
287
  userId?: number;
260
- period?: string;
288
+ /** Number of days to include in the report period */
289
+ periodDays?: number;
261
290
  }
262
291
  interface CommerceSearchMarketplaceInput {
263
- keyword?: string;
264
- saleMode?: SaleMode;
265
- minPrice?: number;
266
- maxPrice?: number;
267
- limit?: number;
268
- offset?: number;
292
+ /** Search query string */
293
+ query?: string;
294
+ /** Filter by sale mode */
295
+ sale_mode?: SaleMode;
296
+ /** Minimum price in cents */
297
+ min_price_cents?: number;
298
+ /** Maximum price in cents */
299
+ max_price_cents?: number;
300
+ /** Filter by specific shop */
301
+ shop_id?: number;
302
+ /** Sort order (e.g. "newest", "price_asc", "price_desc", "popular") */
303
+ sort?: string;
304
+ /** Filter by status (e.g. "active") */
305
+ status?: string;
306
+ /** Page number (1-based) */
307
+ page?: number;
308
+ /** Items per page */
309
+ page_size?: number;
269
310
  }
270
311
  interface CommerceGetShopsByBlueprintInput {
271
- coreCardId: number;
272
- limit?: number;
312
+ /** Core card ID to find shops selling this blueprint */
313
+ core_card_id: number;
314
+ /** Include ended campaigns */
315
+ include_ended?: boolean;
316
+ /** Page number (1-based) */
317
+ page?: number;
318
+ /** Items per page */
319
+ page_size?: number;
273
320
  }
274
321
  interface CommerceRedeemPhysicalInput {
275
322
  orderItemId: number;
@@ -277,6 +324,8 @@ interface CommerceRedeemPhysicalInput {
277
324
  shippingAddress: string;
278
325
  shippingPhone: string;
279
326
  coreCardId?: number;
327
+ /** Core inventory item ID for the specific instance to redeem */
328
+ coreInventoryItemId?: number;
280
329
  userId?: number;
281
330
  }
282
331
  interface CommerceRegisterWebhookInput {
@@ -300,6 +349,12 @@ interface CommerceDeleteWebhookInput {
300
349
  }
301
350
  interface CommerceRegisterAppInput {
302
351
  appName: string;
352
+ /** App description */
353
+ description?: string;
354
+ /** Website URL for the app */
355
+ websiteUrl?: string;
356
+ /** Icon URL for the app */
357
+ iconUrl?: string;
303
358
  redirectUris?: string[];
304
359
  coreScopes?: string[];
305
360
  commerceScopes?: string[];
@@ -1,4 +1,4 @@
1
- export { createCommerceNamespace } from '../chunk-MUZDYQ67.js';
1
+ export { createCommerceNamespace } from '../chunk-V73MMKHI.js';
2
2
  import '../chunk-4SU7SU7K.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -4,8 +4,8 @@ import { ExchangeNamespace } from '../exchange/index.js';
4
4
  export { CompensationDirection, ExchangeAddToWatchlistInput, ExchangeBid, ExchangeBrowseMarketplaceInput, ExchangeBuyListingInput, ExchangeBuyListingOutput, ExchangeCancelListingInput, ExchangeCancelWtbInput, ExchangeCreateListingInput, ExchangeCreateListingOutput, ExchangeCreateWtbInput, ExchangeFulfillWtbInput, ExchangeFulfillWtbOutput, ExchangeGetBidsInput, ExchangeGetListingDetailInput, ExchangeGetMarketDataInput, ExchangeListing, ExchangeMarketData, ExchangePlaceBidInput, ExchangePlaceBidOutput, ExchangePricePoint, ExchangeProposeTradeInput, ExchangeRemoveFromWatchlistInput, ExchangeRespondToTradeInput, ExchangeRespondToTradeOutput, ExchangeTradeItem, ExchangeTradeProposal, ExchangeWatchlistItem, ExchangeWtb, ListingCondition, ListingType } from '../exchange/index.js';
5
5
  import { AliveNamespace } from '../alive/index.js';
6
6
  export { AliveBuildContextInput, AliveChatResponse, AliveClassifiedIntent, AliveClassifyIntentInput, AliveContext, AliveForgetMemoryInput, AliveGetIntimacyInput, AliveIntimacy, AliveMemory, AliveRecallMemoriesInput, AliveSendMessageInput, AliveStoreMemoryInput, AliveUpdateIntimacyInput, IntentCategory, MemoryType, MoodState } from '../alive/index.js';
7
- import { b as AuthUser, A as AuthGetOAuthAppInfoInput, a as AuthOAuthAppInfo, e as CollectibleGetInstanceByIdInput, f as CollectibleGetPublicInstanceInput, g as CollectibleGetPublicInstancesBatchInput, d as CollectibleGetCardProfileInput, h as CollectibleGetShellImageUrlInput, O as ZcoinGetMyBalanceOutput, Q as ZcoinGetMyHistoryInput, L as ZcoinGetDepositPackagesInput, K as ZcoinDepositPackage, D as ZcoinCreateDepositOrderInput, E as ZcoinCreateDepositOrderOutput, M as ZcoinGetDepositStatusInput, N as ZcoinGetDepositStatusOutput, z as ZcoinCommercialTransferInput, B as ZcoinCommercialTransferOutput, R as ZcoinMintAndChargeInput, V as ZcoinMintAndChargeOutput, Z as ZcoinChargeUserInput, y as ZcoinChargeUserOutput, H as ZcoinCreateDirectPurchaseOrderInput, J as ZcoinCreateDirectPurchaseOrderOutput, l as InventoryGetUserInventoryInput, I as InventoryConfirmOwnershipInput, k as InventoryConfirmOwnershipOutput, n as InventoryMintInput, o as InventoryMintOutput, s as InventoryTransferInput, t as InventoryTransferOutput, p as InventoryTransferByCardInput, q as InventoryTransferByCardOutput, m as InventoryGrantMintAuthInput, r as InventoryTransferHistoryInput, w as UserGetPublicProfileInput, x as UserPublicProfile, U as UserGetPublicProfileByIdInput, F as FranchiseGetInput, u as SeriesGetInput, v as SeriesListByFranchiseInput, C as CardGetInput, c as CardListBySeriesInput } from '../transport-BOlScYEv.js';
8
- export { G as GoodZApiError, i as GoodZApiFieldError, j as GoodZErrorV2, P as PurchaseChannel, S as SaleType, T as TransferReason, W as ZcoinTxType } from '../transport-BOlScYEv.js';
7
+ import { b as AuthUser, A as AuthGetOAuthAppInfoInput, a as AuthOAuthAppInfo, e as CollectibleGetInstanceByIdInput, f as CollectibleGetPublicInstanceInput, g as CollectibleGetPublicInstancesBatchInput, d as CollectibleGetCardProfileInput, h as CollectibleGetShellImageUrlInput, Q as ZcoinGetMyBalanceOutput, R as ZcoinGetMyHistoryInput, M as ZcoinGetDepositPackagesInput, L as ZcoinDepositPackage, E as ZcoinCreateDepositOrderInput, H as ZcoinCreateDepositOrderOutput, N as ZcoinGetDepositStatusInput, O as ZcoinGetDepositStatusOutput, B as ZcoinCommercialTransferInput, D as ZcoinCommercialTransferOutput, V as ZcoinMintAndChargeInput, W as ZcoinMintAndChargeOutput, Z as ZcoinChargeUserInput, z as ZcoinChargeUserOutput, J as ZcoinCreateDirectPurchaseOrderInput, K as ZcoinCreateDirectPurchaseOrderOutput, l as InventoryGetUserInventoryInput, n as InventoryItem, I as InventoryConfirmOwnershipInput, k as InventoryConfirmOwnershipOutput, o as InventoryMintInput, p as InventoryMintOutput, t as InventoryTransferInput, u as InventoryTransferOutput, q as InventoryTransferByCardInput, r as InventoryTransferByCardOutput, m as InventoryGrantMintAuthInput, s as InventoryTransferHistoryInput, x as UserGetPublicProfileInput, y as UserPublicProfile, U as UserGetPublicProfileByIdInput, F as FranchiseGetInput, v as SeriesGetInput, w as SeriesListByFranchiseInput, C as CardGetInput, c as CardListBySeriesInput } from '../transport-BeRIHrA1.js';
8
+ export { G as GoodZApiError, i as GoodZApiFieldError, j as GoodZErrorV2, P as PurchaseChannel, S as SaleType, T as TransferReason, X as ZcoinTxType } from '../transport-BeRIHrA1.js';
9
9
 
10
10
  /**
11
11
  * @goodz-core/sdk/core — Unified GoodZ API Client
@@ -142,7 +142,7 @@ interface ZcoinNamespace {
142
142
  }
143
143
  interface InventoryNamespace {
144
144
  /** Get a user's inventory (owned card instances). */
145
- getUserInventory(input: InventoryGetUserInventoryInput): Promise<any[]>;
145
+ getUserInventory(input: InventoryGetUserInventoryInput): Promise<InventoryItem[]>;
146
146
  /** Check if a user owns at least one instance of a specific card. */
147
147
  confirmOwnership(input: InventoryConfirmOwnershipInput): Promise<InventoryConfirmOwnershipOutput>;
148
148
  /**
@@ -279,4 +279,4 @@ declare function createGoodZClient(config?: GoodZClientConfig): GoodZClient;
279
279
  */
280
280
  declare const createUserClient: typeof createGoodZClient;
281
281
 
282
- export { AliveNamespace, AuthGetOAuthAppInfoInput, type AuthNamespace, AuthOAuthAppInfo, AuthUser, CardGetInput, CardListBySeriesInput, CollectibleGetCardProfileInput, CollectibleGetInstanceByIdInput, CollectibleGetPublicInstanceInput, CollectibleGetPublicInstancesBatchInput, CollectibleGetShellImageUrlInput, type CollectibleNamespace, CommerceNamespace, ExchangeNamespace, FranchiseGetInput, type GoodZClient, type GoodZClientConfig, InventoryConfirmOwnershipInput, InventoryConfirmOwnershipOutput, InventoryGetUserInventoryInput, InventoryGrantMintAuthInput, InventoryMintInput, InventoryMintOutput, type InventoryNamespace, InventoryTransferByCardInput, InventoryTransferByCardOutput, InventoryTransferHistoryInput, InventoryTransferInput, InventoryTransferOutput, type IpNamespace, SeriesGetInput, SeriesListByFranchiseInput, UserGetPublicProfileByIdInput, UserGetPublicProfileInput, type UserNamespace, UserPublicProfile, ZcoinChargeUserInput, ZcoinChargeUserOutput, ZcoinCommercialTransferInput, ZcoinCommercialTransferOutput, ZcoinCreateDepositOrderInput, ZcoinCreateDepositOrderOutput, ZcoinCreateDirectPurchaseOrderInput, ZcoinCreateDirectPurchaseOrderOutput, ZcoinDepositPackage, ZcoinGetDepositPackagesInput, ZcoinGetDepositStatusInput, ZcoinGetDepositStatusOutput, ZcoinGetMyBalanceOutput, ZcoinGetMyHistoryInput, ZcoinMintAndChargeInput, ZcoinMintAndChargeOutput, type ZcoinNamespace, createGoodZClient, createUserClient };
282
+ export { AliveNamespace, AuthGetOAuthAppInfoInput, type AuthNamespace, AuthOAuthAppInfo, AuthUser, CardGetInput, CardListBySeriesInput, CollectibleGetCardProfileInput, CollectibleGetInstanceByIdInput, CollectibleGetPublicInstanceInput, CollectibleGetPublicInstancesBatchInput, CollectibleGetShellImageUrlInput, type CollectibleNamespace, CommerceNamespace, ExchangeNamespace, FranchiseGetInput, type GoodZClient, type GoodZClientConfig, InventoryConfirmOwnershipInput, InventoryConfirmOwnershipOutput, InventoryGetUserInventoryInput, InventoryGrantMintAuthInput, InventoryItem, InventoryMintInput, InventoryMintOutput, type InventoryNamespace, InventoryTransferByCardInput, InventoryTransferByCardOutput, InventoryTransferHistoryInput, InventoryTransferInput, InventoryTransferOutput, type IpNamespace, SeriesGetInput, SeriesListByFranchiseInput, UserGetPublicProfileByIdInput, UserGetPublicProfileInput, type UserNamespace, UserPublicProfile, ZcoinChargeUserInput, ZcoinChargeUserOutput, ZcoinCommercialTransferInput, ZcoinCommercialTransferOutput, ZcoinCreateDepositOrderInput, ZcoinCreateDepositOrderOutput, ZcoinCreateDirectPurchaseOrderInput, ZcoinCreateDirectPurchaseOrderOutput, ZcoinDepositPackage, ZcoinGetDepositPackagesInput, ZcoinGetDepositStatusInput, ZcoinGetDepositStatusOutput, ZcoinGetMyBalanceOutput, ZcoinGetMyHistoryInput, ZcoinMintAndChargeInput, ZcoinMintAndChargeOutput, type ZcoinNamespace, createGoodZClient, createUserClient };
@@ -1,5 +1,5 @@
1
- export { createGoodZClient, createUserClient } from '../chunk-7O6UN2D2.js';
2
- import '../chunk-MUZDYQ67.js';
1
+ export { createGoodZClient, createUserClient } from '../chunk-GRHO47XL.js';
2
+ import '../chunk-V73MMKHI.js';
3
3
  import '../chunk-OUKZ2PRD.js';
4
4
  import '../chunk-JAVMQXJM.js';
5
5
  export { GoodZApiError } from '../chunk-4SU7SU7K.js';
@@ -1,4 +1,4 @@
1
- import { X as TransportConfig } from '../transport-BOlScYEv.js';
1
+ import { Y as TransportConfig } from '../transport-BeRIHrA1.js';
2
2
 
3
3
  /**
4
4
  * @goodz-core/sdk — Exchange API Type Definitions
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AuthNamespace, CollectibleNamespace, GoodZClient, GoodZClientConfig, InventoryNamespace, IpNamespace, UserNamespace, ZcoinNamespace, createGoodZClient, createUserClient } from './core/index.js';
2
- export { A as AuthGetOAuthAppInfoInput, a as AuthOAuthAppInfo, b as AuthUser, C as CardGetInput, c as CardListBySeriesInput, d as CollectibleGetCardProfileInput, e as CollectibleGetInstanceByIdInput, f as CollectibleGetPublicInstanceInput, g as CollectibleGetPublicInstancesBatchInput, h as CollectibleGetShellImageUrlInput, F as FranchiseGetInput, G as GoodZApiError, i as GoodZApiFieldError, j as GoodZErrorV2, I as InventoryConfirmOwnershipInput, k as InventoryConfirmOwnershipOutput, l as InventoryGetUserInventoryInput, m as InventoryGrantMintAuthInput, n as InventoryMintInput, o as InventoryMintOutput, p as InventoryTransferByCardInput, q as InventoryTransferByCardOutput, r as InventoryTransferHistoryInput, s as InventoryTransferInput, t as InventoryTransferOutput, P as PurchaseChannel, S as SaleType, u as SeriesGetInput, v as SeriesListByFranchiseInput, T as TransferReason, U as UserGetPublicProfileByIdInput, w as UserGetPublicProfileInput, x as UserPublicProfile, Z as ZcoinChargeUserInput, y as ZcoinChargeUserOutput, z as ZcoinCommercialTransferInput, B as ZcoinCommercialTransferOutput, D as ZcoinCreateDepositOrderInput, E as ZcoinCreateDepositOrderOutput, H as ZcoinCreateDirectPurchaseOrderInput, J as ZcoinCreateDirectPurchaseOrderOutput, K as ZcoinDepositPackage, L as ZcoinGetDepositPackagesInput, M as ZcoinGetDepositStatusInput, N as ZcoinGetDepositStatusOutput, O as ZcoinGetMyBalanceOutput, Q as ZcoinGetMyHistoryInput, R as ZcoinMintAndChargeInput, V as ZcoinMintAndChargeOutput, W as ZcoinTxType } from './transport-BOlScYEv.js';
2
+ export { A as AuthGetOAuthAppInfoInput, a as AuthOAuthAppInfo, b as AuthUser, C as CardGetInput, c as CardListBySeriesInput, d as CollectibleGetCardProfileInput, e as CollectibleGetInstanceByIdInput, f as CollectibleGetPublicInstanceInput, g as CollectibleGetPublicInstancesBatchInput, h as CollectibleGetShellImageUrlInput, F as FranchiseGetInput, G as GoodZApiError, i as GoodZApiFieldError, j as GoodZErrorV2, I as InventoryConfirmOwnershipInput, k as InventoryConfirmOwnershipOutput, l as InventoryGetUserInventoryInput, m as InventoryGrantMintAuthInput, n as InventoryItem, o as InventoryMintInput, p as InventoryMintOutput, q as InventoryTransferByCardInput, r as InventoryTransferByCardOutput, s as InventoryTransferHistoryInput, t as InventoryTransferInput, u as InventoryTransferOutput, P as PurchaseChannel, S as SaleType, v as SeriesGetInput, w as SeriesListByFranchiseInput, T as TransferReason, U as UserGetPublicProfileByIdInput, x as UserGetPublicProfileInput, y as UserPublicProfile, Z as ZcoinChargeUserInput, z as ZcoinChargeUserOutput, B as ZcoinCommercialTransferInput, D as ZcoinCommercialTransferOutput, E as ZcoinCreateDepositOrderInput, H as ZcoinCreateDepositOrderOutput, J as ZcoinCreateDirectPurchaseOrderInput, K as ZcoinCreateDirectPurchaseOrderOutput, L as ZcoinDepositPackage, M as ZcoinGetDepositPackagesInput, N as ZcoinGetDepositStatusInput, O as ZcoinGetDepositStatusOutput, Q as ZcoinGetMyBalanceOutput, R as ZcoinGetMyHistoryInput, V as ZcoinMintAndChargeInput, W as ZcoinMintAndChargeOutput, X as ZcoinTxType } from './transport-BeRIHrA1.js';
3
3
  export { AuthorizationMode, CampaignStatus, CommerceActivateCampaignInput, CommerceBatch, CommerceBatchTier, CommerceBrowseWholesaleInput, CommerceCampaign, CommerceCampaignItem, CommerceCreateBatchInput, CommerceCreateGachaPoolInput, CommerceCreateShopInput, CommerceDeleteWebhookInput, CommerceDrawResult, CommerceEndCampaignInput, CommerceExecutePurchaseInput, CommerceGachaItem, CommerceGachaPool, CommerceGetAuthUrlInput, CommerceGetCampaignInfoInput, CommerceGetCampaignItemsInput, CommerceGetMyOrdersInput, CommerceGetSettlementReportInput, CommerceGetShopDashboardInput, CommerceGetShopsByBlueprintInput, CommerceLaunchCampaignInput, CommerceListMyAppsInput, CommerceManageInventoryInput, CommerceMintToInventoryInput, CommerceNamespace, CommerceOrder, CommercePauseCampaignInput, CommercePityConfig, CommerceProcureBatchInput, CommercePublishToWholesaleInput, CommerceRedeemPhysicalInput, CommerceRegisterAppInput, CommerceRegisterInstancesInput, CommerceRegisterWebhookInput, CommerceSearchMarketplaceInput, CommerceShop, CommerceShopDashboard, CommerceTestWebhookInput, CommerceUpdateAppInput, CommerceUpdateCampaignInput, CommerceWebhook, CommerceWholesaleListing, IntegrationMode, SaleMode } from './commerce/index.js';
4
4
  export { CompensationDirection, ExchangeAddToWatchlistInput, ExchangeBid, ExchangeBrowseMarketplaceInput, ExchangeBuyListingInput, ExchangeBuyListingOutput, ExchangeCancelListingInput, ExchangeCancelWtbInput, ExchangeCreateListingInput, ExchangeCreateListingOutput, ExchangeCreateWtbInput, ExchangeFulfillWtbInput, ExchangeFulfillWtbOutput, ExchangeGetBidsInput, ExchangeGetListingDetailInput, ExchangeGetMarketDataInput, ExchangeListing, ExchangeMarketData, ExchangeNamespace, ExchangePlaceBidInput, ExchangePlaceBidOutput, ExchangePricePoint, ExchangeProposeTradeInput, ExchangeRemoveFromWatchlistInput, ExchangeRespondToTradeInput, ExchangeRespondToTradeOutput, ExchangeTradeItem, ExchangeTradeProposal, ExchangeWatchlistItem, ExchangeWtb, ListingCondition, ListingType } from './exchange/index.js';
5
5
  export { AliveBuildContextInput, AliveChatResponse, AliveClassifiedIntent, AliveClassifyIntentInput, AliveContext, AliveForgetMemoryInput, AliveGetIntimacyInput, AliveIntimacy, AliveMemory, AliveNamespace, AliveRecallMemoriesInput, AliveSendMessageInput, AliveStoreMemoryInput, AliveUpdateIntimacyInput, IntentCategory, MemoryType, MoodState } from './alive/index.js';
@@ -46,6 +46,6 @@ import 'react';
46
46
  * @module
47
47
  */
48
48
 
49
- declare const SDK_VERSION = "0.3.0";
49
+ declare const SDK_VERSION = "0.3.1";
50
50
 
51
51
  export { SDK_VERSION };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- export { createGoodZClient, createUserClient } from './chunk-7O6UN2D2.js';
1
+ export { createGoodZClient, createUserClient } from './chunk-GRHO47XL.js';
2
2
  export { TokenManager, buildAuthorizationUrl, exchangeCode } from './chunk-EUKUN4JF.js';
3
3
  export { ZCOIN_PRECISION, formatZcoin, formatZcoinWithSymbol, toDisplay, toHundredths } from './chunk-2ZETOE2X.js';
4
4
  export { FORM_FACTORS, GoodZCardFocus, getAspectRatioCSS, getFormFactorSpec } from './chunk-K6IFJWLB.js';
5
- import './chunk-MUZDYQ67.js';
5
+ import './chunk-V73MMKHI.js';
6
6
  import './chunk-OUKZ2PRD.js';
7
7
  import './chunk-JAVMQXJM.js';
8
8
  export { GoodZApiError } from './chunk-4SU7SU7K.js';
9
9
 
10
10
  // src/index.ts
11
- var SDK_VERSION = "0.3.0";
11
+ var SDK_VERSION = "0.3.1";
12
12
 
13
13
  export { SDK_VERSION };
14
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAqGO,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * @goodz-core/sdk — Official SDK for the GoodZ Ecosystem\n *\n * One package, all services. Stripe-style unified client.\n *\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk\";\n *\n * const goodz = createGoodZClient({ accessToken: \"...\" });\n *\n * // Core\n * await goodz.zcoin.getMyBalance();\n * await goodz.inventory.mint({ ... });\n *\n * // Commerce\n * await goodz.commerce.createShop({ name: \"My Shop\" });\n * await goodz.commerce.executePurchase({ campaignId: 1, quantity: 1 });\n *\n * // Exchange\n * await goodz.exchange.createListing({ ... });\n * await goodz.exchange.getMarketData({ coreGoodzId: 42 });\n *\n * // Alive\n * await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hello!\" });\n * ```\n *\n * For tree-shaking, prefer importing from specific subpaths:\n *\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk/core\";\n * import { TokenManager } from \"@goodz-core/sdk/auth\";\n * import { GoodZCardFocus } from \"@goodz-core/sdk/ui\";\n * ```\n *\n * @module\n */\n\n// Core client (includes all namespace types)\nexport {\n createGoodZClient,\n createUserClient,\n GoodZApiError,\n type GoodZClient,\n type GoodZClientConfig,\n // Core namespaces\n type ZcoinNamespace,\n type InventoryNamespace,\n type CollectibleNamespace,\n type UserNamespace,\n type AuthNamespace,\n type IpNamespace,\n // Sub-site namespaces\n type CommerceNamespace,\n type ExchangeNamespace,\n type AliveNamespace,\n} from \"./core/index\";\n\n// All API types — Core\nexport type * from \"./types\";\n\n// All API types — Commerce\nexport type * from \"./types-commerce\";\n\n// All API types — Exchange\nexport type * from \"./types-exchange\";\n\n// All API types — Alive\nexport type * from \"./types-alive\";\n\n// Auth helpers\nexport {\n TokenManager,\n buildAuthorizationUrl,\n exchangeCode,\n type TokenManagerConfig,\n type TokenPair,\n type OAuthUrlConfig,\n} from \"./auth/index\";\n\n// Z-coin utilities\nexport {\n ZCOIN_PRECISION,\n toHundredths,\n toDisplay,\n formatZcoin,\n formatZcoinWithSymbol,\n} from \"./zcoin-utils\";\n\n// UI components (React 18+)\n// Note: Import from \"@goodz-core/sdk/ui\" for tree-shaking\nexport {\n GoodZCardFocus,\n type GoodZCardFocusProps,\n type FormFactorKey,\n type FormFactorSpec,\n FORM_FACTORS,\n getFormFactorSpec,\n getAspectRatioCSS,\n} from \"./ui/index\";\n\n// SDK version\nexport const SDK_VERSION = \"0.3.0\";\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAqGO,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * @goodz-core/sdk — Official SDK for the GoodZ Ecosystem\n *\n * One package, all services. Stripe-style unified client.\n *\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk\";\n *\n * const goodz = createGoodZClient({ accessToken: \"...\" });\n *\n * // Core\n * await goodz.zcoin.getMyBalance();\n * await goodz.inventory.mint({ ... });\n *\n * // Commerce\n * await goodz.commerce.createShop({ name: \"My Shop\" });\n * await goodz.commerce.executePurchase({ campaignId: 1, quantity: 1 });\n *\n * // Exchange\n * await goodz.exchange.createListing({ ... });\n * await goodz.exchange.getMarketData({ coreGoodzId: 42 });\n *\n * // Alive\n * await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hello!\" });\n * ```\n *\n * For tree-shaking, prefer importing from specific subpaths:\n *\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk/core\";\n * import { TokenManager } from \"@goodz-core/sdk/auth\";\n * import { GoodZCardFocus } from \"@goodz-core/sdk/ui\";\n * ```\n *\n * @module\n */\n\n// Core client (includes all namespace types)\nexport {\n createGoodZClient,\n createUserClient,\n GoodZApiError,\n type GoodZClient,\n type GoodZClientConfig,\n // Core namespaces\n type ZcoinNamespace,\n type InventoryNamespace,\n type CollectibleNamespace,\n type UserNamespace,\n type AuthNamespace,\n type IpNamespace,\n // Sub-site namespaces\n type CommerceNamespace,\n type ExchangeNamespace,\n type AliveNamespace,\n} from \"./core/index\";\n\n// All API types — Core\nexport type * from \"./types\";\n\n// All API types — Commerce\nexport type * from \"./types-commerce\";\n\n// All API types — Exchange\nexport type * from \"./types-exchange\";\n\n// All API types — Alive\nexport type * from \"./types-alive\";\n\n// Auth helpers\nexport {\n TokenManager,\n buildAuthorizationUrl,\n exchangeCode,\n type TokenManagerConfig,\n type TokenPair,\n type OAuthUrlConfig,\n} from \"./auth/index\";\n\n// Z-coin utilities\nexport {\n ZCOIN_PRECISION,\n toHundredths,\n toDisplay,\n formatZcoin,\n formatZcoinWithSymbol,\n} from \"./zcoin-utils\";\n\n// UI components (React 18+)\n// Note: Import from \"@goodz-core/sdk/ui\" for tree-shaking\nexport {\n GoodZCardFocus,\n type GoodZCardFocusProps,\n type FormFactorKey,\n type FormFactorSpec,\n FORM_FACTORS,\n getFormFactorSpec,\n getAspectRatioCSS,\n} from \"./ui/index\";\n\n// SDK version\nexport const SDK_VERSION = \"0.3.1\";\n"]}
@@ -185,6 +185,37 @@ interface InventoryGetUserInventoryInput {
185
185
  limit?: number;
186
186
  offset?: number;
187
187
  }
188
+ /** A single item in the getUserInventory / mine response */
189
+ interface InventoryItem {
190
+ instanceId: number;
191
+ instanceCode: string;
192
+ shortCode: string;
193
+ instanceNumber: number;
194
+ currentOwnerId: number;
195
+ mintedVia: string;
196
+ mintedAt: number;
197
+ isRedeemed: boolean | null;
198
+ collectibleImageUrl: string | null;
199
+ shellImageUrl: string | null;
200
+ backgroundTemplate: string | null;
201
+ version: number;
202
+ cardId: number;
203
+ cardName: string;
204
+ cardImageUrl: string | null;
205
+ cardFormFactor: string | null;
206
+ /** Rarity label set by the creator (e.g. "SSR", "Rare", "Common") */
207
+ rarity: string | null;
208
+ /** Listing/display image URL — may differ from cardImageUrl */
209
+ listingImageUrl: string | null;
210
+ seriesId: number;
211
+ seriesName: string;
212
+ /** URL to the card blueprint page */
213
+ blueprintUrl: string;
214
+ /** URL to the instance profile page */
215
+ profileUrl: string;
216
+ /** Short public URL (if shortCode exists) */
217
+ publicUrl: string | null;
218
+ }
188
219
  interface InventoryConfirmOwnershipInput {
189
220
  userId: number;
190
221
  cardId: number;
@@ -374,4 +405,4 @@ interface TransportConfig {
374
405
  getHeaders: () => Record<string, string> | Promise<Record<string, string>>;
375
406
  }
376
407
 
377
- export { type AuthGetOAuthAppInfoInput as A, type ZcoinCommercialTransferOutput as B, type CardGetInput as C, type ZcoinCreateDepositOrderInput as D, type ZcoinCreateDepositOrderOutput as E, type FranchiseGetInput as F, GoodZApiError as G, type ZcoinCreateDirectPurchaseOrderInput as H, type InventoryConfirmOwnershipInput as I, type ZcoinCreateDirectPurchaseOrderOutput as J, type ZcoinDepositPackage as K, type ZcoinGetDepositPackagesInput as L, type ZcoinGetDepositStatusInput as M, type ZcoinGetDepositStatusOutput as N, type ZcoinGetMyBalanceOutput as O, type PurchaseChannel as P, type ZcoinGetMyHistoryInput as Q, type ZcoinMintAndChargeInput as R, type SaleType as S, type TransferReason as T, type UserGetPublicProfileByIdInput as U, type ZcoinMintAndChargeOutput as V, type ZcoinTxType as W, type TransportConfig as X, type ZcoinChargeUserInput as Z, type AuthOAuthAppInfo as a, type AuthUser as b, type CardListBySeriesInput as c, type CollectibleGetCardProfileInput as d, type CollectibleGetInstanceByIdInput as e, type CollectibleGetPublicInstanceInput as f, type CollectibleGetPublicInstancesBatchInput as g, type CollectibleGetShellImageUrlInput as h, type GoodZApiFieldError as i, type GoodZErrorV2 as j, type InventoryConfirmOwnershipOutput as k, type InventoryGetUserInventoryInput as l, type InventoryGrantMintAuthInput as m, type InventoryMintInput as n, type InventoryMintOutput as o, type InventoryTransferByCardInput as p, type InventoryTransferByCardOutput as q, type InventoryTransferHistoryInput as r, type InventoryTransferInput as s, type InventoryTransferOutput as t, type SeriesGetInput as u, type SeriesListByFranchiseInput as v, type UserGetPublicProfileInput as w, type UserPublicProfile as x, type ZcoinChargeUserOutput as y, type ZcoinCommercialTransferInput as z };
408
+ export { type AuthGetOAuthAppInfoInput as A, type ZcoinCommercialTransferInput as B, type CardGetInput as C, type ZcoinCommercialTransferOutput as D, type ZcoinCreateDepositOrderInput as E, type FranchiseGetInput as F, GoodZApiError as G, type ZcoinCreateDepositOrderOutput as H, type InventoryConfirmOwnershipInput as I, type ZcoinCreateDirectPurchaseOrderInput as J, type ZcoinCreateDirectPurchaseOrderOutput as K, type ZcoinDepositPackage as L, type ZcoinGetDepositPackagesInput as M, type ZcoinGetDepositStatusInput as N, type ZcoinGetDepositStatusOutput as O, type PurchaseChannel as P, type ZcoinGetMyBalanceOutput as Q, type ZcoinGetMyHistoryInput as R, type SaleType as S, type TransferReason as T, type UserGetPublicProfileByIdInput as U, type ZcoinMintAndChargeInput as V, type ZcoinMintAndChargeOutput as W, type ZcoinTxType as X, type TransportConfig as Y, type ZcoinChargeUserInput as Z, type AuthOAuthAppInfo as a, type AuthUser as b, type CardListBySeriesInput as c, type CollectibleGetCardProfileInput as d, type CollectibleGetInstanceByIdInput as e, type CollectibleGetPublicInstanceInput as f, type CollectibleGetPublicInstancesBatchInput as g, type CollectibleGetShellImageUrlInput as h, type GoodZApiFieldError as i, type GoodZErrorV2 as j, type InventoryConfirmOwnershipOutput as k, type InventoryGetUserInventoryInput as l, type InventoryGrantMintAuthInput as m, type InventoryItem as n, type InventoryMintInput as o, type InventoryMintOutput as p, type InventoryTransferByCardInput as q, type InventoryTransferByCardOutput as r, type InventoryTransferHistoryInput as s, type InventoryTransferInput as t, type InventoryTransferOutput as u, type SeriesGetInput as v, type SeriesListByFranchiseInput as w, type UserGetPublicProfileInput as x, type UserPublicProfile as y, type ZcoinChargeUserOutput as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodz-core/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Official SDK for the GoodZ Ecosystem — unified API client for Core, Commerce, Exchange, and Alive. Includes OAuth helpers, Z-coin utilities, and React UI components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"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","file":"chunk-7O6UN2D2.js","sourcesContent":["/**\n * @goodz-core/sdk/core — Unified GoodZ API Client\n *\n * One client, all services. Stripe-style namespace architecture:\n * goodz.zcoin.* → Core settlement & Z-coin\n * goodz.inventory.* → Core instance management\n * goodz.collectible.* → Core card queries\n * goodz.user.* → Core user profiles\n * goodz.auth.* → Core auth\n * goodz.ip.* → Core IP (franchise/series/card)\n * goodz.commerce.* → Commerce/Shops (MCP)\n * goodz.exchange.* → Exchange marketplace (MCP)\n * goodz.alive.* → Alive companions (MCP)\n *\n * Core uses tRPC HTTP wire protocol; sub-sites use MCP JSON-RPC 2.0.\n * The client handles routing transparently.\n *\n * @example\n * ```ts\n * import { createGoodZClient } from \"@goodz-core/sdk\";\n *\n * const goodz = createGoodZClient({\n * accessToken: \"your-jwt-token\",\n * });\n *\n * // Core APIs\n * const balance = await goodz.zcoin.getMyBalance();\n * const result = await goodz.zcoin.commercialTransfer({ ... });\n *\n * // Commerce APIs\n * const shop = await goodz.commerce.createShop({ name: \"My Shop\" });\n * const order = await goodz.commerce.executePurchase({ campaignId: 1, quantity: 1 });\n *\n * // Exchange APIs\n * const listing = await goodz.exchange.createListing({ ... });\n * const data = await goodz.exchange.getMarketData({ coreGoodzId: 42 });\n *\n * // Alive APIs\n * const chat = await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hello!\" });\n * const memories = await goodz.alive.recallMemories({ instanceId: 1, userId: 1, query: \"birthday\" });\n * ```\n *\n * @module\n */\n\nimport { callQuery, callMutation, GoodZApiError } from \"../transport\";\nimport type { TransportConfig } from \"../transport\";\nimport { createMcpTransportConfig } from \"../mcp-transport\";\nimport { createCommerceNamespace } from \"../commerce/index\";\nimport type { CommerceNamespace } from \"../commerce/index\";\nimport { createExchangeNamespace } from \"../exchange/index\";\nimport type { ExchangeNamespace } from \"../exchange/index\";\nimport { createAliveNamespace } from \"../alive/index\";\nimport type { AliveNamespace } from \"../alive/index\";\nimport type {\n // zcoin\n ZcoinGetMyBalanceOutput,\n ZcoinGetMyHistoryInput,\n ZcoinCommercialTransferInput,\n ZcoinCommercialTransferOutput,\n ZcoinMintAndChargeInput,\n ZcoinMintAndChargeOutput,\n ZcoinChargeUserInput,\n ZcoinChargeUserOutput,\n ZcoinCreateDirectPurchaseOrderInput,\n ZcoinCreateDirectPurchaseOrderOutput,\n ZcoinGetDepositPackagesInput,\n ZcoinDepositPackage,\n ZcoinCreateDepositOrderInput,\n ZcoinCreateDepositOrderOutput,\n ZcoinGetDepositStatusInput,\n ZcoinGetDepositStatusOutput,\n // inventory\n InventoryGetUserInventoryInput,\n InventoryConfirmOwnershipInput,\n InventoryConfirmOwnershipOutput,\n InventoryMintInput,\n InventoryMintOutput,\n InventoryTransferInput,\n InventoryTransferOutput,\n InventoryTransferByCardInput,\n InventoryTransferByCardOutput,\n InventoryGrantMintAuthInput,\n InventoryTransferHistoryInput,\n // collectible\n CollectibleGetInstanceByIdInput,\n CollectibleGetPublicInstanceInput,\n CollectibleGetPublicInstancesBatchInput,\n CollectibleGetCardProfileInput,\n CollectibleGetShellImageUrlInput,\n // user\n UserGetPublicProfileInput,\n UserPublicProfile,\n UserGetPublicProfileByIdInput,\n // auth\n AuthGetOAuthAppInfoInput,\n AuthOAuthAppInfo,\n AuthUser,\n // ip\n FranchiseGetInput,\n SeriesGetInput,\n SeriesListByFranchiseInput,\n CardGetInput,\n CardListBySeriesInput,\n} from \"../types\";\n\n// ─── Re-export types and error class ─────────────────────────\n\nexport { GoodZApiError } from \"../transport\";\nexport type * from \"../types\";\nexport type * from \"../types-commerce\";\nexport type * from \"../types-exchange\";\nexport type * from \"../types-alive\";\nexport type { CommerceNamespace } from \"../commerce/index\";\nexport type { ExchangeNamespace } from \"../exchange/index\";\nexport type { AliveNamespace } from \"../alive/index\";\n\n// ─── Default sub-site URLs ──────────────────────────────────\n\nconst DEFAULT_CORE_URL = \"https://goodzcore.manus.space\";\nconst DEFAULT_COMMERCE_URL = \"https://goodzcommerce.manus.space\";\nconst DEFAULT_EXCHANGE_URL = \"https://goodzexchange.manus.space\";\nconst DEFAULT_ALIVE_URL = \"https://goodzalive.manus.space\";\n\n// ─── Client config ───────────────────────────────────────────\n\nexport interface GoodZClientConfig {\n /**\n * GoodZ.Core base URL.\n * @default \"https://goodzcore.manus.space\"\n */\n coreUrl?: string;\n\n /**\n * GoodZ.Commerce (Shops) base URL.\n * @default \"https://goodzcommerce.manus.space\"\n */\n commerceUrl?: string;\n\n /**\n * GoodZ.Exchange base URL.\n * @default \"https://goodzexchange.manus.space\"\n */\n exchangeUrl?: string;\n\n /**\n * GoodZ.Alive base URL.\n * @default \"https://goodzalive.manus.space\"\n */\n aliveUrl?: string;\n\n /**\n * Static access token (JWT) for authentication.\n * For server-to-server calls, obtain this via OAuth client_credentials flow.\n * For user-context calls, pass the user's access token.\n */\n accessToken?: string;\n\n /**\n * Dynamic token provider — called before every request.\n * Use this when tokens may rotate (e.g., auto-refresh).\n * Takes precedence over `accessToken` if both are set.\n */\n getAccessToken?: () => string | Promise<string>;\n\n /**\n * Custom headers to include in every request.\n * Useful for passing app identifiers or tracing headers.\n */\n headers?: Record<string, string>;\n}\n\n// ─── Core namespace interfaces (tRPC) ───────────────────────\n\nexport interface ZcoinNamespace {\n /** Get the authenticated user's Z-coin balance. */\n getMyBalance(): Promise<ZcoinGetMyBalanceOutput>;\n\n /** Get the authenticated user's Z-coin transaction history. */\n getMyHistory(input?: ZcoinGetMyHistoryInput): Promise<any[]>;\n\n /** Get available Z-coin deposit packages with pricing. */\n getDepositPackages(input?: ZcoinGetDepositPackagesInput): Promise<ZcoinDepositPackage[]>;\n\n /** Create a Stripe checkout session for Z-coin deposit. */\n createDepositOrder(input: ZcoinCreateDepositOrderInput): Promise<ZcoinCreateDepositOrderOutput>;\n\n /** Check the status of a deposit checkout session. */\n getDepositStatus(input: ZcoinGetDepositStatusInput): Promise<ZcoinGetDepositStatusOutput>;\n\n /**\n * Atomic commercial transfer: Z-coin payment + ownership transfer in one transaction.\n * This is the primary API for Commerce and Exchange purchase flows.\n *\n * Idempotent via referenceId — duplicate calls return the same result.\n *\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n * @throws {GoodZApiError} CONFLICT — version conflict (retry)\n * @throws {GoodZApiError} FORBIDDEN — seller doesn't own instance\n */\n commercialTransfer(input: ZcoinCommercialTransferInput): Promise<ZcoinCommercialTransferOutput>;\n\n /**\n * Mint a new card instance and charge the buyer in one atomic transaction.\n * Used by Commerce for gacha and direct-from-creator purchases.\n *\n * Requires mint authorization (granted via inventory.grantMintAuth).\n * Idempotent via referenceId.\n *\n * @throws {GoodZApiError} FORBIDDEN — no mint authorization\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n */\n mintAndCharge(input: ZcoinMintAndChargeInput): Promise<ZcoinMintAndChargeOutput>;\n\n /**\n * Charge a user's Z-coin balance for an in-app purchase.\n * Used by apps that sell non-GoodZ digital goods/services.\n *\n * Idempotent via appOrderId.\n *\n * @throws {GoodZApiError} BAD_REQUEST — insufficient balance\n * @throws {GoodZApiError} CONFLICT — version conflict\n */\n chargeUser(input: ZcoinChargeUserInput): Promise<ZcoinChargeUserOutput>;\n\n /**\n * Create a direct purchase checkout session (fiat → Z-coin → transfer).\n * Transparent intermediation: user sees fiat price, Core handles conversion.\n */\n createDirectPurchaseOrder(input: ZcoinCreateDirectPurchaseOrderInput): Promise<ZcoinCreateDirectPurchaseOrderOutput>;\n}\n\nexport interface InventoryNamespace {\n /** Get a user's inventory (owned card instances). */\n getUserInventory(input: InventoryGetUserInventoryInput): Promise<any[]>;\n\n /** Check if a user owns at least one instance of a specific card. */\n confirmOwnership(input: InventoryConfirmOwnershipInput): Promise<InventoryConfirmOwnershipOutput>;\n\n /**\n * Mint new card instances. Requires franchise ownership or admin role.\n * For Commerce/Exchange, use zcoin.mintAndCharge instead (includes payment).\n */\n mint(input: InventoryMintInput): Promise<InventoryMintOutput>;\n\n /**\n * Transfer a specific card instance to another user.\n * For commercial transfers, use zcoin.commercialTransfer instead.\n *\n * @deprecated for reason=\"purchase\"|\"trade\" — use commercialTransfer\n */\n transfer(input: InventoryTransferInput): Promise<InventoryTransferOutput>;\n\n /**\n * Transfer card instances by cardId (transfers oldest instances).\n * For commercial transfers, use zcoin.commercialTransfer instead.\n *\n * @deprecated for reason=\"purchase\"|\"trade\" — use commercialTransfer\n */\n transferByCard(input: InventoryTransferByCardInput): Promise<InventoryTransferByCardOutput>;\n\n /**\n * Grant mint authorization to another user/app for a specific card.\n * Required before Commerce can call zcoin.mintAndCharge for that card.\n */\n grantMintAuth(input: InventoryGrantMintAuthInput): Promise<any>;\n\n /** Get transfer/ownership history for an instance, card, or user. */\n transferHistory(input: InventoryTransferHistoryInput): Promise<any[]>;\n}\n\nexport interface CollectibleNamespace {\n /** Get a card instance by its numeric ID. Returns full instance data with card chain. */\n getInstanceById(input: CollectibleGetInstanceByIdInput): Promise<any>;\n\n /** Get a card instance by its instance code (public-facing identifier). */\n getPublicInstance(input: CollectibleGetPublicInstanceInput): Promise<any>;\n\n /** Batch-fetch multiple card instances by their IDs (max 100). */\n getPublicInstancesBatch(input: CollectibleGetPublicInstancesBatchInput): Promise<any[]>;\n\n /** Get the card profile (metadata, rarity, series info). */\n getCardProfile(input: CollectibleGetCardProfileInput): Promise<any>;\n\n /** Get the shell (packaging) image URL for a card. */\n getShellImageUrl(input: CollectibleGetShellImageUrlInput): Promise<any>;\n}\n\nexport interface UserNamespace {\n /** Get a user's public profile by openId. */\n getPublicProfile(input: UserGetPublicProfileInput): Promise<UserPublicProfile>;\n\n /** Get a user's public profile by internal userId. */\n getPublicProfileById(input: UserGetPublicProfileByIdInput): Promise<UserPublicProfile>;\n}\n\nexport interface AuthNamespace {\n /** Get the authenticated user's profile. Returns null if not authenticated. */\n me(): Promise<AuthUser | null>;\n\n /** Get public info about an OAuth app by its client ID. */\n getOAuthAppInfo(input: AuthGetOAuthAppInfoInput): Promise<AuthOAuthAppInfo | null>;\n}\n\nexport interface IpNamespace {\n /** Get a franchise by ID or slug. */\n getFranchise(input: FranchiseGetInput): Promise<any>;\n\n /** Get a series by ID or slug. */\n getSeries(input: SeriesGetInput): Promise<any>;\n\n /** List all series in a franchise. */\n listSeriesByFranchise(input: SeriesListByFranchiseInput): Promise<any[]>;\n\n /** Get a card by ID. */\n getCard(input: CardGetInput): Promise<any>;\n\n /** List all cards in a series. */\n listCardsBySeries(input: CardListBySeriesInput): Promise<any[]>;\n}\n\n// ─── GoodZClient type ────────────────────────────────────────\n\nexport interface GoodZClient {\n // ── Core namespaces (tRPC) ──\n readonly zcoin: ZcoinNamespace;\n readonly inventory: InventoryNamespace;\n readonly collectible: CollectibleNamespace;\n readonly user: UserNamespace;\n readonly auth: AuthNamespace;\n readonly ip: IpNamespace;\n\n // ── Sub-site namespaces (MCP) ──\n readonly commerce: CommerceNamespace;\n readonly exchange: ExchangeNamespace;\n readonly alive: AliveNamespace;\n\n /**\n * Make a raw tRPC query call to Core. Use this for routes not yet covered\n * by the typed namespaces.\n */\n rawQuery<T = any>(path: string, input?: any): Promise<T>;\n\n /**\n * Make a raw tRPC mutation call to Core. Use this for routes not yet covered\n * by the typed namespaces.\n */\n rawMutation<T = any>(path: string, input?: any): Promise<T>;\n}\n\n// ─── Client factory ──────────────────────────────────────────\n\n/**\n * Create a unified GoodZ API client — one client for all services.\n *\n * @example Server-to-server with static token\n * ```ts\n * const goodz = createGoodZClient({\n * accessToken: process.env.CORE_ACCESS_TOKEN,\n * });\n *\n * // Core\n * const balance = await goodz.zcoin.getMyBalance();\n *\n * // Commerce\n * const shop = await goodz.commerce.createShop({ name: \"My Shop\" });\n *\n * // Exchange\n * const listings = await goodz.exchange.browseMarketplace();\n *\n * // Alive\n * const chat = await goodz.alive.sendMessage({ instanceId: 1, userId: 1, message: \"Hi!\" });\n * ```\n *\n * @example With dynamic token provider (auto-refresh)\n * ```ts\n * const goodz = createGoodZClient({\n * getAccessToken: async () => {\n * const token = await refreshTokenIfNeeded();\n * return token;\n * },\n * });\n * ```\n *\n * @example Custom sub-site URLs (e.g., staging environment)\n * ```ts\n * const goodz = createGoodZClient({\n * accessToken: \"...\",\n * coreUrl: \"https://staging-core.goodz.dev\",\n * commerceUrl: \"https://staging-commerce.goodz.dev\",\n * exchangeUrl: \"https://staging-exchange.goodz.dev\",\n * aliveUrl: \"https://staging-alive.goodz.dev\",\n * });\n * ```\n */\nexport function createGoodZClient(config: GoodZClientConfig = {}): GoodZClient {\n const {\n coreUrl = DEFAULT_CORE_URL,\n commerceUrl = DEFAULT_COMMERCE_URL,\n exchangeUrl = DEFAULT_EXCHANGE_URL,\n aliveUrl = DEFAULT_ALIVE_URL,\n accessToken,\n getAccessToken,\n headers: customHeaders,\n } = config;\n\n // Shared header builder — used by both tRPC and MCP transports\n const buildHeaders = async (): Promise<Record<string, string>> => {\n const h: Record<string, string> = { ...customHeaders };\n const token = getAccessToken ? await getAccessToken() : accessToken;\n if (token) {\n h[\"Authorization\"] = `Bearer ${token}`;\n }\n return h;\n };\n\n // ── Core transport (tRPC) ──\n const coreTransport: TransportConfig = {\n baseUrl: coreUrl.replace(/\\/$/, \"\"),\n getHeaders: buildHeaders,\n };\n\n // ── Sub-site transports (MCP) ──\n const commerceTransport = createMcpTransportConfig(commerceUrl, buildHeaders);\n const exchangeTransport = createMcpTransportConfig(exchangeUrl, buildHeaders);\n const aliveTransport = createMcpTransportConfig(aliveUrl, buildHeaders);\n\n // Helper shortcuts for Core tRPC\n const q = <I, O>(path: string) => (input?: I) => callQuery<I, O>(coreTransport, path, input);\n const m = <I, O>(path: string) => (input?: I) => callMutation<I, O>(coreTransport, path, input);\n\n return {\n // ── zcoin ──────────────────────────────────────────────\n zcoin: {\n getMyBalance: q<void, ZcoinGetMyBalanceOutput>(\"zcoin.getMyBalance\"),\n getMyHistory: q<ZcoinGetMyHistoryInput, any[]>(\"zcoin.getMyHistory\"),\n getDepositPackages: q<ZcoinGetDepositPackagesInput, ZcoinDepositPackage[]>(\"zcoin.getDepositPackages\"),\n createDepositOrder: m<ZcoinCreateDepositOrderInput, ZcoinCreateDepositOrderOutput>(\"zcoin.createDepositOrder\"),\n getDepositStatus: q<ZcoinGetDepositStatusInput, ZcoinGetDepositStatusOutput>(\"zcoin.getDepositStatus\"),\n commercialTransfer: m<ZcoinCommercialTransferInput, ZcoinCommercialTransferOutput>(\"zcoin.commercialTransfer\"),\n mintAndCharge: m<ZcoinMintAndChargeInput, ZcoinMintAndChargeOutput>(\"zcoin.mintAndCharge\"),\n chargeUser: m<ZcoinChargeUserInput, ZcoinChargeUserOutput>(\"zcoin.chargeUser\"),\n createDirectPurchaseOrder: m<ZcoinCreateDirectPurchaseOrderInput, ZcoinCreateDirectPurchaseOrderOutput>(\"zcoin.createDirectPurchaseOrder\"),\n },\n\n // ── inventory ──────────────────────────────────────────\n inventory: {\n getUserInventory: q<InventoryGetUserInventoryInput, any[]>(\"inventory.getUserInventory\"),\n confirmOwnership: q<InventoryConfirmOwnershipInput, InventoryConfirmOwnershipOutput>(\"inventory.confirmOwnership\"),\n mint: m<InventoryMintInput, InventoryMintOutput>(\"inventory.mint\"),\n transfer: m<InventoryTransferInput, InventoryTransferOutput>(\"inventory.transfer\"),\n transferByCard: m<InventoryTransferByCardInput, InventoryTransferByCardOutput>(\"inventory.transferByCard\"),\n grantMintAuth: m<InventoryGrantMintAuthInput, any>(\"inventory.grantMintAuth\"),\n transferHistory: q<InventoryTransferHistoryInput, any[]>(\"inventory.transferHistory\"),\n },\n\n // ── collectible ────────────────────────────────────────\n collectible: {\n getInstanceById: q<CollectibleGetInstanceByIdInput, any>(\"collectible.getInstanceById\"),\n getPublicInstance: q<CollectibleGetPublicInstanceInput, any>(\"collectible.getPublicInstance\"),\n getPublicInstancesBatch: q<CollectibleGetPublicInstancesBatchInput, any[]>(\"collectible.getPublicInstancesBatch\"),\n getCardProfile: q<CollectibleGetCardProfileInput, any>(\"collectible.getCardProfile\"),\n getShellImageUrl: q<CollectibleGetShellImageUrlInput, any>(\"collectible.getShellImageUrl\"),\n },\n\n // ── user ───────────────────────────────────────────────\n user: {\n getPublicProfile: q<UserGetPublicProfileInput, UserPublicProfile>(\"user.getPublicProfile\"),\n getPublicProfileById: q<UserGetPublicProfileByIdInput, UserPublicProfile>(\"user.getPublicProfileById\"),\n },\n\n // ── auth ───────────────────────────────────────────────\n auth: {\n me: q<void, AuthUser | null>(\"auth.me\"),\n getOAuthAppInfo: q<AuthGetOAuthAppInfoInput, AuthOAuthAppInfo | null>(\"auth.getOAuthAppInfo\"),\n },\n\n // ── ip (franchise/series/card) ─────────────────────────\n ip: {\n getFranchise: q<FranchiseGetInput, any>(\"franchise.get\"),\n getSeries: q<SeriesGetInput, any>(\"series.get\"),\n listSeriesByFranchise: q<SeriesListByFranchiseInput, any[]>(\"series.listByFranchise\"),\n getCard: q<CardGetInput, any>(\"card.get\"),\n listCardsBySeries: q<CardListBySeriesInput, any[]>(\"card.listBySeries\"),\n },\n\n // ── commerce (MCP) ─────────────────────────────────────\n commerce: createCommerceNamespace(commerceTransport),\n\n // ── exchange (MCP) ─────────────────────────────────────\n exchange: createExchangeNamespace(exchangeTransport),\n\n // ── alive (MCP) ────────────────────────────────────────\n alive: createAliveNamespace(aliveTransport),\n\n // ── raw escape hatches (Core tRPC only) ────────────────\n rawQuery: <T = any>(path: string, input?: any) => callQuery<any, T>(coreTransport, path, input),\n rawMutation: <T = any>(path: string, input?: any) => callMutation<any, T>(coreTransport, path, input),\n };\n}\n\n/**\n * Alias for createGoodZClient — creates a client acting on behalf of a user.\n * Semantically identical, but makes the intent clearer in server-to-server code.\n */\nexport const createUserClient = createGoodZClient;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commerce/index.ts"],"names":[],"mappings":";;;AAuJO,SAAS,wBAAwB,SAAA,EAA+C;AACrF,EAAA,MAAM,IAAA,GAAO,CAAmC,IAAA,KAC9C,CAAC,UAAc,WAAA,CAAkB,SAAA,EAAW,MAAM,KAAU,CAAA;AAE9D,EAAA,OAAO;AAAA;AAAA,IAEL,UAAA,EAAY,KAA4C,aAAa,CAAA;AAAA,IACrE,gBAAA,EAAkB,KAA2D,oBAAoB,CAAA;AAAA;AAAA,IAGjG,WAAA,EAAa,KAA8C,cAAc,CAAA;AAAA,IACzE,eAAA,EAAiB,KAAsD,mBAAmB,CAAA;AAAA;AAAA,IAG1F,cAAA,EAAgB,KAAoD,uBAAuB,CAAA;AAAA,IAC3F,gBAAA,EAAkB,KAAsD,mBAAmB,CAAA;AAAA,IAC3F,aAAA,EAAe,KAAmD,gBAAgB,CAAA;AAAA,IAClF,WAAA,EAAa,KAAiD,cAAc,CAAA;AAAA,IAC5E,cAAA,EAAgB,KAAoD,iBAAiB,CAAA;AAAA,IACrF,eAAA,EAAiB,KAAwC,mBAAmB,CAAA;AAAA,IAC5E,gBAAA,EAAkB,KAA4D,oBAAoB,CAAA;AAAA;AAAA,IAGlG,eAAA,EAAiB,KAAuD,kBAAkB,CAAA;AAAA,IAC1F,WAAA,EAAa,KAAgD,eAAe,CAAA;AAAA;AAAA,IAG5E,kBAAA,EAAoB,KAA2C,sBAAsB,CAAA;AAAA,IACrF,eAAA,EAAiB,KAA+D,kBAAkB,CAAA;AAAA,IAClG,YAAA,EAAc,KAAqC,eAAe,CAAA;AAAA;AAAA,IAGlE,eAAA,EAAiB,KAAwC,kBAAkB,CAAA;AAAA,IAC3E,iBAAA,EAAmB,KAA0C,oBAAoB,CAAA;AAAA,IACjF,eAAA,EAAiB,KAAwC,mBAAmB,CAAA;AAAA;AAAA,IAG5E,mBAAA,EAAqB,KAA4C,uBAAuB,CAAA;AAAA;AAAA,IAGxF,iBAAA,EAAmB,KAA4C,oBAAoB,CAAA;AAAA,IACnF,mBAAA,EAAqB,KAA8C,wBAAwB,CAAA;AAAA;AAAA,IAG3F,cAAA,EAAgB,KAAuC,uBAAuB,CAAA;AAAA;AAAA,IAG9E,eAAA,EAAiB,KAAoD,kBAAkB,CAAA;AAAA,IACvF,YAAA,EAAc,KAA+C,eAAe,CAAA;AAAA,IAC5E,WAAA,EAAa,KAAoC,cAAc,CAAA;AAAA,IAC/D,aAAA,EAAe,KAAsC,gBAAgB,CAAA;AAAA;AAAA,IAGrE,WAAA,EAAa,KAAoC,cAAc,CAAA;AAAA,IAC/D,SAAA,EAAW,KAAkC,YAAY,CAAA;AAAA,IACzD,UAAA,EAAY,KAAqC,cAAc,CAAA;AAAA,IAC/D,UAAA,EAAY,KAA+C,cAAc,CAAA;AAAA;AAAA,IAGzE,SAAS,CAAU,QAAA,EAAkB,SACnC,WAAA,CAAoC,SAAA,EAAW,UAAU,IAAI;AAAA,GACjE;AACF","file":"chunk-MUZDYQ67.js","sourcesContent":["/**\n * @goodz-core/sdk — Commerce / Shops Namespace\n *\n * Provides typed access to GoodZ.Commerce MCP tools:\n * shop management, batches, gacha pools, campaigns,\n * wholesale, purchases, settlement, and webhooks.\n *\n * @module\n */\n\nimport { callMcpTool } from \"../mcp-transport\";\nimport type { TransportConfig } from \"../mcp-transport\";\nimport type {\n CommerceCreateShopInput,\n CommerceShop,\n CommerceGetShopDashboardInput,\n CommerceShopDashboard,\n CommerceCreateBatchInput,\n CommerceBatch,\n CommerceCreateGachaPoolInput,\n CommerceGachaPool,\n CommerceLaunchCampaignInput,\n CommerceCampaign,\n CommerceActivateCampaignInput,\n CommercePauseCampaignInput,\n CommerceEndCampaignInput,\n CommerceUpdateCampaignInput,\n CommerceGetCampaignInfoInput,\n CommerceGetCampaignItemsInput,\n CommerceCampaignItem,\n CommerceExecutePurchaseInput,\n CommerceDrawResult,\n CommerceGetMyOrdersInput,\n CommerceOrder,\n CommercePublishToWholesaleInput,\n CommerceBrowseWholesaleInput,\n CommerceWholesaleListing,\n CommerceProcureBatchInput,\n CommerceManageInventoryInput,\n CommerceRegisterInstancesInput,\n CommerceMintToInventoryInput,\n CommerceGetSettlementReportInput,\n CommerceSearchMarketplaceInput,\n CommerceGetShopsByBlueprintInput,\n CommerceRedeemPhysicalInput,\n CommerceRegisterWebhookInput,\n CommerceWebhook,\n CommerceTestWebhookInput,\n CommerceDeleteWebhookInput,\n CommerceRegisterAppInput,\n CommerceUpdateAppInput,\n CommerceListMyAppsInput,\n CommerceGetAuthUrlInput,\n} from \"../types-commerce\";\n\n// Re-export all Commerce types\nexport type * from \"../types-commerce\";\n\n// ─── Namespace interface ────────────────────────────────────\n\nexport interface CommerceNamespace {\n // Shop Management\n /** Create a new shop. */\n createShop(input: CommerceCreateShopInput): Promise<CommerceShop>;\n /** Get shop dashboard with stats, revenue, and recent orders. */\n getShopDashboard(input?: CommerceGetShopDashboardInput): Promise<CommerceShopDashboard>;\n\n // Product Assembly\n /** Create a batch (product assembly with tiers). Supports blind_box, ichiban_kuji, direct_sale. */\n createBatch(input: CommerceCreateBatchInput): Promise<CommerceBatch>;\n /** Create a gacha pool with weighted probabilities and optional pity mechanics. */\n createGachaPool(input: CommerceCreateGachaPoolInput): Promise<CommerceGachaPool>;\n\n // Campaign Lifecycle\n /** Launch a sales campaign in draft status. Connect a Batch or Gacha pool to the storefront. */\n launchCampaign(input: CommerceLaunchCampaignInput): Promise<CommerceCampaign>;\n /** Activate a draft/paused campaign — makes it live and purchasable. */\n activateCampaign(input: CommerceActivateCampaignInput): Promise<CommerceCampaign>;\n /** Pause an active campaign. Existing orders unaffected. */\n pauseCampaign(input: CommercePauseCampaignInput): Promise<CommerceCampaign>;\n /** Permanently end a campaign (terminal state). */\n endCampaign(input: CommerceEndCampaignInput): Promise<CommerceCampaign>;\n /** Update campaign configuration (editable fields depend on status). */\n updateCampaign(input: CommerceUpdateCampaignInput): Promise<CommerceCampaign>;\n /** Get detailed campaign info including batch/gacha config and tiers. */\n getCampaignInfo(input: CommerceGetCampaignInfoInput): Promise<any>;\n /** Get unified campaign items list (works for both batch and gacha campaigns). */\n getCampaignItems(input: CommerceGetCampaignItemsInput): Promise<CommerceCampaignItem[]>;\n\n // Purchase / Draw\n /** Execute a purchase or draw. Handles payment, draw mechanics, settlement, and ownership transfer. */\n executePurchase(input: CommerceExecutePurchaseInput): Promise<CommerceDrawResult>;\n /** Get the authenticated user's order history. */\n getMyOrders(input?: CommerceGetMyOrdersInput): Promise<CommerceOrder[]>;\n\n // Wholesale\n /** Publish a batch to the wholesale market for other shopkeepers to procure. */\n publishToWholesale(input: CommercePublishToWholesaleInput): Promise<any>;\n /** Browse available wholesale listings. */\n browseWholesale(input?: CommerceBrowseWholesaleInput): Promise<CommerceWholesaleListing[]>;\n /** Procure goods from the wholesale market. */\n procureBatch(input: CommerceProcureBatchInput): Promise<any>;\n\n // Inventory\n /** View and manage shop inventory (list or sync from Core). */\n manageInventory(input?: CommerceManageInventoryInput): Promise<any>;\n /** Register existing Core instances into shop inventory. */\n registerInstances(input: CommerceRegisterInstancesInput): Promise<any>;\n /** Mint new instances directly into shop inventory. */\n mintToInventory(input: CommerceMintToInventoryInput): Promise<any>;\n\n // Settlement\n /** Get settlement report with revenue breakdown. */\n getSettlementReport(input?: CommerceGetSettlementReportInput): Promise<any>;\n\n // Discovery\n /** Search the marketplace for campaigns. */\n searchMarketplace(input?: CommerceSearchMarketplaceInput): Promise<any[]>;\n /** Find shops selling a specific GoodZ card. */\n getShopsByBlueprint(input: CommerceGetShopsByBlueprintInput): Promise<any[]>;\n\n // Physical Redemption\n /** Request physical redemption for a purchased item. */\n redeemPhysical(input: CommerceRedeemPhysicalInput): Promise<any>;\n\n // Webhooks\n /** Register a webhook URL to receive shop event notifications. */\n registerWebhook(input: CommerceRegisterWebhookInput): Promise<CommerceWebhook>;\n /** List all registered webhook endpoints. */\n listWebhooks(): Promise<CommerceWebhook[]>;\n /** Send a test ping to a webhook endpoint. */\n testWebhook(input: CommerceTestWebhookInput): Promise<any>;\n /** Delete a webhook endpoint. */\n deleteWebhook(input: CommerceDeleteWebhookInput): Promise<any>;\n\n // OAuth App Management\n /** Register a new OAuth application with Commerce scopes. */\n registerApp(input: CommerceRegisterAppInput): Promise<any>;\n /** Update an existing OAuth application. */\n updateApp(input: CommerceUpdateAppInput): Promise<any>;\n /** List all OAuth applications owned by the user. */\n listMyApps(input?: CommerceListMyAppsInput): Promise<any[]>;\n /** Generate an OAuth authorization URL. */\n getAuthUrl(input?: CommerceGetAuthUrlInput): Promise<{ url: string }>;\n\n /** Call a raw MCP tool by name. Escape hatch for tools not yet in the typed API. */\n rawTool<T = any>(toolName: string, args?: Record<string, any>): Promise<T>;\n}\n\n// ─── Factory ────────────────────────────────────────────────\n\nexport function createCommerceNamespace(transport: TransportConfig): CommerceNamespace {\n const tool = <I extends Record<string, any>, O>(name: string) =>\n (input?: I) => callMcpTool<I, O>(transport, name, input as I);\n\n return {\n // Shop\n createShop: tool<CommerceCreateShopInput, CommerceShop>(\"create_shop\"),\n getShopDashboard: tool<CommerceGetShopDashboardInput, CommerceShopDashboard>(\"get_shop_dashboard\"),\n\n // Product Assembly\n createBatch: tool<CommerceCreateBatchInput, CommerceBatch>(\"create_batch\"),\n createGachaPool: tool<CommerceCreateGachaPoolInput, CommerceGachaPool>(\"create_gacha_pool\"),\n\n // Campaign Lifecycle\n launchCampaign: tool<CommerceLaunchCampaignInput, CommerceCampaign>(\"launch_sales_campaign\"),\n activateCampaign: tool<CommerceActivateCampaignInput, CommerceCampaign>(\"activate_campaign\"),\n pauseCampaign: tool<CommercePauseCampaignInput, CommerceCampaign>(\"pause_campaign\"),\n endCampaign: tool<CommerceEndCampaignInput, CommerceCampaign>(\"end_campaign\"),\n updateCampaign: tool<CommerceUpdateCampaignInput, CommerceCampaign>(\"update_campaign\"),\n getCampaignInfo: tool<CommerceGetCampaignInfoInput, any>(\"get_campaign_info\"),\n getCampaignItems: tool<CommerceGetCampaignItemsInput, CommerceCampaignItem[]>(\"get_campaign_items\"),\n\n // Purchase\n executePurchase: tool<CommerceExecutePurchaseInput, CommerceDrawResult>(\"execute_purchase\"),\n getMyOrders: tool<CommerceGetMyOrdersInput, CommerceOrder[]>(\"get_my_orders\"),\n\n // Wholesale\n publishToWholesale: tool<CommercePublishToWholesaleInput, any>(\"publish_to_wholesale\"),\n browseWholesale: tool<CommerceBrowseWholesaleInput, CommerceWholesaleListing[]>(\"browse_wholesale\"),\n procureBatch: tool<CommerceProcureBatchInput, any>(\"procure_batch\"),\n\n // Inventory\n manageInventory: tool<CommerceManageInventoryInput, any>(\"manage_inventory\"),\n registerInstances: tool<CommerceRegisterInstancesInput, any>(\"register_instances\"),\n mintToInventory: tool<CommerceMintToInventoryInput, any>(\"mint_to_inventory\"),\n\n // Settlement\n getSettlementReport: tool<CommerceGetSettlementReportInput, any>(\"get_settlement_report\"),\n\n // Discovery\n searchMarketplace: tool<CommerceSearchMarketplaceInput, any[]>(\"search_marketplace\"),\n getShopsByBlueprint: tool<CommerceGetShopsByBlueprintInput, any[]>(\"get_shops_by_blueprint\"),\n\n // Physical Redemption\n redeemPhysical: tool<CommerceRedeemPhysicalInput, any>(\"redeem_physical_goodz\"),\n\n // Webhooks\n registerWebhook: tool<CommerceRegisterWebhookInput, CommerceWebhook>(\"register_webhook\"),\n listWebhooks: tool<Record<string, never>, CommerceWebhook[]>(\"list_webhooks\"),\n testWebhook: tool<CommerceTestWebhookInput, any>(\"test_webhook\"),\n deleteWebhook: tool<CommerceDeleteWebhookInput, any>(\"delete_webhook\"),\n\n // OAuth App\n registerApp: tool<CommerceRegisterAppInput, any>(\"register_app\"),\n updateApp: tool<CommerceUpdateAppInput, any>(\"update_app\"),\n listMyApps: tool<CommerceListMyAppsInput, any[]>(\"list_my_apps\"),\n getAuthUrl: tool<CommerceGetAuthUrlInput, { url: string }>(\"get_auth_url\"),\n\n // Raw escape hatch\n rawTool: <T = any>(toolName: string, args?: Record<string, any>) =>\n callMcpTool<Record<string, any>, T>(transport, toolName, args),\n };\n}\n"]}