@gscdump/sdk 0.37.3 → 0.37.5
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.mjs +231 -129
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __exportAll, __reExport } from "./_chunks/rolldown-runtime.mjs";
|
|
2
2
|
import { query_exports } from "./query.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { analyticsEndpoints } from "@gscdump/contracts/analytics";
|
|
4
4
|
import { err, ok, unwrapResult } from "gscdump/result";
|
|
5
5
|
import { ofetch } from "ofetch";
|
|
6
|
-
import {
|
|
6
|
+
import { partnerEndpoints, partnerRoutes } from "@gscdump/contracts/partner";
|
|
7
7
|
import { resolveWindow } from "@gscdump/engine/period";
|
|
8
8
|
import { endOfMonth, format, startOfMonth, startOfQuarter, startOfWeek, subDays, subMonths } from "date-fns";
|
|
9
9
|
import { CANONICAL_WEBHOOK_EVENTS, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_CONTRACT_VERSION_HEADER as WEBHOOK_CONTRACT_VERSION_HEADER$1, WEBHOOK_DELIVERY_HEADER, WEBHOOK_DELIVERY_HEADER as WEBHOOK_DELIVERY_HEADER$1, WEBHOOK_EVENT_HEADER, WEBHOOK_EVENT_HEADER as WEBHOOK_EVENT_HEADER$1, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_HEADER as WEBHOOK_SIGNATURE_HEADER$1, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TIMESTAMP_HEADER as WEBHOOK_TIMESTAMP_HEADER$1, partnerWebhookEnvelopeSchema } from "@gscdump/contracts";
|
|
@@ -270,75 +270,117 @@ function createAnalyticsClient(options = {}) {
|
|
|
270
270
|
const { request, shouldValidate } = createHostedRequester(options, { apiBase: "" });
|
|
271
271
|
return {
|
|
272
272
|
whoami() {
|
|
273
|
-
|
|
273
|
+
const endpoint = analyticsEndpoints.whoami;
|
|
274
|
+
return request(endpoint.path, { method: endpoint.method }, endpoint.response);
|
|
274
275
|
},
|
|
275
276
|
listSites() {
|
|
276
|
-
|
|
277
|
+
const endpoint = analyticsEndpoints.listSites;
|
|
278
|
+
return request(endpoint.path, { method: endpoint.method }, endpoint.response);
|
|
277
279
|
},
|
|
278
280
|
getSourceInfo(siteId, options) {
|
|
279
|
-
|
|
281
|
+
const endpoint = analyticsEndpoints.getSourceInfo;
|
|
282
|
+
return request(endpoint.path(siteId), {
|
|
283
|
+
method: endpoint.method,
|
|
284
|
+
query: sourceInfoQuery(options)
|
|
285
|
+
}, endpoint.response);
|
|
280
286
|
},
|
|
281
287
|
getAnalysisSources(siteId, tables, options) {
|
|
282
|
-
|
|
288
|
+
const endpoint = analyticsEndpoints.getAnalysisSources;
|
|
289
|
+
return request(endpoint.path(siteId), {
|
|
290
|
+
method: endpoint.method,
|
|
291
|
+
query: tablesQuery(tables, options)
|
|
292
|
+
}, endpoint.response);
|
|
283
293
|
},
|
|
284
294
|
analyze(siteId, params) {
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
const endpoint = analyticsEndpoints.analyze;
|
|
296
|
+
return request(endpoint.path(siteId), {
|
|
297
|
+
method: endpoint.method,
|
|
287
298
|
body: withDefaultSearchType(params),
|
|
288
299
|
dedupe: true
|
|
289
300
|
});
|
|
290
301
|
},
|
|
291
302
|
queryRows(siteId, state) {
|
|
292
|
-
|
|
293
|
-
|
|
303
|
+
const endpoint = analyticsEndpoints.queryRows;
|
|
304
|
+
return request(endpoint.path(siteId), {
|
|
305
|
+
method: endpoint.method,
|
|
294
306
|
body: withDefaultSearchType(state),
|
|
295
307
|
dedupe: true
|
|
296
|
-
},
|
|
308
|
+
}, endpoint.response);
|
|
297
309
|
},
|
|
298
310
|
getRollup(siteId, rollupId, params) {
|
|
299
|
-
|
|
311
|
+
const endpoint = analyticsEndpoints.getRollup;
|
|
312
|
+
return request(endpoint.path(siteId, rollupId), {
|
|
313
|
+
method: endpoint.method,
|
|
314
|
+
query: params
|
|
315
|
+
}, endpoint.response);
|
|
300
316
|
},
|
|
301
317
|
requestBackfill(siteId, range) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
318
|
+
const endpoint = analyticsEndpoints.requestBackfill;
|
|
319
|
+
const body = shouldValidate("request") ? endpoint.body.parse(range) : range;
|
|
320
|
+
return request(endpoint.path(siteId), {
|
|
321
|
+
method: endpoint.method,
|
|
305
322
|
body
|
|
306
|
-
},
|
|
323
|
+
}, endpoint.response);
|
|
307
324
|
},
|
|
308
325
|
getSitemaps(siteId) {
|
|
309
|
-
|
|
326
|
+
const endpoint = analyticsEndpoints.getSitemaps;
|
|
327
|
+
return request(endpoint.path(siteId), { method: endpoint.method }, endpoint.response);
|
|
310
328
|
},
|
|
311
329
|
getSitemapHistory(siteId, hash) {
|
|
312
|
-
|
|
330
|
+
const endpoint = analyticsEndpoints.getSitemapHistory;
|
|
331
|
+
return request(endpoint.path(siteId, hash), { method: endpoint.method }, endpoint.response);
|
|
313
332
|
},
|
|
314
333
|
getSitemapChanges(siteId, params = {}) {
|
|
315
|
-
|
|
334
|
+
const endpoint = analyticsEndpoints.getSitemapChanges;
|
|
335
|
+
return request(endpoint.path(siteId), {
|
|
336
|
+
method: endpoint.method,
|
|
337
|
+
query: params
|
|
338
|
+
}, endpoint.response);
|
|
316
339
|
},
|
|
317
340
|
getInspections(siteId) {
|
|
318
|
-
|
|
341
|
+
const endpoint = analyticsEndpoints.getInspections;
|
|
342
|
+
return request(endpoint.path(siteId), { method: endpoint.method }, endpoint.response);
|
|
319
343
|
},
|
|
320
344
|
getInspectionHistory(siteId, hash) {
|
|
321
|
-
|
|
345
|
+
const endpoint = analyticsEndpoints.getInspectionHistory;
|
|
346
|
+
return request(endpoint.path(siteId, hash), { method: endpoint.method }, endpoint.response);
|
|
322
347
|
},
|
|
323
348
|
getIndexingUrls(siteId, params = {}) {
|
|
324
|
-
|
|
349
|
+
const endpoint = analyticsEndpoints.getIndexingUrls;
|
|
350
|
+
return request(endpoint.path(siteId), {
|
|
351
|
+
method: endpoint.method,
|
|
352
|
+
query: indexingUrlsQuery(params)
|
|
353
|
+
}, endpoint.response);
|
|
325
354
|
},
|
|
326
355
|
getIndexingDiagnostics(siteId, params = {}) {
|
|
327
|
-
const
|
|
328
|
-
|
|
356
|
+
const endpoint = analyticsEndpoints.getIndexingDiagnostics;
|
|
357
|
+
const parsed = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
358
|
+
return request(endpoint.path(siteId), {
|
|
359
|
+
method: endpoint.method,
|
|
360
|
+
query: indexingDiagnosticsQuery(parsed)
|
|
361
|
+
}, endpoint.response);
|
|
329
362
|
},
|
|
330
363
|
requestIndexingInspect(siteId, body) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
364
|
+
const endpoint = analyticsEndpoints.requestIndexingInspect;
|
|
365
|
+
const parsed = shouldValidate("request") ? endpoint.body.parse(body) : body;
|
|
366
|
+
return request(endpoint.path(siteId), {
|
|
367
|
+
method: endpoint.method,
|
|
334
368
|
body: parsed
|
|
335
|
-
},
|
|
369
|
+
}, endpoint.response);
|
|
336
370
|
},
|
|
337
371
|
getCountries(siteId, range) {
|
|
338
|
-
|
|
372
|
+
const endpoint = analyticsEndpoints.getCountries;
|
|
373
|
+
return request(endpoint.path(siteId), {
|
|
374
|
+
method: endpoint.method,
|
|
375
|
+
query: range
|
|
376
|
+
}, endpoint.response);
|
|
339
377
|
},
|
|
340
378
|
getSearchAppearance(siteId, range) {
|
|
341
|
-
|
|
379
|
+
const endpoint = analyticsEndpoints.getSearchAppearance;
|
|
380
|
+
return request(endpoint.path(siteId), {
|
|
381
|
+
method: endpoint.method,
|
|
382
|
+
query: range
|
|
383
|
+
}, endpoint.response);
|
|
342
384
|
}
|
|
343
385
|
};
|
|
344
386
|
}
|
|
@@ -442,6 +484,7 @@ function findLifecycleSite(lifecycle, siteIdOrPropertyUrl) {
|
|
|
442
484
|
const propertyKey = normalizeGscPropertyKey(siteIdOrPropertyUrl);
|
|
443
485
|
return lifecycle.sites.find((site) => site.siteId === siteIdOrPropertyUrl || site.externalSiteId === siteIdOrPropertyUrl || !!propertyKey && normalizeGscPropertyKey(site.gscPropertyUrl) === propertyKey || !site.gscPropertyUrl && normalizeLifecycleUrl(site.requestedUrl) === normalized || !propertyKey && normalizeLifecycleUrl(site.requestedUrl) === normalized) ?? null;
|
|
444
486
|
}
|
|
487
|
+
const endpoints = partnerEndpoints;
|
|
445
488
|
function validateAnalysisParamsResult(params) {
|
|
446
489
|
if ((params.preset === "non-brand" || params.preset === "brand-only") && !params.brandTerms?.trim()) return err(new PartnerApiError({
|
|
447
490
|
kind: "validation",
|
|
@@ -463,7 +506,7 @@ function createPartnerClient(options = {}) {
|
|
|
463
506
|
const intervalMs = waitOptions.intervalMs ?? 1e3;
|
|
464
507
|
let latest = null;
|
|
465
508
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
466
|
-
const result = await requestResult(
|
|
509
|
+
const result = await requestResult(endpoints.getUserStatus.path(userId), { method: endpoints.getUserStatus.method });
|
|
467
510
|
if (!result.ok) return result;
|
|
468
511
|
latest = result.value;
|
|
469
512
|
if (latest.status === "ready") return ok(latest);
|
|
@@ -486,7 +529,7 @@ function createPartnerClient(options = {}) {
|
|
|
486
529
|
const intervalMs = waitOptions.intervalMs ?? 1e3;
|
|
487
530
|
let latest = null;
|
|
488
531
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
489
|
-
const result = await requestResult(
|
|
532
|
+
const result = await requestResult(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method });
|
|
490
533
|
if (!result.ok) return result;
|
|
491
534
|
latest = result.value;
|
|
492
535
|
const status = latest.account.status;
|
|
@@ -513,8 +556,8 @@ function createPartnerClient(options = {}) {
|
|
|
513
556
|
}));
|
|
514
557
|
}
|
|
515
558
|
async function getSiteSyncStatusResult(siteId, userId) {
|
|
516
|
-
if (!userId) return requestResult(
|
|
517
|
-
const lifecycle = await requestResult(
|
|
559
|
+
if (!userId) return requestResult(endpoints.getSyncStatus.path(siteId), { method: endpoints.getSyncStatus.method });
|
|
560
|
+
const lifecycle = await requestResult(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method });
|
|
518
561
|
if (!lifecycle.ok) return lifecycle;
|
|
519
562
|
const site = findLifecycleSite(lifecycle.value, siteId);
|
|
520
563
|
if (!site) return err(new PartnerApiError({
|
|
@@ -530,24 +573,24 @@ function createPartnerClient(options = {}) {
|
|
|
530
573
|
}
|
|
531
574
|
return {
|
|
532
575
|
registerUser(params) {
|
|
533
|
-
const body = shouldValidate("request") ?
|
|
534
|
-
return request(
|
|
535
|
-
method:
|
|
576
|
+
const body = shouldValidate("request") ? endpoints.registerUser.body.parse(params) : params;
|
|
577
|
+
return request(endpoints.registerUser.path, {
|
|
578
|
+
method: endpoints.registerUser.method,
|
|
536
579
|
body
|
|
537
|
-
},
|
|
580
|
+
}, endpoints.registerUser.response);
|
|
538
581
|
},
|
|
539
582
|
updateUserTokens(userId, params) {
|
|
540
|
-
const body = shouldValidate("request") ?
|
|
541
|
-
return request(
|
|
542
|
-
method:
|
|
583
|
+
const body = shouldValidate("request") ? endpoints.updateUserTokens.body.parse(params) : params;
|
|
584
|
+
return request(endpoints.updateUserTokens.path(userId), {
|
|
585
|
+
method: endpoints.updateUserTokens.method,
|
|
543
586
|
body
|
|
544
|
-
},
|
|
587
|
+
}, endpoints.updateUserTokens.response);
|
|
545
588
|
},
|
|
546
589
|
getUserStatus(userId) {
|
|
547
|
-
return request(
|
|
590
|
+
return request(endpoints.getUserStatus.path(userId), { method: endpoints.getUserStatus.method }, endpoints.getUserStatus.response);
|
|
548
591
|
},
|
|
549
592
|
getUserLifecycle(userId) {
|
|
550
|
-
return request(
|
|
593
|
+
return request(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method }, endpoints.getUserLifecycle.response);
|
|
551
594
|
},
|
|
552
595
|
async waitForUserReady(userId, waitOptions = {}) {
|
|
553
596
|
return unwrapResult(await waitForUserReadyResult(userId, waitOptions), waitForUserReadyToException);
|
|
@@ -556,65 +599,80 @@ function createPartnerClient(options = {}) {
|
|
|
556
599
|
return unwrapResult(await waitForUserLifecycleReadyResult(userId, waitOptions), partnerErrorToException);
|
|
557
600
|
},
|
|
558
601
|
getUserSites(userId) {
|
|
559
|
-
return request(
|
|
602
|
+
return request(endpoints.getUserSites.path(userId), { method: endpoints.getUserSites.method }, endpoints.getUserSites.response);
|
|
560
603
|
},
|
|
561
604
|
getAvailableSites(userId) {
|
|
562
|
-
return request(
|
|
605
|
+
return request(endpoints.getAvailableSites.path(userId), { method: endpoints.getAvailableSites.method }, endpoints.getAvailableSites.response);
|
|
563
606
|
},
|
|
564
607
|
registerSite(params) {
|
|
565
|
-
const body = shouldValidate("request") ?
|
|
566
|
-
return request(
|
|
567
|
-
method:
|
|
608
|
+
const body = shouldValidate("request") ? endpoints.registerSite.body.parse(params) : params;
|
|
609
|
+
return request(endpoints.registerSite.path, {
|
|
610
|
+
method: endpoints.registerSite.method,
|
|
568
611
|
body
|
|
569
|
-
},
|
|
612
|
+
}, endpoints.registerSite.response);
|
|
570
613
|
},
|
|
571
614
|
bulkRegisterSites(params) {
|
|
572
|
-
const body = shouldValidate("request") ?
|
|
573
|
-
return request(
|
|
574
|
-
method:
|
|
615
|
+
const body = shouldValidate("request") ? endpoints.bulkRegisterSites.body.parse(params) : params;
|
|
616
|
+
return request(endpoints.bulkRegisterSites.path, {
|
|
617
|
+
method: endpoints.bulkRegisterSites.method,
|
|
575
618
|
body
|
|
576
|
-
},
|
|
619
|
+
}, endpoints.bulkRegisterSites.response);
|
|
577
620
|
},
|
|
578
621
|
deleteUser(userId) {
|
|
579
|
-
return request(
|
|
622
|
+
return request(endpoints.deleteUser.path(userId), { method: endpoints.deleteUser.method }, endpoints.deleteUser.response);
|
|
580
623
|
},
|
|
581
624
|
deleteSite(siteId) {
|
|
582
|
-
return request(
|
|
625
|
+
return request(endpoints.deleteSite.path(siteId), { method: endpoints.deleteSite.method });
|
|
583
626
|
},
|
|
584
627
|
getAnalysisSources(siteId, tables, options) {
|
|
585
|
-
return request(
|
|
628
|
+
return request(endpoints.getAnalysisSources.path(siteId), {
|
|
629
|
+
method: endpoints.getAnalysisSources.method,
|
|
630
|
+
query: tablesQuery(tables, options)
|
|
631
|
+
}, endpoints.getAnalysisSources.response);
|
|
586
632
|
},
|
|
587
633
|
async getSiteSyncStatus(siteId, userId) {
|
|
588
634
|
return unwrapResult(await getSiteSyncStatusResult(siteId, userId), partnerErrorToException);
|
|
589
635
|
},
|
|
590
636
|
getData(siteId, state, queryOptions) {
|
|
591
637
|
if (shouldValidate("request")) {
|
|
592
|
-
|
|
593
|
-
|
|
638
|
+
endpoints.getData.state.parse(state);
|
|
639
|
+
endpoints.getData.options.parse(queryOptions);
|
|
594
640
|
}
|
|
595
|
-
return request(
|
|
641
|
+
return request(endpoints.getData.path(siteId), {
|
|
642
|
+
method: endpoints.getData.method,
|
|
643
|
+
query: dataQuery(state, queryOptions)
|
|
644
|
+
}, endpoints.getData.response);
|
|
596
645
|
},
|
|
597
646
|
getDataDetail(siteId, state, queryOptions) {
|
|
598
647
|
if (shouldValidate("request")) {
|
|
599
|
-
|
|
600
|
-
|
|
648
|
+
endpoints.getDataDetail.state.parse(state);
|
|
649
|
+
endpoints.getDataDetail.options.parse(queryOptions);
|
|
601
650
|
}
|
|
602
|
-
return request(
|
|
651
|
+
return request(endpoints.getDataDetail.path(siteId), {
|
|
652
|
+
method: endpoints.getDataDetail.method,
|
|
653
|
+
query: dataDetailQuery(state, queryOptions)
|
|
654
|
+
}, endpoints.getDataDetail.response);
|
|
603
655
|
},
|
|
604
656
|
getAnalysis(siteId, params) {
|
|
605
657
|
assertAnalysisParams(params);
|
|
606
|
-
const query = shouldValidate("request") ?
|
|
607
|
-
return request(
|
|
658
|
+
const query = shouldValidate("request") ? endpoints.getAnalysis.query.parse(params) : params;
|
|
659
|
+
return request(endpoints.getAnalysis.path(siteId), {
|
|
660
|
+
method: endpoints.getAnalysis.method,
|
|
661
|
+
query: analysisQuery(query)
|
|
662
|
+
}, endpoints.getAnalysis.response);
|
|
608
663
|
},
|
|
609
664
|
getSitemaps(siteId) {
|
|
610
|
-
return request(
|
|
665
|
+
return request(endpoints.getSitemaps.path(siteId), { method: endpoints.getSitemaps.method }, endpoints.getSitemaps.response);
|
|
611
666
|
},
|
|
612
667
|
getSitemapChanges(siteId, days = 28) {
|
|
613
|
-
return request(
|
|
668
|
+
return request(endpoints.getSitemapChanges.path(siteId), {
|
|
669
|
+
method: endpoints.getSitemapChanges.method,
|
|
670
|
+
query: { days }
|
|
671
|
+
}, endpoints.getSitemapChanges.response);
|
|
614
672
|
},
|
|
615
673
|
submitSitemap(siteId, sitemapUrl, action = "submit") {
|
|
616
|
-
return request(
|
|
617
|
-
method:
|
|
674
|
+
return request(endpoints.submitSitemap.path(siteId), {
|
|
675
|
+
method: endpoints.submitSitemap.method,
|
|
618
676
|
body: {
|
|
619
677
|
sitemapUrl,
|
|
620
678
|
action
|
|
@@ -622,137 +680,181 @@ function createPartnerClient(options = {}) {
|
|
|
622
680
|
});
|
|
623
681
|
},
|
|
624
682
|
refreshSitemaps(siteId) {
|
|
625
|
-
return request(
|
|
626
|
-
method:
|
|
683
|
+
return request(endpoints.refreshSitemaps.path(siteId), {
|
|
684
|
+
method: endpoints.refreshSitemaps.method,
|
|
627
685
|
body: { action: "refresh" }
|
|
628
686
|
});
|
|
629
687
|
},
|
|
630
688
|
getIndexing(siteId, days = 28) {
|
|
631
|
-
return request(
|
|
689
|
+
return request(endpoints.getIndexing.path(siteId), {
|
|
690
|
+
method: endpoints.getIndexing.method,
|
|
691
|
+
query: { days }
|
|
692
|
+
}, endpoints.getIndexing.response);
|
|
632
693
|
},
|
|
633
694
|
getIndexingUrls(siteId, params = {}) {
|
|
634
|
-
const parsed = shouldValidate("request") ?
|
|
635
|
-
return request(
|
|
695
|
+
const parsed = shouldValidate("request") ? endpoints.getIndexingUrls.query.parse(params) : params;
|
|
696
|
+
return request(endpoints.getIndexingUrls.path(siteId), {
|
|
697
|
+
method: endpoints.getIndexingUrls.method,
|
|
698
|
+
query: indexingUrlsQuery(parsed)
|
|
699
|
+
}, endpoints.getIndexingUrls.response);
|
|
636
700
|
},
|
|
637
701
|
getIndexingDiagnostics(siteId, params = {}) {
|
|
638
|
-
const parsed = shouldValidate("request") ?
|
|
639
|
-
return request(
|
|
702
|
+
const parsed = shouldValidate("request") ? endpoints.getIndexingDiagnostics.query.parse(params) : params;
|
|
703
|
+
return request(endpoints.getIndexingDiagnostics.path(siteId), {
|
|
704
|
+
method: endpoints.getIndexingDiagnostics.method,
|
|
705
|
+
query: indexingDiagnosticsQuery(parsed)
|
|
706
|
+
}, endpoints.getIndexingDiagnostics.response);
|
|
640
707
|
},
|
|
641
708
|
requestIndexingInspect(siteId, body) {
|
|
642
|
-
const parsed = shouldValidate("request") ?
|
|
643
|
-
return request(
|
|
644
|
-
method:
|
|
709
|
+
const parsed = shouldValidate("request") ? endpoints.requestIndexingInspect.body.parse(body) : body;
|
|
710
|
+
return request(endpoints.requestIndexingInspect.path(siteId), {
|
|
711
|
+
method: endpoints.requestIndexingInspect.method,
|
|
645
712
|
body: parsed
|
|
646
|
-
},
|
|
713
|
+
}, endpoints.requestIndexingInspect.response);
|
|
647
714
|
},
|
|
648
715
|
getUserSettings() {
|
|
649
|
-
return request(
|
|
716
|
+
return request(endpoints.getUserSettings.path, { method: endpoints.getUserSettings.method }, endpoints.getUserSettings.response);
|
|
650
717
|
},
|
|
651
718
|
patchUserSettings(body) {
|
|
652
|
-
const parsed = shouldValidate("request") ?
|
|
653
|
-
return request(
|
|
654
|
-
method:
|
|
719
|
+
const parsed = shouldValidate("request") ? endpoints.patchUserSettings.body.parse(body) : body;
|
|
720
|
+
return request(endpoints.patchUserSettings.path, {
|
|
721
|
+
method: endpoints.patchUserSettings.method,
|
|
655
722
|
body: parsed
|
|
656
|
-
},
|
|
723
|
+
}, endpoints.patchUserSettings.response);
|
|
657
724
|
},
|
|
658
725
|
recoverPermission(siteId) {
|
|
659
|
-
return request(
|
|
726
|
+
return request(endpoints.recoverPermission.path(siteId), { method: endpoints.recoverPermission.method }, endpoints.recoverPermission.response);
|
|
660
727
|
},
|
|
661
728
|
getTopAssociation(siteId, params) {
|
|
662
|
-
const query = shouldValidate("request") ?
|
|
663
|
-
return request(
|
|
729
|
+
const query = shouldValidate("request") ? endpoints.getTopAssociation.query.parse(params) : params;
|
|
730
|
+
return request(endpoints.getTopAssociation.path(siteId), {
|
|
731
|
+
method: endpoints.getTopAssociation.method,
|
|
732
|
+
query
|
|
733
|
+
}, endpoints.getTopAssociation.response);
|
|
664
734
|
},
|
|
665
735
|
getKeywordSparklines(siteId, params) {
|
|
666
736
|
const withSearchType = {
|
|
667
737
|
...params,
|
|
668
738
|
searchType: params.searchType ?? "web"
|
|
669
739
|
};
|
|
670
|
-
const body = shouldValidate("request") ?
|
|
671
|
-
return request(
|
|
672
|
-
method:
|
|
740
|
+
const body = shouldValidate("request") ? endpoints.getKeywordSparklines.body.parse(withSearchType) : withSearchType;
|
|
741
|
+
return request(endpoints.getKeywordSparklines.path(siteId), {
|
|
742
|
+
method: endpoints.getKeywordSparklines.method,
|
|
673
743
|
body,
|
|
674
744
|
dedupe: true
|
|
675
|
-
},
|
|
745
|
+
}, endpoints.getKeywordSparklines.response);
|
|
676
746
|
},
|
|
677
747
|
getQueryTrend(siteId, params) {
|
|
678
|
-
const query = shouldValidate("request") ?
|
|
679
|
-
return request(
|
|
748
|
+
const query = shouldValidate("request") ? endpoints.getQueryTrend.query.parse(params) : params;
|
|
749
|
+
return request(endpoints.getQueryTrend.path(siteId), {
|
|
750
|
+
method: endpoints.getQueryTrend.method,
|
|
751
|
+
query: queryTrendQuery(query)
|
|
752
|
+
}, endpoints.getQueryTrend.response);
|
|
680
753
|
},
|
|
681
754
|
getPageTrend(siteId, params) {
|
|
682
|
-
const query = shouldValidate("request") ?
|
|
683
|
-
return request(
|
|
755
|
+
const query = shouldValidate("request") ? endpoints.getPageTrend.query.parse(params) : params;
|
|
756
|
+
return request(endpoints.getPageTrend.path(siteId), {
|
|
757
|
+
method: endpoints.getPageTrend.method,
|
|
758
|
+
query: pageTrendQuery(query)
|
|
759
|
+
}, endpoints.getPageTrend.response);
|
|
684
760
|
},
|
|
685
761
|
getCanonicalMismatches(siteId) {
|
|
686
|
-
return request(
|
|
762
|
+
return request(endpoints.getCanonicalMismatches.path(siteId), { method: endpoints.getCanonicalMismatches.method }, endpoints.getCanonicalMismatches.response);
|
|
687
763
|
},
|
|
688
764
|
getContentVelocity(siteId, days) {
|
|
689
|
-
return request(
|
|
765
|
+
return request(endpoints.getContentVelocity.path(siteId), {
|
|
766
|
+
method: endpoints.getContentVelocity.method,
|
|
767
|
+
query: days == null ? void 0 : { days }
|
|
768
|
+
});
|
|
690
769
|
},
|
|
691
770
|
getCtrCurve(siteId, params) {
|
|
692
|
-
const
|
|
693
|
-
|
|
771
|
+
const endpoint = endpoints.getCtrCurve;
|
|
772
|
+
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
773
|
+
return request(endpoint.path(siteId), {
|
|
774
|
+
method: endpoint.method,
|
|
775
|
+
query: dateRangeQuery(query)
|
|
776
|
+
});
|
|
694
777
|
},
|
|
695
778
|
getDarkTraffic(siteId, params) {
|
|
696
|
-
const
|
|
697
|
-
|
|
779
|
+
const endpoint = endpoints.getDarkTraffic;
|
|
780
|
+
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
781
|
+
return request(endpoint.path(siteId), {
|
|
782
|
+
method: endpoint.method,
|
|
783
|
+
query: dateRangeQuery(query)
|
|
784
|
+
});
|
|
698
785
|
},
|
|
699
786
|
getDeviceGap(siteId, params) {
|
|
700
|
-
const
|
|
701
|
-
|
|
787
|
+
const endpoint = endpoints.getDeviceGap;
|
|
788
|
+
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
789
|
+
return request(endpoint.path(siteId), {
|
|
790
|
+
method: endpoint.method,
|
|
791
|
+
query: dateRangeQuery(query)
|
|
792
|
+
});
|
|
702
793
|
},
|
|
703
794
|
getIndexPercent(siteId, params = {}) {
|
|
704
|
-
const query = shouldValidate("request") ?
|
|
705
|
-
return request(
|
|
795
|
+
const query = shouldValidate("request") ? endpoints.getIndexPercent.query.parse(params) : params;
|
|
796
|
+
return request(endpoints.getIndexPercent.path(siteId), {
|
|
797
|
+
method: endpoints.getIndexPercent.method,
|
|
798
|
+
query
|
|
799
|
+
}, endpoints.getIndexPercent.response);
|
|
706
800
|
},
|
|
707
801
|
getKeywordBreadth(siteId, params) {
|
|
708
|
-
const
|
|
709
|
-
|
|
802
|
+
const endpoint = endpoints.getKeywordBreadth;
|
|
803
|
+
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
804
|
+
return request(endpoint.path(siteId), {
|
|
805
|
+
method: endpoint.method,
|
|
806
|
+
query: dateRangeQuery(query)
|
|
807
|
+
});
|
|
710
808
|
},
|
|
711
809
|
getPositionDistribution(siteId, params) {
|
|
712
|
-
const
|
|
713
|
-
|
|
810
|
+
const endpoint = endpoints.getPositionDistribution;
|
|
811
|
+
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
812
|
+
return request(endpoint.path(siteId), {
|
|
813
|
+
method: endpoint.method,
|
|
814
|
+
query: dateRangeQuery(query)
|
|
815
|
+
});
|
|
714
816
|
},
|
|
715
817
|
createTeam(params) {
|
|
716
|
-
const body = shouldValidate("request") ?
|
|
717
|
-
return request(
|
|
718
|
-
method:
|
|
818
|
+
const body = shouldValidate("request") ? endpoints.createTeam.body.parse(params) : params;
|
|
819
|
+
return request(endpoints.createTeam.path, {
|
|
820
|
+
method: endpoints.createTeam.method,
|
|
719
821
|
body
|
|
720
|
-
},
|
|
822
|
+
}, endpoints.createTeam.response);
|
|
721
823
|
},
|
|
722
824
|
renameTeam(teamId, params) {
|
|
723
|
-
return request(
|
|
724
|
-
method:
|
|
825
|
+
return request(endpoints.renameTeam.path(teamId), {
|
|
826
|
+
method: endpoints.renameTeam.method,
|
|
725
827
|
body: params
|
|
726
828
|
});
|
|
727
829
|
},
|
|
728
830
|
deleteTeam(teamId) {
|
|
729
|
-
return request(
|
|
831
|
+
return request(endpoints.deleteTeam.path(teamId), { method: endpoints.deleteTeam.method });
|
|
730
832
|
},
|
|
731
833
|
listTeamMembers(teamId) {
|
|
732
|
-
return request(
|
|
834
|
+
return request(endpoints.listTeamMembers.path(teamId), { method: endpoints.listTeamMembers.method }, endpoints.listTeamMembers.response);
|
|
733
835
|
},
|
|
734
836
|
addTeamMember(teamId, params) {
|
|
735
|
-
const body = shouldValidate("request") ?
|
|
736
|
-
return request(
|
|
737
|
-
method:
|
|
837
|
+
const body = shouldValidate("request") ? endpoints.addTeamMember.body.parse(params) : params;
|
|
838
|
+
return request(endpoints.addTeamMember.path(teamId), {
|
|
839
|
+
method: endpoints.addTeamMember.method,
|
|
738
840
|
body
|
|
739
|
-
},
|
|
841
|
+
}, endpoints.addTeamMember.response);
|
|
740
842
|
},
|
|
741
843
|
updateTeamMemberRole(teamId, userId, params) {
|
|
742
|
-
return request(
|
|
743
|
-
method:
|
|
844
|
+
return request(endpoints.updateTeamMemberRole.path(teamId, userId), {
|
|
845
|
+
method: endpoints.updateTeamMemberRole.method,
|
|
744
846
|
body: params
|
|
745
847
|
});
|
|
746
848
|
},
|
|
747
849
|
removeTeamMember(teamId, userId) {
|
|
748
|
-
return request(
|
|
850
|
+
return request(endpoints.removeTeamMember.path(teamId, userId), { method: endpoints.removeTeamMember.method });
|
|
749
851
|
},
|
|
750
852
|
bindSiteToTeam(userId, siteId, params) {
|
|
751
|
-
const body = shouldValidate("request") ?
|
|
752
|
-
return request(
|
|
753
|
-
method:
|
|
853
|
+
const body = shouldValidate("request") ? endpoints.bindSiteToTeam.body.parse(params) : params;
|
|
854
|
+
return request(endpoints.bindSiteToTeam.path(userId, siteId), {
|
|
855
|
+
method: endpoints.bindSiteToTeam.method,
|
|
754
856
|
body
|
|
755
|
-
},
|
|
857
|
+
}, endpoints.bindSiteToTeam.response);
|
|
756
858
|
}
|
|
757
859
|
};
|
|
758
860
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.37.
|
|
4
|
+
"version": "0.37.5",
|
|
5
5
|
"description": "Consumer SDK for hosted gscdump.com integrations.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"date-fns": "^4.4.0",
|
|
45
45
|
"ofetch": "^1.5.1",
|
|
46
46
|
"zod": "^4.4.3",
|
|
47
|
-
"@gscdump/
|
|
48
|
-
"@gscdump/
|
|
49
|
-
"@gscdump/engine": "0.37.
|
|
50
|
-
"gscdump": "0.37.
|
|
47
|
+
"@gscdump/contracts": "0.37.5",
|
|
48
|
+
"@gscdump/analysis": "0.37.5",
|
|
49
|
+
"@gscdump/engine": "0.37.5",
|
|
50
|
+
"gscdump": "0.37.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typescript": "^6.0.3",
|