@seaverse/dataservice 1.8.3 → 1.8.4
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 +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +16 -1
- package/dist/index.mjs +15 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -302,6 +302,53 @@ declare function debugSetToken(token: string): void;
|
|
|
302
302
|
* ```
|
|
303
303
|
*/
|
|
304
304
|
declare function setAppId(appId: string): void;
|
|
305
|
+
/**
|
|
306
|
+
* Create a new Data Service client
|
|
307
|
+
*
|
|
308
|
+
* The SDK automatically obtains the service host from the parent page via PostMessage (500ms timeout).
|
|
309
|
+
* If the fetch fails, it falls back to the default host: https://dataservice-api.seaverse.ai
|
|
310
|
+
*
|
|
311
|
+
* AI-friendly: Single entry point with clear configuration
|
|
312
|
+
*
|
|
313
|
+
* @param config - Client configuration (optional)
|
|
314
|
+
* @returns DataServiceClient instance
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* // Auto-fetch token and serviceHost from parent page (iframe)
|
|
319
|
+
* // ServiceHost fetch: 500ms timeout, falls back to https://dataservice-api.seaverse.ai
|
|
320
|
+
* const client = await createClient({});
|
|
321
|
+
*
|
|
322
|
+
* // For development/testing, use debugSetToken
|
|
323
|
+
* import { debugSetToken, createClient } from '@seaverse/dataservice';
|
|
324
|
+
* debugSetToken('your-test-token');
|
|
325
|
+
* const client = await createClient({});
|
|
326
|
+
*
|
|
327
|
+
* // appId is automatically extracted from current URL
|
|
328
|
+
* const order = await client.userData.collection('orders').insert({ ... });
|
|
329
|
+
* const orders = await client.userData.collection('orders').select().execute();
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
/**
|
|
333
|
+
* Notify the parent (SeaVerse App or iframe) of the current game score.
|
|
334
|
+
*
|
|
335
|
+
* Fire-and-forget — no response is expected.
|
|
336
|
+
*
|
|
337
|
+
* Protocol:
|
|
338
|
+
* - RN WebView: window.ReactNativeWebView.postMessage({ type: 'seaverse:game_score', score: number })
|
|
339
|
+
* - iframe: window.parent.postMessage({ type: 'seaverse:game_score', score: number }, '*')
|
|
340
|
+
*
|
|
341
|
+
* @param score Current game score (must be a non-negative number)
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* import { notifyGameScore } from '@seaverse/dataservice';
|
|
346
|
+
*
|
|
347
|
+
* // Call whenever the score updates
|
|
348
|
+
* notifyGameScore(1234);
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function notifyGameScore(score: number): void;
|
|
305
352
|
declare function createClient(config?: ClientConfig): Promise<DataServiceClient>;
|
|
306
353
|
|
|
307
354
|
/**
|
|
@@ -350,6 +397,6 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
350
397
|
* ```
|
|
351
398
|
*/
|
|
352
399
|
|
|
353
|
-
declare const VERSION = "1.8.
|
|
400
|
+
declare const VERSION = "1.8.4";
|
|
354
401
|
|
|
355
|
-
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, setAppId };
|
|
402
|
+
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, notifyGameScore, setAppId };
|
package/dist/index.d.ts
CHANGED
|
@@ -302,6 +302,53 @@ declare function debugSetToken(token: string): void;
|
|
|
302
302
|
* ```
|
|
303
303
|
*/
|
|
304
304
|
declare function setAppId(appId: string): void;
|
|
305
|
+
/**
|
|
306
|
+
* Create a new Data Service client
|
|
307
|
+
*
|
|
308
|
+
* The SDK automatically obtains the service host from the parent page via PostMessage (500ms timeout).
|
|
309
|
+
* If the fetch fails, it falls back to the default host: https://dataservice-api.seaverse.ai
|
|
310
|
+
*
|
|
311
|
+
* AI-friendly: Single entry point with clear configuration
|
|
312
|
+
*
|
|
313
|
+
* @param config - Client configuration (optional)
|
|
314
|
+
* @returns DataServiceClient instance
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* // Auto-fetch token and serviceHost from parent page (iframe)
|
|
319
|
+
* // ServiceHost fetch: 500ms timeout, falls back to https://dataservice-api.seaverse.ai
|
|
320
|
+
* const client = await createClient({});
|
|
321
|
+
*
|
|
322
|
+
* // For development/testing, use debugSetToken
|
|
323
|
+
* import { debugSetToken, createClient } from '@seaverse/dataservice';
|
|
324
|
+
* debugSetToken('your-test-token');
|
|
325
|
+
* const client = await createClient({});
|
|
326
|
+
*
|
|
327
|
+
* // appId is automatically extracted from current URL
|
|
328
|
+
* const order = await client.userData.collection('orders').insert({ ... });
|
|
329
|
+
* const orders = await client.userData.collection('orders').select().execute();
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
/**
|
|
333
|
+
* Notify the parent (SeaVerse App or iframe) of the current game score.
|
|
334
|
+
*
|
|
335
|
+
* Fire-and-forget — no response is expected.
|
|
336
|
+
*
|
|
337
|
+
* Protocol:
|
|
338
|
+
* - RN WebView: window.ReactNativeWebView.postMessage({ type: 'seaverse:game_score', score: number })
|
|
339
|
+
* - iframe: window.parent.postMessage({ type: 'seaverse:game_score', score: number }, '*')
|
|
340
|
+
*
|
|
341
|
+
* @param score Current game score (must be a non-negative number)
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* import { notifyGameScore } from '@seaverse/dataservice';
|
|
346
|
+
*
|
|
347
|
+
* // Call whenever the score updates
|
|
348
|
+
* notifyGameScore(1234);
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function notifyGameScore(score: number): void;
|
|
305
352
|
declare function createClient(config?: ClientConfig): Promise<DataServiceClient>;
|
|
306
353
|
|
|
307
354
|
/**
|
|
@@ -350,6 +397,6 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
350
397
|
* ```
|
|
351
398
|
*/
|
|
352
399
|
|
|
353
|
-
declare const VERSION = "1.8.
|
|
400
|
+
declare const VERSION = "1.8.4";
|
|
354
401
|
|
|
355
|
-
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, setAppId };
|
|
402
|
+
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken, notifyGameScore, setAppId };
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
VERSION: () => VERSION,
|
|
25
25
|
createClient: () => createClient,
|
|
26
26
|
debugSetToken: () => debugSetToken,
|
|
27
|
+
notifyGameScore: () => notifyGameScore,
|
|
27
28
|
setAppId: () => setAppId
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -516,6 +517,19 @@ var DataServiceClientImpl = class {
|
|
|
516
517
|
return this.client.post("/rpc/health");
|
|
517
518
|
}
|
|
518
519
|
};
|
|
520
|
+
function notifyGameScore(score) {
|
|
521
|
+
if (!isInIframe() && !isInSeaVerseApp()) return;
|
|
522
|
+
const payload = JSON.stringify({ type: "seaverse:game_score", score });
|
|
523
|
+
try {
|
|
524
|
+
if (isInSeaVerseApp()) {
|
|
525
|
+
globalThis.window.ReactNativeWebView.postMessage(payload);
|
|
526
|
+
} else {
|
|
527
|
+
globalThis.window.parent.postMessage({ type: "seaverse:game_score", score }, "*");
|
|
528
|
+
}
|
|
529
|
+
} catch (e) {
|
|
530
|
+
console.warn("[SeaVerse DataService SDK] Failed to notify game score:", e);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
519
533
|
async function createClient(config = {}) {
|
|
520
534
|
let token = null;
|
|
521
535
|
let serviceHost = null;
|
|
@@ -551,12 +565,13 @@ async function createClient(config = {}) {
|
|
|
551
565
|
}
|
|
552
566
|
|
|
553
567
|
// src/index.ts
|
|
554
|
-
var VERSION = "1.8.
|
|
568
|
+
var VERSION = "1.8.4";
|
|
555
569
|
// Annotate the CommonJS export names for ESM import in node:
|
|
556
570
|
0 && (module.exports = {
|
|
557
571
|
DataServiceError,
|
|
558
572
|
VERSION,
|
|
559
573
|
createClient,
|
|
560
574
|
debugSetToken,
|
|
575
|
+
notifyGameScore,
|
|
561
576
|
setAppId
|
|
562
577
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -486,6 +486,19 @@ var DataServiceClientImpl = class {
|
|
|
486
486
|
return this.client.post("/rpc/health");
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
|
+
function notifyGameScore(score) {
|
|
490
|
+
if (!isInIframe() && !isInSeaVerseApp()) return;
|
|
491
|
+
const payload = JSON.stringify({ type: "seaverse:game_score", score });
|
|
492
|
+
try {
|
|
493
|
+
if (isInSeaVerseApp()) {
|
|
494
|
+
globalThis.window.ReactNativeWebView.postMessage(payload);
|
|
495
|
+
} else {
|
|
496
|
+
globalThis.window.parent.postMessage({ type: "seaverse:game_score", score }, "*");
|
|
497
|
+
}
|
|
498
|
+
} catch (e) {
|
|
499
|
+
console.warn("[SeaVerse DataService SDK] Failed to notify game score:", e);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
489
502
|
async function createClient(config = {}) {
|
|
490
503
|
let token = null;
|
|
491
504
|
let serviceHost = null;
|
|
@@ -521,11 +534,12 @@ async function createClient(config = {}) {
|
|
|
521
534
|
}
|
|
522
535
|
|
|
523
536
|
// src/index.ts
|
|
524
|
-
var VERSION = "1.8.
|
|
537
|
+
var VERSION = "1.8.4";
|
|
525
538
|
export {
|
|
526
539
|
DataServiceError,
|
|
527
540
|
VERSION,
|
|
528
541
|
createClient,
|
|
529
542
|
debugSetToken,
|
|
543
|
+
notifyGameScore,
|
|
530
544
|
setAppId
|
|
531
545
|
};
|