@arke-institute/sdk 0.1.2 → 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 (64) hide show
  1. package/README.md +126 -184
  2. package/dist/generated/index.cjs +19 -0
  3. package/dist/generated/index.cjs.map +1 -0
  4. package/dist/generated/index.d.cts +6192 -0
  5. package/dist/generated/index.d.ts +6192 -0
  6. package/dist/generated/index.js +1 -0
  7. package/dist/generated/index.js.map +1 -0
  8. package/dist/index-BrXke2kI.d.ts +302 -0
  9. package/dist/index-FHcLPBSV.d.cts +302 -0
  10. package/dist/index.cjs +188 -3654
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +62 -7
  13. package/dist/index.d.ts +62 -7
  14. package/dist/index.js +168 -3626
  15. package/dist/index.js.map +1 -1
  16. package/dist/operations/index.cjs +113 -0
  17. package/dist/operations/index.cjs.map +1 -0
  18. package/dist/operations/index.d.cts +3 -0
  19. package/dist/operations/index.d.ts +3 -0
  20. package/dist/operations/index.js +84 -0
  21. package/dist/operations/index.js.map +1 -0
  22. package/package.json +44 -53
  23. package/dist/client-dAk3E64p.d.cts +0 -183
  24. package/dist/client-dAk3E64p.d.ts +0 -183
  25. package/dist/collections/index.cjs +0 -233
  26. package/dist/collections/index.cjs.map +0 -1
  27. package/dist/collections/index.d.cts +0 -9
  28. package/dist/collections/index.d.ts +0 -9
  29. package/dist/collections/index.js +0 -205
  30. package/dist/collections/index.js.map +0 -1
  31. package/dist/content/index.cjs +0 -506
  32. package/dist/content/index.cjs.map +0 -1
  33. package/dist/content/index.d.cts +0 -403
  34. package/dist/content/index.d.ts +0 -403
  35. package/dist/content/index.js +0 -473
  36. package/dist/content/index.js.map +0 -1
  37. package/dist/edit/index.cjs +0 -1029
  38. package/dist/edit/index.cjs.map +0 -1
  39. package/dist/edit/index.d.cts +0 -78
  40. package/dist/edit/index.d.ts +0 -78
  41. package/dist/edit/index.js +0 -983
  42. package/dist/edit/index.js.map +0 -1
  43. package/dist/errors-3L7IiHcr.d.cts +0 -480
  44. package/dist/errors-B82BMmRP.d.cts +0 -343
  45. package/dist/errors-B82BMmRP.d.ts +0 -343
  46. package/dist/errors-BTe8GKRQ.d.ts +0 -480
  47. package/dist/graph/index.cjs +0 -433
  48. package/dist/graph/index.cjs.map +0 -1
  49. package/dist/graph/index.d.cts +0 -456
  50. package/dist/graph/index.d.ts +0 -456
  51. package/dist/graph/index.js +0 -402
  52. package/dist/graph/index.js.map +0 -1
  53. package/dist/query/index.cjs +0 -289
  54. package/dist/query/index.cjs.map +0 -1
  55. package/dist/query/index.d.cts +0 -541
  56. package/dist/query/index.d.ts +0 -541
  57. package/dist/query/index.js +0 -261
  58. package/dist/query/index.js.map +0 -1
  59. package/dist/upload/index.cjs +0 -1634
  60. package/dist/upload/index.cjs.map +0 -1
  61. package/dist/upload/index.d.cts +0 -150
  62. package/dist/upload/index.d.ts +0 -150
  63. package/dist/upload/index.js +0 -1597
  64. package/dist/upload/index.js.map +0 -1
