@spawnco/sdk-types 0.0.49 → 0.0.51

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 CHANGED
@@ -236,12 +236,51 @@ interface SpawnServerSDK__V1<TConfig = any> {
236
236
  * List all document names for this variant.
237
237
  */
238
238
  list(): Promise<string[]>;
239
+ /**
240
+ * Acquire a distributed lock on a key. Blocks until lock is acquired or timeout.
241
+ * Always use try/finally to ensure unlock() is called.
242
+ *
243
+ * @example
244
+ * await sdk.documents.lock("leaderboard");
245
+ * try {
246
+ * const data = await sdk.documents.get("leaderboard");
247
+ * // ... mutate data ...
248
+ * await sdk.documents.set("leaderboard", data);
249
+ * } finally {
250
+ * await sdk.documents.unlock("leaderboard");
251
+ * }
252
+ */
253
+ lock(key: string, options?: {
254
+ /** Auto-expire if worker crashes (default: 30000ms) */
255
+ ttlMs?: number;
256
+ /** Max time to wait for lock (default: 10000ms) */
257
+ waitMs?: number;
258
+ }): Promise<void>;
259
+ /**
260
+ * Release a distributed lock. Must be called after lock() in a finally block.
261
+ */
262
+ unlock(key: string): Promise<void>;
239
263
  };
240
264
  config: {
241
265
  get(): Promise<TConfig>;
242
266
  version(): Promise<string>;
243
267
  effectiveVersion(): Promise<string>;
244
268
  };
269
+ dew: {
270
+ /** Get today's plant claims for a user in this variant */
271
+ getClaimsToday(userId: string): Promise<{
272
+ claimedIds: ('A' | 'B' | 'C')[];
273
+ }>;
274
+ /** Claim a dew plant for a user. Returns random 10-20 dew amount. */
275
+ claim(userId: string, plantId: 'A' | 'B' | 'C'): Promise<{
276
+ success: boolean;
277
+ amount?: number;
278
+ new_balance?: number;
279
+ duplicate?: boolean;
280
+ claim_id?: string;
281
+ error?: string;
282
+ }>;
283
+ };
245
284
  economy: {
246
285
  redeemPurchase<T extends Record<string, any>>(token: string): Promise<{
247
286
  success: boolean;
package/dist/index.d.ts CHANGED
@@ -236,12 +236,51 @@ interface SpawnServerSDK__V1<TConfig = any> {
236
236
  * List all document names for this variant.
237
237
  */
238
238
  list(): Promise<string[]>;
239
+ /**
240
+ * Acquire a distributed lock on a key. Blocks until lock is acquired or timeout.
241
+ * Always use try/finally to ensure unlock() is called.
242
+ *
243
+ * @example
244
+ * await sdk.documents.lock("leaderboard");
245
+ * try {
246
+ * const data = await sdk.documents.get("leaderboard");
247
+ * // ... mutate data ...
248
+ * await sdk.documents.set("leaderboard", data);
249
+ * } finally {
250
+ * await sdk.documents.unlock("leaderboard");
251
+ * }
252
+ */
253
+ lock(key: string, options?: {
254
+ /** Auto-expire if worker crashes (default: 30000ms) */
255
+ ttlMs?: number;
256
+ /** Max time to wait for lock (default: 10000ms) */
257
+ waitMs?: number;
258
+ }): Promise<void>;
259
+ /**
260
+ * Release a distributed lock. Must be called after lock() in a finally block.
261
+ */
262
+ unlock(key: string): Promise<void>;
239
263
  };
240
264
  config: {
241
265
  get(): Promise<TConfig>;
242
266
  version(): Promise<string>;
243
267
  effectiveVersion(): Promise<string>;
244
268
  };
269
+ dew: {
270
+ /** Get today's plant claims for a user in this variant */
271
+ getClaimsToday(userId: string): Promise<{
272
+ claimedIds: ('A' | 'B' | 'C')[];
273
+ }>;
274
+ /** Claim a dew plant for a user. Returns random 10-20 dew amount. */
275
+ claim(userId: string, plantId: 'A' | 'B' | 'C'): Promise<{
276
+ success: boolean;
277
+ amount?: number;
278
+ new_balance?: number;
279
+ duplicate?: boolean;
280
+ claim_id?: string;
281
+ error?: string;
282
+ }>;
283
+ };
245
284
  economy: {
246
285
  redeemPurchase<T extends Record<string, any>>(token: string): Promise<{
247
286
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spawnco/sdk-types",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "TypeScript type definitions for Spawn SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/v1.ts CHANGED
@@ -260,6 +260,35 @@ export interface SpawnServerSDK__V1<TConfig = any> {
260
260
  * List all document names for this variant.
261
261
  */
262
262
  list(): Promise<string[]>;
263
+
264
+ /**
265
+ * Acquire a distributed lock on a key. Blocks until lock is acquired or timeout.
266
+ * Always use try/finally to ensure unlock() is called.
267
+ *
268
+ * @example
269
+ * await sdk.documents.lock("leaderboard");
270
+ * try {
271
+ * const data = await sdk.documents.get("leaderboard");
272
+ * // ... mutate data ...
273
+ * await sdk.documents.set("leaderboard", data);
274
+ * } finally {
275
+ * await sdk.documents.unlock("leaderboard");
276
+ * }
277
+ */
278
+ lock(
279
+ key: string,
280
+ options?: {
281
+ /** Auto-expire if worker crashes (default: 30000ms) */
282
+ ttlMs?: number;
283
+ /** Max time to wait for lock (default: 10000ms) */
284
+ waitMs?: number;
285
+ }
286
+ ): Promise<void>;
287
+
288
+ /**
289
+ * Release a distributed lock. Must be called after lock() in a finally block.
290
+ */
291
+ unlock(key: string): Promise<void>;
263
292
  };
264
293
 
265
294
  config: {
@@ -268,6 +297,24 @@ export interface SpawnServerSDK__V1<TConfig = any> {
268
297
  effectiveVersion(): Promise<string>;
269
298
  };
270
299
 
300
+ dew: {
301
+ /** Get today's plant claims for a user in this variant */
302
+ getClaimsToday(userId: string): Promise<{ claimedIds: ('A' | 'B' | 'C')[] }>;
303
+
304
+ /** Claim a dew plant for a user. Returns random 10-20 dew amount. */
305
+ claim(
306
+ userId: string,
307
+ plantId: 'A' | 'B' | 'C'
308
+ ): Promise<{
309
+ success: boolean;
310
+ amount?: number;
311
+ new_balance?: number;
312
+ duplicate?: boolean;
313
+ claim_id?: string;
314
+ error?: string;
315
+ }>;
316
+ };
317
+
271
318
  economy: {
272
319
  // Redeem a purchase token from client
273
320
  redeemPurchase<T extends Record<string, any>>(