@rtsdk/topia 0.18.3 → 0.19.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 +1 -5
- package/dist/index.cjs +87 -5
- package/dist/index.d.ts +80 -27
- package/dist/index.js +87 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -317,8 +317,6 @@ Once complete be sure to also call `await keyAsset.updateDataObject({ turnCount:
|
|
|
317
317
|
|
|
318
318
|
You can leverage the data object methods for all types to track analytics unique to your Public Key by passing `analytics` as an optional array along with `profileId`, `urlSlug`, and/or `uniqueKey` to all calls that set, update, or increment data objects!
|
|
319
319
|
|
|
320
|
-
**World** and **Dropped Asset** classes will automatically include `urlSlug`. In addition to `analytics` you can also pass `profileId` if you want to track event per user and/or a `uniqueKey` to additionally track uniqueness of the event for all time, per user (if `profileId` is included), and per world.
|
|
321
|
-
|
|
322
320
|
Examples leveraging World data objects calls:
|
|
323
321
|
|
|
324
322
|
```ts
|
|
@@ -329,8 +327,6 @@ await world.updateDataObject({}, { analytics: [ {analyticName: "matches", unique
|
|
|
329
327
|
await world.incrementDataObjectValue(`keyAssets.${assetId}.completions`, 1, { analytics: [{ analyticName:"completions", incrementBy: 2, profileId, uniqueKey: profileId, urlSlug }] });
|
|
330
328
|
```
|
|
331
329
|
|
|
332
|
-
**Visitor** and **User** classes will automatically include `profileId`. In addition to `analytics` you can also pass `urlSlug` if you want to track event per world and/or a `uniqueKey` to additionally track uniqueness of the event for all time, per user, and per world (if `urlSlug` is included).
|
|
333
|
-
|
|
334
330
|
Examples leveraging Visitor data objects calls:
|
|
335
331
|
|
|
336
332
|
```ts
|
|
@@ -349,7 +345,7 @@ await visitor.incrementDataObjectValue(`completions`, 1, {
|
|
|
349
345
|
});
|
|
350
346
|
```
|
|
351
347
|
|
|
352
|
-
Note:
|
|
348
|
+
Note: passing an empty object does NOT impact the data objects themselves but rather allows you to track custom analytics (incremented by 1) across all instances of your application with a given Public Key.
|
|
353
349
|
|
|
354
350
|
<br>
|
|
355
351
|
|
package/dist/index.cjs
CHANGED
|
@@ -42701,7 +42701,7 @@ class User extends SDKController {
|
|
|
42701
42701
|
* await user.modifyInventoryItemQuantity("item-id-123", 5);
|
|
42702
42702
|
* ```
|
|
42703
42703
|
*
|
|
42704
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
42704
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
42705
42705
|
*/
|
|
42706
42706
|
modifyInventoryItemQuantity(item, quantity) {
|
|
42707
42707
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43287,7 +43287,7 @@ class Visitor extends User {
|
|
|
43287
43287
|
* const items = await visitor.fetchInventoryItems();
|
|
43288
43288
|
* ```
|
|
43289
43289
|
*
|
|
43290
|
-
* @returns {Promise<void>} Returns
|
|
43290
|
+
* @returns {Promise<void>} Returns a new instance of InventoryItem.
|
|
43291
43291
|
*/
|
|
43292
43292
|
fetchInventoryItem(item) {
|
|
43293
43293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43303,6 +43303,88 @@ class Visitor extends User {
|
|
|
43303
43303
|
}
|
|
43304
43304
|
});
|
|
43305
43305
|
}
|
|
43306
|
+
/**
|
|
43307
|
+
* Gets an NPC for this visitor, if one exists.
|
|
43308
|
+
*
|
|
43309
|
+
* @example
|
|
43310
|
+
* ```ts
|
|
43311
|
+
* await visitor.getNpc();
|
|
43312
|
+
* ```
|
|
43313
|
+
*
|
|
43314
|
+
* @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC.
|
|
43315
|
+
*/
|
|
43316
|
+
getNpc() {
|
|
43317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43318
|
+
try {
|
|
43319
|
+
const visitorResponse = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-npc`, this.requestOptions);
|
|
43320
|
+
if (visitorResponse.data)
|
|
43321
|
+
return new Visitor(this.topia, visitorResponse.data.playerId, this.urlSlug, {
|
|
43322
|
+
attributes: visitorResponse.data,
|
|
43323
|
+
credentials: this.credentials,
|
|
43324
|
+
});
|
|
43325
|
+
return null;
|
|
43326
|
+
}
|
|
43327
|
+
catch (error) {
|
|
43328
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.getNpc" });
|
|
43329
|
+
}
|
|
43330
|
+
});
|
|
43331
|
+
}
|
|
43332
|
+
/**
|
|
43333
|
+
* Creates an NPC that follows this visitor using an inventory item the visitor owns.
|
|
43334
|
+
* One NPC is allowed per visitor, per application public key.
|
|
43335
|
+
*
|
|
43336
|
+
* @param userInventoryItemId The ID of the user's inventory item (must be an NPC type item owned by this visitor).
|
|
43337
|
+
* @param options Optional configuration for the NPC.
|
|
43338
|
+
* @param options.showNameplate Whether to display a nameplate above the NPC (default: true).
|
|
43339
|
+
*
|
|
43340
|
+
* @example
|
|
43341
|
+
* ```ts
|
|
43342
|
+
* // First, grant the NPC item to the visitor
|
|
43343
|
+
* const userItem = await visitor.grantInventoryItem(npcInventoryItem, 1);
|
|
43344
|
+
*
|
|
43345
|
+
* // Then create the NPC using the granted item
|
|
43346
|
+
* const npc = await visitor.createNpc(userItem.id);
|
|
43347
|
+
*
|
|
43348
|
+
* // Or create without a nameplate
|
|
43349
|
+
* const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
|
|
43350
|
+
* ```
|
|
43351
|
+
*
|
|
43352
|
+
* @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC.
|
|
43353
|
+
*/
|
|
43354
|
+
createNpc(userInventoryItemId, options) {
|
|
43355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43356
|
+
try {
|
|
43357
|
+
const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/visitors/${this.id}/create-npc`, { userInventoryItemId, showNameplate: options === null || options === void 0 ? void 0 : options.showNameplate }, this.requestOptions);
|
|
43358
|
+
return new Visitor(this.topia, response.data.player.playerId, this.urlSlug, {
|
|
43359
|
+
attributes: response.data,
|
|
43360
|
+
credentials: this.credentials,
|
|
43361
|
+
});
|
|
43362
|
+
}
|
|
43363
|
+
catch (error) {
|
|
43364
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.createNpc" });
|
|
43365
|
+
}
|
|
43366
|
+
});
|
|
43367
|
+
}
|
|
43368
|
+
/**
|
|
43369
|
+
* Deletes the NPC this app has assigned to this visitor.
|
|
43370
|
+
*
|
|
43371
|
+
* @example
|
|
43372
|
+
* ```ts
|
|
43373
|
+
* await visitor.deleteNpc();
|
|
43374
|
+
* ```
|
|
43375
|
+
*
|
|
43376
|
+
* @returns {Promise<void>} Returns nothing if successful.
|
|
43377
|
+
*/
|
|
43378
|
+
deleteNpc() {
|
|
43379
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43380
|
+
try {
|
|
43381
|
+
yield this.topiaPublicApi().delete(`/world/${this.urlSlug}/visitors/${this.id}/delete-npc`, this.requestOptions);
|
|
43382
|
+
}
|
|
43383
|
+
catch (error) {
|
|
43384
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.deleteNpc" });
|
|
43385
|
+
}
|
|
43386
|
+
});
|
|
43387
|
+
}
|
|
43306
43388
|
/**
|
|
43307
43389
|
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43308
43390
|
*
|
|
@@ -43348,7 +43430,7 @@ class Visitor extends User {
|
|
|
43348
43430
|
* await visitor.grantInventoryItem("item-id-123", 2);
|
|
43349
43431
|
* ```
|
|
43350
43432
|
*
|
|
43351
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43433
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
43352
43434
|
*/
|
|
43353
43435
|
grantInventoryItem(item, quantity = 1) {
|
|
43354
43436
|
var _a;
|
|
@@ -43383,7 +43465,7 @@ class Visitor extends User {
|
|
|
43383
43465
|
* await visitor.modifyInventoryItemQuantity("item-id-123", 5);
|
|
43384
43466
|
* ```
|
|
43385
43467
|
*
|
|
43386
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43468
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
43387
43469
|
*/
|
|
43388
43470
|
modifyInventoryItemQuantity(item, quantity) {
|
|
43389
43471
|
var _a;
|
|
@@ -44811,7 +44893,7 @@ class WorldFactory extends SDKController {
|
|
|
44811
44893
|
headers,
|
|
44812
44894
|
}));
|
|
44813
44895
|
}
|
|
44814
|
-
yield Promise.
|
|
44896
|
+
yield Promise.allSettled(promiseArray);
|
|
44815
44897
|
return { success: true };
|
|
44816
44898
|
}
|
|
44817
44899
|
catch (error) {
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ type DroppedAssetLinkType = {
|
|
|
74
74
|
linkSamlQueryParams?: string;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
type InteractiveCredentials = {
|
|
77
|
+
type InteractiveCredentials$1 = {
|
|
78
78
|
apiKey?: string;
|
|
79
79
|
assetId?: string;
|
|
80
80
|
interactiveNonce?: string;
|
|
@@ -88,22 +88,22 @@ type InteractiveCredentials = {
|
|
|
88
88
|
|
|
89
89
|
type AssetOptions = {
|
|
90
90
|
attributes?: AssetInterface | undefined;
|
|
91
|
-
credentials?: InteractiveCredentials | undefined;
|
|
91
|
+
credentials?: InteractiveCredentials$1 | undefined;
|
|
92
92
|
};
|
|
93
93
|
type DroppedAssetOptions = {
|
|
94
94
|
attributes?: DroppedAssetInterface | undefined;
|
|
95
|
-
credentials?: InteractiveCredentials | undefined;
|
|
95
|
+
credentials?: InteractiveCredentials$1 | undefined;
|
|
96
96
|
};
|
|
97
97
|
type UserOptions = {
|
|
98
|
-
credentials?: InteractiveCredentials | undefined;
|
|
98
|
+
credentials?: InteractiveCredentials$1 | undefined;
|
|
99
99
|
};
|
|
100
100
|
type VisitorOptions = {
|
|
101
101
|
attributes?: VisitorInterface | undefined;
|
|
102
|
-
credentials?: InteractiveCredentials | undefined;
|
|
102
|
+
credentials?: InteractiveCredentials$1 | undefined;
|
|
103
103
|
};
|
|
104
104
|
type WorldOptions = {
|
|
105
105
|
attributes?: WorldDetailsInterface | undefined;
|
|
106
|
-
credentials?: InteractiveCredentials | undefined;
|
|
106
|
+
credentials?: InteractiveCredentials$1 | undefined;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
type ResponseType$1 = {
|
|
@@ -1719,7 +1719,7 @@ declare class User extends SDKController implements UserInterface {
|
|
|
1719
1719
|
* await user.modifyInventoryItemQuantity("item-id-123", 5);
|
|
1720
1720
|
* ```
|
|
1721
1721
|
*
|
|
1722
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
1722
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
1723
1723
|
*/
|
|
1724
1724
|
modifyInventoryItemQuantity(item: UserInventoryItem, quantity: number): Promise<UserInventoryItem>;
|
|
1725
1725
|
}
|
|
@@ -2063,9 +2063,56 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
2063
2063
|
* const items = await visitor.fetchInventoryItems();
|
|
2064
2064
|
* ```
|
|
2065
2065
|
*
|
|
2066
|
-
* @returns {Promise<void>} Returns
|
|
2066
|
+
* @returns {Promise<void>} Returns a new instance of InventoryItem.
|
|
2067
2067
|
*/
|
|
2068
2068
|
fetchInventoryItem(item: InventoryItem): Promise<UserInventoryItem>;
|
|
2069
|
+
/**
|
|
2070
|
+
* Gets an NPC for this visitor, if one exists.
|
|
2071
|
+
*
|
|
2072
|
+
* @example
|
|
2073
|
+
* ```ts
|
|
2074
|
+
* await visitor.getNpc();
|
|
2075
|
+
* ```
|
|
2076
|
+
*
|
|
2077
|
+
* @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC.
|
|
2078
|
+
*/
|
|
2079
|
+
getNpc(): Promise<Visitor | null>;
|
|
2080
|
+
/**
|
|
2081
|
+
* Creates an NPC that follows this visitor using an inventory item the visitor owns.
|
|
2082
|
+
* One NPC is allowed per visitor, per application public key.
|
|
2083
|
+
*
|
|
2084
|
+
* @param userInventoryItemId The ID of the user's inventory item (must be an NPC type item owned by this visitor).
|
|
2085
|
+
* @param options Optional configuration for the NPC.
|
|
2086
|
+
* @param options.showNameplate Whether to display a nameplate above the NPC (default: true).
|
|
2087
|
+
*
|
|
2088
|
+
* @example
|
|
2089
|
+
* ```ts
|
|
2090
|
+
* // First, grant the NPC item to the visitor
|
|
2091
|
+
* const userItem = await visitor.grantInventoryItem(npcInventoryItem, 1);
|
|
2092
|
+
*
|
|
2093
|
+
* // Then create the NPC using the granted item
|
|
2094
|
+
* const npc = await visitor.createNpc(userItem.id);
|
|
2095
|
+
*
|
|
2096
|
+
* // Or create without a nameplate
|
|
2097
|
+
* const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
|
|
2098
|
+
* ```
|
|
2099
|
+
*
|
|
2100
|
+
* @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC.
|
|
2101
|
+
*/
|
|
2102
|
+
createNpc(userInventoryItemId: string, options?: {
|
|
2103
|
+
showNameplate?: boolean;
|
|
2104
|
+
}): Promise<Visitor>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Deletes the NPC this app has assigned to this visitor.
|
|
2107
|
+
*
|
|
2108
|
+
* @example
|
|
2109
|
+
* ```ts
|
|
2110
|
+
* await visitor.deleteNpc();
|
|
2111
|
+
* ```
|
|
2112
|
+
*
|
|
2113
|
+
* @returns {Promise<void>} Returns nothing if successful.
|
|
2114
|
+
*/
|
|
2115
|
+
deleteNpc(): Promise<void>;
|
|
2069
2116
|
/**
|
|
2070
2117
|
* Retrieves all inventory items owned by this visitor and app's key.
|
|
2071
2118
|
*
|
|
@@ -2091,7 +2138,7 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
2091
2138
|
* await visitor.grantInventoryItem("item-id-123", 2);
|
|
2092
2139
|
* ```
|
|
2093
2140
|
*
|
|
2094
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
2141
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
2095
2142
|
*/
|
|
2096
2143
|
grantInventoryItem(item: InventoryItem, quantity?: number): Promise<UserInventoryItem>;
|
|
2097
2144
|
/**
|
|
@@ -2105,7 +2152,7 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
2105
2152
|
* await visitor.modifyInventoryItemQuantity("item-id-123", 5);
|
|
2106
2153
|
* ```
|
|
2107
2154
|
*
|
|
2108
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
2155
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
2109
2156
|
*/
|
|
2110
2157
|
modifyInventoryItemQuantity(item: UserInventoryItem, quantity: number): Promise<UserInventoryItem>;
|
|
2111
2158
|
}
|
|
@@ -2150,7 +2197,7 @@ declare enum WorldActivityType {
|
|
|
2150
2197
|
}
|
|
2151
2198
|
|
|
2152
2199
|
interface SDKInterface {
|
|
2153
|
-
credentials?: InteractiveCredentials;
|
|
2200
|
+
credentials?: InteractiveCredentials$1;
|
|
2154
2201
|
jwt?: string;
|
|
2155
2202
|
requestOptions: object;
|
|
2156
2203
|
topia: Topia;
|
|
@@ -2187,7 +2234,7 @@ interface AssetInterface extends SDKInterface {
|
|
|
2187
2234
|
}
|
|
2188
2235
|
type AssetOptionalInterface = {
|
|
2189
2236
|
attributes?: AssetInterface | object;
|
|
2190
|
-
credentials?: InteractiveCredentials;
|
|
2237
|
+
credentials?: InteractiveCredentials$1;
|
|
2191
2238
|
};
|
|
2192
2239
|
|
|
2193
2240
|
interface DroppedAssetInterface extends AssetInterface {
|
|
@@ -2309,7 +2356,7 @@ interface DroppedAssetOptionalInterface {
|
|
|
2309
2356
|
text?: string;
|
|
2310
2357
|
urlSlug?: string;
|
|
2311
2358
|
};
|
|
2312
|
-
credentials?: InteractiveCredentials | object;
|
|
2359
|
+
credentials?: InteractiveCredentials$1 | object;
|
|
2313
2360
|
}
|
|
2314
2361
|
interface UpdateBroadcastInterface {
|
|
2315
2362
|
assetBroadcast?: boolean;
|
|
@@ -2401,7 +2448,7 @@ interface EcosystemInterface {
|
|
|
2401
2448
|
incrementDataObjectValue(path: string, amount: number, options: object): Promise<void | ResponseType$1>;
|
|
2402
2449
|
}
|
|
2403
2450
|
interface EcosystemOptionalInterface {
|
|
2404
|
-
credentials?: InteractiveCredentials;
|
|
2451
|
+
credentials?: InteractiveCredentials$1;
|
|
2405
2452
|
}
|
|
2406
2453
|
|
|
2407
2454
|
interface SceneInterface {
|
|
@@ -2429,7 +2476,7 @@ interface SceneInterface {
|
|
|
2429
2476
|
}
|
|
2430
2477
|
type SceneOptionalInterface = {
|
|
2431
2478
|
attributes?: SceneInterface | object;
|
|
2432
|
-
credentials?: InteractiveCredentials;
|
|
2479
|
+
credentials?: InteractiveCredentials$1;
|
|
2433
2480
|
};
|
|
2434
2481
|
|
|
2435
2482
|
interface FireToastInterface {
|
|
@@ -2468,6 +2515,7 @@ interface UserInterface {
|
|
|
2468
2515
|
}): Promise<ResponseType$1>;
|
|
2469
2516
|
fetchDataObject(appPublicKey?: string, appJWT?: string): Promise<void | ResponseType$1>;
|
|
2470
2517
|
setDataObject(dataObject: object | null | undefined, options: object): Promise<void | ResponseType$1>;
|
|
2518
|
+
updateDataObject(dataObject: object, options: object): Promise<void | ResponseType$1>;
|
|
2471
2519
|
incrementDataObjectValue(path: string, amount: number, options: object): Promise<void | ResponseType$1>;
|
|
2472
2520
|
fetchInventoryItems(): Promise<void>;
|
|
2473
2521
|
inventoryItems: UserInventoryItem[];
|
|
@@ -2476,7 +2524,7 @@ interface UserInterface {
|
|
|
2476
2524
|
dataObject?: object | null;
|
|
2477
2525
|
}
|
|
2478
2526
|
interface UserOptionalInterface {
|
|
2479
|
-
credentials?: InteractiveCredentials;
|
|
2527
|
+
credentials?: InteractiveCredentials$1;
|
|
2480
2528
|
profileId?: string | null;
|
|
2481
2529
|
visitorId?: number | null;
|
|
2482
2530
|
urlSlug?: string;
|
|
@@ -2504,6 +2552,11 @@ interface VisitorInterface extends SDKInterface {
|
|
|
2504
2552
|
grantInventoryItem(item: InventoryItem, quantity: number): Promise<UserInventoryItem>;
|
|
2505
2553
|
modifyInventoryItemQuantity(item: UserInventoryItem, quantity: number): Promise<UserInventoryItem>;
|
|
2506
2554
|
fetchInventoryItem(item: InventoryItem): Promise<UserInventoryItem>;
|
|
2555
|
+
createNpc(userInventoryItemId: string, options?: {
|
|
2556
|
+
showNameplate?: boolean;
|
|
2557
|
+
}): Promise<Visitor>;
|
|
2558
|
+
deleteNpc(): Promise<void>;
|
|
2559
|
+
getNpc(): Promise<Visitor | null>;
|
|
2507
2560
|
triggerParticle({ id, name, duration, }: {
|
|
2508
2561
|
id?: string;
|
|
2509
2562
|
name?: string;
|
|
@@ -2547,7 +2600,7 @@ interface VisitorInterface extends SDKInterface {
|
|
|
2547
2600
|
}
|
|
2548
2601
|
interface VisitorOptionalInterface {
|
|
2549
2602
|
attributes?: VisitorInterface | object;
|
|
2550
|
-
credentials?: InteractiveCredentials;
|
|
2603
|
+
credentials?: InteractiveCredentials$1;
|
|
2551
2604
|
}
|
|
2552
2605
|
interface MoveVisitorInterface {
|
|
2553
2606
|
shouldTeleportVisitor: boolean;
|
|
@@ -2580,12 +2633,12 @@ interface WebRTCConnectorInterface {
|
|
|
2580
2633
|
getTwilioConfig(): Promise<void | ResponseType$1>;
|
|
2581
2634
|
}
|
|
2582
2635
|
interface WebRTCConnectorOptionalInterface {
|
|
2583
|
-
credentials?: InteractiveCredentials;
|
|
2636
|
+
credentials?: InteractiveCredentials$1;
|
|
2584
2637
|
twilioConfig?: object;
|
|
2585
2638
|
}
|
|
2586
2639
|
|
|
2587
2640
|
interface WorldActivityOptionalInterface {
|
|
2588
|
-
credentials?: InteractiveCredentials;
|
|
2641
|
+
credentials?: InteractiveCredentials$1;
|
|
2589
2642
|
}
|
|
2590
2643
|
interface MoveAllVisitorsInterface {
|
|
2591
2644
|
shouldFetchVisitors?: boolean;
|
|
@@ -2675,13 +2728,13 @@ interface WorldInterface extends SDKInterface, WorldDetailsInterface {
|
|
|
2675
2728
|
}
|
|
2676
2729
|
interface WorldOptionalInterface {
|
|
2677
2730
|
attributes?: WorldDetailsInterface | object;
|
|
2678
|
-
credentials?: InteractiveCredentials;
|
|
2731
|
+
credentials?: InteractiveCredentials$1;
|
|
2679
2732
|
}
|
|
2680
2733
|
interface WorldWebhooksInterface {
|
|
2681
2734
|
webhooks: Array<WebhookInterface>;
|
|
2682
2735
|
}
|
|
2683
2736
|
|
|
2684
|
-
type InteractiveCredentials
|
|
2737
|
+
type InteractiveCredentials = {
|
|
2685
2738
|
apiKey?: string;
|
|
2686
2739
|
assetId?: string;
|
|
2687
2740
|
interactiveNonce?: string;
|
|
@@ -2710,7 +2763,7 @@ interface InventoryItemInterface extends SDKInterface {
|
|
|
2710
2763
|
}
|
|
2711
2764
|
type InventoryItemOptionalInterface = {
|
|
2712
2765
|
attributes?: InventoryItemInterface | object;
|
|
2713
|
-
credentials?: InteractiveCredentials
|
|
2766
|
+
credentials?: InteractiveCredentials;
|
|
2714
2767
|
};
|
|
2715
2768
|
|
|
2716
2769
|
/**
|
|
@@ -2728,7 +2781,7 @@ interface UserInventoryItemInterface extends InventoryItemInterface {
|
|
|
2728
2781
|
}
|
|
2729
2782
|
type UserInventoryItemOptionalInterface = {
|
|
2730
2783
|
attributes?: UserInventoryItemInterface | object;
|
|
2731
|
-
credentials?: InteractiveCredentials
|
|
2784
|
+
credentials?: InteractiveCredentials;
|
|
2732
2785
|
};
|
|
2733
2786
|
|
|
2734
2787
|
/**
|
|
@@ -2784,11 +2837,11 @@ declare class Topia implements TopiaInterface {
|
|
|
2784
2837
|
* ```
|
|
2785
2838
|
*/
|
|
2786
2839
|
declare abstract class SDKController implements SDKInterface {
|
|
2787
|
-
credentials: InteractiveCredentials | undefined;
|
|
2840
|
+
credentials: InteractiveCredentials$1 | undefined;
|
|
2788
2841
|
jwt?: string;
|
|
2789
2842
|
requestOptions: object;
|
|
2790
2843
|
topia: Topia;
|
|
2791
|
-
constructor(topia: Topia, credentials?: InteractiveCredentials);
|
|
2844
|
+
constructor(topia: Topia, credentials?: InteractiveCredentials$1);
|
|
2792
2845
|
topiaPublicApi(): axios.AxiosInstance;
|
|
2793
2846
|
errorHandler({ error, message, params, sdkMethod, }: {
|
|
2794
2847
|
error?: Error | AxiosError | unknown;
|
|
@@ -3368,7 +3421,7 @@ declare class DroppedAssetFactory extends SDKController {
|
|
|
3368
3421
|
*
|
|
3369
3422
|
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
|
|
3370
3423
|
*/
|
|
3371
|
-
getWithUniqueName(uniqueName: string, urlSlug: string, interactiveSecret: string, credentials: InteractiveCredentials): Promise<DroppedAsset>;
|
|
3424
|
+
getWithUniqueName(uniqueName: string, urlSlug: string, interactiveSecret: string, credentials: InteractiveCredentials$1): Promise<DroppedAsset>;
|
|
3372
3425
|
/**
|
|
3373
3426
|
* Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
|
|
3374
3427
|
*
|
|
@@ -3950,4 +4003,4 @@ declare class WorldFactory extends SDKController {
|
|
|
3950
4003
|
}>;
|
|
3951
4004
|
}
|
|
3952
4005
|
|
|
3953
|
-
export { AnalyticType, AnimationMetaType, Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetLinkType, DroppedAssetMediaType, DroppedAssetMediaVolumeRadius, DroppedAssetOptionalInterface, DroppedAssetOptions, Ecosystem, EcosystemFactory, EcosystemInterface, EcosystemOptionalInterface, FireToastInterface, FrameType, InteractiveCredentials, InventoryItemInterface, InventoryItemOptionalInterface, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, RemoveClickableLinkInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, SetClickableLinkMultiInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateClickableLinkMultiInterface, UpdateDroppedAssetInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserInventoryItemInterface, UserInventoryItemOptionalInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldActivityType, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
|
4006
|
+
export { AnalyticType, AnimationMetaType, Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetLinkType, DroppedAssetMediaType, DroppedAssetMediaVolumeRadius, DroppedAssetOptionalInterface, DroppedAssetOptions, Ecosystem, EcosystemFactory, EcosystemInterface, EcosystemOptionalInterface, FireToastInterface, FrameType, InteractiveCredentials$1 as InteractiveCredentials, InventoryItemInterface, InventoryItemOptionalInterface, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, RemoveClickableLinkInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, SetClickableLinkMultiInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateClickableLinkMultiInterface, UpdateDroppedAssetInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserInventoryItemInterface, UserInventoryItemOptionalInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldActivityType, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
package/dist/index.js
CHANGED
|
@@ -42699,7 +42699,7 @@ class User extends SDKController {
|
|
|
42699
42699
|
* await user.modifyInventoryItemQuantity("item-id-123", 5);
|
|
42700
42700
|
* ```
|
|
42701
42701
|
*
|
|
42702
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
42702
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
42703
42703
|
*/
|
|
42704
42704
|
modifyInventoryItemQuantity(item, quantity) {
|
|
42705
42705
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43285,7 +43285,7 @@ class Visitor extends User {
|
|
|
43285
43285
|
* const items = await visitor.fetchInventoryItems();
|
|
43286
43286
|
* ```
|
|
43287
43287
|
*
|
|
43288
|
-
* @returns {Promise<void>} Returns
|
|
43288
|
+
* @returns {Promise<void>} Returns a new instance of InventoryItem.
|
|
43289
43289
|
*/
|
|
43290
43290
|
fetchInventoryItem(item) {
|
|
43291
43291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43301,6 +43301,88 @@ class Visitor extends User {
|
|
|
43301
43301
|
}
|
|
43302
43302
|
});
|
|
43303
43303
|
}
|
|
43304
|
+
/**
|
|
43305
|
+
* Gets an NPC for this visitor, if one exists.
|
|
43306
|
+
*
|
|
43307
|
+
* @example
|
|
43308
|
+
* ```ts
|
|
43309
|
+
* await visitor.getNpc();
|
|
43310
|
+
* ```
|
|
43311
|
+
*
|
|
43312
|
+
* @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC.
|
|
43313
|
+
*/
|
|
43314
|
+
getNpc() {
|
|
43315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43316
|
+
try {
|
|
43317
|
+
const visitorResponse = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-npc`, this.requestOptions);
|
|
43318
|
+
if (visitorResponse.data)
|
|
43319
|
+
return new Visitor(this.topia, visitorResponse.data.playerId, this.urlSlug, {
|
|
43320
|
+
attributes: visitorResponse.data,
|
|
43321
|
+
credentials: this.credentials,
|
|
43322
|
+
});
|
|
43323
|
+
return null;
|
|
43324
|
+
}
|
|
43325
|
+
catch (error) {
|
|
43326
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.getNpc" });
|
|
43327
|
+
}
|
|
43328
|
+
});
|
|
43329
|
+
}
|
|
43330
|
+
/**
|
|
43331
|
+
* Creates an NPC that follows this visitor using an inventory item the visitor owns.
|
|
43332
|
+
* One NPC is allowed per visitor, per application public key.
|
|
43333
|
+
*
|
|
43334
|
+
* @param userInventoryItemId The ID of the user's inventory item (must be an NPC type item owned by this visitor).
|
|
43335
|
+
* @param options Optional configuration for the NPC.
|
|
43336
|
+
* @param options.showNameplate Whether to display a nameplate above the NPC (default: true).
|
|
43337
|
+
*
|
|
43338
|
+
* @example
|
|
43339
|
+
* ```ts
|
|
43340
|
+
* // First, grant the NPC item to the visitor
|
|
43341
|
+
* const userItem = await visitor.grantInventoryItem(npcInventoryItem, 1);
|
|
43342
|
+
*
|
|
43343
|
+
* // Then create the NPC using the granted item
|
|
43344
|
+
* const npc = await visitor.createNpc(userItem.id);
|
|
43345
|
+
*
|
|
43346
|
+
* // Or create without a nameplate
|
|
43347
|
+
* const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
|
|
43348
|
+
* ```
|
|
43349
|
+
*
|
|
43350
|
+
* @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC.
|
|
43351
|
+
*/
|
|
43352
|
+
createNpc(userInventoryItemId, options) {
|
|
43353
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43354
|
+
try {
|
|
43355
|
+
const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/visitors/${this.id}/create-npc`, { userInventoryItemId, showNameplate: options === null || options === void 0 ? void 0 : options.showNameplate }, this.requestOptions);
|
|
43356
|
+
return new Visitor(this.topia, response.data.player.playerId, this.urlSlug, {
|
|
43357
|
+
attributes: response.data,
|
|
43358
|
+
credentials: this.credentials,
|
|
43359
|
+
});
|
|
43360
|
+
}
|
|
43361
|
+
catch (error) {
|
|
43362
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.createNpc" });
|
|
43363
|
+
}
|
|
43364
|
+
});
|
|
43365
|
+
}
|
|
43366
|
+
/**
|
|
43367
|
+
* Deletes the NPC this app has assigned to this visitor.
|
|
43368
|
+
*
|
|
43369
|
+
* @example
|
|
43370
|
+
* ```ts
|
|
43371
|
+
* await visitor.deleteNpc();
|
|
43372
|
+
* ```
|
|
43373
|
+
*
|
|
43374
|
+
* @returns {Promise<void>} Returns nothing if successful.
|
|
43375
|
+
*/
|
|
43376
|
+
deleteNpc() {
|
|
43377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43378
|
+
try {
|
|
43379
|
+
yield this.topiaPublicApi().delete(`/world/${this.urlSlug}/visitors/${this.id}/delete-npc`, this.requestOptions);
|
|
43380
|
+
}
|
|
43381
|
+
catch (error) {
|
|
43382
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.deleteNpc" });
|
|
43383
|
+
}
|
|
43384
|
+
});
|
|
43385
|
+
}
|
|
43304
43386
|
/**
|
|
43305
43387
|
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43306
43388
|
*
|
|
@@ -43346,7 +43428,7 @@ class Visitor extends User {
|
|
|
43346
43428
|
* await visitor.grantInventoryItem("item-id-123", 2);
|
|
43347
43429
|
* ```
|
|
43348
43430
|
*
|
|
43349
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43431
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
43350
43432
|
*/
|
|
43351
43433
|
grantInventoryItem(item, quantity = 1) {
|
|
43352
43434
|
var _a;
|
|
@@ -43381,7 +43463,7 @@ class Visitor extends User {
|
|
|
43381
43463
|
* await visitor.modifyInventoryItemQuantity("item-id-123", 5);
|
|
43382
43464
|
* ```
|
|
43383
43465
|
*
|
|
43384
|
-
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43466
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
|
|
43385
43467
|
*/
|
|
43386
43468
|
modifyInventoryItemQuantity(item, quantity) {
|
|
43387
43469
|
var _a;
|
|
@@ -44809,7 +44891,7 @@ class WorldFactory extends SDKController {
|
|
|
44809
44891
|
headers,
|
|
44810
44892
|
}));
|
|
44811
44893
|
}
|
|
44812
|
-
yield Promise.
|
|
44894
|
+
yield Promise.allSettled(promiseArray);
|
|
44813
44895
|
return { success: true };
|
|
44814
44896
|
}
|
|
44815
44897
|
catch (error) {
|
package/package.json
CHANGED