@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.
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 -4254
  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 -4226
  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 -591
  32. package/dist/content/index.cjs.map +0 -1
  33. package/dist/content/index.d.cts +0 -516
  34. package/dist/content/index.d.ts +0 -516
  35. package/dist/content/index.js +0 -558
  36. package/dist/content/index.js.map +0 -1
  37. package/dist/edit/index.cjs +0 -1503
  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 -1447
  42. package/dist/edit/index.js.map +0 -1
  43. package/dist/errors-3L7IiHcr.d.cts +0 -480
  44. package/dist/errors-BTe8GKRQ.d.ts +0 -480
  45. package/dist/errors-CT7yzKkU.d.cts +0 -874
  46. package/dist/errors-CT7yzKkU.d.ts +0 -874
  47. package/dist/graph/index.cjs +0 -427
  48. package/dist/graph/index.cjs.map +0 -1
  49. package/dist/graph/index.d.cts +0 -485
  50. package/dist/graph/index.d.ts +0 -485
  51. package/dist/graph/index.js +0 -396
  52. package/dist/graph/index.js.map +0 -1
  53. package/dist/query/index.cjs +0 -356
  54. package/dist/query/index.cjs.map +0 -1
  55. package/dist/query/index.d.cts +0 -636
  56. package/dist/query/index.d.ts +0 -636
  57. package/dist/query/index.js +0 -328
  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,480 +0,0 @@
