@oasisomniverse/web4-api 2.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 (116) hide show
  1. package/README.md +464 -0
  2. package/docs/README.md +52 -0
  3. package/docs/auth.md +89 -0
  4. package/docs/getting-started.md +129 -0
  5. package/docs/modules/Avatar.md +4160 -0
  6. package/docs/modules/Bridge.md +394 -0
  7. package/docs/modules/Chat.md +168 -0
  8. package/docs/modules/Clan.md +552 -0
  9. package/docs/modules/Competition.md +594 -0
  10. package/docs/modules/Data.md +796 -0
  11. package/docs/modules/EOSIO.md +508 -0
  12. package/docs/modules/Eggs.md +396 -0
  13. package/docs/modules/Files.md +312 -0
  14. package/docs/modules/Gifts.md +306 -0
  15. package/docs/modules/Health.md +90 -0
  16. package/docs/modules/Holochain.md +374 -0
  17. package/docs/modules/HyperDrive.md +3857 -0
  18. package/docs/modules/Karma.md +644 -0
  19. package/docs/modules/Keys.md +3303 -0
  20. package/docs/modules/Map.md +1026 -0
  21. package/docs/modules/Messaging.md +320 -0
  22. package/docs/modules/Nft.md +2216 -0
  23. package/docs/modules/OLand.md +425 -0
  24. package/docs/modules/ONET.md +442 -0
  25. package/docs/modules/ONODE.md +504 -0
  26. package/docs/modules/Provider.md +1396 -0
  27. package/docs/modules/Search.md +69 -0
  28. package/docs/modules/Seeds.md +167 -0
  29. package/docs/modules/Settings.md +533 -0
  30. package/docs/modules/Share.md +64 -0
  31. package/docs/modules/Social.md +190 -0
  32. package/docs/modules/Solana.md +150 -0
  33. package/docs/modules/Stats.md +359 -0
  34. package/docs/modules/Subscription.md +437 -0
  35. package/docs/modules/Video.md +150 -0
  36. package/docs/modules/Wallet.md +1993 -0
  37. package/index.d.ts +106 -0
  38. package/index.js +3 -0
  39. package/index.mjs +4 -0
  40. package/package.json +120 -0
  41. package/src/core/httpClient.js +110 -0
  42. package/src/core/routeHelper.js +50 -0
  43. package/src/core/tokenStore.js +52 -0
  44. package/src/core/types.d.ts +18 -0
  45. package/src/index.js +46 -0
  46. package/src/modules/Auth.d.ts +28 -0
  47. package/src/modules/Auth.js +98 -0
  48. package/src/modules/Avatar.d.ts +192 -0
  49. package/src/modules/Avatar.js +143 -0
  50. package/src/modules/Bridge.d.ts +24 -0
  51. package/src/modules/Bridge.js +35 -0
  52. package/src/modules/Cargo.js +35 -0
  53. package/src/modules/Chat.d.ts +15 -0
  54. package/src/modules/Chat.js +27 -0
  55. package/src/modules/Clan.d.ts +36 -0
  56. package/src/modules/Clan.js +41 -0
  57. package/src/modules/Competition.d.ts +33 -0
  58. package/src/modules/Competition.js +39 -0
  59. package/src/modules/Core.js +27 -0
  60. package/src/modules/Data.d.ts +36 -0
  61. package/src/modules/Data.js +41 -0
  62. package/src/modules/EOSIO.d.ts +33 -0
  63. package/src/modules/EOSIO.js +39 -0
  64. package/src/modules/Eggs.d.ts +24 -0
  65. package/src/modules/Eggs.js +33 -0
  66. package/src/modules/Files.d.ts +24 -0
  67. package/src/modules/Files.js +33 -0
  68. package/src/modules/Gifts.d.ts +24 -0
  69. package/src/modules/Gifts.js +33 -0
  70. package/src/modules/Health.d.ts +12 -0
  71. package/src/modules/Health.js +25 -0
  72. package/src/modules/Holochain.d.ts +27 -0
  73. package/src/modules/Holochain.js +35 -0
  74. package/src/modules/HyperDrive.d.ts +237 -0
  75. package/src/modules/HyperDrive.js +175 -0
  76. package/src/modules/Karma.d.ts +42 -0
  77. package/src/modules/Karma.js +45 -0
  78. package/src/modules/Keys.d.ts +183 -0
  79. package/src/modules/Keys.js +139 -0
  80. package/src/modules/Map.d.ts +75 -0
  81. package/src/modules/Map.js +65 -0
  82. package/src/modules/Messaging.d.ts +24 -0
  83. package/src/modules/Messaging.js +33 -0
  84. package/src/modules/Nft.d.ts +102 -0
  85. package/src/modules/Nft.js +85 -0
  86. package/src/modules/OAPP.js +31 -0
  87. package/src/modules/OLand.d.ts +27 -0
  88. package/src/modules/OLand.js +35 -0
  89. package/src/modules/ONET.d.ts +39 -0
  90. package/src/modules/ONET.js +43 -0
  91. package/src/modules/ONODE.d.ts +45 -0
  92. package/src/modules/ONODE.js +47 -0
  93. package/src/modules/Provider.d.ts +99 -0
  94. package/src/modules/Provider.js +83 -0
  95. package/src/modules/Search.d.ts +9 -0
  96. package/src/modules/Search.js +23 -0
  97. package/src/modules/Seeds.d.ts +15 -0
  98. package/src/modules/Seeds.js +27 -0
  99. package/src/modules/Settings.d.ts +48 -0
  100. package/src/modules/Settings.js +47 -0
  101. package/src/modules/Share.d.ts +9 -0
  102. package/src/modules/Share.js +23 -0
  103. package/src/modules/Social.d.ts +18 -0
  104. package/src/modules/Social.js +29 -0
  105. package/src/modules/Solana.d.ts +12 -0
  106. package/src/modules/Solana.js +25 -0
  107. package/src/modules/Stats.d.ts +30 -0
  108. package/src/modules/Stats.js +37 -0
  109. package/src/modules/Subscription.d.ts +36 -0
  110. package/src/modules/Subscription.js +41 -0
  111. package/src/modules/Telos.js +39 -0
  112. package/src/modules/Video.d.ts +15 -0
  113. package/src/modules/Video.js +27 -0
  114. package/src/modules/Wallet.d.ts +102 -0
  115. package/src/modules/Wallet.js +85 -0
  116. package/src/modules/index.js +79 -0
