@xberg-io/sdk 0.9.0 → 0.11.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.js CHANGED
@@ -1,14 +1,20 @@
1
1
  import createOpenApiClient from "openapi-fetch";
2
- //#region src/errors.ts
2
+ // src/errors.ts
3
3
  var XbergError = class extends Error {
4
4
  status;
5
5
  body;
6
+ /** Stable error code from the response envelope; branch on this, not on `message`. */
7
+ code;
8
+ /** The envelope's `details` object, when the server sent one. */
9
+ details;
6
10
  constructor(message, options) {
7
11
  const errorInit = options.cause === void 0 ? {} : { cause: options.cause };
8
12
  super(message, errorInit);
9
13
  this.name = "XbergError";
10
14
  this.status = options.status;
11
15
  this.body = options.body;
16
+ if (options.code !== void 0) this.code = options.code;
17
+ if (options.details !== void 0) this.details = options.details;
12
18
  }
13
19
  };
14
20
  var AuthError = class extends XbergError {
@@ -37,12 +43,85 @@ var NotFoundError = class extends XbergError {
37
43
  this.name = "NotFoundError";
38
44
  }
39
45
  };
46
+ /**
47
+ * HTTP 404 with code `data_room.disabled`: the deployment's plan does not offer
48
+ * data rooms, so every room route answers this before any other check.
49
+ * `enterpriseHealthz()` reports the same state ahead of time as
50
+ * `data_rooms.enabled === false`. Extends {@link NotFoundError}, which this
51
+ * response mapped to before.
52
+ */
53
+ var DataRoomsDisabledError = class extends NotFoundError {
54
+ constructor(message, options) {
55
+ super(message, options);
56
+ this.name = "DataRoomsDisabledError";
57
+ }
58
+ };
59
+ /** Envelope code of the 404 every data-room route answers on a plan without data rooms. */
60
+ const DATA_ROOM_DISABLED_CODE = "data_room.disabled";
40
61
  var ServerError = class extends XbergError {
41
62
  constructor(message, options) {
42
63
  super(message, options);
43
64
  this.name = "ServerError";
44
65
  }
45
66
  };
