@xberg-io/sdk 0.10.0 → 0.12.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
@@ -473,7 +473,7 @@ const SUCCESS_JOB_STATUSES = ["completed", "partial_success"];
473
473
  * and defaults to `baseUrl`. The backend methods use that origin and an optional
474
474
  * separate `controlPlaneToken`; existing Pro methods retain their data-plane routing.
475
475
  */
476
- const USER_AGENT = `xberg-io-sdk-typescript/0.10.0`;
476
+ const USER_AGENT = `xberg-io-sdk-typescript/0.12.0`;
477
477
  const DEFAULT_TIMEOUT_MS = 3e4;
478
478
  const DEFAULT_POLL_INTERVAL_MS = 1e3;
479
479
  const DEFAULT_WAIT_TIMEOUT_MS = 3e5;
@@ -672,6 +672,10 @@ var XbergClient = class {
672
672
  async backendCreateApiKey(projectId, body) {
673
673
  return await this.backendRequest("POST", `/v1/projects/${encodePathSegment(projectId)}/api-keys`, { json: body });
674
674
  }
675
+ /** Enterprise backend: issue an API key restricted to a custom project role. */
676
+ async backendCreateRoleBoundApiKey(projectId, body) {
677
+ return await this.backendRequest("POST", `${this.projectPath(projectId)}/api-keys/role-bound`, { json: body });
678
+ }
675
679
  /** Enterprise backend `DELETE /v1/projects/{id}/api-keys/{key_id}`. */
676
680
  async backendRevokeApiKey(projectId, apiKeyId) {
677
681
  return await this.backendRequest("DELETE", `/v1/projects/${encodePathSegment(projectId)}/api-keys/${encodePathSegment(apiKeyId)}`);
@@ -839,11 +843,23 @@ var XbergClient = class {
839
843
  }
840
844
  /** Enterprise backend `PUT /v1/projects/{project_id}/saml/providers/{provider_id}`. */
841
845
  async updateSamlProvider(projectId, providerId, body) {
842
- return await this.backendRequest("PUT", `/v1/projects/${encodePathSegment(projectId)}/saml/providers/${encodePathSegment(providerId)}`, { json: body });
846
+ return await this.backendRequest("PUT", this.samlProviderPath(projectId, providerId), { json: body });
847
+ }
848
+ /** Enterprise backend: replace a SAML provider's attribute mapping. */
849
+ async updateSamlAttributeMapping(projectId, providerId, body) {
850
+ return await this.backendRequest("PATCH", `${this.samlProviderPath(projectId, providerId)}/attribute-mapping`, { json: body });
851
+ }
852
+ /** Enterprise backend: start a SAML test and return its browser redirect. */
853
+ async startSamlConnectionTest(projectId, providerId) {
854
+ return await this.backendRequest("POST", `${this.samlProviderPath(projectId, providerId)}/test`);
855
+ }
856
+ /** Enterprise backend: check the status of a SAML connection test. */
857
+ async getSamlConnectionTestStatus(projectId, providerId, testId) {
858
+ return await this.backendRequest("GET", `${this.samlProviderPath(projectId, providerId)}/test/${encodePathSegment(testId)}`);
843
859
  }
844
860
  /** Enterprise backend `DELETE /v1/projects/{project_id}/saml/providers/{provider_id}`. */
845
861
  async deleteSamlProvider(projectId, providerId) {
846
- return await this.backendRequest("DELETE", `/v1/projects/${encodePathSegment(projectId)}/saml/providers/${encodePathSegment(providerId)}`);
862
+ return await this.backendRequest("DELETE", this.samlProviderPath(projectId, providerId));
847
863
  }
848
864
  /** Enterprise backend `POST /v1/projects/{id}/sandbox/extract`. */
849
865
  async sandboxExtract(projectId, params) {
@@ -869,6 +885,10 @@ var XbergClient = class {
869
885
  async rotateScimConnectionSecret(projectId, connectionId) {
870
886
  return await this.backendRequest("POST", `/v1/projects/${encodePathSegment(projectId)}/scim/connections/${encodePathSegment(connectionId)}/rotate`);
871
887
  }
888
+ /** Enterprise backend: revoke a SCIM connection. */
889
+ async revokeScimConnection(projectId, connectionId) {
890
+ return await this.backendRequest("POST", `${this.projectPath(projectId)}/scim/connections/${encodePathSegment(connectionId)}/revoke`);
891
+ }
872
892
  /** Enterprise backend `GET /v1/projects/{id}/usage`. */
873
893
  async getUsage(projectId, params) {
874
894
  return await this.backendRequest("GET", `/v1/projects/${encodePathSegment(projectId)}/usage`, { params: {
@@ -955,7 +975,7 @@ var XbergClient = class {
955
975
  const documentIds = prepareDocumentLineage(filenames, params.documentIds);
956
976
  if (documentIds.size > 0) await this.requireTier("enterprise", "extract document lineage");
957
977
  if (params.projectId !== void 0) await this.requireTier("pro", "projectId");
958
- const projectHeader = Object.keys(this.headers).find((name) => name.toLowerCase() === "x-project-id") ?? "X-Project-ID";
978
+ const projectHeader = this.projectHeaderName();
959
979
  const form = new FormData();
960
980
  for (const [filename, documentId] of documentIds) form.append(`document_id-${filename}`, documentId);
961
981
  const parts = params.files.map(toBlob);
@@ -1112,6 +1132,18 @@ var XbergClient = class {
1112
1132
  async deleteRagCollection(name) {
1113
1133
  await this.requestJson("DELETE", `/v1/rag/collections/${encodePathSegment(name)}`);
1114
1134
  }
1135
+ /** List the documents in a RAG collection, using the returned cursor for the next page. */
1136
+ async listRagDocuments(name, params = {}) {
1137
+ const { limit, cursor, projectId } = params;
1138
+ if (projectId !== void 0) await this.requireTier("pro", "projectId");
1139
+ return await this.requestJson("GET", `/v1/rag/collections/${encodePathSegment(name)}/documents`, {
1140
+ params: {
1141
+ limit,
1142
+ cursor
1143
+ },
1144
+ ...projectId !== void 0 ? { headers: { [this.projectHeaderName()]: projectId } } : {}
1145
+ });
1146
+ }
1115
1147
  /** Add documents to a RAG collection (`POST /v1/rag/collections/{name}/documents`). */
1116
1148
  async addRagDocuments(name, body) {
1117
1149
  return await this.requestJson("POST", `/v1/rag/collections/${encodePathSegment(name)}/documents`, { json: body });
@@ -1275,6 +1307,11 @@ var XbergClient = class {
1275
1307
  const path = `${JOBS_PATH}/${encodePathSegment(jobId)}/pages/${encodePathSegment(String(pageNumber))}`;
1276
1308
  return await this.requestBytes("GET", path, { params: await this.jobScope(scope) });
1277
1309
  }
1310
+ /** Pro only: list the available rendered page numbers for an extraction job. */
1311
+ async getJobPageInventory(jobId, scope = {}) {
1312
+ await this.requireTier("pro", "getJobPageInventory");
1313
+ return await this.requestJson("GET", `${JOBS_PATH}/${encodePathSegment(jobId)}/pages`, { params: { project_id: scope.projectId } });
1314
+ }
1278
1315
  /** Submit text for enrichment (`POST /v1/enrich`). */
1279
1316
  async submitEnrich(body, scope = {}) {
1280
1317
  return await this.requestJson("POST", ENRICH_PATH, {
@@ -1390,6 +1427,42 @@ var XbergClient = class {
1390
1427
  await this.requireTier("pro", "createProject");
1391
1428
  return this.requestJson("POST", "/v1/projects", { json: body });
1392
1429
  }
1430
+ /** Pro only: read a live project visible to the caller. */
1431
+ async proGetProject(projectId) {
1432
+ await this.requireTier("pro", "proGetProject");
1433
+ return this.requestJson("GET", this.projectPath(projectId));
1434
+ }
1435
+ /** Pro only: rename a project. */
1436
+ async proUpdateProject(projectId, body) {
1437
+ await this.requireTier("pro", "proUpdateProject");
1438
+ return this.requestJson("PATCH", this.projectPath(projectId), { json: body });
1439
+ }
1440
+ /** Pro only: soft-delete a project and revoke its API keys. */
1441
+ async proDeleteProject(projectId) {
1442
+ await this.requireTier("pro", "proDeleteProject");
1443
+ await this.requestJson("DELETE", this.projectPath(projectId));
1444
+ }
1445
+ /** Enterprise only: read the project's stored extraction defaults. */
1446
+ async getProjectExtractionConfig(projectId) {
1447
+ await this.requireTier("enterprise", "getProjectExtractionConfig");
1448
+ const projectHeader = this.projectHeaderName();
1449
+ return this.requestJson("GET", `${this.projectPath(projectId)}/extraction-config`, { headers: { [projectHeader]: projectId } });
1450
+ }
1451
+ /** Enterprise only: replace the project's stored extraction defaults. */
1452
+ async setProjectExtractionConfig(projectId, body) {
1453
+ await this.requireTier("enterprise", "setProjectExtractionConfig");
1454
+ const projectHeader = this.projectHeaderName();
1455
+ return this.requestJson("PUT", `${this.projectPath(projectId)}/extraction-config`, {
1456
+ headers: { [projectHeader]: projectId },
1457
+ json: body
1458
+ });
1459
+ }
1460
+ /** Enterprise only: clear the project's stored extraction defaults. */
1461
+ async clearProjectExtractionConfig(projectId) {
1462
+ await this.requireTier("enterprise", "clearProjectExtractionConfig");
1463
+ const projectHeader = this.projectHeaderName();
1464
+ await this.requestJson("DELETE", `${this.projectPath(projectId)}/extraction-config`, { headers: { [projectHeader]: projectId } });
1465
+ }
1393
1466
  /** Pro only: list a project's API keys (`GET /v1/projects/{projectId}/api-keys`). */
1394
1467
  async listApiKeys(projectId, params = {}) {
1395
1468
  await this.requireTier("pro", "listApiKeys");
@@ -1436,6 +1509,11 @@ var XbergClient = class {
1436
1509
  await this.requireTier("pro", "setIntegrationSync");
1437
1510
  await this.requestJson("PUT", `${this.integrationPath(projectId, integrationId)}/sync`, { json: body });
1438
1511
  }
1512
+ /** Pro only: permanently bind an integration to a RAG collection in the same project. */
1513
+ async bindIntegrationRagTarget(projectId, integrationId, body) {
1514
+ await this.requireTier("pro", "bindIntegrationRagTarget");
1515
+ await this.requestJson("PUT", `${this.integrationPath(projectId, integrationId)}/sync/rag-target`, { json: body });
1516
+ }
1439
1517
  /** Pro only: delete an integration (`DELETE .../integrations/{integrationId}`). */
1440
1518
  async deleteIntegration(projectId, integrationId) {
1441
1519
  await this.requireTier("pro", "deleteIntegration");
@@ -1755,6 +1833,41 @@ var XbergClient = class {
1755
1833
  await this.requireTier("enterprise", "transferRoomOwnership");
1756
1834
  await this.requestJson("POST", `${this.roomPath(roomId)}/ownership`, { json: body });
1757
1835
  }
1836
+ /** Enterprise only: list a data room's share links. */
1837
+ async listRoomLinks(roomId, params = {}) {
1838
+ await this.requireTier("enterprise", "listRoomLinks");
1839
+ return this.requestJson("GET", `${this.roomPath(roomId)}/links`, { params: {
1840
+ limit: params.limit,
1841
+ offset: params.offset
1842
+ } });
1843
+ }
1844
+ /** Enterprise only: update link access using the room's last observed version. */
1845
+ async setRoomLinkAccess(roomId, body, version) {
1846
+ await this.requireTier("enterprise", "setRoomLinkAccess");
1847
+ return this.requestJson("PUT", `${this.roomPath(roomId)}/links`, {
1848
+ json: body,
1849
+ headers: ifMatch(version)
1850
+ });
1851
+ }
1852
+ /** Enterprise only: create a share link for a data room. */
1853
+ async createRoomLink(roomId, body) {
1854
+ await this.requireTier("enterprise", "createRoomLink");
1855
+ return this.requestJson("POST", `${this.roomPath(roomId)}/links`, { json: body });
1856
+ }
1857
+ /** Enterprise only: revoke a data room share link and its grants. */
1858
+ async revokeRoomLink(roomId, linkId) {
1859
+ await this.requireTier("enterprise", "revokeRoomLink");
1860
+ await this.requestJson("DELETE", `${this.roomPath(roomId)}/links/${encodePathSegment(linkId)}`);
1861
+ }
1862
+ /** Enterprise only: accept a share link with a signed-in user's session. */
1863
+ async acceptRoomLink(body, options = {}) {
1864
+ const bearer = sessionBearer(options);
1865
+ await this.requireTier("enterprise", "acceptRoomLink");
1866
+ return this.requestJson("POST", "/v1/room-links/accept", {
1867
+ json: body,
1868
+ ...bearer
1869
+ });
1870
+ }
1758
1871
  /**
1759
1872
  * Enterprise only: list a room's invitations (`GET /v1/rooms/{id}/invitations`).
1760
1873
  * The answer never carries an invitation token.
@@ -1885,6 +1998,9 @@ var XbergClient = class {
1885
1998
  if (scope.projectId !== void 0) await this.requireTier("pro", "projectId");
1886
1999
  return { project_id: scope.projectId };
1887
2000
  }
2001
+ projectHeaderName() {
2002
+ return Object.keys(this.headers).find((name) => name.toLowerCase() === "x-project-id") ?? "X-Project-ID";
2003
+ }
1888
2004
  /** Build `/v1/projects/{projectId}` with the id percent-encoded. */
1889
2005
  projectPath(projectId) {
1890
2006
  return `/v1/projects/${encodePathSegment(projectId)}`;
@@ -1893,6 +2009,9 @@ var XbergClient = class {
1893
2009
  integrationPath(projectId, integrationId) {
1894
2010
  return `${this.projectPath(projectId)}/integrations/${encodePathSegment(integrationId)}`;
1895
2011
  }
2012
+ samlProviderPath(projectId, providerId) {
2013
+ return `${this.projectPath(projectId)}/saml/providers/${encodePathSegment(providerId)}`;
2014
+ }
1896
2015
  /** Build `/v1/documents/{documentId}` with the id percent-encoded. */
1897
2016
  documentPath(documentId) {
1898
2017
  return `${DOCUMENTS_PATH}/${encodePathSegment(documentId)}`;