@rtsdk/topia 0.3.9 → 0.5.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 +4 -4
- package/dist/index.cjs +154 -5
- package/dist/index.d.ts +83 -1
- package/dist/index.js +154 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,12 +50,12 @@ await DroppedAsset.get(assetId, urlSlug, {
|
|
|
50
50
|
|
|
51
51
|
### Need an API Key to test locally? This is how you can create one:
|
|
52
52
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
53
|
+
- Navigate directly to your [integrations page](https://topia.io/t/dashboard/integrations) or follow the steps below from within a world.
|
|
54
|
+
- Click on your image (or circle) at the top left of the left hand navbar.
|
|
55
|
+
- Click Edit Profile. This will bring you to a separate dashboard.
|
|
56
|
+
- Click Integrations on the left nav
|
|
55
57
|
- Click Generate New API Key and copy the API Key to be used in your .env and while using https://sdk-examples.metaversecloud.com
|
|
56
58
|
|
|
57
|
-
<br>
|
|
58
|
-
|
|
59
59
|
Alternatively, visitors of a [topia.io](https://topia.io/) world interact with each other and the interactively configured assets in your world without the need for an API Key. This is all made possible through Interactive Session credentials passed to the SDK with every request, when applicable. What does this mean for you? Not much, actually! All of the magic happens behind the scenes and all you have to do is make sure that new class constructors include an options object like this: `options: WorldOptionalInterface = { attributes: {}, credentials: {} }` and all calls to `this.topia.axios` include the inherited `this.requestOptions` parameter.
|
|
60
60
|
|
|
61
61
|

|
package/dist/index.cjs
CHANGED
|
@@ -39637,14 +39637,14 @@ const {
|
|
|
39637
39637
|
*/
|
|
39638
39638
|
class SDKController {
|
|
39639
39639
|
constructor(topia, credentials = {}) {
|
|
39640
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, visitorId = null } = credentials;
|
|
39640
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39641
39641
|
this.topia = topia;
|
|
39642
39642
|
this.credentials = credentials;
|
|
39643
39643
|
this.requestOptions = {};
|
|
39644
39644
|
let payload = {};
|
|
39645
39645
|
const headers = {};
|
|
39646
39646
|
try {
|
|
39647
|
-
if (topia.interactiveSecret && (profileId || assetId)) {
|
|
39647
|
+
if (topia.interactiveSecret && (profileId || assetId || urlSlug)) {
|
|
39648
39648
|
payload = {
|
|
39649
39649
|
interactiveNonce,
|
|
39650
39650
|
visitorId,
|
|
@@ -39742,7 +39742,7 @@ var _DroppedAsset_updateDroppedAsset;
|
|
|
39742
39742
|
class DroppedAsset extends Asset {
|
|
39743
39743
|
constructor(topia, id, urlSlug, options = { attributes: { text: "" }, credentials: {} }) {
|
|
39744
39744
|
var _a;
|
|
39745
|
-
super(topia, id, options);
|
|
39745
|
+
super(topia, id, { attributes: options.attributes, credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
|
|
39746
39746
|
// private methods
|
|
39747
39747
|
_DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
|
|
39748
39748
|
try {
|
|
@@ -40197,6 +40197,40 @@ class DroppedAsset extends Asset {
|
|
|
40197
40197
|
}
|
|
40198
40198
|
});
|
|
40199
40199
|
}
|
|
40200
|
+
////////// analytics
|
|
40201
|
+
/**
|
|
40202
|
+
* @summary
|
|
40203
|
+
* Retrieve analytics for a dropped asset by day, week, month, quarter, or year
|
|
40204
|
+
*
|
|
40205
|
+
* @usage
|
|
40206
|
+
* ```ts
|
|
40207
|
+
* const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
|
|
40208
|
+
* periodType: "quarter",
|
|
40209
|
+
* dateValue: 3,
|
|
40210
|
+
* year: 2023,
|
|
40211
|
+
* });
|
|
40212
|
+
* ```
|
|
40213
|
+
*/
|
|
40214
|
+
fetchDroppedAssetAnalytics({ periodType, dateValue, year, }) {
|
|
40215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40216
|
+
try {
|
|
40217
|
+
let query = "";
|
|
40218
|
+
switch (periodType) {
|
|
40219
|
+
case "week":
|
|
40220
|
+
query = `&week=W${dateValue}`;
|
|
40221
|
+
case "month":
|
|
40222
|
+
query = `&month=${dateValue}`;
|
|
40223
|
+
case "quarter":
|
|
40224
|
+
query = `&quarter=Q${dateValue}`;
|
|
40225
|
+
}
|
|
40226
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/dropped-asset-analytics/${this.id}?year=${year}${query}`, this.requestOptions);
|
|
40227
|
+
return response.data;
|
|
40228
|
+
}
|
|
40229
|
+
catch (error) {
|
|
40230
|
+
throw this.errorHandler({ error });
|
|
40231
|
+
}
|
|
40232
|
+
});
|
|
40233
|
+
}
|
|
40200
40234
|
}
|
|
40201
40235
|
_DroppedAsset_updateDroppedAsset = new WeakMap();
|
|
40202
40236
|
|
|
@@ -40267,7 +40301,7 @@ var _World_droppedAssetsMap;
|
|
|
40267
40301
|
*/
|
|
40268
40302
|
class World extends SDKController {
|
|
40269
40303
|
constructor(topia, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
40270
|
-
super(topia, options.credentials);
|
|
40304
|
+
super(topia, Object.assign({ urlSlug }, options.credentials));
|
|
40271
40305
|
_World_droppedAssetsMap.set(this, void 0);
|
|
40272
40306
|
////////// data objects
|
|
40273
40307
|
/**
|
|
@@ -40534,6 +40568,8 @@ class World extends SDKController {
|
|
|
40534
40568
|
});
|
|
40535
40569
|
}
|
|
40536
40570
|
/**
|
|
40571
|
+
* @deprecated Use {@link fetchScenes} instead.
|
|
40572
|
+
*
|
|
40537
40573
|
* @summary
|
|
40538
40574
|
* Fetch a list of all scene drop ids in a world that include at least one asset with an interactivePublicKey
|
|
40539
40575
|
*
|
|
@@ -40559,6 +40595,46 @@ class World extends SDKController {
|
|
|
40559
40595
|
}
|
|
40560
40596
|
});
|
|
40561
40597
|
}
|
|
40598
|
+
/**
|
|
40599
|
+
* @summary
|
|
40600
|
+
* Fetch a list of all scene drop ids and dropped assets in a world
|
|
40601
|
+
*
|
|
40602
|
+
* @usage
|
|
40603
|
+
* ```ts
|
|
40604
|
+
* await world.fetchScenes();
|
|
40605
|
+
* ```
|
|
40606
|
+
*
|
|
40607
|
+
* @result
|
|
40608
|
+
* ```ts
|
|
40609
|
+
* { "scenes": {
|
|
40610
|
+
* "sceneDropId_1": {
|
|
40611
|
+
* "droppedAssets": {
|
|
40612
|
+
* "droppedAssetId_1": {
|
|
40613
|
+
* "metaName": "hello"
|
|
40614
|
+
* "metaNameReversed": "olleh"
|
|
40615
|
+
* },
|
|
40616
|
+
* "droppedAssetId_2": {
|
|
40617
|
+
* "metaName": "world"
|
|
40618
|
+
* "metaNameReversed": "dlorw"
|
|
40619
|
+
* }
|
|
40620
|
+
* }
|
|
40621
|
+
* },
|
|
40622
|
+
* }
|
|
40623
|
+
* }
|
|
40624
|
+
* ```
|
|
40625
|
+
*/
|
|
40626
|
+
fetchScenes() {
|
|
40627
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40628
|
+
try {
|
|
40629
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/scenes-with-dropped-assets`, this.requestOptions);
|
|
40630
|
+
this.scenes = response.data;
|
|
40631
|
+
return response.data;
|
|
40632
|
+
}
|
|
40633
|
+
catch (error) {
|
|
40634
|
+
throw this.errorHandler({ error });
|
|
40635
|
+
}
|
|
40636
|
+
});
|
|
40637
|
+
}
|
|
40562
40638
|
/**
|
|
40563
40639
|
* @summary
|
|
40564
40640
|
* Drops a scene in a world and returns sceneDropId.
|
|
@@ -40665,6 +40741,40 @@ class World extends SDKController {
|
|
|
40665
40741
|
}
|
|
40666
40742
|
});
|
|
40667
40743
|
}
|
|
40744
|
+
////////// analytics
|
|
40745
|
+
/**
|
|
40746
|
+
* @summary
|
|
40747
|
+
* Retrieve world analytics by day, week, month, quarter, or year
|
|
40748
|
+
*
|
|
40749
|
+
* @usage
|
|
40750
|
+
* ```ts
|
|
40751
|
+
* const analytics = await world.fetchWorldAnalytics({
|
|
40752
|
+
* periodType: "week",
|
|
40753
|
+
* dateValue: 40,
|
|
40754
|
+
* year: 2023,
|
|
40755
|
+
* });
|
|
40756
|
+
* ```
|
|
40757
|
+
*/
|
|
40758
|
+
fetchWorldAnalytics({ periodType, dateValue, year, }) {
|
|
40759
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40760
|
+
try {
|
|
40761
|
+
let query = "";
|
|
40762
|
+
switch (periodType) {
|
|
40763
|
+
case "week":
|
|
40764
|
+
query = `&week=W${dateValue}`;
|
|
40765
|
+
case "month":
|
|
40766
|
+
query = `&month=${dateValue}`;
|
|
40767
|
+
case "quarter":
|
|
40768
|
+
query = `&quarter=Q${dateValue}`;
|
|
40769
|
+
}
|
|
40770
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-analytics?year=${year}${query}`, this.requestOptions);
|
|
40771
|
+
return response.data;
|
|
40772
|
+
}
|
|
40773
|
+
catch (error) {
|
|
40774
|
+
throw this.errorHandler({ error });
|
|
40775
|
+
}
|
|
40776
|
+
});
|
|
40777
|
+
}
|
|
40668
40778
|
}
|
|
40669
40779
|
_World_droppedAssetsMap = new WeakMap();
|
|
40670
40780
|
|
|
@@ -40954,7 +41064,7 @@ _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_sce
|
|
|
40954
41064
|
*/
|
|
40955
41065
|
class Visitor extends User {
|
|
40956
41066
|
constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
40957
|
-
super(topia, { credentials: options.credentials });
|
|
41067
|
+
super(topia, { credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
|
|
40958
41068
|
Object.assign(this, options.attributes);
|
|
40959
41069
|
this.id = id;
|
|
40960
41070
|
this.urlSlug = urlSlug;
|
|
@@ -41098,6 +41208,32 @@ class Visitor extends User {
|
|
|
41098
41208
|
}
|
|
41099
41209
|
});
|
|
41100
41210
|
}
|
|
41211
|
+
/**
|
|
41212
|
+
* @summary
|
|
41213
|
+
* Grant expression to a visitor by id or name.
|
|
41214
|
+
*
|
|
41215
|
+
* @usage
|
|
41216
|
+
* ```ts
|
|
41217
|
+
* await visitor.grantExpression({ name: "Eyes" });
|
|
41218
|
+
* ```
|
|
41219
|
+
*/
|
|
41220
|
+
grantExpression({ id, name }) {
|
|
41221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41222
|
+
if (!id && !name)
|
|
41223
|
+
throw "An expression id or name is required.";
|
|
41224
|
+
try {
|
|
41225
|
+
let expressionId = id;
|
|
41226
|
+
if (name) {
|
|
41227
|
+
expressionId = yield this.topiaPublicApi().get(`/expressions?name=${name}`, this.requestOptions);
|
|
41228
|
+
}
|
|
41229
|
+
const result = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-expression/${expressionId}`, {}, this.requestOptions);
|
|
41230
|
+
return result;
|
|
41231
|
+
}
|
|
41232
|
+
catch (error) {
|
|
41233
|
+
throw this.errorHandler({ error });
|
|
41234
|
+
}
|
|
41235
|
+
});
|
|
41236
|
+
}
|
|
41101
41237
|
/**
|
|
41102
41238
|
* @summary
|
|
41103
41239
|
* Retrieves the data object for a visitor.
|
|
@@ -41393,6 +41529,19 @@ class DroppedAssetFactory extends SDKController {
|
|
|
41393
41529
|
return droppedAsset;
|
|
41394
41530
|
});
|
|
41395
41531
|
}
|
|
41532
|
+
getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
|
|
41533
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41534
|
+
const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
41535
|
+
try {
|
|
41536
|
+
const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
|
|
41537
|
+
const { id } = response.data;
|
|
41538
|
+
return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
|
|
41539
|
+
}
|
|
41540
|
+
catch (error) {
|
|
41541
|
+
throw this.errorHandler({ error });
|
|
41542
|
+
}
|
|
41543
|
+
});
|
|
41544
|
+
}
|
|
41396
41545
|
drop(asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
|
|
41397
41546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41398
41547
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -270,7 +270,7 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
|
|
|
270
270
|
* await droppedAsset.updatePosition(100,200);
|
|
271
271
|
* ```
|
|
272
272
|
*/
|
|
273
|
-
updatePosition(x: number, y: number, yOrderAdjust
|
|
273
|
+
updatePosition(x: number, y: number, yOrderAdjust?: number): Promise<void | ResponseType>;
|
|
274
274
|
/**
|
|
275
275
|
* @summary
|
|
276
276
|
* Updates private zone options for a dropped asset.
|
|
@@ -358,6 +358,24 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
|
|
|
358
358
|
isInteractive?: boolean;
|
|
359
359
|
interactivePublicKey: string;
|
|
360
360
|
}): Promise<void | ResponseType>;
|
|
361
|
+
/**
|
|
362
|
+
* @summary
|
|
363
|
+
* Retrieve analytics for a dropped asset by day, week, month, quarter, or year
|
|
364
|
+
*
|
|
365
|
+
* @usage
|
|
366
|
+
* ```ts
|
|
367
|
+
* const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
|
|
368
|
+
* periodType: "quarter",
|
|
369
|
+
* dateValue: 3,
|
|
370
|
+
* year: 2023,
|
|
371
|
+
* });
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
fetchDroppedAssetAnalytics({ periodType, dateValue, year, }: {
|
|
375
|
+
periodType: "week" | "month" | "quarter" | "year";
|
|
376
|
+
dateValue: number;
|
|
377
|
+
year: number;
|
|
378
|
+
}): Promise<void | ResponseType>;
|
|
361
379
|
}
|
|
362
380
|
|
|
363
381
|
/**
|
|
@@ -374,6 +392,7 @@ declare class World extends SDKController implements WorldInterface {
|
|
|
374
392
|
urlSlug: string;
|
|
375
393
|
dataObject?: object | null | undefined;
|
|
376
394
|
sceneDropIds?: [string] | null | undefined;
|
|
395
|
+
scenes?: [string] | null | undefined;
|
|
377
396
|
webhooks?: WorldWebhooksInterface | null | undefined;
|
|
378
397
|
constructor(topia: Topia, urlSlug: string, options?: WorldOptionalInterface);
|
|
379
398
|
get droppedAssets(): {
|
|
@@ -478,6 +497,8 @@ declare class World extends SDKController implements WorldInterface {
|
|
|
478
497
|
*/
|
|
479
498
|
updateCustomTextDroppedAssets(droppedAssetsToUpdate: Array<DroppedAsset>, style: object): Promise<object>;
|
|
480
499
|
/**
|
|
500
|
+
* @deprecated Use {@link fetchScenes} instead.
|
|
501
|
+
*
|
|
481
502
|
* @summary
|
|
482
503
|
* Fetch a list of all scene drop ids in a world that include at least one asset with an interactivePublicKey
|
|
483
504
|
*
|
|
@@ -492,6 +513,35 @@ declare class World extends SDKController implements WorldInterface {
|
|
|
492
513
|
* ```
|
|
493
514
|
*/
|
|
494
515
|
fetchSceneDropIds(): Promise<object | ResponseType>;
|
|
516
|
+
/**
|
|
517
|
+
* @summary
|
|
518
|
+
* Fetch a list of all scene drop ids and dropped assets in a world
|
|
519
|
+
*
|
|
520
|
+
* @usage
|
|
521
|
+
* ```ts
|
|
522
|
+
* await world.fetchScenes();
|
|
523
|
+
* ```
|
|
524
|
+
*
|
|
525
|
+
* @result
|
|
526
|
+
* ```ts
|
|
527
|
+
* { "scenes": {
|
|
528
|
+
* "sceneDropId_1": {
|
|
529
|
+
* "droppedAssets": {
|
|
530
|
+
* "droppedAssetId_1": {
|
|
531
|
+
* "metaName": "hello"
|
|
532
|
+
* "metaNameReversed": "olleh"
|
|
533
|
+
* },
|
|
534
|
+
* "droppedAssetId_2": {
|
|
535
|
+
* "metaName": "world"
|
|
536
|
+
* "metaNameReversed": "dlorw"
|
|
537
|
+
* }
|
|
538
|
+
* }
|
|
539
|
+
* },
|
|
540
|
+
* }
|
|
541
|
+
* }
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
fetchScenes(): Promise<object | ResponseType>;
|
|
495
545
|
/**
|
|
496
546
|
* @summary
|
|
497
547
|
* Drops a scene in a world and returns sceneDropId.
|
|
@@ -618,6 +668,24 @@ declare class World extends SDKController implements WorldInterface {
|
|
|
618
668
|
* ```
|
|
619
669
|
*/
|
|
620
670
|
fetchWebhooks(): Promise<void | ResponseType>;
|
|
671
|
+
/**
|
|
672
|
+
* @summary
|
|
673
|
+
* Retrieve world analytics by day, week, month, quarter, or year
|
|
674
|
+
*
|
|
675
|
+
* @usage
|
|
676
|
+
* ```ts
|
|
677
|
+
* const analytics = await world.fetchWorldAnalytics({
|
|
678
|
+
* periodType: "week",
|
|
679
|
+
* dateValue: 40,
|
|
680
|
+
* year: 2023,
|
|
681
|
+
* });
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
fetchWorldAnalytics({ periodType, dateValue, year, }: {
|
|
685
|
+
periodType: "week" | "month" | "quarter" | "year";
|
|
686
|
+
dateValue: number;
|
|
687
|
+
year: number;
|
|
688
|
+
}): Promise<void | ResponseType>;
|
|
621
689
|
}
|
|
622
690
|
|
|
623
691
|
/**
|
|
@@ -851,6 +919,19 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
851
919
|
* ```
|
|
852
920
|
*/
|
|
853
921
|
turnAVOff(): Promise<void | ResponseType>;
|
|
922
|
+
/**
|
|
923
|
+
* @summary
|
|
924
|
+
* Grant expression to a visitor by id or name.
|
|
925
|
+
*
|
|
926
|
+
* @usage
|
|
927
|
+
* ```ts
|
|
928
|
+
* await visitor.grantExpression({ name: "Eyes" });
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
grantExpression({ id, name }: {
|
|
932
|
+
id?: string;
|
|
933
|
+
name?: string;
|
|
934
|
+
}): Promise<object | ResponseType>;
|
|
854
935
|
/**
|
|
855
936
|
* @summary
|
|
856
937
|
* Retrieves the data object for a visitor.
|
|
@@ -1485,6 +1566,7 @@ declare class DroppedAssetFactory extends SDKController {
|
|
|
1485
1566
|
constructor(topia: Topia);
|
|
1486
1567
|
create(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): DroppedAsset;
|
|
1487
1568
|
get(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): Promise<DroppedAsset>;
|
|
1569
|
+
getWithUniqueName(uniqueName: string, urlSlug: string, interactivePublicKey: string, interactiveSecret: string): Promise<DroppedAsset>;
|
|
1488
1570
|
drop(asset: Asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }: {
|
|
1489
1571
|
interactivePublicKey?: string;
|
|
1490
1572
|
position: {
|
package/dist/index.js
CHANGED
|
@@ -39635,14 +39635,14 @@ const {
|
|
|
39635
39635
|
*/
|
|
39636
39636
|
class SDKController {
|
|
39637
39637
|
constructor(topia, credentials = {}) {
|
|
39638
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, visitorId = null } = credentials;
|
|
39638
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39639
39639
|
this.topia = topia;
|
|
39640
39640
|
this.credentials = credentials;
|
|
39641
39641
|
this.requestOptions = {};
|
|
39642
39642
|
let payload = {};
|
|
39643
39643
|
const headers = {};
|
|
39644
39644
|
try {
|
|
39645
|
-
if (topia.interactiveSecret && (profileId || assetId)) {
|
|
39645
|
+
if (topia.interactiveSecret && (profileId || assetId || urlSlug)) {
|
|
39646
39646
|
payload = {
|
|
39647
39647
|
interactiveNonce,
|
|
39648
39648
|
visitorId,
|
|
@@ -39740,7 +39740,7 @@ var _DroppedAsset_updateDroppedAsset;
|
|
|
39740
39740
|
class DroppedAsset extends Asset {
|
|
39741
39741
|
constructor(topia, id, urlSlug, options = { attributes: { text: "" }, credentials: {} }) {
|
|
39742
39742
|
var _a;
|
|
39743
|
-
super(topia, id, options);
|
|
39743
|
+
super(topia, id, { attributes: options.attributes, credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
|
|
39744
39744
|
// private methods
|
|
39745
39745
|
_DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
|
|
39746
39746
|
try {
|
|
@@ -40195,6 +40195,40 @@ class DroppedAsset extends Asset {
|
|
|
40195
40195
|
}
|
|
40196
40196
|
});
|
|
40197
40197
|
}
|
|
40198
|
+
////////// analytics
|
|
40199
|
+
/**
|
|
40200
|
+
* @summary
|
|
40201
|
+
* Retrieve analytics for a dropped asset by day, week, month, quarter, or year
|
|
40202
|
+
*
|
|
40203
|
+
* @usage
|
|
40204
|
+
* ```ts
|
|
40205
|
+
* const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
|
|
40206
|
+
* periodType: "quarter",
|
|
40207
|
+
* dateValue: 3,
|
|
40208
|
+
* year: 2023,
|
|
40209
|
+
* });
|
|
40210
|
+
* ```
|
|
40211
|
+
*/
|
|
40212
|
+
fetchDroppedAssetAnalytics({ periodType, dateValue, year, }) {
|
|
40213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40214
|
+
try {
|
|
40215
|
+
let query = "";
|
|
40216
|
+
switch (periodType) {
|
|
40217
|
+
case "week":
|
|
40218
|
+
query = `&week=W${dateValue}`;
|
|
40219
|
+
case "month":
|
|
40220
|
+
query = `&month=${dateValue}`;
|
|
40221
|
+
case "quarter":
|
|
40222
|
+
query = `&quarter=Q${dateValue}`;
|
|
40223
|
+
}
|
|
40224
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/dropped-asset-analytics/${this.id}?year=${year}${query}`, this.requestOptions);
|
|
40225
|
+
return response.data;
|
|
40226
|
+
}
|
|
40227
|
+
catch (error) {
|
|
40228
|
+
throw this.errorHandler({ error });
|
|
40229
|
+
}
|
|
40230
|
+
});
|
|
40231
|
+
}
|
|
40198
40232
|
}
|
|
40199
40233
|
_DroppedAsset_updateDroppedAsset = new WeakMap();
|
|
40200
40234
|
|
|
@@ -40265,7 +40299,7 @@ var _World_droppedAssetsMap;
|
|
|
40265
40299
|
*/
|
|
40266
40300
|
class World extends SDKController {
|
|
40267
40301
|
constructor(topia, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
40268
|
-
super(topia, options.credentials);
|
|
40302
|
+
super(topia, Object.assign({ urlSlug }, options.credentials));
|
|
40269
40303
|
_World_droppedAssetsMap.set(this, void 0);
|
|
40270
40304
|
////////// data objects
|
|
40271
40305
|
/**
|
|
@@ -40532,6 +40566,8 @@ class World extends SDKController {
|
|
|
40532
40566
|
});
|
|
40533
40567
|
}
|
|
40534
40568
|
/**
|
|
40569
|
+
* @deprecated Use {@link fetchScenes} instead.
|
|
40570
|
+
*
|
|
40535
40571
|
* @summary
|
|
40536
40572
|
* Fetch a list of all scene drop ids in a world that include at least one asset with an interactivePublicKey
|
|
40537
40573
|
*
|
|
@@ -40557,6 +40593,46 @@ class World extends SDKController {
|
|
|
40557
40593
|
}
|
|
40558
40594
|
});
|
|
40559
40595
|
}
|
|
40596
|
+
/**
|
|
40597
|
+
* @summary
|
|
40598
|
+
* Fetch a list of all scene drop ids and dropped assets in a world
|
|
40599
|
+
*
|
|
40600
|
+
* @usage
|
|
40601
|
+
* ```ts
|
|
40602
|
+
* await world.fetchScenes();
|
|
40603
|
+
* ```
|
|
40604
|
+
*
|
|
40605
|
+
* @result
|
|
40606
|
+
* ```ts
|
|
40607
|
+
* { "scenes": {
|
|
40608
|
+
* "sceneDropId_1": {
|
|
40609
|
+
* "droppedAssets": {
|
|
40610
|
+
* "droppedAssetId_1": {
|
|
40611
|
+
* "metaName": "hello"
|
|
40612
|
+
* "metaNameReversed": "olleh"
|
|
40613
|
+
* },
|
|
40614
|
+
* "droppedAssetId_2": {
|
|
40615
|
+
* "metaName": "world"
|
|
40616
|
+
* "metaNameReversed": "dlorw"
|
|
40617
|
+
* }
|
|
40618
|
+
* }
|
|
40619
|
+
* },
|
|
40620
|
+
* }
|
|
40621
|
+
* }
|
|
40622
|
+
* ```
|
|
40623
|
+
*/
|
|
40624
|
+
fetchScenes() {
|
|
40625
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40626
|
+
try {
|
|
40627
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/scenes-with-dropped-assets`, this.requestOptions);
|
|
40628
|
+
this.scenes = response.data;
|
|
40629
|
+
return response.data;
|
|
40630
|
+
}
|
|
40631
|
+
catch (error) {
|
|
40632
|
+
throw this.errorHandler({ error });
|
|
40633
|
+
}
|
|
40634
|
+
});
|
|
40635
|
+
}
|
|
40560
40636
|
/**
|
|
40561
40637
|
* @summary
|
|
40562
40638
|
* Drops a scene in a world and returns sceneDropId.
|
|
@@ -40663,6 +40739,40 @@ class World extends SDKController {
|
|
|
40663
40739
|
}
|
|
40664
40740
|
});
|
|
40665
40741
|
}
|
|
40742
|
+
////////// analytics
|
|
40743
|
+
/**
|
|
40744
|
+
* @summary
|
|
40745
|
+
* Retrieve world analytics by day, week, month, quarter, or year
|
|
40746
|
+
*
|
|
40747
|
+
* @usage
|
|
40748
|
+
* ```ts
|
|
40749
|
+
* const analytics = await world.fetchWorldAnalytics({
|
|
40750
|
+
* periodType: "week",
|
|
40751
|
+
* dateValue: 40,
|
|
40752
|
+
* year: 2023,
|
|
40753
|
+
* });
|
|
40754
|
+
* ```
|
|
40755
|
+
*/
|
|
40756
|
+
fetchWorldAnalytics({ periodType, dateValue, year, }) {
|
|
40757
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40758
|
+
try {
|
|
40759
|
+
let query = "";
|
|
40760
|
+
switch (periodType) {
|
|
40761
|
+
case "week":
|
|
40762
|
+
query = `&week=W${dateValue}`;
|
|
40763
|
+
case "month":
|
|
40764
|
+
query = `&month=${dateValue}`;
|
|
40765
|
+
case "quarter":
|
|
40766
|
+
query = `&quarter=Q${dateValue}`;
|
|
40767
|
+
}
|
|
40768
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-analytics?year=${year}${query}`, this.requestOptions);
|
|
40769
|
+
return response.data;
|
|
40770
|
+
}
|
|
40771
|
+
catch (error) {
|
|
40772
|
+
throw this.errorHandler({ error });
|
|
40773
|
+
}
|
|
40774
|
+
});
|
|
40775
|
+
}
|
|
40666
40776
|
}
|
|
40667
40777
|
_World_droppedAssetsMap = new WeakMap();
|
|
40668
40778
|
|
|
@@ -40952,7 +41062,7 @@ _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_sce
|
|
|
40952
41062
|
*/
|
|
40953
41063
|
class Visitor extends User {
|
|
40954
41064
|
constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
40955
|
-
super(topia, { credentials: options.credentials });
|
|
41065
|
+
super(topia, { credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
|
|
40956
41066
|
Object.assign(this, options.attributes);
|
|
40957
41067
|
this.id = id;
|
|
40958
41068
|
this.urlSlug = urlSlug;
|
|
@@ -41096,6 +41206,32 @@ class Visitor extends User {
|
|
|
41096
41206
|
}
|
|
41097
41207
|
});
|
|
41098
41208
|
}
|
|
41209
|
+
/**
|
|
41210
|
+
* @summary
|
|
41211
|
+
* Grant expression to a visitor by id or name.
|
|
41212
|
+
*
|
|
41213
|
+
* @usage
|
|
41214
|
+
* ```ts
|
|
41215
|
+
* await visitor.grantExpression({ name: "Eyes" });
|
|
41216
|
+
* ```
|
|
41217
|
+
*/
|
|
41218
|
+
grantExpression({ id, name }) {
|
|
41219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41220
|
+
if (!id && !name)
|
|
41221
|
+
throw "An expression id or name is required.";
|
|
41222
|
+
try {
|
|
41223
|
+
let expressionId = id;
|
|
41224
|
+
if (name) {
|
|
41225
|
+
expressionId = yield this.topiaPublicApi().get(`/expressions?name=${name}`, this.requestOptions);
|
|
41226
|
+
}
|
|
41227
|
+
const result = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-expression/${expressionId}`, {}, this.requestOptions);
|
|
41228
|
+
return result;
|
|
41229
|
+
}
|
|
41230
|
+
catch (error) {
|
|
41231
|
+
throw this.errorHandler({ error });
|
|
41232
|
+
}
|
|
41233
|
+
});
|
|
41234
|
+
}
|
|
41099
41235
|
/**
|
|
41100
41236
|
* @summary
|
|
41101
41237
|
* Retrieves the data object for a visitor.
|
|
@@ -41391,6 +41527,19 @@ class DroppedAssetFactory extends SDKController {
|
|
|
41391
41527
|
return droppedAsset;
|
|
41392
41528
|
});
|
|
41393
41529
|
}
|
|
41530
|
+
getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
|
|
41531
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41532
|
+
const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
41533
|
+
try {
|
|
41534
|
+
const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
|
|
41535
|
+
const { id } = response.data;
|
|
41536
|
+
return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
|
|
41537
|
+
}
|
|
41538
|
+
catch (error) {
|
|
41539
|
+
throw this.errorHandler({ error });
|
|
41540
|
+
}
|
|
41541
|
+
});
|
|
41542
|
+
}
|
|
41394
41543
|
drop(asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
|
|
41395
41544
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41396
41545
|
try {
|
package/package.json
CHANGED