@arke-institute/sdk 0.1.0 → 0.1.1
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/dist/{index.d.mts → client-dAk3E64p.d.cts} +1 -7
- package/dist/client-dAk3E64p.d.ts +183 -0
- package/dist/{index.mjs → collections/index.cjs} +34 -5
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.d.cts +9 -0
- package/dist/collections/index.d.ts +9 -1
- package/dist/collections/index.js +5 -32
- package/dist/collections/index.js.map +1 -1
- package/dist/errors-BrNZWPE7.d.cts +477 -0
- package/dist/errors-CCyp5KCg.d.ts +477 -0
- package/dist/index.cjs +1649 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -189
- package/dist/index.js +1407 -29
- package/dist/index.js.map +1 -1
- package/dist/upload/index.cjs +1645 -0
- package/dist/upload/index.cjs.map +1 -0
- package/dist/upload/index.d.cts +150 -0
- package/dist/upload/index.d.ts +150 -0
- package/dist/upload/index.js +1608 -0
- package/dist/upload/index.js.map +1 -0
- package/package.json +18 -8
- package/dist/collections/index.d.mts +0 -1
- package/dist/collections/index.mjs +0 -204
- package/dist/collections/index.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { f as CreateCollectionPayload, b as Collection, o as PiPermissions, C as CollectionsClient } from './client-dAk3E64p.cjs';
|
|
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
|
+
addToCollection(options: AddToCollectionOptions): Promise<BatchResult>;
|
|
333
|
+
/**
|
|
334
|
+
* Check if you can edit a specific PI (i.e., add files to its collection)
|
|
335
|
+
*/
|
|
336
|
+
canEdit(pi: string): Promise<PiPermissions>;
|
|
337
|
+
/**
|
|
338
|
+
* Get access to the underlying collections client for other operations
|
|
339
|
+
*/
|
|
340
|
+
get collections(): CollectionsClient;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* File metadata and upload tracking types
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
interface FileInfo {
|
|
348
|
+
/** Absolute path on local filesystem */
|
|
349
|
+
localPath: string;
|
|
350
|
+
/** Logical path within the batch (e.g., /series_1/box_7/page_001.tiff) */
|
|
351
|
+
logicalPath: string;
|
|
352
|
+
/** File name only */
|
|
353
|
+
fileName: string;
|
|
354
|
+
/** File size in bytes */
|
|
355
|
+
size: number;
|
|
356
|
+
/** MIME type */
|
|
357
|
+
contentType: string;
|
|
358
|
+
/** IPFS CID v1 (base32) - optional, may be undefined if computation failed */
|
|
359
|
+
cid?: string;
|
|
360
|
+
/** Processing configuration for this file */
|
|
361
|
+
processingConfig: ProcessingConfig;
|
|
362
|
+
}
|
|
363
|
+
interface UploadTask extends FileInfo {
|
|
364
|
+
/** Current status of the upload */
|
|
365
|
+
status: 'pending' | 'uploading' | 'completed' | 'failed';
|
|
366
|
+
/** R2 key assigned by worker */
|
|
367
|
+
r2Key?: string;
|
|
368
|
+
/** Upload type determined by worker */
|
|
369
|
+
uploadType?: 'simple' | 'multipart';
|
|
370
|
+
/** Multipart upload ID (if applicable) */
|
|
371
|
+
uploadId?: string;
|
|
372
|
+
/** Completed parts for multipart uploads */
|
|
373
|
+
completedParts?: Array<{
|
|
374
|
+
part_number: number;
|
|
375
|
+
etag: string;
|
|
376
|
+
}>;
|
|
377
|
+
/** Error message if failed */
|
|
378
|
+
error?: string;
|
|
379
|
+
/** Bytes uploaded so far */
|
|
380
|
+
bytesUploaded?: number;
|
|
381
|
+
/** Timestamp when upload started */
|
|
382
|
+
startedAt?: Date;
|
|
383
|
+
/** Timestamp when upload completed */
|
|
384
|
+
completedAt?: Date;
|
|
385
|
+
}
|
|
386
|
+
interface ScanResult {
|
|
387
|
+
files: FileInfo[];
|
|
388
|
+
totalSize: number;
|
|
389
|
+
totalFiles: number;
|
|
390
|
+
largestFile: number;
|
|
391
|
+
smallestFile: number;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Common platform types and utilities
|
|
396
|
+
*/
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Platform-specific file source
|
|
400
|
+
* Can be a path string (Node.js) or File object (Browser)
|
|
401
|
+
*/
|
|
402
|
+
type FileSource = string | File;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Main ArkeUploader SDK class
|
|
406
|
+
*/
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Upload client for Arke Institute's ingest service
|
|
410
|
+
* Works in Node.js, browsers, and other JavaScript runtimes
|
|
411
|
+
*/
|
|
412
|
+
declare class ArkeUploader {
|
|
413
|
+
private config;
|
|
414
|
+
private workerClient;
|
|
415
|
+
private scanner;
|
|
416
|
+
private platform;
|
|
417
|
+
constructor(config: UploaderConfig);
|
|
418
|
+
/**
|
|
419
|
+
* Get platform-specific scanner
|
|
420
|
+
*/
|
|
421
|
+
private getScanner;
|
|
422
|
+
/**
|
|
423
|
+
* Upload a batch of files
|
|
424
|
+
* @param source - Directory path (Node.js) or File[]/FileList (browser)
|
|
425
|
+
* @param options - Upload options
|
|
426
|
+
*/
|
|
427
|
+
uploadBatch(source: FileSource | FileSource[], options?: UploadOptions): Promise<BatchResult>;
|
|
428
|
+
/**
|
|
429
|
+
* Poll for root_pi during async discovery
|
|
430
|
+
*/
|
|
431
|
+
private pollForRootPi;
|
|
432
|
+
/**
|
|
433
|
+
* Upload files with controlled concurrency
|
|
434
|
+
*/
|
|
435
|
+
private uploadFilesWithConcurrency;
|
|
436
|
+
/**
|
|
437
|
+
* Upload a single file
|
|
438
|
+
*/
|
|
439
|
+
private uploadSingleFile;
|
|
440
|
+
/**
|
|
441
|
+
* Get file data based on platform
|
|
442
|
+
*/
|
|
443
|
+
private getFileData;
|
|
444
|
+
/**
|
|
445
|
+
* Report progress to callback
|
|
446
|
+
*/
|
|
447
|
+
private reportProgress;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Custom error classes for better error handling
|
|
452
|
+
*/
|
|
453
|
+
declare class WorkerAPIError extends Error {
|
|
454
|
+
statusCode?: number | undefined;
|
|
455
|
+
details?: any | undefined;
|
|
456
|
+
constructor(message: string, statusCode?: number | undefined, details?: any | undefined);
|
|
457
|
+
}
|
|
458
|
+
declare class UploadError extends Error {
|
|
459
|
+
fileName?: string | undefined;
|
|
460
|
+
statusCode?: number | undefined;
|
|
461
|
+
cause?: Error | undefined;
|
|
462
|
+
constructor(message: string, fileName?: string | undefined, statusCode?: number | undefined, cause?: Error | undefined);
|
|
463
|
+
}
|
|
464
|
+
declare class ValidationError extends Error {
|
|
465
|
+
field?: string | undefined;
|
|
466
|
+
constructor(message: string, field?: string | undefined);
|
|
467
|
+
}
|
|
468
|
+
declare class NetworkError extends Error {
|
|
469
|
+
cause?: Error | undefined;
|
|
470
|
+
constructor(message: string, cause?: Error | undefined);
|
|
471
|
+
}
|
|
472
|
+
declare class ScanError extends Error {
|
|
473
|
+
path?: string | undefined;
|
|
474
|
+
constructor(message: string, path?: string | undefined);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
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 };
|