@foxnose/sdk 0.6.1 → 0.8.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.d.cts CHANGED
@@ -93,8 +93,8 @@ interface RetryConfig {
93
93
  methods: readonly string[];
94
94
  }
95
95
  declare const DEFAULT_RETRY_CONFIG: Readonly<RetryConfig>;
96
- declare const SDK_VERSION = "0.6.1";
97
- declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.6.1";
96
+ declare const SDK_VERSION = "0.8.0";
97
+ declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.8.0";
98
98
  /**
99
99
  * General transport-level configuration shared by all clients.
100
100
  */
@@ -185,6 +185,42 @@ declare class PlanExhaustedError extends FoxnoseAPIError {
185
185
  upgradeUrl?: string;
186
186
  });
187
187
  }
188
+ /**
189
+ * Raised on HTTP 402 `files_quota_exceeded` when no file processing units are left.
190
+ *
191
+ * `reason` says what ran out, and the matching link is `upgradeUrl` or `raiseCapUrl`.
192
+ * A refusal relayed by Flux carries the code only, so these fields are undefined there.
193
+ */
194
+ declare class FilesQuotaExceededError extends FoxnoseAPIError {
195
+ readonly axis?: string;
196
+ readonly reason?: string;
197
+ readonly usedUnits?: number;
198
+ readonly includedUnits?: number | null;
199
+ readonly capUsd?: number | null;
200
+ readonly windowResetsAt?: string | null;
201
+ readonly upgradeUrl?: string;
202
+ readonly raiseCapUrl?: string;
203
+ constructor(options: APIErrorOptions & {
204
+ axis?: string;
205
+ reason?: string;
206
+ usedUnits?: number;
207
+ includedUnits?: number | null;
208
+ capUsd?: number | null;
209
+ windowResetsAt?: string | null;
210
+ upgradeUrl?: string;
211
+ raiseCapUrl?: string;
212
+ });
213
+ }
214
+ /**
215
+ * Raised on HTTP 503 `files_quota_unavailable` when the file processing quota could
216
+ * not be read, so nothing was started. Retry after `retryAfter` seconds.
217
+ */
218
+ declare class FilesQuotaUnavailableError extends FoxnoseAPIError {
219
+ readonly retryAfter?: number;
220
+ constructor(options: APIErrorOptions & {
221
+ retryAfter?: number;
222
+ });
223
+ }
188
224
  /**
189
225
  * Raised on HTTP 403 when a plan entity limit is exceeded.
190
226
  */
