@foxnose/sdk 0.6.1 → 0.7.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/README.md CHANGED
@@ -14,6 +14,7 @@ Official TypeScript SDK for the [FoxNose](https://foxnose.net/?utm_source=github
14
14
  - **Automatic retries** with exponential backoff and Retry-After support
15
15
  - **Four auth strategies** — Anonymous, JWT, Simple key, and Secure (ECDSA P-256)
16
16
  - **Flux introspection** — discover route contracts with `/_router` and `/_schema`
17
+ - **FoxNose Files** — upload links, analysis, review, policy and short-lived downloads
17
18
  - **Zero dependencies** — uses only Node.js built-in modules
18
19
  - **Dual output** — ESM and CommonJS builds with full `.d.ts` declarations
19
20
 
@@ -318,6 +319,110 @@ await managementClient.addApiFolder(api.key, folder.key, {
318
319
  });
319
320
  ```
320
321
 
322
+ ## Files
323
+
324
+ FoxNose Files takes uploads from end users and processes them for agents. Upload links and review run through the Management client.
325
+
326
+ ```typescript
327
+ // A hosted page for an end user. The collection must be strict, and `owner` is
328
+ // the parent record. Works with a user token or a Management API key.
329
+ const link = await client.createUploadLink('attachments', {
330
+ owner: 'tk_8f2c91',
331
+ title: 'Upload your documents',
332
+ max_files: 3,
333
+ });
334
+ sendToUser(link.upload_url); // returned once; no later read reproduces it
335
+
336
+ // Read the link back through the Management API.
337
+ const current = await client.getUploadLink('attachments', link.upload_id);
338
+ const files = current.sessions.flatMap((session) => session.files);
339
+ const recordKey = files.find((file) => file.state === 'ready')?.record_key;
340
+
341
+ // The record's verdict, checks and findings.
342
+ const view = await client.getFileAnalysis('attachments', recordKey!);
343
+
344
+ // A download is a short-lived link. It is returned, never streamed.
345
+ const safeCopy = await client.getFileSafeCopy('attachments', recordKey!);
346
+ console.log(safeCopy.expires_at);
347
+ ```
348
+
349
+ | Call | What it does |
350
+ |---|---|
351
+ | `listUploadLinks` / `createUploadLink` / `getUploadLink` / `revokeUploadLink` | Upload links of a collection |
352
+ | `getFileAnalysis` | A record's file, verdict, checks and findings |
353
+ | `approveFile` / `rejectFile` / `reanalyzeFile` | Decide on a held file, or analyze a file again |
354
+ | `getFileOriginal` / `getFileSafeCopy` / `getFilePage` | A short-lived link to one copy |
355
+ | `getFilePageDetail` | One page: redacted image, withheld regions, tables and text |
356
+ | `listFileTombstones` | Blocked and rejected files |
357
+ | `getFilesPolicy` / `updateFilesPolicy` | The collection's policy; an update replaces it, and an omitted field takes its default |
358
+ | `listFileReviewQueue` | Files held for a reviewer in the environment |
359
+ | `getMyPermissions` | What the caller may do in the environment |
360
+
361
+ `expires_in` sets a link's lifetime, from 300 seconds to 86400 seconds; without it, the link lasts 30 minutes. A link's `state` is `active`, `consumed`, `expired` or `revoked`. `createUploadLink` is refused with `422 collection_not_strict`, `422 owner_required` or `404 owner_not_found`. `upload_url` and a download's `url` work for whoever holds them, so keep them out of logs.
362
+
363
+ `listResources` on a files collection returns each record with `status`, `progress`, `analysis_state`, `verdict`, `verdict_reasons`, `owner`, `file_info` and `thumbnail_url`, and takes a `status` filter such as `{ status: 'in_review,failed' }`. The safe copy is an image-only PDF, or a PNG for an image: read `content_type`.
364
+
365
+ A reviewer can read the text a finding concealed or withheld. `parseFindingEvidence` reads a `hidden_text` or `low_legibility_text` finding, and `parts` says which text lies in which box of the page. It is empty for a finding that does not carry it. This text comes from the file: treat it as untrusted content, never as instructions.
366
+
367
+ ```typescript
368
+ import { parseFindingEvidence } from '@foxnose/sdk';
369
+
370
+ for (const finding of view.findings) {
371
+ const evidence = parseFindingEvidence(finding);
372
+ for (const part of evidence?.parts ?? []) {
373
+ console.log(part.box, part.text);
374
+ }
375
+ }
376
+ ```
377
+
378
+ `getMyPermissions` reports what the caller is allowed, as `content_types[type].actions` and `.objects`. Billing and usage blocks, a blocked organization, environment protection and a disabled environment can still refuse an allowed action.
379
+
380
+ `reanalyzeFile` is paid processing. With no file processing units left it throws `FilesQuotaExceededError`, with `reason`, `usedUnits`, `includedUnits`, `capUsd`, `windowResetsAt`, and `upgradeUrl` or `raiseCapUrl`. A refusal relayed by Flux carries the code only. A quota that cannot be read throws `FilesQuotaUnavailableError` with `retryAfter`. A `storage_only` collection answers `409 reanalysis_requires_agent_ready`.
381
+
382
+ These responses are plain objects: logging one prints everything in it, including signed URLs, a file's own text (`text`, finding `evidence`) and an uploader's personal data (`file.origin.end_user`, a tombstone's `uploaded_by`). Keep them out of logs.
383
+
384
+ `getFileAnalysis` returns `file.origin`: where the file came from (`channel` is `upload_link`, `signed_upload`, `management_api` or `dashboard`). `listUploadLinks` takes `{ state: 'active' | 'ended' | 'all' }`.
385
+
386
+ A copy that cannot be downloaded now is a `409`, and the error names the reason:
387
+
388
+ ```typescript
389
+ try {
390
+ await client.getFileOriginal('attachments', recordKey);
391
+ } catch (err) {
392
+ if (err instanceof FoxnoseAPIError && err.statusCode === 409) {
393
+ console.error((err.detail as { reason: string }).reason);
394
+ }
395
+ }
396
+ ```
397
+
398
+ ### File uploads on Flux
399
+
400
+ On the Flux client, a key takes a grant for one upload and polls it. For a strict collection, the path names the owner.
401
+
402
+ ```typescript
403
+ const path = 'tickets/tk_8f2c91/attachments';
404
+
405
+ const grant = await flux.createUploadSignature(path);
406
+ const status = await flux.getUploadStatus(path, grant.upload_id);
407
+
408
+ if (status.state === 'ready') {
409
+ const resource = await flux.getResource(path, status.record_key!);
410
+ }
411
+ ```
412
+
413
+ The grant's fields keep their wire names, so it can go to a browser as it is. Upload the file with an Uploadcare upload client pointed at `uploadBaseUrl`, with `publicKey`, `authToken`, `store` and `metadata` unchanged.
414
+
415
+ The grant is a credential: the SDK never logs it, and it should stay out of your logs too. `createUploadSignature` is not resent automatically. To retry one safely, send `{ sessionKey }`, an idempotency key of 43 URL-safe characters: a repeat with the same key, collection and owner reaches the same upload session.
416
+
417
+ A key reads only the uploads that key started, through a path that names the same collection and owner. Any other combination is `404 not_found`, which includes a link made through the Management API: read that one with `getUploadLink`.
418
+
419
+ A client with no key reads the end user's view with `status_token`. It never carries a record key:
420
+
421
+ ```typescript
422
+ const flux = new FluxClient({ baseUrl, apiPrefix: 'support', auth: new AnonymousAuth() });
423
+ const status = await flux.getUploadStatus(path, uploadId, { statusToken });
424
+ ```
425
+
321
426
  ## Authentication
322
427
 
323
428
  The SDK supports four authentication strategies:
package/dist/index.cjs CHANGED
@@ -26,6 +26,8 @@ __export(index_exports, {
26
26
  DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
27
27
  DEFAULT_USER_AGENT: () => DEFAULT_USER_AGENT,
28
28
  ExternalIdConflictError: () => ExternalIdConflictError,
29
+ FilesQuotaExceededError: () => FilesQuotaExceededError,
30
+ FilesQuotaUnavailableError: () => FilesQuotaUnavailableError,
29
31
  FluxClient: () => FluxClient,
30
32
  FoxnoseAPIError: () => FoxnoseAPIError,
31
33
  FoxnoseAuthError: () => FoxnoseAuthError,
@@ -48,6 +50,7 @@ __export(index_exports, {
48
50
  buildSearchBody: () => buildSearchBody,
49
51
  createConfig: () => createConfig,
50
52
  nestedFieldMeta: () => nestedFieldMeta,
53
+ parseFindingEvidence: () => parseFindingEvidence,
51
54
  resolveKey: () => resolveKey
52
55
  });
53
56
  module.exports = __toCommonJS(index_exports);
@@ -147,6 +150,36 @@ var PlanExhaustedError = class extends FoxnoseAPIError {
147
150
  this.upgradeUrl = options.upgradeUrl;
148
151
  }
149
152
  };
153
+ var FilesQuotaExceededError = class extends FoxnoseAPIError {
154
+ axis;
155
+ reason;
156
+ usedUnits;
157
+ includedUnits;
158
+ capUsd;
159
+ windowResetsAt;
160
+ upgradeUrl;
161
+ raiseCapUrl;
162
+ constructor(options) {
163
+ super(options);
164
+ this.name = "FilesQuotaExceededError";
165
+ this.axis = options.axis;
166
+ this.reason = options.reason;
167
+ this.usedUnits = options.usedUnits;
168
+ this.includedUnits = options.includedUnits;
169
+ this.capUsd = options.capUsd;
170
+ this.windowResetsAt = options.windowResetsAt;
171
+ this.upgradeUrl = options.upgradeUrl;
172
+ this.raiseCapUrl = options.raiseCapUrl;
173
+ }
174
+ };
175
+ var FilesQuotaUnavailableError = class extends FoxnoseAPIError {
176
+ retryAfter;
177
+ constructor(options) {
178
+ super(options);
179
+ this.name = "FilesQuotaUnavailableError";
180
+ this.retryAfter = options.retryAfter;
181
+ }
182
+ };
150
183
  var PlanLimitExceededError = class extends FoxnoseAPIError {
151
184
  /** Entity whose limit was exceeded (e.g. collections, environments, api_keys). */
152
185
  entity;
@@ -219,6 +252,11 @@ function getHeader(headers, name) {
219
252
  }
220
253
  return void 0;
221
254
  }
255
+ function retryAfterSeconds(headers) {
256
+ const raw = getHeader(headers, "Retry-After");
257
+ const parsed = raw !== void 0 ? Number(raw) : NaN;
258
+ return Number.isNaN(parsed) ? void 0 : parsed;
259
+ }
222
260
  var CONTENT_VALIDATION_CODES = /* @__PURE__ */ new Set(["content_validation_failed", "data_validation_error"]);
223
261
  function buildAPIError(options) {
224
262
  const { statusCode, errorCode, detail, responseHeaders, responseBody } = options;
@@ -241,6 +279,29 @@ function buildAPIError(options) {
241
279
  upgradeUrl: typeof body.upgrade_url === "string" ? body.upgrade_url : void 0
242
280
  });
243
281
  }
282
+ if (statusCode === 402 && errorCode === "files_quota_exceeded" && body) {
283
+ const numberOrNull = (value) => typeof value === "number" ? value : value === null ? null : void 0;
284
+ const text = (value) => typeof value === "string" ? value : void 0;
285
+ return new FilesQuotaExceededError({
286
+ ...options,
287
+ message: "message" in body ? options.message : "File processing quota reached",
288
+ axis: text(body.axis),
289
+ reason: text(body.reason),
290
+ usedUnits: typeof body.used_units === "number" ? body.used_units : void 0,
291
+ includedUnits: numberOrNull(body.included_units),
292
+ capUsd: numberOrNull(body.cap_usd),
293
+ windowResetsAt: body.window_resets_at === null ? null : text(body.window_resets_at),
294
+ upgradeUrl: text(body.upgrade_url),
295
+ raiseCapUrl: text(body.raise_cap_url)
296
+ });
297
+ }
298
+ if (statusCode === 503 && errorCode === "files_quota_unavailable") {
299
+ return new FilesQuotaUnavailableError({
300
+ ...options,
301
+ message: body && "message" in body ? options.message : "File processing quota is unavailable",
302
+ retryAfter: retryAfterSeconds(responseHeaders)
303
+ });
304
+ }
244
305
  if (statusCode === 403 && errorCode === "plan_limit_exceeded") {
245
306
  const d = isPlainObject(detail) ? detail : {};
246
307
  return new PlanLimitExceededError({
@@ -252,11 +313,9 @@ function buildAPIError(options) {
252
313
  });
253
314
  }
254
315
  if (statusCode === 429 && errorCode === "rate_limited") {
255
- const raw = getHeader(responseHeaders, "Retry-After");
256
- const parsed = raw !== void 0 ? Number(raw) : NaN;
257
316
  return new RateLimitExceededError({
258
317
  ...options,
259
- retryAfter: Number.isNaN(parsed) ? void 0 : parsed
318
+ retryAfter: retryAfterSeconds(responseHeaders)
260
319
  });
261
320
  }
262
321
  if (statusCode === 403 && errorCode === "collection_not_writable") {
@@ -363,7 +422,7 @@ var DEFAULT_RETRY_CONFIG = {
363
422
  statusCodes: [408, 425, 429, 500, 502, 503, 504],
364
423
  methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
365
424
  };
366
- var SDK_VERSION = "0.6.1";
425
+ var SDK_VERSION = "0.7.0";
367
426
  var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
368
427
  function createConfig(options) {
369
428
  if (!options.baseUrl) {
@@ -547,7 +606,7 @@ var HttpTransport = class {
547
606
  body = payload;
548
607
  if (payload && typeof payload === "object" && !Array.isArray(payload)) {
549
608
  message = payload.message ?? message;
550
- errorCode = payload.error_code;
609
+ errorCode = payload.error_code ?? payload.code;
551
610
  detail = payload.detail;
552
611
  }
553
612
  } catch {
@@ -604,6 +663,26 @@ function nestedFieldMeta(opts) {
604
663
  auto_update: opts.autoUpdate ?? false
605
664
  };
606
665
  }
666
+ var TEXT_EVIDENCE_KINDS = /* @__PURE__ */ new Set(["hidden_text", "low_legibility_text"]);
667
+ function parseFindingEvidence(finding) {
668
+ if (!TEXT_EVIDENCE_KINDS.has(finding.kind) || !finding.evidence) {
669
+ return null;
670
+ }
671
+ let fields;
672
+ try {
673
+ fields = JSON.parse(finding.evidence);
674
+ } catch {
675
+ return null;
676
+ }
677
+ if (typeof fields !== "object" || fields === null || Array.isArray(fields)) {
678
+ return null;
679
+ }
680
+ const { parts } = fields;
681
+ if (parts !== void 0 && !Array.isArray(parts)) {
682
+ return null;
683
+ }
684
+ return { ...fields, parts: parts ?? [] };
685
+ }
607
686
  function resolveKey(value) {
608
687
  if (typeof value === "string") {
609
688
  return value;
@@ -643,6 +722,15 @@ function managementPaths(environmentKey) {
643
722
  // Resource paths
644
723
  resourceBase: (folderKey) => `/v1/${environmentKey}/folders/${folderKey}/resources`,
645
724
  revisionBase: (folderKey, resourceKey) => `/v1/${environmentKey}/folders/${folderKey}/resources/${resourceKey}/revisions`,
725
+ // Files paths
726
+ uploadLinksRoot: (collectionKey) => `/v1/${environmentKey}/collections/${collectionKey}/upload-links`,
727
+ uploadLinkRoot: (collectionKey, uploadId) => `/v1/${environmentKey}/collections/${collectionKey}/upload-links/${encodeURIComponent(uploadId)}`,
728
+ fileRoot: (collectionKey, resourceKey) => `/v1/${environmentKey}/collections/${collectionKey}/files/${resourceKey}`,
729
+ fileTombstonesRoot: (collectionKey) => `/v1/${environmentKey}/collections/${collectionKey}/files/tombstones`,
730
+ filesPolicyRoot: (collectionKey) => `/v1/${environmentKey}/collections/${collectionKey}/files-policy`,
731
+ filesReviewRoot: () => `/v1/${environmentKey}/files/review`,
732
+ // Caller's own permissions
733
+ myPermissionsRoot: () => `/v1/${environmentKey}/permissions/me`,
646
734
  // Management API key paths
647
735
  managementApiKeysRoot: () => `/v1/${environmentKey}/permissions/management-api/api-keys`,
648
736
  managementApiKeyRoot: (apiKey) => `/v1/${environmentKey}/permissions/management-api/api-keys/${apiKey}`,
@@ -751,6 +839,14 @@ var ManagementClient = class {
751
839
  const key = resolveKey(orgKey);
752
840
  return this.request("PUT", `${this.paths.orgRoot(key)}/`, { jsonBody: payload });
753
841
  }
842
+ /**
843
+ * Write the given fields of an organization and leave the rest alone. The
844
+ * response is the whole organization as stored.
845
+ */
846
+ async patchOrganization(orgKey, payload) {
847
+ const key = resolveKey(orgKey);
848
+ return this.request("PATCH", `${this.paths.orgRoot(key)}/`, { jsonBody: payload });
849
+ }
754
850
  async listRegions() {
755
851
  const payload = await this.request("GET", "/regions/") ?? [];
756
852
  return Array.isArray(payload) ? payload : [payload];
@@ -1165,6 +1261,20 @@ var ManagementClient = class {
1165
1261
  jsonBody: payload
1166
1262
  });
1167
1263
  }
1264
+ /**
1265
+ * Write the given fields of a collection and leave the rest alone.
1266
+ *
1267
+ * `updateCollection` replaces the whole record; this does not. An omitted
1268
+ * `parent` keeps the collection where it is, and `{ parent: null }` moves it
1269
+ * to the root. The response is the whole collection as stored.
1270
+ */
1271
+ async patchCollection(collectionKey, payload) {
1272
+ const key = resolveKey(collectionKey);
1273
+ return this.request("PATCH", `${this.paths.collectionsTreeItem()}/`, {
1274
+ params: { key },
1275
+ jsonBody: payload
1276
+ });
1277
+ }
1168
1278
  async deleteCollection(collectionKey) {
1169
1279
  const key = resolveKey(collectionKey);
1170
1280
  await this.request("DELETE", `${this.paths.collectionsTreeItem()}/`, {
@@ -1502,6 +1612,14 @@ var ManagementClient = class {
1502
1612
  const key = resolveKey(componentKey);
1503
1613
  return this.request("PUT", `${this.paths.componentRoot(key)}/`, { jsonBody: payload });
1504
1614
  }
1615
+ /**
1616
+ * Write the given fields of a component and leave the rest alone. The response
1617
+ * is the whole component as stored.
1618
+ */
1619
+ async patchComponent(componentKey, payload) {
1620
+ const key = resolveKey(componentKey);
1621
+ return this.request("PATCH", `${this.paths.componentRoot(key)}/`, { jsonBody: payload });
1622
+ }
1505
1623
  async deleteComponent(componentKey) {
1506
1624
  const key = resolveKey(componentKey);
1507
1625
  await this.request("DELETE", `${this.paths.componentRoot(key)}/`, { parseJson: false });
@@ -1887,6 +2005,159 @@ var ManagementClient = class {
1887
2005
  protectionLevel: "none"
1888
2006
  });
1889
2007
  }
2008
+ // ------------------------------------------------------------------ //
2009
+ // Files
2010
+ // ------------------------------------------------------------------ //
2011
+ /**
2012
+ * List a files collection's upload links, newest first. `params` carries `limit` (at
2013
+ * most 100), `offset` and `state`: `active`, `ended` or `all` (the default).
2014
+ */
2015
+ async listUploadLinks(collectionKey, params) {
2016
+ const key = resolveKey(collectionKey);
2017
+ return this.request("GET", `${this.paths.uploadLinksRoot(key)}/`, { params });
2018
+ }
2019
+ /**
2020
+ * Create an upload link: a hosted page where an end user adds files.
2021
+ *
2022
+ * The collection must be strict. Works with a user token or a Management API
2023
+ * key of this environment. Read the link back with {@link getUploadLink}; the
2024
+ * Flux upload status answers only the Flux key that started an upload, never
2025
+ * a link made here.
2026
+ *
2027
+ * `upload_url` carries the link's token and is returned only by this call.
2028
+ */
2029
+ async createUploadLink(collectionKey, request) {
2030
+ const key = resolveKey(collectionKey);
2031
+ return this.transport.request("POST", `${this.paths.uploadLinksRoot(key)}/`, {
2032
+ jsonBody: { ...request, owner: resolveKey(request.owner) },
2033
+ allowRetries: false
2034
+ });
2035
+ }
2036
+ /** Read one upload link with its sessions and the status of each file. */
2037
+ async getUploadLink(collectionKey, uploadId) {
2038
+ const key = resolveKey(collectionKey);
2039
+ return this.request("GET", `${this.paths.uploadLinkRoot(key, uploadId)}/`);
2040
+ }
2041
+ /**
2042
+ * Revoke an upload link. Revoking a revoked link returns the same state. Files
2043
+ * already uploaded through the link are not affected.
2044
+ */
2045
+ async revokeUploadLink(collectionKey, uploadId) {
2046
+ const key = resolveKey(collectionKey);
2047
+ return this.request("POST", `${this.paths.uploadLinkRoot(key, uploadId)}/revoke/`);
2048
+ }
2049
+ /** Read a record's file: its verdict, the checks that ran and every finding. */
2050
+ async getFileAnalysis(collectionKey, resourceKey) {
2051
+ const root = this.fileRoot(collectionKey, resourceKey);
2052
+ return this.request("GET", `${root}/analysis/`);
2053
+ }
2054
+ /**
2055
+ * Release a file held for a reviewer.
2056
+ *
2057
+ * The answer's `outcome` says what happened; a publish that goes back through
2058
+ * processing completes on its own. A file no reviewer holds is
2059
+ * `409 file_not_in_review`, `file_not_ready` or `file_erased`.
2060
+ */
2061
+ async approveFile(collectionKey, resourceKey) {
2062
+ const root = this.fileRoot(collectionKey, resourceKey);
2063
+ return this.transport.request("POST", `${root}/approve/`, { allowRetries: false });
2064
+ }
2065
+ /** Reject a file held for a reviewer. Repeating it returns the same state. */
2066
+ async rejectFile(collectionKey, resourceKey) {
2067
+ const root = this.fileRoot(collectionKey, resourceKey);
2068
+ return this.request("POST", `${root}/reject/`);
2069
+ }
2070
+ /**
2071
+ * Analyze a file again under the collection's live policy.
2072
+ *
2073
+ * Accepted work runs in the background; a published generation keeps serving
2074
+ * until the new one publishes. A `storage_only` collection answers
2075
+ * `409 reanalysis_requires_agent_ready`. This is paid processing: a refusal over
2076
+ * the plan throws {@link FilesQuotaExceededError}, a quota that cannot be read
2077
+ * throws {@link FilesQuotaUnavailableError}, and over a budget is `429`.
2078
+ */
2079
+ async reanalyzeFile(collectionKey, resourceKey) {
2080
+ const root = this.fileRoot(collectionKey, resourceKey);
2081
+ return this.transport.request("POST", `${root}/reanalyze/`, { allowRetries: false });
2082
+ }
2083
+ /**
2084
+ * Get a short-lived link to a record's original file.
2085
+ *
2086
+ * A state that cannot be downloaded now is a `409`: `detail.reason` of the
2087
+ * thrown error names it. Check `warnings` before opening the file.
2088
+ */
2089
+ async getFileOriginal(collectionKey, resourceKey) {
2090
+ const root = this.fileRoot(collectionKey, resourceKey);
2091
+ return this.request("GET", `${root}/file/original/`);
2092
+ }
2093
+ /**
2094
+ * Get a short-lived link to a record's safe copy. It is an image-only PDF, or a PNG
2095
+ * for an image: read `content_type`.
2096
+ */
2097
+ async getFileSafeCopy(collectionKey, resourceKey) {
2098
+ const root = this.fileRoot(collectionKey, resourceKey);
2099
+ return this.request("GET", `${root}/file/safe-copy/`);
2100
+ }
2101
+ /** Get a short-lived link to the redacted PNG of one page. */
2102
+ async getFilePage(collectionKey, resourceKey, page) {
2103
+ const root = this.fileRoot(collectionKey, resourceKey);
2104
+ return this.request("GET", `${root}/file/pages/${page}/`);
2105
+ }
2106
+ /**
2107
+ * Read one page: its redacted image, what was withheld, its tables and the
2108
+ * text an agent receives.
2109
+ */
2110
+ async getFilePageDetail(collectionKey, resourceKey, page) {
2111
+ const root = this.fileRoot(collectionKey, resourceKey);
2112
+ return this.request("GET", `${root}/file/pages/${page}/detail/`);
2113
+ }
2114
+ /** List a collection's blocked and rejected files, newest first. */
2115
+ async listFileTombstones(collectionKey, params) {
2116
+ const key = resolveKey(collectionKey);
2117
+ return this.request("GET", `${this.paths.fileTombstonesRoot(key)}/`, { params });
2118
+ }
2119
+ /** Read a collection's live files policy. */
2120
+ async getFilesPolicy(collectionKey) {
2121
+ const key = resolveKey(collectionKey);
2122
+ return this.request("GET", `${this.paths.filesPolicyRoot(key)}/`);
2123
+ }
2124
+ /**
2125
+ * Replace a collection's files policy with a new version.
2126
+ *
2127
+ * A full replacement: an omitted field takes its default. Sending the live
2128
+ * body again creates no version.
2129
+ */
2130
+ async updateFilesPolicy(collectionKey, payload) {
2131
+ const key = resolveKey(collectionKey);
2132
+ return this.request("PUT", `${this.paths.filesPolicyRoot(key)}/`, { jsonBody: payload });
2133
+ }
2134
+ /**
2135
+ * List the files held for a reviewer in this environment, newest first.
2136
+ *
2137
+ * `collection` narrows the queue to one collection; one the caller cannot read,
2138
+ * or that does not exist, is an empty page. `params` carries `limit` (at most
2139
+ * 100) and `offset`.
2140
+ */
2141
+ async listFileReviewQueue(options) {
2142
+ const params = { ...options?.params };
2143
+ if (options?.collection !== void 0) {
2144
+ params.collection = resolveKey(options.collection);
2145
+ }
2146
+ return this.request("GET", `${this.paths.filesReviewRoot()}/`, { params });
2147
+ }
2148
+ /**
2149
+ * Read what the authenticated caller may do in this environment.
2150
+ *
2151
+ * Works for a user token and for a Management API key of this environment. A caller
2152
+ * with no grants at all is a `403`; a key of another environment is a
2153
+ * `404 environment_not_found`.
2154
+ */
2155
+ async getMyPermissions() {
2156
+ return this.request("GET", `${this.paths.myPermissionsRoot()}/`);
2157
+ }
2158
+ fileRoot(collectionKey, resourceKey) {
2159
+ return this.paths.fileRoot(resolveKey(collectionKey), resolveKey(resourceKey));
2160
+ }
1890
2161
  };
1891
2162
 
1892
2163
  // src/flux/models.ts
@@ -2137,6 +2408,45 @@ var FluxClient = class {
2137
2408
  const path = this.buildPath(folderPath, `/${resourceKey}/`);
2138
2409
  return this.transport.request("PUT", path, { jsonBody: { data }, allowRetries: false });
2139
2410
  }
2411
+ /**
2412
+ * Get a grant for one upload to a files collection.
2413
+ *
2414
+ * The grant is a credential: pass it on, do not log it. For a strict collection
2415
+ * `folderPath` names the owner, e.g. `support/tickets/tk_1/attachments`. Needs a
2416
+ * key with create access to the collection.
2417
+ *
2418
+ * `options.sessionKey` is an optional idempotency key of 43 URL-safe characters:
2419
+ * a repeat with the same key, collection and owner reaches the same upload
2420
+ * session. A failed request is never retried automatically, so send one to
2421
+ * retry safely.
2422
+ */
2423
+ async createUploadSignature(folderPath, options) {
2424
+ const path = this.buildPath(folderPath, "/_upload-signature");
2425
+ const sessionKey = options?.sessionKey;
2426
+ return this.transport.request("POST", path, {
2427
+ jsonBody: sessionKey === void 0 ? void 0 : { session_key: sessionKey },
2428
+ allowRetries: false
2429
+ });
2430
+ }
2431
+ /**
2432
+ * Read the status of an upload.
2433
+ *
2434
+ * A key reads the uploads that key started, and the path must name the same
2435
+ * collection and owner. Any other combination is `404 not_found`, which includes
2436
+ * a link made through the Management API: read that one with
2437
+ * `ManagementClient.getUploadLink`.
2438
+ *
2439
+ * `options.statusToken` is the end user's token from the grant, for a client that
2440
+ * holds no key (use `AnonymousAuth`). It answers the end user's view, which never
2441
+ * carries a record key. A request authenticated by a key ignores it.
2442
+ */
2443
+ async getUploadStatus(folderPath, uploadId, options) {
2444
+ const path = this.buildPath(folderPath, `/_uploads/${encodeURIComponent(uploadId)}`);
2445
+ const statusToken = options?.statusToken;
2446
+ return this.transport.request("GET", path, {
2447
+ headers: statusToken === void 0 ? void 0 : { "X-Upload-Status-Token": statusToken }
2448
+ });
2449
+ }
2140
2450
  /** Semantic search using auto-generated embeddings. */
2141
2451
  async vectorSearch(folderPath, options) {
2142
2452
  const {
@@ -2286,6 +2596,8 @@ var FluxClient = class {
2286
2596
  DEFAULT_RETRY_CONFIG,
2287
2597
  DEFAULT_USER_AGENT,
2288
2598
  ExternalIdConflictError,
2599
+ FilesQuotaExceededError,
2600
+ FilesQuotaUnavailableError,
2289
2601
  FluxClient,
2290
2602
  FoxnoseAPIError,
2291
2603
  FoxnoseAuthError,
@@ -2308,6 +2620,7 @@ var FluxClient = class {
2308
2620
  buildSearchBody,
2309
2621
  createConfig,
2310
2622
  nestedFieldMeta,
2623
+ parseFindingEvidence,
2311
2624
  resolveKey
2312
2625
  });
2313
2626
  //# sourceMappingURL=index.cjs.map