@oasisomniverse/web5-api 1.0.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.
Files changed (92) hide show
  1. package/README.md +250 -0
  2. package/docs/README.md +44 -0
  3. package/docs/modules/Avatar.md +606 -0
  4. package/docs/modules/CelestialBodies.md +1051 -0
  5. package/docs/modules/CelestialBodiesMetaData.md +949 -0
  6. package/docs/modules/CelestialSpaces.md +1051 -0
  7. package/docs/modules/Chapters.md +955 -0
  8. package/docs/modules/Competition.md +594 -0
  9. package/docs/modules/Cosmic.md +3653 -0
  10. package/docs/modules/Games.md +2619 -0
  11. package/docs/modules/GeoHotSpots.md +1027 -0
  12. package/docs/modules/GeoNFTs.md +1049 -0
  13. package/docs/modules/Health.md +90 -0
  14. package/docs/modules/Holons.md +1139 -0
  15. package/docs/modules/HolonsMetaData.md +949 -0
  16. package/docs/modules/InventoryItems.md +1071 -0
  17. package/docs/modules/Libraries.md +1052 -0
  18. package/docs/modules/Missions.md +1286 -0
  19. package/docs/modules/NFTs.md +1008 -0
  20. package/docs/modules/OAPPs.md +1190 -0
  21. package/docs/modules/Parks.md +1079 -0
  22. package/docs/modules/Plugins.md +1138 -0
  23. package/docs/modules/Quests.md +1941 -0
  24. package/docs/modules/Runtimes.md +1112 -0
  25. package/docs/modules/STAR.md +178 -0
  26. package/docs/modules/Templates.md +990 -0
  27. package/docs/modules/Zomes.md +1049 -0
  28. package/docs/modules/ZomesMetaData.md +949 -0
  29. package/index.d.ts +97 -0
  30. package/index.js +3 -0
  31. package/index.mjs +4 -0
  32. package/package.json +117 -0
  33. package/src/core/httpClient.js +110 -0
  34. package/src/core/routeHelper.js +85 -0
  35. package/src/core/tokenStore.js +52 -0
  36. package/src/core/types.d.ts +18 -0
  37. package/src/index.js +60 -0
  38. package/src/modules/Auth.d.ts +15 -0
  39. package/src/modules/Auth.js +62 -0
  40. package/src/modules/Avatar.d.ts +45 -0
  41. package/src/modules/Avatar.js +47 -0
  42. package/src/modules/CelestialBodies.d.ts +72 -0
  43. package/src/modules/CelestialBodies.js +65 -0
  44. package/src/modules/CelestialBodiesMetaData.d.ts +69 -0
  45. package/src/modules/CelestialBodiesMetaData.js +61 -0
  46. package/src/modules/CelestialSpaces.d.ts +72 -0
  47. package/src/modules/CelestialSpaces.js +65 -0
  48. package/src/modules/Chapters.d.ts +66 -0
  49. package/src/modules/Chapters.js +61 -0
  50. package/src/modules/Competition.d.ts +33 -0
  51. package/src/modules/Competition.js +39 -0
  52. package/src/modules/Cosmic.d.ts +222 -0
  53. package/src/modules/Cosmic.js +165 -0
  54. package/src/modules/Games.d.ts +171 -0
  55. package/src/modules/Games.js +131 -0
  56. package/src/modules/GeoHotSpots.d.ts +66 -0
  57. package/src/modules/GeoHotSpots.js +61 -0
  58. package/src/modules/GeoNFTs.d.ts +72 -0
  59. package/src/modules/GeoNFTs.js +65 -0
  60. package/src/modules/Health.d.ts +12 -0
  61. package/src/modules/Health.js +25 -0
  62. package/src/modules/Holons.d.ts +78 -0
  63. package/src/modules/Holons.js +69 -0
  64. package/src/modules/HolonsMetaData.d.ts +69 -0
  65. package/src/modules/HolonsMetaData.js +61 -0
  66. package/src/modules/InventoryItems.d.ts +69 -0
  67. package/src/modules/InventoryItems.js +63 -0
  68. package/src/modules/Libraries.d.ts +72 -0
  69. package/src/modules/Libraries.js +65 -0
  70. package/src/modules/Missions.d.ts +87 -0
  71. package/src/modules/Missions.js +75 -0
  72. package/src/modules/NFTs.d.ts +69 -0
  73. package/src/modules/NFTs.js +63 -0
  74. package/src/modules/OAPPs.d.ts +69 -0
  75. package/src/modules/OAPPs.js +61 -0
  76. package/src/modules/Parks.d.ts +72 -0
  77. package/src/modules/Parks.js +65 -0
  78. package/src/modules/Plugins.d.ts +78 -0
  79. package/src/modules/Plugins.js +69 -0
  80. package/src/modules/Quests.d.ts +129 -0
  81. package/src/modules/Quests.js +101 -0
  82. package/src/modules/Runtimes.d.ts +81 -0
  83. package/src/modules/Runtimes.js +69 -0
  84. package/src/modules/STAR.d.ts +18 -0
  85. package/src/modules/STAR.js +29 -0
  86. package/src/modules/Templates.d.ts +72 -0
  87. package/src/modules/Templates.js +63 -0
  88. package/src/modules/Zomes.d.ts +72 -0
  89. package/src/modules/Zomes.js +65 -0
  90. package/src/modules/ZomesMetaData.d.ts +69 -0
  91. package/src/modules/ZomesMetaData.js +61 -0
  92. package/src/modules/index.js +67 -0
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # @oasisomniverse/web5-api
2
+
3
+ Isomorphic (Node 18+ and browser) JavaScript/TypeScript-friendly client for the
4
+ **WEB5 STAR API** - full coverage of the OASIS2 STAR WebAPI: OAPPs, Quests,
5
+ Missions, Games, Celestial Bodies/Spaces, the full Cosmic hierarchy
6
+ (Omniverse → Multiverse → Universe → Galaxy → Solar System → Planet/Moon/Star
7
+ and beyond), NFTs, GeoNFTs, GeoHotSpots, Plugins, Templates, Libraries,
8
+ Runtimes, Holons, Zomes, Parks, Chapters, Inventory Items and
9
+ Competition/Leaderboards.
10
+
11
+ Zero dependencies. Wraps the global `fetch`. Works the same in Node and the
12
+ browser.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @oasisomniverse/web5-api
18
+ ```
19
+
20
+ ## Quick start
21
+
22
+ ```js
23
+ const { STARClient } = require('@oasisomniverse/web5-api');
24
+ // or: import { STARClient } from '@oasisomniverse/web5-api';
25
+
26
+ const star = new STARClient({ baseUrl: 'https://api.star.oasisweb5.one' });
27
+
28
+ await star.auth.login({ username: 'me@example.com', password: '...' });
29
+
30
+ const { isError, message, result } = await star.quests.getAllQuestsForAvatar();
31
+ if (isError) throw new Error(message);
32
+ console.log(result);
33
+ ```
34
+
35
+ ## Calling any endpoint
36
+
37
+ Every controller on the OASIS2 STAR WebAPI is reachable as a lowerCamel
38
+ property on the client (`star.avatar`, `star.quests`, `star.missions`,
39
+ `star.games`, `star.cosmic`, `star.holons`, `star.nFTs`, `star.geoNFTs`,
40
+ `star.plugins`, `star.templates`, `star.libraries`, `star.runtimes`,
41
+ `star.competition`, ...). Every generated method takes a single args object:
42
+
43
+ - Any key matching a `{token}` in the route template is consumed and
44
+ substituted into the URL (case-insensitive match).
45
+ - Any remaining keys become the query string (GET/DELETE) or JSON body
46
+ (POST/PUT) - **matching the real `[FromQuery]`/`[FromBody]` binding of the
47
+ underlying C# action**, not just the HTTP verb. Many STAR actions mix a
48
+ `[FromBody]` payload with several `[FromQuery]` flags (e.g. `version`,
49
+ `providerType`, `softDelete`) even on `POST`/`PUT`/`DELETE` - those flags are
50
+ always sent as query params, never folded into the JSON body, because
51
+ `endpoints.json` records exactly which arg names are query-bound per
52
+ operation (see [`docs/`](./docs/README.md) for the per-method breakdown).
53
+ - When an action's entire body is a single primitive `[FromBody]` parameter
54
+ (e.g. `CompleteQuest(Guid id, [FromBody] string completionNotes)`), the
55
+ JSON body is that value directly - not an object wrapping it.
56
+
57
+ ```js
58
+ // GET api/celestialBodies/{id} -> id is consumed as a route token
59
+ const body = await star.celestialBodies.getCelestialBody({ id: '...' });
60
+
61
+ // POST api/quests/{id}/complete -> id consumed as a route token, completionNotes
62
+ // (a single primitive [FromBody] param) becomes the raw JSON body itself
63
+ const done = await star.quests.completeQuest({ id: questId, completionNotes: 'Finished!' });
64
+
65
+ // PUT api/cosmic/omniverse -> saveChildren/providerType are [FromQuery] and go
66
+ // on the URL; the rest (the omniverse payload) becomes the JSON body
67
+ await star.cosmic.updateOmniverse({ name: 'New Omniverse', saveChildren: true, providerType: 'Default' });
68
+
69
+ // DELETE api/cosmic/omniverse/{omniverseId} -> omniverseId is a route token,
70
+ // softDelete/providerType are [FromQuery] and go on the URL - no body sent
71
+ await star.cosmic.deleteOmniverse({ omniverseId, softDelete: true, providerType: 'Default' });
72
+ ```
73
+
74
+ Every response has the shape:
75
+
76
+ ```ts
77
+ interface OASISResponse<T = any> {
78
+ isError: boolean;
79
+ message: string | null;
80
+ result: T;
81
+ raw: any;
82
+ statusCode: number;
83
+ }
84
+ ```
85
+
86
+ ## Auth & sessions
87
+
88
+ `star.auth` is a hand-written ergonomic wrapper around the generated
89
+ `avatar` module's `authenticate` operation. It manages the SDK's
90
+ `TokenStore` for you so you don't have to think about JWTs.
91
+
92
+ ```js
93
+ const loginRes = await star.auth.login({ username: 'me@example.com', password: '...' });
94
+ if (loginRes.isError) throw new Error(loginRes.message);
95
+
96
+ console.log(star.auth.isAuthenticated()); // true
97
+ console.log(star.auth.getSession()); // { avatarId, username, email, jwtToken, ... }
98
+
99
+ await star.auth.logout(); // clears the local session
100
+ ```
101
+
102
+ > STAR's `AvatarController` has no logout/revoke-token endpoint of its own (it
103
+ > only forwards a subset of WEB4 avatar operations), so `logout()` simply
104
+ > clears the local session client-side - it does not call the server.
105
+
106
+ If you already have a JWT (e.g. issued by your own backend), set it directly:
107
+
108
+ ```js
109
+ star.setToken(jwtToken, { avatarId, username });
110
+ ```
111
+
112
+ ## STAR runtime convenience methods
113
+
114
+ The `STARController` (`api/sTAR`) controls the underlying STAR/OASIS runtime
115
+ boot lifecycle. Convenience pass-throughs are exposed directly on the client:
116
+
117
+ ```js
118
+ await star.starIgnite(); // boots the STAR/OASIS runtime
119
+ await star.starStatus(); // current boot status
120
+ await star.starExtinguish(); // shuts the runtime down
121
+ ```
122
+
123
+ These are thin wrappers over `star.sTAR.igniteSTAR()`, `star.sTAR.getStatus()`
124
+ and `star.sTAR.extinguishSTAR()` - the full generated module is also
125
+ available directly under `star.sTAR`.
126
+
127
+ ## Module examples
128
+
129
+ ### Avatar (`star.avatar`)
130
+
131
+ ```js
132
+ const inv = await star.avatar.getInventory();
133
+ await star.avatar.addXp({ amount: 100 });
134
+ ```
135
+
136
+ ### Quests (`star.quests`)
137
+
138
+ ```js
139
+ const myQuests = await star.quests.getAllQuestsForAvatar();
140
+ await star.quests.startQuest({ id: questId });
141
+ await star.quests.completeQuest({ id: questId, completionNotes: 'Done!' });
142
+ ```
143
+
144
+ ### Missions (`star.missions`)
145
+
146
+ ```js
147
+ const missions = await star.missions.getAllMissions();
148
+ await star.missions.completeMission({ id: missionId, completionNotes: 'Done!' });
149
+ ```
150
+
151
+ ### Games (`star.games`)
152
+
153
+ ```js
154
+ const games = await star.games.getAllGames();
155
+ await star.games.startGame({ gameId });
156
+ await star.games.loadLevel({ gameId, level: '1-1' });
157
+ ```
158
+
159
+ ### Cosmic (`star.cosmic`)
160
+
161
+ ```js
162
+ const omniverse = await star.cosmic.getOmniverse();
163
+ await star.cosmic.addGalaxy({ parentGalaxyClusterId, /* ...IGalaxy fields */ });
164
+ ```
165
+
166
+ ### Holons (`star.holons`)
167
+
168
+ ```js
169
+ const holons = await star.holons.getAllHolons();
170
+ const matches = await star.holons.searchHolons({ query: 'forest' });
171
+ ```
172
+
173
+ ### NFTs (`star.nFTs`)
174
+
175
+ ```js
176
+ const nfts = await star.nFTs.getAllNFTs();
177
+ await star.nFTs.publishNFT({ id: nftId, /* ...PublishRequest fields */ });
178
+ ```
179
+
180
+ ### GeoNFTs (`star.geoNFTs`)
181
+
182
+ ```js
183
+ const nearby = await star.geoNFTs.getNearbyGeoNFTs({ latitude: 51.5, longitude: -0.12, radiusKm: 5 });
184
+ ```
185
+
186
+ ### Competition (`star.competition`)
187
+
188
+ ```js
189
+ const leaderboard = await star.competition.getLeaderboard({ competitionType: 'Karma', seasonType: 'Weekly' });
190
+ const myRank = await star.competition.getMyRank({ competitionType: 'Karma', seasonType: 'Weekly' });
191
+ ```
192
+
193
+ ## Module reference
194
+
195
+ 26 modules, 616 operations in total. Full per-method tables live in
196
+ [`docs/`](./docs/README.md).
197
+
198
+ | Client property | Route prefix | Operations |
199
+ | --- | --- | --- |
200
+ | `star.avatar` | `api/avatar` | 13 |
201
+ | `star.celestialBodies` | `api/celestialBodies` | 22 |
202
+ | `star.celestialBodiesMetaData` | `api/celestialBodiesMetaData` | 21 |
203
+ | `star.celestialSpaces` | `api/celestialSpaces` | 22 |
204
+ | `star.chapters` | `api/chapters` | 20 |
205
+ | `star.competition` | `api/competition` | 9 |
206
+ | `star.cosmic` | `api/cosmic` | 72 |
207
+ | `star.games` | `api/games` | 55 |
208
+ | `star.geoHotSpots` | `api/geoHotSpots` | 20 |
209
+ | `star.geoNFTs` | `api/geoNFTs` | 22 |
210
+ | `star.health` | `api/health` | 2 |
211
+ | `star.holons` | `api/holons` | 24 |
212
+ | `star.holonsMetaData` | `api/holonsMetaData` | 21 |
213
+ | `star.inventoryItems` | `api/inventoryItems` | 21 |
214
+ | `star.libraries` | `api/libraries` | 22 |
215
+ | `star.missions` | `api/missions` | 27 |
216
+ | `star.nFTs` | `api/nFTs` | 21 |
217
+ | `star.oAPPs` | `api/oAPPs` | 21 |
218
+ | `star.parks` | `api/parks` | 22 |
219
+ | `star.plugins` | `api/plugins` | 24 |
220
+ | `star.quests` | `api/quests` | 41 |
221
+ | `star.runtimes` | `api/runtimes` | 25 |
222
+ | `star.sTAR` | `api/sTAR` | 4 |
223
+ | `star.templates` | `api/templates` | 22 |
224
+ | `star.zomes` | `api/zomes` | 22 |
225
+ | `star.zomesMetaData` | `api/zomesMetaData` | 21 |
226
+
227
+ See [`docs/README.md`](./docs/README.md) for the full generated reference,
228
+ or [`docs/modules/`](./docs/modules) for per-module method tables with
229
+ parameter and route details.
230
+
231
+ ## Regenerating
232
+
233
+ The generated modules, type declarations and docs are produced from
234
+ `endpoints.json` (extracted from the STAR WebAPI controller source):
235
+
236
+ ```bash
237
+ npm run generate # src/modules/*.js + src/modules/index.js
238
+ npm run types # src/modules/*.d.ts + index.d.ts + src/core/types.d.ts
239
+ npm run docs # docs/README.md + docs/modules/*.md
240
+ ```
241
+
242
+ ## Testing
243
+
244
+ ```bash
245
+ npm test
246
+ ```
247
+
248
+ ## License
249
+
250
+ MIT
package/docs/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # WEB5 STAR API — JavaScript SDK Reference
2
+
3
+ Generated from `endpoints.json` (extracted from the WebAPI controllers) by
4
+ `scripts/generate-full-docs.js`. Regenerate the full pipeline after the API
5
+ changes:
6
+
7
+ ```
8
+ node scripts/extract-endpoints.js
9
+ node scripts/generate-modules.js
10
+ node scripts/generate-full-docs.js
11
+ ```
12
+
13
+ - [Module Reference](#module-reference) (26 modules, 609 operations)
14
+
15
+ ## Module Reference
16
+
17
+ | Client property | Route prefix | Operations |
18
+ | --- | --- | --- |
19
+ | [`star.avatar`](modules/Avatar.md) | `api/avatar` | 13 |
20
+ | [`star.celestialBodies`](modules/CelestialBodies.md) | `api/celestialBodies` | 22 |
21
+ | [`star.celestialBodiesMetaData`](modules/CelestialBodiesMetaData.md) | `api/celestialBodiesMetaData` | 20 |
22
+ | [`star.celestialSpaces`](modules/CelestialSpaces.md) | `api/celestialSpaces` | 22 |
23
+ | [`star.chapters`](modules/Chapters.md) | `api/chapters` | 20 |
24
+ | [`star.competition`](modules/Competition.md) | `api/competition` | 9 |
25
+ | [`star.cosmic`](modules/Cosmic.md) | `api/cosmic` | 72 |
26
+ | [`star.games`](modules/Games.md) | `api/games` | 55 |
27
+ | [`star.geoHotSpots`](modules/GeoHotSpots.md) | `api/geoHotSpots` | 20 |
28
+ | [`star.geoNFTs`](modules/GeoNFTs.md) | `api/geoNFTs` | 22 |
29
+ | [`star.health`](modules/Health.md) | `api/health` | 2 |
30
+ | [`star.holons`](modules/Holons.md) | `api/holons` | 24 |
31
+ | [`star.holonsMetaData`](modules/HolonsMetaData.md) | `api/holonsMetaData` | 20 |
32
+ | [`star.inventoryItems`](modules/InventoryItems.md) | `api/inventoryItems` | 21 |
33
+ | [`star.libraries`](modules/Libraries.md) | `api/libraries` | 22 |
34
+ | [`star.missions`](modules/Missions.md) | `api/missions` | 27 |
35
+ | [`star.nFTs`](modules/NFTs.md) | `api/nFTs` | 21 |
36
+ | [`star.oAPPs`](modules/OAPPs.md) | `api/oAPPs` | 20 |
37
+ | [`star.parks`](modules/Parks.md) | `api/parks` | 22 |
38
+ | [`star.plugins`](modules/Plugins.md) | `api/plugins` | 24 |
39
+ | [`star.quests`](modules/Quests.md) | `api/quests` | 40 |
40
+ | [`star.runtimes`](modules/Runtimes.md) | `api/runtimes` | 24 |
41
+ | [`star.sTAR`](modules/STAR.md) | `api/sTAR` | 4 |
42
+ | [`star.templates`](modules/Templates.md) | `api/templates` | 21 |
43
+ | [`star.zomes`](modules/Zomes.md) | `api/zomes` | 22 |
44
+ | [`star.zomesMetaData`](modules/ZomesMetaData.md) | `api/zomesMetaData` | 20 |