@@ -10,6 +10,14 @@ The SDK is currently under early development and the API can change at any time.
10
10
11
11
- Version 0.1.0 introduces [ upload strategy] ( #upload ) to support browser and Node JS.
12
12
13
+ ## Types generation
14
+
15
+ The types are generated from the openapi.yaml using the commande:
16
+
17
+ ``` bash
18
+ npx openapi-typescript ./openapi.yaml -o src/openapi.ts --default-non-nullable false
19
+ ```
20
+
13
21
## How to use
14
22
15
23
### Sync api
@@ -126,7 +134,7 @@ const marketplace = codex.marketplace;
126
134
127
135
Returns active slots.
128
136
129
- - returns Promise<[ CodexSlot] ( ./src/marketplace/types.ts#L85 ) [ ] >
137
+ - returns Promise<[ CodexSlot] ( ./src/marketplace/types.ts#L7 ) [ ] >
130
138
131
139
Example:
132
140
@@ -139,7 +147,7 @@ const slots = await marketplace.activeSlots();
139
147
Returns active slot with id {slotId} for the host.
140
148
141
149
- slotId (string, required)
142
- - returns Promise<[ CodexSlot ] ( ./src/marketplace/types.ts#L85 ) [ ] >
150
+ - returns Promise<[ CodexSlotAgent ] ( ./src/marketplace/types.ts#L12 ) [ ] >
143
151
144
152
Example:
145
153
@@ -152,7 +160,7 @@ const slot = await marketplace.activeSlot(slotId);
152
160
153
161
Returns storage that is for sale.
154
162
155
- - returns Promise<[ CodexAvailability] ( ./src/marketplace/types.ts#L99 ) >
163
+ - returns Promise<[ CodexAvailability] ( ./src/marketplace/types.ts#L20 ) >
156
164
157
165
Example:
158
166
@@ -164,8 +172,8 @@ const availabilities = await marketplace.availabilities();
164
172
165
173
Offers storage for sale.
166
174
167
- - input ([ CodexCreateAvailabilityInput] ( ./src/marketplace/types.ts#L175 ) , required)
168
- - returns Promise<[ CodexAvailabilityCreateResponse ] ( ./src/marketplace/types.ts#L186 ) [ ] >
175
+ - input ([ CodexCreateAvailabilityInput] ( ./src/marketplace/types.ts#L45 ) , required)
176
+ - returns Promise<[ CodexAvailability ] ( ./src/marketplace/types.ts#L20 ) [ ] >
169
177
170
178
Example:
171
179
@@ -182,7 +190,7 @@ const response = await marketplace.createAvailability({
182
190
183
191
Updates availability.
184
192
185
- - input ([ CodexUpdateAvailabilityInput ] ( ./src/marketplace/types.ts#L186 ) , required)
193
+ - input ([ CodexAvailabilityPatchInput ] ( ./src/marketplace/types.ts#L66 ) , required)
186
194
- returns Promise<"">
187
195
188
196
Example:
@@ -202,7 +210,7 @@ const response = await marketplace.updateAvailability({
202
210
Return list of reservations for ongoing Storage Requests that the node hosts.
203
211
204
212
- availabilityId (string, required)
205
- - returns Promise<[ CodexReservation] ( ./src/marketplace/types.ts#L198 ) [ ] >
213
+ - returns Promise<[ CodexReservation] ( ./src/marketplace/types.ts#L83 ) [ ] >
206
214
207
215
Example:
208
216
@@ -214,7 +222,7 @@ const reservations = await marketplace.reservations("Ox...");
214
222
215
223
Creates a new Request for storage
216
224
217
- - input ([ CodexCreateStorageRequestInput] ( ./src/marketplace/types.ts#L230 ) , required)
225
+ - input ([ CodexCreateStorageRequestInput] ( ./src/marketplace/types.ts#L120 ) , required)
218
226
- returns Promise<string >
219
227
220
228
Example:
@@ -248,7 +256,7 @@ const ids = await marketplace.purchaseIds();
248
256
Returns purchase details
249
257
250
258
- purchaseId (string, required)
251
- - returns Promise<[ CodexPurchase] ( ./src/marketplace/types.ts#L214 ) [ ] >
259
+ - returns Promise<[ CodexPurchase] ( ./src/marketplace/types.ts#L103 ) [ ] >
252
260
253
261
Example:
254
262
@@ -274,7 +282,7 @@ const data = codex.data;
274
282
275
283
Returns the manifest stored locally in node.
276
284
277
- - returns Promise<[ CodexDataResponse ] ( ./src/data/types.ts#L54 ) [ ] >
285
+ - returns Promise<[ CodexDataItem ] ( ./src/data/types.ts#L8 ) [ ] >
278
286
279
287
Example:
280
288
@@ -286,7 +294,7 @@ const cids = await data.cids();
286
294
287
295
Returns a summary of the storage space allocation of the node
288
296
289
- - returns Promise<[ CodexNodeSpace] ( ./src/data/types.ts#L56 ) [ ] >
297
+ - returns Promise<[ CodexNodeSpace] ( ./src/data/types.ts#L15 ) [ ] >
290
298
291
299
Example:
292
300
@@ -301,7 +309,7 @@ Upload a file in a streaming manner
301
309
#### Browser
302
310
303
311
- stategy [ BrowserUploadStategy] ( ./src/data/browser-upload.ts#L5 )
304
- - returns [ UploadResponse] ( ./src/data/types.ts#L80 )
312
+ - returns [ UploadResponse] ( ./src/data/types.ts#L17 )
305
313
306
314
Example:
307
315
@@ -330,8 +338,8 @@ console.info("CID is", res.data);
330
338
331
339
#### Node
332
340
333
- - stategy [ NodeUploadStategy] ( ./src/data/node-download .ts#L8 )
334
- - returns [ UploadResponse] ( ./src/data/types.ts#L80 )
341
+ - stategy [ NodeUploadStategy] ( ./src/data/node-upload .ts#L9 )
342
+ - returns [ UploadResponse] ( ./src/data/types.ts#L17 )
335
343
336
344
Example:
337
345
@@ -354,7 +362,7 @@ console.info("CID is", res.data);
354
362
Download only the dataset manifest from the network to the local node if it's not available locally.
355
363
356
364
- cid (string, required)
357
- - returns [ CodexManifest] ( ./src/data/types.ts#L3 )
365
+ - returns [ CodexManifest] ( ./src/data/types.ts#L30 )
358
366
359
367
Example:
360
368
@@ -410,7 +418,7 @@ const data = codex.debug;
410
418
411
419
Set log level at run time.
412
420
413
- - level ([ CodexLogLevel] ( ./src/debug/types.ts#L3 ) , required)
421
+ - level ([ CodexLogLevel] ( ./src/debug/types.ts#L7 ) , required)
414
422
- returns Promise<"">
415
423
416
424
Example:
@@ -423,7 +431,7 @@ await debug.setLogLevel("DEBUG");
423
431
424
432
Gets node information
425
433
426
- - returns Promise<[ CodexDebugInfo] ( ./src/debug/types.ts#L15 ) >
434
+ - returns Promise<[ CodexDebugInfo] ( ./src/debug/types.ts#L23 ) >
427
435
428
436
Example:
429
437
@@ -448,10 +456,44 @@ const node = codex.node;
448
456
449
457
Get Node's SPR
450
458
451
- - returns Promise<[ CodexSpr] ( ./src/node/types.ts#L1 ) >
459
+ - returns Promise<[ CodexSpr] ( ./src/node/types.ts#L11 ) >
452
460
453
461
Example:
454
462
455
463
``` js
456
464
const spr = await node .spr ();
457
465
```
466
+
467
+ By default, the response will be a json. You can use ` text ` option to get the string:
468
+
469
+ #### peeriD
470
+
471
+ Get Node's peer id
472
+
473
+ - returns Promise<[ CodexPeerId] ( ./src/node/types.ts#L25 ) >
474
+
475
+ Example:
476
+
477
+ ``` js
478
+ const peerId = await node .peerId ();
479
+ ```
480
+
481
+ By default, the response will be a json. You can use ` text ` option to get the string:
482
+
483
+ ``` js
484
+ const peerId = await node .peerId (" text" );
485
+ ```
486
+
487
+ #### connect
488
+
489
+ Connect to a peer
490
+
491
+ - returns Promise<string >
492
+
493
+ Example:
494
+
495
+ ``` js
496
+ const peerId = " ..."
497
+ const addrs = [... ]
498
+ const spr = await node .connect (peerId, addrs);
499
+ ```
0 commit comments