@@ -0,0 +1,129 @@
1
+ # Getting Started
2
+
3
+ `@oasisomniverse/web4-api` is an isomorphic client for the WEB4 OASIS API - it runs the
4
+ same way in Node.js 18+ and in the browser, has zero dependencies (it uses the
5
+ global `fetch`), and covers every controller on the OASIS2 ONODE WebAPI.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @oasisomniverse/web4-api
11
+ ```
12
+
13
+ ## Create a client
14
+
15
+ ```js
16
+ // CommonJS
17
+ const { OASISClient } = require('@oasisomniverse/web4-api');
18
+ // or ESM
19
+ import { OASISClient } from '@oasisomniverse/web4-api';
20
+
21
+ const oasis = new OASISClient({
22
+ baseUrl: 'https://api.oasisweb4.one', // optional, this is the default
23
+ persistSession: true // optional, see "Sessions" below
24
+ });
25
+ ```
26
+
27
+ | Option | Default | Notes |
28
+ | --- | --- | --- |
29
+ | `baseUrl` | `https://api.oasisweb4.one` | Point at any OASIS node (your own ONODE, a staging environment, etc). |
30
+ | `persistSession` | `true` in browsers, `false` in Node | Whether the session is written to `localStorage`. |
31
+ | `fetchImpl` | `globalThis.fetch` | Override for testing or non-standard runtimes. |
32
+
33
+ ## Authenticate
34
+
35
+ ```js
36
+ const { isError, message, session } = await oasis.auth.login({
37
+ username: 'me@example.com', // username or email both work
38
+ password: 'correct-horse-battery-staple'
39
+ });
40
+
41
+ if (isError) throw new Error(message);
42
+ console.log('Signed in as', session.username, session.avatarId);
43
+ ```
44
+
45
+ From here on, every call automatically sends `Authorization: Bearer <jwtToken>`
46
+ - you don't need to attach it yourself. See [Auth & Sessions](./auth.md) for
47
+ registration, logout, and how to manage sessions in stateless environments
48
+ (serverless functions, SSR, etc).
49
+
50
+ ## Calling any endpoint
51
+
52
+ Every controller on the OASIS2 WebAPI is exposed as a lowerCamel property on
53
+ the client, e.g. `oasis.avatar`, `oasis.data`, `oasis.karma`, `oasis.nft`,
54
+ `oasis.wallet`, `oasis.map`, `oasis.search`, `oasis.hyperDrive`. See the
55
+ [Module Reference](./README.md#module-reference) for the full list (32
56
+ modules, 485 operations).
57
+
58
+ ### Calling convention
59
+
60
+ Every generated method takes **one args object**:
61
+
62
+ 1. Any key in that object whose name matches a `{token}` in the endpoint's
63
+ route is substituted into the URL.
64
+ 2. Everything else you pass becomes the **query string** (for `GET`/`DELETE`)
65
+ or the **JSON body** (for `POST`/`PUT`) - exactly what the underlying
66
+ ASP.NET controller expects, so body field names must match the C# request
67
+ model's property names (PascalCase, e.g. `KarmaType`, `Holon`, `Id`).
68
+
69
+ ```js
70
+ // GET api/karma/get-karma-for-avatar/{avatarId} -> avatarId is a route token
71
+ const karma = await oasis.karma.getKarmaForAvatar({ avatarId });
72
+
73
+ // POST api/karma/add-karma-to-avatar/{avatarId} -> avatarId is a route token,
74
+ // everything else becomes the JSON body (AddRemoveKarmaToAvatarRequest)
75
+ await oasis.karma.addKarmaToAvatar({
76
+ avatarId,
77
+ KarmaType: 'ContributingToTheOASISWithCode',
78
+ karmaSourceType: 'Website',
79
+ KaramSourceTitle: 'Shipped a feature',
80
+ KarmaSourceDesc: 'Added full WEB4 OASIS API coverage'
81
+ });
82
+
83
+ // POST api/data/save-holon -> no route tokens at all, the whole object is the body
84
+ await oasis.data.saveHolon({
85
+ Holon: { Name: 'My Trust', HolonType: 'Trust', ParentHolonId: avatarId, MetaData: { foo: 'bar' } },
86
+ SaveChildren: true
87
+ });
88
+ ```
89
+
90
+ ### Response shape
91
+
92
+ Every call resolves to:
93
+
94
+ ```ts
95
+ {
96
+ isError: boolean,
97
+ message: string | null,
98
+ result: any, // the unwrapped payload
99
+ raw: any, // the full OASIS response envelope, if you need it
100
+ statusCode: number
101
+ }
102
+ ```
103
+
104
+ Network failures (DNS, connection refused, timeout) are caught and returned
105
+ in this same shape (`isError: true`) rather than thrown, so you only need one
106
+ error-handling path:
107
+
108
+ ```js
109
+ const { isError, message, result } = await oasis.nft.getAllNfts({});
110
+ if (isError) {
111
+ console.error(message);
112
+ return;
113
+ }
114
+ console.log(result);
115
+ ```
116
+
117
+ ## TypeScript
118
+
119
+ The package ships as plain JS (CommonJS + ESM dual entry) without bundled
120
+ `.d.ts` files yet. Method signatures are uniform (`(args?: object) => Promise<Response>`),
121
+ so a minimal ambient declaration is usually enough if you need one - see the
122
+ [Module Reference](./README.md#module-reference) for exact argument shapes per
123
+ endpoint.
124
+
125
+ ## Next steps
126
+
127
+ - [Auth & Sessions](./auth.md)
128
+ - [Module Reference](./README.md#module-reference)
129
+ - [Regenerating modules/docs](../README.md#regenerating-module-coverage) when the OASIS2 API changes