@arke-institute/sdk 0.1.3 → 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.
- package/README.md +126 -184
- package/dist/generated/index.cjs +19 -0
- package/dist/generated/index.cjs.map +1 -0
- package/dist/generated/index.d.cts +6192 -0
- package/dist/generated/index.d.ts +6192 -0
- package/dist/generated/index.js +1 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/index-BrXke2kI.d.ts +302 -0
- package/dist/index-FHcLPBSV.d.cts +302 -0
- package/dist/index.cjs +188 -4254
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -7
- package/dist/index.d.ts +62 -7
- package/dist/index.js +168 -4226
- package/dist/index.js.map +1 -1
- package/dist/operations/index.cjs +113 -0
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +3 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +84 -0
- package/dist/operations/index.js.map +1 -0
- package/package.json +44 -53
- package/dist/client-dAk3E64p.d.cts +0 -183
- package/dist/client-dAk3E64p.d.ts +0 -183
- package/dist/collections/index.cjs +0 -233
- package/dist/collections/index.cjs.map +0 -1
- package/dist/collections/index.d.cts +0 -9
- package/dist/collections/index.d.ts +0 -9
- package/dist/collections/index.js +0 -205
- package/dist/collections/index.js.map +0 -1
- package/dist/content/index.cjs +0 -591
- package/dist/content/index.cjs.map +0 -1
- package/dist/content/index.d.cts +0 -516
- package/dist/content/index.d.ts +0 -516
- package/dist/content/index.js +0 -558
- package/dist/content/index.js.map +0 -1
- package/dist/edit/index.cjs +0 -1503
- package/dist/edit/index.cjs.map +0 -1
- package/dist/edit/index.d.cts +0 -78
- package/dist/edit/index.d.ts +0 -78
- package/dist/edit/index.js +0 -1447
- package/dist/edit/index.js.map +0 -1
- package/dist/errors-3L7IiHcr.d.cts +0 -480
- package/dist/errors-BTe8GKRQ.d.ts +0 -480
- package/dist/errors-CT7yzKkU.d.cts +0 -874
- package/dist/errors-CT7yzKkU.d.ts +0 -874
- package/dist/graph/index.cjs +0 -427
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.d.cts +0 -485
- package/dist/graph/index.d.ts +0 -485
- package/dist/graph/index.js +0 -396
- package/dist/graph/index.js.map +0 -1
- package/dist/query/index.cjs +0 -356
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -636
- package/dist/query/index.d.ts +0 -636
- package/dist/query/index.js +0 -328
- package/dist/query/index.js.map +0 -1
- package/dist/upload/index.cjs +0 -1634
- package/dist/upload/index.cjs.map +0 -1
- package/dist/upload/index.d.cts +0 -150
- package/dist/upload/index.d.ts +0 -150
- package/dist/upload/index.js +0 -1597
- package/dist/upload/index.js.map +0 -1
|
@@ -1,874 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Arke SDK - Edit Package Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Types for write operations against the IPFS Wrapper API.
|
|
5
|
-
* Based on the arke/eidos@v1 schema.
|
|
6
|
-
*/
|
|
7
|
-
/** Network type for API requests */
|
|
8
|
-
type Network = 'main' | 'test';
|
|
9
|
-
/**
|
|
10
|
-
* Full entity manifest from IPFS Wrapper
|
|
11
|
-
*/
|
|
12
|
-
interface Entity {
|
|
13
|
-
/** Entity identifier (ULID or test ID with II prefix) */
|
|
14
|
-
id: string;
|
|
15
|
-
/** Entity type (e.g., "PI", "person", "place", "concept", "document") */
|
|
16
|
-
type: string;
|
|
17
|
-
/** Creation timestamp (immutable, set at v1) */
|
|
18
|
-
created_at: string;
|
|
19
|
-
/** Display name */
|
|
20
|
-
label?: string;
|
|
21
|
-
/** Human-readable description */
|
|
22
|
-
description?: string;
|
|
23
|
-
/** Version number */
|
|
24
|
-
ver: number;
|
|
25
|
-
/** Timestamp when this version was created */
|
|
26
|
-
ts: string;
|
|
27
|
-
/** CID of this manifest */
|
|
28
|
-
manifest_cid: string;
|
|
29
|
-
/** CID of the previous version (null for version 1) */
|
|
30
|
-
prev_cid: string | null;
|
|
31
|
-
/** Map of component names to their CIDs */
|
|
32
|
-
components: Record<string, string>;
|
|
33
|
-
/** IDs of child entities */
|
|
34
|
-
children_pi?: string[];
|
|
35
|
-
/** ID of parent entity */
|
|
36
|
-
parent_pi?: string;
|
|
37
|
-
/** Provenance: which PI extracted this entity */
|
|
38
|
-
source_pi?: string;
|
|
39
|
-
/** IDs of entities that have been merged into this one */
|
|
40
|
-
merged_entities?: string[];
|
|
41
|
-
/** Change note for this version */
|
|
42
|
-
note?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Summary entity info returned when listing entities
|
|
46
|
-
*/
|
|
47
|
-
interface EntitySummary {
|
|
48
|
-
/** Entity identifier */
|
|
49
|
-
id: string;
|
|
50
|
-
/** Tip CID (latest manifest) */
|
|
51
|
-
tip: string;
|
|
52
|
-
/** Entity type (if include_metadata=true) */
|
|
53
|
-
type?: string;
|
|
54
|
-
/** Display name (if include_metadata=true) */
|
|
55
|
-
label?: string;
|
|
56
|
-
/** Version number (if include_metadata=true) */
|
|
57
|
-
ver?: number;
|
|
58
|
-
/** Timestamp (if include_metadata=true) */
|
|
59
|
-
ts?: string;
|
|
60
|
-
/** Change note (if include_metadata=true) */
|
|
61
|
-
note?: string;
|
|
62
|
-
/** Number of components (if include_metadata=true) */
|
|
63
|
-
component_count?: number;
|
|
64
|
-
/** Number of children (if include_metadata=true) */
|
|
65
|
-
children_count?: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Version entry in version history
|
|
69
|
-
*/
|
|
70
|
-
interface VersionHistoryItem {
|
|
71
|
-
/** Version number */
|
|
72
|
-
ver: number;
|
|
73
|
-
/** CID of this version's manifest */
|
|
74
|
-
cid: string;
|
|
75
|
-
/** Timestamp when this version was created */
|
|
76
|
-
ts: string;
|
|
77
|
-
/** Change note for this version */
|
|
78
|
-
note?: string;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* A single relationship edge in the semantic graph
|
|
82
|
-
*/
|
|
83
|
-
interface Relationship {
|
|
84
|
-
/** Relationship predicate (e.g., "authored_by", "mentions", "located_in") */
|
|
85
|
-
predicate: string;
|
|
86
|
-
/** Type of target */
|
|
87
|
-
target_type: 'pi' | 'entity';
|
|
88
|
-
/** Target entity identifier */
|
|
89
|
-
target_id: string;
|
|
90
|
-
/** Display label for the target (e.g., "Alice Austen") */
|
|
91
|
-
target_label: string;
|
|
92
|
-
/** Target entity type (e.g., "person", "place") - only if target is entity */
|
|
93
|
-
target_entity_type?: string;
|
|
94
|
-
/** Optional metadata on the relationship edge */
|
|
95
|
-
properties?: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Request to create a new entity
|
|
99
|
-
*/
|
|
100
|
-
interface CreateEntityRequest {
|
|
101
|
-
/** Entity ID (optional - server generates ULID if omitted) */
|
|
102
|
-
id?: string;
|
|
103
|
-
/** Entity type (required, e.g., "PI", "person", "place") */
|
|
104
|
-
type: string;
|
|
105
|
-
/** Components map: label → CID */
|
|
106
|
-
components: Record<string, string>;
|
|
107
|
-
/** Display name */
|
|
108
|
-
label?: string;
|
|
109
|
-
/** Human-readable description */
|
|
110
|
-
description?: string;
|
|
111
|
-
/** Parent entity ID (auto-updates parent's children_pi) */
|
|
112
|
-
parent_pi?: string;
|
|
113
|
-
/** Child entity IDs */
|
|
114
|
-
children_pi?: string[];
|
|
115
|
-
/** Provenance: which PI extracted this entity */
|
|
116
|
-
source_pi?: string;
|
|
117
|
-
/** Initial properties (will be stored as component) */
|
|
118
|
-
properties?: Record<string, unknown>;
|
|
119
|
-
/** Initial relationships (will be stored as component) */
|
|
120
|
-
relationships?: Relationship[];
|
|
121
|
-
/** Change note */
|
|
122
|
-
note?: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Response from creating an entity
|
|
126
|
-
*/
|
|
127
|
-
interface CreateEntityResponse {
|
|
128
|
-
/** Entity identifier */
|
|
129
|
-
id: string;
|
|
130
|
-
/** Entity type */
|
|
131
|
-
type: string;
|
|
132
|
-
/** Version number (always 1 for new entities) */
|
|
133
|
-
ver: number;
|
|
134
|
-
/** CID of the manifest */
|
|
135
|
-
manifest_cid: string;
|
|
136
|
-
/** Tip CID (same as manifest_cid for new entities) */
|
|
137
|
-
tip: string;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Request to append a new version to an entity
|
|
141
|
-
*/
|
|
142
|
-
interface UpdateEntityRequest {
|
|
143
|
-
/** Current tip CID (CAS guard - required) */
|
|
144
|
-
expect_tip: string;
|
|
145
|
-
/** Change entity type */
|
|
146
|
-
type?: string;
|
|
147
|
-
/** Update display name */
|
|
148
|
-
label?: string;
|
|
149
|
-
/** Update description */
|
|
150
|
-
description?: string;
|
|
151
|
-
/** Components to add/update: label → CID */
|
|
152
|
-
components?: Record<string, string>;
|
|
153
|
-
/** Component labels to remove */
|
|
154
|
-
components_remove?: string[];
|
|
155
|
-
/** Child IDs to add (max 100, auto-updates children's parent_pi) */
|
|
156
|
-
children_pi_add?: string[];
|
|
157
|
-
/** Child IDs to remove (max 100, auto-updates children's parent_pi) */
|
|
158
|
-
children_pi_remove?: string[];
|
|
159
|
-
/** Replace entire properties object */
|
|
160
|
-
properties?: Record<string, unknown>;
|
|
161
|
-
/** Replace entire relationships array */
|
|
162
|
-
relationships?: Relationship[];
|
|
163
|
-
/** Change note */
|
|
164
|
-
note?: string;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Response from updating an entity
|
|
168
|
-
*/
|
|
169
|
-
interface UpdateEntityResponse {
|
|
170
|
-
/** Entity identifier */
|
|
171
|
-
id: string;
|
|
172
|
-
/** Entity type */
|
|
173
|
-
type: string;
|
|
174
|
-
/** New version number */
|
|
175
|
-
ver: number;
|
|
176
|
-
/** CID of the new manifest */
|
|
177
|
-
manifest_cid: string;
|
|
178
|
-
/** New tip CID */
|
|
179
|
-
tip: string;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Options for listing entities
|
|
183
|
-
*/
|
|
184
|
-
interface ListEntitiesOptions {
|
|
185
|
-
/** Maximum entities to return (1-1000, default: 100) */
|
|
186
|
-
limit?: number;
|
|
187
|
-
/** Pagination cursor from next_cursor */
|
|
188
|
-
cursor?: string;
|
|
189
|
-
/** Include full metadata for each entity */
|
|
190
|
-
include_metadata?: boolean;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Response from listing entities
|
|
194
|
-
*/
|
|
195
|
-
interface ListEntitiesResponse {
|
|
196
|
-
/** List of entity summaries */
|
|
197
|
-
entities: EntitySummary[];
|
|
198
|
-
/** Limit used */
|
|
199
|
-
limit: number;
|
|
200
|
-
/** Cursor for next page (null if no more) */
|
|
201
|
-
next_cursor: string | null;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Options for listing versions
|
|
205
|
-
*/
|
|
206
|
-
interface ListVersionsOptions {
|
|
207
|
-
/** Maximum versions to return (1-1000, default: 50) */
|
|
208
|
-
limit?: number;
|
|
209
|
-
/** Pagination cursor (manifest CID) */
|
|
210
|
-
cursor?: string;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Response from listing versions
|
|
214
|
-
*/
|
|
215
|
-
interface ListVersionsResponse {
|
|
216
|
-
/** List of versions (newest first) */
|
|
217
|
-
items: VersionHistoryItem[];
|
|
218
|
-
/** Cursor for next page (null if reached genesis) */
|
|
219
|
-
next_cursor: string | null;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Response from resolving an ID to tip
|
|
223
|
-
*/
|
|
224
|
-
interface ResolveResponse {
|
|
225
|
-
/** Entity identifier */
|
|
226
|
-
id: string;
|
|
227
|
-
/** Tip CID (latest manifest) */
|
|
228
|
-
tip: string;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Request to update parent-child hierarchy
|
|
232
|
-
*/
|
|
233
|
-
interface UpdateHierarchyRequest {
|
|
234
|
-
/** Parent entity ID */
|
|
235
|
-
parent_id: string;
|
|
236
|
-
/** Current parent tip CID (CAS guard) */
|
|
237
|
-
expect_tip: string;
|
|
238
|
-
/** Child IDs to add (max 100) */
|
|
239
|
-
add_children?: string[];
|
|
240
|
-
/** Child IDs to remove (max 100) */
|
|
241
|
-
remove_children?: string[];
|
|
242
|
-
/** Change note */
|
|
243
|
-
note?: string;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Response from updating hierarchy
|
|
247
|
-
*/
|
|
248
|
-
interface UpdateHierarchyResponse {
|
|
249
|
-
/** Parent entity ID */
|
|
250
|
-
parent_pi: string;
|
|
251
|
-
/** New parent version */
|
|
252
|
-
parent_ver: number;
|
|
253
|
-
/** New parent tip CID */
|
|
254
|
-
parent_tip: string;
|
|
255
|
-
/** Number of children successfully updated */
|
|
256
|
-
children_updated: number;
|
|
257
|
-
/** Number of children that failed to update */
|
|
258
|
-
children_failed: number;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Request to merge source entity into target
|
|
262
|
-
*/
|
|
263
|
-
interface MergeEntityRequest {
|
|
264
|
-
/** Target entity ID (entity to merge into) */
|
|
265
|
-
target_id: string;
|
|
266
|
-
/** Current target tip CID (CAS guard) */
|
|
267
|
-
expect_target_tip: string;
|
|
268
|
-
/** Reason for merge */
|
|
269
|
-
note?: string;
|
|
270
|
-
/** Skip index-sync callback (internal use) */
|
|
271
|
-
skip_sync?: boolean;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Response from merging entities
|
|
275
|
-
*/
|
|
276
|
-
interface MergeEntityResponse {
|
|
277
|
-
/** Source entity ID (now a tombstone) */
|
|
278
|
-
source_id: string;
|
|
279
|
-
/** Target entity ID */
|
|
280
|
-
target_id: string;
|
|
281
|
-
/** New target version */
|
|
282
|
-
target_ver: number;
|
|
283
|
-
/** New target tip CID */
|
|
284
|
-
target_tip: string;
|
|
285
|
-
/** CID of the tombstone manifest */
|
|
286
|
-
tombstone_cid: string;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Request to unmerge (restore) a previously merged entity
|
|
290
|
-
*/
|
|
291
|
-
interface UnmergeEntityRequest {
|
|
292
|
-
/** Target entity ID (entity it was merged into) */
|
|
293
|
-
target_id: string;
|
|
294
|
-
/** Current target tip CID (CAS guard) */
|
|
295
|
-
expect_target_tip: string;
|
|
296
|
-
/** Reason for unmerge */
|
|
297
|
-
note?: string;
|
|
298
|
-
/** Skip index-sync callback (internal use) */
|
|
299
|
-
skip_sync?: boolean;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Response from unmerging entity
|
|
303
|
-
*/
|
|
304
|
-
interface UnmergeEntityResponse {
|
|
305
|
-
/** Restored source entity ID */
|
|
306
|
-
source_id: string;
|
|
307
|
-
/** New source version */
|
|
308
|
-
source_ver: number;
|
|
309
|
-
/** New source tip CID */
|
|
310
|
-
source_tip: string;
|
|
311
|
-
/** Target entity ID */
|
|
312
|
-
target_id: string;
|
|
313
|
-
/** New target version */
|
|
314
|
-
target_ver: number;
|
|
315
|
-
/** New target tip CID */
|
|
316
|
-
target_tip: string;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Request to soft delete an entity
|
|
320
|
-
*/
|
|
321
|
-
interface DeleteEntityRequest {
|
|
322
|
-
/** Current tip CID (CAS guard) */
|
|
323
|
-
expect_tip: string;
|
|
324
|
-
/** Reason for deletion */
|
|
325
|
-
note?: string;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Response from deleting an entity
|
|
329
|
-
*/
|
|
330
|
-
interface DeleteEntityResponse {
|
|
331
|
-
/** Entity ID */
|
|
332
|
-
id: string;
|
|
333
|
-
/** Version number of the tombstone */
|
|
334
|
-
deleted_ver: number;
|
|
335
|
-
/** Timestamp of deletion */
|
|
336
|
-
deleted_at: string;
|
|
337
|
-
/** CID of the tombstone manifest */
|
|
338
|
-
deleted_manifest_cid: string;
|
|
339
|
-
/** Previous version number (before deletion) */
|
|
340
|
-
previous_ver: number;
|
|
341
|
-
/** CID of the previous manifest */
|
|
342
|
-
prev_cid: string;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Request to restore a deleted entity
|
|
346
|
-
*/
|
|
347
|
-
interface UndeleteEntityRequest {
|
|
348
|
-
/** Current tip CID (tombstone CID, CAS guard) */
|
|
349
|
-
expect_tip: string;
|
|
350
|
-
/** Reason for restoration */
|
|
351
|
-
note?: string;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Response from restoring a deleted entity
|
|
355
|
-
*/
|
|
356
|
-
interface UndeleteEntityResponse {
|
|
357
|
-
/** Entity ID */
|
|
358
|
-
id: string;
|
|
359
|
-
/** New version number after restoration */
|
|
360
|
-
restored_ver: number;
|
|
361
|
-
/** Version number that was restored from */
|
|
362
|
-
restored_from_ver: number;
|
|
363
|
-
/** CID of the new manifest */
|
|
364
|
-
new_manifest_cid: string;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Response from uploading files
|
|
368
|
-
*/
|
|
369
|
-
interface UploadResponse {
|
|
370
|
-
/** Original filename */
|
|
371
|
-
name: string;
|
|
372
|
-
/** CID of the uploaded content */
|
|
373
|
-
cid: string;
|
|
374
|
-
/** Size in bytes */
|
|
375
|
-
size: number;
|
|
376
|
-
}
|
|
377
|
-
type EditMode = 'ai-prompt' | 'manual-with-review' | 'manual-only';
|
|
378
|
-
interface EditSessionConfig {
|
|
379
|
-
mode: EditMode;
|
|
380
|
-
aiReviewEnabled?: boolean;
|
|
381
|
-
}
|
|
382
|
-
type RegeneratableComponent = 'pinax' | 'description' | 'cheimarros';
|
|
383
|
-
interface EditScope {
|
|
384
|
-
components: RegeneratableComponent[];
|
|
385
|
-
cascade: boolean;
|
|
386
|
-
stopAtPi?: string;
|
|
387
|
-
}
|
|
388
|
-
interface Correction {
|
|
389
|
-
original: string;
|
|
390
|
-
corrected: string;
|
|
391
|
-
sourceFile?: string;
|
|
392
|
-
context?: string;
|
|
393
|
-
}
|
|
394
|
-
type DiffType = 'addition' | 'deletion' | 'change' | 'unchanged';
|
|
395
|
-
interface TextDiff {
|
|
396
|
-
type: DiffType;
|
|
397
|
-
original?: string;
|
|
398
|
-
modified?: string;
|
|
399
|
-
lineNumber?: number;
|
|
400
|
-
context?: string;
|
|
401
|
-
}
|
|
402
|
-
interface ComponentDiff {
|
|
403
|
-
componentName: string;
|
|
404
|
-
diffs: TextDiff[];
|
|
405
|
-
summary: string;
|
|
406
|
-
hasChanges: boolean;
|
|
407
|
-
}
|
|
408
|
-
type PromptTarget = RegeneratableComponent | 'general' | 'reorganization';
|
|
409
|
-
interface EntityContext {
|
|
410
|
-
pi: string;
|
|
411
|
-
ver: number;
|
|
412
|
-
parentPi?: string;
|
|
413
|
-
childrenCount: number;
|
|
414
|
-
currentContent: Record<string, string>;
|
|
415
|
-
}
|
|
416
|
-
interface CascadeContext {
|
|
417
|
-
path: string[];
|
|
418
|
-
depth: number;
|
|
419
|
-
stopAtPi?: string;
|
|
420
|
-
}
|
|
421
|
-
interface CustomPrompts {
|
|
422
|
-
general?: string;
|
|
423
|
-
pinax?: string;
|
|
424
|
-
description?: string;
|
|
425
|
-
cheimarros?: string;
|
|
426
|
-
reorganization?: string;
|
|
427
|
-
}
|
|
428
|
-
interface ReprocessRequest {
|
|
429
|
-
pi: string;
|
|
430
|
-
phases: RegeneratableComponent[];
|
|
431
|
-
cascade: boolean;
|
|
432
|
-
options?: {
|
|
433
|
-
stop_at_pi?: string;
|
|
434
|
-
custom_prompts?: CustomPrompts;
|
|
435
|
-
custom_note?: string;
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
interface ReprocessResult {
|
|
439
|
-
batch_id: string;
|
|
440
|
-
entities_queued: number;
|
|
441
|
-
entity_pis: string[];
|
|
442
|
-
status_url: string;
|
|
443
|
-
}
|
|
444
|
-
type ReprocessPhase = 'QUEUED' | 'DISCOVERY' | 'OCR_IN_PROGRESS' | 'REORGANIZATION' | 'PINAX_EXTRACTION' | 'CHEIMARROS_EXTRACTION' | 'DESCRIPTION' | 'DONE' | 'ERROR';
|
|
445
|
-
interface ReprocessProgress {
|
|
446
|
-
directories_total: number;
|
|
447
|
-
directories_pinax_complete: number;
|
|
448
|
-
directories_cheimarros_complete: number;
|
|
449
|
-
directories_description_complete: number;
|
|
450
|
-
}
|
|
451
|
-
interface ReprocessStatus {
|
|
452
|
-
batch_id: string;
|
|
453
|
-
status: ReprocessPhase;
|
|
454
|
-
progress: ReprocessProgress;
|
|
455
|
-
root_pi?: string;
|
|
456
|
-
error?: string;
|
|
457
|
-
started_at?: string;
|
|
458
|
-
completed_at?: string;
|
|
459
|
-
}
|
|
460
|
-
interface SaveResult {
|
|
461
|
-
pi: string;
|
|
462
|
-
newVersion: number;
|
|
463
|
-
newTip: string;
|
|
464
|
-
}
|
|
465
|
-
interface EditResult {
|
|
466
|
-
saved?: SaveResult;
|
|
467
|
-
reprocess?: ReprocessResult;
|
|
468
|
-
}
|
|
469
|
-
type EditPhase = 'idle' | 'saving' | 'reprocessing' | 'complete' | 'error';
|
|
470
|
-
interface EditStatus {
|
|
471
|
-
phase: EditPhase;
|
|
472
|
-
saveComplete: boolean;
|
|
473
|
-
reprocessStatus?: ReprocessStatus;
|
|
474
|
-
error?: string;
|
|
475
|
-
}
|
|
476
|
-
interface PollOptions {
|
|
477
|
-
intervalMs?: number;
|
|
478
|
-
timeoutMs?: number;
|
|
479
|
-
onProgress?: (status: EditStatus) => void;
|
|
480
|
-
}
|
|
481
|
-
interface ChangeSummary {
|
|
482
|
-
mode: EditMode;
|
|
483
|
-
hasManualEdits: boolean;
|
|
484
|
-
editedComponents: string[];
|
|
485
|
-
corrections: Correction[];
|
|
486
|
-
prompts: Record<string, string>;
|
|
487
|
-
scope: EditScope;
|
|
488
|
-
willRegenerate: RegeneratableComponent[];
|
|
489
|
-
willCascade: boolean;
|
|
490
|
-
willSave: boolean;
|
|
491
|
-
willReprocess: boolean;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Configuration for retry behavior on transient errors
|
|
495
|
-
*/
|
|
496
|
-
interface RetryConfig {
|
|
497
|
-
/** Maximum retry attempts (default: 10) */
|
|
498
|
-
maxRetries: number;
|
|
499
|
-
/** Base delay in ms (default: 100) */
|
|
500
|
-
baseDelay: number;
|
|
501
|
-
/** Maximum delay in ms (default: 5000) */
|
|
502
|
-
maxDelay: number;
|
|
503
|
-
/** Jitter factor 0-1 (default: 0.3) */
|
|
504
|
-
jitterFactor: number;
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Default retry configuration based on API spec recommendations
|
|
508
|
-
*/
|
|
509
|
-
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* EditClient - Complete API client for Arke edit operations
|
|
513
|
-
*
|
|
514
|
-
* Provides full access to IPFS Wrapper write operations:
|
|
515
|
-
* - Entity CRUD (create, read, update, delete)
|
|
516
|
-
* - Version management
|
|
517
|
-
* - Hierarchy operations
|
|
518
|
-
* - Merge/unmerge operations
|
|
519
|
-
* - Content upload
|
|
520
|
-
* - Reprocessing
|
|
521
|
-
*
|
|
522
|
-
* Routes through the gateway:
|
|
523
|
-
* - /api/* -> IPFS Wrapper (entities, content, uploads)
|
|
524
|
-
* - /reprocess/* -> Reprocess API
|
|
525
|
-
*/
|
|
526
|
-
|
|
527
|
-
/** Configuration for EditClient */
|
|
528
|
-
interface EditClientConfig {
|
|
529
|
-
/** Gateway URL (e.g., https://gateway.arke.io) or direct API URL */
|
|
530
|
-
gatewayUrl: string;
|
|
531
|
-
/** JWT auth token */
|
|
532
|
-
authToken?: string;
|
|
533
|
-
/** Network to use (default: 'main') */
|
|
534
|
-
network?: Network;
|
|
535
|
-
/** User ID for permission checks */
|
|
536
|
-
userId?: string;
|
|
537
|
-
/** Retry configuration */
|
|
538
|
-
retryConfig?: Partial<RetryConfig>;
|
|
539
|
-
/** Optional transform for status URLs (e.g., for CORS proxy) */
|
|
540
|
-
statusUrlTransform?: (url: string) => string;
|
|
541
|
-
/**
|
|
542
|
-
* API prefix for IPFS wrapper routes (default: '/api').
|
|
543
|
-
* Set to '' (empty string) when using direct API URL like https://api.arke.institute
|
|
544
|
-
*/
|
|
545
|
-
apiPrefix?: string;
|
|
546
|
-
}
|
|
547
|
-
declare class EditClient {
|
|
548
|
-
private gatewayUrl;
|
|
549
|
-
private authToken?;
|
|
550
|
-
private network;
|
|
551
|
-
private userId?;
|
|
552
|
-
private retryConfig;
|
|
553
|
-
private statusUrlTransform?;
|
|
554
|
-
private apiPrefix;
|
|
555
|
-
constructor(config: EditClientConfig);
|
|
556
|
-
/**
|
|
557
|
-
* Update the auth token (useful for token refresh)
|
|
558
|
-
*/
|
|
559
|
-
setAuthToken(token: string): void;
|
|
560
|
-
/**
|
|
561
|
-
* Set the network (main or test)
|
|
562
|
-
*/
|
|
563
|
-
setNetwork(network: Network): void;
|
|
564
|
-
/**
|
|
565
|
-
* Set the user ID for permission checks
|
|
566
|
-
*/
|
|
567
|
-
setUserId(userId: string): void;
|
|
568
|
-
/**
|
|
569
|
-
* Build URL with API prefix
|
|
570
|
-
*/
|
|
571
|
-
private buildUrl;
|
|
572
|
-
private sleep;
|
|
573
|
-
private getHeaders;
|
|
574
|
-
private calculateDelay;
|
|
575
|
-
private isRetryableStatus;
|
|
576
|
-
private isRetryableError;
|
|
577
|
-
/**
|
|
578
|
-
* Execute a fetch with exponential backoff retry on transient errors
|
|
579
|
-
*/
|
|
580
|
-
private fetchWithRetry;
|
|
581
|
-
/**
|
|
582
|
-
* Handle common error responses and throw appropriate error types
|
|
583
|
-
*/
|
|
584
|
-
private handleErrorResponse;
|
|
585
|
-
/**
|
|
586
|
-
* Create a new entity
|
|
587
|
-
*/
|
|
588
|
-
createEntity(request: CreateEntityRequest): Promise<CreateEntityResponse>;
|
|
589
|
-
/**
|
|
590
|
-
* Get an entity by ID
|
|
591
|
-
*/
|
|
592
|
-
getEntity(id: string): Promise<Entity>;
|
|
593
|
-
/**
|
|
594
|
-
* List entities with pagination
|
|
595
|
-
*/
|
|
596
|
-
listEntities(options?: ListEntitiesOptions): Promise<ListEntitiesResponse>;
|
|
597
|
-
/**
|
|
598
|
-
* Update an entity (append new version)
|
|
599
|
-
*/
|
|
600
|
-
updateEntity(id: string, update: UpdateEntityRequest): Promise<UpdateEntityResponse>;
|
|
601
|
-
/**
|
|
602
|
-
* List version history for an entity
|
|
603
|
-
*/
|
|
604
|
-
listVersions(id: string, options?: ListVersionsOptions): Promise<ListVersionsResponse>;
|
|
605
|
-
/**
|
|
606
|
-
* Get a specific version of an entity
|
|
607
|
-
*/
|
|
608
|
-
getVersion(id: string, selector: string): Promise<Entity>;
|
|
609
|
-
/**
|
|
610
|
-
* Resolve an entity ID to its current tip CID (fast lookup)
|
|
611
|
-
*/
|
|
612
|
-
resolve(id: string): Promise<ResolveResponse>;
|
|
613
|
-
/**
|
|
614
|
-
* Update parent-child hierarchy relationships
|
|
615
|
-
*/
|
|
616
|
-
updateHierarchy(request: UpdateHierarchyRequest): Promise<UpdateHierarchyResponse>;
|
|
617
|
-
/**
|
|
618
|
-
* Merge source entity into target entity
|
|
619
|
-
*/
|
|
620
|
-
mergeEntity(sourceId: string, request: MergeEntityRequest): Promise<MergeEntityResponse>;
|
|
621
|
-
/**
|
|
622
|
-
* Unmerge (restore) a previously merged entity
|
|
623
|
-
*/
|
|
624
|
-
unmergeEntity(sourceId: string, request: UnmergeEntityRequest): Promise<UnmergeEntityResponse>;
|
|
625
|
-
/**
|
|
626
|
-
* Soft delete an entity (creates tombstone, preserves history)
|
|
627
|
-
*/
|
|
628
|
-
deleteEntity(id: string, request: DeleteEntityRequest): Promise<DeleteEntityResponse>;
|
|
629
|
-
/**
|
|
630
|
-
* Restore a deleted entity
|
|
631
|
-
*/
|
|
632
|
-
undeleteEntity(id: string, request: UndeleteEntityRequest): Promise<UndeleteEntityResponse>;
|
|
633
|
-
/**
|
|
634
|
-
* Upload files to IPFS
|
|
635
|
-
*/
|
|
636
|
-
upload(files: File | Blob | File[] | Blob[] | FormData): Promise<UploadResponse[]>;
|
|
637
|
-
/**
|
|
638
|
-
* Upload text content and return CID
|
|
639
|
-
*/
|
|
640
|
-
uploadContent(content: string, filename: string): Promise<string>;
|
|
641
|
-
/**
|
|
642
|
-
* Download file content by CID
|
|
643
|
-
*/
|
|
644
|
-
getContent(cid: string): Promise<string>;
|
|
645
|
-
/**
|
|
646
|
-
* Download a DAG node (JSON) by CID
|
|
647
|
-
*/
|
|
648
|
-
getDag<T = unknown>(cid: string): Promise<T>;
|
|
649
|
-
/**
|
|
650
|
-
* Get the Arke origin block (genesis entity)
|
|
651
|
-
*/
|
|
652
|
-
getArke(): Promise<Entity>;
|
|
653
|
-
/**
|
|
654
|
-
* Initialize the Arke origin block (creates if doesn't exist)
|
|
655
|
-
*/
|
|
656
|
-
initArke(): Promise<CreateEntityResponse>;
|
|
657
|
-
/**
|
|
658
|
-
* Trigger reprocessing for an entity
|
|
659
|
-
*/
|
|
660
|
-
reprocess(request: ReprocessRequest): Promise<ReprocessResult>;
|
|
661
|
-
/**
|
|
662
|
-
* Get reprocessing status by batch ID
|
|
663
|
-
*/
|
|
664
|
-
getReprocessStatus(statusUrl: string, isFirstPoll?: boolean): Promise<ReprocessStatus>;
|
|
665
|
-
/**
|
|
666
|
-
* Execute an operation with automatic CAS retry
|
|
667
|
-
*/
|
|
668
|
-
withCAS<T>(id: string, operation: (entity: Entity) => Promise<T>, maxRetries?: number): Promise<T>;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* EditSession - Stateful session managing an edit workflow
|
|
673
|
-
*/
|
|
674
|
-
|
|
675
|
-
declare class EditSession {
|
|
676
|
-
readonly pi: string;
|
|
677
|
-
readonly mode: EditMode;
|
|
678
|
-
readonly aiReviewEnabled: boolean;
|
|
679
|
-
private client;
|
|
680
|
-
private entity;
|
|
681
|
-
private loadedComponents;
|
|
682
|
-
private prompts;
|
|
683
|
-
private editedContent;
|
|
684
|
-
private corrections;
|
|
685
|
-
private scope;
|
|
686
|
-
private submitting;
|
|
687
|
-
private result;
|
|
688
|
-
private statusUrl;
|
|
689
|
-
constructor(client: EditClient, pi: string, config?: EditSessionConfig);
|
|
690
|
-
/**
|
|
691
|
-
* Load the entity and its key components
|
|
692
|
-
*/
|
|
693
|
-
load(): Promise<void>;
|
|
694
|
-
/**
|
|
695
|
-
* Load a specific component on demand
|
|
696
|
-
*/
|
|
697
|
-
loadComponent(name: string): Promise<string | undefined>;
|
|
698
|
-
/**
|
|
699
|
-
* Get the loaded entity
|
|
700
|
-
*/
|
|
701
|
-
getEntity(): Entity;
|
|
702
|
-
/**
|
|
703
|
-
* Get loaded component content
|
|
704
|
-
*/
|
|
705
|
-
getComponents(): Record<string, string>;
|
|
706
|
-
/**
|
|
707
|
-
* Set a prompt for AI regeneration
|
|
708
|
-
*/
|
|
709
|
-
setPrompt(target: PromptTarget, prompt: string): void;
|
|
710
|
-
/**
|
|
711
|
-
* Get all prompts
|
|
712
|
-
*/
|
|
713
|
-
getPrompts(): Record<string, string>;
|
|
714
|
-
/**
|
|
715
|
-
* Clear a prompt
|
|
716
|
-
*/
|
|
717
|
-
clearPrompt(target: PromptTarget): void;
|
|
718
|
-
/**
|
|
719
|
-
* Set edited content for a component
|
|
720
|
-
*/
|
|
721
|
-
setContent(componentName: string, content: string): void;
|
|
722
|
-
/**
|
|
723
|
-
* Get all edited content
|
|
724
|
-
*/
|
|
725
|
-
getEditedContent(): Record<string, string>;
|
|
726
|
-
/**
|
|
727
|
-
* Clear edited content for a component
|
|
728
|
-
*/
|
|
729
|
-
clearContent(componentName: string): void;
|
|
730
|
-
/**
|
|
731
|
-
* Add a correction (for OCR fixes, etc.)
|
|
732
|
-
*/
|
|
733
|
-
addCorrection(original: string, corrected: string, sourceFile?: string): void;
|
|
734
|
-
/**
|
|
735
|
-
* Get all corrections
|
|
736
|
-
*/
|
|
737
|
-
getCorrections(): Correction[];
|
|
738
|
-
/**
|
|
739
|
-
* Clear corrections
|
|
740
|
-
*/
|
|
741
|
-
clearCorrections(): void;
|
|
742
|
-
/**
|
|
743
|
-
* Set the edit scope
|
|
744
|
-
*/
|
|
745
|
-
setScope(scope: Partial<EditScope>): void;
|
|
746
|
-
/**
|
|
747
|
-
* Get the current scope
|
|
748
|
-
*/
|
|
749
|
-
getScope(): EditScope;
|
|
750
|
-
/**
|
|
751
|
-
* Get diffs for manual changes
|
|
752
|
-
*/
|
|
753
|
-
getDiff(): ComponentDiff[];
|
|
754
|
-
/**
|
|
755
|
-
* Preview what prompts will be sent to AI
|
|
756
|
-
*/
|
|
757
|
-
previewPrompt(): Record<RegeneratableComponent, string>;
|
|
758
|
-
/**
|
|
759
|
-
* Get a summary of pending changes
|
|
760
|
-
*/
|
|
761
|
-
getChangeSummary(): ChangeSummary;
|
|
762
|
-
/**
|
|
763
|
-
* Submit changes (saves first if manual edits, then reprocesses)
|
|
764
|
-
*/
|
|
765
|
-
submit(note: string): Promise<EditResult>;
|
|
766
|
-
/**
|
|
767
|
-
* Wait for reprocessing to complete
|
|
768
|
-
*/
|
|
769
|
-
waitForCompletion(options?: PollOptions): Promise<EditStatus>;
|
|
770
|
-
/**
|
|
771
|
-
* Get current status without waiting
|
|
772
|
-
*/
|
|
773
|
-
getStatus(): Promise<EditStatus>;
|
|
774
|
-
private buildCustomPrompts;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Error classes for edit operations
|
|
779
|
-
*/
|
|
780
|
-
/**
|
|
781
|
-
* Base error class for edit operations
|
|
782
|
-
*/
|
|
783
|
-
declare class EditError extends Error {
|
|
784
|
-
code: string;
|
|
785
|
-
details?: unknown | undefined;
|
|
786
|
-
constructor(message: string, code?: string, details?: unknown | undefined);
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Thrown when an entity is not found
|
|
790
|
-
*/
|
|
791
|
-
declare class EntityNotFoundError extends EditError {
|
|
792
|
-
constructor(id: string);
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Thrown when a CAS (Compare-And-Swap) conflict occurs
|
|
796
|
-
* This means the entity was modified since it was last read
|
|
797
|
-
*/
|
|
798
|
-
declare class CASConflictError extends EditError {
|
|
799
|
-
constructor(id: string, expectedTip: string, actualTip: string);
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Thrown when an entity ID already exists (on create)
|
|
803
|
-
*/
|
|
804
|
-
declare class EntityExistsError extends EditError {
|
|
805
|
-
constructor(id: string);
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* Thrown when a merge operation fails
|
|
809
|
-
*/
|
|
810
|
-
declare class MergeError extends EditError {
|
|
811
|
-
constructor(message: string, sourceId?: string, targetId?: string);
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Thrown when an unmerge operation fails
|
|
815
|
-
*/
|
|
816
|
-
declare class UnmergeError extends EditError {
|
|
817
|
-
constructor(message: string, sourceId?: string, targetId?: string);
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Thrown when a delete operation fails
|
|
821
|
-
*/
|
|
822
|
-
declare class DeleteError extends EditError {
|
|
823
|
-
constructor(message: string, id?: string);
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Thrown when an undelete operation fails
|
|
827
|
-
*/
|
|
828
|
-
declare class UndeleteError extends EditError {
|
|
829
|
-
constructor(message: string, id?: string);
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Thrown when reprocessing fails
|
|
833
|
-
*/
|
|
834
|
-
declare class ReprocessError extends EditError {
|
|
835
|
-
constructor(message: string, batchId?: string);
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Thrown when request validation fails
|
|
839
|
-
*/
|
|
840
|
-
declare class ValidationError extends EditError {
|
|
841
|
-
constructor(message: string, field?: string);
|
|
842
|
-
}
|
|
843
|
-
/**
|
|
844
|
-
* Thrown when the user doesn't have permission
|
|
845
|
-
*/
|
|
846
|
-
declare class PermissionError extends EditError {
|
|
847
|
-
constructor(message: string, id?: string);
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Thrown when a network error occurs
|
|
851
|
-
*/
|
|
852
|
-
declare class NetworkError extends EditError {
|
|
853
|
-
constructor(message: string, statusCode?: number);
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Thrown when content is not found by CID
|
|
857
|
-
*/
|
|
858
|
-
declare class ContentNotFoundError extends EditError {
|
|
859
|
-
constructor(cid: string);
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Thrown when the IPFS backend has an error
|
|
863
|
-
*/
|
|
864
|
-
declare class IPFSError extends EditError {
|
|
865
|
-
constructor(message: string);
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Thrown when the backend API has an error
|
|
869
|
-
*/
|
|
870
|
-
declare class BackendError extends EditError {
|
|
871
|
-
constructor(message: string);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
export { type PollOptions as $, type MergeEntityResponse as A, type UnmergeEntityRequest as B, type ComponentDiff as C, type UnmergeEntityResponse as D, EditClient as E, type DeleteEntityRequest as F, type DeleteEntityResponse as G, type UndeleteEntityRequest as H, type UndeleteEntityResponse as I, type UploadResponse as J, type RetryConfig as K, type ListEntitiesOptions as L, type MergeEntityRequest as M, type Network as N, DEFAULT_RETRY_CONFIG as O, PermissionError as P, type DiffType as Q, type RegeneratableComponent as R, type PromptTarget as S, type TextDiff as T, type UpdateEntityRequest as U, type VersionHistoryItem as V, type CustomPrompts as W, type ReprocessRequest as X, type ReprocessPhase as Y, type ReprocessProgress as Z, type SaveResult as _, type EditClientConfig as a, type ChangeSummary as a0, EntityNotFoundError as a1, EntityExistsError as a2, CASConflictError as a3, MergeError as a4, UnmergeError as a5, DeleteError as a6, UndeleteError as a7, ReprocessError as a8, ValidationError as a9, NetworkError as aa, ContentNotFoundError as ab, IPFSError as ac, BackendError as ad, EditSession as b, EditError as c, type EditMode as d, type EditSessionConfig as e, type EditScope as f, type EditResult as g, type EditStatus as h, type EditPhase as i, type ReprocessResult as j, type ReprocessStatus as k, type Correction as l, type EntityContext as m, type CascadeContext as n, type Entity as o, type EntitySummary as p, type Relationship as q, type CreateEntityRequest as r, type CreateEntityResponse as s, type UpdateEntityResponse as t, type ListEntitiesResponse as u, type ListVersionsOptions as v, type ListVersionsResponse as w, type ResolveResponse as x, type UpdateHierarchyRequest as y, type UpdateHierarchyResponse as z };
|