@goodz-core/sdk 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +350 -0
- package/dist/alive/index.d.ts +175 -0
- package/dist/alive/index.js +4 -0
- package/dist/alive/index.js.map +1 -0
- package/dist/chunk-4SU7SU7K.js +227 -0
- package/dist/chunk-4SU7SU7K.js.map +1 -0
- package/dist/chunk-7O6UN2D2.js +102 -0
- package/dist/chunk-7O6UN2D2.js.map +1 -0
- package/dist/chunk-JAVMQXJM.js +27 -0
- package/dist/chunk-JAVMQXJM.js.map +1 -0
- package/dist/chunk-K6IFJWLB.js +924 -0
- package/dist/chunk-K6IFJWLB.js.map +1 -0
- package/dist/chunk-MUZDYQ67.js +56 -0
- package/dist/chunk-MUZDYQ67.js.map +1 -0
- package/dist/chunk-OUKZ2PRD.js +37 -0
- package/dist/chunk-OUKZ2PRD.js.map +1 -0
- package/dist/commerce/index.d.ts +407 -0
- package/dist/commerce/index.js +4 -0
- package/dist/commerce/index.js.map +1 -0
- package/dist/core/index.d.ts +76 -385
- package/dist/core/index.js +5 -1
- package/dist/exchange/index.d.ts +252 -0
- package/dist/exchange/index.js +4 -0
- package/dist/exchange/index.js.map +1 -0
- package/dist/index.d.ts +34 -4
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/transport-BOlScYEv.d.ts +377 -0
- package/dist/ui/index.d.ts +56 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +43 -3
- package/dist/chunk-G7NKU6PT.js +0 -183
- package/dist/chunk-G7NKU6PT.js.map +0 -1
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @goodz-core/sdk — Public API Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Hand-crafted types mirroring GoodZ.Core's tRPC API surface.
|
|
5
|
+
* These are the source of truth for SDK consumers — they define
|
|
6
|
+
* the contract between apps and Core.
|
|
7
|
+
*
|
|
8
|
+
* Naming convention:
|
|
9
|
+
* Input types: {Namespace}{Method}Input
|
|
10
|
+
* Output types: {Namespace}{Method}Output
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
type SaleType = "direct" | "wholesale" | "retail_resale" | "gacha" | "trade";
|
|
15
|
+
type TransferReason = "purchase" | "gift" | "trade" | "admin_transfer";
|
|
16
|
+
type PurchaseChannel = "web" | "ios" | "android";
|
|
17
|
+
type ZcoinTxType = "DEPOSIT" | "PURCHASE" | "APP_PAYMENT" | "DIRECT_PURCHASE" | "REFUND" | "ADJUSTMENT" | "EXPIRY";
|
|
18
|
+
interface ZcoinGetMyBalanceOutput {
|
|
19
|
+
balance: number;
|
|
20
|
+
totalDeposited: number;
|
|
21
|
+
totalSpent: number;
|
|
22
|
+
version: number;
|
|
23
|
+
}
|
|
24
|
+
interface ZcoinGetMyHistoryInput {
|
|
25
|
+
limit?: number;
|
|
26
|
+
offset?: number;
|
|
27
|
+
txType?: ZcoinTxType;
|
|
28
|
+
}
|
|
29
|
+
interface ZcoinCommercialTransferInput {
|
|
30
|
+
/** ID of the card_instance to transfer */
|
|
31
|
+
instanceId: number;
|
|
32
|
+
/** Buyer's userId — will be debited Z-coin */
|
|
33
|
+
buyerUserId: number;
|
|
34
|
+
/** Seller's userId — must be current owner of the instance */
|
|
35
|
+
sellerUserId: number;
|
|
36
|
+
/** Transaction price in Z-coin hundredths (e.g. 1050 = 10.50 Z-coin) */
|
|
37
|
+
priceZcoin: number;
|
|
38
|
+
/** Type of sale — determines fee rules */
|
|
39
|
+
saleType: SaleType;
|
|
40
|
+
/** Idempotency key (e.g., Commerce order ID, Exchange trade ID) */
|
|
41
|
+
referenceId: string;
|
|
42
|
+
/** OAuth APP client ID of the calling application */
|
|
43
|
+
appClientId: string;
|
|
44
|
+
/** Human-readable description of the transaction */
|
|
45
|
+
description?: string;
|
|
46
|
+
/** Optional listing ID (for Exchange trades) */
|
|
47
|
+
listingId?: number;
|
|
48
|
+
}
|
|
49
|
+
interface ZcoinCommercialTransferOutput {
|
|
50
|
+
success: true;
|
|
51
|
+
tradeId: number;
|
|
52
|
+
zcoinTxId: number;
|
|
53
|
+
ownershipEventId: number;
|
|
54
|
+
platformFee: number;
|
|
55
|
+
sellerProceeds: number;
|
|
56
|
+
primarySaleFeeApplied: boolean;
|
|
57
|
+
primarySaleFeeMarked: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface ZcoinMintAndChargeInput {
|
|
60
|
+
/** The card to mint (probability result from Commerce) */
|
|
61
|
+
cardId: number;
|
|
62
|
+
/** The buyer's user ID (will be debited Z-coin and receive the new instance) */
|
|
63
|
+
buyerUserId: number;
|
|
64
|
+
/** Price per unit in Z-coin hundredths (e.g. 1050 = 10.50 Z-coin) */
|
|
65
|
+
priceZcoin: number;
|
|
66
|
+
/** Type of sale */
|
|
67
|
+
saleType?: "gacha" | "direct";
|
|
68
|
+
/** Idempotency key (e.g., Commerce order ID) */
|
|
69
|
+
referenceId: string;
|
|
70
|
+
/** OAuth APP client ID of the calling application */
|
|
71
|
+
appClientId: string;
|
|
72
|
+
/** Human-readable description */
|
|
73
|
+
description?: string;
|
|
74
|
+
/** Number of instances to mint (default 1, max 10 for batch gacha) */
|
|
75
|
+
quantity?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ZcoinMintAndChargeOutput {
|
|
78
|
+
success: boolean;
|
|
79
|
+
tradeId: number;
|
|
80
|
+
zcoinTxId: number;
|
|
81
|
+
platformFee: number;
|
|
82
|
+
sellerProceeds: number;
|
|
83
|
+
authorizationId: number;
|
|
84
|
+
remainingMints: number | null;
|
|
85
|
+
instances: Array<{
|
|
86
|
+
id: number;
|
|
87
|
+
instanceCode: string;
|
|
88
|
+
shortCode: string;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
interface ZcoinChargeUserInput {
|
|
92
|
+
/** Z-coin amount to charge (in hundredths, e.g. 1050 = 10.50 Z-coin) */
|
|
93
|
+
amount: number;
|
|
94
|
+
/** OAuth app client ID making the charge */
|
|
95
|
+
appClientId: string;
|
|
96
|
+
/** Unique order/reference ID from the APP (for idempotency) */
|
|
97
|
+
appOrderId: string;
|
|
98
|
+
/** Human-readable description of what the user is paying for */
|
|
99
|
+
description: string;
|
|
100
|
+
}
|
|
101
|
+
interface ZcoinChargeUserOutput {
|
|
102
|
+
success: boolean;
|
|
103
|
+
transactionId: number;
|
|
104
|
+
amountCharged: number;
|
|
105
|
+
platformFee: number;
|
|
106
|
+
developerProceeds: number;
|
|
107
|
+
balanceAfter: number;
|
|
108
|
+
referenceId: string;
|
|
109
|
+
}
|
|
110
|
+
interface ZcoinCreateDirectPurchaseOrderInput {
|
|
111
|
+
/** The card instance to purchase */
|
|
112
|
+
instanceId: number;
|
|
113
|
+
/** The seller's user ID */
|
|
114
|
+
sellerUserId: number;
|
|
115
|
+
/** Price in Z-coin hundredths (e.g. 5000 = 50.00 Z-coin) */
|
|
116
|
+
priceZcoin: number;
|
|
117
|
+
/** Type of sale */
|
|
118
|
+
saleType: SaleType;
|
|
119
|
+
/** OAuth APP client ID */
|
|
120
|
+
appClientId: string;
|
|
121
|
+
/** Idempotency key from the calling APP */
|
|
122
|
+
referenceId: string;
|
|
123
|
+
/** Human-readable description */
|
|
124
|
+
description?: string;
|
|
125
|
+
/** Purchase channel */
|
|
126
|
+
channel?: PurchaseChannel;
|
|
127
|
+
/** Frontend origin for redirect URLs */
|
|
128
|
+
origin: string;
|
|
129
|
+
/** Optional listing ID (for Exchange trades) */
|
|
130
|
+
listingId?: number;
|
|
131
|
+
}
|
|
132
|
+
interface ZcoinCreateDirectPurchaseOrderOutput {
|
|
133
|
+
sessionId: string;
|
|
134
|
+
checkoutUrl: string;
|
|
135
|
+
priceZcoin: number;
|
|
136
|
+
fiatAmountCents: number;
|
|
137
|
+
groupId: string;
|
|
138
|
+
channel: PurchaseChannel;
|
|
139
|
+
status: "pending_payment";
|
|
140
|
+
}
|
|
141
|
+
interface ZcoinGetDepositPackagesInput {
|
|
142
|
+
channel?: PurchaseChannel;
|
|
143
|
+
}
|
|
144
|
+
interface ZcoinDepositPackage {
|
|
145
|
+
id: string;
|
|
146
|
+
zcoinAmount: number;
|
|
147
|
+
zcoinHundredths: number;
|
|
148
|
+
label: string;
|
|
149
|
+
basePriceCents: number;
|
|
150
|
+
totalPriceCents: number;
|
|
151
|
+
channel: PurchaseChannel;
|
|
152
|
+
featured: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface ZcoinCreateDepositOrderInput {
|
|
155
|
+
/** Z-coin amount to purchase (display units, e.g. 100 or 100.50) */
|
|
156
|
+
amount: number;
|
|
157
|
+
/** Purchase channel */
|
|
158
|
+
channel?: PurchaseChannel;
|
|
159
|
+
/** Frontend origin for redirect URLs */
|
|
160
|
+
origin: string;
|
|
161
|
+
}
|
|
162
|
+
interface ZcoinCreateDepositOrderOutput {
|
|
163
|
+
sessionId: string;
|
|
164
|
+
checkoutUrl: string;
|
|
165
|
+
zcoinAmount: number;
|
|
166
|
+
fiatAmountCents: number;
|
|
167
|
+
channel: PurchaseChannel;
|
|
168
|
+
status: "pending_payment";
|
|
169
|
+
}
|
|
170
|
+
interface ZcoinGetDepositStatusInput {
|
|
171
|
+
sessionId: string;
|
|
172
|
+
}
|
|
173
|
+
interface ZcoinGetDepositStatusOutput {
|
|
174
|
+
sessionId: string;
|
|
175
|
+
paymentStatus: string;
|
|
176
|
+
status: string;
|
|
177
|
+
zcoinAmount: number;
|
|
178
|
+
amountTotal: number | null;
|
|
179
|
+
currency: string | null;
|
|
180
|
+
}
|
|
181
|
+
interface InventoryGetUserInventoryInput {
|
|
182
|
+
userId?: number;
|
|
183
|
+
openId?: string;
|
|
184
|
+
seriesId?: number;
|
|
185
|
+
limit?: number;
|
|
186
|
+
offset?: number;
|
|
187
|
+
}
|
|
188
|
+
interface InventoryConfirmOwnershipInput {
|
|
189
|
+
userId: number;
|
|
190
|
+
cardId: number;
|
|
191
|
+
}
|
|
192
|
+
interface InventoryConfirmOwnershipOutput {
|
|
193
|
+
owns: boolean;
|
|
194
|
+
count: number;
|
|
195
|
+
}
|
|
196
|
+
interface InventoryMintInput {
|
|
197
|
+
cardId: number;
|
|
198
|
+
toUserId: number;
|
|
199
|
+
quantity?: number;
|
|
200
|
+
referenceId?: string;
|
|
201
|
+
}
|
|
202
|
+
interface InventoryMintOutput {
|
|
203
|
+
success: boolean;
|
|
204
|
+
cardId: number;
|
|
205
|
+
toUserId: number;
|
|
206
|
+
quantity: number;
|
|
207
|
+
instances: Array<{
|
|
208
|
+
id: number;
|
|
209
|
+
instanceCode: string;
|
|
210
|
+
shortCode: string;
|
|
211
|
+
}>;
|
|
212
|
+
}
|
|
213
|
+
interface InventoryTransferInput {
|
|
214
|
+
instanceId: number;
|
|
215
|
+
toUserId: number;
|
|
216
|
+
reason?: TransferReason;
|
|
217
|
+
referenceId?: string;
|
|
218
|
+
expectedVersion?: number;
|
|
219
|
+
}
|
|
220
|
+
interface InventoryTransferOutput {
|
|
221
|
+
success: true;
|
|
222
|
+
idempotent: boolean;
|
|
223
|
+
instanceId: number;
|
|
224
|
+
fromUserId: number | null;
|
|
225
|
+
toUserId: number;
|
|
226
|
+
reason: string;
|
|
227
|
+
eventId?: number;
|
|
228
|
+
_deprecation_warning?: string;
|
|
229
|
+
}
|
|
230
|
+
interface InventoryTransferByCardInput {
|
|
231
|
+
cardId: number;
|
|
232
|
+
toUserId: number;
|
|
233
|
+
quantity?: number;
|
|
234
|
+
reason?: TransferReason;
|
|
235
|
+
referenceId?: string;
|
|
236
|
+
}
|
|
237
|
+
interface InventoryTransferByCardOutput {
|
|
238
|
+
success: true;
|
|
239
|
+
idempotent: boolean;
|
|
240
|
+
cardId: number;
|
|
241
|
+
fromUserId: number | null;
|
|
242
|
+
toUserId: number;
|
|
243
|
+
quantity: number;
|
|
244
|
+
reason: string;
|
|
245
|
+
_deprecation_warning?: string;
|
|
246
|
+
}
|
|
247
|
+
interface InventoryGrantMintAuthInput {
|
|
248
|
+
cardId: number;
|
|
249
|
+
granteeUserId: number;
|
|
250
|
+
granteeAppClientId?: string;
|
|
251
|
+
maxMintCount?: number;
|
|
252
|
+
validUntilMs?: number;
|
|
253
|
+
}
|
|
254
|
+
interface InventoryTransferHistoryInput {
|
|
255
|
+
instanceId?: number;
|
|
256
|
+
cardId?: number;
|
|
257
|
+
userId?: number;
|
|
258
|
+
limit?: number;
|
|
259
|
+
offset?: number;
|
|
260
|
+
}
|
|
261
|
+
interface CollectibleGetInstanceByIdInput {
|
|
262
|
+
instanceId: number;
|
|
263
|
+
claimToken?: string;
|
|
264
|
+
}
|
|
265
|
+
interface CollectibleGetPublicInstanceInput {
|
|
266
|
+
instanceCode: string;
|
|
267
|
+
}
|
|
268
|
+
interface CollectibleGetPublicInstancesBatchInput {
|
|
269
|
+
instanceIds: number[];
|
|
270
|
+
}
|
|
271
|
+
interface CollectibleGetCardProfileInput {
|
|
272
|
+
cardId: number;
|
|
273
|
+
}
|
|
274
|
+
interface CollectibleGetShellImageUrlInput {
|
|
275
|
+
cardId: number;
|
|
276
|
+
}
|
|
277
|
+
interface UserGetPublicProfileInput {
|
|
278
|
+
openId: string;
|
|
279
|
+
}
|
|
280
|
+
interface UserPublicProfile {
|
|
281
|
+
openId: string;
|
|
282
|
+
name: string;
|
|
283
|
+
avatarUrl: string | null;
|
|
284
|
+
joinedAt: Date;
|
|
285
|
+
stats: {
|
|
286
|
+
totalOwned: number;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
interface UserGetPublicProfileByIdInput {
|
|
290
|
+
userId: number;
|
|
291
|
+
}
|
|
292
|
+
interface AuthGetOAuthAppInfoInput {
|
|
293
|
+
clientId: string;
|
|
294
|
+
}
|
|
295
|
+
interface AuthOAuthAppInfo {
|
|
296
|
+
appName: string;
|
|
297
|
+
iconUrl: string | null;
|
|
298
|
+
websiteUrl: string | null;
|
|
299
|
+
}
|
|
300
|
+
interface AuthUser {
|
|
301
|
+
id: number;
|
|
302
|
+
openId: string;
|
|
303
|
+
name: string;
|
|
304
|
+
email: string | null;
|
|
305
|
+
avatarUrl: string | null;
|
|
306
|
+
role: "admin" | "user";
|
|
307
|
+
}
|
|
308
|
+
interface FranchiseGetInput {
|
|
309
|
+
id?: number;
|
|
310
|
+
slug?: string;
|
|
311
|
+
}
|
|
312
|
+
interface SeriesGetInput {
|
|
313
|
+
id?: number;
|
|
314
|
+
slug?: string;
|
|
315
|
+
}
|
|
316
|
+
interface SeriesListByFranchiseInput {
|
|
317
|
+
franchiseId: number;
|
|
318
|
+
}
|
|
319
|
+
interface CardGetInput {
|
|
320
|
+
id: number;
|
|
321
|
+
}
|
|
322
|
+
interface CardListBySeriesInput {
|
|
323
|
+
seriesId: number;
|
|
324
|
+
}
|
|
325
|
+
interface GoodZApiFieldError {
|
|
326
|
+
path: (string | number)[];
|
|
327
|
+
message: string;
|
|
328
|
+
code: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Structured error from GoodZ.Core API.
|
|
332
|
+
* Includes tRPC error code, HTTP status, and optional Zod validation details.
|
|
333
|
+
*/
|
|
334
|
+
interface GoodZErrorV2 {
|
|
335
|
+
type: string;
|
|
336
|
+
code: string;
|
|
337
|
+
message: string;
|
|
338
|
+
httpStatus: number;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @goodz-core/sdk — HTTP Transport Layer
|
|
343
|
+
*
|
|
344
|
+
* Speaks the tRPC v11 HTTP wire protocol directly using fetch.
|
|
345
|
+
* Handles superjson serialization, batching, and error parsing.
|
|
346
|
+
*
|
|
347
|
+
* Wire format reference:
|
|
348
|
+
* - Queries: GET /api/trpc/{procedure}?input={superjson-encoded}
|
|
349
|
+
* - Mutations: POST /api/trpc/{procedure} body: {superjson-encoded}
|
|
350
|
+
* - Batch: GET /api/trpc/{p1},{p2}?input={0: ..., 1: ...}
|
|
351
|
+
*
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
declare class GoodZApiError extends Error {
|
|
356
|
+
readonly code: string;
|
|
357
|
+
readonly httpStatus: number;
|
|
358
|
+
readonly path: string;
|
|
359
|
+
readonly zodErrors?: GoodZApiFieldError[];
|
|
360
|
+
readonly data?: unknown;
|
|
361
|
+
constructor(opts: {
|
|
362
|
+
message: string;
|
|
363
|
+
code: string;
|
|
364
|
+
httpStatus: number;
|
|
365
|
+
path: string;
|
|
366
|
+
zodErrors?: GoodZApiFieldError[];
|
|
367
|
+
data?: unknown;
|
|
368
|
+
});
|
|
369
|
+
/** Human-readable summary including field errors if present. */
|
|
370
|
+
toDetailedString(): string;
|
|
371
|
+
}
|
|
372
|
+
interface TransportConfig {
|
|
373
|
+
baseUrl: string;
|
|
374
|
+
getHeaders: () => Record<string, string> | Promise<Record<string, string>>;
|
|
375
|
+
}
|
|
376
|
+
|
|
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 };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Form Factor Standards — self-contained within SDK.
|
|
6
|
+
* Mirrors GoodZ.Core's shared/formFactors.ts but with zero external dependencies.
|
|
7
|
+
*/
|
|
8
|
+
type FormFactorKey = "trading_card" | "postcard" | "postcard_portrait" | "polaroid" | "laser_ticket" | "badge_small" | "badge_medium" | "badge_large" | "acrylic_stand_tall" | "acrylic_stand_chibi";
|
|
9
|
+
interface FormFactorSpec {
|
|
10
|
+
key: FormFactorKey;
|
|
11
|
+
label: string;
|
|
12
|
+
aspectRatio: [number, number];
|
|
13
|
+
isCircle: boolean;
|
|
14
|
+
isTransparent?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const FORM_FACTORS: Record<FormFactorKey, FormFactorSpec>;
|
|
17
|
+
declare function getFormFactorSpec(key: string): FormFactorSpec | undefined;
|
|
18
|
+
declare function getAspectRatioCSS(key: string): string;
|
|
19
|
+
|
|
20
|
+
interface GoodZCardFocusProps {
|
|
21
|
+
/** Content to render as the clickable trigger (typically a card thumbnail) */
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
/** URL of the GoodZ image (original artwork or shell image) */
|
|
24
|
+
imageUrl?: string | null;
|
|
25
|
+
/** Display name of the GoodZ */
|
|
26
|
+
cardName?: string;
|
|
27
|
+
/** Rarity tier (e.g., "R", "SR", "SSR", "UR") — controls holographic intensity */
|
|
28
|
+
rarity?: string | null;
|
|
29
|
+
/** Form factor key — controls material effect and aspect ratio */
|
|
30
|
+
formFactor?: FormFactorKey | string;
|
|
31
|
+
/** Additional CSS class for the trigger wrapper */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Disable the focus modal (click-through) */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* GoodZCardFocus — wraps any content as a clickable trigger that opens
|
|
38
|
+
* a full-screen focus modal with holographic tilt effects.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { GoodZCardFocus } from "@goodz-core/sdk/ui";
|
|
43
|
+
*
|
|
44
|
+
* <GoodZCardFocus
|
|
45
|
+
* imageUrl="https://goodzcore.manus.space/api/shell/42.png"
|
|
46
|
+
* cardName="Luna"
|
|
47
|
+
* rarity="SSR"
|
|
48
|
+
* formFactor="trading_card"
|
|
49
|
+
* >
|
|
50
|
+
* <img src={thumbnailUrl} alt="Luna" />
|
|
51
|
+
* </GoodZCardFocus>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function GoodZCardFocus({ children, imageUrl, cardName, rarity, formFactor, className, disabled, }: GoodZCardFocusProps): react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
export { FORM_FACTORS, type FormFactorKey, type FormFactorSpec, GoodZCardFocus, type GoodZCardFocusProps, getAspectRatioCSS, getFormFactorSpec };
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodz-core/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official SDK for GoodZ
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -21,6 +21,22 @@
|
|
|
21
21
|
"./zcoin": {
|
|
22
22
|
"types": "./dist/zcoin-utils.d.ts",
|
|
23
23
|
"import": "./dist/zcoin-utils.js"
|
|
24
|
+
},
|
|
25
|
+
"./ui": {
|
|
26
|
+
"types": "./dist/ui/index.d.ts",
|
|
27
|
+
"import": "./dist/ui/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./commerce": {
|
|
30
|
+
"types": "./dist/commerce/index.d.ts",
|
|
31
|
+
"import": "./dist/commerce/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./exchange": {
|
|
34
|
+
"types": "./dist/exchange/index.d.ts",
|
|
35
|
+
"import": "./dist/exchange/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./alive": {
|
|
38
|
+
"types": "./dist/alive/index.d.ts",
|
|
39
|
+
"import": "./dist/alive/index.js"
|
|
24
40
|
}
|
|
25
41
|
},
|
|
26
42
|
"files": [
|
|
@@ -40,7 +56,15 @@
|
|
|
40
56
|
"digital-collectibles",
|
|
41
57
|
"oauth",
|
|
42
58
|
"api-client",
|
|
43
|
-
"zcoin"
|
|
59
|
+
"zcoin",
|
|
60
|
+
"react",
|
|
61
|
+
"card-display",
|
|
62
|
+
"holographic",
|
|
63
|
+
"commerce",
|
|
64
|
+
"exchange",
|
|
65
|
+
"marketplace",
|
|
66
|
+
"gacha",
|
|
67
|
+
"nft"
|
|
44
68
|
],
|
|
45
69
|
"author": "GoodZ Team",
|
|
46
70
|
"license": "MIT",
|
|
@@ -52,8 +76,24 @@
|
|
|
52
76
|
"dependencies": {
|
|
53
77
|
"superjson": "^1.13.0"
|
|
54
78
|
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"react": ">=18.0.0",
|
|
81
|
+
"react-dom": ">=18.0.0"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"react": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"react-dom": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
55
91
|
"devDependencies": {
|
|
56
92
|
"@types/node": "^22.0.0",
|
|
93
|
+
"@types/react": "^19.0.0",
|
|
94
|
+
"@types/react-dom": "^19.0.0",
|
|
95
|
+
"react": "^19.0.0",
|
|
96
|
+
"react-dom": "^19.0.0",
|
|
57
97
|
"tsup": "^8.0.0",
|
|
58
98
|
"typescript": "^5.5.0",
|
|
59
99
|
"vitest": "^1.0.0"
|
package/dist/chunk-G7NKU6PT.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import superjson from 'superjson';
|
|
2
|
-
|
|
3
|
-
// src/transport.ts
|
|
4
|
-
var GoodZApiError = class extends Error {
|
|
5
|
-
code;
|
|
6
|
-
httpStatus;
|
|
7
|
-
path;
|
|
8
|
-
zodErrors;
|
|
9
|
-
data;
|
|
10
|
-
constructor(opts) {
|
|
11
|
-
super(opts.message);
|
|
12
|
-
this.name = "GoodZApiError";
|
|
13
|
-
this.code = opts.code;
|
|
14
|
-
this.httpStatus = opts.httpStatus;
|
|
15
|
-
this.path = opts.path;
|
|
16
|
-
this.zodErrors = opts.zodErrors;
|
|
17
|
-
this.data = opts.data;
|
|
18
|
-
}
|
|
19
|
-
/** Human-readable summary including field errors if present. */
|
|
20
|
-
toDetailedString() {
|
|
21
|
-
const parts = [
|
|
22
|
-
`[GoodZApiError] ${this.code} on ${this.path}: ${this.message}`
|
|
23
|
-
];
|
|
24
|
-
if (this.zodErrors?.length) {
|
|
25
|
-
parts.push("Field errors:");
|
|
26
|
-
for (const e of this.zodErrors) {
|
|
27
|
-
parts.push(` - ${e.path.join(".")}: ${e.message} (${e.code})`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return parts.join("\n");
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
async function callQuery(config, path, input) {
|
|
34
|
-
const url = `${config.baseUrl}/api/trpc/${path}`;
|
|
35
|
-
const headers = await config.getHeaders();
|
|
36
|
-
const serialized = input !== void 0 ? superjson.serialize(input) : void 0;
|
|
37
|
-
const queryUrl = serialized ? `${url}?input=${encodeURIComponent(JSON.stringify(serialized))}` : url;
|
|
38
|
-
const res = await fetch(queryUrl, {
|
|
39
|
-
method: "GET",
|
|
40
|
-
headers: {
|
|
41
|
-
...headers,
|
|
42
|
-
"Content-Type": "application/json"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return parseResponse(res, path);
|
|
46
|
-
}
|
|
47
|
-
async function callMutation(config, path, input) {
|
|
48
|
-
const url = `${config.baseUrl}/api/trpc/${path}`;
|
|
49
|
-
const headers = await config.getHeaders();
|
|
50
|
-
const serialized = input !== void 0 ? superjson.serialize(input) : void 0;
|
|
51
|
-
const res = await fetch(url, {
|
|
52
|
-
method: "POST",
|
|
53
|
-
headers: {
|
|
54
|
-
...headers,
|
|
55
|
-
"Content-Type": "application/json"
|
|
56
|
-
},
|
|
57
|
-
body: serialized ? JSON.stringify(serialized) : void 0
|
|
58
|
-
});
|
|
59
|
-
return parseResponse(res, path);
|
|
60
|
-
}
|
|
61
|
-
async function parseResponse(res, path) {
|
|
62
|
-
const text = await res.text();
|
|
63
|
-
let body;
|
|
64
|
-
try {
|
|
65
|
-
body = JSON.parse(text);
|
|
66
|
-
} catch {
|
|
67
|
-
throw new GoodZApiError({
|
|
68
|
-
message: `Invalid JSON response: ${text.slice(0, 200)}`,
|
|
69
|
-
code: "PARSE_ERROR",
|
|
70
|
-
httpStatus: res.status,
|
|
71
|
-
path
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const envelope = Array.isArray(body) ? body[0] : body;
|
|
75
|
-
if (envelope?.error) {
|
|
76
|
-
const err = envelope.error;
|
|
77
|
-
const errJson = err?.json ?? err;
|
|
78
|
-
const errData = errJson?.data ?? {};
|
|
79
|
-
throw new GoodZApiError({
|
|
80
|
-
message: errJson?.message ?? "Unknown API error",
|
|
81
|
-
code: errData?.code ?? errJson?.code ?? "UNKNOWN",
|
|
82
|
-
httpStatus: errData?.httpStatus ?? res.status,
|
|
83
|
-
path: errData?.path ?? path,
|
|
84
|
-
zodErrors: errData?.zodError?.issues,
|
|
85
|
-
data: errData
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const resultData = envelope?.result?.data;
|
|
89
|
-
if (resultData === void 0) {
|
|
90
|
-
if (res.ok) return void 0;
|
|
91
|
-
throw new GoodZApiError({
|
|
92
|
-
message: `Unexpected response shape from ${path}`,
|
|
93
|
-
code: "UNEXPECTED_RESPONSE",
|
|
94
|
-
httpStatus: res.status,
|
|
95
|
-
path
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (resultData && typeof resultData === "object" && "json" in resultData) {
|
|
99
|
-
return superjson.deserialize(resultData);
|
|
100
|
-
}
|
|
101
|
-
return resultData;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/core/index.ts
|
|
105
|
-
function createGoodZClient(config = {}) {
|
|
106
|
-
const {
|
|
107
|
-
coreUrl = "https://goodzcore.manus.space",
|
|
108
|
-
accessToken,
|
|
109
|
-
getAccessToken,
|
|
110
|
-
headers: customHeaders
|
|
111
|
-
} = config;
|
|
112
|
-
const transport = {
|
|
113
|
-
baseUrl: coreUrl.replace(/\/$/, ""),
|
|
114
|
-
getHeaders: async () => {
|
|
115
|
-
const h = { ...customHeaders };
|
|
116
|
-
const token = getAccessToken ? await getAccessToken() : accessToken;
|
|
117
|
-
if (token) {
|
|
118
|
-
h["Authorization"] = `Bearer ${token}`;
|
|
119
|
-
}
|
|
120
|
-
return h;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const q = (path) => (input) => callQuery(transport, path, input);
|
|
124
|
-
const m = (path) => (input) => callMutation(transport, path, input);
|
|
125
|
-
return {
|
|
126
|
-
// ── zcoin ──────────────────────────────────────────────
|
|
127
|
-
zcoin: {
|
|
128
|
-
getMyBalance: q("zcoin.getMyBalance"),
|
|
129
|
-
getMyHistory: q("zcoin.getMyHistory"),
|
|
130
|
-
getDepositPackages: q("zcoin.getDepositPackages"),
|
|
131
|
-
createDepositOrder: m("zcoin.createDepositOrder"),
|
|
132
|
-
getDepositStatus: q("zcoin.getDepositStatus"),
|
|
133
|
-
commercialTransfer: m("zcoin.commercialTransfer"),
|
|
134
|
-
mintAndCharge: m("zcoin.mintAndCharge"),
|
|
135
|
-
chargeUser: m("zcoin.chargeUser"),
|
|
136
|
-
createDirectPurchaseOrder: m("zcoin.createDirectPurchaseOrder")
|
|
137
|
-
},
|
|
138
|
-
// ── inventory ──────────────────────────────────────────
|
|
139
|
-
inventory: {
|
|
140
|
-
getUserInventory: q("inventory.getUserInventory"),
|
|
141
|
-
confirmOwnership: q("inventory.confirmOwnership"),
|
|
142
|
-
mint: m("inventory.mint"),
|
|
143
|
-
transfer: m("inventory.transfer"),
|
|
144
|
-
transferByCard: m("inventory.transferByCard"),
|
|
145
|
-
grantMintAuth: m("inventory.grantMintAuth"),
|
|
146
|
-
transferHistory: q("inventory.transferHistory")
|
|
147
|
-
},
|
|
148
|
-
// ── collectible ────────────────────────────────────────
|
|
149
|
-
collectible: {
|
|
150
|
-
getInstanceById: q("collectible.getInstanceById"),
|
|
151
|
-
getPublicInstance: q("collectible.getPublicInstance"),
|
|
152
|
-
getPublicInstancesBatch: q("collectible.getPublicInstancesBatch"),
|
|
153
|
-
getCardProfile: q("collectible.getCardProfile"),
|
|
154
|
-
getShellImageUrl: q("collectible.getShellImageUrl")
|
|
155
|
-
},
|
|
156
|
-
// ── user ───────────────────────────────────────────────
|
|
157
|
-
user: {
|
|
158
|
-
getPublicProfile: q("user.getPublicProfile"),
|
|
159
|
-
getPublicProfileById: q("user.getPublicProfileById")
|
|
160
|
-
},
|
|
161
|
-
// ── auth ───────────────────────────────────────────────
|
|
162
|
-
auth: {
|
|
163
|
-
me: q("auth.me"),
|
|
164
|
-
getOAuthAppInfo: q("auth.getOAuthAppInfo")
|
|
165
|
-
},
|
|
166
|
-
// ── ip (franchise/series/card) ─────────────────────────
|
|
167
|
-
ip: {
|
|
168
|
-
getFranchise: q("franchise.get"),
|
|
169
|
-
getSeries: q("series.get"),
|
|
170
|
-
listSeriesByFranchise: q("series.listByFranchise"),
|
|
171
|
-
getCard: q("card.get"),
|
|
172
|
-
listCardsBySeries: q("card.listBySeries")
|
|
173
|
-
},
|
|
174
|
-
// ── raw escape hatches ─────────────────────────────────
|
|
175
|
-
rawQuery: (path, input) => callQuery(transport, path, input),
|
|
176
|
-
rawMutation: (path, input) => callMutation(transport, path, input)
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
var createUserClient = createGoodZClient;
|
|
180
|
-
|
|
181
|
-
export { GoodZApiError, createGoodZClient, createUserClient };
|
|
182
|
-
//# sourceMappingURL=chunk-G7NKU6PT.js.map
|
|
183
|
-
//# sourceMappingURL=chunk-G7NKU6PT.js.map
|