@@ -1,403 +0,0 @@
1
- /**
2
- * Content package types for the Arke SDK
3
- *
4
- * Types for interacting with entities and content from the IPFS Wrapper service.
5
- */
6
- /**
7
- * Full entity manifest from IPFS Wrapper
8
- */
9
- interface Entity {
10
- /** Persistent Identifier (ULID or test PI with II prefix) */
11
- pi: string;
12
- /** Version number */
13
- ver: number;
14
- /** Timestamp when this version was created */
15
- ts: string;
16
- /** CID of this manifest */
17
- manifest_cid: string;
18
- /** CID of the previous version (undefined for version 1) */
19
- prev_cid?: string;
20
- /** Map of component names to their CIDs */
21
- components: Record<string, string>;
22
- /** PIs of child entities */
23
- children_pi?: string[];
24
- /** PI of parent entity */
25
- parent_pi?: string;
26
- /** Change note for this version */
27
- note?: string;
28
- }
29
- /**
30
- * Summary entity info returned when listing entities
31
- */
32
- interface EntitySummary {
33
- /** Persistent Identifier */
34
- pi: string;
35
- /** Tip CID (latest manifest) */
36
- tip: string;
37
- /** Version number (if include_metadata=true) */
38
- ver?: number;
39
- /** Timestamp (if include_metadata=true) */
40
- ts?: string;
41
- /** Change note (if include_metadata=true) */
42
- note?: string;
43
- /** Number of components (if include_metadata=true) */
44
- component_count?: number;
45
- /** Number of children (if include_metadata=true) */
46
- children_count?: number;
47
- }
48
- /**
49
- * Version entry in version history
50
- */
51
- interface EntityVersion {
52
- /** Version number */
53
- ver: number;
54
- /** CID of this version's manifest */
55
- cid: string;
56
- /** Timestamp when this version was created */
57
- ts: string;
58
- /** Change note for this version */
59
- note?: string;
60
- }
61
- /**
62
- * Options for listing entities
63
- */
64
- interface ListOptions {
65
- /** Maximum entities to return (1-1000, default: 100) */
66
- limit?: number;
67
- /** Cursor for pagination (CID, base32 starting with 'b') */
68
- cursor?: string;
69
- /** Whether to include full metadata for each entity */
70
- include_metadata?: boolean;
71
- }
72
- /**
73
- * Options for listing versions
74
- */
75
- interface VersionsOptions {
76
- /** Maximum versions to return (default: 20) */
77
- limit?: number;
78
- /** Cursor for pagination (CID to start from) */
79
- cursor?: string;
80
- }
81
- /**
82
- * Response from listing entities
83
- */
84
- interface ListResponse {
85
- /** List of entity summaries */
86
- entities: EntitySummary[];
87
- /** Number of entities returned (matches limit) */
88
- limit: number;
89
- /** Cursor for next page (null if no more) */
90
- next_cursor: string | null;
91
- }
92
- /**
93
- * Response from listing versions
94
- */
95
- interface VersionsResponse {
96
- /** List of versions (newest first) */
97
- items: EntityVersion[];
98
- /** Cursor for next page (null if reached genesis) */
99
- next_cursor: string | null;
100
- }
101
- /**
102
- * Response from resolving a PI
103
- */
104
- interface ResolveResponse {
105
- /** Persistent Identifier */
106
- pi: string;
107
- /** Tip CID (latest manifest) */
108
- tip: string;
109
- }
110
-
111
- /**
112
- * Configuration for ContentClient
113
- */
114
- interface ContentClientConfig {
115
- /**
116
- * Gateway base URL (e.g., https://gateway.arke.institute).
117
- * The client will call /api/* endpoints for IPFS Wrapper.
118
- */
119
- gatewayUrl: string;
120
- /**
121
- * Optional custom fetch implementation (useful for testing).
122
- */
123
- fetchImpl?: typeof fetch;
124
- }
125
- /**
126
- * Client for accessing entities and content from the Arke archive.
127
- *
128
- * All endpoints are public and do not require authentication.
129
- *
130
- * @example
131
- * ```typescript
132
- * const content = new ContentClient({
133
- * gatewayUrl: 'https://gateway.arke.institute',
134
- * });
135
- *
136
- * // Get an entity
137
- * const entity = await content.get('01K75HQQXNTDG7BBP7PS9AWYAN');
138
- *
139
- * // Download content by CID
140
- * const blob = await content.download('bafybeihkoviema7g3gxyt6la7vd5ho32jywf7b4c4z3qtwcabpjqxwsumu');
141
- *
142
- * // Get component content
143
- * const pinax = await content.getComponent(entity, 'pinax');
144
- * ```
145
- */
146
- declare class ContentClient {
147
- private baseUrl;
148
- private fetchImpl;
149
- constructor(config: ContentClientConfig);
150
- private buildUrl;
151
- private request;
152
- /**
153
- * Get an entity by its Persistent Identifier (PI).
154
- *
155
- * @param pi - Persistent Identifier (ULID or test PI with II prefix)
156
- * @returns Full entity manifest
157
- * @throws EntityNotFoundError if the entity doesn't exist
158
- *
159
- * @example
160
- * ```typescript
161
- * const entity = await content.get('01K75HQQXNTDG7BBP7PS9AWYAN');
162
- * console.log('Version:', entity.ver);
163
- * console.log('Components:', Object.keys(entity.components));
164
- * ```
165
- */
166
- get(pi: string): Promise<Entity>;
167
- /**
168
- * List entities with pagination.
169
- *
170
- * @param options - Pagination and metadata options
171
- * @returns Paginated list of entity summaries
172
- *
173
- * @example
174
- * ```typescript
175
- * // Get first page
176
- * const page1 = await content.list({ limit: 20, include_metadata: true });
177
- *
178
- * // Get next page
179
- * if (page1.next_cursor) {
180
- * const page2 = await content.list({ cursor: page1.next_cursor });
181
- * }
182
- * ```
183
- */
184
- list(options?: ListOptions): Promise<ListResponse>;
185
- /**
186
- * Get version history for an entity.
187
- *
188
- * @param pi - Persistent Identifier
189
- * @param options - Pagination options
190
- * @returns Version history (newest first)
191
- *
192
- * @example
193
- * ```typescript
194
- * const history = await content.versions('01K75HQQXNTDG7BBP7PS9AWYAN');
195
- * console.log('Total versions:', history.items.length);
196
- * history.items.forEach(v => {
197
- * console.log(`v${v.ver}: ${v.ts} - ${v.note || 'no note'}`);
198
- * });
199
- * ```
200
- */
201
- versions(pi: string, options?: VersionsOptions): Promise<VersionsResponse>;
202
- /**
203
- * Get a specific version of an entity.
204
- *
205
- * @param pi - Persistent Identifier
206
- * @param selector - Version selector: 'ver:N' for version number or 'cid:...' for CID
207
- * @returns Entity manifest for the specified version
208
- *
209
- * @example
210
- * ```typescript
211
- * // Get version 2
212
- * const v2 = await content.getVersion('01K75HQQXNTDG7BBP7PS9AWYAN', 'ver:2');
213
- *
214
- * // Get by CID
215
- * const vByCid = await content.getVersion('01K75HQQXNTDG7BBP7PS9AWYAN', 'cid:bafybeih...');
216
- * ```
217
- */
218
- getVersion(pi: string, selector: string): Promise<Entity>;
219
- /**
220
- * Resolve a PI to its tip CID (fast lookup without fetching manifest).
221
- *
222
- * @param pi - Persistent Identifier
223
- * @returns PI and tip CID
224
- *
225
- * @example
226
- * ```typescript
227
- * const { tip } = await content.resolve('01K75HQQXNTDG7BBP7PS9AWYAN');
228
- * console.log('Latest manifest CID:', tip);
229
- * ```
230
- */
231
- resolve(pi: string): Promise<ResolveResponse>;
232
- /**
233
- * Get the list of child PIs for an entity (fast, returns only PIs).
234
- *
235
- * @param pi - Persistent Identifier of parent entity
236
- * @returns Array of child PIs
237
- *
238
- * @example
239
- * ```typescript
240
- * const childPis = await content.children('01K75HQQXNTDG7BBP7PS9AWYAN');
241
- * console.log('Children:', childPis);
242
- * ```
243
- */
244
- children(pi: string): Promise<string[]>;
245
- /**
246
- * Get all child entities for a parent (fetches full entity for each child).
247
- *
248
- * @param pi - Persistent Identifier of parent entity
249
- * @returns Array of child entities
250
- *
251
- * @example
252
- * ```typescript
253
- * const childEntities = await content.childrenEntities('01K75HQQXNTDG7BBP7PS9AWYAN');
254
- * childEntities.forEach(child => {
255
- * console.log(`${child.pi}: v${child.ver}`);
256
- * });
257
- * ```
258
- */
259
- childrenEntities(pi: string): Promise<Entity[]>;
260
- /**
261
- * Get the Arke origin block (root of the archive tree).
262
- *
263
- * @returns Arke origin entity
264
- *
265
- * @example
266
- * ```typescript
267
- * const origin = await content.arke();
268
- * console.log('Arke origin:', origin.pi);
269
- * ```
270
- */
271
- arke(): Promise<Entity>;
272
- /**
273
- * Download content by CID.
274
- *
275
- * Returns Blob in browser environments, Buffer in Node.js.
276
- *
277
- * @param cid - Content Identifier
278
- * @returns Content as Blob (browser) or Buffer (Node)
279
- * @throws ContentNotFoundError if the content doesn't exist
280
- *
281
- * @example
282
- * ```typescript
283
- * const content = await client.download('bafybeih...');
284
- *
285
- * // In browser
286
- * const url = URL.createObjectURL(content as Blob);
287
- *
288
- * // In Node.js
289
- * fs.writeFileSync('output.bin', content as Buffer);
290
- * ```
291
- */
292
- download(cid: string): Promise<Blob | Buffer>;
293
- /**
294
- * Get a direct URL for content by CID.
295
- *
296
- * This is useful for embedding in img tags or for direct downloads.
297
- *
298
- * @param cid - Content Identifier
299
- * @returns URL string
300
- *
301
- * @example
302
- * ```typescript
303
- * const url = content.getUrl('bafybeih...');
304
- * // Use in img tag: <img src={url} />
305
- * ```
306
- */
307
- getUrl(cid: string): string;
308
- /**
309
- * Stream content by CID.
310
- *
311
- * @param cid - Content Identifier
312
- * @returns ReadableStream of the content
313
- * @throws ContentNotFoundError if the content doesn't exist
314
- *
315
- * @example
316
- * ```typescript
317
- * const stream = await content.stream('bafybeih...');
318
- * const reader = stream.getReader();
319
- * while (true) {
320
- * const { done, value } = await reader.read();
321
- * if (done) break;
322
- * // Process chunk
323
- * }
324
- * ```
325
- */
326
- stream(cid: string): Promise<ReadableStream<Uint8Array>>;
327
- /**
328
- * Download a component from an entity.
329
- *
330
- * @param entity - Entity containing the component
331
- * @param componentName - Name of the component (e.g., 'pinax', 'description', 'source')
332
- * @returns Component content as Blob (browser) or Buffer (Node)
333
- * @throws ComponentNotFoundError if the component doesn't exist
334
- *
335
- * @example
336
- * ```typescript
337
- * const entity = await content.get('01K75HQQXNTDG7BBP7PS9AWYAN');
338
- * const pinax = await content.getComponent(entity, 'pinax');
339
- * ```
340
- */
341
- getComponent(entity: Entity, componentName: string): Promise<Blob | Buffer>;
342
- /**
343
- * Get the URL for a component from an entity.
344
- *
345
- * @param entity - Entity containing the component
346
- * @param componentName - Name of the component
347
- * @returns URL string
348
- * @throws ComponentNotFoundError if the component doesn't exist
349
- *
350
- * @example
351
- * ```typescript
352
- * const entity = await content.get('01K75HQQXNTDG7BBP7PS9AWYAN');
353
- * const imageUrl = content.getComponentUrl(entity, 'source');
354
- * // Use in img tag: <img src={imageUrl} />
355
- * ```
356
- */
357
- getComponentUrl(entity: Entity, componentName: string): string;
358
- }
359
-
360
- /**
361
- * Content package error classes for the Arke SDK
362
- */
363
- /**
364
- * Base error class for content operations
365
- */
366
- declare class ContentError extends Error {
367
- code: string;
368
- details?: unknown | undefined;
369
- constructor(message: string, code?: string, details?: unknown | undefined);
370
- }
371
- /**
372
- * Thrown when an entity is not found by PI
373
- */
374
- declare class EntityNotFoundError extends ContentError {
375
- constructor(pi: string);
376
- }
377
- /**
378
- * Thrown when content is not found by CID
379
- */
380
- declare class ContentNotFoundError extends ContentError {
381
- constructor(cid: string);
382
- }
383
- /**
384
- * Thrown when a component is not found on an entity
385
- */
386
- declare class ComponentNotFoundError extends ContentError {
387
- constructor(pi: string, componentName: string);
388
- }
389
- /**
390
- * Thrown when a version is not found
391
- */
392
- declare class VersionNotFoundError extends ContentError {
393
- constructor(pi: string, selector: string);
394
- }
395
- /**
396
- * Thrown when a network error occurs
397
- */
398
- declare class NetworkError extends ContentError {
399
- statusCode?: number | undefined;
400
- constructor(message: string, statusCode?: number | undefined);
401
- }
402
-
403
- export { ComponentNotFoundError, ContentClient, type ContentClientConfig, ContentError, ContentNotFoundError, type Entity, EntityNotFoundError, type EntitySummary, type EntityVersion, type ListOptions, type ListResponse, NetworkError, type ResolveResponse, VersionNotFoundError, type VersionsOptions, type VersionsResponse };