1
- import { f as CreateCollectionPayload, b as Collection, o as PiPermissions, C as CollectionsClient } from './client-dAk3E64p.js';
2
-
3
- /**
4
- * Processing configuration types for per-directory control
5
- */
6
- /**
7
- * Configuration for processing stages applied to files
8
- */
9
- interface ProcessingConfig {
10
- /** Enable OCR on eligible files */
11
- ocr: boolean;
12
- /** Enable description/summary generation */
13
- describe: boolean;
14
- /** Enable pinax metadata generation */
15
- pinax: boolean;
16
- }
17
-
18
- /**
19
- * SDK Configuration Types
20
- */
21
-
22
- /**
23
- * Custom prompts for AI services in the ingest pipeline
24
- * All fields are optional. Prompts are appended to base system prompts.
25
- */
26
- interface CustomPrompts {
27
- /**
28
- * Applied to all AI service calls across all phases
29
- * @example "All content is from 18th century manuscripts. Use period-appropriate terminology."
30
- */
31
- general?: string;
32
- /**
33
- * Phase-specific: file reorganization
34
- * @example "Group documents by subject matter (astronomy, biology, chemistry, physics)."
35
- */
36
- reorganization?: string;
37
- /**
38
- * Phase-specific: PINAX metadata extraction
39
- * @example "Focus on extracting dates, locations, and institutional affiliations. Use Library of Congress Subject Headings."
40
- */
41
- pinax?: string;
42
- /**
43
- * Phase-specific: description generation
44
- * @example "Write descriptions in scholarly, academic tone with focus on historical context."
45
- */
46
- description?: string;
47
- /**
48
- * Phase-specific: knowledge graph extraction
49
- * @example "Focus on extracting people, institutions, and their relationships."
50
- */
51
- cheimarros?: string;
52
- }
53
- /**
54
- * Configuration for the ArkeUploader SDK
55
- */
56
- interface UploaderConfig {
57
- /**
58
- * Gateway base URL (e.g., https://api.arke.institute)
59
- * All requests route through /ingest/* endpoints
60
- * @example 'https://api.arke.institute'
61
- */
62
- gatewayUrl: string;
63
- /**
64
- * Bearer token for authentication (required for all upload operations)
65
- */
66
- authToken: string;
67
- /**
68
- * Name of person/service uploading files
69
- */
70
- uploader: string;
71
- /**
72
- * Root path in the archive hierarchy
73
- * @default '/'
74
- */
75
- rootPath?: string;
76
- /**
77
- * Parent persistent identifier (for hierarchical archives)
78
- */
79
- parentPi?: string;
80
- /**
81
- * Custom metadata to attach to batch
82
- */
83
- metadata?: Record<string, unknown>;
84
- /**
85
- * Custom prompts for AI services in the ingest pipeline
86
- */
87
- customPrompts?: CustomPrompts;
88
- /**
89
- * Processing options (OCR, IIIF, etc.)
90
- */
91
- processing?: ProcessingConfig;
92
- /**
93
- * Number of files to upload in parallel
94
- * @default 5
95
- */
96
- parallelUploads?: number;
97
- /**
98
- * Number of parts to upload in parallel for multipart uploads
99
- * @default 3
100
- */
101
- parallelParts?: number;
102
- /**
103
- * Maximum number of retry attempts for failed requests
104
- * @default 3
105
- */
106
- maxRetries?: number;
107
- /**
108
- * Initial delay between retries in milliseconds
109
- * @default 1000
110
- */
111
- retryInitialDelay?: number;
112
- /**
113
- * Maximum delay between retries in milliseconds
114
- * @default 30000
115
- */
116
- retryMaxDelay?: number;
117
- /**
118
- * Add random jitter to retry delays to prevent thundering herd
119
- * @default true
120
- */
121
- retryJitter?: boolean;
122
- /**
123
- * Timeout for API requests in milliseconds
124
- * @default 30000
125
- */
126
- timeout?: number;
127
- }
128
- /**
129
- * Options for batch upload operation
130
- */
131
- interface UploadOptions {
132
- /**
133
- * Progress callback for upload tracking
134
- */
135
- onProgress?: (progress: UploadProgress) => void;
136
- /**
137
- * Dry run mode - validate without uploading
138
- * @default false
139
- */
140
- dryRun?: boolean;
141
- }
142
- /**
143
- * Progress information during upload
144
- */
145
- interface UploadProgress {
146
- /**
147
- * Current phase of upload
148
- */
149
- phase: 'scanning' | 'uploading' | 'finalizing' | 'discovery' | 'complete';
150
- /**
151
- * Total number of files to upload
152
- */
153
- filesTotal: number;
154
- /**
155
- * Number of files uploaded so far
156
- */
157
- filesUploaded: number;
158
- /**
159
- * Total bytes to upload
160
- */
161
- bytesTotal: number;
162
- /**
163
- * Bytes uploaded so far
164
- */
165
- bytesUploaded: number;
166
- /**
167
- * Current file being processed
168
- */
169
- currentFile?: string;
170
- /**
171
- * Percentage complete (0-100)
172
- */
173
- percentComplete: number;
174
- }
175
- /**
176
- * Result of batch upload
177
- */
178
- interface BatchResult {
179
- /**
180
- * Batch ID assigned by worker
181
- */
182
- batchId: string;
183
- /**
184
- * Root PI of the uploaded content (entity identifier)
185
- * This is the canonical identifier for the uploaded collection.
186
- */
187
- rootPi: string;
188
- /**
189
- * Number of files uploaded
190
- */
191
- filesUploaded: number;
192
- /**
193
- * Total bytes uploaded
194
- */
195
- bytesUploaded: number;
196
- /**
197
- * Upload duration in milliseconds
198
- */
199
- durationMs: number;
200
- }
201
-
202
- /**
203
- * Upload Client with Collections Integration
204
- * Provides high-level upload operations with permission checks
205
- */
206
-
207
- interface UploadClientConfig {
208
- /**
209
- * Gateway base URL (e.g., https://api.arke.institute)
210
- */
211
- gatewayUrl: string;
212
- /**
213
- * Bearer token for authentication
214
- */
215
- authToken: string;
216
- /**
217
- * Name of person/service uploading files (defaults to user ID from JWT)
218
- */
219
- uploader?: string;
220
- /**
221
- * Custom fetch implementation (optional, for testing)
222
- */
223
- fetchImpl?: typeof fetch;
224
- }
225
- interface CreateCollectionUploadOptions {
226
- /**
227
- * Files to upload - directory path (Node.js) or File[]/FileList (browser)
228
- */
229
- files: string | File[] | FileList;
230
- /**
231
- * Collection metadata
232
- */
233
- collectionMetadata: CreateCollectionPayload;
234
- /**
235
- * Custom prompts for AI processing
236
- */
237
- customPrompts?: CustomPrompts;
238
- /**
239
- * Processing options (OCR, IIIF, etc.)
240
- */
241
- processing?: ProcessingConfig;
242
- /**
243
- * Progress callback
244
- */
245
- onProgress?: (progress: UploadProgress) => void;
246
- /**
247
- * Dry run mode
248
- */
249
- dryRun?: boolean;
250
- }
251
- interface AddToCollectionOptions {
252
- /**
253
- * Files to upload - directory path (Node.js) or File[]/FileList (browser)
254
- */
255
- files: string | File[] | FileList;
256
- /**
257
- * Parent PI to add files under (must be within a collection you can edit)
258
- */
259
- parentPi: string;
260
- /**
261
- * Custom prompts for AI processing
262
- */
263
- customPrompts?: CustomPrompts;
264
- /**
265
- * Processing options (OCR, IIIF, etc.)
266
- */
267
- processing?: ProcessingConfig;
268
- /**
269
- * Progress callback
270
- */
271
- onProgress?: (progress: UploadProgress) => void;
272
- /**
273
- * Dry run mode
274
- */
275
- dryRun?: boolean;
276
- }
277
- interface CreateCollectionUploadResult extends BatchResult {
278
- /**
279
- * The created collection
280
- */
281
- collection: Collection & {
282
- rootPi: string;
283
- };
284
- }
285
- /**
286
- * High-level upload client with collections integration
287
- *
288
- * @example
289
- * ```typescript
290
- * import { UploadClient } from '@arke-institute/sdk';
291
- *
292
- * const client = new UploadClient({
293
- * gatewayUrl: 'https://api.arke.institute',
294
- * authToken: 'your-jwt-token',
295
- * uploader: 'my-app',
296
- * });
297
- *
298
- * // Create a new collection from files
299
- * const result = await client.createCollection({
300
- * files: './photos',
301
- * collectionMetadata: { title: 'My Archive', slug: 'my-archive' },
302
- * });
303
- *
304
- * // Add files to an existing collection
305
- * await client.addToCollection({
306
- * files: './more-photos',
307
- * parentPi: result.collection.rootPi,
308
- * });
309
- * ```
310
- */
311
- declare class UploadClient {
312
- private config;
313
- private collectionsClient;
314
- constructor(config: UploadClientConfig);
315
- /**
316
- * Update the auth token (e.g., after token refresh)
317
- */
318
- setAuthToken(token: string): void;
319
- /**
320
- * Create a new collection and upload files to it
321
- *
322
- * Anyone authenticated can create a new collection.
323
- * The root PI of the uploaded files becomes the collection's root.
324
- */
325
- createCollection(options: CreateCollectionUploadOptions): Promise<CreateCollectionUploadResult>;
326
- /**
327
- * Add files to an existing collection
328
- *
329
- * Requires owner or editor role on the collection containing the parent PI.
330
- * Use this to add a folder or files to an existing collection hierarchy.
331
- *
332
- * Note: Permission checks are enforced server-side by the ingest worker.
333
- * The server will return 403 if the user lacks edit access to the parent PI.
334
- */
335
- addToCollection(options: AddToCollectionOptions): Promise<BatchResult>;
336
- /**
337
- * Check if you can edit a specific PI (i.e., add files to its collection)
338
- */
339
- canEdit(pi: string): Promise<PiPermissions>;
340
- /**
341
- * Get access to the underlying collections client for other operations
342
- */
343
- get collections(): CollectionsClient;
344
- }
345
-
346
- /**
347
- * File metadata and upload tracking types
348
- */
349
-
350
- interface FileInfo {
351
- /** Absolute path on local filesystem */
352
- localPath: string;
353
- /** Logical path within the batch (e.g., /series_1/box_7/page_001.tiff) */
354
- logicalPath: string;
355
- /** File name only */
356
- fileName: string;
357
- /** File size in bytes */
358
- size: number;
359
- /** MIME type */
360
- contentType: string;
361
- /** IPFS CID v1 (base32) - optional, may be undefined if computation failed */
362
- cid?: string;
363
- /** Processing configuration for this file */
364
- processingConfig: ProcessingConfig;
365
- }
366
- interface UploadTask extends FileInfo {
367
- /** Current status of the upload */
368
- status: 'pending' | 'uploading' | 'completed' | 'failed';
369
- /** R2 key assigned by worker */
370
- r2Key?: string;
371
- /** Upload type determined by worker */
372
- uploadType?: 'simple' | 'multipart';
373
- /** Multipart upload ID (if applicable) */
374
- uploadId?: string;
375
- /** Completed parts for multipart uploads */
376
- completedParts?: Array<{
377
- part_number: number;
378
- etag: string;
379
- }>;
380
- /** Error message if failed */
381
- error?: string;
382
- /** Bytes uploaded so far */
383
- bytesUploaded?: number;
384
- /** Timestamp when upload started */
385
- startedAt?: Date;
386
- /** Timestamp when upload completed */
387
- completedAt?: Date;
388
- }
389
- interface ScanResult {
390
- files: FileInfo[];
391
- totalSize: number;
392
- totalFiles: number;
393
- largestFile: number;
394
- smallestFile: number;
395
- }
396
-
397
- /**
398
- * Common platform types and utilities
399
- */
400
-
401
- /**
402
- * Platform-specific file source
403
- * Can be a path string (Node.js) or File object (Browser)
404
- */
405
- type FileSource = string | File;
406
-
407
- /**
408
- * Main ArkeUploader SDK class
409
- */
410
-
411
- /**
412
- * Upload client for Arke Institute's ingest service
413
- * Works in Node.js, browsers, and other JavaScript runtimes
414
- */
415
- declare class ArkeUploader {
416
- private config;
417
- private workerClient;
418
- private scanner;
419
- private platform;
420
- constructor(config: UploaderConfig);
421
- /**
422
- * Get platform-specific scanner
423
- */
424
- private getScanner;
425
- /**
426
- * Upload a batch of files
427
- * @param source - Directory path (Node.js) or File[]/FileList (browser)
428
- * @param options - Upload options
429
- */
430
- uploadBatch(source: FileSource | FileSource[], options?: UploadOptions): Promise<BatchResult>;
431
- /**
432
- * Poll for root_pi during async discovery
433
- */
434
- private pollForRootPi;
435
- /**
436
- * Upload files with controlled concurrency
437
- */
438
- private uploadFilesWithConcurrency;
439
- /**
440
- * Upload a single file
441
- */
442
- private uploadSingleFile;
443
- /**
444
- * Get file data based on platform
445
- */
446
- private getFileData;
447
- /**
448
- * Report progress to callback
449
- */
450
- private reportProgress;
451
- }
452
-
453
- /**
454
- * Custom error classes for better error handling
455
- */
456
- declare class WorkerAPIError extends Error {
457
- statusCode?: number | undefined;
458
- details?: any | undefined;
459
- constructor(message: string, statusCode?: number | undefined, details?: any | undefined);
460
- }
461
- declare class UploadError extends Error {
462
- fileName?: string | undefined;
463
- statusCode?: number | undefined;
464
- cause?: Error | undefined;
465
- constructor(message: string, fileName?: string | undefined, statusCode?: number | undefined, cause?: Error | undefined);
466
- }
467
- declare class ValidationError extends Error {
468
- field?: string | undefined;
469
- constructor(message: string, field?: string | undefined);
470
- }
471
- declare class NetworkError extends Error {
472
- cause?: Error | undefined;
473
- constructor(message: string, cause?: Error | undefined);
474
- }
475
- declare class ScanError extends Error {
476
- path?: string | undefined;
477
- constructor(message: string, path?: string | undefined);
478
- }
479
-
480
- export { type AddToCollectionOptions as A, type BatchResult as B, type CreateCollectionUploadOptions as C, type FileInfo as F, NetworkError as N, type ProcessingConfig as P, ScanError as S, UploadClient as U, ValidationError as V, WorkerAPIError as W, type UploadClientConfig as a, type CreateCollectionUploadResult as b, ArkeUploader as c, type UploaderConfig as d, type UploadOptions as e, type UploadProgress as f, type CustomPrompts as g, UploadError as h, type UploadTask as i, type ScanResult as j };