@goodz-core/sdk 0.1.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.
@@ -0,0 +1,591 @@
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
+
373
+ /**
374
+ * @goodz-core/sdk/core — Type-safe API client for GoodZ.Core
375
+ *
376
+ * Zero tRPC dependency — speaks the tRPC HTTP wire protocol directly
377
+ * using fetch + superjson. All types are hand-crafted and self-contained.
378
+ *
379
+ * @example
380
+ * ```ts
381
+ * import { createGoodZClient } from "@goodz-core/sdk/core";
382
+ *
383
+ * const goodz = createGoodZClient({
384
+ * coreUrl: "https://goodzcore.manus.space",
385
+ * accessToken: "your-jwt-token",
386
+ * });
387
+ *
388
+ * // Fully typed — IDE autocomplete for all inputs and outputs
389
+ * const balance = await goodz.zcoin.getMyBalance();
390
+ * const result = await goodz.zcoin.commercialTransfer({ ... });
391
+ * const instance = await goodz.collectible.getInstanceById({ instanceId: 90447 });
392
+ * ```
393
+ *
394
+ * @module
395
+ */
396
+
397
+ interface GoodZClientConfig {
398
+ /**
399
+ * GoodZ.Core base URL.
400
+ * @default "https://goodzcore.manus.space"
401
+ */
402
+ coreUrl?: string;
403
+ /**
404
+ * Static access token (JWT) for authentication.
405
+ * For server-to-server calls, obtain this via OAuth client_credentials flow.
406
+ * For user-context calls, pass the user's access token.
407
+ */
408
+ accessToken?: string;
409
+ /**
410
+ * Dynamic token provider — called before every request.
411
+ * Use this when tokens may rotate (e.g., auto-refresh).
412
+ * Takes precedence over `accessToken` if both are set.
413
+ */
414
+ getAccessToken?: () => string | Promise<string>;
415
+ /**
416
+ * Custom headers to include in every request.
417
+ * Useful for passing app identifiers or tracing headers.
418
+ */
419
+ headers?: Record<string, string>;
420
+ }
421
+ interface ZcoinNamespace {
422
+ /** Get the authenticated user's Z-coin balance. */
423
+ getMyBalance(): Promise<ZcoinGetMyBalanceOutput>;
424
+ /** Get the authenticated user's Z-coin transaction history. */
425
+ getMyHistory(input?: ZcoinGetMyHistoryInput): Promise<any[]>;
426
+ /** Get available Z-coin deposit packages with pricing. */
427
+ getDepositPackages(input?: ZcoinGetDepositPackagesInput): Promise<ZcoinDepositPackage[]>;
428
+ /** Create a Stripe checkout session for Z-coin deposit. */
429
+ createDepositOrder(input: ZcoinCreateDepositOrderInput): Promise<ZcoinCreateDepositOrderOutput>;
430
+ /** Check the status of a deposit checkout session. */
431
+ getDepositStatus(input: ZcoinGetDepositStatusInput): Promise<ZcoinGetDepositStatusOutput>;
432
+ /**
433
+ * Atomic commercial transfer: Z-coin payment + ownership transfer in one transaction.
434
+ * This is the primary API for Commerce and Exchange purchase flows.
435
+ *
436
+ * Idempotent via referenceId — duplicate calls return the same result.
437
+ *
438
+ * @throws {GoodZApiError} BAD_REQUEST — insufficient balance
439
+ * @throws {GoodZApiError} CONFLICT — version conflict (retry)
440
+ * @throws {GoodZApiError} FORBIDDEN — seller doesn't own instance
441
+ */
442
+ commercialTransfer(input: ZcoinCommercialTransferInput): Promise<ZcoinCommercialTransferOutput>;
443
+ /**
444
+ * Mint a new card instance and charge the buyer in one atomic transaction.
445
+ * Used by Commerce for gacha and direct-from-creator purchases.
446
+ *
447
+ * Requires mint authorization (granted via inventory.grantMintAuth).
448
+ * Idempotent via referenceId.
449
+ *
450
+ * @throws {GoodZApiError} FORBIDDEN — no mint authorization
451
+ * @throws {GoodZApiError} BAD_REQUEST — insufficient balance
452
+ */
453
+ mintAndCharge(input: ZcoinMintAndChargeInput): Promise<ZcoinMintAndChargeOutput>;
454
+ /**
455
+ * Charge a user's Z-coin balance for an in-app purchase.
456
+ * Used by apps that sell non-GoodZ digital goods/services.
457
+ *
458
+ * Idempotent via appOrderId.
459
+ *
460
+ * @throws {GoodZApiError} BAD_REQUEST — insufficient balance
461
+ * @throws {GoodZApiError} CONFLICT — version conflict
462
+ */
463
+ chargeUser(input: ZcoinChargeUserInput): Promise<ZcoinChargeUserOutput>;
464
+ /**
465
+ * Create a direct purchase checkout session (fiat → Z-coin → transfer).
466
+ * Transparent intermediation: user sees fiat price, Core handles conversion.
467
+ */
468
+ createDirectPurchaseOrder(input: ZcoinCreateDirectPurchaseOrderInput): Promise<ZcoinCreateDirectPurchaseOrderOutput>;
469
+ }
470
+ interface InventoryNamespace {
471
+ /** Get a user's inventory (owned card instances). */
472
+ getUserInventory(input: InventoryGetUserInventoryInput): Promise<any[]>;
473
+ /** Check if a user owns at least one instance of a specific card. */
474
+ confirmOwnership(input: InventoryConfirmOwnershipInput): Promise<InventoryConfirmOwnershipOutput>;
475
+ /**
476
+ * Mint new card instances. Requires franchise ownership or admin role.
477
+ * For Commerce/Exchange, use zcoin.mintAndCharge instead (includes payment).
478
+ */
479
+ mint(input: InventoryMintInput): Promise<InventoryMintOutput>;
480
+ /**
481
+ * Transfer a specific card instance to another user.
482
+ * For commercial transfers, use zcoin.commercialTransfer instead.
483
+ *
484
+ * @deprecated for reason="purchase"|"trade" — use commercialTransfer
485
+ */
486
+ transfer(input: InventoryTransferInput): Promise<InventoryTransferOutput>;
487
+ /**
488
+ * Transfer card instances by cardId (transfers oldest instances).
489
+ * For commercial transfers, use zcoin.commercialTransfer instead.
490
+ *
491
+ * @deprecated for reason="purchase"|"trade" — use commercialTransfer
492
+ */
493
+ transferByCard(input: InventoryTransferByCardInput): Promise<InventoryTransferByCardOutput>;
494
+ /**
495
+ * Grant mint authorization to another user/app for a specific card.
496
+ * Required before Commerce can call zcoin.mintAndCharge for that card.
497
+ */
498
+ grantMintAuth(input: InventoryGrantMintAuthInput): Promise<any>;
499
+ /** Get transfer/ownership history for an instance, card, or user. */
500
+ transferHistory(input: InventoryTransferHistoryInput): Promise<any[]>;
501
+ }
502
+ interface CollectibleNamespace {
503
+ /** Get a card instance by its numeric ID. Returns full instance data with card chain. */
504
+ getInstanceById(input: CollectibleGetInstanceByIdInput): Promise<any>;
505
+ /** Get a card instance by its instance code (public-facing identifier). */
506
+ getPublicInstance(input: CollectibleGetPublicInstanceInput): Promise<any>;
507
+ /** Batch-fetch multiple card instances by their IDs (max 100). */
508
+ getPublicInstancesBatch(input: CollectibleGetPublicInstancesBatchInput): Promise<any[]>;
509
+ /** Get the card profile (metadata, rarity, series info). */
510
+ getCardProfile(input: CollectibleGetCardProfileInput): Promise<any>;
511
+ /** Get the shell (packaging) image URL for a card. */
512
+ getShellImageUrl(input: CollectibleGetShellImageUrlInput): Promise<any>;
513
+ }
514
+ interface UserNamespace {
515
+ /** Get a user's public profile by openId. */
516
+ getPublicProfile(input: UserGetPublicProfileInput): Promise<UserPublicProfile>;
517
+ /** Get a user's public profile by internal userId. */
518
+ getPublicProfileById(input: UserGetPublicProfileByIdInput): Promise<UserPublicProfile>;
519
+ }
520
+ interface AuthNamespace {
521
+ /** Get the authenticated user's profile. Returns null if not authenticated. */
522
+ me(): Promise<AuthUser | null>;
523
+ /** Get public info about an OAuth app by its client ID. */
524
+ getOAuthAppInfo(input: AuthGetOAuthAppInfoInput): Promise<AuthOAuthAppInfo | null>;
525
+ }
526
+ interface IpNamespace {
527
+ /** Get a franchise by ID or slug. */
528
+ getFranchise(input: FranchiseGetInput): Promise<any>;
529
+ /** Get a series by ID or slug. */
530
+ getSeries(input: SeriesGetInput): Promise<any>;
531
+ /** List all series in a franchise. */
532
+ listSeriesByFranchise(input: SeriesListByFranchiseInput): Promise<any[]>;
533
+ /** Get a card by ID. */
534
+ getCard(input: CardGetInput): Promise<any>;
535
+ /** List all cards in a series. */
536
+ listCardsBySeries(input: CardListBySeriesInput): Promise<any[]>;
537
+ }
538
+ interface GoodZClient {
539
+ readonly zcoin: ZcoinNamespace;
540
+ readonly inventory: InventoryNamespace;
541
+ readonly collectible: CollectibleNamespace;
542
+ readonly user: UserNamespace;
543
+ readonly auth: AuthNamespace;
544
+ readonly ip: IpNamespace;
545
+ /**
546
+ * Make a raw tRPC query call. Use this for routes not yet covered
547
+ * by the typed namespaces.
548
+ */
549
+ rawQuery<T = any>(path: string, input?: any): Promise<T>;
550
+ /**
551
+ * Make a raw tRPC mutation call. Use this for routes not yet covered
552
+ * by the typed namespaces.
553
+ */
554
+ rawMutation<T = any>(path: string, input?: any): Promise<T>;
555
+ }
556
+ /**
557
+ * Create a type-safe GoodZ.Core API client.
558
+ *
559
+ * @example Server-to-server with static token
560
+ * ```ts
561
+ * const goodz = createGoodZClient({
562
+ * accessToken: process.env.CORE_ACCESS_TOKEN,
563
+ * });
564
+ * ```
565
+ *
566
+ * @example With dynamic token provider (auto-refresh)
567
+ * ```ts
568
+ * const goodz = createGoodZClient({
569
+ * getAccessToken: async () => {
570
+ * const token = await refreshTokenIfNeeded();
571
+ * return token;
572
+ * },
573
+ * });
574
+ * ```
575
+ *
576
+ * @example Acting on behalf of a user
577
+ * ```ts
578
+ * const userGoodz = createGoodZClient({
579
+ * accessToken: userAccessToken,
580
+ * });
581
+ * const balance = await userGoodz.zcoin.getMyBalance();
582
+ * ```
583
+ */
584
+ declare function createGoodZClient(config?: GoodZClientConfig): GoodZClient;
585
+ /**
586
+ * Alias for createGoodZClient — creates a client acting on behalf of a user.
587
+ * Semantically identical, but makes the intent clearer in server-to-server code.
588
+ */
589
+ declare const createUserClient: typeof createGoodZClient;
590
+
591
+ export { type AuthGetOAuthAppInfoInput, type AuthNamespace, type AuthOAuthAppInfo, type AuthUser, type CardGetInput, type CardListBySeriesInput, type CollectibleGetCardProfileInput, type CollectibleGetInstanceByIdInput, type CollectibleGetPublicInstanceInput, type CollectibleGetPublicInstancesBatchInput, type CollectibleGetShellImageUrlInput, type CollectibleNamespace, type FranchiseGetInput, GoodZApiError, type GoodZApiFieldError, type GoodZClient, type GoodZClientConfig, type GoodZErrorV2, type InventoryConfirmOwnershipInput, type InventoryConfirmOwnershipOutput, type InventoryGetUserInventoryInput, type InventoryGrantMintAuthInput, type InventoryMintInput, type InventoryMintOutput, type InventoryNamespace, type InventoryTransferByCardInput, type InventoryTransferByCardOutput, type InventoryTransferHistoryInput, type InventoryTransferInput, type InventoryTransferOutput, type IpNamespace, type PurchaseChannel, type SaleType, type SeriesGetInput, type SeriesListByFranchiseInput, type TransferReason, type UserGetPublicProfileByIdInput, type UserGetPublicProfileInput, type UserNamespace, type UserPublicProfile, type ZcoinChargeUserInput, type ZcoinChargeUserOutput, type ZcoinCommercialTransferInput, type ZcoinCommercialTransferOutput, type ZcoinCreateDepositOrderInput, type ZcoinCreateDepositOrderOutput, type ZcoinCreateDirectPurchaseOrderInput, type ZcoinCreateDirectPurchaseOrderOutput, type ZcoinDepositPackage, type ZcoinGetDepositPackagesInput, type ZcoinGetDepositStatusInput, type ZcoinGetDepositStatusOutput, type ZcoinGetMyBalanceOutput, type ZcoinGetMyHistoryInput, type ZcoinMintAndChargeInput, type ZcoinMintAndChargeOutput, type ZcoinNamespace, type ZcoinTxType, createGoodZClient, createUserClient };
@@ -0,0 +1,3 @@
1
+ export { GoodZApiError, createGoodZClient, createUserClient } from '../chunk-G7NKU6PT.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,21 @@
1
+ export { AuthGetOAuthAppInfoInput, AuthNamespace, AuthOAuthAppInfo, AuthUser, CardGetInput, CardListBySeriesInput, CollectibleGetCardProfileInput, CollectibleGetInstanceByIdInput, CollectibleGetPublicInstanceInput, CollectibleGetPublicInstancesBatchInput, CollectibleGetShellImageUrlInput, CollectibleNamespace, FranchiseGetInput, GoodZApiError, GoodZApiFieldError, GoodZClient, GoodZClientConfig, GoodZErrorV2, InventoryConfirmOwnershipInput, InventoryConfirmOwnershipOutput, InventoryGetUserInventoryInput, InventoryGrantMintAuthInput, InventoryMintInput, InventoryMintOutput, InventoryNamespace, InventoryTransferByCardInput, InventoryTransferByCardOutput, InventoryTransferHistoryInput, InventoryTransferInput, InventoryTransferOutput, IpNamespace, PurchaseChannel, SaleType, SeriesGetInput, SeriesListByFranchiseInput, TransferReason, UserGetPublicProfileByIdInput, UserGetPublicProfileInput, UserNamespace, UserPublicProfile, ZcoinChargeUserInput, ZcoinChargeUserOutput, ZcoinCommercialTransferInput, ZcoinCommercialTransferOutput, ZcoinCreateDepositOrderInput, ZcoinCreateDepositOrderOutput, ZcoinCreateDirectPurchaseOrderInput, ZcoinCreateDirectPurchaseOrderOutput, ZcoinDepositPackage, ZcoinGetDepositPackagesInput, ZcoinGetDepositStatusInput, ZcoinGetDepositStatusOutput, ZcoinGetMyBalanceOutput, ZcoinGetMyHistoryInput, ZcoinMintAndChargeInput, ZcoinMintAndChargeOutput, ZcoinNamespace, ZcoinTxType, createGoodZClient, createUserClient } from './core/index.js';
2
+ export { OAuthUrlConfig, TokenManager, TokenManagerConfig, TokenPair, buildAuthorizationUrl, exchangeCode } from './auth/index.js';
3
+ export { ZCOIN_PRECISION, formatZcoin, formatZcoinWithSymbol, toDisplay, toHundredths } from './zcoin-utils.js';
4
+
5
+ /**
6
+ * @goodz-core/sdk — Official SDK for GoodZ.Core
7
+ *
8
+ * This is the main entry point that re-exports all submodules.
9
+ * For tree-shaking, prefer importing from specific subpaths:
10
+ *
11
+ * ```ts
12
+ * import { createGoodZClient } from "@goodz-core/sdk/core";
13
+ * import { TokenManager } from "@goodz-core/sdk/auth";
14
+ * ```
15
+ *
16
+ * @module
17
+ */
18
+
19
+ declare const SDK_VERSION = "0.1.0";
20
+
21
+ export { SDK_VERSION };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { GoodZApiError, createGoodZClient, createUserClient } from './chunk-G7NKU6PT.js';
2
+ export { TokenManager, buildAuthorizationUrl, exchangeCode } from './chunk-EUKUN4JF.js';
3
+ export { ZCOIN_PRECISION, formatZcoin, formatZcoinWithSymbol, toDisplay, toHundredths } from './chunk-2ZETOE2X.js';
4
+
5
+ // src/index.ts
6
+ var SDK_VERSION = "0.1.0";
7
+
8
+ export { SDK_VERSION };
9
+ //# sourceMappingURL=index.js.map
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAoDO,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * @goodz-core/sdk — Official SDK for GoodZ.Core\n *\n * This is the main entry point that re-exports all submodules.\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 * ```\n *\n * @module\n */\n\n// Core client\nexport {\n createGoodZClient,\n createUserClient,\n GoodZApiError,\n type GoodZClient,\n type GoodZClientConfig,\n type ZcoinNamespace,\n type InventoryNamespace,\n type CollectibleNamespace,\n type UserNamespace,\n type AuthNamespace,\n type IpNamespace,\n} from \"./core/index\";\n\n// All API types\nexport type * from \"./types\";\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// SDK version\nexport const SDK_VERSION = \"0.1.0\";\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @goodz-core/sdk — Z-coin Precision Utilities
3
+ *
4
+ * GoodZ.Core stores Z-coin amounts in "hundredths" (1/100th of a Z-coin).
5
+ * For example, 10.50 Z-coin is stored as 1050 hundredths.
6
+ *
7
+ * These helpers convert between display values and hundredths to prevent
8
+ * the off-by-100x errors that plagued early Commerce integration.
9
+ *
10
+ * @module
11
+ */
12
+ /** Precision multiplier: 1 Z-coin = 100 hundredths */
13
+ declare const ZCOIN_PRECISION = 100;
14
+ /**
15
+ * Convert a display Z-coin amount to hundredths for API calls.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * toHundredths(10.50) // → 1050
20
+ * toHundredths(100) // → 10000
21
+ * toHundredths(0.01) // → 1
22
+ * ```
23
+ */
24
+ declare function toHundredths(displayAmount: number): number;
25
+ /**
26
+ * Convert hundredths to a display Z-coin amount.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * toDisplay(1050) // → 10.5
31
+ * toDisplay(10000) // → 100
32
+ * toDisplay(1) // → 0.01
33
+ * ```
34
+ */
35
+ declare function toDisplay(hundredths: number): number;
36
+ /**
37
+ * Format a hundredths value as a display string with 2 decimal places.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * formatZcoin(1050) // → "10.50"
42
+ * formatZcoin(10000) // → "100.00"
43
+ * formatZcoin(1) // → "0.01"
44
+ * ```
45
+ */
46
+ declare function formatZcoin(hundredths: number): string;
47
+ /**
48
+ * Format a hundredths value as a display string with the Z-coin symbol.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * formatZcoinWithSymbol(1050) // → "Z 10.50"
53
+ * formatZcoinWithSymbol(10000) // → "Z 100.00"
54
+ * ```
55
+ */
56
+ declare function formatZcoinWithSymbol(hundredths: number): string;
57
+
58
+ export { ZCOIN_PRECISION, formatZcoin, formatZcoinWithSymbol, toDisplay, toHundredths };