@xberg-io/sdk 0.6.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 +4 -5
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.6.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
|
|
@@ -410,7 +408,7 @@ const CRAWL_EVENT_KINDS = new Set([
|
|
|
410
408
|
"error"
|
|
411
409
|
]);
|
|
412
410
|
/**
|
|
413
|
-
* High-level dual-target client. Construct with `new XbergClient({ apiKey })`.
|
|
411
|
+
* High-level dual-target client. Construct with `new XbergClient({ baseUrl, apiKey })`.
|
|
414
412
|
*/
|
|
415
413
|
var XbergClient = class {
|
|
416
414
|
baseUrl;
|
|
@@ -432,7 +430,7 @@ var XbergClient = class {
|
|
|
432
430
|
tierProbe;
|
|
433
431
|
/** Underlying `openapi-fetch` client — exposed for advanced use. */
|
|
434
432
|
raw;
|
|
435
|
-
constructor(options
|
|
433
|
+
constructor(options) {
|
|
436
434
|
if (options.target !== void 0) this.target = options.target;
|
|
437
435
|
this.baseUrl = resolveBaseUrl(options.baseUrl, options.target);
|
|
438
436
|
this.controlPlaneBaseUrl = resolveControlPlaneBaseUrl(options.controlPlaneBaseUrl, this.baseUrl);
|
|
@@ -1653,14 +1651,14 @@ async function* iterateCrawlEvents(open) {
|
|
|
1653
1651
|
await reader.cancel().catch(() => void 0);
|
|
1654
1652
|
}
|
|
1655
1653
|
}
|
|
1656
|
-
function createClient(options
|
|
1654
|
+
function createClient(options) {
|
|
1657
1655
|
const headers = {
|
|
1658
1656
|
"User-Agent": USER_AGENT,
|
|
1659
1657
|
...options.headers
|
|
1660
1658
|
};
|
|
1661
1659
|
if (options.apiKey !== void 0) headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
1662
1660
|
return createOpenApiClient({
|
|
1663
|
-
baseUrl: options.baseUrl
|
|
1661
|
+
baseUrl: resolveBaseUrl(options.baseUrl, void 0),
|
|
1664
1662
|
headers,
|
|
1665
1663
|
...options.fetch !== void 0 ? { fetch: options.fetch } : {}
|
|
1666
1664
|
});
|