@rtsdk/topia 0.0.19 → 0.0.21

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 CHANGED
@@ -2,18 +2,151 @@
2
2
 
3
3
  The Topia Client Library leverages the Topia Public API and allows users to interact with the topia systems and modify their world programmatically. With the SDK you can now build new features to be used in Topia! Check out a few awesome examples [here](https://sdk-examples.metaversecloud.com/).
4
4
 
5
+ <br>
6
+
7
+ ## Authorization
8
+
9
+ A Topia provided API Key can be included with every object initialization as a parameter named `apiKey`. This API Key is used to in authorization headers in all calls to the Public API.
10
+
11
+ ### Need an API Key to test locally? This is how you can create one:
12
+
13
+ - While logged in to [topia.io](https://topia.io/), click on your image (or gray circle) in the top left of the screen to open My Account
14
+ - In the side menu, select Integrations
15
+ - Click Generate New API Key and copy the API Key to be used in your .env and while using https://sdk-examples.metaversecloud.com
16
+
17
+ <br>
18
+
19
+ Alternatively, visitors of a [topia.io](https://topia.io/) world interact with each other and the interactively configured assets in your world without the need for an API Key. This is all made possible through Interactive Session credentials passed to the SDK with every request, when applicable. What does this mean for you? Not much, actually! All of the magic happens behind the scenes and all you have to do is make sure that new class constructors include an options object like this: `options: WorldOptionalInterface = { attributes: {}, credentials: {} }` and all calls to `this.topia.axios` include the inherited `this.requestOptions` parameter.
20
+
21
+ ![Interactive Application Development Diagram](./InteractiveApplicationDevelopment.png)
22
+
23
+ <br>
24
+
25
+ <hr/>
26
+
27
+ # Contributors
28
+
5
29
  ## Get Started
6
30
 
7
- Run `yarn add @rtsdk/topia` or `npm install @rtsdk/topia`
31
+ Run `gh repo clone metaversecloud-com/mc-sdk-js`
8
32
 
9
- ## Authorization
33
+ <br>
34
+
35
+ ## Issues
36
+
37
+ We've added an Issue template to help standardize Issues and ensure they have enough detail for a developer to start work and help prevent contributors from forgetting to add an important piece of information.
38
+
39
+ <br>
40
+
41
+ ## Pull Requests
42
+
43
+ We've added a Pull Request template to help make it easier for developers to clarify what the proposed changes will do. This helps facilitate clear communication between all contributors of the SDK and ensures that we are all on the same page!
44
+
45
+ <br>
46
+
47
+ ## Documentation
48
+
49
+ We use [TypeDoc](https://typedoc.org/guides/overview) to convert comments in TypeScript source code into rendered HTML documentation. Comments should be simple and concise and include examples where applicable. Please be sure to add or update comments accordingly!
50
+
51
+ To update docs run `yarn docs`.
52
+
53
+ To view docs locally open `mc-sdk-js/clients/client-topia/docs/modules.html` in your browser.
54
+
55
+ Example of Class comments:
10
56
 
11
- A Topia provided API Key should be included with every object initialization as a parameter named `apiKey`. This API Key is used to in authorization headers in all calls to the Public API.
57
+ ````ts
58
+ /**
59
+ * @summary
60
+ * Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
61
+ *
62
+ * @usage
63
+ * ```ts
64
+ * await new DroppedAsset(topia, "1giFZb0sQ3X27L7uGyQX", "example", { attributes: { text: "" }, credentials: { assetId: "1giFZb0sQ3X27L7uGyQX" } } });
65
+ * ```
66
+ */
67
+ ````
68
+
69
+ Example of method comments
70
+
71
+ ````ts
72
+ /**
73
+ * @summary
74
+ * Sets the data object for a dropped asset.
75
+ *
76
+ * 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
77
+ *
78
+ * @usage
79
+ * ```ts
80
+ * await droppedAsset.setDroppedAssetDataObject({
81
+ * "exampleKey": "exampleValue",
82
+ * });
83
+ * const { dataObject } = droppedAsset;
84
+ * ```
85
+ */
86
+ ````
87
+
88
+ <br>
12
89
 
13
90
  ## Testing
14
91
 
15
92
  We use Jest for testing and take advantage of dependency injection to pass mock data into our services.
16
93
 
17
- To run the test suite, please run:
94
+ To run the test suite, please run `yarn test`.
95
+
96
+ <br><br>
97
+
98
+ <hr/>
99
+
100
+ # Developers
101
+
102
+ Need inspiration?! Check out our [example application](https://sdk-examples.metaversecloud.com/) which utilizes the SDK to create new and enhanced features inside [topia.io](https://topia.io/).
103
+
104
+ <br>
105
+
106
+ ## Get Started
107
+
108
+ Run `yarn add @rtsdk/topia` or `npm install @rtsdk/topia`
109
+
110
+ Create your instance of Topia and instantiate the factories you need:
111
+
112
+ ```js
113
+ dotenv.config();
114
+ import dotenv from "dotenv";
115
+
116
+ import { AssetFactory, Topia, DroppedAssetFactory, UserFactory, WorldFactory } from "@rtsdk/topia";
117
+
118
+ const config = {
119
+ apiDomain: process.env.INSTANCE_DOMAIN || "https://api.topia.io/",
120
+ apiKey: process.env.API_KEY,
121
+ interactiveKey: process.env.INTERACTIVE_KEY,
122
+ interactiveSecret: process.env.INTERACTIVE_SECRET,
123
+ };
124
+
125
+ const myTopiaInstance = new Topia(config);
126
+
127
+ const Asset = new AssetFactory(myTopiaInstance);
128
+ const DroppedAsset = new DroppedAssetFactory(myTopiaInstance);
129
+ const User = new UserFactory(myTopiaInstance);
130
+ const World = new WorldFactory(myTopiaInstance);
131
+
132
+ export { Asset, DroppedAsset, myTopiaInstance, User, World };
133
+ ```
134
+
135
+ <br/>
136
+
137
+ Put it to use:
138
+
139
+ ```js
140
+ import { DroppedAsset } from "./pathToAboveCode";
141
+
142
+ export const getAssetAndDataObject = async (req) => {
143
+ const { assetId, urlSlug } = req.body;
144
+
145
+ const droppedAsset = await DroppedAsset.get(assetId, urlSlug, {
146
+ credentials: req.body,
147
+ });
18
148
 
19
- `yarn test`
149
+ await droppedAsset.fetchDroppedAssetDataObject();
150
+ return droppedAsset;
151
+ };
152
+ ```