@bisibility/sdk 0.6.0 → 0.7.1
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/CHANGELOG.md +22 -0
- package/README.md +77 -64
- package/dist/api-version.d.ts +4 -0
- package/dist/api-version.d.ts.map +1 -0
- package/dist/api-version.js +4 -0
- package/dist/api-version.js.map +1 -0
- package/dist/client.d.ts +156 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +267 -5
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/public-id-contract.d.ts.map +1 -1
- package/dist/public-id-contract.js +3 -0
- package/dist/public-id-contract.js.map +1 -1
- package/dist/resources.d.ts +197 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +278 -0
- package/dist/resources.js.map +1 -0
- package/dist/types.d.ts +58 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +14 -3
package/dist/client.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BISIBILITY_API_VERSION, BISIBILITY_API_VERSION_HEADER, UNSUPPORTED_API_VERSION_PROBLEM_TYPE, } from "./api-version.js";
|
|
2
|
+
import { BisibilityApiError, BisibilityApiVersionError, BisibilityConfigurationError, BisibilityNetworkError, BisibilityResponseError, isUnsupportedApiVersionProblem, } from "./errors.js";
|
|
2
3
|
import { iterateCursorPagination } from "./pagination.js";
|
|
3
4
|
import { validatePublicIdRequest, validatePublicIdResponse } from "./public-id-contract.js";
|
|
4
5
|
import { isPublicIdOfType } from "./public-id.js";
|
|
6
|
+
import { installResourceNamespaces } from "./resources.js";
|
|
5
7
|
import { SDK_VERSION } from "./version.js";
|
|
6
8
|
const DEFAULT_BASE_URL = "https://bisibility.com/api/v1";
|
|
7
9
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -41,6 +43,24 @@ function stringOrUndefined(value) {
|
|
|
41
43
|
function numberOrUndefined(value) {
|
|
42
44
|
return typeof value === "number" ? value : undefined;
|
|
43
45
|
}
|
|
46
|
+
function apiVersionErrorDetails(problem) {
|
|
47
|
+
if (!problem?.errors || typeof problem.errors !== "object") {
|
|
48
|
+
return {
|
|
49
|
+
declaredApiVersion: BISIBILITY_API_VERSION,
|
|
50
|
+
serverApiVersions: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const errors = problem.errors;
|
|
54
|
+
const serverApiVersions = Array.isArray(errors.apiVersions)
|
|
55
|
+
? errors.apiVersions.filter((version) => typeof version === "string")
|
|
56
|
+
: [];
|
|
57
|
+
return {
|
|
58
|
+
declaredApiVersion: typeof errors.declaredApiVersion === "string"
|
|
59
|
+
? errors.declaredApiVersion
|
|
60
|
+
: BISIBILITY_API_VERSION,
|
|
61
|
+
serverApiVersions,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
44
64
|
function problemFromJson(value) {
|
|
45
65
|
if (!value || typeof value !== "object") {
|
|
46
66
|
return undefined;
|
|
@@ -163,6 +183,7 @@ function validateCredential(value) {
|
|
|
163
183
|
}
|
|
164
184
|
}
|
|
165
185
|
export class BisibilityClient {
|
|
186
|
+
#apiVersionPreflight;
|
|
166
187
|
#apiKey;
|
|
167
188
|
#defaultHeaders;
|
|
168
189
|
#fetchImpl;
|
|
@@ -182,19 +203,44 @@ export class BisibilityClient {
|
|
|
182
203
|
this.#maxRetries = validatedMaxRetries(config.maxRetries);
|
|
183
204
|
this.#projectId = config.projectId;
|
|
184
205
|
this.#timeout = validatedTimeout(config.timeout);
|
|
206
|
+
installResourceNamespaces(this);
|
|
185
207
|
}
|
|
208
|
+
/** @deprecated Use `client.system.getHealth()`. */
|
|
186
209
|
getHealth(options) {
|
|
187
|
-
return this.request("GET", "/health", {
|
|
210
|
+
return this.request("GET", "/health", {
|
|
211
|
+
...options,
|
|
212
|
+
acceptedStatuses: [503],
|
|
213
|
+
auth: false,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/** @deprecated Use `client.system.getLiveness()`. */
|
|
217
|
+
getLiveness(options) {
|
|
218
|
+
return this.request("GET", "/liveness", { ...options, auth: false });
|
|
219
|
+
}
|
|
220
|
+
/** @deprecated Use `client.system.getReadiness()`. */
|
|
221
|
+
getReadiness(options) {
|
|
222
|
+
return this.request("GET", "/readiness", {
|
|
223
|
+
...options,
|
|
224
|
+
acceptedStatuses: [503],
|
|
225
|
+
auth: false,
|
|
226
|
+
});
|
|
188
227
|
}
|
|
228
|
+
/** @deprecated Use `client.system.getOpenApi()`. */
|
|
189
229
|
getOpenApi(options) {
|
|
190
230
|
return this.request("GET", "/openapi.json", { ...options, auth: false });
|
|
191
231
|
}
|
|
192
|
-
getCapabilities(
|
|
193
|
-
|
|
232
|
+
/** @deprecated Use `client.system.getCapabilities()`. */
|
|
233
|
+
async getCapabilities(options) {
|
|
234
|
+
const response = await this.request("GET", "/capabilities", {
|
|
194
235
|
...options,
|
|
195
236
|
auth: false,
|
|
237
|
+
skipApiVersionPreflight: true,
|
|
196
238
|
});
|
|
239
|
+
this.assertApiVersionCompatible(response);
|
|
240
|
+
this.#apiVersionPreflight ??= Promise.resolve();
|
|
241
|
+
return response;
|
|
197
242
|
}
|
|
243
|
+
/** @deprecated Use `client.system.getLlmsText()`. */
|
|
198
244
|
getLlmsText(options) {
|
|
199
245
|
return this.request("GET", "/llms.txt", {
|
|
200
246
|
...options,
|
|
@@ -202,12 +248,14 @@ export class BisibilityClient {
|
|
|
202
248
|
parseAs: "text",
|
|
203
249
|
});
|
|
204
250
|
}
|
|
251
|
+
/** @deprecated Use `client.pricing.getRates()`. */
|
|
205
252
|
getProviderRates(options) {
|
|
206
253
|
return this.request("GET", "/provider-rates", {
|
|
207
254
|
...options,
|
|
208
255
|
auth: false,
|
|
209
256
|
});
|
|
210
257
|
}
|
|
258
|
+
/** @deprecated Use `client.pricing.estimate()`. */
|
|
211
259
|
getCostEstimate(input, options) {
|
|
212
260
|
return this.request("GET", "/cost-estimate", {
|
|
213
261
|
...options,
|
|
@@ -223,6 +271,7 @@ export class BisibilityClient {
|
|
|
223
271
|
},
|
|
224
272
|
});
|
|
225
273
|
}
|
|
274
|
+
/** @deprecated Use `client.locations.search()`. */
|
|
226
275
|
searchLocations(input, options) {
|
|
227
276
|
return this.request("GET", "/locations/search", {
|
|
228
277
|
...options,
|
|
@@ -233,48 +282,60 @@ export class BisibilityClient {
|
|
|
233
282
|
},
|
|
234
283
|
});
|
|
235
284
|
}
|
|
285
|
+
/** @deprecated Use `client.account.get()`. */
|
|
236
286
|
getMe(options) {
|
|
237
287
|
return this.request("GET", "/me", options);
|
|
238
288
|
}
|
|
289
|
+
/** @deprecated Use `client.account.update()`. */
|
|
239
290
|
updateMe(input, options) {
|
|
240
291
|
return this.request("PATCH", "/me", { ...options, body: input });
|
|
241
292
|
}
|
|
293
|
+
/** @deprecated Use `client.account.tokens.list()`. */
|
|
242
294
|
listMyTokens(options) {
|
|
243
295
|
return this.request("GET", "/me/tokens", options);
|
|
244
296
|
}
|
|
297
|
+
/** @deprecated Use `client.account.tokens.create()`. */
|
|
245
298
|
createMyToken(input, options) {
|
|
246
299
|
return this.request("POST", "/me/tokens", {
|
|
247
300
|
...options,
|
|
248
301
|
body: input,
|
|
249
302
|
});
|
|
250
303
|
}
|
|
304
|
+
/** @deprecated Use `client.account.tokens.revoke()`. */
|
|
251
305
|
revokeMyToken(tokenId, options) {
|
|
252
306
|
return this.request("DELETE", `/me/tokens/${encodedPathSegment(tokenId)}`, options);
|
|
253
307
|
}
|
|
308
|
+
/** @deprecated Use `client.projects.list()`. */
|
|
254
309
|
listProjects(options) {
|
|
255
310
|
return this.request("GET", "/projects", options);
|
|
256
311
|
}
|
|
312
|
+
/** @deprecated Use `client.projects.create()`. */
|
|
257
313
|
createProject(input, options) {
|
|
258
314
|
return this.request("POST", "/projects", {
|
|
259
315
|
...options,
|
|
260
316
|
body: input,
|
|
261
317
|
});
|
|
262
318
|
}
|
|
319
|
+
/** @deprecated Use `client.projects.get()`. */
|
|
263
320
|
getProject(projectId, options) {
|
|
264
321
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}`, options);
|
|
265
322
|
}
|
|
323
|
+
/** @deprecated Use `client.projects.update()`. */
|
|
266
324
|
updateProject(projectId, input, options) {
|
|
267
325
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}`, {
|
|
268
326
|
...options,
|
|
269
327
|
body: input,
|
|
270
328
|
});
|
|
271
329
|
}
|
|
330
|
+
/** @deprecated Use `client.projects.delete()`. */
|
|
272
331
|
deleteProject(projectId, options) {
|
|
273
332
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}`, options);
|
|
274
333
|
}
|
|
334
|
+
/** @deprecated Use `client.projects.getDefaults()`. */
|
|
275
335
|
getProjectDefaults(projectId, options) {
|
|
276
336
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/defaults`, options);
|
|
277
337
|
}
|
|
338
|
+
/** @deprecated Use `client.analytics.overview.get()`. */
|
|
278
339
|
getProjectOverview(projectId, options, requestOptions) {
|
|
279
340
|
const filters = options ?? {};
|
|
280
341
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/overview`, {
|
|
@@ -286,12 +347,15 @@ export class BisibilityClient {
|
|
|
286
347
|
},
|
|
287
348
|
});
|
|
288
349
|
}
|
|
350
|
+
/** @deprecated Use `client.keywords.match()`. */
|
|
289
351
|
matchProjectKeywords(projectId, input, requestOptions) {
|
|
290
352
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/keyword-matches`, { ...requestOptions, body: input });
|
|
291
353
|
}
|
|
354
|
+
/** @deprecated Use `client.projects.updateDefaults()`. */
|
|
292
355
|
updateProjectDefaults(projectId, input, options) {
|
|
293
356
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/defaults`, { ...options, body: input });
|
|
294
357
|
}
|
|
358
|
+
/** @deprecated Use `client.apiKeys.list()`. */
|
|
295
359
|
listApiKeys(options, requestOptions) {
|
|
296
360
|
const pagination = options ?? {};
|
|
297
361
|
return this.request("GET", "/api-keys", {
|
|
@@ -302,15 +366,19 @@ export class BisibilityClient {
|
|
|
302
366
|
},
|
|
303
367
|
});
|
|
304
368
|
}
|
|
369
|
+
/** @deprecated Use `client.apiKeys.iterate()`. */
|
|
305
370
|
iterateApiKeys(options = {}, requestOptions) {
|
|
306
371
|
return iterateCursorPagination((pageOptions) => this.listApiKeys(pageOptions, requestOptions), options);
|
|
307
372
|
}
|
|
373
|
+
/** @deprecated Use `client.apiKeys.create()`. */
|
|
308
374
|
createApiKey(input, options) {
|
|
309
375
|
return this.request("POST", "/api-keys", { ...options, body: input });
|
|
310
376
|
}
|
|
377
|
+
/** @deprecated Use `client.apiKeys.revoke()`. */
|
|
311
378
|
revokeApiKey(keyId, options) {
|
|
312
379
|
return this.request("DELETE", `/api-keys/${encodedPathSegment(keyId)}`, options);
|
|
313
380
|
}
|
|
381
|
+
/** @deprecated Use `client.apiKeys.list({ projectId })`. */
|
|
314
382
|
listProjectApiKeys(projectId, options, requestOptions) {
|
|
315
383
|
const pagination = options ?? {};
|
|
316
384
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/api-keys`, {
|
|
@@ -321,12 +389,15 @@ export class BisibilityClient {
|
|
|
321
389
|
},
|
|
322
390
|
});
|
|
323
391
|
}
|
|
392
|
+
/** @deprecated Use `client.apiKeys.iterate({ projectId })`. */
|
|
324
393
|
iterateProjectApiKeys(projectId, options = {}, requestOptions) {
|
|
325
394
|
return iterateCursorPagination((pageOptions) => this.listProjectApiKeys(projectId, pageOptions, requestOptions), options);
|
|
326
395
|
}
|
|
396
|
+
/** @deprecated Use `client.apiKeys.create(input, { projectId })`. */
|
|
327
397
|
createProjectApiKey(projectId, input, options) {
|
|
328
398
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/api-keys`, { ...options, body: input });
|
|
329
399
|
}
|
|
400
|
+
/** @deprecated Use `client.webhooks.list()`. */
|
|
330
401
|
listWebhooks(projectId, options, requestOptions) {
|
|
331
402
|
const pagination = options ?? {};
|
|
332
403
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/webhooks`, {
|
|
@@ -337,21 +408,26 @@ export class BisibilityClient {
|
|
|
337
408
|
},
|
|
338
409
|
});
|
|
339
410
|
}
|
|
411
|
+
/** @deprecated Use `client.webhooks.iterate()`. */
|
|
340
412
|
iterateWebhooks(projectId, options = {}, requestOptions) {
|
|
341
413
|
return iterateCursorPagination((pageOptions) => this.listWebhooks(projectId, pageOptions, requestOptions), options);
|
|
342
414
|
}
|
|
415
|
+
/** @deprecated Use `client.webhooks.create()`. */
|
|
343
416
|
createWebhook(projectId, input, options) {
|
|
344
417
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/webhooks`, {
|
|
345
418
|
...options,
|
|
346
419
|
body: input,
|
|
347
420
|
});
|
|
348
421
|
}
|
|
422
|
+
/** @deprecated Use `client.webhooks.update()`. */
|
|
349
423
|
updateWebhook(projectId, webhookId, input, options) {
|
|
350
424
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/webhooks/${encodedPathSegment(webhookId)}`, { ...options, body: input });
|
|
351
425
|
}
|
|
426
|
+
/** @deprecated Use `client.webhooks.delete()`. */
|
|
352
427
|
deleteWebhook(projectId, webhookId, options) {
|
|
353
428
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/webhooks/${encodedPathSegment(webhookId)}`, options);
|
|
354
429
|
}
|
|
430
|
+
/** @deprecated Use `client.keywords.list()`. */
|
|
355
431
|
listKeywords(projectId, options, requestOptions) {
|
|
356
432
|
const filters = options ?? {};
|
|
357
433
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/keywords`, {
|
|
@@ -371,30 +447,38 @@ export class BisibilityClient {
|
|
|
371
447
|
},
|
|
372
448
|
});
|
|
373
449
|
}
|
|
450
|
+
/** @deprecated Use `client.keywords.iterate()`. */
|
|
374
451
|
iterateKeywords(projectId, options = {}, requestOptions) {
|
|
375
452
|
return iterateCursorPagination((pageOptions) => this.listKeywords(projectId, pageOptions, requestOptions), options);
|
|
376
453
|
}
|
|
454
|
+
/** @deprecated Use `client.keywords.add()`. */
|
|
377
455
|
addKeywords(projectId, input, options) {
|
|
378
456
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/keywords`, { ...options, body: input });
|
|
379
457
|
}
|
|
458
|
+
/** @deprecated Use `client.keywords.get()`. */
|
|
380
459
|
getKeyword(keywordId, options) {
|
|
381
460
|
return this.request("GET", `/keywords/${encodedPathSegment(keywordId)}`, options);
|
|
382
461
|
}
|
|
462
|
+
/** @deprecated Use `client.keywords.update()`. */
|
|
383
463
|
updateKeyword(keywordId, input, options) {
|
|
384
464
|
return this.request("PATCH", `/keywords/${encodedPathSegment(keywordId)}`, {
|
|
385
465
|
...options,
|
|
386
466
|
body: input,
|
|
387
467
|
});
|
|
388
468
|
}
|
|
469
|
+
/** @deprecated Use `client.keywords.setTargetUrl()`. */
|
|
389
470
|
setKeywordTargetUrl(keywordId, targetUrl, options) {
|
|
390
471
|
return this.updateKeyword(keywordId, { target_url: targetUrl }, options);
|
|
391
472
|
}
|
|
473
|
+
/** @deprecated Use `client.keywords.delete()`. */
|
|
392
474
|
deleteKeyword(keywordId, options) {
|
|
393
475
|
return this.requestOrUndefined("DELETE", `/keywords/${encodedPathSegment(keywordId)}`, options);
|
|
394
476
|
}
|
|
477
|
+
/** @deprecated Use `client.keywords.bulkUpdate()`. */
|
|
395
478
|
bulkUpdateKeywords(input, options) {
|
|
396
479
|
return this.request("POST", "/keywords/bulk", { ...options, body: input });
|
|
397
480
|
}
|
|
481
|
+
/** @deprecated Use `client.keywords.suggestions.list()`. */
|
|
398
482
|
listRankedKeywordSuggestions(projectId, options, requestOptions) {
|
|
399
483
|
const filters = options ?? {};
|
|
400
484
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/ranked-keyword-suggestions`, {
|
|
@@ -410,6 +494,7 @@ export class BisibilityClient {
|
|
|
410
494
|
/**
|
|
411
495
|
* Research keywords from one seed. This operation requires API write scope because a cache
|
|
412
496
|
* miss can spend the project's provider budget. Use `estimateOnly` for a free dry run.
|
|
497
|
+
* @deprecated Use `client.keywords.research()`.
|
|
413
498
|
*/
|
|
414
499
|
researchKeywords(projectId, options, requestOptions) {
|
|
415
500
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/keyword-research`, {
|
|
@@ -430,6 +515,7 @@ export class BisibilityClient {
|
|
|
430
515
|
* Analyze backlinks. This operation requires API write scope because a cache miss can spend the
|
|
431
516
|
* project's provider budget. Use `estimateOnly` (`estimate_only` on the wire) for a free dry
|
|
432
517
|
* run.
|
|
518
|
+
* @deprecated Use `client.backlinks.analyze()`.
|
|
433
519
|
*/
|
|
434
520
|
analyzeBacklinks(projectId, options, requestOptions) {
|
|
435
521
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/backlinks`, {
|
|
@@ -449,6 +535,7 @@ export class BisibilityClient {
|
|
|
449
535
|
/**
|
|
450
536
|
* Load more rows into an unexpired backlinks snapshot. This operation requires API write scope
|
|
451
537
|
* and spends provider budget.
|
|
538
|
+
* @deprecated Use `client.backlinks.extendSnapshot()`.
|
|
452
539
|
*/
|
|
453
540
|
loadMoreBacklinkRows(projectId, options, requestOptions) {
|
|
454
541
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/backlinks/rows`, {
|
|
@@ -464,10 +551,12 @@ export class BisibilityClient {
|
|
|
464
551
|
/**
|
|
465
552
|
* Hydrate keyword metrics. This operation requires API write scope because cache misses can
|
|
466
553
|
* spend the project's provider budget. Use `estimate_only` for a free dry run.
|
|
554
|
+
* @deprecated Use `client.keywords.metrics.get()`.
|
|
467
555
|
*/
|
|
468
556
|
getKeywordMetrics(projectId, input, options) {
|
|
469
557
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/keyword-metrics`, { ...options, body: input });
|
|
470
558
|
}
|
|
559
|
+
/** @deprecated Use `client.rankChecks.history.export()`. */
|
|
471
560
|
exportRankHistory(projectId, options = {}, requestOptions) {
|
|
472
561
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/exports/rank-history`, {
|
|
473
562
|
...requestOptions,
|
|
@@ -482,15 +571,19 @@ export class BisibilityClient {
|
|
|
482
571
|
},
|
|
483
572
|
});
|
|
484
573
|
}
|
|
574
|
+
/** @deprecated Use `client.rankChecks.history.iterate()`. */
|
|
485
575
|
iterateRankHistoryExport(projectId, options = {}, requestOptions) {
|
|
486
576
|
return iterateCursorPagination((pageOptions) => this.exportRankHistory(projectId, { ...options, ...pageOptions, format: "json" }, requestOptions), options);
|
|
487
577
|
}
|
|
578
|
+
/** @deprecated Use `client.sitemapMonitors.list()`. */
|
|
488
579
|
listSitemapMonitors(projectId, options) {
|
|
489
580
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/sitemap-monitors`, options);
|
|
490
581
|
}
|
|
582
|
+
/** @deprecated Use `client.sitemapMonitors.update()`. */
|
|
491
583
|
updateSitemapMonitor(projectId, monitorId, input, options) {
|
|
492
584
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/sitemap-monitors/${encodedPathSegment(monitorId)}`, { ...options, body: input });
|
|
493
585
|
}
|
|
586
|
+
/** @deprecated Use `client.rankChecks.list()`. */
|
|
494
587
|
listRankChecks(keywordId, options, requestOptions) {
|
|
495
588
|
const filters = options ?? {};
|
|
496
589
|
return this.request("GET", `/keywords/${encodedPathSegment(keywordId)}/rank-checks`, {
|
|
@@ -504,9 +597,11 @@ export class BisibilityClient {
|
|
|
504
597
|
},
|
|
505
598
|
});
|
|
506
599
|
}
|
|
600
|
+
/** @deprecated Use `client.rankChecks.iterate()`. */
|
|
507
601
|
iterateRankChecks(keywordId, options = {}, requestOptions) {
|
|
508
602
|
return iterateCursorPagination((pageOptions) => this.listRankChecks(keywordId, pageOptions, requestOptions), options);
|
|
509
603
|
}
|
|
604
|
+
/** @deprecated Use `client.rankChecks.run()`. */
|
|
510
605
|
runRankCheck(keywordId, input, options) {
|
|
511
606
|
const { async: runAsync, ...requestOptions } = options ?? {};
|
|
512
607
|
const body = input && Object.keys(input).length ? input : undefined;
|
|
@@ -516,12 +611,15 @@ export class BisibilityClient {
|
|
|
516
611
|
...(runAsync ? { query: { async: "true" } } : {}),
|
|
517
612
|
});
|
|
518
613
|
}
|
|
614
|
+
/** @deprecated Use `client.rankChecks.getResult()`. */
|
|
519
615
|
getRankCheckResult(checkId, options) {
|
|
520
616
|
return this.request("GET", `/rank-checks/${encodedPathSegment(checkId)}`, options);
|
|
521
617
|
}
|
|
618
|
+
/** @deprecated Use `client.signals.create()`. */
|
|
522
619
|
createSignal(input, options) {
|
|
523
620
|
return this.request("POST", "/signals", { ...options, body: input });
|
|
524
621
|
}
|
|
622
|
+
/** @deprecated Use `client.signals.list()`. */
|
|
525
623
|
listSignals(projectId, options, requestOptions) {
|
|
526
624
|
const filters = options ?? {};
|
|
527
625
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/signals`, {
|
|
@@ -536,9 +634,11 @@ export class BisibilityClient {
|
|
|
536
634
|
},
|
|
537
635
|
});
|
|
538
636
|
}
|
|
637
|
+
/** @deprecated Use `client.signals.iterate()`. */
|
|
539
638
|
iterateSignals(projectId, options = {}, requestOptions) {
|
|
540
639
|
return iterateCursorPagination((pageOptions) => this.listSignals(projectId, pageOptions, requestOptions), options);
|
|
541
640
|
}
|
|
641
|
+
/** @deprecated Use `client.analytics.traffic.list()`. */
|
|
542
642
|
listTrafficSnapshots(projectId, options, requestOptions) {
|
|
543
643
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/analytics/traffic-snapshots`, {
|
|
544
644
|
...requestOptions,
|
|
@@ -551,6 +651,7 @@ export class BisibilityClient {
|
|
|
551
651
|
},
|
|
552
652
|
});
|
|
553
653
|
}
|
|
654
|
+
/** @deprecated Use `client.analytics.searchPerformance.list()`. */
|
|
554
655
|
listSearchPerformanceQueryStats(projectId, options, requestOptions) {
|
|
555
656
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/analytics/query-stats`, {
|
|
556
657
|
...requestOptions,
|
|
@@ -563,9 +664,11 @@ export class BisibilityClient {
|
|
|
563
664
|
},
|
|
564
665
|
});
|
|
565
666
|
}
|
|
667
|
+
/** @deprecated Use `client.analytics.traffic.sync()`. */
|
|
566
668
|
syncProjectTraffic(projectId, options) {
|
|
567
669
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/analytics/sync`, options);
|
|
568
670
|
}
|
|
671
|
+
/** @deprecated Use `client.alertRules.list()`. */
|
|
569
672
|
listAlertRules(projectId, options, requestOptions) {
|
|
570
673
|
const pagination = options ?? {};
|
|
571
674
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/alert-rules`, {
|
|
@@ -576,21 +679,26 @@ export class BisibilityClient {
|
|
|
576
679
|
},
|
|
577
680
|
});
|
|
578
681
|
}
|
|
682
|
+
/** @deprecated Use `client.alertRules.iterate()`. */
|
|
579
683
|
iterateAlertRules(projectId, options = {}, requestOptions) {
|
|
580
684
|
return iterateCursorPagination((pageOptions) => this.listAlertRules(projectId, pageOptions, requestOptions), options);
|
|
581
685
|
}
|
|
686
|
+
/** @deprecated Use `client.alertRules.create()`. */
|
|
582
687
|
createAlertRule(projectId, input, options) {
|
|
583
688
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/alert-rules`, { ...options, body: input });
|
|
584
689
|
}
|
|
690
|
+
/** @deprecated Use `client.alertRules.update()`. */
|
|
585
691
|
updateAlertRule(ruleId, input, options) {
|
|
586
692
|
return this.request("PATCH", `/alert-rules/${encodedPathSegment(ruleId)}`, {
|
|
587
693
|
...options,
|
|
588
694
|
body: input,
|
|
589
695
|
});
|
|
590
696
|
}
|
|
697
|
+
/** @deprecated Use `client.alertRules.delete()`. */
|
|
591
698
|
deleteAlertRule(ruleId, options) {
|
|
592
699
|
return this.request("DELETE", `/alert-rules/${encodedPathSegment(ruleId)}`, options);
|
|
593
700
|
}
|
|
701
|
+
/** @deprecated Use `client.alerts.list()`. */
|
|
594
702
|
listTriggeredAlerts(projectId, options, requestOptions) {
|
|
595
703
|
const pagination = options ?? {};
|
|
596
704
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/triggered-alerts`, {
|
|
@@ -601,15 +709,19 @@ export class BisibilityClient {
|
|
|
601
709
|
},
|
|
602
710
|
});
|
|
603
711
|
}
|
|
712
|
+
/** @deprecated Use `client.alerts.iterate()`. */
|
|
604
713
|
iterateTriggeredAlerts(projectId, options = {}, requestOptions) {
|
|
605
714
|
return iterateCursorPagination((pageOptions) => this.listTriggeredAlerts(projectId, pageOptions, requestOptions), options);
|
|
606
715
|
}
|
|
716
|
+
/** @deprecated Use `client.alerts.mute()`. */
|
|
607
717
|
muteTriggeredAlert(projectId, alertId, options) {
|
|
608
718
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/triggered-alerts/${encodedPathSegment(alertId)}/mute`, options);
|
|
609
719
|
}
|
|
720
|
+
/** @deprecated Use `client.alerts.markAllRead({ projectId })`. */
|
|
610
721
|
markProjectAlertsRead(projectId, options) {
|
|
611
722
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/triggered-alerts/mark-read`, options);
|
|
612
723
|
}
|
|
724
|
+
/** @deprecated Use `client.team.members.list()`. */
|
|
613
725
|
listTeamMembers(projectId, options, requestOptions) {
|
|
614
726
|
const pagination = options ?? {};
|
|
615
727
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/team/members`, {
|
|
@@ -620,9 +732,11 @@ export class BisibilityClient {
|
|
|
620
732
|
},
|
|
621
733
|
});
|
|
622
734
|
}
|
|
735
|
+
/** @deprecated Use `client.team.members.iterate()`. */
|
|
623
736
|
iterateTeamMembers(projectId, options = {}, requestOptions) {
|
|
624
737
|
return iterateCursorPagination((pageOptions) => this.listTeamMembers(projectId, pageOptions, requestOptions), options);
|
|
625
738
|
}
|
|
739
|
+
/** @deprecated Use `client.team.invites.list()`. */
|
|
626
740
|
listTeamInvites(projectId, options, requestOptions) {
|
|
627
741
|
const pagination = options ?? {};
|
|
628
742
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/team/invites`, {
|
|
@@ -633,27 +747,35 @@ export class BisibilityClient {
|
|
|
633
747
|
},
|
|
634
748
|
});
|
|
635
749
|
}
|
|
750
|
+
/** @deprecated Use `client.team.invites.iterate()`. */
|
|
636
751
|
iterateTeamInvites(projectId, options = {}, requestOptions) {
|
|
637
752
|
return iterateCursorPagination((pageOptions) => this.listTeamInvites(projectId, pageOptions, requestOptions), options);
|
|
638
753
|
}
|
|
754
|
+
/** @deprecated Use `client.team.invites.create()`. */
|
|
639
755
|
createTeamInvite(projectId, input, options) {
|
|
640
756
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/team/invites`, { ...options, body: input });
|
|
641
757
|
}
|
|
758
|
+
/** @deprecated Use `client.team.invites.revoke({ id, projectId })`. */
|
|
642
759
|
revokeTeamInvite(projectId, inviteId, options) {
|
|
643
760
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/team/invites/${encodedPathSegment(inviteId)}`, options);
|
|
644
761
|
}
|
|
762
|
+
/** @deprecated Use `client.team.invites.revoke(id)`. */
|
|
645
763
|
revokeTeamInviteById(inviteId, options) {
|
|
646
764
|
return this.request("DELETE", `/team/invites/${encodedPathSegment(inviteId)}`, options);
|
|
647
765
|
}
|
|
766
|
+
/** @deprecated Use `client.team.invites.resend()`. */
|
|
648
767
|
resendTeamInvite(projectId, inviteId, options) {
|
|
649
768
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/team/invites/${encodedPathSegment(inviteId)}/resend`, options);
|
|
650
769
|
}
|
|
770
|
+
/** @deprecated Use `client.team.members.updateRole()`. */
|
|
651
771
|
updateTeamMemberRole(projectId, memberId, input, options) {
|
|
652
772
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/team/members/${encodedPathSegment(memberId)}`, { ...options, body: input });
|
|
653
773
|
}
|
|
774
|
+
/** @deprecated Use `client.team.members.remove()`. */
|
|
654
775
|
removeTeamMember(projectId, memberId, options) {
|
|
655
776
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/team/members/${encodedPathSegment(memberId)}`, options);
|
|
656
777
|
}
|
|
778
|
+
/** @deprecated Use `client.providers.list()`. */
|
|
657
779
|
listProviders(projectId, options, requestOptions) {
|
|
658
780
|
const pagination = options ?? {};
|
|
659
781
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/providers`, {
|
|
@@ -664,36 +786,47 @@ export class BisibilityClient {
|
|
|
664
786
|
},
|
|
665
787
|
});
|
|
666
788
|
}
|
|
789
|
+
/** @deprecated Use `client.providers.iterate()`. */
|
|
667
790
|
iterateProviders(projectId, options = {}, requestOptions) {
|
|
668
791
|
return iterateCursorPagination((pageOptions) => this.listProviders(projectId, pageOptions, requestOptions), options);
|
|
669
792
|
}
|
|
793
|
+
/** @deprecated Use `client.providers.connect()`. */
|
|
670
794
|
connectProvider(projectId, providerId, input = {}, options) {
|
|
671
795
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/providers/${encodedPathSegment(providerId)}/connect`, { ...options, body: bodyOrUndefined(input) });
|
|
672
796
|
}
|
|
797
|
+
/** @deprecated Use `client.providers.test()`. */
|
|
673
798
|
testProviderConnection(projectId, providerId, input = {}, options) {
|
|
674
799
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/providers/${encodedPathSegment(providerId)}/test`, { ...options, body: bodyOrUndefined(input) });
|
|
675
800
|
}
|
|
801
|
+
/** @deprecated Use `client.providers.updateSettings()`. */
|
|
676
802
|
updateProviderSettings(projectId, providerId, input, options) {
|
|
677
803
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/providers/${encodedPathSegment(providerId)}`, { ...options, body: input });
|
|
678
804
|
}
|
|
805
|
+
/** @deprecated Use `client.providers.setEnabled()`. */
|
|
679
806
|
setProviderEnabled(projectId, providerId, enabled, options) {
|
|
680
807
|
return this.updateProviderSettings(projectId, providerId, { enabled }, options);
|
|
681
808
|
}
|
|
809
|
+
/** @deprecated Use `client.providers.setEnabled(projectId, providerId, true)`. */
|
|
682
810
|
enableProvider(projectId, providerId, options) {
|
|
683
811
|
return this.setProviderEnabled(projectId, providerId, true, options);
|
|
684
812
|
}
|
|
813
|
+
/** @deprecated Use `client.providers.setEnabled(projectId, providerId, false)`. */
|
|
685
814
|
disableProvider(projectId, providerId, options) {
|
|
686
815
|
return this.setProviderEnabled(projectId, providerId, false, options);
|
|
687
816
|
}
|
|
817
|
+
/** @deprecated Use `client.providers.setPriority()`. */
|
|
688
818
|
setProviderPriority(projectId, providerId, priority, options) {
|
|
689
819
|
return this.updateProviderSettings(projectId, providerId, { priority }, options);
|
|
690
820
|
}
|
|
821
|
+
/** @deprecated Use `client.providers.setPrimary()`. */
|
|
691
822
|
setPrimaryProvider(projectId, providerId, primary = true, options) {
|
|
692
823
|
return this.updateProviderSettings(projectId, providerId, { primary }, options);
|
|
693
824
|
}
|
|
825
|
+
/** @deprecated Use `client.providers.disconnect()`. */
|
|
694
826
|
disconnectProvider(projectId, providerId, options) {
|
|
695
827
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/providers/${encodedPathSegment(providerId)}`, options);
|
|
696
828
|
}
|
|
829
|
+
/** @deprecated Use `client.savedViews.list()`. */
|
|
697
830
|
listSavedViews(projectId, options, requestOptions) {
|
|
698
831
|
const pagination = options ?? {};
|
|
699
832
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/saved-views`, {
|
|
@@ -705,18 +838,50 @@ export class BisibilityClient {
|
|
|
705
838
|
},
|
|
706
839
|
});
|
|
707
840
|
}
|
|
841
|
+
/** @deprecated Use `client.savedViews.iterate()`. */
|
|
708
842
|
iterateSavedViews(projectId, options = {}, requestOptions) {
|
|
709
843
|
return iterateCursorPagination((pageOptions) => this.listSavedViews(projectId, pageOptions, requestOptions), options);
|
|
710
844
|
}
|
|
845
|
+
/** @deprecated Use `client.savedViews.create()`. */
|
|
711
846
|
createSavedView(projectId, input, options) {
|
|
712
847
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/saved-views`, { ...options, body: input });
|
|
713
848
|
}
|
|
849
|
+
/** @deprecated Use `client.savedViews.delete({ id, projectId })`. */
|
|
714
850
|
deleteSavedView(projectId, viewId, options) {
|
|
715
851
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/saved-views/${encodedPathSegment(viewId)}`, options);
|
|
716
852
|
}
|
|
853
|
+
/** @deprecated Use `client.savedViews.delete(id)`. */
|
|
717
854
|
deleteSavedViewById(viewId, options) {
|
|
718
855
|
return this.request("DELETE", `/saved-views/${encodedPathSegment(viewId)}`, options);
|
|
719
856
|
}
|
|
857
|
+
/** @deprecated Use `client.keywords.saved.list()` instead. */
|
|
858
|
+
listSavedKeywords(projectId, options, requestOptions) {
|
|
859
|
+
const pagination = options ?? {};
|
|
860
|
+
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/saved-keywords`, {
|
|
861
|
+
...requestOptions,
|
|
862
|
+
query: {
|
|
863
|
+
...(pagination.cursor === undefined ? {} : { cursor: pagination.cursor }),
|
|
864
|
+
...(pagination.limit === undefined ? {} : { limit: pagination.limit }),
|
|
865
|
+
},
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
/** @deprecated Use `client.keywords.saved.iterate()` instead. */
|
|
869
|
+
iterateSavedKeywords(projectId, options = {}, requestOptions) {
|
|
870
|
+
return iterateCursorPagination((pageOptions) => this.listSavedKeywords(projectId, pageOptions, requestOptions), options);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Saves keywords for later without putting them under rank tracking.
|
|
874
|
+
* Keywords already tracked or already saved come back as `skipped`.
|
|
875
|
+
* @deprecated Use `client.keywords.saved.create()` instead.
|
|
876
|
+
*/
|
|
877
|
+
createSavedKeywords(projectId, input, options) {
|
|
878
|
+
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/saved-keywords`, { ...options, body: input });
|
|
879
|
+
}
|
|
880
|
+
/** @deprecated Use `client.keywords.saved.delete()` instead. */
|
|
881
|
+
deleteSavedKeyword(projectId, savedKeywordId, options) {
|
|
882
|
+
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/saved-keywords/${encodedPathSegment(savedKeywordId)}`, options);
|
|
883
|
+
}
|
|
884
|
+
/** @deprecated Use `client.competitors.list()`. */
|
|
720
885
|
listCompetitors(projectId, options, requestOptions) {
|
|
721
886
|
const pagination = options ?? {};
|
|
722
887
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/competitors`, {
|
|
@@ -727,24 +892,31 @@ export class BisibilityClient {
|
|
|
727
892
|
},
|
|
728
893
|
});
|
|
729
894
|
}
|
|
895
|
+
/** @deprecated Use `client.competitors.iterate()`. */
|
|
730
896
|
iterateCompetitors(projectId, options = {}, requestOptions) {
|
|
731
897
|
return iterateCursorPagination((pageOptions) => this.listCompetitors(projectId, pageOptions, requestOptions), options);
|
|
732
898
|
}
|
|
899
|
+
/** @deprecated Use `client.competitors.add()`. */
|
|
733
900
|
addCompetitor(projectId, input, options) {
|
|
734
901
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/competitors`, { ...options, body: input });
|
|
735
902
|
}
|
|
903
|
+
/** @deprecated Use `client.competitors.remove({ id, projectId })`. */
|
|
736
904
|
removeCompetitor(projectId, competitorId, options) {
|
|
737
905
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/competitors/${encodedPathSegment(competitorId)}`, options);
|
|
738
906
|
}
|
|
907
|
+
/** @deprecated Use `client.competitors.remove(id)`. */
|
|
739
908
|
removeCompetitorById(competitorId, options) {
|
|
740
909
|
return this.request("DELETE", `/competitors/${encodedPathSegment(competitorId)}`, options);
|
|
741
910
|
}
|
|
911
|
+
/** @deprecated Use `client.notificationSettings.get()`. */
|
|
742
912
|
getNotificationPreferences(projectId, options) {
|
|
743
913
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/notification-preferences`, options);
|
|
744
914
|
}
|
|
915
|
+
/** @deprecated Use `client.notificationSettings.update()`. */
|
|
745
916
|
updateNotificationPreferences(projectId, input, options) {
|
|
746
917
|
return this.request("PATCH", `/projects/${encodedPathSegment(projectId)}/notification-preferences`, { ...options, body: input });
|
|
747
918
|
}
|
|
919
|
+
/** @deprecated Use `client.imports.tokens.list()`. */
|
|
748
920
|
listMigrationTokens(projectId, options, requestOptions) {
|
|
749
921
|
const pagination = options ?? {};
|
|
750
922
|
return this.request("GET", `/projects/${encodedPathSegment(projectId)}/migration-tokens`, {
|
|
@@ -755,36 +927,44 @@ export class BisibilityClient {
|
|
|
755
927
|
},
|
|
756
928
|
});
|
|
757
929
|
}
|
|
930
|
+
/** @deprecated Use `client.imports.tokens.iterate()`. */
|
|
758
931
|
iterateMigrationTokens(projectId, options = {}, requestOptions) {
|
|
759
932
|
return iterateCursorPagination((pageOptions) => this.listMigrationTokens(projectId, pageOptions, requestOptions), options);
|
|
760
933
|
}
|
|
934
|
+
/** @deprecated Use `client.imports.tokens.create()`. */
|
|
761
935
|
mintMigrationToken(projectId, input = {}, options) {
|
|
762
936
|
return this.request("POST", `/projects/${encodedPathSegment(projectId)}/migration-tokens`, { ...options, body: bodyOrUndefined(input) });
|
|
763
937
|
}
|
|
938
|
+
/** @deprecated Use `client.imports.tokens.revoke({ id, projectId })`. */
|
|
764
939
|
revokeMigrationToken(projectId, tokenId, options) {
|
|
765
940
|
return this.request("DELETE", `/projects/${encodedPathSegment(projectId)}/migration-tokens/${encodedPathSegment(tokenId)}`, options);
|
|
766
941
|
}
|
|
942
|
+
/** @deprecated Use `client.imports.tokens.revoke(id)`. */
|
|
767
943
|
revokeMigrationTokenById(tokenId, options) {
|
|
768
944
|
return this.request("DELETE", `/migration-tokens/${encodedPathSegment(tokenId)}`, options);
|
|
769
945
|
}
|
|
946
|
+
/** @deprecated Use `client.imports.compatibility.get()`. */
|
|
770
947
|
getCloudImportCompatibility(options) {
|
|
771
948
|
return this.request("GET", "/cloud/import/compatibility", {
|
|
772
949
|
...options,
|
|
773
950
|
auth: false,
|
|
774
951
|
});
|
|
775
952
|
}
|
|
953
|
+
/** @deprecated Use `client.imports.runFromExport()`. */
|
|
776
954
|
importCloudExport(input, options) {
|
|
777
955
|
return this.request("POST", "/cloud/import", {
|
|
778
956
|
...options,
|
|
779
957
|
body: input,
|
|
780
958
|
});
|
|
781
959
|
}
|
|
960
|
+
/** @deprecated Use `client.imports.sessions.create()`. */
|
|
782
961
|
createCloudImportSession(input, options) {
|
|
783
962
|
return this.request("POST", "/cloud/import/sessions", {
|
|
784
963
|
...options,
|
|
785
964
|
body: input,
|
|
786
965
|
});
|
|
787
966
|
}
|
|
967
|
+
/** @deprecated Use `client.imports.sessions.uploadChunk()`. */
|
|
788
968
|
uploadCloudImportChunk(sessionId, index, input, options) {
|
|
789
969
|
const { contentEncoding, headers, ...requestOptions } = options ?? {};
|
|
790
970
|
const mergedHeaders = new Headers(headers);
|
|
@@ -793,6 +973,7 @@ export class BisibilityClient {
|
|
|
793
973
|
}
|
|
794
974
|
return this.request("PUT", `/cloud/import/sessions/${encodedPathSegment(sessionId)}/chunks/${encodedPathSegment(String(index))}`, { ...requestOptions, body: input, headers: mergedHeaders });
|
|
795
975
|
}
|
|
976
|
+
/** @deprecated Use `client.imports.sessions.finalize()`. */
|
|
796
977
|
finalizeCloudImportSession(sessionId, options) {
|
|
797
978
|
return this.request("POST", `/cloud/import/sessions/${encodedPathSegment(sessionId)}/finalize`, options);
|
|
798
979
|
}
|
|
@@ -815,6 +996,70 @@ export class BisibilityClient {
|
|
|
815
996
|
}
|
|
816
997
|
return absolute ? url.toString() : `${url.pathname}${url.search}`;
|
|
817
998
|
}
|
|
999
|
+
assertApiVersionCompatible(response) {
|
|
1000
|
+
const advertised = response.apiVersions;
|
|
1001
|
+
if (advertised === undefined) {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
if (!Array.isArray(advertised) || advertised.some((version) => typeof version !== "string")) {
|
|
1005
|
+
throw new BisibilityResponseError("Bisibility API returned invalid API version capabilities.", {
|
|
1006
|
+
body: JSON.stringify(response),
|
|
1007
|
+
cause: undefined,
|
|
1008
|
+
method: "GET",
|
|
1009
|
+
status: 200,
|
|
1010
|
+
url: this.buildUrl("/capabilities"),
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
if (advertised.includes(BISIBILITY_API_VERSION)) {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
const detail = `The declared API version ${BISIBILITY_API_VERSION} is not served by this server.`;
|
|
1017
|
+
const problem = {
|
|
1018
|
+
detail,
|
|
1019
|
+
errors: {
|
|
1020
|
+
apiVersions: advertised,
|
|
1021
|
+
declaredApiVersion: BISIBILITY_API_VERSION,
|
|
1022
|
+
},
|
|
1023
|
+
status: 409,
|
|
1024
|
+
title: "Unsupported API version",
|
|
1025
|
+
type: UNSUPPORTED_API_VERSION_PROBLEM_TYPE,
|
|
1026
|
+
};
|
|
1027
|
+
throw new BisibilityApiVersionError(detail, {
|
|
1028
|
+
body: JSON.stringify(problem),
|
|
1029
|
+
declaredApiVersion: BISIBILITY_API_VERSION,
|
|
1030
|
+
headers: new Headers(),
|
|
1031
|
+
method: "GET",
|
|
1032
|
+
problem,
|
|
1033
|
+
serverApiVersions: advertised,
|
|
1034
|
+
status: 409,
|
|
1035
|
+
url: this.buildUrl("/capabilities"),
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
ensureApiVersionPreflight(signal, timeout) {
|
|
1039
|
+
if (this.#apiVersionPreflight === undefined) {
|
|
1040
|
+
const options = {
|
|
1041
|
+
auth: false,
|
|
1042
|
+
skipApiVersionPreflight: true,
|
|
1043
|
+
};
|
|
1044
|
+
if (signal !== undefined) {
|
|
1045
|
+
options.signal = signal;
|
|
1046
|
+
}
|
|
1047
|
+
if (timeout !== undefined) {
|
|
1048
|
+
options.timeout = timeout;
|
|
1049
|
+
}
|
|
1050
|
+
const pending = this.request("GET", "/capabilities", options).then((response) => {
|
|
1051
|
+
this.assertApiVersionCompatible(response);
|
|
1052
|
+
});
|
|
1053
|
+
const cached = pending.catch((error) => {
|
|
1054
|
+
if (!(error instanceof BisibilityApiVersionError) && this.#apiVersionPreflight === cached) {
|
|
1055
|
+
this.#apiVersionPreflight = undefined;
|
|
1056
|
+
}
|
|
1057
|
+
throw error;
|
|
1058
|
+
});
|
|
1059
|
+
this.#apiVersionPreflight = cached;
|
|
1060
|
+
}
|
|
1061
|
+
return this.#apiVersionPreflight;
|
|
1062
|
+
}
|
|
818
1063
|
async request(method, path, options = {}) {
|
|
819
1064
|
const statusRef = { status: 0 };
|
|
820
1065
|
const result = await this.requestOrUndefined(method, path, options, statusRef);
|
|
@@ -852,6 +1097,9 @@ export class BisibilityClient {
|
|
|
852
1097
|
if (projectHeader !== null && !isPublicIdOfType(projectHeader, "prj")) {
|
|
853
1098
|
throw new BisibilityConfigurationError("X-Bisibility-Project must match prj_[a-z][a-z0-9]{23}.");
|
|
854
1099
|
}
|
|
1100
|
+
if (!options.skipApiVersionPreflight) {
|
|
1101
|
+
await this.ensureApiVersionPreflight(options.signal, options.timeout);
|
|
1102
|
+
}
|
|
855
1103
|
if (options.auth !== false) {
|
|
856
1104
|
headers.set("Authorization", `Bearer ${this.#apiKey}`);
|
|
857
1105
|
}
|
|
@@ -859,6 +1107,7 @@ export class BisibilityClient {
|
|
|
859
1107
|
headers.set("Idempotency-Key", options.idempotencyKey);
|
|
860
1108
|
}
|
|
861
1109
|
headers.set("X-Bisibility-Client", CLIENT_ID);
|
|
1110
|
+
headers.set(BISIBILITY_API_VERSION_HEADER, BISIBILITY_API_VERSION);
|
|
862
1111
|
if (!headers.has("User-Agent")) {
|
|
863
1112
|
try {
|
|
864
1113
|
headers.set("User-Agent", CLIENT_ID);
|
|
@@ -903,7 +1152,7 @@ export class BisibilityClient {
|
|
|
903
1152
|
await sleepForRetry(retryBackoffMs(attempt), options.signal, method, url);
|
|
904
1153
|
continue;
|
|
905
1154
|
}
|
|
906
|
-
if (!response.ok) {
|
|
1155
|
+
if (!response.ok && !options.acceptedStatuses?.includes(response.status)) {
|
|
907
1156
|
const error = await this.errorFromResponse(response, method, url);
|
|
908
1157
|
if (retryable &&
|
|
909
1158
|
attempt < this.#maxRetries &&
|
|
@@ -971,6 +1220,19 @@ export class BisibilityClient {
|
|
|
971
1220
|
}
|
|
972
1221
|
const problem = problemFromJson(parsed);
|
|
973
1222
|
const message = problem?.detail || body || `Bisibility API request failed with status ${response.status}.`;
|
|
1223
|
+
if (response.status === 409 && isUnsupportedApiVersionProblem(problem)) {
|
|
1224
|
+
const details = apiVersionErrorDetails(problem);
|
|
1225
|
+
return new BisibilityApiVersionError(message, {
|
|
1226
|
+
body,
|
|
1227
|
+
declaredApiVersion: details.declaredApiVersion,
|
|
1228
|
+
headers,
|
|
1229
|
+
method,
|
|
1230
|
+
problem,
|
|
1231
|
+
serverApiVersions: details.serverApiVersions,
|
|
1232
|
+
status: response.status,
|
|
1233
|
+
url,
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
974
1236
|
return new BisibilityApiError(message, {
|
|
975
1237
|
body,
|
|
976
1238
|
headers,
|