@xberg-io/sdk 0.5.0 → 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 +16 -12
- package/dist/index.d.ts +8768 -1457
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -109
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -120,7 +120,6 @@ function parseRetryAfter(value) {
|
|
|
120
120
|
* {@link FileLike} and {@link BackoffStrategy} are re-exported, via `client.ts`,
|
|
121
121
|
* because they appear in public client signatures.
|
|
122
122
|
*/
|
|
123
|
-
const DEFAULT_ENTERPRISE_BASE_URL = "https://api.xberg.io";
|
|
124
123
|
const DEFAULT_RETRY_BACKOFF_CAP_MS = 3e4;
|
|
125
124
|
const DEFAULT_BACKOFF_FACTOR = 2;
|
|
126
125
|
/**
|
|
@@ -135,15 +134,15 @@ const DEFAULT_BACKOFF_FACTOR = 2;
|
|
|
135
134
|
*/
|
|
136
135
|
const MAX_EVENT_STREAM_FRAME_BYTES = 1 << 20;
|
|
137
136
|
/**
|
|
138
|
-
* Resolve the
|
|
137
|
+
* Resolve the deployer's base URL; neither self-hosted product has a default.
|
|
139
138
|
*/
|
|
140
139
|
function resolveBaseUrl(baseUrl, target) {
|
|
141
|
-
|
|
142
|
-
if (
|
|
140
|
+
const resolved = baseUrl?.replace(/\/+$/, "");
|
|
141
|
+
if (resolved !== void 0 && resolved.length > 0) return resolved;
|
|
142
|
+
throw new XbergError(`${target === "pro" ? "Xberg Pro" : target === "enterprise" ? "Xberg Enterprise" : "Xberg"} has no default base URL; pass baseUrl pointing at your deployment.`, {
|
|
143
143
|
status: 0,
|
|
144
144
|
body: null
|
|
145
145
|
});
|
|
146
|
-
return DEFAULT_ENTERPRISE_BASE_URL;
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
148
|
* Resolve the base URL of the Enterprise control plane, defaulting to the data plane's.
|
|
@@ -350,7 +349,7 @@ const SUCCESS_JOB_STATUSES = ["completed", "partial_success"];
|
|
|
350
349
|
* Package version, synced from the repo-root `VERSION` file by
|
|
351
350
|
* `scripts/sync-versions.py`. Used to build the `User-Agent` header. ~keep
|
|
352
351
|
*/
|
|
353
|
-
const VERSION = "0.
|
|
352
|
+
const VERSION = "0.7.0";
|
|
354
353
|
|
|
355
354
|
//#endregion
|
|
356
355
|
//#region src/client.ts
|
|
@@ -365,8 +364,7 @@ const VERSION = "0.5.0";
|
|
|
365
364
|
* invoked against the wrong tier.
|
|
366
365
|
*
|
|
367
366
|
* Both products authenticate identically: `Authorization: Bearer {apiKey}`.
|
|
368
|
-
*
|
|
369
|
-
* (its spec ships no servers block) and requires an explicit one.
|
|
367
|
+
* Both products are self-hosted and require the deployment's `baseUrl`.
|
|
370
368
|
*
|
|
371
369
|
* Enterprise splits into two binaries — the data plane `baseUrl` addresses and a
|
|
372
370
|
* control plane (projects, API keys, integrations) on its own origin — while Pro
|
|
@@ -386,12 +384,10 @@ const DEFAULT_RETRY_STATUSES = [
|
|
|
386
384
|
];
|
|
387
385
|
const DEFAULT_RETRY_BACKOFF_BASE_MS = 200;
|
|
388
386
|
/**
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* (hyphen). The request and response schemas are identical.
|
|
387
|
+
* ~keep `saved-presets` is an OpenAPI *tag* name, not a route: both specs serve
|
|
388
|
+
* `/v1/saved_presets`, so there is no per-tier spelling to select between.
|
|
392
389
|
*/
|
|
393
|
-
const
|
|
394
|
-
const SAVED_PRESETS_PATH_PRO = "/v1/saved-presets";
|
|
390
|
+
const SAVED_PRESETS_PATH = "/v1/saved_presets";
|
|
395
391
|
const AUTO_TUNE_PATH = "/v1/auto-tune";
|
|
396
392
|
const TUNING_PROFILES_PATH = "/v1/tuning-profiles";
|
|
397
393
|
const ENRICH_PATH = "/v1/enrich";
|
|
@@ -399,6 +395,9 @@ const EXTRACTIONS_PATH = "/v1/extractions";
|
|
|
399
395
|
const DOCUMENTS_PATH = "/v1/documents";
|
|
400
396
|
const JOBS_PATH = "/v1/jobs";
|
|
401
397
|
const CRAWL_JOBS_PATH = "/v1/crawl-jobs";
|
|
398
|
+
const WEBHOOKS_PATH = "/v1/webhooks";
|
|
399
|
+
/** Media type of a raw upload body, and the fallback when a submitted file declares none. */
|
|
400
|
+
const OCTET_STREAM_MEDIA_TYPE = "application/octet-stream";
|
|
402
401
|
/** Media type of the crawl-event stream, sent as `Accept` and served as `Content-Type`. */
|
|
403
402
|
const EVENT_STREAM_MEDIA_TYPE = "text/event-stream";
|
|
404
403
|
/** The `kind` values `CrawlEventV1` declares. A frame carrying anything else is rejected. */
|
|
@@ -409,7 +408,7 @@ const CRAWL_EVENT_KINDS = new Set([
|
|
|
409
408
|
"error"
|
|
410
409
|
]);
|
|
411
410
|
/**
|
|
412
|
-
* High-level dual-target client. Construct with `new XbergClient({ apiKey })`.
|
|
411
|
+
* High-level dual-target client. Construct with `new XbergClient({ baseUrl, apiKey })`.
|
|
413
412
|
*/
|
|
414
413
|
var XbergClient = class {
|
|
415
414
|
baseUrl;
|
|
@@ -431,7 +430,7 @@ var XbergClient = class {
|
|
|
431
430
|
tierProbe;
|
|
432
431
|
/** Underlying `openapi-fetch` client — exposed for advanced use. */
|
|
433
432
|
raw;
|
|
434
|
-
constructor(options
|
|
433
|
+
constructor(options) {
|
|
435
434
|
if (options.target !== void 0) this.target = options.target;
|
|
436
435
|
this.baseUrl = resolveBaseUrl(options.baseUrl, options.target);
|
|
437
436
|
this.controlPlaneBaseUrl = resolveControlPlaneBaseUrl(options.controlPlaneBaseUrl, this.baseUrl);
|
|
@@ -600,7 +599,8 @@ var XbergClient = class {
|
|
|
600
599
|
return await this.backendRequest("GET", `/v1/projects/${encodePathSegment(projectId)}/integrations/${encodePathSegment(integrationId)}/documents`, { params: {
|
|
601
600
|
mime_types: params.mimeTypes,
|
|
602
601
|
folder_id: params.folderId,
|
|
603
|
-
|
|
602
|
+
limit: params.limit,
|
|
603
|
+
offset: params.offset
|
|
604
604
|
} });
|
|
605
605
|
}
|
|
606
606
|
/** Enterprise backend `GET /v1/projects/{id}/integrations/{iid}/documents/{doc_id}`. */
|
|
@@ -686,6 +686,10 @@ var XbergClient = class {
|
|
|
686
686
|
offset: params.offset
|
|
687
687
|
} });
|
|
688
688
|
}
|
|
689
|
+
/** Enterprise backend `GET /v1/projects/{id}/webhooks/{wh_id}/deliveries/{delivery_id}`. */
|
|
690
|
+
async getWebhookDelivery(projectId, webhookId, deliveryId) {
|
|
691
|
+
return await this.backendRequest("GET", `/v1/projects/${encodePathSegment(projectId)}/webhooks/${encodePathSegment(webhookId)}/deliveries/${encodePathSegment(deliveryId)}`);
|
|
692
|
+
}
|
|
689
693
|
/** Enterprise backend `POST /v1/projects/{id}/webhooks/{wh_id}/deliveries/{delivery_id}/retry`. */
|
|
690
694
|
async retryWebhookDelivery(projectId, webhookId, deliveryId) {
|
|
691
695
|
return await this.backendRequest("POST", `/v1/projects/${encodePathSegment(projectId)}/webhooks/${encodePathSegment(webhookId)}/deliveries/${encodePathSegment(deliveryId)}/retry`);
|
|
@@ -735,17 +739,15 @@ var XbergClient = class {
|
|
|
735
739
|
if (documentIds.size > 0) await this.requireTier("enterprise", "extract document lineage");
|
|
736
740
|
const form = new FormData();
|
|
737
741
|
for (const [filename, documentId] of documentIds) form.append(`document_id-${filename}`, documentId);
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
form.append("file", blob, filename);
|
|
741
|
-
}
|
|
742
|
+
const parts = params.files.map(toBlob);
|
|
743
|
+
for (const { blob, filename } of parts) form.append("file", blob, filename);
|
|
742
744
|
if (params.options !== void 0) form.append("options", JSON.stringify(params.options));
|
|
743
745
|
if (params.webhook !== void 0) form.append("webhook", JSON.stringify(params.webhook));
|
|
744
746
|
appendPerFileConfigs(form, filenames, params.configs);
|
|
745
747
|
const body = await this.requestJson("POST", "/v1/extract", { body: form });
|
|
746
748
|
const jobIds = body.job_ids ?? [];
|
|
747
749
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
748
|
-
return
|
|
750
|
+
return parts.map(({ blob, filename }, index) => {
|
|
749
751
|
const id = jobIds[index];
|
|
750
752
|
if (id === void 0) throw new XbergError(`Server returned ${jobIds.length} job IDs for ${params.files.length} files`, {
|
|
751
753
|
status: 500,
|
|
@@ -753,7 +755,8 @@ var XbergClient = class {
|
|
|
753
755
|
});
|
|
754
756
|
return {
|
|
755
757
|
id,
|
|
756
|
-
filename
|
|
758
|
+
filename,
|
|
759
|
+
mime_type: blob.type.length > 0 ? blob.type : OCTET_STREAM_MEDIA_TYPE,
|
|
757
760
|
status: "pending",
|
|
758
761
|
created_at: now
|
|
759
762
|
};
|
|
@@ -915,33 +918,35 @@ var XbergClient = class {
|
|
|
915
918
|
async getRagJob(jobId) {
|
|
916
919
|
return await this.requestJson("GET", `/v1/rag/jobs/${encodePathSegment(jobId)}`);
|
|
917
920
|
}
|
|
918
|
-
/**
|
|
921
|
+
/**
|
|
922
|
+
* List the managed embedding presets this server build ships
|
|
923
|
+
* (`GET /v1/rag/embedding-presets`), in the canonical backend order.
|
|
924
|
+
*/
|
|
925
|
+
async listManagedEmbeddingPresets() {
|
|
926
|
+
return await this.requestJson("GET", "/v1/rag/embedding-presets");
|
|
927
|
+
}
|
|
928
|
+
/** List the project's saved presets (`GET /v1/saved_presets`). */
|
|
919
929
|
async listSavedPresets(params = {}) {
|
|
920
|
-
|
|
921
|
-
return await this.requestJson("GET", path, { params: {
|
|
930
|
+
return await this.requestJson("GET", SAVED_PRESETS_PATH, { params: {
|
|
922
931
|
limit: params.limit,
|
|
923
932
|
offset: params.offset
|
|
924
933
|
} });
|
|
925
934
|
}
|
|
926
|
-
/** Create a saved preset (`POST /v1/saved_presets
|
|
935
|
+
/** Create a saved preset (`POST /v1/saved_presets`). */
|
|
927
936
|
async createSavedPreset(body) {
|
|
928
|
-
|
|
929
|
-
return await this.requestJson("POST", path, { json: body });
|
|
937
|
+
return await this.requestJson("POST", SAVED_PRESETS_PATH, { json: body });
|
|
930
938
|
}
|
|
931
|
-
/** Fetch one saved preset (`GET /v1/saved_presets/{
|
|
939
|
+
/** Fetch one saved preset (`GET /v1/saved_presets/{preset_id}`). */
|
|
932
940
|
async getSavedPreset(presetId) {
|
|
933
|
-
|
|
934
|
-
return await this.requestJson("GET", path);
|
|
941
|
+
return await this.requestJson("GET", this.savedPresetPath(presetId));
|
|
935
942
|
}
|
|
936
|
-
/** Update a saved preset (`PATCH /v1/saved_presets/{
|
|
943
|
+
/** Update a saved preset (`PATCH /v1/saved_presets/{preset_id}`). */
|
|
937
944
|
async updateSavedPreset(presetId, body) {
|
|
938
|
-
|
|
939
|
-
return await this.requestJson("PATCH", path, { json: body });
|
|
945
|
+
return await this.requestJson("PATCH", this.savedPresetPath(presetId), { json: body });
|
|
940
946
|
}
|
|
941
|
-
/** Delete a saved preset (`DELETE /v1/saved_presets/{
|
|
947
|
+
/** Delete a saved preset (`DELETE /v1/saved_presets/{preset_id}`). */
|
|
942
948
|
async deleteSavedPreset(presetId) {
|
|
943
|
-
|
|
944
|
-
await this.requestJson("DELETE", path);
|
|
949
|
+
await this.requestJson("DELETE", this.savedPresetPath(presetId));
|
|
945
950
|
}
|
|
946
951
|
/** List the project's auto-tune jobs (`GET /v1/auto-tune`). */
|
|
947
952
|
async listAutoTuneJobs(params = {}) {
|
|
@@ -979,6 +984,17 @@ var XbergClient = class {
|
|
|
979
984
|
async deleteAutoTuneJob(autoTuneJobId) {
|
|
980
985
|
await this.requestJson("DELETE", this.autoTunePath(autoTuneJobId));
|
|
981
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* Stop a running auto-tune job (`POST /v1/auto-tune/{id}/stop`).
|
|
989
|
+
*
|
|
990
|
+
* The run finishes the trial in flight and then completes with the partial
|
|
991
|
+
* leaderboard, so {@link getAutoTuneResult} still serves the best configuration
|
|
992
|
+
* the search found. Idempotent: a job that already reached a terminal state
|
|
993
|
+
* answers `204` and nothing changes.
|
|
994
|
+
*/
|
|
995
|
+
async stopAutoTuneJob(autoTuneJobId) {
|
|
996
|
+
await this.requestJson("POST", `${this.autoTunePath(autoTuneJobId)}/stop`);
|
|
997
|
+
}
|
|
982
998
|
/** Promote an auto-tune result to a named tuning profile (`POST /v1/auto-tune/{id}/promote`). */
|
|
983
999
|
async promoteAutoTuneProfile(autoTuneJobId, body) {
|
|
984
1000
|
return await this.requestJson("POST", `${this.autoTunePath(autoTuneJobId)}/promote`, { json: body });
|
|
@@ -1002,6 +1018,69 @@ var XbergClient = class {
|
|
|
1002
1018
|
async deleteTuningProfile(profileId) {
|
|
1003
1019
|
await this.requestJson("DELETE", this.tuningProfilePath(profileId));
|
|
1004
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Request presigned upload URLs (`POST /v1/uploads/presign`).
|
|
1023
|
+
*
|
|
1024
|
+
* The request body is typed off the Enterprise schema, whose `config` is a full
|
|
1025
|
+
* `ExtractionConfig`; Pro declares that field as an open object and accepts the
|
|
1026
|
+
* same payload.
|
|
1027
|
+
*/
|
|
1028
|
+
async presignUpload(body) {
|
|
1029
|
+
return await this.requestJson("POST", "/v1/uploads/presign", { json: body });
|
|
1030
|
+
}
|
|
1031
|
+
/** Confirm presigned uploads and start processing (`POST /v1/uploads/confirm`). */
|
|
1032
|
+
async confirmUpload(body) {
|
|
1033
|
+
return await this.requestJson("POST", "/v1/uploads/confirm", { json: body });
|
|
1034
|
+
}
|
|
1035
|
+
/** Fetch usage/metering data for a date window (`GET /v1/usage`). */
|
|
1036
|
+
async usage(params) {
|
|
1037
|
+
const init = params !== void 0 ? { params } : {};
|
|
1038
|
+
return await this.requestJson("GET", "/v1/usage", init);
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Download one rendered page of an extraction job
|
|
1042
|
+
* (`GET /v1/jobs/{job_id}/pages/{page_number}`). The response is a PNG image —
|
|
1043
|
+
* raw bytes, not JSON. `pageNumber` is 1-indexed.
|
|
1044
|
+
*/
|
|
1045
|
+
async getJobPage(jobId, pageNumber) {
|
|
1046
|
+
const path = `${JOBS_PATH}/${encodePathSegment(jobId)}/pages/${encodePathSegment(String(pageNumber))}`;
|
|
1047
|
+
return await this.requestBytes("GET", path);
|
|
1048
|
+
}
|
|
1049
|
+
/** Submit text for enrichment (`POST /v1/enrich`). */
|
|
1050
|
+
async submitEnrich(body) {
|
|
1051
|
+
return await this.requestJson("POST", ENRICH_PATH, { json: body });
|
|
1052
|
+
}
|
|
1053
|
+
/** Fetch an enrichment job's status (`GET /v1/enrich/{job_id}`). */
|
|
1054
|
+
async getEnrichStatus(jobId) {
|
|
1055
|
+
return await this.requestJson("GET", `${ENRICH_PATH}/${encodePathSegment(jobId)}`);
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Stream a crawl job's events (`GET /v1/crawl-jobs/{crawl_job_id}/events`,
|
|
1059
|
+
* Server-Sent Events).
|
|
1060
|
+
*
|
|
1061
|
+
* Returns an `AsyncIterable` of the `kind`-discriminated {@link CrawlEvent}
|
|
1062
|
+
* union; the server closes the stream after the `complete` event.
|
|
1063
|
+
*
|
|
1064
|
+
* ```ts
|
|
1065
|
+
* for await (const event of client.streamCrawlEvents(crawlJobId)) {
|
|
1066
|
+
* if (event.kind === "page") {
|
|
1067
|
+
* console.log(event.url, event.status_code);
|
|
1068
|
+
* }
|
|
1069
|
+
* }
|
|
1070
|
+
* ```
|
|
1071
|
+
*
|
|
1072
|
+
* Nothing is requested until iteration begins, and the response body is
|
|
1073
|
+
* cancelled when iteration ends: on `complete`, on `break`/`return` out of the
|
|
1074
|
+
* loop, on a thrown error, or when `options.signal` aborts. A stream is idle
|
|
1075
|
+
* between events by design, so unlike every other method here it carries no
|
|
1076
|
+
* request timeout and is not routed through the retry engine — a retried
|
|
1077
|
+
* subscription would redeliver every event the caller had already handled.
|
|
1078
|
+
*/
|
|
1079
|
+
streamCrawlEvents(crawlJobId, options = {}) {
|
|
1080
|
+
const path = `${CRAWL_JOBS_PATH}/${encodePathSegment(crawlJobId)}/events`;
|
|
1081
|
+
const open = () => this.openEventStream(path, options.signal);
|
|
1082
|
+
return { [Symbol.asyncIterator]: () => iterateCrawlEvents(open) };
|
|
1083
|
+
}
|
|
1005
1084
|
/** Pro only: fetch the instance's accepted auth methods (`GET /auth/config`). */
|
|
1006
1085
|
async authConfig() {
|
|
1007
1086
|
await this.requireTier("pro", "authConfig");
|
|
@@ -1012,6 +1091,33 @@ var XbergClient = class {
|
|
|
1012
1091
|
await this.requireTier("pro", "login");
|
|
1013
1092
|
return this.requestJson("POST", "/auth/login", { json: body });
|
|
1014
1093
|
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Pro only: read the running instance's license detail (`GET /v1/license`) —
|
|
1096
|
+
* licensee, plan, expiry, grace window and days remaining. Requires an admin
|
|
1097
|
+
* API key or an admin session.
|
|
1098
|
+
*/
|
|
1099
|
+
async getLicenseInfo() {
|
|
1100
|
+
await this.requireTier("pro", "getLicenseInfo");
|
|
1101
|
+
return this.requestJson("GET", "/v1/license");
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Pro only: upload a document's bytes against a presigned local capability
|
|
1105
|
+
* (`PUT /v1/uploads/local/{project_id}/{token}`).
|
|
1106
|
+
*
|
|
1107
|
+
* `projectId` and `token` come from the `upload_url` {@link presignUpload}
|
|
1108
|
+
* returns when the instance stages uploads locally. The capability is one-use,
|
|
1109
|
+
* expiring, and bounded by the size limit recorded when it was issued; the
|
|
1110
|
+
* body is sent as raw bytes.
|
|
1111
|
+
*/
|
|
1112
|
+
async putLocalUpload(projectId, token, file) {
|
|
1113
|
+
await this.requireTier("pro", "putLocalUpload");
|
|
1114
|
+
const { blob } = toBlob(file);
|
|
1115
|
+
const path = `/v1/uploads/local/${encodePathSegment(projectId)}/${encodePathSegment(token)}`;
|
|
1116
|
+
await this.requestJson("PUT", path, {
|
|
1117
|
+
body: new Uint8Array(await blob.arrayBuffer()),
|
|
1118
|
+
headers: { "Content-Type": OCTET_STREAM_MEDIA_TYPE }
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1015
1121
|
/** Pro only: fetch a project's RAG config (`GET /v1/projects/{projectId}/rag-config`). */
|
|
1016
1122
|
async getRagConfig(projectId) {
|
|
1017
1123
|
await this.requireTier("pro", "getRagConfig");
|
|
@@ -1096,7 +1202,8 @@ var XbergClient = class {
|
|
|
1096
1202
|
return this.requestJson("GET", `${this.integrationPath(projectId, integrationId)}/documents`, { params: {
|
|
1097
1203
|
mime_types: params.mimeTypes,
|
|
1098
1204
|
folder_id: params.folderId,
|
|
1099
|
-
|
|
1205
|
+
limit: params.limit,
|
|
1206
|
+
offset: params.offset
|
|
1100
1207
|
} });
|
|
1101
1208
|
}
|
|
1102
1209
|
/**
|
|
@@ -1169,71 +1276,29 @@ var XbergClient = class {
|
|
|
1169
1276
|
} });
|
|
1170
1277
|
}
|
|
1171
1278
|
/**
|
|
1172
|
-
* Enterprise only:
|
|
1173
|
-
* (`GET /v1/
|
|
1174
|
-
*
|
|
1279
|
+
* Enterprise only: list a webhook subscription's delivery attempts
|
|
1280
|
+
* (`GET /v1/webhooks/{webhook_id}/deliveries`). Metadata only — call
|
|
1281
|
+
* {@link getSubscriptionDelivery} for an attempt's payload previews.
|
|
1282
|
+
*
|
|
1283
|
+
* ~keep Distinct from {@link listWebhookDeliveries}, which reads the same
|
|
1284
|
+
* history through the control plane's project-scoped route.
|
|
1175
1285
|
*/
|
|
1176
|
-
async
|
|
1177
|
-
await this.requireTier("enterprise", "
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
async submitEnrich(body) {
|
|
1183
|
-
await this.requireTier("enterprise", "submitEnrich");
|
|
1184
|
-
return this.requestJson("POST", ENRICH_PATH, { json: body });
|
|
1185
|
-
}
|
|
1186
|
-
/** Enterprise only: fetch an enrichment job's status (`GET /v1/enrich/{jobId}`). */
|
|
1187
|
-
async getEnrichStatus(jobId) {
|
|
1188
|
-
await this.requireTier("enterprise", "getEnrichStatus");
|
|
1189
|
-
return this.requestJson("GET", `${ENRICH_PATH}/${encodePathSegment(jobId)}`);
|
|
1286
|
+
async listSubscriptionDeliveries(webhookId, params = {}) {
|
|
1287
|
+
await this.requireTier("enterprise", "listSubscriptionDeliveries");
|
|
1288
|
+
return this.requestJson("GET", this.webhookDeliveriesPath(webhookId), { params: {
|
|
1289
|
+
limit: params.limit,
|
|
1290
|
+
offset: params.offset
|
|
1291
|
+
} });
|
|
1190
1292
|
}
|
|
1191
1293
|
/**
|
|
1192
|
-
* Enterprise only:
|
|
1193
|
-
* (`GET /v1/
|
|
1194
|
-
*
|
|
1195
|
-
* Returns an `AsyncIterable` of the `kind`-discriminated {@link CrawlEvent}
|
|
1196
|
-
* union; the server closes the stream after the `complete` event.
|
|
1197
|
-
*
|
|
1198
|
-
* ```ts
|
|
1199
|
-
* for await (const event of client.streamCrawlEvents(crawlJobId)) {
|
|
1200
|
-
* if (event.kind === "page") {
|
|
1201
|
-
* console.log(event.url, event.status_code);
|
|
1202
|
-
* }
|
|
1203
|
-
* }
|
|
1204
|
-
* ```
|
|
1205
|
-
*
|
|
1206
|
-
* Nothing is requested — not even the `/healthz` tier probe — until
|
|
1207
|
-
* iteration begins, and the response body is cancelled when iteration ends:
|
|
1208
|
-
* on `complete`, on `break`/`return` out of the loop, on a thrown error, or
|
|
1209
|
-
* when `options.signal` aborts. A stream is idle between events by design,
|
|
1210
|
-
* so unlike every other method here it carries no request timeout and is not
|
|
1211
|
-
* routed through the retry engine — a retried subscription would redeliver
|
|
1212
|
-
* every event the caller had already handled.
|
|
1294
|
+
* Enterprise only: fetch one delivery attempt with its bounded request and
|
|
1295
|
+
* response previews (`GET /v1/webhooks/{webhook_id}/deliveries/{delivery_id}`).
|
|
1296
|
+
* The previews can carry project document content.
|
|
1213
1297
|
*/
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
return this.openEventStream(path, options.signal);
|
|
1219
|
-
};
|
|
1220
|
-
return { [Symbol.asyncIterator]: () => iterateCrawlEvents(open) };
|
|
1221
|
-
}
|
|
1222
|
-
/** Enterprise only: request a presigned upload URL (`POST /v1/uploads/presign`). */
|
|
1223
|
-
async presignUpload(body) {
|
|
1224
|
-
await this.requireTier("enterprise", "presignUpload");
|
|
1225
|
-
return this.requestJson("POST", "/v1/uploads/presign", { json: body });
|
|
1226
|
-
}
|
|
1227
|
-
/** Enterprise only: confirm a presigned upload (`POST /v1/uploads/confirm`). */
|
|
1228
|
-
async confirmUpload(body) {
|
|
1229
|
-
await this.requireTier("enterprise", "confirmUpload");
|
|
1230
|
-
return this.requestJson("POST", "/v1/uploads/confirm", { json: body });
|
|
1231
|
-
}
|
|
1232
|
-
/** Enterprise only: fetch usage/metering data (`GET /v1/usage`). */
|
|
1233
|
-
async usage(params) {
|
|
1234
|
-
await this.requireTier("enterprise", "usage");
|
|
1235
|
-
const init = params !== void 0 ? { params } : {};
|
|
1236
|
-
return this.requestJson("GET", "/v1/usage", init);
|
|
1298
|
+
async getSubscriptionDelivery(webhookId, deliveryId) {
|
|
1299
|
+
await this.requireTier("enterprise", "getSubscriptionDelivery");
|
|
1300
|
+
const path = `${this.webhookDeliveriesPath(webhookId)}/${encodePathSegment(deliveryId)}`;
|
|
1301
|
+
return this.requestJson("GET", path);
|
|
1237
1302
|
}
|
|
1238
1303
|
/** Build `/v1/projects/{projectId}` with the id percent-encoded. */
|
|
1239
1304
|
projectPath(projectId) {
|
|
@@ -1247,6 +1312,10 @@ var XbergClient = class {
|
|
|
1247
1312
|
documentPath(documentId) {
|
|
1248
1313
|
return `${DOCUMENTS_PATH}/${encodePathSegment(documentId)}`;
|
|
1249
1314
|
}
|
|
1315
|
+
/** Build `/v1/saved_presets/{preset_id}` with the id percent-encoded. */
|
|
1316
|
+
savedPresetPath(presetId) {
|
|
1317
|
+
return `${SAVED_PRESETS_PATH}/${encodePathSegment(presetId)}`;
|
|
1318
|
+
}
|
|
1250
1319
|
/** Build `/v1/auto-tune/{id}` with the id percent-encoded. */
|
|
1251
1320
|
autoTunePath(autoTuneJobId) {
|
|
1252
1321
|
return `${AUTO_TUNE_PATH}/${encodePathSegment(autoTuneJobId)}`;
|
|
@@ -1255,14 +1324,9 @@ var XbergClient = class {
|
|
|
1255
1324
|
tuningProfilePath(profileId) {
|
|
1256
1325
|
return `${TUNING_PROFILES_PATH}/${encodePathSegment(profileId)}`;
|
|
1257
1326
|
}
|
|
1258
|
-
/**
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
* `presetId` for the single-preset routes.
|
|
1262
|
-
*/
|
|
1263
|
-
async savedPresetsPath(presetId) {
|
|
1264
|
-
const base = await this.resolveTier() === "pro" ? SAVED_PRESETS_PATH_PRO : SAVED_PRESETS_PATH_ENTERPRISE;
|
|
1265
|
-
return presetId === void 0 ? base : `${base}/${encodePathSegment(presetId)}`;
|
|
1327
|
+
/** Build `/v1/webhooks/{webhook_id}/deliveries` with the id percent-encoded. */
|
|
1328
|
+
webhookDeliveriesPath(webhookId) {
|
|
1329
|
+
return `${WEBHOOKS_PATH}/${encodePathSegment(webhookId)}/deliveries`;
|
|
1266
1330
|
}
|
|
1267
1331
|
/**
|
|
1268
1332
|
* Return the effective tier — an explicit `target` if set, else probed from
|
|
@@ -1587,14 +1651,14 @@ async function* iterateCrawlEvents(open) {
|
|
|
1587
1651
|
await reader.cancel().catch(() => void 0);
|
|
1588
1652
|
}
|
|
1589
1653
|
}
|
|
1590
|
-
function createClient(options
|
|
1654
|
+
function createClient(options) {
|
|
1591
1655
|
const headers = {
|
|
1592
1656
|
"User-Agent": USER_AGENT,
|
|
1593
1657
|
...options.headers
|
|
1594
1658
|
};
|
|
1595
1659
|
if (options.apiKey !== void 0) headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
1596
1660
|
return createOpenApiClient({
|
|
1597
|
-
baseUrl: options.baseUrl
|
|
1661
|
+
baseUrl: resolveBaseUrl(options.baseUrl, void 0),
|
|
1598
1662
|
headers,
|
|
1599
1663
|
...options.fetch !== void 0 ? { fetch: options.fetch } : {}
|
|
1600
1664
|
});
|