@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,456 +0,0 @@
1
- /**
2
- * Graph package types for the Arke SDK
3
- *
4
- * Types for interacting with entity relationships from the GraphDB Gateway service.
5
- */
6
- /**
7
- * Entity from the knowledge graph
8
- */
9
- interface GraphEntity {
10
- /** Unique identifier (UUID) */
11
- canonical_id: string;
12
- /** Entity code (e.g., 'person_john', 'event_123') */
13
- code: string;
14
- /** Human-readable label */
15
- label: string;
16
- /** Entity type (e.g., 'person', 'event', 'date', 'organization') */
17
- type: string;
18
- /** Additional entity properties */
19
- properties?: Record<string, unknown>;
20
- /** PI that created this entity */
21
- created_by_pi?: string;
22
- /** All PIs that contributed to this entity */
23
- source_pis?: string[];
24
- }
25
- /**
26
- * Relationship between entities
27
- */
28
- interface Relationship {
29
- /** Direction of the relationship relative to the queried entity */
30
- direction: 'outgoing' | 'incoming';
31
- /** Relationship type/predicate (e.g., 'affiliated_with', 'authored', 'located_at') */
32
- predicate: string;
33
- /** Canonical ID of the related entity */
34
- target_id: string;
35
- /** Code of the related entity */
36
- target_code: string;
37
- /** Label of the related entity */
38
- target_label: string;
39
- /** Type of the related entity */
40
- target_type: string;
41
- /** Additional relationship properties */
42
- properties?: Record<string, unknown>;
43
- /** PI that created this relationship */
44
- source_pi?: string;
45
- /** When the relationship was created */
46
- created_at?: string;
47
- }
48
- /**
49
- * Entity with its relationships
50
- */
51
- interface EntityWithRelationships extends GraphEntity {
52
- /** All relationships for this entity */
53
- relationships: Relationship[];
54
- }
55
- /**
56
- * An edge in a path between entities
57
- */
58
- interface PathEdge {
59
- /** Subject entity ID */
60
- subject_id: string;
61
- /** Subject entity label */
62
- subject_label: string;
63
- /** Subject entity type */
64
- subject_type: string;
65
- /** Relationship predicate */
66
- predicate: string;
67
- /** Object entity ID */
68
- object_id: string;
69
- /** Object entity label */
70
- object_label: string;
71
- /** Object entity type */
72
- object_type: string;
73
- /** PI that contributed this edge */
74
- source_pi?: string;
75
- }
76
- /**
77
- * A path between two entities
78
- */
79
- interface Path {
80
- /** Starting entity ID */
81
- source_id: string;
82
- /** Ending entity ID */
83
- target_id: string;
84
- /** Number of hops in the path */
85
- length: number;
86
- /** Edges in the path */
87
- edges: PathEdge[];
88
- }
89
- /**
90
- * Options for finding paths between entities
91
- */
92
- interface PathOptions {
93
- /** Maximum traversal depth (default: 3) */
94
- max_depth?: number;
95
- /** Direction of traversal */
96
- direction?: 'outgoing' | 'incoming' | 'both';
97
- /** Maximum number of paths to return */
98
- limit?: number;
99
- }
100
- /**
101
- * Options for finding reachable entities
102
- */
103
- interface ReachableOptions {
104
- /** Maximum traversal depth */
105
- max_depth?: number;
106
- /** Direction of traversal */
107
- direction?: 'outgoing' | 'incoming' | 'both';
108
- /** Maximum entities to return */
109
- limit?: number;
110
- }
111
- /**
112
- * Options for listing entities from a PI
113
- */
114
- interface ListFromPiOptions {
115
- /** Filter by entity type */
116
- type?: string;
117
- }
118
- /**
119
- * Response from entity query by code
120
- */
121
- interface EntityQueryResponse {
122
- /** Whether entity was found */
123
- found: boolean;
124
- /** The entity (if found) */
125
- entity?: GraphEntity;
126
- /** Relationships (if found) */
127
- relationships?: {
128
- outgoing: Array<{
129
- predicate: string;
130
- target_id: string;
131
- target_label: string;
132
- target_type: string;
133
- }>;
134
- incoming: Array<{
135
- predicate: string;
136
- source_id: string;
137
- source_label: string;
138
- source_type: string;
139
- }>;
140
- };
141
- }
142
- /**
143
- * Response from entities with relationships query
144
- */
145
- interface EntitiesWithRelationshipsResponse {
146
- /** PI that was queried */
147
- pi: string;
148
- /** Entities with their relationships */
149
- entities: EntityWithRelationships[];
150
- /** Total count of entities */
151
- total_count: number;
152
- }
153
- /**
154
- * Response from path finding
155
- */
156
- interface PathsResponse {
157
- /** Found paths */
158
- paths: Path[];
159
- /** Whether results were truncated */
160
- truncated: boolean;
161
- }
162
- /**
163
- * Lineage PI entry
164
- */
165
- interface LineagePiEntry {
166
- /** PI ID */
167
- id: string;
168
- /** Number of hops from source */
169
- hops: number;
170
- /** When the PI was created */
171
- created_at?: string;
172
- }
173
- /**
174
- * Lineage result set (ancestors or descendants)
175
- */
176
- interface LineageResultSet {
177
- /** List of PIs */
178
- pis: LineagePiEntry[];
179
- /** Total count */
180
- count: number;
181
- /** Whether results were truncated */
182
- truncated: boolean;
183
- }
184
- /**
185
- * Response from lineage query
186
- */
187
- interface LineageResponse {
188
- /** Source PI */
189
- sourcePi: string;
190
- /** Ancestor PIs (if requested) */
191
- ancestors?: LineageResultSet;
192
- /** Descendant PIs (if requested) */
193
- descendants?: LineageResultSet;
194
- }
195
-
196
- /**
197
- * Configuration for GraphClient
198
- */
199
- interface GraphClientConfig {
200
- /**
201
- * Gateway base URL (e.g., https://gateway.arke.institute).
202
- * The client will call /graphdb/* endpoints for GraphDB Gateway.
203
- */
204
- gatewayUrl: string;
205
- /**
206
- * Optional custom fetch implementation (useful for testing).
207
- */
208
- fetchImpl?: typeof fetch;
209
- }
210
- /**
211
- * Client for querying entity relationships from the Arke knowledge graph.
212
- *
213
- * All endpoints are public and do not require authentication.
214
- *
215
- * @example
216
- * ```typescript
217
- * const graph = new GraphClient({
218
- * gatewayUrl: 'https://gateway.arke.institute',
219
- * });
220
- *
221
- * // Get entity by ID
222
- * const entity = await graph.getEntity('uuid-123');
223
- *
224
- * // Find entities by code
225
- * const results = await graph.queryByCode('person_john');
226
- *
227
- * // Get entities with relationships from a PI
228
- * const entities = await graph.getEntitiesWithRelationships('01K75HQQXNTDG7BBP7PS9AWYAN');
229
- *
230
- * // Find paths between entities
231
- * const paths = await graph.findPaths(['uuid-1'], ['uuid-2'], { max_depth: 4 });
232
- * ```
233
- */
234
- declare class GraphClient {
235
- private baseUrl;
236
- private fetchImpl;
237
- constructor(config: GraphClientConfig);
238
- private buildUrl;
239
- private request;
240
- /**
241
- * Get an entity by its canonical ID.
242
- *
243
- * @param canonicalId - Entity UUID
244
- * @returns Entity data
245
- * @throws GraphEntityNotFoundError if the entity doesn't exist
246
- *
247
- * @example
248
- * ```typescript
249
- * const entity = await graph.getEntity('uuid-123');
250
- * console.log('Entity:', entity.label, entity.type);
251
- * ```
252
- */
253
- getEntity(canonicalId: string): Promise<GraphEntity>;
254
- /**
255
- * Check if an entity exists by its canonical ID.
256
- *
257
- * @param canonicalId - Entity UUID
258
- * @returns True if entity exists
259
- *
260
- * @example
261
- * ```typescript
262
- * if (await graph.entityExists('uuid-123')) {
263
- * console.log('Entity exists');
264
- * }
265
- * ```
266
- */
267
- entityExists(canonicalId: string): Promise<boolean>;
268
- /**
269
- * Query entities by code with optional type filter.
270
- *
271
- * @param code - Entity code to search for
272
- * @param type - Optional entity type filter
273
- * @returns Matching entities
274
- *
275
- * @example
276
- * ```typescript
277
- * // Find by code
278
- * const entities = await graph.queryByCode('person_john');
279
- *
280
- * // With type filter
281
- * const people = await graph.queryByCode('john', 'person');
282
- * ```
283
- */
284
- queryByCode(code: string, type?: string): Promise<GraphEntity[]>;
285
- /**
286
- * Look up entities by code across all PIs.
287
- *
288
- * @param code - Entity code to search for
289
- * @param type - Optional entity type filter
290
- * @returns Matching entities
291
- *
292
- * @example
293
- * ```typescript
294
- * const entities = await graph.lookupByCode('alice_austen', 'person');
295
- * ```
296
- */
297
- lookupByCode(code: string, type?: string): Promise<GraphEntity[]>;
298
- /**
299
- * List entities from a specific PI or multiple PIs.
300
- *
301
- * @param pi - Single PI or array of PIs
302
- * @param options - Filter options
303
- * @returns Entities from the PI(s)
304
- *
305
- * @example
306
- * ```typescript
307
- * // From single PI
308
- * const entities = await graph.listEntitiesFromPi('01K75HQQXNTDG7BBP7PS9AWYAN');
309
- *
310
- * // With type filter
311
- * const people = await graph.listEntitiesFromPi('01K75HQQXNTDG7BBP7PS9AWYAN', { type: 'person' });
312
- *
313
- * // From multiple PIs
314
- * const all = await graph.listEntitiesFromPi(['pi-1', 'pi-2']);
315
- * ```
316
- */
317
- listEntitiesFromPi(pi: string | string[], options?: ListFromPiOptions): Promise<GraphEntity[]>;
318
- /**
319
- * Get entities with their relationships from a PI.
320
- *
321
- * This is an optimized query that returns entities along with all their
322
- * relationship data in a single request.
323
- *
324
- * @param pi - Persistent Identifier
325
- * @param type - Optional entity type filter
326
- * @returns Entities with relationships
327
- *
328
- * @example
329
- * ```typescript
330
- * const entities = await graph.getEntitiesWithRelationships('01K75HQQXNTDG7BBP7PS9AWYAN');
331
- * entities.forEach(e => {
332
- * console.log(`${e.label} has ${e.relationships.length} relationships`);
333
- * });
334
- * ```
335
- */
336
- getEntitiesWithRelationships(pi: string, type?: string): Promise<EntityWithRelationships[]>;
337
- /**
338
- * Get the lineage (ancestors and/or descendants) of a PI.
339
- *
340
- * @param pi - Source PI
341
- * @param direction - 'ancestors', 'descendants', or 'both'
342
- * @returns Lineage data
343
- *
344
- * @example
345
- * ```typescript
346
- * // Get ancestors
347
- * const lineage = await graph.getLineage('01K75HQQXNTDG7BBP7PS9AWYAN', 'ancestors');
348
- *
349
- * // Get both directions
350
- * const full = await graph.getLineage('01K75HQQXNTDG7BBP7PS9AWYAN', 'both');
351
- * ```
352
- */
353
- getLineage(pi: string, direction?: 'ancestors' | 'descendants' | 'both', maxHops?: number): Promise<LineageResponse>;
354
- /**
355
- * Get all relationships for an entity.
356
- *
357
- * @param canonicalId - Entity UUID
358
- * @returns Array of relationships
359
- *
360
- * @example
361
- * ```typescript
362
- * const relationships = await graph.getRelationships('uuid-123');
363
- * relationships.forEach(r => {
364
- * console.log(`${r.direction}: ${r.predicate} -> ${r.target_label}`);
365
- * });
366
- * ```
367
- */
368
- getRelationships(canonicalId: string): Promise<Relationship[]>;
369
- /**
370
- * Find shortest paths between sets of entities.
371
- *
372
- * @param sourceIds - Starting entity IDs
373
- * @param targetIds - Target entity IDs
374
- * @param options - Path finding options
375
- * @returns Found paths
376
- *
377
- * @example
378
- * ```typescript
379
- * const paths = await graph.findPaths(
380
- * ['uuid-alice'],
381
- * ['uuid-bob'],
382
- * { max_depth: 4, direction: 'both' }
383
- * );
384
- *
385
- * paths.forEach(path => {
386
- * console.log(`Path of length ${path.length}:`);
387
- * path.edges.forEach(e => {
388
- * console.log(` ${e.subject_label} -[${e.predicate}]-> ${e.object_label}`);
389
- * });
390
- * });
391
- * ```
392
- */
393
- findPaths(sourceIds: string[], targetIds: string[], options?: PathOptions): Promise<Path[]>;
394
- /**
395
- * Find entities of a specific type reachable from starting entities.
396
- *
397
- * @param startIds - Starting entity IDs
398
- * @param targetType - Type of entities to find
399
- * @param options - Search options
400
- * @returns Reachable entities of the specified type
401
- *
402
- * @example
403
- * ```typescript
404
- * // Find all people reachable from an event
405
- * const people = await graph.findReachable(
406
- * ['uuid-event'],
407
- * 'person',
408
- * { max_depth: 3 }
409
- * );
410
- * ```
411
- */
412
- findReachable(startIds: string[], targetType: string, options?: ReachableOptions): Promise<GraphEntity[]>;
413
- /**
414
- * Check the health of the graph service.
415
- *
416
- * @returns Health status
417
- */
418
- health(): Promise<{
419
- status: string;
420
- service: string;
421
- version: string;
422
- }>;
423
- }
424
-
425
- /**
426
- * Graph package error classes for the Arke SDK
427
- */
428
- /**
429
- * Base error class for graph operations
430
- */
431
- declare class GraphError extends Error {
432
- code: string;
433
- details?: unknown | undefined;
434
- constructor(message: string, code?: string, details?: unknown | undefined);
435
- }
436
- /**
437
- * Thrown when an entity is not found by canonical ID
438
- */
439
- declare class GraphEntityNotFoundError extends GraphError {
440
- constructor(canonicalId: string);
441
- }
442
- /**
443
- * Thrown when no paths are found between entities
444
- */
445
- declare class NoPathFoundError extends GraphError {
446
- constructor(sourceIds: string[], targetIds: string[]);
447
- }
448
- /**
449
- * Thrown when a network error occurs
450
- */
451
- declare class NetworkError extends GraphError {
452
- statusCode?: number | undefined;
453
- constructor(message: string, statusCode?: number | undefined);
454
- }
455
-
456
- export { type EntitiesWithRelationshipsResponse, type EntityQueryResponse, type EntityWithRelationships, GraphClient, type GraphClientConfig, type GraphEntity, GraphEntityNotFoundError, GraphError, type LineagePiEntry, type LineageResponse, type LineageResultSet, type ListFromPiOptions, NetworkError, NoPathFoundError, type Path, type PathEdge, type PathOptions, type PathsResponse, type ReachableOptions, type Relationship };