67
+ /**
68
+ * HTTP 408: the request body stopped arriving before the upload completed
69
+ * (`details.limit` is `body_idle`). Not retried by default — the body must be
70
+ * sent again. Extends {@link ValidationError}, which every 4xx mapped to before.
71
+ */
72
+ var RequestTimeoutError = class extends ValidationError {
73
+ /** Which server limit fired (`body_idle`), from `details.limit`. */
74
+ limit;
75
+ /** The limit that was exceeded, in seconds, from `details.timeout_seconds`. */
76
+ timeoutSeconds;
77
+ constructor(message, options) {
78
+ super(message, options);
79
+ this.name = "RequestTimeoutError";
80
+ const limits = timeoutLimits(options.details);
81
+ if (limits.limit !== void 0) this.limit = limits.limit;
82
+ if (limits.timeoutSeconds !== void 0) this.timeoutSeconds = limits.timeoutSeconds;
83
+ }
84
+ };
85
+ /** HTTP 410: the job's stored result has expired and can no longer be fetched. */
86
+ var ResultExpiredError = class extends ValidationError {
87
+ constructor(message, options) {
88
+ super(message, options);
89
+ this.name = "ResultExpiredError";
90
+ }
91
+ };
92
+ /** HTTP 412: the `If-Match` precondition did not match the resource's current version. */
93
+ var PreconditionFailedError = class extends ValidationError {
94
+ constructor(message, options) {
95
+ super(message, options);
96
+ this.name = "PreconditionFailedError";
97
+ }
98
+ };
99
+ /** HTTP 428: the endpoint requires an `If-Match` header and none was sent. */
100
+ var PreconditionRequiredError = class extends ValidationError {
101
+ constructor(message, options) {
102
+ super(message, options);
103
+ this.name = "PreconditionRequiredError";
104
+ }
105
+ };
106
+ /**
107
+ * HTTP 504: the server did not produce a response in time (`details.limit` is
108
+ * `handler`). The work may still have happened server-side, which is why a
109
+ * POST is not retried on 504 unless the client opts in. Extends
110
+ * {@link ServerError}, which 504 mapped to before.
111
+ */
112
+ var GatewayTimeoutError = class extends ServerError {
113
+ /** Which server limit fired (`handler`), from `details.limit`. */
114
+ limit;
115
+ /** The limit that was exceeded, in seconds, from `details.timeout_seconds`. */
116
+ timeoutSeconds;
117
+ constructor(message, options) {
118
+ super(message, options);
119
+ this.name = "GatewayTimeoutError";
120
+ const limits = timeoutLimits(options.details);
121
+ if (limits.limit !== void 0) this.limit = limits.limit;
122
+ if (limits.timeoutSeconds !== void 0) this.timeoutSeconds = limits.timeoutSeconds;
123
+ }
124
+ };
46
125
  var TimeoutError = class extends XbergError {
47
126
  constructor(message, options) {
48
127
  super(message, options);
@@ -59,13 +138,19 @@ var TimeoutError = class extends XbergError {
59
138
  */
60
139
  async function raiseForStatus(response) {
61
140
  const body = await readBody(response);
62
- const message = extractErrorMessage(body) ?? `Request failed with status ${response.status}`;
141
+ const envelope = parseErrorEnvelope(body);
142
+ const message = envelope.message ?? `Request failed with status ${response.status}`;
63
143
  const options = {
64
144
  status: response.status,
65
145
  body
66
146
  };
147
+ if (envelope.code !== void 0) options.code = envelope.code;
148
+ if (envelope.details !== void 0) options.details = envelope.details;
67
149
  if (response.status === 401 || response.status === 403) throw new AuthError(message, options);
68
- if (response.status === 404) throw new NotFoundError(message, options);
150
+ if (response.status === 404) {
151
+ if (options.code === DATA_ROOM_DISABLED_CODE) throw new DataRoomsDisabledError(message, options);
152
+ throw new NotFoundError(message, options);
153
+ }
69
154
  if (response.status === 429) {
70
155
  const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
71
156
  throw new RateLimitError(message, retryAfter === void 0 ? options : {
@@ -73,6 +158,8 @@ async function raiseForStatus(response) {
73
158
  retryAfter
74
159
  });
75
160
  }
161
+ const specific = STATUS_ERRORS[response.status];
162
+ if (specific !== void 0) throw new specific(message, options);
76
163
  if (response.status >= 400 && response.status < 500) throw new ValidationError(message, options);
77
164
  if (response.status >= 500) throw new ServerError(message, options);
78
165
  throw new XbergError(message, options);
@@ -90,15 +177,45 @@ async function readBody(response) {
90
177
  return;
91
178
  }
92
179
  }
93
- function extractErrorMessage(body) {
94
- if (typeof body === "string" && body.length > 0) return body;
95
- if (body !== null && typeof body === "object") {
96
- const record = body;
97
- const error = record["error"];
98
- if (typeof error === "string" && error.length > 0) return error;
99
- const message = record["message"];
100
- if (typeof message === "string" && message.length > 0) return message;
101
- }
180
+ const STATUS_ERRORS = {
181
+ 408: RequestTimeoutError,
182
+ 410: ResultExpiredError,
183
+ 412: PreconditionFailedError,
184
+ 428: PreconditionRequiredError,
185
+ 504: GatewayTimeoutError
186
+ };
187
+ /**
188
+ * Read an error body in any shape the servers send: the canonical nested
189
+ * envelope `{"error":{"code","message","details"}}`, the older flat
190
+ * `{"error":"..."}` / `{"message":"...","code":"..."}`, or plain text.
191
+ */
192
+ function parseErrorEnvelope(body) {
193
+ if (typeof body === "string") return body.length > 0 ? { message: body } : {};
194
+ if (!isRecord(body)) return {};
195
+ const error = body["error"];
196
+ const source = isRecord(error) ? error : body;
197
+ const envelope = {};
198
+ const message = nonEmptyString(source === body && typeof error === "string" ? error : void 0) ?? nonEmptyString(source["message"]);
199
+ if (message !== void 0) envelope.message = message;
200
+ const code = nonEmptyString(source["code"]);
201
+ if (code !== void 0) envelope.code = code;
202
+ const details = source["details"];
203
+ if (isRecord(details)) envelope.details = details;
204
+ return envelope;
205
+ }
206
+ function timeoutLimits(details) {
207
+ const out = {};
208
+ const limit = details?.["limit"];
209
+ if (typeof limit === "string") out.limit = limit;
210
+ const seconds = details?.["timeout_seconds"];
211
+ if (typeof seconds === "number" && Number.isFinite(seconds)) out.timeoutSeconds = seconds;
212
+ return out;
213
+ }
214
+ function isRecord(value) {
215
+ return value !== null && typeof value === "object" && !Array.isArray(value);
216
+ }
217
+ function nonEmptyString(value) {
218
+ return typeof value === "string" && value.length > 0 ? value : void 0;
102
219
  }
103
220
  function parseRetryAfter(value) {
104
221
  if (value === null) return;
@@ -108,8 +225,7 @@ function parseRetryAfter(value) {
108
225
  if (Number.isNaN(parsed)) return;
109
226
  return Math.max(0, Math.ceil((parsed - Date.now()) / 1e3));
110
227
  }
111
- //#endregion
112
- //#region src/_internal.ts
228
+ // src/_internal.ts
113
229
  /**
114
230
  * Internal helpers for {@link XbergClient}: base-URL resolution, query-string
115
231
  * and backoff arithmetic, the file-to-`Blob` conversion the multipart request
@@ -321,8 +437,7 @@ function encodePathSegment(value) {
321
437
  });
322
438
  return encodeURIComponent(value);
323
439
  }
324
- //#endregion
325
- //#region src/types.ts
440
+ // src/types.ts
326
441
  /**
327
442
  * Terminal job statuses — once observed, polling stops and the job result is
328
443
  * returned (or thrown, for `failed`/`cancelled`).
@@ -338,8 +453,7 @@ const TERMINAL_JOB_STATUSES = [
338
453
  * "completed but check warnings" result from a hard failure.
339
454
  */
340
455
  const SUCCESS_JOB_STATUSES = ["completed", "partial_success"];
341
- //#endregion
342
- //#region src/client.ts
456
+ // src/client.ts
343
457
  /**
344
458
  * High-level dual-target client for the Xberg Enterprise and Xberg Pro HTTP APIs.
345
459
  *
@@ -359,7 +473,7 @@ const SUCCESS_JOB_STATUSES = ["completed", "partial_success"];
359
473
  * and defaults to `baseUrl`. The backend methods use that origin and an optional
360
474
  * separate `controlPlaneToken`; existing Pro methods retain their data-plane routing.
361
475
  */
362
- const USER_AGENT = `xberg-io-sdk-typescript/0.9.0`;
476
+ const USER_AGENT = `xberg-io-sdk-typescript/0.11.0`;
363
477
  const DEFAULT_TIMEOUT_MS = 3e4;
364
478
  const DEFAULT_POLL_INTERVAL_MS = 1e3;
365
479
  const DEFAULT_WAIT_TIMEOUT_MS = 3e5;
@@ -369,6 +483,18 @@ const DEFAULT_RETRY_STATUSES = [
369
483
  503,
370
484
  504
371
485
  ];
486
+ /**
487
+ * ~keep Methods a retry cannot duplicate work through. A 502/503/504 on a POST may
488
+ * arrive after the server accepted the submission, so retrying it can create a
489
+ * second job; 429 is safe for every method because the request was refused.
490
+ */
491
+ const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
492
+ "GET",
493
+ "HEAD",
494
+ "OPTIONS",
495
+ "PUT",
496
+ "DELETE"
497
+ ]);
372
498
  const DEFAULT_RETRY_BACKOFF_BASE_MS = 200;
373
499
  /**
374
500
  * ~keep `saved-presets` is an OpenAPI *tag* name, not a route: both specs serve
@@ -383,6 +509,16 @@ const DOCUMENTS_PATH = "/v1/documents";
383
509
  const JOBS_PATH = "/v1/jobs";
384
510
  const CRAWL_JOBS_PATH = "/v1/crawl-jobs";
385
511
  const WEBHOOKS_PATH = "/v1/webhooks";
512
+ const ROOMS_PATH = "/v1/rooms";
513
+ const ROOM_INVITATIONS_PATH = "/v1/room-invitations";
514
+ const PUBLIC_ROOMS_PATH = "/public/rooms";
515
+ /** Headers that carry a credential, stripped from every request to an unauthenticated public route. */
516
+ const CREDENTIAL_HEADERS = [
517
+ "authorization",
518
+ "proxy-authorization",
519
+ "cookie",
520
+ "x-api-key"
521
+ ];
386
522
  /** Media type of a raw upload body, and the fallback when a submitted file declares none. */
387
523
  const OCTET_STREAM_MEDIA_TYPE = "application/octet-stream";
388
524
  /** Media type of the crawl-event stream, sent as `Accept` and served as `Content-Type`. */
@@ -409,6 +545,7 @@ var XbergClient = class {
409
545
  timeoutMs;
410
546
  retries;
411
547
  retryOn;
548
+ retryNonIdempotent;
412
549
  retryBackoff;
413
550
  sleep;
414
551
  target;
@@ -426,6 +563,7 @@ var XbergClient = class {
426
563
  this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
427
564
  this.retries = options.retries ?? 0;
428
565
  this.retryOn = options.retryOn ?? DEFAULT_RETRY_STATUSES;
566
+ this.retryNonIdempotent = options.retryNonIdempotent ?? false;
429
567
  this.retryBackoff = options.retryBackoff ?? "exponential";
430
568
  this.sleep = options.sleep ?? defaultSleep;
431
569
  this.headers = {
@@ -817,7 +955,7 @@ var XbergClient = class {
817
955
  const documentIds = prepareDocumentLineage(filenames, params.documentIds);
818
956
  if (documentIds.size > 0) await this.requireTier("enterprise", "extract document lineage");
819
957
  if (params.projectId !== void 0) await this.requireTier("pro", "projectId");
820
- const projectHeader = Object.keys(this.headers).find((name) => name.toLowerCase() === "x-project-id") ?? "X-Project-ID";
958
+ const projectHeader = this.projectHeaderName();
821
959
  const form = new FormData();
822
960
  for (const [filename, documentId] of documentIds) form.append(`document_id-${filename}`, documentId);
823
961
  const parts = params.files.map(toBlob);
@@ -1176,6 +1314,15 @@ var XbergClient = class {
1176
1314
  return { [Symbol.asyncIterator]: () => iterateCrawlEvents(open) };
1177
1315
  }
1178
1316
  /**
1317
+ * Enterprise liveness and feature availability (`GET /healthz` on the data plane).
1318
+ * Decoded leniently: a missing feature object reads as `{ enabled: false }` and
1319
+ * unknown fields are kept, so an older or newer server does not break the call. ~keep
1320
+ */
1321
+ async enterpriseHealthz() {
1322
+ await this.requireTier("enterprise", "enterpriseHealthz");
1323
+ return decodeEnterpriseHealth(await this.requestJson("GET", "/healthz"));
1324
+ }
1325
+ /**
1179
1326
  * Pro liveness and coarse license/capability state (`GET /healthz`).
1180
1327
  * Use readiness checks to assess dependencies. ~keep
1181
1328
  */
@@ -1243,6 +1390,42 @@ var XbergClient = class {
1243
1390
  await this.requireTier("pro", "createProject");
1244
1391
  return this.requestJson("POST", "/v1/projects", { json: body });
1245
1392
  }
1393
+ /** Pro only: read a live project visible to the caller. */
1394
+ async proGetProject(projectId) {
1395
+ await this.requireTier("pro", "proGetProject");
1396
+ return this.requestJson("GET", this.projectPath(projectId));
1397
+ }
1398
+ /** Pro only: rename a project. */
1399
+ async proUpdateProject(projectId, body) {
1400
+ await this.requireTier("pro", "proUpdateProject");
1401
+ return this.requestJson("PATCH", this.projectPath(projectId), { json: body });
1402
+ }
1403
+ /** Pro only: soft-delete a project and revoke its API keys. */
1404
+ async proDeleteProject(projectId) {
1405
+ await this.requireTier("pro", "proDeleteProject");
1406
+ await this.requestJson("DELETE", this.projectPath(projectId));
1407
+ }
1408
+ /** Enterprise only: read the project's stored extraction defaults. */
1409
+ async getProjectExtractionConfig(projectId) {
1410
+ await this.requireTier("enterprise", "getProjectExtractionConfig");
1411
+ const projectHeader = this.projectHeaderName();
1412
+ return this.requestJson("GET", `${this.projectPath(projectId)}/extraction-config`, { headers: { [projectHeader]: projectId } });
1413
+ }
1414
+ /** Enterprise only: replace the project's stored extraction defaults. */
1415
+ async setProjectExtractionConfig(projectId, body) {
1416
+ await this.requireTier("enterprise", "setProjectExtractionConfig");
1417
+ const projectHeader = this.projectHeaderName();
1418
+ return this.requestJson("PUT", `${this.projectPath(projectId)}/extraction-config`, {
1419
+ headers: { [projectHeader]: projectId },
1420
+ json: body
1421
+ });
1422
+ }
1423
+ /** Enterprise only: clear the project's stored extraction defaults. */
1424
+ async clearProjectExtractionConfig(projectId) {
1425
+ await this.requireTier("enterprise", "clearProjectExtractionConfig");
1426
+ const projectHeader = this.projectHeaderName();
1427
+ await this.requestJson("DELETE", `${this.projectPath(projectId)}/extraction-config`, { headers: { [projectHeader]: projectId } });
1428
+ }
1246
1429
  /** Pro only: list a project's API keys (`GET /v1/projects/{projectId}/api-keys`). */
1247
1430
  async listApiKeys(projectId, params = {}) {
1248
1431
  await this.requireTier("pro", "listApiKeys");
@@ -1412,10 +1595,362 @@ var XbergClient = class {
1412
1595
  const path = `${this.webhookDeliveriesPath(webhookId)}/${encodePathSegment(deliveryId)}`;
1413
1596
  return this.requestJson("GET", path);
1414
1597
  }
1598
+ /**
1599
+ * Enterprise only: list the project's logical documents (`GET /v1/documents`),
1600
+ * each shown by its newest finished version, most recently updated first. An
1601
+ * entry's `document_id` is the id {@link addRoomItem} takes.
1602
+ */
1603
+ async listDocuments(params = {}) {
1604
+ await this.requireTier("enterprise", "listDocuments");
1605
+ return this.requestJson("GET", DOCUMENTS_PATH, { params: {
1606
+ limit: params.limit,
1607
+ offset: params.offset
1608
+ } });
1609
+ }
1610
+ /**
1611
+ * Enterprise only: list the data rooms the caller can see (`GET /v1/rooms`),
1612
+ * with the rights it holds on each. `state: "deleted"` lists the deleted rooms
1613
+ * that can still be restored.
1614
+ */
1615
+ async listRooms(params = {}) {
1616
+ await this.requireTier("enterprise", "listRooms");
1617
+ return this.requestJson("GET", ROOMS_PATH, { params: {
1618
+ limit: params.limit,
1619
+ offset: params.offset,
1620
+ state: params.state
1621
+ } });
1622
+ }
1623
+ /**
1624
+ * Enterprise only: create a data room owned by the caller (`POST /v1/rooms`).
1625
+ * A project at its room limit answers 409 `quota_exceeded`.
1626
+ */
1627
+ async createRoom(body) {
1628
+ await this.requireTier("enterprise", "createRoom");
1629
+ return this.requestJson("POST", ROOMS_PATH, { json: body });
1630
+ }
1631
+ /** Enterprise only: fetch one live data room with the caller's rights on it (`GET /v1/rooms/{id}`). */
1632
+ async getRoom(roomId) {
1633
+ await this.requireTier("enterprise", "getRoom");
1634
+ return this.requestJson("GET", this.roomPath(roomId));
1635
+ }
1636
+ /**
1637
+ * Enterprise only: rename a data room or change its description
1638
+ * (`PATCH /v1/rooms/{id}`).
1639
+ *
1640
+ * `version` is the room's `version` as last read, sent as `If-Match`. A stale
1641
+ * one throws {@link PreconditionFailedError}; read the room again and retry.
1642
+ * The returned room carries the new `version`. A `null` description clears it.
1643
+ */
1644
+ async updateRoom(roomId, body, version) {
1645
+ await this.requireTier("enterprise", "updateRoom");
1646
+ return this.requestJson("PATCH", this.roomPath(roomId), {
1647
+ json: body,
1648
+ headers: ifMatch(version)
1649
+ });
1650
+ }
1651
+ /**
1652
+ * Enterprise only: delete a live data room (`DELETE /v1/rooms/{id}`). It stays
1653
+ * restorable until its `restorable_until`; see {@link restoreRoom}.
1654
+ */
1655
+ async deleteRoom(roomId) {
1656
+ await this.requireTier("enterprise", "deleteRoom");
1657
+ await this.requestJson("DELETE", this.roomPath(roomId));
1658
+ }
1659
+ /**
1660
+ * Enterprise only: restore a deleted data room inside its restore window
1661
+ * (`POST /v1/rooms/{id}/restore`). A project at its room limit answers 409.
1662
+ */
1663
+ async restoreRoom(roomId) {
1664
+ await this.requireTier("enterprise", "restoreRoom");
1665
+ return this.requestJson("POST", `${this.roomPath(roomId)}/restore`);
1666
+ }
1667
+ /**
1668
+ * Enterprise only: list a room's documents in room order
1669
+ * (`GET /v1/rooms/{id}/items`). The answer's `version` is the one
1670
+ * {@link reorderRoomItems} sends.
1671
+ */
1672
+ async listRoomItems(roomId, params = {}) {
1673
+ await this.requireTier("enterprise", "listRoomItems");
1674
+ return this.requestJson("GET", `${this.roomPath(roomId)}/items`, { params: {
1675
+ limit: params.limit,
1676
+ offset: params.offset
1677
+ } });
1678
+ }
1679
+ /**
1680
+ * Enterprise only: add a project document to the end of a room
1681
+ * (`POST /v1/rooms/{id}/items`). The document needs a finished version; take
1682
+ * its id from {@link listDocuments}. It moves the room version without
1683
+ * returning it: read it again before the next versioned write.
1684
+ */
1685
+ async addRoomItem(roomId, body) {
1686
+ await this.requireTier("enterprise", "addRoomItem");
1687
+ return this.requestJson("POST", `${this.roomPath(roomId)}/items`, { json: body });
1688
+ }
1689
+ /**
1690
+ * Enterprise only: set the order of every item in a room
1691
+ * (`PUT /v1/rooms/{id}/items/order`). `body.document_ids` names each item once.
1692
+ *
1693
+ * `version` is the room version from {@link listRoomItems} or
1694
+ * {@link getRoom}, sent as `If-Match`; a stale one throws
1695
+ * {@link PreconditionFailedError}. The answer carries the new `version`.
1696
+ */
1697
+ async reorderRoomItems(roomId, body, version) {
1698
+ await this.requireTier("enterprise", "reorderRoomItems");
1699
+ return this.requestJson("PUT", `${this.roomPath(roomId)}/items/order`, {
1700
+ json: body,
1701
+ headers: ifMatch(version)
1702
+ });
1703
+ }
1704
+ /**
1705
+ * Enterprise only: remove a document from a room
1706
+ * (`DELETE /v1/rooms/{id}/items/{document_id}`). The document stays in the project.
1707
+ * It moves the room version without returning it. A retried call whose first
1708
+ * attempt applied throws {@link NotFoundError}.
1709
+ */
1710
+ async removeRoomItem(roomId, documentId) {
1711
+ await this.requireTier("enterprise", "removeRoomItem");
1712
+ await this.requestJson("DELETE", this.roomItemPath(roomId, documentId));
1713
+ }
1714
+ /**
1715
+ * Enterprise only: fetch the extraction result of a room item's newest
1716
+ * finished version (`GET /v1/rooms/{id}/items/{document_id}/content`).
1717
+ * `result` is `null` while extraction has not finished.
1718
+ */
1719
+ async getRoomItemContent(roomId, documentId) {
1720
+ await this.requireTier("enterprise", "getRoomItemContent");
1721
+ return this.requestJson("GET", `${this.roomItemPath(roomId, documentId)}/content`);
1722
+ }
1723
+ /**
1724
+ * Enterprise only: download a room item's original file
1725
+ * (`GET /v1/rooms/{id}/items/{document_id}/download`). The response is raw
1726
+ * bytes, not JSON. A room that does not allow downloads answers 403.
1727
+ */
1728
+ async downloadRoomItem(roomId, documentId) {
1729
+ await this.requireTier("enterprise", "downloadRoomItem");
1730
+ return this.requestBytes("GET", `${this.roomItemPath(roomId, documentId)}/download`);
1731
+ }
1732
+ /**
1733
+ * Enterprise only: download one rendered page of a room item as a PNG
1734
+ * (`GET /v1/rooms/{id}/items/{document_id}/pages/{page_number}`). Raw bytes,
1735
+ * not JSON. `pageNumber` is 1-indexed. Every reader of the room can open it,
1736
+ * whatever its download setting.
1737
+ */
1738
+ async getRoomItemPage(roomId, documentId, pageNumber) {
1739
+ await this.requireTier("enterprise", "getRoomItemPage");
1740
+ const path = `${this.roomItemPath(roomId, documentId)}/pages/${encodePathSegment(String(pageNumber))}`;
1741
+ return this.requestBytes("GET", path);
1742
+ }
1743
+ /** Enterprise only: list the users holding a grant on a room (`GET /v1/rooms/{id}/members`). */
1744
+ async listRoomMembers(roomId, params = {}) {
1745
+ await this.requireTier("enterprise", "listRoomMembers");
1746
+ return this.requestJson("GET", `${this.roomPath(roomId)}/members`, { params: {
1747
+ limit: params.limit,
1748
+ offset: params.offset
1749
+ } });
1750
+ }
1751
+ /**
1752
+ * Enterprise only: give a project member a grant on a room
1753
+ * (`POST /v1/rooms/{id}/members`). Anyone outside the project joins by
1754
+ * {@link createRoomInvitation} instead.
1755
+ */
1756
+ async addRoomMember(roomId, body) {
1757
+ await this.requireTier("enterprise", "addRoomMember");
1758
+ return this.requestJson("POST", `${this.roomPath(roomId)}/members`, { json: body });
1759
+ }
1760
+ /**
1761
+ * Enterprise only: remove a member's grant on a room
1762
+ * (`DELETE /v1/rooms/{id}/members/{user_id}`). The owner answers 409; transfer
1763
+ * ownership first.
1764
+ */
1765
+ async removeRoomMember(roomId, userId) {
1766
+ await this.requireTier("enterprise", "removeRoomMember");
1767
+ await this.requestJson("DELETE", this.roomMemberPath(roomId, userId));
1768
+ }
1769
+ /**
1770
+ * Enterprise only: change a room member's role to an editor or a viewer
1771
+ * (`PATCH /v1/rooms/{id}/members/{user_id}`).
1772
+ */
1773
+ async changeRoomMemberRole(roomId, userId, body) {
1774
+ await this.requireTier("enterprise", "changeRoomMemberRole");
1775
+ return this.requestJson("PATCH", this.roomMemberPath(roomId, userId), { json: body });
1776
+ }
1777
+ /**
1778
+ * Enterprise only: remove the caller's own grant on a room
1779
+ * (`POST /v1/rooms/{id}/leave`). The owner answers 409.
1780
+ */
1781
+ async leaveRoom(roomId) {
1782
+ await this.requireTier("enterprise", "leaveRoom");
1783
+ await this.requestJson("POST", `${this.roomPath(roomId)}/leave`);
1784
+ }
1785
+ /**
1786
+ * Enterprise only: make another room member the owner
1787
+ * (`POST /v1/rooms/{id}/ownership`). The new owner must be a project member
1788
+ * who already holds a grant on the room.
1789
+ */
1790
+ async transferRoomOwnership(roomId, body) {
1791
+ await this.requireTier("enterprise", "transferRoomOwnership");
1792
+ await this.requestJson("POST", `${this.roomPath(roomId)}/ownership`, { json: body });
1793
+ }
1794
+ /** Enterprise only: list a data room's share links. */
1795
+ async listRoomLinks(roomId, params = {}) {
1796
+ await this.requireTier("enterprise", "listRoomLinks");
1797
+ return this.requestJson("GET", `${this.roomPath(roomId)}/links`, { params: {
1798
+ limit: params.limit,
1799
+ offset: params.offset
1800
+ } });
1801
+ }
1802
+ /** Enterprise only: create a share link for a data room. */
1803
+ async createRoomLink(roomId, body) {
1804
+ await this.requireTier("enterprise", "createRoomLink");
1805
+ return this.requestJson("POST", `${this.roomPath(roomId)}/links`, { json: body });
1806
+ }
1807
+ /** Enterprise only: revoke a data room share link and its grants. */
1808
+ async revokeRoomLink(roomId, linkId) {
1809
+ await this.requireTier("enterprise", "revokeRoomLink");
1810
+ await this.requestJson("DELETE", `${this.roomPath(roomId)}/links/${encodePathSegment(linkId)}`);
1811
+ }
1812
+ /** Enterprise only: accept a share link with a signed-in user's session. */
1813
+ async acceptRoomLink(body, options = {}) {
1814
+ const bearer = sessionBearer(options);
1815
+ await this.requireTier("enterprise", "acceptRoomLink");
1816
+ return this.requestJson("POST", "/v1/room-links/accept", {
1817
+ json: body,
1818
+ ...bearer
1819
+ });
1820
+ }
1821
+ /**
1822
+ * Enterprise only: list a room's invitations (`GET /v1/rooms/{id}/invitations`).
1823
+ * The answer never carries an invitation token.
1824
+ */
1825
+ async listRoomInvitations(roomId, params = {}) {
1826
+ await this.requireTier("enterprise", "listRoomInvitations");
1827
+ return this.requestJson("GET", `${this.roomPath(roomId)}/invitations`, { params: {
1828
+ limit: params.limit,
1829
+ offset: params.offset
1830
+ } });
1831
+ }
1832
+ /**
1833
+ * Enterprise only: invite an email address to a room
1834
+ * (`POST /v1/rooms/{id}/invitations`). `token` is in the answer only when the
1835
+ * configured delivery channel returns it.
1836
+ */
1837
+ async createRoomInvitation(roomId, body) {
1838
+ await this.requireTier("enterprise", "createRoomInvitation");
1839
+ return this.requestJson("POST", `${this.roomPath(roomId)}/invitations`, { json: body });
1840
+ }
1841
+ /**
1842
+ * Enterprise only: revoke a pending room invitation
1843
+ * (`DELETE /v1/rooms/{id}/invitations/{invitation_id}`).
1844
+ */
1845
+ async revokeRoomInvitation(roomId, invitationId) {
1846
+ await this.requireTier("enterprise", "revokeRoomInvitation");
1847
+ await this.requestJson("DELETE", `${this.roomPath(roomId)}/invitations/${encodePathSegment(invitationId)}`);
1848
+ }
1849
+ /**
1850
+ * Enterprise only: show a signed-in invitee the room an invitation token opens
1851
+ * (`POST /v1/room-invitations/preview`).
1852
+ *
1853
+ * Requires a dashboard user session, not an API key: pass
1854
+ * `options.sessionToken` or build the client with the session token as
1855
+ * `apiKey`. A token that cannot be accepted answers 404, whatever the reason.
1856
+ */
1857
+ async previewRoomInvitation(body, options = {}) {
1858
+ await this.requireTier("enterprise", "previewRoomInvitation");
1859
+ return this.requestJson("POST", `${ROOM_INVITATIONS_PATH}/preview`, {
1860
+ json: body,
1861
+ ...sessionBearer(options)
1862
+ });
1863
+ }
1864
+ /**
1865
+ * Enterprise only: accept an invitation token for the signed-in user
1866
+ * (`POST /v1/room-invitations/accept`), granting them the room.
1867
+ *
1868
+ * Requires a dashboard user session, not an API key: pass
1869
+ * `options.sessionToken` or build the client with the session token as
1870
+ * `apiKey`. A token that cannot be accepted answers 404, whatever the reason.
1871
+ */
1872
+ async acceptRoomInvitation(body, options = {}) {
1873
+ await this.requireTier("enterprise", "acceptRoomInvitation");
1874
+ return this.requestJson("POST", `${ROOM_INVITATIONS_PATH}/accept`, {
1875
+ json: body,
1876
+ ...sessionBearer(options)
1877
+ });
1878
+ }
1879
+ /**
1880
+ * Enterprise only: read a room's publication settings
1881
+ * (`GET /v1/rooms/{id}/publication`). `room_version` is the value
1882
+ * {@link setRoomPublication} sends.
1883
+ */
1884
+ async getRoomPublication(roomId) {
1885
+ await this.requireTier("enterprise", "getRoomPublication");
1886
+ return this.requestJson("GET", `${this.roomPath(roomId)}/publication`);
1887
+ }
1888
+ /**
1889
+ * Enterprise only: publish or unpublish a room, optionally changing its mode
1890
+ * and download setting (`PUT /v1/rooms/{id}/publication`).
1891
+ *
1892
+ * `version` is the room version (`room_version` from
1893
+ * {@link getRoomPublication}, or the room's `version`), sent as `If-Match`; a
1894
+ * stale one throws {@link PreconditionFailedError}. The answer carries the
1895
+ * new `room_version` and, once published, the public `slug`.
1896
+ */
1897
+ async setRoomPublication(roomId, body, version) {
1898
+ await this.requireTier("enterprise", "setRoomPublication");
1899
+ return this.requestJson("PUT", `${this.roomPath(roomId)}/publication`, {
1900
+ json: body,
1901
+ headers: ifMatch(version)
1902
+ });
1903
+ }
1904
+ /**
1905
+ * Enterprise only: read a published room by its slug (`GET /public/rooms/{slug}`).
1906
+ *
1907
+ * Unauthenticated: sends no credential and no cookie, even when the client
1908
+ * has an API key. A room that is not published answers 404.
1909
+ */
1910
+ async getPublicRoom(slug) {
1911
+ await this.requireTier("enterprise", "getPublicRoom");
1912
+ return this.requestJson("GET", this.publicRoomPath(slug), { anonymous: true });
1913
+ }
1914
+ /**
1915
+ * Enterprise only: list a published room's items in room order
1916
+ * (`GET /public/rooms/{slug}/items`). Unauthenticated; each item's `item_ref`
1917
+ * is what the public content and download methods take.
1918
+ */
1919
+ async listPublicRoomItems(slug, params = {}) {
1920
+ await this.requireTier("enterprise", "listPublicRoomItems");
1921
+ return this.requestJson("GET", `${this.publicRoomPath(slug)}/items`, {
1922
+ anonymous: true,
1923
+ params: {
1924
+ limit: params.limit,
1925
+ offset: params.offset
1926
+ }
1927
+ });
1928
+ }
1929
+ /**
1930
+ * Enterprise only: fetch the extraction result of a published room's item
1931
+ * (`GET /public/rooms/{slug}/items/{item_ref}/content`). Unauthenticated;
1932
+ * `result` is `null` until extraction finishes.
1933
+ */
1934
+ async getPublicRoomItemContent(slug, itemRef) {
1935
+ await this.requireTier("enterprise", "getPublicRoomItemContent");
1936
+ return this.requestJson("GET", `${this.publicRoomItemPath(slug, itemRef)}/content`, { anonymous: true });
1937
+ }
1938
+ /**
1939
+ * Enterprise only: download a published room item's original file
1940
+ * (`GET /public/rooms/{slug}/items/{item_ref}/download`). Unauthenticated; raw
1941
+ * bytes, not JSON. A room that does not allow downloads answers 404.
1942
+ */
1943
+ async downloadPublicRoomItem(slug, itemRef) {
1944
+ await this.requireTier("enterprise", "downloadPublicRoomItem");
1945
+ return this.requestBytes("GET", `${this.publicRoomItemPath(slug, itemRef)}/download`, { anonymous: true });
1946
+ }
1415
1947
  async jobScope(scope) {
1416
1948
  if (scope.projectId !== void 0) await this.requireTier("pro", "projectId");
1417
1949
  return { project_id: scope.projectId };
1418
1950
  }
1951
+ projectHeaderName() {
1952
+ return Object.keys(this.headers).find((name) => name.toLowerCase() === "x-project-id") ?? "X-Project-ID";
1953
+ }
1419
1954
  /** Build `/v1/projects/{projectId}` with the id percent-encoded. */
1420
1955
  projectPath(projectId) {
1421
1956
  return `/v1/projects/${encodePathSegment(projectId)}`;
@@ -1428,6 +1963,26 @@ var XbergClient = class {
1428
1963
  documentPath(documentId) {
1429
1964
  return `${DOCUMENTS_PATH}/${encodePathSegment(documentId)}`;
1430
1965
  }
1966
+ /** Build `/v1/rooms/{id}` with the id percent-encoded. */
1967
+ roomPath(roomId) {
1968
+ return `${ROOMS_PATH}/${encodePathSegment(roomId)}`;
1969
+ }
1970
+ /** Build `/v1/rooms/{id}/items/{document_id}`. */
1971
+ roomItemPath(roomId, documentId) {
1972
+ return `${this.roomPath(roomId)}/items/${encodePathSegment(documentId)}`;
1973
+ }
1974
+ /** Build `/v1/rooms/{id}/members/{user_id}`. */
1975
+ roomMemberPath(roomId, userId) {
1976
+ return `${this.roomPath(roomId)}/members/${encodePathSegment(userId)}`;
1977
+ }
1978
+ /** Build `/public/rooms/{slug}` with the slug percent-encoded. */
1979
+ publicRoomPath(slug) {
1980
+ return `${PUBLIC_ROOMS_PATH}/${encodePathSegment(slug)}`;
1981
+ }
1982
+ /** Build `/public/rooms/{slug}/items/{item_ref}`. */
1983
+ publicRoomItemPath(slug, itemRef) {
1984
+ return `${this.publicRoomPath(slug)}/items/${encodePathSegment(itemRef)}`;
1985
+ }
1431
1986
  /** Build `/v1/saved_presets/{preset_id}` with the id percent-encoded. */
1432
1987
  savedPresetPath(presetId) {
1433
1988
  return `${SAVED_PRESETS_PATH}/${encodePathSegment(presetId)}`;
@@ -1508,6 +2063,21 @@ var XbergClient = class {
1508
2063
  if (init.body instanceof FormData || init.json !== void 0) headers.delete("content-type");
1509
2064
  return Object.fromEntries(headers);
1510
2065
  }
2066
+ /**
2067
+ * Data-plane headers: the client's own merged with the call's, then stripped
2068
+ * of every credential for an anonymous call, or given a per-call bearer.
2069
+ */
2070
+ dataPlaneHeaders(init) {
2071
+ const merged = {
2072
+ ...this.headers,
2073
+ ...init.headers
2074
+ };
2075
+ if (!init.anonymous && init.bearerToken === void 0) return merged;
2076
+ const headers = new Headers(merged);
2077
+ if (init.anonymous) for (const name of CREDENTIAL_HEADERS) headers.delete(name);
2078
+ else if (init.bearerToken !== void 0) headers.set("Authorization", `Bearer ${init.bearerToken}`);
2079
+ return Object.fromEntries(headers);
2080
+ }
1511
2081
  /** Issue a request, raise on non-2xx, and decode the JSON body (undefined for empty bodies). */
1512
2082
  async requestJson(method, path, init = {}) {
1513
2083
  const { body } = await this.requestJsonWithStatus(method, path, init);
@@ -1583,10 +2153,7 @@ var XbergClient = class {
1583
2153
  * mapped to a thrown {@link XbergError} subclass.
1584
2154
  */
1585
2155
  prepareRequest(method, init) {
1586
- const headers = init.controlPlane ? this.backendHeaders(init) : {
1587
- ...this.headers,
1588
- ...init.headers
1589
- };
2156
+ const headers = init.controlPlane ? this.backendHeaders(init) : this.dataPlaneHeaders(init);
1590
2157
  let body = init.body;
1591
2158
  if (init.json !== void 0) {
1592
2159
  headers["Content-Type"] = "application/json";
@@ -1599,17 +2166,29 @@ var XbergClient = class {
1599
2166
  ...init.controlPlane ? {
1600
2167
  credentials: "omit",
1601
2168
  redirect: "manual"
1602
- } : {}
2169
+ } : {},
2170
+ ...init.anonymous ? { credentials: "omit" } : {}
1603
2171
  };
1604
2172
  if (body !== void 0) requestInit.body = body;
1605
2173
  return requestInit;
1606
2174
  }
2175
+ /**
2176
+ * Whether a response status is retryable for this request under the configured policy. A request
2177
+ * carrying `If-Match` (`conditional`) is treated like a POST: once an attempt applied, the room
2178
+ * version moved, so a replay can only answer 412.
2179
+ */
2180
+ shouldRetryStatus(method, status, conditional) {
2181
+ if (!this.retryOn.includes(status)) return false;
2182
+ if (status === 429 || this.retryNonIdempotent) return true;
2183
+ return !conditional && IDEMPOTENT_METHODS.has(method.toUpperCase());
2184
+ }
1607
2185
  async requestWithRetry(method, path, init = {}) {
1608
2186
  if (init.controlPlane && (this.target ?? this.probedTier) === "pro") throw new XbergError("Enterprise backend methods are not available on the 'pro' tier", {
1609
2187
  status: 0,
1610
2188
  body: null
1611
2189
  });
1612
2190
  const url = `${init.controlPlane ? this.controlPlaneBaseUrl : this.baseUrl}${path}${buildQueryString(init.params)}`;
2191
+ const conditional = Object.keys(init.headers ?? {}).some((name) => name.toLowerCase() === "if-match");
1613
2192
  let attempt = 0;
1614
2193
  let interval = DEFAULT_RETRY_BACKOFF_BASE_MS;
1615
2194
  for (;;) {
@@ -1635,7 +2214,7 @@ var XbergClient = class {
1635
2214
  });
1636
2215
  }
1637
2216
  if (response.ok || init.acceptRedirect && response.status === 303) return response;
1638
- if (this.retryOn.includes(response.status) && attempt < this.retries) {
2217
+ if (this.shouldRetryStatus(method, response.status, conditional) && attempt < this.retries) {
1639
2218
  attempt += 1;
1640
2219
  const retryAfter = parseRetryAfterHeader(response.headers.get("retry-after"));
1641
2220
  const wait = retryAfter !== void 0 ? retryAfter * 1e3 : interval;
@@ -1647,6 +2226,45 @@ var XbergClient = class {
1647
2226
  }
1648
2227
  }
1649
2228
  };
2229
+ /** The `If-Match` header a room write sends: the room version, quoted as an entity tag. */
2230
+ function ifMatch(version) {
2231
+ if (!Number.isSafeInteger(version) || version < 0) throw new ValidationError(`Room version must be a non-negative integer, got ${String(version)}`, {
2232
+ status: 0,
2233
+ body: null
2234
+ });
2235
+ return { "If-Match": `"${version}"` };
2236
+ }
2237
+ /** The per-call bearer an invitation route sends, when the caller supplied a session token. */
2238
+ function sessionBearer(options) {
2239
+ if (options.sessionToken === void 0) return {};
2240
+ if (options.sessionToken.trim().length === 0) throw new ValidationError("sessionToken must not be blank", {
2241
+ status: 0,
2242
+ body: null
2243
+ });
2244
+ return { bearerToken: options.sessionToken };
2245
+ }
2246
+ function decodeEnterpriseHealth(payload) {
2247
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) throw new ValidationError("unexpected /healthz response shape", {
2248
+ status: 200,
2249
+ body: payload
2250
+ });
2251
+ const record = payload;
2252
+ return {
2253
+ ...record,
2254
+ status: typeof record["status"] === "string" ? record["status"] : "",
2255
+ tier: typeof record["tier"] === "string" ? record["tier"] : "",
2256
+ rag: decodeHealthFeature(record["rag"]),
2257
+ auto_tune: decodeHealthFeature(record["auto_tune"]),
2258
+ data_rooms: decodeHealthFeature(record["data_rooms"])
2259
+ };
2260
+ }
2261
+ function decodeHealthFeature(value) {
2262
+ if (typeof value !== "object" || value === null) return { enabled: false };
2263
+ return {
2264
+ ...value,
2265
+ enabled: value["enabled"] === true
2266
+ };
2267
+ }
1650
2268
  function parseJobResponse(payload) {
1651
2269
  if (typeof payload !== "object" || payload === null || Array.isArray(payload)) throw new ValidationError("unexpected job response shape", {
1652
2270
  status: 200,
@@ -1825,7 +2443,67 @@ function prepareDocumentLineage(filenames, ids) {
1825
2443
  }
1826
2444
  return fields;
1827
2445
  }
1828
- //#endregion
1829
- export { AuthError, NotFoundError, RateLimitError, SUCCESS_JOB_STATUSES, ServerError, TERMINAL_JOB_STATUSES, TimeoutError, ValidationError, XbergClient, XbergError, createClient };
2446
+ // src/webhooks.ts
2447
+ /**
2448
+ * Verification of the `X-Webhook-Signature` header on webhook deliveries.
2449
+ *
2450
+ * The header is `t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>`.
2451
+ * Uses WebCrypto (`globalThis.crypto.subtle`) rather than `node:crypto`, so the
2452
+ * same code runs on Node, Deno, Bun, edge runtimes and browsers.
2453
+ */
2454
+ /** The request header that carries the signature. */
2455
+ const WEBHOOK_SIGNATURE_HEADER = "X-Webhook-Signature";
2456
+ /** Default replay window, in seconds, matching the server's. */
2457
+ const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
2458
+ const encoder = new TextEncoder();
2459
+ /**
2460
+ * Verify a webhook delivery's `X-Webhook-Signature` header against its raw body.
2461
+ *
2462
+ * Resolves `true` only when `t` is within `toleranceSeconds` of `now` and some
2463
+ * `v1` element is the HMAC-SHA256 of `"<t>.<body>"` under `secret`. Every `v1`
2464
+ * element is tried, so a sender signing with two secrets during a rotation
2465
+ * still verifies. The digest comparison is constant-time (`crypto.subtle.verify`).
2466
+ *
2467
+ * Pass the body exactly as received — re-serialising parsed JSON changes the
2468
+ * bytes and fails verification.
2469
+ */
2470
+ async function verifyWebhookSignature(secret, header, body, options = {}) {
2471
+ const tolerance = options.toleranceSeconds ?? 300;
2472
+ const now = options.now ?? Math.floor(Date.now() / 1e3);
2473
+ let timestamp;
2474
+ const candidates = [];
2475
+ for (const element of header.split(",")) {
2476
+ const trimmed = element.trim();
2477
+ const eq = trimmed.indexOf("=");
2478
+ if (eq === -1) continue;
2479
+ const key = trimmed.slice(0, eq);
2480
+ const value = trimmed.slice(eq + 1);
2481
+ if (key === "t") timestamp = /^[+-]?\d+$/.test(value) ? Number(value) : void 0;
2482
+ else if (key === "v1") candidates.push(value);
2483
+ }
2484
+ if (timestamp === void 0 || !Number.isSafeInteger(timestamp) || candidates.length === 0) return false;
2485
+ if (!(Math.abs(now - timestamp) <= tolerance)) return false;
2486
+ const key = await crypto.subtle.importKey("raw", encoder.encode(secret), {
2487
+ name: "HMAC",
2488
+ hash: "SHA-256"
2489
+ }, false, ["verify"]);
2490
+ const prefix = encoder.encode(`${timestamp}.`);
2491
+ const bodyBytes = typeof body === "string" ? encoder.encode(body) : body;
2492
+ const signed = new Uint8Array(prefix.length + bodyBytes.length);
2493
+ signed.set(prefix, 0);
2494
+ signed.set(bodyBytes, prefix.length);
2495
+ for (const candidate of candidates) {
2496
+ const expected = decodeHex(candidate);
2497
+ if (expected !== void 0 && await crypto.subtle.verify("HMAC", key, expected, signed)) return true;
2498
+ }
2499
+ return false;
2500
+ }
2501
+ function decodeHex(value) {
2502
+ if (value.length === 0 || value.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(value)) return;
2503
+ const bytes = new Uint8Array(value.length / 2);
2504
+ for (let index = 0; index < bytes.length; index += 1) bytes[index] = Number.parseInt(value.slice(index * 2, index * 2 + 2), 16);
2505
+ return bytes;
2506
+ }
2507
+ export { AuthError, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DataRoomsDisabledError, GatewayTimeoutError, NotFoundError, PreconditionFailedError, PreconditionRequiredError, RateLimitError, RequestTimeoutError, ResultExpiredError, SUCCESS_JOB_STATUSES, ServerError, TERMINAL_JOB_STATUSES, TimeoutError, ValidationError, WEBHOOK_SIGNATURE_HEADER, XbergClient, XbergError, createClient, verifyWebhookSignature };
1830
2508
 
1831
2509
  //# sourceMappingURL=index.js.map