@opensecret/react 1.3.7 → 1.3.8
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.ts +158 -11
- package/dist/opensecret-react.es.js +1218 -1181
- package/dist/opensecret-react.umd.js +21 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ declare namespace api {
|
|
|
48
48
|
confirmAccountDeletion,
|
|
49
49
|
fetchModels,
|
|
50
50
|
uploadDocument,
|
|
51
|
+
checkDocumentStatus,
|
|
52
|
+
uploadDocumentWithPolling,
|
|
51
53
|
LoginResponse,
|
|
52
54
|
UserResponse,
|
|
53
55
|
KVListItem,
|
|
@@ -67,7 +69,10 @@ declare namespace api {
|
|
|
67
69
|
EncryptDataResponse,
|
|
68
70
|
DecryptDataRequest,
|
|
69
71
|
DocumentUploadRequest,
|
|
70
|
-
DocumentResponse
|
|
72
|
+
DocumentResponse,
|
|
73
|
+
DocumentUploadInitResponse,
|
|
74
|
+
DocumentStatusRequest,
|
|
75
|
+
DocumentStatusResponse
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -209,6 +214,33 @@ declare function changePlatformPassword(currentPassword: string, newPassword: st
|
|
|
209
214
|
message: string;
|
|
210
215
|
}>;
|
|
211
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Checks the status of a document processing task
|
|
219
|
+
* @param taskId - The task ID returned from uploadDocument
|
|
220
|
+
* @returns A promise resolving to the current status and optionally the processed document
|
|
221
|
+
* @throws {Error} If:
|
|
222
|
+
* - The user is not authenticated
|
|
223
|
+
* - The task ID is not found (404)
|
|
224
|
+
* - The user doesn't have access to the task (403)
|
|
225
|
+
*
|
|
226
|
+
* @description
|
|
227
|
+
* This function checks the status of an async document processing task.
|
|
228
|
+
* Status values include:
|
|
229
|
+
* - "pending": Document is queued for processing
|
|
230
|
+
* - "started": Document processing has begun
|
|
231
|
+
* - "success": Processing completed successfully (document field will be populated)
|
|
232
|
+
* - "failure": Processing failed (error field will contain details)
|
|
233
|
+
*
|
|
234
|
+
* Example usage:
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const status = await checkDocumentStatus(taskId);
|
|
237
|
+
* if (status.status === "success" && status.document) {
|
|
238
|
+
* console.log(status.document.text);
|
|
239
|
+
* }
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
declare function checkDocumentStatus(taskId: string): Promise<DocumentStatusResponse>;
|
|
243
|
+
|
|
212
244
|
/**
|
|
213
245
|
* Confirms and completes the account deletion process
|
|
214
246
|
* @param confirmationCode - The confirmation code from the verification email
|
|
@@ -320,6 +352,23 @@ export declare type DocumentResponse = {
|
|
|
320
352
|
size: number;
|
|
321
353
|
};
|
|
322
354
|
|
|
355
|
+
export declare type DocumentStatusRequest = {
|
|
356
|
+
task_id: string;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export declare type DocumentStatusResponse = {
|
|
360
|
+
status: string;
|
|
361
|
+
progress?: number;
|
|
362
|
+
error?: string;
|
|
363
|
+
document?: DocumentResponse;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export declare type DocumentUploadInitResponse = {
|
|
367
|
+
task_id: string;
|
|
368
|
+
filename: string;
|
|
369
|
+
size: number;
|
|
370
|
+
};
|
|
371
|
+
|
|
323
372
|
declare type DocumentUploadRequest = {
|
|
324
373
|
filename: string;
|
|
325
374
|
content_base64: string;
|
|
@@ -1118,7 +1167,7 @@ export declare type OpenSecretContextType = {
|
|
|
1118
1167
|
/**
|
|
1119
1168
|
* Uploads a document for text extraction and processing
|
|
1120
1169
|
* @param file - The file to upload (File or Blob object)
|
|
1121
|
-
* @returns A promise resolving to the
|
|
1170
|
+
* @returns A promise resolving to the task ID and initial metadata
|
|
1122
1171
|
* @throws {Error} If:
|
|
1123
1172
|
* - The file exceeds 10MB size limit
|
|
1124
1173
|
* - The user is not authenticated (or is a guest user)
|
|
@@ -1127,8 +1176,8 @@ export declare type OpenSecretContextType = {
|
|
|
1127
1176
|
*
|
|
1128
1177
|
* @description
|
|
1129
1178
|
* This function uploads a document to the Tinfoil processing service which:
|
|
1130
|
-
* 1.
|
|
1131
|
-
* 2.
|
|
1179
|
+
* 1. Accepts the document and returns a task ID immediately
|
|
1180
|
+
* 2. Processes the document asynchronously in the background
|
|
1132
1181
|
* 3. Maintains end-to-end encryption using session keys
|
|
1133
1182
|
*
|
|
1134
1183
|
* Common supported formats include PDF, DOCX, XLSX, PPTX, TXT, RTF, and more.
|
|
@@ -1138,10 +1187,71 @@ export declare type OpenSecretContextType = {
|
|
|
1138
1187
|
* ```typescript
|
|
1139
1188
|
* const file = new File(["content"], "document.pdf", { type: "application/pdf" });
|
|
1140
1189
|
* const result = await context.uploadDocument(file);
|
|
1141
|
-
* console.log(result.
|
|
1190
|
+
* console.log(result.task_id); // Task ID to check status
|
|
1191
|
+
* ```
|
|
1192
|
+
*/
|
|
1193
|
+
uploadDocument: (file: File | Blob) => Promise<api.DocumentUploadInitResponse>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Checks the status of a document processing task
|
|
1196
|
+
* @param taskId - The task ID returned from uploadDocument
|
|
1197
|
+
* @returns A promise resolving to the current status and optionally the processed document
|
|
1198
|
+
* @throws {Error} If:
|
|
1199
|
+
* - The user is not authenticated
|
|
1200
|
+
* - The task ID is not found (404)
|
|
1201
|
+
* - The user doesn't have access to the task (403)
|
|
1202
|
+
*
|
|
1203
|
+
* @description
|
|
1204
|
+
* This function checks the status of an async document processing task.
|
|
1205
|
+
* Status values include:
|
|
1206
|
+
* - "pending": Document is queued for processing
|
|
1207
|
+
* - "started": Document processing has begun
|
|
1208
|
+
* - "success": Processing completed successfully (document field will be populated)
|
|
1209
|
+
* - "failure": Processing failed (error field will contain details)
|
|
1210
|
+
*
|
|
1211
|
+
* Example usage:
|
|
1212
|
+
* ```typescript
|
|
1213
|
+
* const status = await context.checkDocumentStatus(taskId);
|
|
1214
|
+
* if (status.status === "success" && status.document) {
|
|
1215
|
+
* console.log(status.document.text);
|
|
1216
|
+
* }
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
checkDocumentStatus: (taskId: string) => Promise<api.DocumentStatusResponse>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Uploads a document and polls for completion
|
|
1222
|
+
* @param file - The file to upload (File or Blob object)
|
|
1223
|
+
* @param options - Optional configuration for polling behavior
|
|
1224
|
+
* @returns A promise resolving to the processed document
|
|
1225
|
+
* @throws {Error} If:
|
|
1226
|
+
* - Upload fails (see uploadDocument errors)
|
|
1227
|
+
* - Processing fails (error from server)
|
|
1228
|
+
* - Processing times out (exceeds maxAttempts)
|
|
1229
|
+
*
|
|
1230
|
+
* @description
|
|
1231
|
+
* This is a convenience function that combines uploadDocument and checkDocumentStatus
|
|
1232
|
+
* to provide a simple interface that handles the async processing automatically.
|
|
1233
|
+
*
|
|
1234
|
+
* Options:
|
|
1235
|
+
* - pollInterval: Time between status checks in milliseconds (default: 2000)
|
|
1236
|
+
* - maxAttempts: Maximum number of status checks before timeout (default: 150 = 5 minutes)
|
|
1237
|
+
* - onProgress: Callback function called on each status update
|
|
1238
|
+
*
|
|
1239
|
+
* Example usage:
|
|
1240
|
+
* ```typescript
|
|
1241
|
+
* const file = new File(["content"], "document.pdf", { type: "application/pdf" });
|
|
1242
|
+
* const result = await context.uploadDocumentWithPolling(file, {
|
|
1243
|
+
* onProgress: (status, progress) => {
|
|
1244
|
+
* console.log(`Status: ${status}, Progress: ${progress || 0}%`);
|
|
1245
|
+
* }
|
|
1246
|
+
* });
|
|
1247
|
+
* console.log(result.text);
|
|
1142
1248
|
* ```
|
|
1143
1249
|
*/
|
|
1144
|
-
|
|
1250
|
+
uploadDocumentWithPolling: (file: File | Blob, options?: {
|
|
1251
|
+
pollInterval?: number;
|
|
1252
|
+
maxAttempts?: number;
|
|
1253
|
+
onProgress?: (status: string, progress?: number) => void;
|
|
1254
|
+
}) => Promise<DocumentResponse>;
|
|
1145
1255
|
};
|
|
1146
1256
|
|
|
1147
1257
|
/**
|
|
@@ -1901,7 +2011,7 @@ declare function updateProject(orgId: string, projectId: string, updates: {
|
|
|
1901
2011
|
/**
|
|
1902
2012
|
* Uploads a document for text extraction and processing
|
|
1903
2013
|
* @param file - The file to upload (File or Blob object)
|
|
1904
|
-
* @returns A promise resolving to the
|
|
2014
|
+
* @returns A promise resolving to the task ID and initial metadata
|
|
1905
2015
|
* @throws {Error} If:
|
|
1906
2016
|
* - The file exceeds 10MB size limit
|
|
1907
2017
|
* - The user is not authenticated
|
|
@@ -1911,8 +2021,8 @@ declare function updateProject(orgId: string, projectId: string, updates: {
|
|
|
1911
2021
|
*
|
|
1912
2022
|
* @description
|
|
1913
2023
|
* This function uploads a document to the Tinfoil processing service which:
|
|
1914
|
-
* 1.
|
|
1915
|
-
* 2.
|
|
2024
|
+
* 1. Accepts the document and returns a task ID immediately
|
|
2025
|
+
* 2. Processes the document asynchronously in the background
|
|
1916
2026
|
* 3. Maintains end-to-end encryption using session keys
|
|
1917
2027
|
*
|
|
1918
2028
|
* The file is converted to base64 before upload due to encryption requirements.
|
|
@@ -1922,10 +2032,47 @@ declare function updateProject(orgId: string, projectId: string, updates: {
|
|
|
1922
2032
|
* ```typescript
|
|
1923
2033
|
* const file = new File(["content"], "document.pdf", { type: "application/pdf" });
|
|
1924
2034
|
* const result = await uploadDocument(file);
|
|
1925
|
-
* console.log(result.
|
|
2035
|
+
* console.log(result.task_id); // Task ID to check status
|
|
2036
|
+
* ```
|
|
2037
|
+
*/
|
|
2038
|
+
declare function uploadDocument(file: File | Blob): Promise<DocumentUploadInitResponse>;
|
|
2039
|
+
|
|
2040
|
+
/**
|
|
2041
|
+
* Uploads a document and polls for completion
|
|
2042
|
+
* @param file - The file to upload (File or Blob object)
|
|
2043
|
+
* @param options - Optional configuration for polling behavior
|
|
2044
|
+
* @returns A promise resolving to the processed document
|
|
2045
|
+
* @throws {Error} If:
|
|
2046
|
+
* - Upload fails (see uploadDocument errors)
|
|
2047
|
+
* - Processing fails (error from server)
|
|
2048
|
+
* - Processing times out (exceeds maxAttempts)
|
|
2049
|
+
*
|
|
2050
|
+
* @description
|
|
2051
|
+
* This is a convenience function that combines uploadDocument and checkDocumentStatus
|
|
2052
|
+
* to provide a simple interface that handles the async processing automatically.
|
|
2053
|
+
* It uploads the document, then polls the status endpoint until processing completes.
|
|
2054
|
+
*
|
|
2055
|
+
* Options:
|
|
2056
|
+
* - pollInterval: Time between status checks in milliseconds (default: 2000)
|
|
2057
|
+
* - maxAttempts: Maximum number of status checks before timeout (default: 150 = 5 minutes)
|
|
2058
|
+
* - onProgress: Callback function called on each status update
|
|
2059
|
+
*
|
|
2060
|
+
* Example usage:
|
|
2061
|
+
* ```typescript
|
|
2062
|
+
* const file = new File(["content"], "document.pdf", { type: "application/pdf" });
|
|
2063
|
+
* const result = await uploadDocumentWithPolling(file, {
|
|
2064
|
+
* onProgress: (status, progress) => {
|
|
2065
|
+
* console.log(`Status: ${status}, Progress: ${progress || 0}%`);
|
|
2066
|
+
* }
|
|
2067
|
+
* });
|
|
2068
|
+
* console.log(result.text);
|
|
1926
2069
|
* ```
|
|
1927
2070
|
*/
|
|
1928
|
-
declare function
|
|
2071
|
+
declare function uploadDocumentWithPolling(file: File | Blob, options?: {
|
|
2072
|
+
pollInterval?: number;
|
|
2073
|
+
maxAttempts?: number;
|
|
2074
|
+
onProgress?: (status: string, progress?: number) => void;
|
|
2075
|
+
}): Promise<DocumentResponse>;
|
|
1929
2076
|
|
|
1930
2077
|
export declare function useOpenSecret(): OpenSecretContextType;
|
|
1931
2078
|
|