@rtsdk/topia 0.1.0 → 0.2.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/dist/index.cjs +168 -25
- package/dist/index.js +169 -26
- package/dist/types/example.d.ts +6 -0
- package/dist/types/src/__mocks__/assets.d.ts +99 -0
- package/dist/{src/__mocks__/index.js → types/src/__mocks__/index.d.ts} +4 -4
- package/dist/types/src/__mocks__/scenes.d.ts +79 -0
- package/dist/types/src/__mocks__/visitors.d.ts +83 -0
- package/dist/types/src/__mocks__/worlds.d.ts +73 -0
- package/dist/types/src/controllers/Asset.d.ts +20 -0
- package/dist/types/src/controllers/DroppedAsset.d.ts +285 -0
- package/dist/types/src/controllers/SDKController.d.ts +48 -0
- package/dist/types/src/controllers/Scene.d.ts +19 -0
- package/dist/types/src/controllers/Topia.d.ts +33 -0
- package/dist/types/src/controllers/User.d.ts +112 -0
- package/dist/types/src/controllers/Visitor.d.ts +101 -0
- package/dist/types/src/controllers/World.d.ts +143 -0
- package/dist/types/src/controllers/WorldActivity.d.ts +83 -0
- package/dist/{src/interfaces/AssetInterfaces.js → types/src/controllers/__tests__/asset.test.d.ts} +1 -1
- package/dist/{src/interfaces/DroppedAssetInterfaces.js → types/src/controllers/__tests__/droppedAsset.test.d.ts} +1 -1
- package/dist/{src/interfaces/SDKInterfaces.js → types/src/controllers/__tests__/scene.test.d.ts} +1 -1
- package/dist/{src/interfaces/SceneInterfaces.js → types/src/controllers/__tests__/user.test.d.ts} +1 -1
- package/dist/types/src/controllers/__tests__/visitor.test.d.ts +1 -0
- package/dist/types/src/controllers/__tests__/world.test.d.ts +1 -0
- package/dist/types/src/controllers/__tests__/worldActivity.test.d.ts +1 -0
- package/dist/{src/controllers/index.js → types/src/controllers/index.d.ts} +9 -9
- package/dist/types/src/factories/AssetFactory.d.ts +8 -0
- package/dist/types/src/factories/DroppedAssetFactory.d.ts +16 -0
- package/dist/types/src/factories/SceneFactory.d.ts +9 -0
- package/dist/types/src/factories/UserFactory.d.ts +8 -0
- package/dist/types/src/factories/VisitorFactory.d.ts +9 -0
- package/dist/types/src/factories/WorldActivityFactory.d.ts +8 -0
- package/dist/types/src/factories/WorldFactory.d.ts +8 -0
- package/dist/{src/factories/index.js → types/src/factories/index.d.ts} +7 -7
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/interfaces/AssetInterfaces.d.ts +26 -0
- package/dist/types/src/interfaces/DroppedAssetInterfaces.d.ts +104 -0
- package/dist/types/src/interfaces/SDKInterfaces.d.ts +8 -0
- package/dist/types/src/interfaces/SceneInterfaces.d.ts +27 -0
- package/dist/types/src/interfaces/TopiaInterfaces.d.ts +10 -0
- package/dist/types/src/interfaces/UserInterfaces.d.ts +7 -0
- package/dist/types/src/interfaces/VisitorInterfaces.d.ts +37 -0
- package/dist/types/src/interfaces/WorldActivityInterfaces.d.ts +11 -0
- package/dist/types/src/interfaces/WorldInterfaces.d.ts +32 -0
- package/dist/{src/interfaces/index.js → types/src/interfaces/index.d.ts} +9 -9
- package/dist/types/src/types/DroppedAssetTypes.d.ts +10 -0
- package/dist/types/src/types/InteractiveCredentialsTypes.d.ts +8 -0
- package/dist/types/src/types/OptionsTypes.d.ts +21 -0
- package/dist/types/src/types/ResponseTypes.d.ts +4 -0
- package/dist/types/src/types/VisitorTypes.d.ts +33 -0
- package/dist/{src/types/index.js → types/src/types/index.d.ts} +5 -4
- package/dist/types/src/utils/__tests__/removeUndefined.test.d.ts +1 -0
- package/dist/types/src/utils/__tests__/scatterVisitors.test.d.ts +1 -0
- package/dist/types/src/utils/getBrowserWarning.d.ts +1 -0
- package/dist/{src/utils/index.js → types/src/utils/index.d.ts} +3 -3
- package/dist/types/src/utils/removeUndefined.d.ts +8 -0
- package/dist/types/src/utils/scatterVisitors.d.ts +4 -0
- package/package.json +2 -2
- package/dist/example.js +0 -32
- package/dist/src/__mocks__/assets.js +0 -249
- package/dist/src/__mocks__/scenes.js +0 -104
- package/dist/src/__mocks__/visitors.js +0 -83
- package/dist/src/__mocks__/worlds.js +0 -52
- package/dist/src/controllers/Asset.js +0 -39
- package/dist/src/controllers/DroppedAsset.js +0 -461
- package/dist/src/controllers/SDKController.js +0 -85
- package/dist/src/controllers/Scene.js +0 -39
- package/dist/src/controllers/Topia.js +0 -39
- package/dist/src/controllers/User.js +0 -139
- package/dist/src/controllers/Visitor.js +0 -92
- package/dist/src/controllers/World.js +0 -256
- package/dist/src/controllers/WorldActivity.js +0 -162
- package/dist/src/controllers/__tests__/asset.test.js +0 -37
- package/dist/src/controllers/__tests__/droppedAsset.test.js +0 -98
- package/dist/src/controllers/__tests__/scene.test.js +0 -38
- package/dist/src/controllers/__tests__/user.test.js +0 -49
- package/dist/src/controllers/__tests__/visitor.test.js +0 -47
- package/dist/src/controllers/__tests__/world.test.js +0 -51
- package/dist/src/controllers/__tests__/worldActivity.test.js +0 -63
- package/dist/src/factories/AssetFactory.js +0 -11
- package/dist/src/factories/DroppedAssetFactory.js +0 -42
- package/dist/src/factories/SceneFactory.js +0 -27
- package/dist/src/factories/UserFactory.js +0 -10
- package/dist/src/factories/VisitorFactory.js +0 -26
- package/dist/src/factories/WorldActivityFactory.js +0 -10
- package/dist/src/factories/WorldFactory.js +0 -10
- package/dist/src/index.js +0 -28
- package/dist/src/interfaces/TopiaInterfaces.js +0 -1
- package/dist/src/interfaces/UserInterfaces.js +0 -1
- package/dist/src/interfaces/VisitorInterfaces.js +0 -1
- package/dist/src/interfaces/WorldActivityInterfaces.js +0 -1
- package/dist/src/interfaces/WorldInterfaces.js +0 -1
- package/dist/src/types/DroppedAssetTypes.js +0 -12
- package/dist/src/types/InteractiveCredentialsTypes.js +0 -1
- package/dist/src/types/OptionsTypes.js +0 -1
- package/dist/src/types/ResponseTypes.js +0 -1
- package/dist/src/types/VisitorTypes.js +0 -1
- package/dist/src/utils/__tests__/removeUndefined.test.js +0 -10
- package/dist/src/utils/__tests__/scatterVisitors.test.js +0 -11
- package/dist/src/utils/getBrowserWarning.js +0 -5
- package/dist/src/utils/removeUndefined.js +0 -11
- package/dist/src/utils/scatterVisitors.js +0 -8
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _DroppedAsset_updateDroppedAsset;
|
|
16
|
-
// controllers
|
|
17
|
-
import { Asset } from "controllers/Asset";
|
|
18
|
-
/**
|
|
19
|
-
* @summary
|
|
20
|
-
* Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
|
|
21
|
-
*
|
|
22
|
-
* @usage
|
|
23
|
-
* ```ts
|
|
24
|
-
* await new DroppedAsset(topia, "1giFZb0sQ3X27L7uGyQX", "example", { attributes: { text: "" }, credentials: { assetId: "1giFZb0sQ3X27L7uGyQX" } } });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export class DroppedAsset extends Asset {
|
|
28
|
-
constructor(topia, id, urlSlug, options = { attributes: { text: "" }, credentials: {} }) {
|
|
29
|
-
var _a;
|
|
30
|
-
super(topia, id, options);
|
|
31
|
-
// update dropped assets
|
|
32
|
-
_DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
try {
|
|
34
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/${updateType}`, Object.assign({}, payload), this.requestOptions);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw this.errorHandler({ error });
|
|
38
|
-
}
|
|
39
|
-
}));
|
|
40
|
-
Object.assign(this, options.attributes);
|
|
41
|
-
this.id = id;
|
|
42
|
-
this.text = (_a = options.attributes) === null || _a === void 0 ? void 0 : _a.text;
|
|
43
|
-
this.urlSlug = urlSlug;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @summary
|
|
47
|
-
* Retrieves dropped asset details.
|
|
48
|
-
*
|
|
49
|
-
* @usage
|
|
50
|
-
* ```ts
|
|
51
|
-
* await droppedAsset.fetchDroppedAssetById();
|
|
52
|
-
* const { assetName } = droppedAsset;
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
fetchDroppedAssetById() {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
try {
|
|
58
|
-
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
|
|
59
|
-
const droppedAssetDetails = response.data;
|
|
60
|
-
droppedAssetDetails.urlSlug = this.urlSlug;
|
|
61
|
-
Object.assign(this, droppedAssetDetails);
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
throw this.errorHandler({ error });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @summary
|
|
70
|
-
* Delete dropped asset.
|
|
71
|
-
*
|
|
72
|
-
* @usage
|
|
73
|
-
* ```ts
|
|
74
|
-
* await droppedAsset.deleteDroppedAsset();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
deleteDroppedAsset() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
try {
|
|
80
|
-
yield this.topiaPublicApi().delete(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
throw this.errorHandler({ error });
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @summary
|
|
89
|
-
* Retrieves the data object for a dropped asset.
|
|
90
|
-
*
|
|
91
|
-
* @usage
|
|
92
|
-
* ```ts
|
|
93
|
-
* await droppedAsset.fetchDroppedAssetDataObject();
|
|
94
|
-
* const { dataObject } = droppedAsset;
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
fetchDroppedAssetDataObject() {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
try {
|
|
100
|
-
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}/data-object`, this.requestOptions);
|
|
101
|
-
this.dataObject = response.data;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
throw this.errorHandler({ error });
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @summary
|
|
110
|
-
* Sets the data object for a dropped asset.
|
|
111
|
-
*
|
|
112
|
-
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
113
|
-
*
|
|
114
|
-
* @usage
|
|
115
|
-
* ```ts
|
|
116
|
-
* await droppedAsset.setDroppedAssetDataObject({
|
|
117
|
-
* "exampleKey": "exampleValue",
|
|
118
|
-
* });
|
|
119
|
-
* const { dataObject } = droppedAsset;
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
setDroppedAssetDataObject(dataObject, options = {}) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
try {
|
|
125
|
-
const { lock = {} } = options;
|
|
126
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
|
|
127
|
-
this.dataObject = dataObject;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
throw this.errorHandler({ error });
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* @summary
|
|
136
|
-
* Updates the data object for a dropped asset.
|
|
137
|
-
*
|
|
138
|
-
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
139
|
-
*
|
|
140
|
-
* @usage
|
|
141
|
-
* ```ts
|
|
142
|
-
* await droppedAsset.updateDroppedAssetDataObject({
|
|
143
|
-
* "exampleKey": "exampleValue",
|
|
144
|
-
* });
|
|
145
|
-
* const { dataObject } = droppedAsset;
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
// get dropped asset
|
|
149
|
-
updateDroppedAssetDataObject(dataObject, options = {}) {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
try {
|
|
152
|
-
const { lock = {} } = options;
|
|
153
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
|
|
154
|
-
this.dataObject = dataObject;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
throw this.errorHandler({ error });
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* @summary
|
|
163
|
-
* Updates broadcast options for a dropped asset.
|
|
164
|
-
*
|
|
165
|
-
* @usage
|
|
166
|
-
* ```ts
|
|
167
|
-
* await droppedAsset.updateBroadcast({
|
|
168
|
-
* assetBroadcast: true,
|
|
169
|
-
* assetBroadcastAll: true,
|
|
170
|
-
* broadcasterEmail: "example@email.com"
|
|
171
|
-
* });
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
updateBroadcast({ assetBroadcast, assetBroadcastAll, broadcasterEmail, }) {
|
|
175
|
-
try {
|
|
176
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetBroadcast, assetBroadcastAll, broadcasterEmail }, "set-asset-broadcast");
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
throw this.errorHandler({ error });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* @summary
|
|
184
|
-
* Updates click options for a dropped asset.
|
|
185
|
-
*
|
|
186
|
-
* @usage
|
|
187
|
-
* ```ts
|
|
188
|
-
* await droppedAsset.updateClickType({
|
|
189
|
-
* "clickType": "portal",
|
|
190
|
-
* "clickableLink": "https://topia.io",
|
|
191
|
-
* "clickableLinkTitle": "My awesome link!",
|
|
192
|
-
* "clickableDisplayTextDescription": "Description",
|
|
193
|
-
* "clickableDisplayTextHeadline": "Title",
|
|
194
|
-
* "position": {
|
|
195
|
-
* "x": 0,
|
|
196
|
-
* "y": 0
|
|
197
|
-
* },
|
|
198
|
-
* "portalName": "community"
|
|
199
|
-
* });
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
updateClickType({ clickType, clickableLink, clickableLinkTitle, clickableDisplayTextDescription, clickableDisplayTextHeadline, portalName, position, }) {
|
|
203
|
-
try {
|
|
204
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, {
|
|
205
|
-
clickType,
|
|
206
|
-
clickableLink,
|
|
207
|
-
clickableLinkTitle,
|
|
208
|
-
clickableDisplayTextDescription,
|
|
209
|
-
clickableDisplayTextHeadline,
|
|
210
|
-
portalName,
|
|
211
|
-
position,
|
|
212
|
-
}, "change-click-type");
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
throw this.errorHandler({ error });
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* @summary
|
|
220
|
-
* Updates text and style of a dropped asset.
|
|
221
|
-
*
|
|
222
|
-
* @usage
|
|
223
|
-
* ```ts
|
|
224
|
-
* const style = {
|
|
225
|
-
* "textColor": "#abc123",
|
|
226
|
-
* "textFontFamily": "Arial",
|
|
227
|
-
* "textSize": 40,
|
|
228
|
-
* "textWeight": "normal",
|
|
229
|
-
* "textWidth": 200
|
|
230
|
-
* };
|
|
231
|
-
* await droppedAsset.updateCustomTextAsset(style, "hello world");
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
updateCustomTextAsset(style, text) {
|
|
235
|
-
try {
|
|
236
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { style, text }, "set-custom-text");
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
throw this.errorHandler({ error });
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* @summary
|
|
244
|
-
* Updates media options for a dropped asset.
|
|
245
|
-
*
|
|
246
|
-
* @usage
|
|
247
|
-
* ```ts
|
|
248
|
-
* await droppedAsset.updateMediaType({
|
|
249
|
-
* "mediaType": "link",
|
|
250
|
-
* "mediaLink": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
|
251
|
-
* "isVideo": true,
|
|
252
|
-
* "syncUserMedia": true,
|
|
253
|
-
* "audioSliderVolume: 30"
|
|
254
|
-
* "portalName": "community",
|
|
255
|
-
* "audioRadius": 0,
|
|
256
|
-
* "mediaName": "string"
|
|
257
|
-
* });
|
|
258
|
-
* ```
|
|
259
|
-
*/
|
|
260
|
-
updateMediaType({ audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia, }) {
|
|
261
|
-
try {
|
|
262
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia }, "change-media-type");
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
throw this.errorHandler({ error });
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* @summary
|
|
270
|
-
* Updates mute zone options for a dropped asset.
|
|
271
|
-
*
|
|
272
|
-
* @usage
|
|
273
|
-
* ```ts
|
|
274
|
-
* await droppedAsset.updateMuteZone(true);
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
updateMuteZone(isMutezone) {
|
|
278
|
-
try {
|
|
279
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isMutezone }, "set-mute-zone");
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
throw this.errorHandler({ error });
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* @summary
|
|
287
|
-
* Updates webhook zone options for a dropped asset.
|
|
288
|
-
*
|
|
289
|
-
* @usage
|
|
290
|
-
* ```ts
|
|
291
|
-
* await droppedAsset.updateWebhookZone(true);
|
|
292
|
-
* ```
|
|
293
|
-
*/
|
|
294
|
-
updateWebhookZone(isWebhookZoneEnabled) {
|
|
295
|
-
try {
|
|
296
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isWebhookZoneEnabled }, "set-webhook-zone");
|
|
297
|
-
}
|
|
298
|
-
catch (error) {
|
|
299
|
-
throw this.errorHandler({ error });
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* @summary
|
|
304
|
-
* Moves a dropped asset to specified coordinates.
|
|
305
|
-
*
|
|
306
|
-
* @usage
|
|
307
|
-
* ```ts
|
|
308
|
-
* await droppedAsset.updatePosition(100,200);
|
|
309
|
-
* ```
|
|
310
|
-
*/
|
|
311
|
-
updatePosition(x, y) {
|
|
312
|
-
try {
|
|
313
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { x, y }, "set-position");
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
throw this.errorHandler({ error });
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* @summary
|
|
321
|
-
* Updates private zone options for a dropped asset.
|
|
322
|
-
*
|
|
323
|
-
* @usage
|
|
324
|
-
* ```ts
|
|
325
|
-
* await droppedAsset.updatePrivateZone({
|
|
326
|
-
* "isPrivateZone": false,
|
|
327
|
-
* "isPrivateZoneChatDisabled": true,
|
|
328
|
-
* "privateZoneUserCap": 10
|
|
329
|
-
* });
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
updatePrivateZone({ isPrivateZone, isPrivateZoneChatDisabled, privateZoneUserCap, }) {
|
|
333
|
-
try {
|
|
334
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isPrivateZone, isPrivateZoneChatDisabled, privateZoneUserCap }, "set-private-zone");
|
|
335
|
-
}
|
|
336
|
-
catch (error) {
|
|
337
|
-
throw this.errorHandler({ error });
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* @summary
|
|
342
|
-
* Updates the size of a dropped asset.
|
|
343
|
-
*
|
|
344
|
-
* @usage
|
|
345
|
-
* ```ts
|
|
346
|
-
* await droppedAsset.assetScale(.5);
|
|
347
|
-
* ```
|
|
348
|
-
*/
|
|
349
|
-
updateScale(assetScale) {
|
|
350
|
-
try {
|
|
351
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetScale }, "change-scale");
|
|
352
|
-
}
|
|
353
|
-
catch (error) {
|
|
354
|
-
throw this.errorHandler({ error });
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* @summary
|
|
359
|
-
* Change or remove media embedded in a dropped asset.
|
|
360
|
-
*
|
|
361
|
-
* @usage
|
|
362
|
-
* ```ts
|
|
363
|
-
* await droppedAsset.updateUploadedMediaSelected("LVWyxwNxI96eLjnXWwYO");
|
|
364
|
-
* ```
|
|
365
|
-
*/
|
|
366
|
-
updateUploadedMediaSelected(mediaId) {
|
|
367
|
-
try {
|
|
368
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { mediaId }, "change-uploaded-media-selected");
|
|
369
|
-
}
|
|
370
|
-
catch (error) {
|
|
371
|
-
throw this.errorHandler({ error });
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* @summary
|
|
376
|
-
* Change or remove top and bottom layers of a dropped asset.
|
|
377
|
-
*
|
|
378
|
-
* @usage
|
|
379
|
-
* ```ts
|
|
380
|
-
* await droppedAsset.updateWebImageLayers("","https://www.shutterstock.com/image-vector/colorful-illustration-test-word-260nw-1438324490.jpg");
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
updateWebImageLayers(bottom, top) {
|
|
384
|
-
try {
|
|
385
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { bottom, top }, "set-webimage-layers");
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
throw this.errorHandler({ error });
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* @summary
|
|
393
|
-
* Add a webhook to a dropped asset
|
|
394
|
-
*
|
|
395
|
-
* @usage
|
|
396
|
-
* ```ts
|
|
397
|
-
* await droppedAsset.addWebhook({
|
|
398
|
-
* active: true,
|
|
399
|
-
* dataObject: {},
|
|
400
|
-
* description: "Webhook desc",
|
|
401
|
-
* enteredBy: "you",
|
|
402
|
-
* isUniqueOnly: false,
|
|
403
|
-
* title: "title",
|
|
404
|
-
* type: "type",
|
|
405
|
-
* url: "https://url.com",
|
|
406
|
-
* urlSlug: "world",
|
|
407
|
-
* });
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
|
|
411
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
412
|
-
try {
|
|
413
|
-
const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
|
|
414
|
-
active: true,
|
|
415
|
-
assetId: this.id,
|
|
416
|
-
dataObject,
|
|
417
|
-
description,
|
|
418
|
-
enteredBy: "",
|
|
419
|
-
isUniqueOnly,
|
|
420
|
-
title,
|
|
421
|
-
type,
|
|
422
|
-
url,
|
|
423
|
-
urlSlug: this.urlSlug,
|
|
424
|
-
}, this.requestOptions);
|
|
425
|
-
return response.data.webhookId;
|
|
426
|
-
}
|
|
427
|
-
catch (error) {
|
|
428
|
-
throw this.errorHandler({ error });
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* @summary
|
|
434
|
-
* Set the interactive settings on a dropped asset
|
|
435
|
-
*
|
|
436
|
-
* @usage
|
|
437
|
-
* ```ts
|
|
438
|
-
* await droppedAsset.setInteractiveSettings({
|
|
439
|
-
* isInteractive: true,
|
|
440
|
-
* interactivePublicKey: "xyz"
|
|
441
|
-
* });
|
|
442
|
-
* ```
|
|
443
|
-
*/
|
|
444
|
-
setInteractiveSettings({ isInteractive = false, interactivePublicKey = "", }) {
|
|
445
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
-
try {
|
|
447
|
-
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-asset-interactive-settings`, {
|
|
448
|
-
interactivePublicKey,
|
|
449
|
-
isInteractive,
|
|
450
|
-
}, this.requestOptions);
|
|
451
|
-
this.isInteractive = isInteractive;
|
|
452
|
-
this.interactivePublicKey = interactivePublicKey;
|
|
453
|
-
}
|
|
454
|
-
catch (error) {
|
|
455
|
-
throw this.errorHandler({ error });
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
_DroppedAsset_updateDroppedAsset = new WeakMap();
|
|
461
|
-
export default DroppedAsset;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// utils
|
|
2
|
-
import jwt from "jsonwebtoken";
|
|
3
|
-
import { AxiosError } from "axios";
|
|
4
|
-
/**
|
|
5
|
-
* @summary
|
|
6
|
-
* Create an instance of SDKController class with credentials.
|
|
7
|
-
*
|
|
8
|
-
* @usage
|
|
9
|
-
* ```ts
|
|
10
|
-
* const credentials = {
|
|
11
|
-
* assetId: "exampleAsset",
|
|
12
|
-
* interactiveNonce: "exampleNonce"
|
|
13
|
-
* interactivePublicKey: "examplePublicKey",
|
|
14
|
-
* visitorId: 1,
|
|
15
|
-
* url: "https://topia.io",
|
|
16
|
-
* }
|
|
17
|
-
* const topia = await new Topia({
|
|
18
|
-
* apiDomain: "api.topia.io",
|
|
19
|
-
* apiKey: "exampleKey",
|
|
20
|
-
* interactiveKey: "key",
|
|
21
|
-
* interactiveSecret: "secret",
|
|
22
|
-
* }
|
|
23
|
-
* await new SDKController({ credentials, topia });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export class SDKController {
|
|
27
|
-
constructor(topia, credentials = {}) {
|
|
28
|
-
const { assetId, interactiveNonce, visitorId, apiKey } = credentials;
|
|
29
|
-
this.topia = topia;
|
|
30
|
-
this.credentials = credentials;
|
|
31
|
-
this.requestOptions = {};
|
|
32
|
-
let payload = {};
|
|
33
|
-
const headers = {};
|
|
34
|
-
if (visitorId && assetId && interactiveNonce) {
|
|
35
|
-
payload = {
|
|
36
|
-
interactiveNonce,
|
|
37
|
-
visitorId,
|
|
38
|
-
assetId,
|
|
39
|
-
};
|
|
40
|
-
this.jwt = jwt.sign(payload, topia.interactiveSecret);
|
|
41
|
-
headers.InteractiveJWT = this.jwt;
|
|
42
|
-
}
|
|
43
|
-
if (apiKey) {
|
|
44
|
-
headers.Authorization = apiKey;
|
|
45
|
-
}
|
|
46
|
-
this.requestOptions = { headers };
|
|
47
|
-
}
|
|
48
|
-
topiaPublicApi() {
|
|
49
|
-
return this.topia.axios;
|
|
50
|
-
}
|
|
51
|
-
errorHandler({ error, message = "Something went wrong. Please try again or contact support.", }) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
const stackTrace = new Error("Thrown here:");
|
|
54
|
-
let data = {}, errorMessage = message, method = "unknown", stack = "empty", status = 500, url = "unknown";
|
|
55
|
-
if (error instanceof AxiosError) {
|
|
56
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
|
|
57
|
-
if (error.response) {
|
|
58
|
-
status = error.response.status;
|
|
59
|
-
data = error.response.data;
|
|
60
|
-
if (error.response.data.errors)
|
|
61
|
-
errorMessage = error.response.data.errors[0].message;
|
|
62
|
-
}
|
|
63
|
-
if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.url)
|
|
64
|
-
url = error.config.url;
|
|
65
|
-
if ((_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method)
|
|
66
|
-
method = error.config.method;
|
|
67
|
-
stack = `${error.stack}\n${stackTrace.stack}`;
|
|
68
|
-
}
|
|
69
|
-
else if (error instanceof Error) {
|
|
70
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
|
|
71
|
-
stack = `${error.stack}\n${stackTrace.stack}`;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
data,
|
|
75
|
-
message: errorMessage,
|
|
76
|
-
method,
|
|
77
|
-
stack,
|
|
78
|
-
stackTrace,
|
|
79
|
-
status,
|
|
80
|
-
success: false,
|
|
81
|
-
url,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export default SDKController;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
// controllers
|
|
11
|
-
import { SDKController } from "controllers/SDKController";
|
|
12
|
-
/**
|
|
13
|
-
* @summary
|
|
14
|
-
* Create an instance of Scene class with a given scene id and optional attributes and session credentials.
|
|
15
|
-
*
|
|
16
|
-
* @usage
|
|
17
|
-
* ```ts
|
|
18
|
-
* await new Scene(topia, "sceneId", { attributes: { name: "My Scene" } });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export class Scene extends SDKController {
|
|
22
|
-
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
23
|
-
super(topia, options.credentials);
|
|
24
|
-
this.id = id;
|
|
25
|
-
Object.assign(this, options.attributes);
|
|
26
|
-
}
|
|
27
|
-
fetchSceneById() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
try {
|
|
30
|
-
const response = yield this.topiaPublicApi().get(`/scenes/${this.id}`, this.requestOptions);
|
|
31
|
-
Object.assign(this, response.data);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
throw this.errorHandler({ error });
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default Scene;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
// utils
|
|
3
|
-
import { getBrowserWarning } from "utils";
|
|
4
|
-
/**
|
|
5
|
-
* @summary
|
|
6
|
-
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
7
|
-
*
|
|
8
|
-
* @usage
|
|
9
|
-
* ```ts
|
|
10
|
-
* const topia = await new Topia({
|
|
11
|
-
* apiDomain: "api.topia.io",
|
|
12
|
-
* apiKey: "exampleKey",
|
|
13
|
-
* interactiveKey: "key",
|
|
14
|
-
* interactiveSecret: "secret",
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class Topia {
|
|
19
|
-
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, }) {
|
|
20
|
-
getBrowserWarning();
|
|
21
|
-
this.apiDomain = apiDomain || "api.topia.io";
|
|
22
|
-
this.apiKey = apiKey;
|
|
23
|
-
this.apiProtocol = apiProtocol || "https";
|
|
24
|
-
this.interactiveSecret = interactiveSecret;
|
|
25
|
-
const headers = {
|
|
26
|
-
"ApplicationId": "sdk-js-topia",
|
|
27
|
-
"Content-Type": "application/json",
|
|
28
|
-
};
|
|
29
|
-
if (apiKey)
|
|
30
|
-
headers.Authorization = apiKey;
|
|
31
|
-
if (interactiveKey)
|
|
32
|
-
headers.PublicKey = interactiveKey;
|
|
33
|
-
this.axios = axios.create({
|
|
34
|
-
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
35
|
-
headers,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default Topia;
|