wriftai 0.49.0 → 0.51.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/dist/index.cjs +141 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +121 -122
- package/dist/index.mjs +141 -81
- package/dist/index.mjs.map +1 -1
- package/dist/wriftai.umd.min.js +2 -2
- package/dist/wriftai.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,16 @@ interface ModelCategory {
|
|
|
234
234
|
*/
|
|
235
235
|
slug: string;
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Represents the result of a completed upload.
|
|
239
|
+
*/
|
|
240
|
+
interface UploadCompletionResult {
|
|
241
|
+
/**
|
|
242
|
+
* A time-limited signed URL for downloading the file.
|
|
243
|
+
* No additional authentication is required.
|
|
244
|
+
*/
|
|
245
|
+
download_url: string;
|
|
246
|
+
}
|
|
237
247
|
|
|
238
248
|
/**
|
|
239
249
|
* Representation of an error from WriftAI's API.
|
|
@@ -402,6 +412,7 @@ declare enum ErrorSource {
|
|
|
402
412
|
*/
|
|
403
413
|
declare enum Status {
|
|
404
414
|
pending = "pending",
|
|
415
|
+
starting = "starting",
|
|
405
416
|
started = "started",
|
|
406
417
|
failed = "failed",
|
|
407
418
|
succeeded = "succeeded",
|
|
@@ -467,9 +478,9 @@ interface Prediction {
|
|
|
467
478
|
model: PredictionModel;
|
|
468
479
|
}
|
|
469
480
|
/**
|
|
470
|
-
* Represents a prediction with
|
|
481
|
+
* Represents a prediction with details.
|
|
471
482
|
*/
|
|
472
|
-
interface
|
|
483
|
+
interface PredictionWithDetails extends Prediction {
|
|
473
484
|
/**
|
|
474
485
|
* Input data provided for the prediction.
|
|
475
486
|
*/
|
|
@@ -482,6 +493,10 @@ interface PredictionWithIO extends Prediction {
|
|
|
482
493
|
* Error details if the prediction failed.
|
|
483
494
|
*/
|
|
484
495
|
error: TaskError | null;
|
|
496
|
+
/**
|
|
497
|
+
* Usage metrics returned by the model.
|
|
498
|
+
*/
|
|
499
|
+
metrics: Record<string, JsonValue> | null;
|
|
485
500
|
}
|
|
486
501
|
/**
|
|
487
502
|
* Represents webhook details.
|
|
@@ -530,7 +545,7 @@ interface WaitOptions {
|
|
|
530
545
|
/**
|
|
531
546
|
* Optional callback that receives the latest prediction after each poll.
|
|
532
547
|
*/
|
|
533
|
-
onPoll?: (prediction:
|
|
548
|
+
onPoll?: (prediction: PredictionWithDetails) => Promise<void>;
|
|
534
549
|
}
|
|
535
550
|
/**
|
|
536
551
|
* Default wait options.
|
|
@@ -556,7 +571,7 @@ declare class PredictionsResource extends Resource {
|
|
|
556
571
|
* @param signal Optional AbortSignal to cancel the request.
|
|
557
572
|
* @returns The prediction object.
|
|
558
573
|
*/
|
|
559
|
-
get(id: string, signal?: AbortSignal): Promise<
|
|
574
|
+
get(id: string, signal?: AbortSignal): Promise<PredictionWithDetails>;
|
|
560
575
|
/**
|
|
561
576
|
* Cancel a prediction by its ID.
|
|
562
577
|
* @param id The ID of the prediction to cancel.
|
|
@@ -575,7 +590,7 @@ declare class PredictionsResource extends Resource {
|
|
|
575
590
|
* @param signal Optional AbortSignal to cancel the request.
|
|
576
591
|
* @returns The new prediction.
|
|
577
592
|
*/
|
|
578
|
-
create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<
|
|
593
|
+
create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithDetails>;
|
|
579
594
|
/**
|
|
580
595
|
* List predictions.
|
|
581
596
|
* @param options Optional settings to control pagination behavior.
|
|
@@ -594,7 +609,7 @@ declare class PredictionsResource extends Resource {
|
|
|
594
609
|
* operation.
|
|
595
610
|
* @returns Prediction after completion.
|
|
596
611
|
*/
|
|
597
|
-
wait(predictionID: string, options?: WaitOptions, signal?: AbortSignal): Promise<
|
|
612
|
+
wait(predictionID: string, options?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithDetails>;
|
|
598
613
|
}
|
|
599
614
|
|
|
600
615
|
/**
|
|
@@ -606,9 +621,9 @@ type ModelVersionConfiguration = {
|
|
|
606
621
|
*/
|
|
607
622
|
hardware_identifier: string;
|
|
608
623
|
/**
|
|
609
|
-
* A list of variable
|
|
624
|
+
* A list of variable names for the model version.
|
|
610
625
|
*/
|
|
611
|
-
|
|
626
|
+
variable_names: string[];
|
|
612
627
|
};
|
|
613
628
|
/**
|
|
614
629
|
* Parameters for creating a version of a model.
|
|
@@ -658,10 +673,10 @@ type UpdateModelVersionConfigurationParams = {
|
|
|
658
673
|
*/
|
|
659
674
|
hardware_identifier?: string;
|
|
660
675
|
/**
|
|
661
|
-
* The new list of variable
|
|
662
|
-
* Replaces all current variable
|
|
676
|
+
* The new list of variable names to attach to the model version.
|
|
677
|
+
* Replaces all current variable names.
|
|
663
678
|
*/
|
|
664
|
-
|
|
679
|
+
variable_names?: string[];
|
|
665
680
|
};
|
|
666
681
|
/**
|
|
667
682
|
* Represents a model version with it's details and configuration.
|
|
@@ -1024,114 +1039,35 @@ declare class ModelCategories extends Resource {
|
|
|
1024
1039
|
list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
|
|
1025
1040
|
}
|
|
1026
1041
|
|
|
1027
|
-
/** Resource a file is related to. */
|
|
1028
|
-
type FileResource = 'prediction';
|
|
1029
1042
|
/**
|
|
1030
1043
|
* Represents contents of a file.
|
|
1031
1044
|
*/
|
|
1032
1045
|
type FileContent = File | Blob | Uint8Array;
|
|
1033
1046
|
/**
|
|
1034
|
-
*
|
|
1047
|
+
* Represents a file.
|
|
1035
1048
|
*/
|
|
1036
|
-
|
|
1049
|
+
declare class FileData {
|
|
1050
|
+
/** Contents of the file. */
|
|
1051
|
+
readonly content: FileContent;
|
|
1052
|
+
/** MIME type of the file. */
|
|
1053
|
+
readonly mimeType: string;
|
|
1037
1054
|
/**
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1055
|
+
* Initializes a file.
|
|
1056
|
+
* @param content Contents of the file.
|
|
1057
|
+
* @param mimeType MIME type of the file, overriding the inferred value.
|
|
1058
|
+
* If omitted, it is inferred from the file object's `type` property when
|
|
1059
|
+
* available, otherwise from the file extension in its `name` property.
|
|
1060
|
+
* Falls back to `application/octet-stream` if it cannot be inferred.
|
|
1044
1061
|
*/
|
|
1045
|
-
|
|
1046
|
-
/**
|
|
1047
|
-
* The url to download the file.
|
|
1048
|
-
*/
|
|
1049
|
-
download_url: string;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Parameters for creating file urls.
|
|
1053
|
-
*/
|
|
1054
|
-
type CreateFileUrlsParams = {
|
|
1055
|
-
/**
|
|
1056
|
-
* The name of the file to upload.
|
|
1057
|
-
*/
|
|
1058
|
-
name: string;
|
|
1059
|
-
/**
|
|
1060
|
-
* The size of the file to upload in bytes.
|
|
1061
|
-
* This should be the exact size of the file.
|
|
1062
|
-
* Any mismatch will result in the url being
|
|
1063
|
-
* invalid or a corrupt file being uploaded.
|
|
1064
|
-
*/
|
|
1065
|
-
size: number;
|
|
1066
|
-
/**
|
|
1067
|
-
* The resource the file will be related to.
|
|
1068
|
-
*/
|
|
1069
|
-
resource: FileResource;
|
|
1070
|
-
/**
|
|
1071
|
-
* The MIME type of the file.
|
|
1072
|
-
*/
|
|
1073
|
-
mime_type: string;
|
|
1074
|
-
};
|
|
1075
|
-
/**
|
|
1076
|
-
* Resource for operations related to files.
|
|
1077
|
-
*/
|
|
1078
|
-
declare class Files extends Resource {
|
|
1079
|
-
private fetchImpl;
|
|
1080
|
-
private headers;
|
|
1081
|
-
/**
|
|
1082
|
-
* Create a new Files resource.
|
|
1083
|
-
* @param fetchImpl Fetch implementation to use.
|
|
1084
|
-
* @param headers Additional headers to send with file upload requests.
|
|
1085
|
-
* @param api API client instance used to
|
|
1086
|
-
* communicate with WriftAI's API.
|
|
1087
|
-
*/
|
|
1088
|
-
constructor(fetchImpl: typeof fetch, headers: Record<string, string>, api: API);
|
|
1089
|
-
/**
|
|
1090
|
-
* Generate urls to upload and download a file for a resource.
|
|
1091
|
-
* This is a low-level method. Most callers should use
|
|
1092
|
-
* {@link upload} instead, which handles reading, streaming,
|
|
1093
|
-
* and uploading the file contents.
|
|
1094
|
-
* @param params Parameters for url generation.
|
|
1095
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1096
|
-
* @returns The generated urls.
|
|
1097
|
-
*/
|
|
1098
|
-
createUrls(params: CreateFileUrlsParams, signal?: AbortSignal): Promise<FileUrls>;
|
|
1099
|
-
/**
|
|
1100
|
-
* Upload a file.
|
|
1101
|
-
* The upload is streamed, but the underlying data may already be
|
|
1102
|
-
* in memory depending on how `file` was constructed.
|
|
1103
|
-
* For example, a browser `File` from an `<input>` or Node's
|
|
1104
|
-
* `openAsBlob()` stream from disk, while `new Blob([buffer])` or
|
|
1105
|
-
* `Uint8Array` require the data to already be in memory.
|
|
1106
|
-
* @param file Contents of the file to upload.
|
|
1107
|
-
* @param resource The resource this file relates to.
|
|
1108
|
-
* @param name Display name including extension (e.g. "report.pdf").
|
|
1109
|
-
* When omitted, inferred from `File.name`. Required when file is a `Blob`
|
|
1110
|
-
* or `Uint8Array`.
|
|
1111
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1112
|
-
* @returns The download url for the uploaded file.
|
|
1113
|
-
* @throws {TypeError} If `name` is not provided and `file` is not a
|
|
1114
|
-
* `File` instance.
|
|
1115
|
-
*/
|
|
1116
|
-
upload(file: FileContent, resource: FileResource, name?: string, signal?: AbortSignal): Promise<string>;
|
|
1117
|
-
/**
|
|
1118
|
-
* Resolves the display name for a file.
|
|
1119
|
-
* @param file Contents of the file.
|
|
1120
|
-
* @param name Display name including extension (e.g. "report.pdf").
|
|
1121
|
-
* @returns The resolved mime type.
|
|
1122
|
-
* @throws {TypeError} When `name` is not provided and `file` is not
|
|
1123
|
-
* a `File` instance.
|
|
1124
|
-
*/
|
|
1125
|
-
private resolveFileName;
|
|
1062
|
+
constructor(content: FileContent, mimeType?: string);
|
|
1126
1063
|
/**
|
|
1127
1064
|
* Guesses the MIME type.
|
|
1128
1065
|
* Prefers the file's own type, while falling back to
|
|
1129
1066
|
* extension lookup.
|
|
1130
1067
|
* @param file Contents of the file.
|
|
1131
|
-
* @param name Display name including extension (e.g. "report.pdf").
|
|
1132
1068
|
* @returns The resolved mime type.
|
|
1133
1069
|
*/
|
|
1134
|
-
private resolveMimeType;
|
|
1070
|
+
private static resolveMimeType;
|
|
1135
1071
|
}
|
|
1136
1072
|
|
|
1137
1073
|
/**
|
|
@@ -1139,7 +1075,11 @@ declare class Files extends Resource {
|
|
|
1139
1075
|
*/
|
|
1140
1076
|
interface Variable {
|
|
1141
1077
|
/**
|
|
1142
|
-
* The
|
|
1078
|
+
* The name of the variable.
|
|
1079
|
+
*/
|
|
1080
|
+
name: string;
|
|
1081
|
+
/**
|
|
1082
|
+
* The key of the variable.
|
|
1143
1083
|
*/
|
|
1144
1084
|
key: string;
|
|
1145
1085
|
/**
|
|
@@ -1165,7 +1105,11 @@ interface Variable {
|
|
|
1165
1105
|
*/
|
|
1166
1106
|
type CreateVariableParams = {
|
|
1167
1107
|
/**
|
|
1168
|
-
* The
|
|
1108
|
+
* The name of the variable.
|
|
1109
|
+
*/
|
|
1110
|
+
name: string;
|
|
1111
|
+
/**
|
|
1112
|
+
* The key of the variable.
|
|
1169
1113
|
*/
|
|
1170
1114
|
key: string;
|
|
1171
1115
|
/**
|
|
@@ -1201,18 +1145,18 @@ declare class Variables extends Resource {
|
|
|
1201
1145
|
create(params: CreateVariableParams, signal?: AbortSignal): Promise<Variable>;
|
|
1202
1146
|
/**
|
|
1203
1147
|
* Delete a variable.
|
|
1204
|
-
* @param
|
|
1148
|
+
* @param name The name of the variable to be deleted.
|
|
1205
1149
|
* @param signal Optional abort signal.
|
|
1206
1150
|
*/
|
|
1207
|
-
delete(
|
|
1151
|
+
delete(name: string, signal?: AbortSignal): Promise<void>;
|
|
1208
1152
|
/**
|
|
1209
1153
|
* Update a variable.
|
|
1210
|
-
* @param
|
|
1154
|
+
* @param name The name of the variable to be updated.
|
|
1211
1155
|
* @param params The parameters for updating the variable.
|
|
1212
1156
|
* @param signal Optional abort signal.
|
|
1213
1157
|
* @returns The updated variable.
|
|
1214
1158
|
*/
|
|
1215
|
-
update(
|
|
1159
|
+
update(name: string, params: UpdateVariableParams, signal?: AbortSignal): Promise<Variable>;
|
|
1216
1160
|
/**
|
|
1217
1161
|
* List variables.
|
|
1218
1162
|
* @param options Optional settings to control pagination behavior.
|
|
@@ -1331,16 +1275,6 @@ type CompleteUploadParams = {
|
|
|
1331
1275
|
*/
|
|
1332
1276
|
etags: string[];
|
|
1333
1277
|
};
|
|
1334
|
-
/**
|
|
1335
|
-
* Represents the result of a completed upload.
|
|
1336
|
-
*/
|
|
1337
|
-
interface UploadCompletionResult {
|
|
1338
|
-
/**
|
|
1339
|
-
* A time-limited signed URL for downloading the file.
|
|
1340
|
-
* No additional authentication is required.
|
|
1341
|
-
*/
|
|
1342
|
-
download_url: string;
|
|
1343
|
-
}
|
|
1344
1278
|
/**
|
|
1345
1279
|
* Resource for operations related to uploads.
|
|
1346
1280
|
*/
|
|
@@ -1419,6 +1353,71 @@ declare class AuthenticatedUser extends Resource {
|
|
|
1419
1353
|
models(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Model>>;
|
|
1420
1354
|
}
|
|
1421
1355
|
|
|
1356
|
+
/**
|
|
1357
|
+
* Resource for operations related to files.
|
|
1358
|
+
*/
|
|
1359
|
+
declare class Files {
|
|
1360
|
+
private fetchImpl;
|
|
1361
|
+
private headers;
|
|
1362
|
+
private uploads;
|
|
1363
|
+
private readonly MAX_CONCURRENT_PARTS;
|
|
1364
|
+
/**
|
|
1365
|
+
* Create a new Files resource.
|
|
1366
|
+
* @param fetchImpl Fetch implementation to use.
|
|
1367
|
+
* @param headers Additional headers to send with file upload requests.
|
|
1368
|
+
* @param uploads An instance of the uploads resource.
|
|
1369
|
+
*/
|
|
1370
|
+
constructor(fetchImpl: typeof fetch, headers: Record<string, string>, uploads: Uploads);
|
|
1371
|
+
/**
|
|
1372
|
+
* Uploads a single part and returns its etag.
|
|
1373
|
+
* @param url The part's upload url.
|
|
1374
|
+
* @param part The part's content.
|
|
1375
|
+
* @param mimeType Content type for the part.
|
|
1376
|
+
* @param signal Optional abort signal.
|
|
1377
|
+
* @returns The uploaded part's etag, or null if the response carried
|
|
1378
|
+
* no etag header.
|
|
1379
|
+
*/
|
|
1380
|
+
private uploadPart;
|
|
1381
|
+
/**
|
|
1382
|
+
* Claims and uploads parts by calling `next` until it returns
|
|
1383
|
+
* undefined, returning each claimed part's index and etag.
|
|
1384
|
+
* @param body File content to upload.
|
|
1385
|
+
* @param urls Part upload URLs.
|
|
1386
|
+
* @param partSize Size of each part in bytes.
|
|
1387
|
+
* @param next Claims the next unclaimed part index, shared across
|
|
1388
|
+
* workers; returns undefined once no parts remain.
|
|
1389
|
+
* @param mimeType Content type for each part.
|
|
1390
|
+
* @param signal Optional abort signal.
|
|
1391
|
+
* @returns The index and etag of every part this worker uploaded.
|
|
1392
|
+
*/
|
|
1393
|
+
private uploadWorker;
|
|
1394
|
+
/**
|
|
1395
|
+
* Uploads a blob in parts concurrently and returns any collected ETags.
|
|
1396
|
+
* If any part fails, remaining in-flight parts are aborted rather
|
|
1397
|
+
* than left to complete.
|
|
1398
|
+
* @param body File content to upload.
|
|
1399
|
+
* @param urls Part upload URLs.
|
|
1400
|
+
* @param partSize Size of each part in bytes.
|
|
1401
|
+
* @param mimeType Content type for uploaded parts.
|
|
1402
|
+
* @param signal Optional abort signal.
|
|
1403
|
+
* @returns Collected ETags from successful uploads.
|
|
1404
|
+
*/
|
|
1405
|
+
private uploadParts;
|
|
1406
|
+
/**
|
|
1407
|
+
* Upload a file.
|
|
1408
|
+
* The upload is streamed, but the underlying data may already be
|
|
1409
|
+
* in memory depending on how `file` was constructed.
|
|
1410
|
+
* For example, a browser `File` from an `<input>` or Node's
|
|
1411
|
+
* `openAsBlob()` stream from disk, while `new Blob([buffer])` or
|
|
1412
|
+
* `Uint8Array` require the data to already be in memory.
|
|
1413
|
+
* Large files are split into parts by the server and uploaded concurrently.
|
|
1414
|
+
* @param file The file to upload.
|
|
1415
|
+
* @param signal Optional AbortSignal to cancel the request.
|
|
1416
|
+
* @returns Result of the completed upload.
|
|
1417
|
+
*/
|
|
1418
|
+
upload(file: FileData, signal?: AbortSignal): Promise<UploadCompletionResult>;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1422
1421
|
interface WriftAIClientOptions {
|
|
1423
1422
|
/**
|
|
1424
1423
|
* Optional base URL for the API. It must not contain
|
|
@@ -1514,5 +1513,5 @@ declare class WriftAI {
|
|
|
1514
1513
|
constructor(options?: WriftAIClientOptions);
|
|
1515
1514
|
}
|
|
1516
1515
|
|
|
1517
|
-
export { DEFAULT_WAIT_OPTIONS, ErrorSource, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1518
|
-
export type { BaseUser, Compatibilities,
|
|
1516
|
+
export { DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1517
|
+
export type { BaseUser, Compatibilities, Hardware, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionConfiguration, ModelVersionWithDetails, ModelVersionWithDetailsAndConfiguration, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithDetails, SchemaIO, Schemas, TaskError, Upload, UploadCompletionResult, User, UserWithDetails, Variable, WriftAIClientOptions };
|