@@ -253,6 +289,52 @@ declare class ContentValidationFailedError extends FoxnoseAPIError {
253
289
  declare class UpstreamError extends FoxnoseAPIError {
254
290
  constructor(options: APIErrorOptions);
255
291
  }
292
+ /**
293
+ * Raised on HTTP 404 `webhook_endpoint_not_found`: no endpoint with this id in the
294
+ * environment.
295
+ */
296
+ declare class WebhookEndpointNotFoundError extends FoxnoseAPIError {
297
+ constructor(options: APIErrorOptions);
298
+ }
299
+ /**
300
+ * Raised on HTTP 404 `webhook_event_not_found`: no such event in the environment
301
+ * within the last 30 days.
302
+ */
303
+ declare class WebhookEventNotFoundError extends FoxnoseAPIError {
304
+ constructor(options: APIErrorOptions);
305
+ }
306
+ /**
307
+ * Raised on HTTP 409 `limit_exceeded`: the environment already has the most webhook
308
+ * endpoints it can have (20).
309
+ */
310
+ declare class WebhookEndpointLimitExceededError extends FoxnoseAPIError {
311
+ constructor(options: APIErrorOptions);
312
+ }
313
+ /**
314
+ * Raised on HTTP 409 `endpoint_not_active`: the endpoint is paused, disabled or
315
+ * deleted, so a test event, a recovery or a redelivery cannot go to it.
316
+ */
317
+ declare class WebhookEndpointNotActiveError extends FoxnoseAPIError {
318
+ /** The endpoint's state (`paused`, `disabled` or `deleted`) when the call named it. */
319
+ readonly reason?: string;
320
+ /** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
321
+ readonly skipped: unknown[];
322
+ constructor(options: APIErrorOptions & {
323
+ reason?: string;
324
+ skipped?: unknown[];
325
+ });
326
+ }
327
+ /**
328
+ * Raised on HTTP 409 `endpoint_not_subscribed`: the endpoint's current event types or
329
+ * collection filter do not cover the event.
330
+ */
331
+ declare class WebhookEndpointNotSubscribedError extends FoxnoseAPIError {
332
+ /** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
333
+ readonly skipped: unknown[];
334
+ constructor(options: APIErrorOptions & {
335
+ skipped?: unknown[];
336
+ });
337
+ }
256
338
  /**
257
339
  * Raised when authentication headers cannot be generated.
258
340
  */
@@ -305,6 +387,39 @@ interface PaginatedResponse<T> {
305
387
  previous: string | null;
306
388
  results: T[];
307
389
  }
390
+ /** Where a file stands in the processing steps. */
391
+ interface UploadFileProgress {
392
+ step: number;
393
+ of: number;
394
+ step_name: string | null;
395
+ }
396
+ /** The file attached to a record or a revision. */
397
+ interface FileSummary {
398
+ uuid: string | null;
399
+ mime: string | null;
400
+ width: number | null;
401
+ height: number | null;
402
+ cdn_url_base: string | null;
403
+ filename: string | null;
404
+ size: number | null;
405
+ page_count: number | null;
406
+ }
407
+ /**
408
+ * The parent record of a file record. `title` is `null` when the caller may not
409
+ * read the owner, and `deleted` is `true` for a parent that was deleted.
410
+ */
411
+ interface FileRecordOwner {
412
+ key: string;
413
+ title: string | null;
414
+ deleted?: boolean;
415
+ }
416
+ /** A file record's newest file, published or not. */
417
+ interface FileInfo {
418
+ filename: string | null;
419
+ mime: string | null;
420
+ size: number | null;
421
+ page_count: number | null;
422
+ }
308
423
  interface ResourceSummary {
309
424
  key: string;
310
425
  folder: string;
@@ -312,14 +427,34 @@ interface ResourceSummary {
312
427
  created_at: string;
313
428
  vectors_size: number;
314
429
  name?: string | null;
430
+ name_is_auto?: boolean;
315
431
  resource_owner?: string | null;
316
432
  current_revision?: string | null;
317
433
  external_id?: string | null;
434
+ file?: FileSummary | null;
435
+ /** Set on a record of a files collection, like the fields below it. */
436
+ owner?: FileRecordOwner | null;
437
+ status?: string | null;
438
+ progress?: UploadFileProgress | null;
439
+ analysis_state?: string | null;
440
+ /** Short-lived. Keep it out of logs. */
441
+ thumbnail_url?: string | null;
442
+ file_info?: FileInfo | null;
443
+ verdict?: string | null;
444
+ verdict_reasons?: unknown[];
445
+ /** The record's trust summary, where the API computes one. */
446
+ guardrails?: Record<string, unknown> | null;
318
447
  }
319
448
  interface RevisionSummary {
320
449
  key: string;
321
450
  resource: string;
322
- schema_version: string;
451
+ /** `null` when the schema version is gone. */
452
+ schema_version: string | null;
453
+ /** `null` for a draft version, and when the schema version is gone. */
454
+ schema_version_number?: number | null;
455
+ file?: FileSummary | null;
456
+ /** The revision's trust summary, where the API computes one. */
457
+ guardrails?: Record<string, unknown> | null;
323
458
  number: number;
324
459
  size: number;
325
460
  created_at: string;
@@ -732,6 +867,8 @@ interface OrganizationSummary {
732
867
  block_dt?: string | null;
733
868
  block_reason?: string | null;
734
869
  is_blocked: boolean;
870
+ is_verified?: boolean;
871
+ verification_method?: string | null;
735
872
  }
736
873
  type OrganizationList = OrganizationSummary[];
737
874
  interface PlanLimits {
@@ -808,6 +945,408 @@ interface BatchUpsertResult {
808
945
  succeeded: ResourceSummary[];
809
946
  failed: BatchItemError[];
810
947
  }
948
+ /** A kind of file a collection or an upload link accepts. */
949
+ type FileKind = 'image' | 'document' | 'archive';
950
+ /** Body of {@link ManagementClient.createUploadLink}. */
951
+ interface UploadLinkCreateRequest {
952
+ /** The parent record that owns the uploaded files; the caller must be able to read it. */
953
+ owner: ResourceRef;
954
+ /** Heading of the hosted page: 1 to 80 characters, one line. */
955
+ title: string;
956
+ /** Plain text under the heading, up to 500 characters. */
957
+ instructions?: string;
958
+ /** How many files the link accepts, from 1 to 10. Defaults to 1. */
959
+ max_files?: number;
960
+ /** Narrows the collection's kinds for this link. */
961
+ allowed_kinds?: FileKind[];
962
+ /** The link's lifetime in seconds, from 300 to 86400. Defaults to 30 minutes. */
963
+ expires_in?: number;
964
+ }
965
+ /** Who created an upload link. */
966
+ interface UploadLinkCreator {
967
+ kind: 'user' | 'api_key';
968
+ label: string | null;
969
+ /** The user's uid, for `kind: 'user'`. */
970
+ user?: string;
971
+ /** The key's uid, for `kind: 'api_key'`. */
972
+ key?: string;
973
+ }
974
+ /** One file uploaded through a link, as the link's owner sees it. */
975
+ interface UploadLinkFile {
976
+ state: 'processing' | 'ready' | 'pending_review' | 'rejected';
977
+ record_key?: string | null;
978
+ public_reason?: string;
979
+ file_name?: string | null;
980
+ progress?: UploadFileProgress;
981
+ }
982
+ /** One visit to a link's hosted page and the files it uploaded. */
983
+ interface UploadLinkSession {
984
+ created_at: string | null;
985
+ expires_at: string | null;
986
+ files: UploadLinkFile[];
987
+ }
988
+ /** An upload link with its sessions and the status of each file. */
989
+ interface UploadLink {
990
+ upload_id: string;
991
+ created_by: UploadLinkCreator | null;
992
+ owner_key: string | null;
993
+ title: string | null;
994
+ instructions: string | null;
995
+ max_files: number;
996
+ allowed_kinds: string[];
997
+ consumed_count: number;
998
+ created_at: string;
999
+ expires_at: string;
1000
+ revoked_at: string | null;
1001
+ state: 'active' | 'consumed' | 'expired' | 'revoked';
1002
+ sessions: UploadLinkSession[];
1003
+ }
1004
+ type UploadLinkList = PaginatedResponse<UploadLink>;
1005
+ /**
1006
+ * The answer to creating an upload link. `upload_url` carries the link's token
1007
+ * and is returned only here: no later read reproduces it. Keep it out of logs.
1008
+ */
1009
+ interface UploadLinkCreated {
1010
+ upload_id: string;
1011
+ title: string;
1012
+ instructions: string | null;
1013
+ upload_url: string;
1014
+ expires_at: string;
1015
+ max_files: number;
1016
+ allowed_kinds: string[];
1017
+ }
1018
+ /** The active analysis of a file. */
1019
+ interface FileAnalysis {
1020
+ generation: number;
1021
+ state: string;
1022
+ verdict: string | null;
1023
+ verdict_reasons: unknown[];
1024
+ public_reason: string | null;
1025
+ error_code: string | null;
1026
+ in_review: boolean;
1027
+ publish_requested_by: string | null;
1028
+ policy_version: number | null;
1029
+ pipeline_version: string | null;
1030
+ source_format: string | null;
1031
+ scanned_at: string | null;
1032
+ step_times: Record<string, unknown>;
1033
+ state_changed_at: string | null;
1034
+ created_at: string | null;
1035
+ }
1036
+ /** The receipt of one check that ran on a file. */
1037
+ interface FileCheck {
1038
+ detector: string;
1039
+ detector_version: string | null;
1040
+ status: string;
1041
+ started_at: string | null;
1042
+ finished_at: string | null;
1043
+ }
1044
+ /** The text of one zone of a finding. */
1045
+ interface FileEvidencePart {
1046
+ box?: unknown;
1047
+ text?: string;
1048
+ }
1049
+ /**
1050
+ * The concealed or withheld text a finding holds, as it was in the file.
1051
+ *
1052
+ * `parts` says which text lies in which box of the page. It is empty for a finding
1053
+ * that does not carry it, so fall back to `text`.
1054
+ */
1055
+ interface FileTextEvidence {
1056
+ page?: number;
1057
+ box?: unknown;
1058
+ tokens?: number;
1059
+ text?: string;
1060
+ samples?: string[];
1061
+ reason?: string;
1062
+ parts: FileEvidencePart[];
1063
+ truncated?: boolean;
1064
+ list_truncated?: boolean;
1065
+ omitted?: number;
1066
+ }
1067
+ /** One finding of an analysis. */
1068
+ interface FileFinding {
1069
+ kind: string;
1070
+ sub_kind: string | null;
1071
+ severity: string;
1072
+ page: number | null;
1073
+ box: unknown;
1074
+ detector: string | null;
1075
+ detector_version: string | null;
1076
+ score: number | null;
1077
+ /**
1078
+ * The stored string, `null` once a blocked or rejected file's personal data is
1079
+ * redacted. It can quote text from the file. {@link parseFindingEvidence} reads it
1080
+ * for a finding that holds text.
1081
+ */
1082
+ evidence: string | null;
1083
+ detail: Record<string, unknown> | null;
1084
+ rule_id: string | null;
1085
+ }
1086
+ /** Whether one copy of a file can be downloaded now, and why not if it cannot. */
1087
+ interface FileCopyAvailability {
1088
+ available: boolean;
1089
+ reason: string | null;
1090
+ }
1091
+ /** Active content found in a file. `present` is `null` when it is unknown. */
1092
+ interface FileActiveContent {
1093
+ present?: boolean | null;
1094
+ kinds?: Record<string, number>;
1095
+ truncated?: boolean;
1096
+ }
1097
+ /** Who started an upload. `name` is `null` when it cannot be found. */
1098
+ interface FileOriginActor {
1099
+ kind: 'user' | 'management_key' | 'flux_key';
1100
+ name: string | null;
1101
+ }
1102
+ /** The upload link a file came through. */
1103
+ interface FileOriginLink {
1104
+ upload_id: string;
1105
+ title: string | null;
1106
+ }
1107
+ /**
1108
+ * Where a record's file came from. `external` is true for a file that came from
1109
+ * outside the team. `end_user` is the identifier given when an end user's upload was
1110
+ * signed: personal data, so keep it out of logs.
1111
+ */
1112
+ interface FileOrigin {
1113
+ channel: 'upload_link' | 'signed_upload' | 'management_api' | 'dashboard' | null;
1114
+ external: boolean;
1115
+ created_by: FileOriginActor | null;
1116
+ upload_link: FileOriginLink | null;
1117
+ end_user: string | null;
1118
+ }
1119
+ /**
1120
+ * What the caller may download of a record's file, and where it came from. `origin`
1121
+ * is set on `getFileAnalysis` for a file bound to the record, and `null` for a record
1122
+ * uploaded without an intent.
1123
+ */
1124
+ interface FileDownloadOptions {
1125
+ original: FileCopyAvailability;
1126
+ safe_copy: FileCopyAvailability;
1127
+ active_content: FileActiveContent;
1128
+ original_access: string;
1129
+ origin?: FileOrigin | null;
1130
+ }
1131
+ /** How agent surfaces mark the file's content. */
1132
+ interface FileTrust {
1133
+ processing: string;
1134
+ content_tainted: boolean;
1135
+ tainted_paths: string[];
1136
+ }
1137
+ /** A record's file, its active analysis, check receipts and findings. */
1138
+ interface FileRecordView {
1139
+ resource_key: string;
1140
+ file_uuid: string | null;
1141
+ page_count: number | null;
1142
+ asset_state: string | null;
1143
+ tombstone: boolean;
1144
+ trust: FileTrust | null;
1145
+ analysis: FileAnalysis | null;
1146
+ checks: FileCheck[];
1147
+ findings: FileFinding[];
1148
+ file: FileDownloadOptions | null;
1149
+ /** Set on the answer to an approval only. */
1150
+ outcome?: string;
1151
+ /** Set on the answer to an approval only. */
1152
+ reason?: string | null;
1153
+ }
1154
+ /** A short-lived link to one copy of a file. Keep `url` out of logs. */
1155
+ interface FileDownload {
1156
+ url: string;
1157
+ expires_in: number | null;
1158
+ expires_at: string | null;
1159
+ kind: 'original' | 'safe_copy' | 'page';
1160
+ filename: string | null;
1161
+ content_type: string | null;
1162
+ generation: number | null;
1163
+ state: string | null;
1164
+ active_content: FileActiveContent | null;
1165
+ warnings: Record<string, unknown>[];
1166
+ }
1167
+ /** A region withheld from a page image. */
1168
+ interface FilePageRedaction {
1169
+ reason: string;
1170
+ box: number[];
1171
+ label: string | null;
1172
+ }
1173
+ /** A table found on a page. */
1174
+ interface FilePageTable {
1175
+ box: unknown;
1176
+ }
1177
+ /**
1178
+ * Where personal data stands on a page. `unreliable` marks data found only in text
1179
+ * read with low confidence. The matched text is never included.
1180
+ */
1181
+ interface FilePagePii {
1182
+ type: string;
1183
+ label: string | null;
1184
+ box: number[];
1185
+ unreliable?: boolean;
1186
+ }
1187
+ /** The findings of a file that share a kind, severity and source. */
1188
+ interface FileFindingGroup {
1189
+ code: string;
1190
+ sub_kind: string | null;
1191
+ severity: string;
1192
+ source: string;
1193
+ pages: number[];
1194
+ removed_from_agents: boolean;
1195
+ label?: string;
1196
+ rule_id?: string;
1197
+ }
1198
+ /** A finding of one page. `box` is `null` when it has no place on the page. */
1199
+ interface FilePageFinding {
1200
+ code: string;
1201
+ sub_kind: string | null;
1202
+ severity: string;
1203
+ source: string;
1204
+ box: number[] | null;
1205
+ removed_from_agents: boolean;
1206
+ label?: string;
1207
+ rule_id?: string;
1208
+ }
1209
+ /**
1210
+ * One page of a file. `image_url` is short-lived. `redactions`, `tables`, `text`,
1211
+ * `content_flags`, `pii` and `pii_truncated` are `null` for a page without extracted
1212
+ * text. With `pii_truncated` true, an empty `pii` means locations were discarded, not
1213
+ * that none were found.
1214
+ *
1215
+ * `findings` covers the whole file and `page_findings` this page. Neither carries
1216
+ * evidence. `removed_passages` counts the file's findings whose text is withheld from
1217
+ * agents.
1218
+ */
1219
+ interface FilePageDetail {
1220
+ page: number;
1221
+ of: number | null;
1222
+ image_url: string;
1223
+ image_width: number | null;
1224
+ image_height: number | null;
1225
+ expires_in: number | null;
1226
+ redactions: FilePageRedaction[] | null;
1227
+ tables: FilePageTable[] | null;
1228
+ text: string | null;
1229
+ content_flags: Record<string, unknown>[] | null;
1230
+ pii: FilePagePii[] | null;
1231
+ pii_truncated: boolean | null;
1232
+ findings: FileFindingGroup[];
1233
+ page_findings: FilePageFinding[];
1234
+ removed_passages: number;
1235
+ trust: FileTrust;
1236
+ verdict: string | null;
1237
+ reasons: unknown[];
1238
+ generation: number | null;
1239
+ state: string | null;
1240
+ }
1241
+ /**
1242
+ * A blocked or rejected file. `original_filename`, `raw_payload`, `uploaded_by`,
1243
+ * `owner_key` and each finding's `evidence` are `null` once `redacted` is true.
1244
+ */
1245
+ interface FileTombstone {
1246
+ resource_key: string | null;
1247
+ file_uuid: string | null;
1248
+ reason: string;
1249
+ public_reason: string | null;
1250
+ error_code: string | null;
1251
+ verdict_reasons: unknown[];
1252
+ generation: number | null;
1253
+ asset_state: string | null;
1254
+ blocked_at: string | null;
1255
+ purge_completed_at: string | null;
1256
+ redacts_at: string | null;
1257
+ redacted: boolean;
1258
+ original_filename: string | null;
1259
+ raw_payload: unknown;
1260
+ uploaded_by: string | null;
1261
+ owner_key: string | null;
1262
+ findings: FileFinding[];
1263
+ }
1264
+ type FileTombstoneList = PaginatedResponse<FileTombstone>;
1265
+ /** Counts of a file's findings. */
1266
+ interface FileFindingsSummary {
1267
+ total: number;
1268
+ by_kind: Record<string, number>;
1269
+ by_severity: Record<string, number>;
1270
+ }
1271
+ /**
1272
+ * A file held for a reviewer. `owner` is `null` outside a strict collection.
1273
+ * `thumbnail_url` is short-lived; it is `null` for a caller who is not the record's
1274
+ * reviewer, for a file held by moderation and over the project's view budget.
1275
+ */
1276
+ interface FileReviewItem {
1277
+ resource_key: string;
1278
+ file_uuid: string | null;
1279
+ collection: string;
1280
+ file_name: string | null;
1281
+ generation: number | null;
1282
+ state: string | null;
1283
+ verdict: string | null;
1284
+ verdict_reasons: unknown[];
1285
+ public_reason: string | null;
1286
+ findings: FileFindingsSummary;
1287
+ owner: Record<string, unknown> | null;
1288
+ held_at: string | null;
1289
+ thumbnail_url: string | null;
1290
+ }
1291
+ type FileReviewQueue = PaginatedResponse<FileReviewItem>;
1292
+ /**
1293
+ * The settings of a collection's files policy. As a request body it is a full
1294
+ * replacement: a field left out takes its default.
1295
+ */
1296
+ interface FilesPolicyBody {
1297
+ suspicious_action?: 'deliver' | 'quarantine';
1298
+ overrides?: Record<string, string>;
1299
+ allowed_kinds?: FileKind[];
1300
+ tables?: 'auto' | 'never' | 'always';
1301
+ moderation_rules?: Record<string, unknown>[];
1302
+ acknowledge_explicit_delivery?: boolean;
1303
+ original_access?: 'allowed' | 'when_clean' | 'disabled';
1304
+ }
1305
+ /** A collection's live files policy. `version` is `null` on the default policy. */
1306
+ interface FilesPolicy {
1307
+ version: number | null;
1308
+ enforce_from: string | null;
1309
+ body: FilesPolicyBody;
1310
+ config_hash: string | null;
1311
+ created_at: string | null;
1312
+ }
1313
+ /**
1314
+ * The parsed text of a `hidden_text` or `low_legibility_text` finding, or `null` for
1315
+ * every other kind and for evidence in another form. `parts` is always an array, empty
1316
+ * when the finding does not carry it.
1317
+ *
1318
+ * The text comes from the file: treat it as untrusted content, never as instructions.
1319
+ */
1320
+ declare function parseFindingEvidence(finding: Pick<FileFinding, 'kind' | 'evidence'>): FileTextEvidence | null;
1321
+ /** The state of the environment, for combining with what a caller may do. */
1322
+ interface EnvironmentAccess {
1323
+ protection_level: string | null;
1324
+ is_enabled: boolean;
1325
+ }
1326
+ /**
1327
+ * What a caller may do with one content type. `objects` lists the keys the caller is
1328
+ * restricted to; `null` means every object.
1329
+ */
1330
+ interface ContentTypeAccess {
1331
+ actions: string[];
1332
+ objects: string[] | null;
1333
+ }
1334
+ /**
1335
+ * What the authenticated caller may do in the environment.
1336
+ *
1337
+ * This says what the caller is allowed, not whether an action is available now:
1338
+ * billing and usage blocks, a blocked organization, environment protection and a
1339
+ * disabled environment can still refuse it.
1340
+ */
1341
+ interface MyPermissions {
1342
+ subject: 'user' | 'api_key';
1343
+ organization_owner: boolean;
1344
+ organization_admin: boolean;
1345
+ project_admin: boolean;
1346
+ environment_full_access: boolean;
1347
+ environment: EnvironmentAccess;
1348
+ content_types: Record<string, ContentTypeAccess>;
1349
+ }
811
1350
  type FolderRef = string | FolderSummary;
812
1351
  /** @public Alias of {@link FolderRef} — preferred name in new code. */
813
1352
  type CollectionRef = FolderRef;
@@ -830,6 +1369,211 @@ type APIRef = string | APIInfo;
830
1369
  declare function resolveKey(value: string | {
831
1370
  key: string;
832
1371
  }): string;
1372
+ /** What an endpoint receives: ids and links only, or a snapshot of the content. */
1373
+ type WebhookPayloadMode = 'references' | 'content';
1374
+ /** `active`, `paused`, or `disabled` by FoxNose after `410 Gone` or five days of failures. */
1375
+ type WebhookEndpointStatus = 'active' | 'paused' | 'disabled';
1376
+ /** Attempts of the last 24 hours: all of them and those answered with `2xx`. */
1377
+ interface WebhookStats24h {
1378
+ attempts: number;
1379
+ succeeded: number;
1380
+ }
1381
+ /**
1382
+ * A webhook endpoint. It never carries the signing secret. `stats_24h` is set on
1383
+ * the items of a list only.
1384
+ */
1385
+ interface WebhookEndpoint {
1386
+ id: string;
1387
+ url: string;
1388
+ description: string;
1389
+ event_types: string[];
1390
+ collection_keys: string[];
1391
+ payload_mode: WebhookPayloadMode;
1392
+ version: number;
1393
+ status: WebhookEndpointStatus;
1394
+ /** `gone` (it answered `410 Gone`) or `failing` (no success for 5 days). */
1395
+ disabled_reason: string | null;
1396
+ failing_since: string | null;
1397
+ disabled_at: string | null;
1398
+ created_at: string;
1399
+ updated_at: string;
1400
+ stats_24h?: WebhookStats24h;
1401
+ }
1402
+ type WebhookEndpointList = PaginatedResponse<WebhookEndpoint>;
1403
+ /**
1404
+ * The answer to creating an endpoint: the endpoint and its signing secret.
1405
+ *
1406
+ * `secret` is not enumerable: `console.log`, `JSON.stringify`, `util.inspect` and a
1407
+ * spread leave it out, and only a direct read, `created.secret`, returns it. Read it
1408
+ * again later with {@link ManagementClient.getWebhookEndpointSecret}.
1409
+ */
1410
+ interface WebhookEndpointCreated extends WebhookEndpoint {
1411
+ readonly secret: string;
1412
+ }
1413
+ /** The current signing secret. `secret` is not enumerable, like {@link WebhookEndpointCreated.secret}. */
1414
+ interface WebhookSecret {
1415
+ readonly secret: string | null;
1416
+ }
1417
+ /**
1418
+ * The answer to rotating a secret. `previous_secret_expires_at` is when the old
1419
+ * secret stops being used, or `null` when none is left. `secret` is not enumerable.
1420
+ */
1421
+ interface WebhookSecretRotation {
1422
+ readonly secret: string;
1423
+ previous_secret_expires_at: string | null;
1424
+ }
1425
+ /** Body of {@link ManagementClient.createWebhookEndpoint}. */
1426
+ interface WebhookEndpointCreateRequest {
1427
+ /** The `https` URL deliveries are sent to. */
1428
+ url: string;
1429
+ /** Event types to receive, at least one. */
1430
+ event_types: string[];
1431
+ /** At most 255 characters. */
1432
+ description?: string;
1433
+ /** Collections to receive events from, at most 50. Empty or omitted for every collection. */
1434
+ collection_keys?: CollectionRef[];
1435
+ /** `references` (the default) or `content`. */
1436
+ payload_mode?: WebhookPayloadMode;
1437
+ /** Payload version; `1` is the only one. */
1438
+ version?: number;
1439
+ }
1440
+ /** Body of {@link ManagementClient.updateWebhookEndpoint}: send only the fields to change. */
1441
+ interface WebhookEndpointUpdateRequest extends Partial<WebhookEndpointCreateRequest> {
1442
+ /** `active` resumes a paused or disabled endpoint and clears its failure streak. */
1443
+ status?: 'active' | 'paused';
1444
+ }
1445
+ /** The endpoint of a delivery or an attempt; `deleted` once it was removed. */
1446
+ interface WebhookEndpointRef {
1447
+ id: string;
1448
+ deleted: boolean;
1449
+ }
1450
+ /** One event sent to one endpoint, with all its attempts. */
1451
+ interface WebhookDelivery {
1452
+ id: string;
1453
+ endpoint: WebhookEndpointRef;
1454
+ /** `pending`, `succeeded` or `dead`. */
1455
+ status: 'pending' | 'succeeded' | 'dead';
1456
+ attempts: number;
1457
+ last_status_code: number | null;
1458
+ last_error: string | null;
1459
+ created_at: string;
1460
+ finished_at: string | null;
1461
+ /** Set only while the delivery is pending. */
1462
+ next_attempt_at: string | null;
1463
+ }
1464
+ /** The event a delivery carries. */
1465
+ interface WebhookDeliveryEvent {
1466
+ id: string;
1467
+ type: string;
1468
+ test: boolean;
1469
+ }
1470
+ /** A delivery in an endpoint's delivery list. `event` is `null` once the event has aged out. */
1471
+ interface WebhookEndpointDelivery extends WebhookDelivery {
1472
+ event_id: string;
1473
+ event: WebhookDeliveryEvent | null;
1474
+ }
1475
+ type WebhookEndpointDeliveryList = PaginatedResponse<WebhookEndpointDelivery>;
1476
+ /** How many deliveries of an event are in each status. */
1477
+ interface WebhookDeliveryCounts {
1478
+ pending: number;
1479
+ succeeded: number;
1480
+ dead: number;
1481
+ }
1482
+ /** An event of the log. `delivery_counts` is set on the items of a list only. */
1483
+ interface WebhookEvent {
1484
+ id: string;
1485
+ type: string;
1486
+ created_at: string;
1487
+ test: boolean;
1488
+ collection_key: string | null;
1489
+ delivery_counts?: WebhookDeliveryCounts;
1490
+ }
1491
+ type WebhookEventList = PaginatedResponse<WebhookEvent>;
1492
+ /**
1493
+ * One event with its envelope and all its deliveries, oldest first. `envelope` is the
1494
+ * event as a references-only endpoint receives it; the log never returns content.
1495
+ */
1496
+ interface WebhookEventDetail extends WebhookEvent {
1497
+ envelope: Record<string, unknown>;
1498
+ deliveries: WebhookDelivery[];
1499
+ }
1500
+ /**
1501
+ * One try to deliver an event. `response_excerpt` is the first 1 KB of what the
1502
+ * endpoint answered.
1503
+ */
1504
+ interface WebhookAttempt {
1505
+ id: string;
1506
+ delivery_id: string;
1507
+ endpoint: WebhookEndpointRef;
1508
+ created_at: string;
1509
+ status_code: number | null;
1510
+ latency_ms: number;
1511
+ error_class: string | null;
1512
+ response_excerpt: string;
1513
+ }
1514
+ type WebhookAttemptList = PaginatedResponse<WebhookAttempt>;
1515
+ /** The answer to sending a test event. */
1516
+ interface WebhookTestEvent {
1517
+ event_id: string;
1518
+ delivery_id: string;
1519
+ }
1520
+ /**
1521
+ * The answer to recovering failed deliveries: `requeued` were queued, and `more` is
1522
+ * `true` when another call with the same `since` has more to do.
1523
+ */
1524
+ interface WebhookRecovery {
1525
+ requeued: number;
1526
+ more: boolean;
1527
+ }
1528
+ /** A delivery created by redelivering an event. */
1529
+ interface WebhookRedelivery {
1530
+ id: string;
1531
+ endpoint_id: string;
1532
+ }
1533
+ /**
1534
+ * An endpoint an event was not redelivered to. `reason` is `deleted`, `paused`,
1535
+ * `disabled` or `endpoint_not_subscribed`.
1536
+ */
1537
+ interface WebhookSkippedEndpoint {
1538
+ endpoint_id: string;
1539
+ reason: string;
1540
+ }
1541
+ /** The answer to redelivering an event. */
1542
+ interface WebhookRedeliveryResult {
1543
+ event_id: string;
1544
+ deliveries: WebhookRedelivery[];
1545
+ skipped: WebhookSkippedEndpoint[];
1546
+ }
1547
+ /** An event type of the catalogue. `collection_scoped` is true when every event of the type belongs to a collection. */
1548
+ interface WebhookEventType {
1549
+ name: string;
1550
+ description: string;
1551
+ collection_scoped: boolean;
1552
+ /** JSON Schemas (draft 2020-12) of the event's `data` per payload mode. */
1553
+ schemas: {
1554
+ references: Record<string, unknown>;
1555
+ content: Record<string, unknown>;
1556
+ };
1557
+ }
1558
+ /** The event-type catalogue; it is not paginated. */
1559
+ interface WebhookEventTypeList {
1560
+ results: WebhookEventType[];
1561
+ }
1562
+ /** Filters of {@link ManagementClient.listWebhookEvents}. */
1563
+ interface WebhookEventListParams {
1564
+ type?: string;
1565
+ /** An endpoint `id`. */
1566
+ endpoint?: string;
1567
+ status?: 'pending' | 'succeeded' | 'dead';
1568
+ /** `true` for test events only, `false` to leave them out. */
1569
+ test?: boolean;
1570
+ /** ISO 8601; a time without a zone is read as UTC. */
1571
+ after?: string;
1572
+ before?: string;
1573
+ /** At most 200. */
1574
+ limit?: number;
1575
+ offset?: number;
1576
+ }
833
1577
 
834
1578
  interface ManagementClientOptions {
835
1579
  baseUrl?: string;
@@ -886,6 +1630,11 @@ declare class ManagementClient {
886
1630
  listOrganizations(): Promise<OrganizationList>;
887
1631
  getOrganization(orgKey: OrgRef): Promise<OrganizationSummary>;
888
1632
  updateOrganization(orgKey: OrgRef, payload: Record<string, any>): Promise<OrganizationSummary>;
1633
+ /**
1634
+ * Write the given fields of an organization and leave the rest alone. The
1635
+ * response is the whole organization as stored.
1636
+ */
1637
+ patchOrganization(orgKey: OrgRef, payload: Record<string, any>): Promise<OrganizationSummary>;
889
1638
  listRegions(): Promise<RegionInfo[]>;
890
1639
  getAvailablePlans(): Promise<OrganizationPlanStatus>;
891
1640
  getOrganizationPlan(orgKey: OrgRef): Promise<OrganizationPlanStatus>;
@@ -991,6 +1740,14 @@ declare class ManagementClient {
991
1740
  }): Promise<CollectionList>;
992
1741
  createCollection(payload: Record<string, any>): Promise<CollectionSummary>;
993
1742
  updateCollection(collectionKey: CollectionRef, payload: Record<string, any>): Promise<CollectionSummary>;
1743
+ /**
1744
+ * Write the given fields of a collection and leave the rest alone.
1745
+ *
1746
+ * `updateCollection` replaces the whole record; this does not. An omitted
1747
+ * `parent` keeps the collection where it is, and `{ parent: null }` moves it
1748
+ * to the root. The response is the whole collection as stored.
1749
+ */
1750
+ patchCollection(collectionKey: CollectionRef, payload: Record<string, any>): Promise<CollectionSummary>;
994
1751
  deleteCollection(collectionKey: CollectionRef): Promise<void>;
995
1752
  listCollectionVersions(collectionKey: CollectionRef, params?: Record<string, any>): Promise<SchemaVersionList>;
996
1753
  createCollectionVersion(collectionKey: CollectionRef, payload: Record<string, any>, options?: {
@@ -1101,6 +1858,11 @@ declare class ManagementClient {
1101
1858
  getComponent(componentKey: ComponentRef): Promise<ComponentSummary>;
1102
1859
  createComponent(payload: Record<string, any>): Promise<ComponentSummary>;
1103
1860
  updateComponent(componentKey: ComponentRef, payload: Record<string, any>): Promise<ComponentSummary>;
1861
+ /**
1862
+ * Write the given fields of a component and leave the rest alone. The response
1863
+ * is the whole component as stored.
1864
+ */
1865
+ patchComponent(componentKey: ComponentRef, payload: Record<string, any>): Promise<ComponentSummary>;
1104
1866
  deleteComponent(componentKey: ComponentRef): Promise<void>;
1105
1867
  listComponentVersions(componentKey: ComponentRef, params?: Record<string, any>): Promise<SchemaVersionList>;
1106
1868
  createComponentVersion(componentKey: ComponentRef, payload: Record<string, any>, options?: {
@@ -1162,6 +1924,304 @@ declare class ManagementClient {
1162
1924
  protectionReason?: string;
1163
1925
  }): Promise<EnvironmentSummary>;
1164
1926
  clearEnvironmentProtection(orgKey: OrgRef, projectKey: ProjectRef, envKey: EnvironmentRef): Promise<EnvironmentSummary>;
1927
+ /**
1928
+ * List a files collection's upload links, newest first. `params` carries `limit` (at
1929
+ * most 100), `offset` and `state`: `active`, `ended` or `all` (the default).
1930
+ */
1931
+ listUploadLinks(collectionKey: CollectionRef, params?: Record<string, any>): Promise<UploadLinkList>;
1932
+ /**
1933
+ * Create an upload link: a hosted page where an end user adds files.
1934
+ *
1935
+ * The collection must be strict. Works with a user token or a Management API
1936
+ * key of this environment. Read the link back with {@link getUploadLink}; the
1937
+ * Flux upload status answers only the Flux key that started an upload, never
1938
+ * a link made here.
1939
+ *
1940
+ * `upload_url` carries the link's token and is returned only by this call.
1941
+ */
1942
+ createUploadLink(collectionKey: CollectionRef, request: UploadLinkCreateRequest): Promise<UploadLinkCreated>;
1943
+ /** Read one upload link with its sessions and the status of each file. */
1944
+ getUploadLink(collectionKey: CollectionRef, uploadId: string): Promise<UploadLink>;
1945
+ /**
1946
+ * Revoke an upload link. Revoking a revoked link returns the same state. Files
1947
+ * already uploaded through the link are not affected.
1948
+ */
1949
+ revokeUploadLink(collectionKey: CollectionRef, uploadId: string): Promise<UploadLink>;
1950
+ /** Read a record's file: its verdict, the checks that ran and every finding. */
1951
+ getFileAnalysis(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileRecordView>;
1952
+ /**
1953
+ * Release a file held for a reviewer.
1954
+ *
1955
+ * The answer's `outcome` says what happened; a publish that goes back through
1956
+ * processing completes on its own. A file no reviewer holds is
1957
+ * `409 file_not_in_review`, `file_not_ready` or `file_erased`.
1958
+ */
1959
+ approveFile(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileRecordView>;
1960
+ /** Reject a file held for a reviewer. Repeating it returns the same state. */
1961
+ rejectFile(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileRecordView>;
1962
+ /**
1963
+ * Analyze a file again under the collection's live policy.
1964
+ *
1965
+ * Accepted work runs in the background; a published generation keeps serving
1966
+ * until the new one publishes. A `storage_only` collection answers
1967
+ * `409 reanalysis_requires_agent_ready`. This is paid processing: a refusal over
1968
+ * the plan throws {@link FilesQuotaExceededError}, a quota that cannot be read
1969
+ * throws {@link FilesQuotaUnavailableError}, and over a budget is `429`.
1970
+ */
1971
+ reanalyzeFile(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileRecordView>;
1972
+ /**
1973
+ * Get a short-lived link to a record's original file.
1974
+ *
1975
+ * A state that cannot be downloaded now is a `409`: `detail.reason` of the
1976
+ * thrown error names it. Check `warnings` before opening the file.
1977
+ */
1978
+ getFileOriginal(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileDownload>;
1979
+ /**
1980
+ * Get a short-lived link to a record's safe copy. It is an image-only PDF, or a PNG
1981
+ * for an image: read `content_type`.
1982
+ */
1983
+ getFileSafeCopy(collectionKey: CollectionRef, resourceKey: ResourceRef): Promise<FileDownload>;
1984
+ /** Get a short-lived link to the redacted PNG of one page. */
1985
+ getFilePage(collectionKey: CollectionRef, resourceKey: ResourceRef, page: number): Promise<FileDownload>;
1986
+ /**
1987
+ * Read one page: its redacted image, what was withheld, its tables and the
1988
+ * text an agent receives.
1989
+ */
1990
+ getFilePageDetail(collectionKey: CollectionRef, resourceKey: ResourceRef, page: number): Promise<FilePageDetail>;
1991
+ /** List a collection's blocked and rejected files, newest first. */
1992
+ listFileTombstones(collectionKey: CollectionRef, params?: Record<string, any>): Promise<FileTombstoneList>;
1993
+ /** Read a collection's live files policy. */
1994
+ getFilesPolicy(collectionKey: CollectionRef): Promise<FilesPolicy>;
1995
+ /**
1996
+ * Replace a collection's files policy with a new version.
1997
+ *
1998
+ * A full replacement: an omitted field takes its default. Sending the live
1999
+ * body again creates no version.
2000
+ */
2001
+ updateFilesPolicy(collectionKey: CollectionRef, payload: FilesPolicyBody): Promise<FilesPolicy>;
2002
+ /**
2003
+ * List the files held for a reviewer in this environment, newest first.
2004
+ *
2005
+ * `collection` narrows the queue to one collection; one the caller cannot read,
2006
+ * or that does not exist, is an empty page. `params` carries `limit` (at most
2007
+ * 100) and `offset`.
2008
+ */
2009
+ listFileReviewQueue(options?: {
2010
+ collection?: CollectionRef;
2011
+ params?: Record<string, any>;
2012
+ }): Promise<FileReviewQueue>;
2013
+ /**
2014
+ * Read what the authenticated caller may do in this environment.
2015
+ *
2016
+ * Works for a user token and for a Management API key of this environment. A caller
2017
+ * with no grants at all is a `403`; a key of another environment is a
2018
+ * `404 environment_not_found`.
2019
+ */
2020
+ getMyPermissions(): Promise<MyPermissions>;
2021
+ /**
2022
+ * List the environment's webhook endpoints, newest first. Each item carries
2023
+ * `stats_24h`; secrets are never included. `params` carries `status` (`active`,
2024
+ * `paused` or `disabled`), `limit` (at most 200) and `offset`.
2025
+ */
2026
+ listWebhookEndpoints(params?: Record<string, any>): Promise<WebhookEndpointList>;
2027
+ /**
2028
+ * Create a webhook endpoint.
2029
+ *
2030
+ * The answer carries the signing `secret`, which is not enumerable: read it as
2031
+ * `created.secret`, and read it again later with {@link getWebhookEndpointSecret}.
2032
+ * An environment holds at most 20 endpoints ({@link WebhookEndpointLimitExceededError}).
2033
+ * A `content` endpoint also needs read access to the content it will deliver.
2034
+ */
2035
+ createWebhookEndpoint(request: WebhookEndpointCreateRequest): Promise<WebhookEndpointCreated>;
2036
+ /** Read one webhook endpoint. It carries neither the secret nor `stats_24h`. */
2037
+ getWebhookEndpoint(endpointId: string): Promise<WebhookEndpoint>;
2038
+ /**
2039
+ * Change the given fields of an endpoint and leave the rest alone.
2040
+ *
2041
+ * `status: 'active'` resumes a paused or disabled endpoint and clears its failure
2042
+ * streak; events that happened meanwhile are not sent, but failed deliveries can be
2043
+ * sent again with {@link recoverWebhookDeliveries}.
2044
+ */
2045
+ updateWebhookEndpoint(endpointId: string, changes: WebhookEndpointUpdateRequest): Promise<WebhookEndpoint>;
2046
+ /**
2047
+ * Delete an endpoint and its pending deliveries. Its finished deliveries and
2048
+ * attempts stay in the event log for 30 days, with `endpoint.deleted` true.
2049
+ */
2050
+ deleteWebhookEndpoint(endpointId: string): Promise<void>;
2051
+ /**
2052
+ * List an endpoint's deliveries, newest first, each with the event it carries.
2053
+ * `params` carries `limit` (at most 200) and `offset`.
2054
+ */
2055
+ listWebhookEndpointDeliveries(endpointId: string, params?: Record<string, any>): Promise<WebhookEndpointDeliveryList>;
2056
+ /**
2057
+ * Read the endpoint's current signing secret: the newest, during a rotation. Needs
2058
+ * `webhooks:update`. `secret` is not enumerable: read it as `response.secret`.
2059
+ */
2060
+ getWebhookEndpointSecret(endpointId: string): Promise<WebhookSecret>;
2061
+ /**
2062
+ * Create a new signing secret and return it.
2063
+ *
2064
+ * The previous secret stays valid for 24 hours, and deliveries carry a signature for
2065
+ * each valid secret; with `expire_previous_now` it stops at once. Needs
2066
+ * `webhooks:update`. `secret` is not enumerable: read it as `rotation.secret`.
2067
+ */
2068
+ rotateWebhookEndpointSecret(endpointId: string, options?: {
2069
+ expire_previous_now?: boolean;
2070
+ }): Promise<WebhookSecretRotation>;
2071
+ /**
2072
+ * Send a sample event of `eventType` to this endpoint only, with `test` true in the
2073
+ * envelope. It is sent whatever the endpoint's event types and collection filter,
2074
+ * but the endpoint must be active ({@link WebhookEndpointNotActiveError}).
2075
+ */
2076
+ sendWebhookTestEvent(endpointId: string, eventType: string): Promise<WebhookTestEvent>;
2077
+ /**
2078
+ * Send again the endpoint's failed deliveries created at or after `since`.
2079
+ *
2080
+ * Each becomes a new pending delivery of the same event. One call queues at most
2081
+ * 10,000 deliveries; when `more` is true, call again with the same `since`. `since`
2082
+ * is an ISO 8601 time within the last 30 days; a time without a zone is read as UTC.
2083
+ */
2084
+ recoverWebhookDeliveries(endpointId: string, since: string | Date): Promise<WebhookRecovery>;
2085
+ /**
2086
+ * List the events of the last 30 days, newest first, with `delivery_counts`.
2087
+ * `params` carries `type`, `endpoint` (an endpoint `id`), `status` (`pending`,
2088
+ * `succeeded` or `dead`), `test`, `after`, `before` (ISO 8601), `limit` (at most 200)
2089
+ * and `offset`.
2090
+ */
2091
+ listWebhookEvents(params?: WebhookEventListParams): Promise<WebhookEventList>;
2092
+ /** Read one event with its envelope and all its deliveries, oldest first. */
2093
+ getWebhookEvent(eventId: string): Promise<WebhookEventDetail>;
2094
+ /**
2095
+ * List every attempt to deliver the event, across endpoints, oldest first. `params`
2096
+ * carries `limit` (at most 200) and `offset`.
2097
+ */
2098
+ listWebhookEventAttempts(eventId: string, params?: Record<string, any>): Promise<WebhookAttemptList>;
2099
+ /**
2100
+ * Send the event again as a new delivery, with the same event `id`.
2101
+ *
2102
+ * With `endpoint_id` the event goes to that endpoint. Without it, the event goes to
2103
+ * every endpoint that had a delivery of it and is active and subscribed to it now;
2104
+ * the others are listed in `skipped`.
2105
+ */
2106
+ redeliverWebhookEvent(eventId: string, options?: {
2107
+ endpoint_id?: string;
2108
+ }): Promise<WebhookRedeliveryResult>;
2109
+ /** List the event-type catalogue with the JSON Schema of each payload mode. */
2110
+ listWebhookEventTypes(): Promise<WebhookEventTypeList>;
2111
+ private fileRoot;
2112
+ }
2113
+
2114
+ /**
2115
+ * Types and validation for Flux vector search requests.
2116
+ */
2117
+ /** Search mode for the Flux search endpoint. */
2118
+ declare const SearchMode: {
2119
+ readonly TEXT: "text";
2120
+ readonly VECTOR: "vector";
2121
+ readonly VECTOR_BOOSTED: "vector_boosted";
2122
+ readonly HYBRID: "hybrid";
2123
+ };
2124
+ type SearchMode = (typeof SearchMode)[keyof typeof SearchMode];
2125
+ /** Configuration for auto-generated embedding search. */
2126
+ interface VectorSearch {
2127
+ query: string;
2128
+ fields?: string[];
2129
+ top_k?: number;
2130
+ similarity_threshold?: number;
2131
+ }
2132
+ /** Configuration for custom pre-computed embedding search. */
2133
+ interface VectorFieldSearch {
2134
+ field: string;
2135
+ query_vector: number[];
2136
+ top_k?: number;
2137
+ similarity_threshold?: number;
2138
+ }
2139
+ /** Configuration for vector-boosted search mode. */
2140
+ interface VectorBoostConfig {
2141
+ boost_factor?: number;
2142
+ similarity_threshold?: number;
2143
+ max_boost_results?: number;
2144
+ }
2145
+ /** Configuration for hybrid (text + vector) search mode. */
2146
+ interface HybridConfig {
2147
+ vector_weight?: number;
2148
+ text_weight?: number;
2149
+ rerank_results?: boolean;
2150
+ }
2151
+ /** Full search request payload for the Flux search endpoint. */
2152
+ interface SearchRequest {
2153
+ search_mode?: SearchMode;
2154
+ find_text?: Record<string, any>;
2155
+ find_phrase?: Record<string, any>;
2156
+ vector_search?: VectorSearch;
2157
+ vector_field_search?: VectorFieldSearch;
2158
+ vector_boost_config?: VectorBoostConfig;
2159
+ hybrid_config?: HybridConfig;
2160
+ limit?: number;
2161
+ offset?: number;
2162
+ [extra: string]: any;
2163
+ }
2164
+ /**
2165
+ * Validate a {@link SearchRequest} and return a clean body object (no undefined values).
2166
+ *
2167
+ * Enforces cross-field constraints:
2168
+ * - `vector_search` and `vector_field_search` are mutually exclusive
2169
+ * - Each search mode has specific required/forbidden fields
2170
+ */
2171
+ declare function buildSearchBody(req: SearchRequest): Record<string, any>;
2172
+ /**
2173
+ * A grant for one upload to a files collection.
2174
+ *
2175
+ * The grant is a credential. The field names are the wire names, so the object
2176
+ * can go to a browser as it is, and that same object prints every token: keep it
2177
+ * out of logs and error reports.
2178
+ */
2179
+ interface UploadSignature {
2180
+ publicKey: string;
2181
+ /** The upload host. */
2182
+ uploadBaseUrl: string;
2183
+ authToken: string;
2184
+ /** When the token ends, in Unix seconds. */
2185
+ tokenExpire: number;
2186
+ /** Passed to the upload unchanged. */
2187
+ store: string;
2188
+ /** Passed to the upload unchanged. */
2189
+ metadata: Record<string, unknown>;
2190
+ /** The id to poll with {@link FluxClient.getUploadStatus}. */
2191
+ upload_id: string;
2192
+ /** The end user's token for reading the status. */
2193
+ status_token: string;
2194
+ /** The order of status tokens in a session. */
2195
+ rotation: number;
2196
+ }
2197
+ /**
2198
+ * The status of one file of an upload.
2199
+ *
2200
+ * A key sees `state` as `processing`, `ready` (with `record_key`),
2201
+ * `pending_review` or `rejected` (with `public_reason`). A status token sees
2202
+ * `processing`, `accepted` or `rejected`, with `user_status`, `reason` and `slot`.
2203
+ */
2204
+ interface UploadFileStatus {
2205
+ state: string;
2206
+ record_key?: string | null;
2207
+ public_reason?: string;
2208
+ user_status?: string;
2209
+ reason?: string;
2210
+ slot?: number;
2211
+ }
2212
+ /**
2213
+ * The status of an upload.
2214
+ *
2215
+ * For an upload of one file these are that file's fields. For a link of several
2216
+ * files, `state` is `processing` or `done` and `files` and `remaining` are set; a
2217
+ * status token also gets `slots_uploading`.
2218
+ */
2219
+ interface UploadStatus extends UploadFileStatus {
2220
+ files?: UploadFileStatus[];
2221
+ remaining?: number;
2222
+ slots_uploading?: {
2223
+ slot: number;
2224
+ }[];
1165
2225
  }
1166
2226
 
1167
2227
  interface FluxClientOptions {
@@ -1278,6 +2338,36 @@ declare class FluxClient {
1278
2338
  * is never retried automatically.
1279
2339
  */
1280
2340
  updateResource<T = any>(folderPath: string, resourceKey: string, data: Record<string, any>): Promise<T>;
2341
+ /**
2342
+ * Get a grant for one upload to a files collection.
2343
+ *
2344
+ * The grant is a credential: pass it on, do not log it. For a strict collection
2345
+ * `folderPath` names the owner, e.g. `support/tickets/tk_1/attachments`. Needs a
2346
+ * key with create access to the collection.
2347
+ *
2348
+ * `options.sessionKey` is an optional idempotency key of 43 URL-safe characters:
2349
+ * a repeat with the same key, collection and owner reaches the same upload
2350
+ * session. A failed request is never retried automatically, so send one to
2351
+ * retry safely.
2352
+ */
2353
+ createUploadSignature(folderPath: string, options?: {
2354
+ sessionKey?: string;
2355
+ }): Promise<UploadSignature>;
2356
+ /**
2357
+ * Read the status of an upload.
2358
+ *
2359
+ * A key reads the uploads that key started, and the path must name the same
2360
+ * collection and owner. Any other combination is `404 not_found`, which includes
2361
+ * a link made through the Management API: read that one with
2362
+ * `ManagementClient.getUploadLink`.
2363
+ *
2364
+ * `options.statusToken` is the end user's token from the grant, for a client that
2365
+ * holds no key (use `AnonymousAuth`). It answers the end user's view, which never
2366
+ * carries a record key. A request authenticated by a key ignores it.
2367
+ */
2368
+ getUploadStatus(folderPath: string, uploadId: string, options?: {
2369
+ statusToken?: string;
2370
+ }): Promise<UploadStatus>;
1281
2371
  /** Semantic search using auto-generated embeddings. */
1282
2372
  vectorSearch<T = any>(folderPath: string, options: VectorSearchOptions): Promise<T>;
1283
2373
  /** Search using custom pre-computed embeddings. */
@@ -1291,63 +2381,4 @@ declare class FluxClient {
1291
2381
  close(): void;
1292
2382
  }
1293
2383
 
1294
- /**
1295
- * Types and validation for Flux vector search requests.
1296
- */
1297
- /** Search mode for the Flux search endpoint. */
1298
- declare const SearchMode: {
1299
- readonly TEXT: "text";
1300
- readonly VECTOR: "vector";
1301
- readonly VECTOR_BOOSTED: "vector_boosted";
1302
- readonly HYBRID: "hybrid";
1303
- };
1304
- type SearchMode = (typeof SearchMode)[keyof typeof SearchMode];
1305
- /** Configuration for auto-generated embedding search. */
1306
- interface VectorSearch {
1307
- query: string;
1308
- fields?: string[];
1309
- top_k?: number;
1310
- similarity_threshold?: number;
1311
- }
1312
- /** Configuration for custom pre-computed embedding search. */
1313
- interface VectorFieldSearch {
1314
- field: string;
1315
- query_vector: number[];
1316
- top_k?: number;
1317
- similarity_threshold?: number;
1318
- }
1319
- /** Configuration for vector-boosted search mode. */
1320
- interface VectorBoostConfig {
1321
- boost_factor?: number;
1322
- similarity_threshold?: number;
1323
- max_boost_results?: number;
1324
- }
1325
- /** Configuration for hybrid (text + vector) search mode. */
1326
- interface HybridConfig {
1327
- vector_weight?: number;
1328
- text_weight?: number;
1329
- rerank_results?: boolean;
1330
- }
1331
- /** Full search request payload for the Flux search endpoint. */
1332
- interface SearchRequest {
1333
- search_mode?: SearchMode;
1334
- find_text?: Record<string, any>;
1335
- find_phrase?: Record<string, any>;
1336
- vector_search?: VectorSearch;
1337
- vector_field_search?: VectorFieldSearch;
1338
- vector_boost_config?: VectorBoostConfig;
1339
- hybrid_config?: HybridConfig;
1340
- limit?: number;
1341
- offset?: number;
1342
- [extra: string]: any;
1343
- }
1344
- /**
1345
- * Validate a {@link SearchRequest} and return a clean body object (no undefined values).
1346
- *
1347
- * Enforces cross-field constraints:
1348
- * - `vector_search` and `vector_field_search` are mutually exclusive
1349
- * - Each search mode has specific required/forbidden fields
1350
- */
1351
- declare function buildSearchBody(req: SearchRequest): Record<string, any>;
1352
-
1353
- export { type APICollectionList, type APICollectionSummary, type APIFolderList, type APIFolderSummary, type APIInfo, type APIList, type APIRef, AnonymousAuth, type ApiFolderOptions, type ApiFolderRouteDescriptionOptions, type AuthStrategy, type BatchItemError, type BatchUpsertItem, type BatchUpsertResult, type BoostedSearchOptions, type CollectionList, CollectionNotWritableError, type CollectionRef, type CollectionSummary, type ComponentList, type ComponentRef, type ComponentSummary, type ComponentSyncConflictDetail, ContentValidationFailedError, type CurrentUsage, DEFAULT_RETRY_CONFIG, DEFAULT_USER_AGENT, type EnvironmentList, type EnvironmentRef, type EnvironmentSummary, ExternalIdConflictError, type FieldList, type FieldSummary, type FlatRoute, type FlatRouteSummary, type FluxAPIKeyBearerToken, type FluxAPIKeyList, type FluxAPIKeyRef, type FluxAPIKeySummary, FluxClient, type FluxClientOptions, type FluxRoleList, type FluxRoleRef, type FluxRoleSummary, type FolderList, type FolderRef, type FolderSummary, FoxnoseAPIError, FoxnoseAuthError, type FoxnoseConfig, FoxnoseError, FoxnoseTransportError, HttpTransport, type HybridConfig, type HybridSearchOptions, JWTAuth, type LocaleList, type LocaleSummary, type ManagementAPIKeyList, type ManagementAPIKeyRef, type ManagementAPIKeySummary, ManagementClient, type ManagementClientOptions, type ManagementRoleList, type ManagementRoleRef, type ManagementRoleSummary, type NestedFieldMeta, type OrgRef, type OrganizationList, type OrganizationOwner, type OrganizationPlanStatus, type OrganizationSummary, type OrganizationUsage, type PaginatedResponse, type PlanDetails, PlanExhaustedError, PlanLimitExceededError, type PlanLimits, type ProjectList, type ProjectRef, type ProjectSummary, RateLimitExceededError, type RegionInfo, type RequestData, type ResourceList, type ResourceRef, type ResourceSummary, type RetryConfig, type RevisionList, type RevisionRef, type RevisionSummary, type RolePermission, type RolePermissionObject, SDK_VERSION, type SchemaVersionList, type SchemaVersionRef, type SchemaVersionSummary, SearchMode, type SearchRequest, SecureKeyAuth, SimpleKeyAuth, SpendCapExceededError, StaticTokenProvider, type StorageUsage, type SyncComponentResponse, type SyncComponentSkippedItem, type TokenProvider, type UnitsUsage, UpstreamError, type UsageBreakdown, type UsageMetric, type UserReference, SDK_VERSION as VERSION, type VectorBoostConfig, type VectorFieldSearch, type VectorFieldSearchOptions, type VectorSearch, type VectorSearchOptions, buildSearchBody, createConfig, nestedFieldMeta, resolveKey };
2384
+ export { type APICollectionList, type APICollectionSummary, type APIFolderList, type APIFolderSummary, type APIInfo, type APIList, type APIRef, AnonymousAuth, type ApiFolderOptions, type ApiFolderRouteDescriptionOptions, type AuthStrategy, type BatchItemError, type BatchUpsertItem, type BatchUpsertResult, type BoostedSearchOptions, type CollectionList, CollectionNotWritableError, type CollectionRef, type CollectionSummary, type ComponentList, type ComponentRef, type ComponentSummary, type ComponentSyncConflictDetail, type ContentTypeAccess, ContentValidationFailedError, type CurrentUsage, DEFAULT_RETRY_CONFIG, DEFAULT_USER_AGENT, type EnvironmentAccess, type EnvironmentList, type EnvironmentRef, type EnvironmentSummary, ExternalIdConflictError, type FieldList, type FieldSummary, type FileActiveContent, type FileAnalysis, type FileCheck, type FileCopyAvailability, type FileDownload, type FileDownloadOptions, type FileEvidencePart, type FileFinding, type FileFindingGroup, type FileFindingsSummary, type FileInfo, type FileKind, type FileOrigin, type FileOriginActor, type FileOriginLink, type FilePageDetail, type FilePageFinding, type FilePagePii, type FilePageRedaction, type FilePageTable, type FileRecordOwner, type FileRecordView, type FileReviewItem, type FileReviewQueue, type FileSummary, type FileTextEvidence, type FileTombstone, type FileTombstoneList, type FileTrust, type FilesPolicy, type FilesPolicyBody, FilesQuotaExceededError, FilesQuotaUnavailableError, type FlatRoute, type FlatRouteSummary, type FluxAPIKeyBearerToken, type FluxAPIKeyList, type FluxAPIKeyRef, type FluxAPIKeySummary, FluxClient, type FluxClientOptions, type FluxRoleList, type FluxRoleRef, type FluxRoleSummary, type FolderList, type FolderRef, type FolderSummary, FoxnoseAPIError, FoxnoseAuthError, type FoxnoseConfig, FoxnoseError, FoxnoseTransportError, HttpTransport, type HybridConfig, type HybridSearchOptions, JWTAuth, type LocaleList, type LocaleSummary, type ManagementAPIKeyList, type ManagementAPIKeyRef, type ManagementAPIKeySummary, ManagementClient, type ManagementClientOptions, type ManagementRoleList, type ManagementRoleRef, type ManagementRoleSummary, type MyPermissions, type NestedFieldMeta, type OrgRef, type OrganizationList, type OrganizationOwner, type OrganizationPlanStatus, type OrganizationSummary, type OrganizationUsage, type PaginatedResponse, type PlanDetails, PlanExhaustedError, PlanLimitExceededError, type PlanLimits, type ProjectList, type ProjectRef, type ProjectSummary, RateLimitExceededError, type RegionInfo, type RequestData, type ResourceList, type ResourceRef, type ResourceSummary, type RetryConfig, type RevisionList, type RevisionRef, type RevisionSummary, type RolePermission, type RolePermissionObject, SDK_VERSION, type SchemaVersionList, type SchemaVersionRef, type SchemaVersionSummary, SearchMode, type SearchRequest, SecureKeyAuth, SimpleKeyAuth, SpendCapExceededError, StaticTokenProvider, type StorageUsage, type SyncComponentResponse, type SyncComponentSkippedItem, type TokenProvider, type UnitsUsage, type UploadFileProgress, type UploadFileStatus, type UploadLink, type UploadLinkCreateRequest, type UploadLinkCreated, type UploadLinkCreator, type UploadLinkFile, type UploadLinkList, type UploadLinkSession, type UploadSignature, type UploadStatus, UpstreamError, type UsageBreakdown, type UsageMetric, type UserReference, SDK_VERSION as VERSION, type VectorBoostConfig, type VectorFieldSearch, type VectorFieldSearchOptions, type VectorSearch, type VectorSearchOptions, type WebhookAttempt, type WebhookAttemptList, type WebhookDelivery, type WebhookDeliveryCounts, type WebhookDeliveryEvent, type WebhookEndpoint, type WebhookEndpointCreateRequest, type WebhookEndpointCreated, type WebhookEndpointDelivery, type WebhookEndpointDeliveryList, WebhookEndpointLimitExceededError, type WebhookEndpointList, WebhookEndpointNotActiveError, WebhookEndpointNotFoundError, WebhookEndpointNotSubscribedError, type WebhookEndpointRef, type WebhookEndpointStatus, type WebhookEndpointUpdateRequest, type WebhookEvent, type WebhookEventDetail, type WebhookEventList, type WebhookEventListParams, WebhookEventNotFoundError, type WebhookEventType, type WebhookEventTypeList, type WebhookPayloadMode, type WebhookRecovery, type WebhookRedelivery, type WebhookRedeliveryResult, type WebhookSecret, type WebhookSecretRotation, type WebhookSkippedEndpoint, type WebhookStats24h, type WebhookTestEvent, buildSearchBody, createConfig, nestedFieldMeta, parseFindingEvidence, resolveKey };