@rtsdk/topia 0.8.4 → 0.9.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 +106 -11
- package/dist/index.cjs +318 -45
- package/dist/index.d.ts +374 -112
- package/dist/index.js +318 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39715,7 +39715,7 @@ class SDKController {
|
|
|
39715
39715
|
*/
|
|
39716
39716
|
class Asset extends SDKController {
|
|
39717
39717
|
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
39718
|
-
var _a, _b, _c, _d, _e;
|
|
39718
|
+
var _a, _b, _c, _d, _e, _f;
|
|
39719
39719
|
// assetId and urlSlug should only be used when Asset is extended by DroppedAsset
|
|
39720
39720
|
super(topia, {
|
|
39721
39721
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
@@ -39725,16 +39725,27 @@ class Asset extends SDKController {
|
|
|
39725
39725
|
visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
|
|
39726
39726
|
});
|
|
39727
39727
|
this.id = id;
|
|
39728
|
+
this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
|
|
39728
39729
|
Object.assign(this, options.attributes);
|
|
39729
39730
|
}
|
|
39730
|
-
|
|
39731
|
+
/**
|
|
39732
|
+
* @summary
|
|
39733
|
+
* Retrieves platform asset details.
|
|
39734
|
+
*
|
|
39735
|
+
* @usage
|
|
39736
|
+
* ```ts
|
|
39737
|
+
* await asset.fetchAssetById();
|
|
39738
|
+
* const { assetName } = asset;
|
|
39739
|
+
* ```
|
|
39740
|
+
*/
|
|
39741
|
+
fetchAssetById() {
|
|
39731
39742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39732
39743
|
try {
|
|
39733
|
-
const response = yield this.topiaPublicApi().get(
|
|
39744
|
+
const response = yield this.topiaPublicApi().get(`/assets/${this.urlSlug}/${this.id}`, this.requestOptions);
|
|
39734
39745
|
return response.data;
|
|
39735
39746
|
}
|
|
39736
39747
|
catch (error) {
|
|
39737
|
-
throw this.errorHandler({ error, sdkMethod: "Asset.
|
|
39748
|
+
throw this.errorHandler({ error, sdkMethod: "Asset.fetchAssetById" });
|
|
39738
39749
|
}
|
|
39739
39750
|
});
|
|
39740
39751
|
}
|
|
@@ -39850,8 +39861,8 @@ class DroppedAsset extends Asset {
|
|
|
39850
39861
|
setDataObject(dataObject, options = {}) {
|
|
39851
39862
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39852
39863
|
try {
|
|
39853
|
-
const { lock = {} } = options;
|
|
39854
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
39864
|
+
const { analytics = [], lock = {} } = options;
|
|
39865
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
39855
39866
|
this.dataObject = dataObject || this.dataObject;
|
|
39856
39867
|
}
|
|
39857
39868
|
catch (error) {
|
|
@@ -39876,8 +39887,8 @@ class DroppedAsset extends Asset {
|
|
|
39876
39887
|
updateDataObject(dataObject, options = {}) {
|
|
39877
39888
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39878
39889
|
try {
|
|
39879
|
-
const { lock = {} } = options;
|
|
39880
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
39890
|
+
const { analytics = [], lock = {} } = options;
|
|
39891
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
39881
39892
|
this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
|
|
39882
39893
|
}
|
|
39883
39894
|
catch (error) {
|
|
@@ -39902,8 +39913,8 @@ class DroppedAsset extends Asset {
|
|
|
39902
39913
|
incrementDataObjectValue(path, amount, options = {}) {
|
|
39903
39914
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39904
39915
|
try {
|
|
39905
|
-
const { lock = {} } = options;
|
|
39906
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
|
|
39916
|
+
const { analytics = [], lock = {} } = options;
|
|
39917
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
|
|
39907
39918
|
}
|
|
39908
39919
|
catch (error) {
|
|
39909
39920
|
throw this.errorHandler({
|
|
@@ -40187,7 +40198,6 @@ class DroppedAsset extends Asset {
|
|
|
40187
40198
|
* @usage
|
|
40188
40199
|
* ```ts
|
|
40189
40200
|
* await droppedAsset.addWebhook({
|
|
40190
|
-
* active: true,
|
|
40191
40201
|
* dataObject: {},
|
|
40192
40202
|
* description: "Webhook desc",
|
|
40193
40203
|
* enteredBy: "you",
|
|
@@ -40195,7 +40205,6 @@ class DroppedAsset extends Asset {
|
|
|
40195
40205
|
* title: "title",
|
|
40196
40206
|
* type: "type",
|
|
40197
40207
|
* url: "https://url.com",
|
|
40198
|
-
* urlSlug: "world",
|
|
40199
40208
|
* });
|
|
40200
40209
|
* ```
|
|
40201
40210
|
*/
|
|
@@ -40313,6 +40322,16 @@ class Scene extends SDKController {
|
|
|
40313
40322
|
this.id = id;
|
|
40314
40323
|
Object.assign(this, options.attributes);
|
|
40315
40324
|
}
|
|
40325
|
+
/**
|
|
40326
|
+
* @summary
|
|
40327
|
+
* Retrieves scene details.
|
|
40328
|
+
*
|
|
40329
|
+
* @usage
|
|
40330
|
+
* ```ts
|
|
40331
|
+
* await scene.fetchSceneById();
|
|
40332
|
+
* const { name } = scene;
|
|
40333
|
+
* ```
|
|
40334
|
+
*/
|
|
40316
40335
|
fetchSceneById() {
|
|
40317
40336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40318
40337
|
try {
|
|
@@ -40413,8 +40432,8 @@ class World extends SDKController {
|
|
|
40413
40432
|
*/
|
|
40414
40433
|
this.setDataObject = (dataObject, options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
40415
40434
|
try {
|
|
40416
|
-
const { lock = {} } = options;
|
|
40417
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
40435
|
+
const { analytics = [], lock = {} } = options;
|
|
40436
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
40418
40437
|
this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
|
|
40419
40438
|
}
|
|
40420
40439
|
catch (error) {
|
|
@@ -40437,8 +40456,8 @@ class World extends SDKController {
|
|
|
40437
40456
|
*/
|
|
40438
40457
|
this.updateDataObject = (dataObject, options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
40439
40458
|
try {
|
|
40440
|
-
const { lock = {} } = options;
|
|
40441
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
40459
|
+
const { analytics = [], lock = {} } = options;
|
|
40460
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
40442
40461
|
this.dataObject = dataObject || this.dataObject;
|
|
40443
40462
|
}
|
|
40444
40463
|
catch (error) {
|
|
@@ -40517,6 +40536,42 @@ class World extends SDKController {
|
|
|
40517
40536
|
}
|
|
40518
40537
|
});
|
|
40519
40538
|
}
|
|
40539
|
+
/**
|
|
40540
|
+
* @summary
|
|
40541
|
+
* Set close world settings
|
|
40542
|
+
*
|
|
40543
|
+
* @usage
|
|
40544
|
+
* ```ts
|
|
40545
|
+
* await world.updateCloseWorldSettings({
|
|
40546
|
+
* controls: {
|
|
40547
|
+
* allowMuteAll: true,
|
|
40548
|
+
* disableHideVideo: true,
|
|
40549
|
+
* isMobileDisabled: false,
|
|
40550
|
+
* isShowingCurrentGuests: false,
|
|
40551
|
+
* },
|
|
40552
|
+
* description: 'Welcome to my world.',
|
|
40553
|
+
* forceAuthOnLogin: false,
|
|
40554
|
+
* height: 2000,
|
|
40555
|
+
* name: 'Example',
|
|
40556
|
+
* spawnPosition: { x: 100, y: 100 },
|
|
40557
|
+
* width: 2000
|
|
40558
|
+
* });
|
|
40559
|
+
* ```
|
|
40560
|
+
*/
|
|
40561
|
+
updateCloseWorldSettings({ closeWorldDescription, isWorldClosed, }) {
|
|
40562
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40563
|
+
const params = {
|
|
40564
|
+
closeWorldDescription,
|
|
40565
|
+
isWorldClosed,
|
|
40566
|
+
};
|
|
40567
|
+
try {
|
|
40568
|
+
return yield this.topiaPublicApi().put(`/world/${this.urlSlug}/set-close-world-settings`, params, this.requestOptions);
|
|
40569
|
+
}
|
|
40570
|
+
catch (error) {
|
|
40571
|
+
throw this.errorHandler({ error, params, sdkMethod: "World.updateCloseWorldSettings" });
|
|
40572
|
+
}
|
|
40573
|
+
});
|
|
40574
|
+
}
|
|
40520
40575
|
////////// dropped assets
|
|
40521
40576
|
/**
|
|
40522
40577
|
* @summary
|
|
@@ -40648,6 +40703,7 @@ class World extends SDKController {
|
|
|
40648
40703
|
return outcomes;
|
|
40649
40704
|
});
|
|
40650
40705
|
}
|
|
40706
|
+
// scenes
|
|
40651
40707
|
/**
|
|
40652
40708
|
* @deprecated Use {@link fetchScenes} instead.
|
|
40653
40709
|
*
|
|
@@ -40708,7 +40764,7 @@ class World extends SDKController {
|
|
|
40708
40764
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40709
40765
|
try {
|
|
40710
40766
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/scenes-with-dropped-assets`, this.requestOptions);
|
|
40711
|
-
this.scenes = response.data;
|
|
40767
|
+
this.scenes = response.data.scenes;
|
|
40712
40768
|
return response.data;
|
|
40713
40769
|
}
|
|
40714
40770
|
catch (error) {
|
|
@@ -40793,8 +40849,8 @@ class World extends SDKController {
|
|
|
40793
40849
|
incrementDataObjectValue(path, amount, options = {}) {
|
|
40794
40850
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40795
40851
|
try {
|
|
40796
|
-
const { lock = {} } = options;
|
|
40797
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
|
|
40852
|
+
const { analytics, lock = {} } = options;
|
|
40853
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
|
|
40798
40854
|
}
|
|
40799
40855
|
catch (error) {
|
|
40800
40856
|
throw this.errorHandler({
|
|
@@ -40918,6 +40974,12 @@ class User extends SDKController {
|
|
|
40918
40974
|
/**
|
|
40919
40975
|
* @summary
|
|
40920
40976
|
* Returns all assets owned by User when an email address is provided.
|
|
40977
|
+
*
|
|
40978
|
+
* @usage
|
|
40979
|
+
* ```ts
|
|
40980
|
+
* await user.fetchAssets();
|
|
40981
|
+
* const userAssets = user.assets;
|
|
40982
|
+
* ```
|
|
40921
40983
|
*/
|
|
40922
40984
|
fetchAssets() {
|
|
40923
40985
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40940,7 +41002,33 @@ class User extends SDKController {
|
|
|
40940
41002
|
}
|
|
40941
41003
|
/**
|
|
40942
41004
|
* @summary
|
|
40943
|
-
* Returns all
|
|
41005
|
+
* Returns all platform assets.
|
|
41006
|
+
*
|
|
41007
|
+
* @usage
|
|
41008
|
+
* ```ts
|
|
41009
|
+
* const assets = await user.fetchPlatformAssets();
|
|
41010
|
+
* ```
|
|
41011
|
+
*/
|
|
41012
|
+
fetchPlatformAssets() {
|
|
41013
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41014
|
+
try {
|
|
41015
|
+
const response = yield this.topiaPublicApi().get("/assets/topia-assets", this.requestOptions);
|
|
41016
|
+
return response.data;
|
|
41017
|
+
}
|
|
41018
|
+
catch (error) {
|
|
41019
|
+
throw this.errorHandler({ error, sdkMethod: "Asset.fetchPlatformAssets" });
|
|
41020
|
+
}
|
|
41021
|
+
});
|
|
41022
|
+
}
|
|
41023
|
+
/**
|
|
41024
|
+
* @summary
|
|
41025
|
+
* Returns all scenes owned by User.
|
|
41026
|
+
*
|
|
41027
|
+
* @usage
|
|
41028
|
+
* ```ts
|
|
41029
|
+
* await user.fetchScenes();
|
|
41030
|
+
* const userScenes = user.scenes;
|
|
41031
|
+
* ```
|
|
40944
41032
|
*/
|
|
40945
41033
|
fetchScenes() {
|
|
40946
41034
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -41089,8 +41177,8 @@ class User extends SDKController {
|
|
|
41089
41177
|
try {
|
|
41090
41178
|
if (!this.profileId)
|
|
41091
41179
|
throw "This method requires the use of a profileId";
|
|
41092
|
-
const { lock = {} } = options;
|
|
41093
|
-
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41180
|
+
const { analytics = [], lock = {} } = options;
|
|
41181
|
+
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41094
41182
|
this.dataObject = dataObject || this.dataObject;
|
|
41095
41183
|
}
|
|
41096
41184
|
catch (error) {
|
|
@@ -41116,8 +41204,8 @@ class User extends SDKController {
|
|
|
41116
41204
|
try {
|
|
41117
41205
|
if (!this.profileId)
|
|
41118
41206
|
throw "This method requires the use of a profileId";
|
|
41119
|
-
const { lock = {} } = options;
|
|
41120
|
-
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41207
|
+
const { analytics = [], lock = {} } = options;
|
|
41208
|
+
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41121
41209
|
this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
|
|
41122
41210
|
}
|
|
41123
41211
|
catch (error) {
|
|
@@ -41142,8 +41230,8 @@ class User extends SDKController {
|
|
|
41142
41230
|
incrementDataObjectValue(path, amount, options = {}) {
|
|
41143
41231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41144
41232
|
try {
|
|
41145
|
-
const { lock = {} } = options;
|
|
41146
|
-
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
|
|
41233
|
+
const { analytics = [], lock = {} } = options;
|
|
41234
|
+
yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
|
|
41147
41235
|
}
|
|
41148
41236
|
catch (error) {
|
|
41149
41237
|
throw this.errorHandler({ error, params: { path, amount, options }, sdkMethod: "User.incrementDataObjectValue" });
|
|
@@ -41414,8 +41502,8 @@ class Visitor extends User {
|
|
|
41414
41502
|
setDataObject(dataObject, options = {}) {
|
|
41415
41503
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41416
41504
|
try {
|
|
41417
|
-
const { lock = {} } = options;
|
|
41418
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41505
|
+
const { analytics = [], lock = {} } = options;
|
|
41506
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41419
41507
|
this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
|
|
41420
41508
|
}
|
|
41421
41509
|
catch (error) {
|
|
@@ -41439,8 +41527,8 @@ class Visitor extends User {
|
|
|
41439
41527
|
updateDataObject(dataObject, options = {}) {
|
|
41440
41528
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41441
41529
|
try {
|
|
41442
|
-
const { lock = {} } = options;
|
|
41443
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41530
|
+
const { analytics = [], lock = {} } = options;
|
|
41531
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
|
|
41444
41532
|
this.dataObject = dataObject || this.dataObject;
|
|
41445
41533
|
}
|
|
41446
41534
|
catch (error) {
|
|
@@ -41465,8 +41553,8 @@ class Visitor extends User {
|
|
|
41465
41553
|
incrementDataObjectValue(path, amount, options = {}) {
|
|
41466
41554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41467
41555
|
try {
|
|
41468
|
-
const { lock = {} } = options;
|
|
41469
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
|
|
41556
|
+
const { analytics = [], lock = {} } = options;
|
|
41557
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
|
|
41470
41558
|
}
|
|
41471
41559
|
catch (error) {
|
|
41472
41560
|
throw this.errorHandler({
|
|
@@ -41661,23 +41749,62 @@ class Topia {
|
|
|
41661
41749
|
}
|
|
41662
41750
|
}
|
|
41663
41751
|
|
|
41752
|
+
/**
|
|
41753
|
+
* @usage
|
|
41754
|
+
* ```ts
|
|
41755
|
+
* const Asset = new AssetFactory(myTopiaInstance);
|
|
41756
|
+
* ```
|
|
41757
|
+
*/
|
|
41664
41758
|
class AssetFactory {
|
|
41665
41759
|
constructor(topia) {
|
|
41666
41760
|
this.topia = topia;
|
|
41667
41761
|
this.create;
|
|
41668
41762
|
}
|
|
41763
|
+
/**
|
|
41764
|
+
* @summary
|
|
41765
|
+
* Instantiate a new instance of Asset class.
|
|
41766
|
+
*
|
|
41767
|
+
* @usage
|
|
41768
|
+
* ```
|
|
41769
|
+
* const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41770
|
+
* ```
|
|
41771
|
+
*/
|
|
41669
41772
|
create(id, options) {
|
|
41670
41773
|
return new Asset(this.topia, id, options);
|
|
41671
41774
|
}
|
|
41672
41775
|
}
|
|
41673
41776
|
|
|
41777
|
+
/**
|
|
41778
|
+
* @usage
|
|
41779
|
+
* ```ts
|
|
41780
|
+
* const DroppedAsset = new DroppedAssetFactory(myTopiaInstance);
|
|
41781
|
+
* ```
|
|
41782
|
+
*/
|
|
41674
41783
|
class DroppedAssetFactory extends SDKController {
|
|
41675
41784
|
constructor(topia) {
|
|
41676
41785
|
super(topia);
|
|
41677
41786
|
}
|
|
41787
|
+
/**
|
|
41788
|
+
* @summary
|
|
41789
|
+
* Instantiate a new instance of DroppedAsset class.
|
|
41790
|
+
*
|
|
41791
|
+
* @usage
|
|
41792
|
+
* ```
|
|
41793
|
+
* const droppedAssetInstance = await DroppedAsset.create(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41794
|
+
* ```
|
|
41795
|
+
*/
|
|
41678
41796
|
create(id, urlSlug, options) {
|
|
41679
41797
|
return new DroppedAsset(this.topia, id, urlSlug, options);
|
|
41680
41798
|
}
|
|
41799
|
+
/**
|
|
41800
|
+
* @summary
|
|
41801
|
+
* Instantiate a new instance of DroppedAsset class and retrieve all properties.
|
|
41802
|
+
*
|
|
41803
|
+
* @usage
|
|
41804
|
+
* ```
|
|
41805
|
+
* const droppedAssetInstance = await DroppedAsset.get(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41806
|
+
* ```
|
|
41807
|
+
*/
|
|
41681
41808
|
get(id, urlSlug, options) {
|
|
41682
41809
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41683
41810
|
const droppedAsset = new DroppedAsset(this.topia, id, urlSlug, options);
|
|
@@ -41685,12 +41812,29 @@ class DroppedAssetFactory extends SDKController {
|
|
|
41685
41812
|
return droppedAsset;
|
|
41686
41813
|
});
|
|
41687
41814
|
}
|
|
41688
|
-
|
|
41815
|
+
/**
|
|
41816
|
+
* @summary
|
|
41817
|
+
* Searches dropped assets within a world by a provide `uniqueName`. If a single match is found, a new instance of DroppedAsset class is returned all properties.
|
|
41818
|
+
*
|
|
41819
|
+
* @usage
|
|
41820
|
+
* ```
|
|
41821
|
+
* const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, { interactivePublicKey, interactiveSecret });
|
|
41822
|
+
* ```
|
|
41823
|
+
*/
|
|
41824
|
+
getWithUniqueName(uniqueName, urlSlug, credentials) {
|
|
41689
41825
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41690
|
-
const
|
|
41826
|
+
const { apiKey, interactivePublicKey, interactiveSecret } = credentials;
|
|
41827
|
+
const params = { apiKey, interactivePublicKey, interactiveSecret, uniqueName, urlSlug };
|
|
41691
41828
|
try {
|
|
41692
|
-
const
|
|
41693
|
-
|
|
41829
|
+
const headers = {};
|
|
41830
|
+
if (apiKey) {
|
|
41831
|
+
headers.Authorization = apiKey;
|
|
41832
|
+
}
|
|
41833
|
+
else if (interactivePublicKey && interactiveSecret) {
|
|
41834
|
+
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
41835
|
+
headers.publickey = interactivePublicKey;
|
|
41836
|
+
}
|
|
41837
|
+
const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers });
|
|
41694
41838
|
const { id } = response.data;
|
|
41695
41839
|
return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
|
|
41696
41840
|
}
|
|
@@ -41699,9 +41843,29 @@ class DroppedAssetFactory extends SDKController {
|
|
|
41699
41843
|
}
|
|
41700
41844
|
});
|
|
41701
41845
|
}
|
|
41702
|
-
|
|
41846
|
+
/**
|
|
41847
|
+
* @summary
|
|
41848
|
+
* Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
|
|
41849
|
+
*
|
|
41850
|
+
* @usage
|
|
41851
|
+
* ```
|
|
41852
|
+
* const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41853
|
+
* const droppedAssetInstance = await DroppedAsset.get(assetInstance, {
|
|
41854
|
+
assetScale: 1.5,
|
|
41855
|
+
flipped: true,
|
|
41856
|
+
layer0: "",
|
|
41857
|
+
layer1: "https://pathtoimage.png",
|
|
41858
|
+
interactivePublicKey,
|
|
41859
|
+
isInteractive: true,
|
|
41860
|
+
position: { x: 0, y: 0 },
|
|
41861
|
+
uniqueName: "exampleUniqueName",
|
|
41862
|
+
urlSlug,
|
|
41863
|
+
});
|
|
41864
|
+
* ```
|
|
41865
|
+
*/
|
|
41866
|
+
drop(asset, { assetScale = 1, flipped, interactivePublicKey, isInteractive, layer0 = "", layer1 = "", position: { x, y }, sceneDropId, text, textColor, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
|
|
41703
41867
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41704
|
-
let specialType;
|
|
41868
|
+
let specialType = null;
|
|
41705
41869
|
if (layer0 || layer1)
|
|
41706
41870
|
specialType = "webImage";
|
|
41707
41871
|
else if (text)
|
|
@@ -41743,14 +41907,38 @@ class DroppedAssetFactory extends SDKController {
|
|
|
41743
41907
|
}
|
|
41744
41908
|
}
|
|
41745
41909
|
|
|
41910
|
+
/**
|
|
41911
|
+
* @usage
|
|
41912
|
+
* ```ts
|
|
41913
|
+
* const Scene = new SceneFactory(myTopiaInstance);
|
|
41914
|
+
* ```
|
|
41915
|
+
*/
|
|
41746
41916
|
class SceneFactory {
|
|
41747
41917
|
constructor(topia) {
|
|
41748
41918
|
this.topia = topia;
|
|
41749
41919
|
this.create;
|
|
41750
41920
|
}
|
|
41921
|
+
/**
|
|
41922
|
+
* @summary
|
|
41923
|
+
* Instantiate a new instance of Scene class.
|
|
41924
|
+
*
|
|
41925
|
+
* @usage
|
|
41926
|
+
* ```
|
|
41927
|
+
* const sceneInstance = await Scene.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41928
|
+
* ```
|
|
41929
|
+
*/
|
|
41751
41930
|
create(id, options) {
|
|
41752
41931
|
return new Scene(this.topia, id, options);
|
|
41753
41932
|
}
|
|
41933
|
+
/**
|
|
41934
|
+
* @summary
|
|
41935
|
+
* Instantiate a new instance of Scene class and retrieve all properties.
|
|
41936
|
+
*
|
|
41937
|
+
* @usage
|
|
41938
|
+
* ```
|
|
41939
|
+
* const sceneInstance = await Scene.get(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41940
|
+
* ```
|
|
41941
|
+
*/
|
|
41754
41942
|
get(id, options) {
|
|
41755
41943
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41756
41944
|
const scene = yield new Scene(this.topia, id, options);
|
|
@@ -41760,22 +41948,61 @@ class SceneFactory {
|
|
|
41760
41948
|
}
|
|
41761
41949
|
}
|
|
41762
41950
|
|
|
41951
|
+
/**
|
|
41952
|
+
* @usage
|
|
41953
|
+
* ```ts
|
|
41954
|
+
* const User = new UserFactory(myTopiaInstance);
|
|
41955
|
+
* ```
|
|
41956
|
+
*/
|
|
41763
41957
|
class UserFactory {
|
|
41764
41958
|
constructor(topia) {
|
|
41765
41959
|
this.topia = topia;
|
|
41766
41960
|
}
|
|
41961
|
+
/**
|
|
41962
|
+
* @summary
|
|
41963
|
+
* Instantiate a new instance of User class.
|
|
41964
|
+
*
|
|
41965
|
+
* @usage
|
|
41966
|
+
* ```
|
|
41967
|
+
* const userInstance = await User.create({ credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41968
|
+
* ```
|
|
41969
|
+
*/
|
|
41767
41970
|
create(options) {
|
|
41768
41971
|
return new User(this.topia, options);
|
|
41769
41972
|
}
|
|
41770
41973
|
}
|
|
41771
41974
|
|
|
41975
|
+
/**
|
|
41976
|
+
* @usage
|
|
41977
|
+
* ```ts
|
|
41978
|
+
* const Visitor = new VisitorFactory(myTopiaInstance);
|
|
41979
|
+
* ```
|
|
41980
|
+
*/
|
|
41772
41981
|
class VisitorFactory {
|
|
41773
41982
|
constructor(topia) {
|
|
41774
41983
|
this.topia = topia;
|
|
41775
41984
|
}
|
|
41985
|
+
/**
|
|
41986
|
+
* @summary
|
|
41987
|
+
* Instantiate a new instance of Visitor class.
|
|
41988
|
+
*
|
|
41989
|
+
* @usage
|
|
41990
|
+
* ```
|
|
41991
|
+
* const visitorInstance = await Visitor.create(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
41992
|
+
* ```
|
|
41993
|
+
*/
|
|
41776
41994
|
create(id, urlSlug, options) {
|
|
41777
41995
|
return new Visitor(this.topia, id, urlSlug, options);
|
|
41778
41996
|
}
|
|
41997
|
+
/**
|
|
41998
|
+
* @summary
|
|
41999
|
+
* Instantiate a new instance of Visitor class and retrieve all properties.
|
|
42000
|
+
*
|
|
42001
|
+
* @usage
|
|
42002
|
+
* ```
|
|
42003
|
+
* const visitorInstance = await Visitor.get(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
42004
|
+
* ```
|
|
42005
|
+
*/
|
|
41779
42006
|
get(id, urlSlug, options) {
|
|
41780
42007
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41781
42008
|
const visitor = new Visitor(this.topia, id, urlSlug, options);
|
|
@@ -41785,39 +42012,85 @@ class VisitorFactory {
|
|
|
41785
42012
|
}
|
|
41786
42013
|
}
|
|
41787
42014
|
|
|
42015
|
+
/**
|
|
42016
|
+
* @usage
|
|
42017
|
+
* ```ts
|
|
42018
|
+
* const WorldActivity = new WorldActivityFactory(myTopiaInstance);
|
|
42019
|
+
* ```
|
|
42020
|
+
*/
|
|
41788
42021
|
class WorldActivityFactory {
|
|
41789
42022
|
constructor(topia) {
|
|
41790
42023
|
this.topia = topia;
|
|
41791
42024
|
}
|
|
42025
|
+
/**
|
|
42026
|
+
* @summary
|
|
42027
|
+
* Instantiate a new instance of WorldActivity class.
|
|
42028
|
+
*
|
|
42029
|
+
* @usage
|
|
42030
|
+
* ```
|
|
42031
|
+
* const worldActivityInstance = await WorldActivity.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
42032
|
+
* ```
|
|
42033
|
+
*/
|
|
41792
42034
|
create(urlSlug, options) {
|
|
41793
42035
|
return new WorldActivity(this.topia, urlSlug, options);
|
|
41794
42036
|
}
|
|
41795
42037
|
}
|
|
41796
42038
|
|
|
42039
|
+
/**
|
|
42040
|
+
* @usage
|
|
42041
|
+
* ```ts
|
|
42042
|
+
* const World = new WorldFactory(myTopiaInstance);
|
|
42043
|
+
* ```
|
|
42044
|
+
*/
|
|
41797
42045
|
class WorldFactory extends SDKController {
|
|
41798
42046
|
constructor(topia) {
|
|
41799
42047
|
super(topia);
|
|
41800
42048
|
}
|
|
42049
|
+
/**
|
|
42050
|
+
* @summary
|
|
42051
|
+
* Instantiate a new instance of World class.
|
|
42052
|
+
*
|
|
42053
|
+
* @usage
|
|
42054
|
+
* ```
|
|
42055
|
+
* const worldInstance = await World.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
|
|
42056
|
+
* ```
|
|
42057
|
+
*/
|
|
41801
42058
|
create(urlSlug, options) {
|
|
41802
42059
|
return new World(this.topia, urlSlug, options);
|
|
41803
42060
|
}
|
|
41804
|
-
|
|
42061
|
+
/**
|
|
42062
|
+
* @summary
|
|
42063
|
+
* Deletes an array of Dropped Assets from within a world and returns success: true
|
|
42064
|
+
*
|
|
42065
|
+
* @usage
|
|
42066
|
+
* ```
|
|
42067
|
+
* await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], { interactiveNonce, interactivePublicKey, visitorId });
|
|
42068
|
+
* ```
|
|
42069
|
+
*/
|
|
42070
|
+
deleteDroppedAssets(urlSlug, droppedAssetIds, credentials) {
|
|
41805
42071
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41806
|
-
const
|
|
42072
|
+
const { apiKey, interactivePublicKey, interactiveSecret } = credentials;
|
|
42073
|
+
const params = { apiKey, droppedAssetIds, interactivePublicKey, interactiveSecret, urlSlug };
|
|
41807
42074
|
try {
|
|
41808
|
-
const
|
|
42075
|
+
const headers = {};
|
|
42076
|
+
if (apiKey) {
|
|
42077
|
+
headers.Authorization = apiKey;
|
|
42078
|
+
}
|
|
42079
|
+
else if (interactivePublicKey && interactiveSecret) {
|
|
42080
|
+
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
42081
|
+
headers.publickey = interactivePublicKey;
|
|
42082
|
+
}
|
|
41809
42083
|
const promiseArray = [];
|
|
41810
42084
|
for (const id of droppedAssetIds) {
|
|
41811
42085
|
promiseArray.push(this.topiaPublicApi().delete(`/world/${urlSlug}/assets/${id}`, {
|
|
41812
|
-
headers
|
|
42086
|
+
headers,
|
|
41813
42087
|
}));
|
|
41814
42088
|
}
|
|
41815
|
-
|
|
41816
|
-
console.log(result);
|
|
42089
|
+
yield Promise.all(promiseArray);
|
|
41817
42090
|
return { success: true };
|
|
41818
42091
|
}
|
|
41819
42092
|
catch (error) {
|
|
41820
|
-
throw this.errorHandler({ error, params, sdkMethod: "
|
|
42093
|
+
throw this.errorHandler({ error, params, sdkMethod: "WorldFactory.deleteDroppedAssets" });
|
|
41821
42094
|
}
|
|
41822
42095
|
});
|
|
41823
42096
|
}
|
package/package.json
CHANGED