@spawnco/sdk-types 0.0.23 → 0.0.24
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/v1.ts +55 -33
package/dist/index.d.mts
CHANGED
@@ -219,7 +219,7 @@ interface LeaderboardEntry {
|
|
219
219
|
isMe?: boolean;
|
220
220
|
timestamp: number;
|
221
221
|
}
|
222
|
-
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'
|
223
|
-
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | '
|
222
|
+
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
|
223
|
+
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
|
224
224
|
|
225
225
|
export type { InventoryItem, Item, LeaderboardEntry, Room, RoomInfo, RoomVisibility, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, User };
|
package/dist/index.d.ts
CHANGED
@@ -219,7 +219,7 @@ interface LeaderboardEntry {
|
|
219
219
|
isMe?: boolean;
|
220
220
|
timestamp: number;
|
221
221
|
}
|
222
|
-
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'
|
223
|
-
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | '
|
222
|
+
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
|
223
|
+
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
|
224
224
|
|
225
225
|
export type { InventoryItem, Item, LeaderboardEntry, Room, RoomInfo, RoomVisibility, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, User };
|
package/package.json
CHANGED
package/src/v1.ts
CHANGED
@@ -118,46 +118,68 @@ export interface SpawnServerSDK__V1<TConfig = any> {
|
|
118
118
|
inventory: {
|
119
119
|
currencies: {
|
120
120
|
// Credit currency (creates if doesn't exist)
|
121
|
-
credit(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
credit(
|
122
|
+
userId: string,
|
123
|
+
currency: string,
|
124
|
+
amount: number,
|
125
|
+
options?: {
|
126
|
+
idempotencyKey?: string;
|
127
|
+
reason?: string;
|
128
|
+
}
|
129
|
+
): Promise<{ newBalance: number }>;
|
130
|
+
|
126
131
|
// Debit currency (returns false if insufficient)
|
127
|
-
debit(
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
+
debit(
|
133
|
+
userId: string,
|
134
|
+
currency: string,
|
135
|
+
amount: number,
|
136
|
+
options?: {
|
137
|
+
idempotencyKey?: string;
|
138
|
+
reason?: string;
|
139
|
+
}
|
140
|
+
): Promise<{ success: boolean; newBalance?: number }>;
|
141
|
+
|
132
142
|
// Atomic multi-currency exchange
|
133
|
-
exchange(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
143
|
+
exchange(
|
144
|
+
userId: string,
|
145
|
+
tx: {
|
146
|
+
debit: Record<string, number>;
|
147
|
+
credit: Record<string, number>;
|
148
|
+
},
|
149
|
+
options?: {
|
150
|
+
idempotencyKey?: string;
|
151
|
+
reason?: string;
|
152
|
+
}
|
153
|
+
): Promise<{ success: boolean; balances?: Record<string, number> }>;
|
154
|
+
|
141
155
|
// Get user's balances
|
142
156
|
get(userId: string): Promise<Record<string, number>>;
|
143
157
|
};
|
144
158
|
|
145
159
|
items: {
|
146
160
|
// Grant items to user (returns instance IDs)
|
147
|
-
grant(
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
161
|
+
grant(
|
162
|
+
userId: string,
|
163
|
+
items: Array<{
|
164
|
+
itemId: string;
|
165
|
+
data?: any;
|
166
|
+
}>,
|
167
|
+
options?: {
|
168
|
+
idempotencyKey?: string;
|
169
|
+
reason?: string;
|
170
|
+
}
|
171
|
+
): Promise<string[]>;
|
172
|
+
|
155
173
|
// Consume an item by instance ID
|
156
|
-
consume(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
174
|
+
consume(
|
175
|
+
userId: string,
|
176
|
+
instanceId: string,
|
177
|
+
options?: {
|
178
|
+
idempotencyKey?: string;
|
179
|
+
reason?: string;
|
180
|
+
}
|
181
|
+
): Promise<boolean>;
|
182
|
+
|
161
183
|
// Get user's inventory
|
162
184
|
list(userId: string): Promise<InventoryItem[]>;
|
163
185
|
};
|
@@ -256,5 +278,5 @@ export interface LeaderboardEntry {
|
|
256
278
|
|
257
279
|
// v0 sdk types for testing
|
258
280
|
|
259
|
-
export type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'
|
260
|
-
export type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | '
|
281
|
+
export type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
|
282
|
+
export type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
|