@gscdump/sdk 3.4.4 → 3.6.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 +19 -55
- package/dist/analytics-client.d.mts +6 -7
- package/dist/anonymization.d.mts +2 -3
- package/dist/archetype-compile.d.mts +4 -5
- package/dist/archetype-compile.mjs +30 -10
- package/dist/client.d.mts +6 -7
- package/dist/country-names.d.mts +1 -2
- package/dist/cwv-thresholds.d.mts +10 -11
- package/dist/errors.d.mts +5 -6
- package/dist/errors.mjs +8 -2
- package/dist/gsc-console-url.d.mts +2 -3
- package/dist/gsc-constants.d.mts +1 -2
- package/dist/gsc-error.d.mts +3 -4
- package/dist/gsc-period-presets.d.mts +8 -9
- package/dist/gsc-rows.d.mts +8 -9
- package/dist/hosted-query.d.mts +13 -13
- package/dist/indexing-issues.d.mts +7 -8
- package/dist/lifecycle.d.mts +5 -6
- package/dist/period.d.mts +13 -14
- package/dist/request.d.mts +5 -6
- package/dist/search-console-stage.d.mts +11 -12
- package/dist/site-baseline.d.mts +10 -11
- package/dist/site-triage.d.mts +12 -13
- package/dist/v1/http.d.mts +15 -16
- package/dist/v1/http.mjs +1 -0
- package/dist/v1/realtime.d.mts +16 -17
- package/dist/v1/realtime.mjs +2 -2
- package/dist/webhook.d.mts +5 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,17 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Consumer SDK for hosted gscdump.com integrations.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
This package is for partner applications that consume gscdump.com APIs,
|
|
13
|
-
webhooks, and realtime events. Callers inject the HTTP transport and auth they
|
|
14
|
-
want to use; route construction stays inside the hosted adapter. New hosted
|
|
15
|
-
HTTP integrations should import the stable v1 client:
|
|
5
|
+
Use `@gscdump/sdk/v1` for hosted HTTP and realtime clients.
|
|
6
|
+
The package root has no export.
|
|
7
|
+
Keep long-lived credentials on your server.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @gscdump/sdk
|
|
11
|
+
```
|
|
16
12
|
|
|
17
13
|
```ts
|
|
18
14
|
import { createGscdumpV1Client } from '@gscdump/sdk/v1'
|
|
@@ -28,7 +24,7 @@ const lifecycle = await gscdump.getUserLifecycle({
|
|
|
28
24
|
```
|
|
29
25
|
|
|
30
26
|
The v1 surface uses a server-held Bearer credential and exposes a generic
|
|
31
|
-
operation executor plus typed convenience methods for all
|
|
27
|
+
operation executor plus typed convenience methods for all 55 registered HTTP
|
|
32
28
|
operations across partner, analytics, and realtime.
|
|
33
29
|
|
|
34
30
|
Focused guides:
|
|
@@ -59,51 +55,19 @@ const report = await gscdump.queryAnalyticsReport({
|
|
|
59
55
|
})
|
|
60
56
|
```
|
|
61
57
|
|
|
62
|
-
##
|
|
63
|
-
|
|
64
|
-
- Partner user lifecycle
|
|
65
|
-
- Partner site lifecycle
|
|
66
|
-
- Data/detail queries
|
|
67
|
-
- Analysis presets
|
|
68
|
-
- Sitemap and indexing reads
|
|
69
|
-
- Webhook receiver contracts and HMAC verification helpers
|
|
70
|
-
- Shared request/response types re-exported from `@gscdump/contracts`
|
|
71
|
-
|
|
72
|
-
Analyzer Source dispatch, browser DuckDB-WASM boot, and R2 parquet attach are
|
|
73
|
-
separate engine/Nuxt concerns. A Nuxt app can consume the hosted SDK through
|
|
74
|
-
its own query layer; the current consumer uses `nuxt-use-query` rather than
|
|
75
|
-
making the public API depend on `@gscdump/nuxt`.
|
|
76
|
-
|
|
77
|
-
For v1, a Nuxt consumer keeps `user_key` and `partner_key` credentials on its
|
|
78
|
-
server and exposes proxy paths that retain the upstream surface and major
|
|
79
|
-
(for example `/api/gscdump/analytics/v1/...`). Browser realtime receives only
|
|
80
|
-
a single-use ticket. Every semantic event's `changes[]` maps to one ordered,
|
|
81
|
-
awaited query-cache effect; unsafe resync purges the whole host-owned cache
|
|
82
|
-
scope and primary-reseeds it before the SDK advances its cursor or ACKs.
|
|
83
|
-
|
|
84
|
-
## Boundary
|
|
85
|
-
|
|
86
|
-
`@gscdump/sdk` is a consumer SDK. It must not own gscdump.com producer
|
|
87
|
-
behavior.
|
|
88
|
-
|
|
89
|
-
Belongs here:
|
|
58
|
+
## Browser integration
|
|
90
59
|
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
- awaited realtime apply/resync hooks; a rejected effect never advances ACK
|
|
95
|
-
- webhook header constants, event schemas, parsing, normalization, and signature
|
|
96
|
-
verification for receivers
|
|
60
|
+
Keep `user_key` and `partner_key` credentials on your server.
|
|
61
|
+
Expose a same-origin proxy that preserves the upstream surface and major version, such as `/api/gscdump/analytics/v1/...`.
|
|
62
|
+
The browser receives a single-use realtime ticket.
|
|
97
63
|
|
|
98
|
-
|
|
64
|
+
Your `applyEvent` callback must await every cache change before the SDK advances its cursor or sends an ACK.
|
|
65
|
+
Your `resync` callback must clear the affected cache scope and reload authoritative state.
|
|
66
|
+
See the [realtime guide](../../docs/guides/hosted-v1.md#realtime) for the client hooks.
|
|
99
67
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- generating or storing production webhook secrets
|
|
104
|
-
- creating production webhook delivery IDs or envelopes
|
|
105
|
-
- partner subscription filtering for outgoing deliveries
|
|
106
|
-
- Durable Object stream storage, replay retention, or outbox dispatch
|
|
68
|
+
The SDK provides HTTP transport, realtime state, and webhook receiver helpers.
|
|
69
|
+
Your application owns authentication, caching, and UI integration.
|
|
70
|
+
gscdump.com owns webhook delivery, queues, and storage.
|
|
107
71
|
|
|
108
72
|
## Webhooks
|
|
109
73
|
|
|
@@ -115,7 +79,7 @@ delivery.
|
|
|
115
79
|
```ts
|
|
116
80
|
import { parseWebhookPayload } from '@gscdump/sdk/webhook'
|
|
117
81
|
|
|
118
|
-
const envelope = await parseWebhookPayload(
|
|
82
|
+
const envelope = await parseWebhookPayload(await request.text(), {
|
|
119
83
|
secret: webhookSecret,
|
|
120
84
|
signature: request.headers.get('x-gscdump-signature'),
|
|
121
85
|
})
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { AnalysisSourcesOptions, SearchTypeOptions, SourceRangeOptions } from "./hosted-query.mjs";
|
|
2
2
|
import { HostedClientOptions, HostedFetch, HostedFetchOptions, HostedHeaders } from "./request.mjs";
|
|
3
3
|
import { AnalysisSourcesResponse, BackfillRange, BackfillResponse, BulkFileResolutionRequest, BulkFileResolutionResponse, CountriesResponse, IndexingDiagnostics, IndexingDiagnosticsParams, IndexingInspectRateLimited, IndexingInspectRequest, IndexingInspectResponse, IndexingUrlStatus, IndexingUrlsResponse, InspectionHistoryResponse, InspectionIndex, QueryDimSourceResponse, RollupEnvelope, SearchAppearanceResponse, SiteListItem, SourceInfoOptions, SourceInfoResponse, WhoamiResponse } from "@gscdump/contracts";
|
|
4
|
-
type AnalyticsFetch = HostedFetch;
|
|
5
|
-
type AnalyticsHeaders = HostedHeaders;
|
|
6
|
-
type AnalyticsFetchOptions = HostedFetchOptions;
|
|
7
|
-
interface AnalyticsClientOptions extends HostedClientOptions {
|
|
4
|
+
export type AnalyticsFetch = HostedFetch;
|
|
5
|
+
export type AnalyticsHeaders = HostedHeaders;
|
|
6
|
+
export type AnalyticsFetchOptions = HostedFetchOptions;
|
|
7
|
+
export interface AnalyticsClientOptions extends HostedClientOptions {
|
|
8
8
|
apiBase?: string;
|
|
9
9
|
fetch?: AnalyticsFetch;
|
|
10
10
|
headers?: AnalyticsHeaders;
|
|
11
11
|
validate?: boolean | 'request' | 'response';
|
|
12
12
|
}
|
|
13
13
|
/** Hosted analytics transport exposed by `@gscdump/sdk`. */
|
|
14
|
-
interface AnalyticsClient {
|
|
14
|
+
export interface AnalyticsClient {
|
|
15
15
|
whoami: () => Promise<WhoamiResponse>;
|
|
16
16
|
listSites: () => Promise<SiteListItem[]>;
|
|
17
17
|
getBulkSources: (params: BulkFileResolutionRequest) => Promise<BulkFileResolutionResponse>;
|
|
@@ -44,5 +44,4 @@ interface AnalyticsClient {
|
|
|
44
44
|
end: string;
|
|
45
45
|
}) => Promise<SearchAppearanceResponse>;
|
|
46
46
|
}
|
|
47
|
-
declare function createAnalyticsClient(options?: AnalyticsClientOptions): AnalyticsClient;
|
|
48
|
-
export { AnalyticsClient, AnalyticsClientOptions, AnalyticsFetch, AnalyticsFetchOptions, AnalyticsHeaders, createAnalyticsClient };
|
|
47
|
+
export declare function createAnalyticsClient(options?: AnalyticsClientOptions): AnalyticsClient;
|
package/dist/anonymization.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
interface DailyAnonInput {
|
|
1
|
+
export interface DailyAnonInput {
|
|
2
2
|
impressions: number;
|
|
3
3
|
anonymizedImpressionsPct: number;
|
|
4
4
|
}
|
|
5
|
-
declare function weightedAnonPct(days: readonly DailyAnonInput[] | null | undefined, window?: number): number | null;
|
|
6
|
-
export { DailyAnonInput, weightedAnonPct };
|
|
5
|
+
export declare function weightedAnonPct(days: readonly DailyAnonInput[] | null | undefined, window?: number): number | null;
|
|
@@ -5,8 +5,8 @@ import { ArchetypeQuery, GscSearchType, WireDateRange } from "@gscdump/contracts
|
|
|
5
5
|
* either accepted format (SDK-branded or partner wire). Returns `null` when no
|
|
6
6
|
* complete range is present.
|
|
7
7
|
*/
|
|
8
|
-
declare function extractWireDateRange(filter: unknown): WireDateRange | null;
|
|
9
|
-
interface BuilderStateToArchetypeOptions {
|
|
8
|
+
export declare function extractWireDateRange(filter: unknown): WireDateRange | null;
|
|
9
|
+
export interface BuilderStateToArchetypeOptions {
|
|
10
10
|
searchType?: GscSearchType;
|
|
11
11
|
compareRange?: WireDateRange;
|
|
12
12
|
}
|
|
@@ -32,7 +32,7 @@ interface BuilderStateToArchetypeOptions {
|
|
|
32
32
|
* hardcoded to `url, query` regardless of which two dims were requested) —
|
|
33
33
|
* returns `null`.
|
|
34
34
|
*/
|
|
35
|
-
declare function builderStateToArchetype(siteId: string,
|
|
35
|
+
export declare function builderStateToArchetype(siteId: string, input: BuilderState, opts?: BuilderStateToArchetypeOptions): ArchetypeQuery | null;
|
|
36
36
|
/**
|
|
37
37
|
* Archetypes a hosted seam's execution wrapper can safely serve end-to-end
|
|
38
38
|
* today (rows + an ACCURATE `totalCount`/`totals`, matching the legacy
|
|
@@ -44,5 +44,4 @@ declare function builderStateToArchetype(siteId: string, state: BuilderState, op
|
|
|
44
44
|
* rather than serve a wrong `totalCount`. Revisit once the contract grows
|
|
45
45
|
* those fields.
|
|
46
46
|
*/
|
|
47
|
-
declare function archetypeSeamSupportsQuery(query: ArchetypeQuery): boolean;
|
|
48
|
-
export { BuilderStateToArchetypeOptions, archetypeSeamSupportsQuery, builderStateToArchetype, extractWireDateRange };
|
|
47
|
+
export declare function archetypeSeamSupportsQuery(query: ArchetypeQuery): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { entityDailyTimeseries, multiSeriesStackedDaily, siteDailyTimeseries, topNBreakdown, twoDimensionDetail } from "@gscdump/contracts/archetypes";
|
|
2
|
-
import { extractDateRange,
|
|
2
|
+
import { extractDateRange, normalizeBuilderStateResult } from "gscdump/query";
|
|
3
3
|
const KNOWN_DIMENSIONS = /* @__PURE__ */ new Set([
|
|
4
4
|
"query",
|
|
5
5
|
"queryCanonical",
|
|
@@ -41,21 +41,34 @@ function collectEqualityMatches(filter, out) {
|
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
43
|
function extractWireDateRange(filter) {
|
|
44
|
-
const
|
|
44
|
+
const parsed = normalizeBuilderStateResult({ filter });
|
|
45
|
+
if (!parsed.ok) return null;
|
|
46
|
+
const { startDate, endDate } = extractDateRange(parsed.value.filter);
|
|
45
47
|
return startDate && endDate ? {
|
|
46
48
|
start: startDate,
|
|
47
49
|
end: endDate
|
|
48
50
|
} : null;
|
|
49
51
|
}
|
|
50
|
-
function builderStateToArchetype(siteId,
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
52
|
+
function builderStateToArchetype(siteId, input, opts = {}) {
|
|
53
|
+
const parsed = normalizeBuilderStateResult(input);
|
|
54
|
+
if (!parsed.ok) return null;
|
|
55
|
+
const state = parsed.value;
|
|
56
|
+
if (state.prefilter !== void 0 || state.dataState !== void 0 || state.aggregationType !== void 0) return null;
|
|
57
|
+
const { startDate, endDate } = extractDateRange(state.filter);
|
|
58
|
+
if (!startDate || !endDate) return null;
|
|
59
|
+
const range = {
|
|
60
|
+
start: startDate,
|
|
61
|
+
end: endDate
|
|
62
|
+
};
|
|
53
63
|
const matches = /* @__PURE__ */ new Map();
|
|
54
|
-
if (!collectEqualityMatches(
|
|
64
|
+
if (!collectEqualityMatches(state.filter, matches)) return null;
|
|
55
65
|
const dims = state.dimensions ?? [];
|
|
56
66
|
if (dims.some((d) => !KNOWN_DIMENSIONS.has(d))) return null;
|
|
57
67
|
if (dims.includes("hour") || dims.includes("searchAppearance")) return null;
|
|
58
|
-
|
|
68
|
+
if (dims.includes("date") && (state.rowLimit !== void 0 || state.startRow !== void 0 || state.orderBy !== void 0)) return null;
|
|
69
|
+
if (state.orderBy?.column === "date") return null;
|
|
70
|
+
const searchType = opts.searchType ?? state.searchType;
|
|
71
|
+
const metrics = state.metrics;
|
|
59
72
|
const cmp = opts.compareRange;
|
|
60
73
|
const order = state.orderBy ? {
|
|
61
74
|
metric: state.orderBy.column,
|
|
@@ -72,21 +85,25 @@ function builderStateToArchetype(siteId, state, opts = {}) {
|
|
|
72
85
|
value: matches.get(dim)
|
|
73
86
|
}, {
|
|
74
87
|
searchType,
|
|
75
|
-
compareRange: cmp
|
|
88
|
+
compareRange: cmp,
|
|
89
|
+
metrics
|
|
76
90
|
});
|
|
77
91
|
}
|
|
78
92
|
if (matches.size > 0) return null;
|
|
79
93
|
return siteDailyTimeseries(siteId, range, {
|
|
80
94
|
searchType,
|
|
81
|
-
compareRange: cmp
|
|
95
|
+
compareRange: cmp,
|
|
96
|
+
metrics
|
|
82
97
|
});
|
|
83
98
|
}
|
|
84
99
|
if (dims.length === 2 && dims.includes("date")) {
|
|
85
100
|
if (matches.size > 0) return null;
|
|
101
|
+
if (metrics !== void 0 && metrics.length !== 1) return null;
|
|
86
102
|
const series = dims.find((d) => d !== "date");
|
|
87
103
|
return multiSeriesStackedDaily(siteId, range, series, {
|
|
88
104
|
searchType,
|
|
89
|
-
compareRange: cmp
|
|
105
|
+
compareRange: cmp,
|
|
106
|
+
metric: metrics?.[0]
|
|
90
107
|
});
|
|
91
108
|
}
|
|
92
109
|
if (dims.length === 1 && dims[0] !== "date") {
|
|
@@ -99,6 +116,7 @@ function builderStateToArchetype(siteId, state, opts = {}) {
|
|
|
99
116
|
}));
|
|
100
117
|
return topNBreakdown(siteId, range, primary, {
|
|
101
118
|
searchType,
|
|
119
|
+
metrics,
|
|
102
120
|
compareRange: cmp,
|
|
103
121
|
...order ? { orderBy: order } : {},
|
|
104
122
|
limit: state.rowLimit ?? 50,
|
|
@@ -107,11 +125,13 @@ function builderStateToArchetype(siteId, state, opts = {}) {
|
|
|
107
125
|
});
|
|
108
126
|
}
|
|
109
127
|
if (dims.length === 2 && !dims.includes("date")) {
|
|
128
|
+
if (state.startRow !== void 0 && state.startRow !== 0) return null;
|
|
110
129
|
const set = new Set(dims);
|
|
111
130
|
if (!set.has("page") || !set.has("query")) return null;
|
|
112
131
|
if (matches.size > 0) return null;
|
|
113
132
|
return twoDimensionDetail(siteId, range, {
|
|
114
133
|
searchType,
|
|
134
|
+
metrics,
|
|
115
135
|
compareRange: cmp,
|
|
116
136
|
...order ? { orderBy: order } : {},
|
|
117
137
|
...state.rowLimit ? { limit: state.rowLimit } : {}
|
package/dist/client.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AnalysisSourcesOptions, SearchTypeOptions, SourceRangeOptions } from "./hosted-query.mjs";
|
|
2
2
|
import { HostedClientOptions, HostedFetch, HostedFetchOptions, HostedHeaders } from "./request.mjs";
|
|
3
3
|
import { BuilderStateWire, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, DataDetailOptions, DataQueryOptions, GscAddAndVerifyResponse, GscVerificationRequest, GscVerificationTokenResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingResponse, GscdumpIndexingUrlsResponse, GscdumpSiteRegistration, GscdumpSyncStatusResponse, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingDiagnosticsParams, IndexingUrlsParams, PartnerLifecycleResponse, RegisterPartnerSiteParams, RegisterPartnerUserParams, UpdatePartnerUserTokensParams } from "@gscdump/contracts";
|
|
4
|
-
type PartnerFetch = HostedFetch;
|
|
5
|
-
type PartnerHeaders = HostedHeaders;
|
|
6
|
-
type PartnerFetchOptions = HostedFetchOptions;
|
|
7
|
-
interface PartnerClientOptions extends HostedClientOptions {
|
|
4
|
+
export type PartnerFetch = HostedFetch;
|
|
5
|
+
export type PartnerHeaders = HostedHeaders;
|
|
6
|
+
export type PartnerFetchOptions = HostedFetchOptions;
|
|
7
|
+
export interface PartnerClientOptions extends HostedClientOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Origin API base. Use `/api` for same-origin Nitro routes, or pass a full
|
|
10
10
|
* remote origin base from the host app. The client has no baked-in origin.
|
|
@@ -20,7 +20,7 @@ interface PartnerClientOptions extends HostedClientOptions {
|
|
|
20
20
|
validate?: boolean | 'request' | 'response';
|
|
21
21
|
}
|
|
22
22
|
/** Hosted partner transport exposed by `@gscdump/sdk`. */
|
|
23
|
-
interface PartnerClient {
|
|
23
|
+
export interface PartnerClient {
|
|
24
24
|
registerUser: (params: RegisterPartnerUserParams) => Promise<GscdumpUserRegistration>;
|
|
25
25
|
updateUserTokens: (userId: string, params: UpdatePartnerUserTokensParams) => Promise<GscdumpUserTokenUpdate>;
|
|
26
26
|
getUserStatus: (userId: string) => Promise<GscdumpUserStatus>;
|
|
@@ -56,5 +56,4 @@ interface PartnerClient {
|
|
|
56
56
|
getUserSettings: () => Promise<GscdumpUserSettings>;
|
|
57
57
|
patchUserSettings: (body: Partial<GscdumpUserSettings>) => Promise<GscdumpUserSettings>;
|
|
58
58
|
}
|
|
59
|
-
declare function createPartnerClient(options?: PartnerClientOptions): PartnerClient;
|
|
60
|
-
export { PartnerClient, PartnerClientOptions, PartnerFetch, PartnerFetchOptions, PartnerHeaders, createPartnerClient };
|
|
59
|
+
export declare function createPartnerClient(options?: PartnerClientOptions): PartnerClient;
|
package/dist/country-names.d.mts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare const countryName: (code: string) => string;
|
|
2
|
-
export { countryName };
|
|
1
|
+
export declare const countryName: (code: string) => string;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
declare const CWV_GOOD_LCP = 2500;
|
|
2
|
-
declare const CWV_POOR_LCP = 4000;
|
|
3
|
-
declare const CWV_GOOD_INP = 200;
|
|
4
|
-
declare const CWV_POOR_INP = 500;
|
|
5
|
-
declare const CWV_GOOD_CLS = 0.1;
|
|
6
|
-
declare const CWV_POOR_CLS = 0.25;
|
|
7
|
-
type CwvBucket = 'good' | 'ni' | 'poor';
|
|
8
|
-
declare function cwvBucket(metric: 'lcp' | 'inp' | 'cls', v: number): CwvBucket;
|
|
1
|
+
export declare const CWV_GOOD_LCP = 2500;
|
|
2
|
+
export declare const CWV_POOR_LCP = 4000;
|
|
3
|
+
export declare const CWV_GOOD_INP = 200;
|
|
4
|
+
export declare const CWV_POOR_INP = 500;
|
|
5
|
+
export declare const CWV_GOOD_CLS = 0.1;
|
|
6
|
+
export declare const CWV_POOR_CLS = 0.25;
|
|
7
|
+
export type CwvBucket = 'good' | 'ni' | 'poor';
|
|
8
|
+
export declare function cwvBucket(metric: 'lcp' | 'inp' | 'cls', v: number): CwvBucket;
|
|
9
9
|
/** Trim long query strings for table cells / chart tooltips. */
|
|
10
|
-
declare function truncateQuery(q: string, max?: number): string;
|
|
10
|
+
export declare function truncateQuery(q: string, max?: number): string;
|
|
11
11
|
/** Best-effort extract a hostname; returns undefined if the URL is unparseable. */
|
|
12
|
-
declare function siteUrlToHostname(url: string | undefined | null): string | undefined;
|
|
13
|
-
export { CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, CwvBucket, cwvBucket, siteUrlToHostname, truncateQuery };
|
|
12
|
+
export declare function siteUrlToHostname(url: string | undefined | null): string | undefined;
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
type PartnerErrorKind = 'auth' | 'rate-limit' | 'provisioning' | 'permission' | 'network' | 'validation' | 'not-found' | 'server' | 'unknown';
|
|
2
|
-
interface PartnerErrorInfo {
|
|
1
|
+
export type PartnerErrorKind = 'auth' | 'rate-limit' | 'provisioning' | 'permission' | 'network' | 'validation' | 'not-found' | 'server' | 'unknown';
|
|
2
|
+
export interface PartnerErrorInfo {
|
|
3
3
|
kind: PartnerErrorKind;
|
|
4
4
|
statusCode?: number;
|
|
5
5
|
message: string;
|
|
6
6
|
data?: unknown;
|
|
7
7
|
}
|
|
8
|
-
declare class PartnerApiError extends Error {
|
|
8
|
+
export declare class PartnerApiError extends Error {
|
|
9
9
|
readonly kind: PartnerErrorKind;
|
|
10
10
|
readonly statusCode?: number;
|
|
11
11
|
readonly data?: unknown;
|
|
12
12
|
constructor(info: PartnerErrorInfo);
|
|
13
13
|
}
|
|
14
|
-
declare function toPartnerError(error: unknown): PartnerApiError;
|
|
14
|
+
export declare function toPartnerError(error: unknown): PartnerApiError;
|
|
15
15
|
/**
|
|
16
16
|
* Re-raise a modelled `PartnerApiError` as itself. The error variant of every
|
|
17
17
|
* `*Result` core already IS the throwable `PartnerApiError`, so the throwing
|
|
18
18
|
* wrappers preserve the exact identity/message existing call sites and tests
|
|
19
19
|
* assert (`rejects.toThrow(PartnerApiError)`, `toThrow('Invalid webhook signature')`).
|
|
20
20
|
*/
|
|
21
|
-
declare function partnerErrorToException(error: PartnerApiError): PartnerApiError;
|
|
22
|
-
export { PartnerApiError, PartnerErrorInfo, PartnerErrorKind, partnerErrorToException, toPartnerError };
|
|
21
|
+
export declare function partnerErrorToException(error: PartnerApiError): PartnerApiError;
|
package/dist/errors.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ZodError } from "zod";
|
|
1
2
|
var PartnerApiError = class extends Error {
|
|
2
3
|
kind;
|
|
3
4
|
statusCode;
|
|
@@ -12,11 +13,11 @@ var PartnerApiError = class extends Error {
|
|
|
12
13
|
};
|
|
13
14
|
function statusOf(error) {
|
|
14
15
|
const rec = error;
|
|
15
|
-
return rec
|
|
16
|
+
return rec?.statusCode ?? rec?.status ?? rec?.response?.status;
|
|
16
17
|
}
|
|
17
18
|
function messageOf(error) {
|
|
18
19
|
const rec = error;
|
|
19
|
-
return rec
|
|
20
|
+
return rec?.data?.message ?? rec?.data?.statusMessage ?? rec?.message ?? rec?.statusMessage ?? String(error);
|
|
20
21
|
}
|
|
21
22
|
function kindOf(status, message) {
|
|
22
23
|
if (status === 401 || status === 403) return "auth";
|
|
@@ -31,6 +32,11 @@ function kindOf(status, message) {
|
|
|
31
32
|
}
|
|
32
33
|
function toPartnerError(error) {
|
|
33
34
|
if (error instanceof PartnerApiError) return error;
|
|
35
|
+
if (error instanceof ZodError) return new PartnerApiError({
|
|
36
|
+
kind: "validation",
|
|
37
|
+
message: error.message,
|
|
38
|
+
data: { issues: error.issues }
|
|
39
|
+
});
|
|
34
40
|
const statusCode = statusOf(error);
|
|
35
41
|
const message = messageOf(error);
|
|
36
42
|
const data = error?.data;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface GscConsoleUrlOpts {
|
|
1
|
+
export interface GscConsoleUrlOpts {
|
|
2
2
|
/** The GSC property — either `sc-domain:example.com` or a URL-prefix. */
|
|
3
3
|
siteLabel: string;
|
|
4
4
|
/** Optional page to open Performance drilldown for. */
|
|
@@ -8,5 +8,4 @@ interface GscConsoleUrlOpts {
|
|
|
8
8
|
/** Resource: `performance`, `url-inspection`, `sitemaps`, … */
|
|
9
9
|
resource?: 'performance' | 'url-inspection' | 'sitemaps' | 'index';
|
|
10
10
|
}
|
|
11
|
-
declare function gscConsoleUrl(opts: GscConsoleUrlOpts): string;
|
|
12
|
-
export { GscConsoleUrlOpts, gscConsoleUrl };
|
|
11
|
+
export declare function gscConsoleUrl(opts: GscConsoleUrlOpts): string;
|
package/dist/gsc-constants.d.mts
CHANGED
package/dist/gsc-error.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type GscErrorStatus = 'auth-missing' | 'rate-limited' | 'network' | 'error';
|
|
2
|
-
interface GscClassifiedError {
|
|
1
|
+
export type GscErrorStatus = 'auth-missing' | 'rate-limited' | 'network' | 'error';
|
|
2
|
+
export interface GscClassifiedError {
|
|
3
3
|
status: GscErrorStatus;
|
|
4
4
|
/** HTTP status code if the error came from a response, otherwise undefined. */
|
|
5
5
|
code?: number;
|
|
@@ -8,5 +8,4 @@ interface GscClassifiedError {
|
|
|
8
8
|
/** Seconds the server suggested waiting (429/503 retry payloads). */
|
|
9
9
|
retryAfter?: number;
|
|
10
10
|
}
|
|
11
|
-
declare function classifyGscError(e: unknown): GscClassifiedError;
|
|
12
|
-
export { GscClassifiedError, GscErrorStatus, classifyGscError };
|
|
11
|
+
export declare function classifyGscError(e: unknown): GscClassifiedError;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { CompareMode, Period } from "./period.mjs";
|
|
2
|
-
type GscColumn = 'clicks' | 'impressions' | 'ctr' | 'position';
|
|
3
|
-
interface GscColumnOption {
|
|
2
|
+
export type GscColumn = 'clicks' | 'impressions' | 'ctr' | 'position';
|
|
3
|
+
export interface GscColumnOption {
|
|
4
4
|
key: GscColumn;
|
|
5
5
|
label: string;
|
|
6
6
|
icon: string;
|
|
7
7
|
color: string;
|
|
8
8
|
}
|
|
9
|
-
interface PeriodPreset {
|
|
9
|
+
export interface PeriodPreset {
|
|
10
10
|
value: Period;
|
|
11
11
|
label: string;
|
|
12
12
|
shortLabel: string;
|
|
13
13
|
group: 'rolling' | 'calendar';
|
|
14
14
|
}
|
|
15
|
-
declare const PERIOD_PRESETS: PeriodPreset[];
|
|
16
|
-
declare const COMPARE_OPTIONS: {
|
|
15
|
+
export declare const PERIOD_PRESETS: PeriodPreset[];
|
|
16
|
+
export declare const COMPARE_OPTIONS: {
|
|
17
17
|
value: CompareMode;
|
|
18
18
|
label: string;
|
|
19
19
|
description: string;
|
|
20
20
|
}[];
|
|
21
|
-
declare const GSC_PERIOD_OPTIONS: {
|
|
21
|
+
export declare const GSC_PERIOD_OPTIONS: {
|
|
22
22
|
label: string;
|
|
23
23
|
value: Period;
|
|
24
24
|
longLabel: string;
|
|
25
25
|
}[];
|
|
26
|
-
declare const GSC_PERIOD_OPTIONS_LONG: {
|
|
26
|
+
export declare const GSC_PERIOD_OPTIONS_LONG: {
|
|
27
27
|
label: string;
|
|
28
28
|
value: Period;
|
|
29
29
|
}[];
|
|
30
|
-
declare const GSC_COLUMN_OPTIONS: GscColumnOption[];
|
|
31
|
-
export { COMPARE_OPTIONS, GSC_COLUMN_OPTIONS, GSC_PERIOD_OPTIONS, GSC_PERIOD_OPTIONS_LONG, GscColumn, GscColumnOption, PERIOD_PRESETS, PeriodPreset };
|
|
30
|
+
export declare const GSC_COLUMN_OPTIONS: GscColumnOption[];
|
package/dist/gsc-rows.d.mts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
interface RawDailyRow {
|
|
1
|
+
export interface RawDailyRow {
|
|
2
2
|
date: string;
|
|
3
3
|
clicks: number;
|
|
4
4
|
impressions: number;
|
|
5
5
|
sum_position?: number;
|
|
6
6
|
position?: number;
|
|
7
7
|
}
|
|
8
|
-
interface CanonicalDailyRow {
|
|
8
|
+
export interface CanonicalDailyRow {
|
|
9
9
|
date: string;
|
|
10
10
|
clicks: number;
|
|
11
11
|
impressions: number;
|
|
12
12
|
sum_position: number;
|
|
13
13
|
}
|
|
14
|
-
interface GscRowTotals {
|
|
14
|
+
export interface GscRowTotals {
|
|
15
15
|
clicks: number;
|
|
16
16
|
impressions: number;
|
|
17
17
|
ctr: number;
|
|
18
18
|
position: number;
|
|
19
19
|
}
|
|
20
|
-
interface GscDailySummary {
|
|
20
|
+
export interface GscDailySummary {
|
|
21
21
|
daily: CanonicalDailyRow[];
|
|
22
22
|
totals: GscRowTotals;
|
|
23
23
|
chartData: Array<{
|
|
@@ -32,7 +32,7 @@ interface GscDailySummary {
|
|
|
32
32
|
* sentinel — the old `Math.max(1, …)` clamp synthesized rank #1 (sum 0 with
|
|
33
33
|
* full impression weight) for such rows instead of contributing nothing.
|
|
34
34
|
*/
|
|
35
|
-
declare function coerceRowMetrics<T extends {
|
|
35
|
+
export declare function coerceRowMetrics<T extends {
|
|
36
36
|
impressions: number;
|
|
37
37
|
sum_position?: number;
|
|
38
38
|
position?: number;
|
|
@@ -40,15 +40,14 @@ declare function coerceRowMetrics<T extends {
|
|
|
40
40
|
sum_position: number;
|
|
41
41
|
};
|
|
42
42
|
/** Sort daily rows by date asc, coerce `sum_position`, reduce totals, derive chartData. */
|
|
43
|
-
declare function summarizeDailyRows(raw: readonly RawDailyRow[]): GscDailySummary;
|
|
43
|
+
export declare function summarizeDailyRows(raw: readonly RawDailyRow[]): GscDailySummary;
|
|
44
44
|
/**
|
|
45
45
|
* Rollup-row position helper. `sum_position` is GSC's average-position sum
|
|
46
46
|
* across impressions; dividing back out (+1 because GSC is 1-indexed) gives
|
|
47
47
|
* the impression-weighted average position. Returns 0 when there were no
|
|
48
48
|
* impressions so the column renders blank rather than NaN.
|
|
49
49
|
*/
|
|
50
|
-
declare function positionFor(r: {
|
|
50
|
+
export declare function positionFor(r: {
|
|
51
51
|
impressions: number;
|
|
52
52
|
sum_position: number;
|
|
53
|
-
}): number;
|
|
54
|
-
export { CanonicalDailyRow, GscDailySummary, GscRowTotals, RawDailyRow, coerceRowMetrics, positionFor, summarizeDailyRows };
|
|
53
|
+
}): number;
|
package/dist/hosted-query.d.mts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { BuilderStateWire, DataDetailOptions, DataQueryOptions, IndexingDiagnosticsParams, IndexingUrlsParams, SourceInfoOptions } from "@gscdump/contracts";
|
|
2
2
|
import { GscSearchType, GscSearchType as GscSearchType$2 } from "@gscdump/contracts/search-types";
|
|
3
|
-
interface SearchTypeOptions {
|
|
3
|
+
export interface SearchTypeOptions {
|
|
4
4
|
searchType?: GscSearchType$2;
|
|
5
5
|
}
|
|
6
|
-
interface SourceRangeOptions {
|
|
6
|
+
export interface SourceRangeOptions {
|
|
7
7
|
start?: string;
|
|
8
8
|
end?: string;
|
|
9
9
|
startDate?: string;
|
|
10
10
|
endDate?: string;
|
|
11
11
|
}
|
|
12
|
-
interface AnalysisSourcesOptions extends SearchTypeOptions, SourceRangeOptions {
|
|
12
|
+
export interface AnalysisSourcesOptions extends SearchTypeOptions, SourceRangeOptions {
|
|
13
13
|
tables?: string[] | string;
|
|
14
14
|
maxBytes?: number;
|
|
15
15
|
maxRows?: number;
|
|
16
16
|
maxFiles?: number;
|
|
17
17
|
}
|
|
18
|
-
declare const DEFAULT_SEARCH_TYPE: GscSearchType$2;
|
|
19
|
-
declare function withDefaultSearchType<T extends object>(value: T, searchType?: GscSearchType$2): T & SearchTypeOptions & Record<string, unknown>;
|
|
20
|
-
declare function withDefaultSearchType<T>(value: T, searchType?: GscSearchType$2): T;
|
|
21
|
-
declare function sourceInfoQuery(options: SourceInfoOptions | undefined): Record<string, string>;
|
|
22
|
-
declare function tablesQuery(tablesOrOptions: string[] | string | AnalysisSourcesOptions | undefined, options?: AnalysisSourcesOptions): Record<string, string>;
|
|
23
|
-
declare function dataQuery(state: BuilderStateWire, options?: DataQueryOptions): Record<string, string>;
|
|
24
|
-
declare function dataDetailQuery(state: BuilderStateWire, options?: DataDetailOptions): Record<string, string>;
|
|
25
|
-
declare function indexingUrlsQuery(params?: IndexingUrlsParams): Record<string, string | number>;
|
|
26
|
-
declare function indexingDiagnosticsQuery(params?: IndexingDiagnosticsParams): Record<string, string | number>;
|
|
27
|
-
export {
|
|
18
|
+
export declare const DEFAULT_SEARCH_TYPE: GscSearchType$2;
|
|
19
|
+
export declare function withDefaultSearchType<T extends object>(value: T, searchType?: GscSearchType$2): T & SearchTypeOptions & Record<string, unknown>;
|
|
20
|
+
export declare function withDefaultSearchType<T>(value: T, searchType?: GscSearchType$2): T;
|
|
21
|
+
export declare function sourceInfoQuery(options: SourceInfoOptions | undefined): Record<string, string>;
|
|
22
|
+
export declare function tablesQuery(tablesOrOptions: string[] | string | AnalysisSourcesOptions | undefined, options?: AnalysisSourcesOptions): Record<string, string>;
|
|
23
|
+
export declare function dataQuery(state: BuilderStateWire, options?: DataQueryOptions): Record<string, string>;
|
|
24
|
+
export declare function dataDetailQuery(state: BuilderStateWire, options?: DataDetailOptions): Record<string, string>;
|
|
25
|
+
export declare function indexingUrlsQuery(params?: IndexingUrlsParams): Record<string, string | number>;
|
|
26
|
+
export declare function indexingDiagnosticsQuery(params?: IndexingDiagnosticsParams): Record<string, string | number>;
|
|
27
|
+
export type { GscSearchType };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
interface IndexingIssueDetail {
|
|
1
|
+
export interface IndexingIssueDetail {
|
|
2
2
|
description: string;
|
|
3
3
|
fix: string;
|
|
4
4
|
}
|
|
5
|
-
type IssueSeverity = 'error' | 'warning' | 'info';
|
|
6
|
-
interface IndexingIssue {
|
|
5
|
+
export type IssueSeverity = 'error' | 'warning' | 'info';
|
|
6
|
+
export interface IndexingIssue {
|
|
7
7
|
type: string;
|
|
8
8
|
label: string;
|
|
9
9
|
severity: IssueSeverity;
|
|
@@ -11,9 +11,9 @@ interface IndexingIssue {
|
|
|
11
11
|
description: string;
|
|
12
12
|
fix: string;
|
|
13
13
|
}
|
|
14
|
-
declare const issueDetails: Record<string, IndexingIssueDetail>;
|
|
15
|
-
declare const severityOrder: IssueSeverity[];
|
|
16
|
-
interface IssueGroup {
|
|
14
|
+
export declare const issueDetails: Record<string, IndexingIssueDetail>;
|
|
15
|
+
export declare const severityOrder: IssueSeverity[];
|
|
16
|
+
export interface IssueGroup {
|
|
17
17
|
id: string;
|
|
18
18
|
label: string;
|
|
19
19
|
icon: string;
|
|
@@ -27,5 +27,4 @@ interface IssueGroup {
|
|
|
27
27
|
/** Issue types belonging to this group */
|
|
28
28
|
issueTypes: string[];
|
|
29
29
|
}
|
|
30
|
-
declare const issueGroups: IssueGroup[];
|
|
31
|
-
export { IndexingIssue, IndexingIssueDetail, IssueGroup, IssueSeverity, issueDetails, issueGroups, severityOrder };
|
|
30
|
+
export declare const issueGroups: IssueGroup[];
|
package/dist/lifecycle.d.mts
CHANGED
|
@@ -4,10 +4,9 @@ import { GscdumpSyncStatusResponse, GscdumpUserSite, PartnerLifecycleSite } from
|
|
|
4
4
|
* Keeping the adapters structural lets consumers migrate to v1 without
|
|
5
5
|
* re-introducing legacy-only fields such as `intId` or `lifecycleRevision`.
|
|
6
6
|
*/
|
|
7
|
-
type LifecycleSiteLike = Pick<PartnerLifecycleSite, 'siteId' | 'externalSiteId' | 'requestedUrl' | 'gscPropertyUrl' | 'permissionLevel' | 'analytics' | 'indexing' | 'latestError' | 'updatedAt'>;
|
|
8
|
-
declare function analyticsStatusToSyncStatus(status: LifecycleSiteLike['analytics']['status']): GscdumpUserSite['syncStatus'];
|
|
9
|
-
declare function lifecycleSiteToSyncStatus(site: LifecycleSiteLike): GscdumpSyncStatusResponse;
|
|
10
|
-
declare function findLifecycleSite<TSite extends LifecycleSiteLike>(lifecycle: {
|
|
7
|
+
export type LifecycleSiteLike = Pick<PartnerLifecycleSite, 'siteId' | 'externalSiteId' | 'requestedUrl' | 'gscPropertyUrl' | 'permissionLevel' | 'analytics' | 'indexing' | 'latestError' | 'updatedAt'>;
|
|
8
|
+
export declare function analyticsStatusToSyncStatus(status: LifecycleSiteLike['analytics']['status']): GscdumpUserSite['syncStatus'];
|
|
9
|
+
export declare function lifecycleSiteToSyncStatus(site: LifecycleSiteLike): GscdumpSyncStatusResponse;
|
|
10
|
+
export declare function findLifecycleSite<TSite extends LifecycleSiteLike>(lifecycle: {
|
|
11
11
|
sites: readonly TSite[];
|
|
12
|
-
}, siteIdOrPropertyUrl: string): TSite | null;
|
|
13
|
-
export { LifecycleSiteLike, analyticsStatusToSyncStatus, findLifecycleSite, lifecycleSiteToSyncStatus };
|
|
12
|
+
}, siteIdOrPropertyUrl: string): TSite | null;
|
package/dist/period.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
type RollingPeriod = '7d' | '28d' | '3m' | '6m' | '12m';
|
|
2
|
-
type CalendarPeriod = 'this-week' | 'this-month' | 'last-month' | 'this-quarter' | 'this-year';
|
|
1
|
+
export type RollingPeriod = '7d' | '28d' | '3m' | '6m' | '12m';
|
|
2
|
+
export type CalendarPeriod = 'this-week' | 'this-month' | 'last-month' | 'this-quarter' | 'this-year';
|
|
3
3
|
/**
|
|
4
4
|
* Custom date range from drag-to-zoom.
|
|
5
5
|
* - `custom:CS:CE` - current range only; prev range resolved by compareMode.
|
|
6
6
|
* - `custom:CS:CE:PS:PE` - explicit prev range.
|
|
7
7
|
*/
|
|
8
|
-
type CustomPeriod = `custom:${string}:${string}` | `custom:${string}:${string}:${string}:${string}`;
|
|
9
|
-
type Period = RollingPeriod | CalendarPeriod | CustomPeriod;
|
|
10
|
-
type CompareMode = 'previous' | 'year' | 'none';
|
|
11
|
-
interface DateRangeResult {
|
|
8
|
+
export type CustomPeriod = `custom:${string}:${string}` | `custom:${string}:${string}:${string}:${string}`;
|
|
9
|
+
export type Period = RollingPeriod | CalendarPeriod | CustomPeriod;
|
|
10
|
+
export type CompareMode = 'previous' | 'year' | 'none';
|
|
11
|
+
export interface DateRangeResult {
|
|
12
12
|
start: string;
|
|
13
13
|
end: string;
|
|
14
14
|
prevStart: string;
|
|
@@ -17,7 +17,7 @@ interface DateRangeResult {
|
|
|
17
17
|
yearEnd: string;
|
|
18
18
|
days: number;
|
|
19
19
|
}
|
|
20
|
-
interface PeriodOptions {
|
|
20
|
+
export interface PeriodOptions {
|
|
21
21
|
/** Subtract GSC's stable-data latency from `end`. Default `true`. */
|
|
22
22
|
stableData?: boolean;
|
|
23
23
|
/** IANA timezone used to resolve today's calendar date. Default GSC/Pacific time. */
|
|
@@ -25,16 +25,16 @@ interface PeriodOptions {
|
|
|
25
25
|
/** Clock used to resolve today's calendar date. Defaults to the current time. */
|
|
26
26
|
now?: Date;
|
|
27
27
|
}
|
|
28
|
-
declare function isCustomPeriod(p: Period | string): p is CustomPeriod;
|
|
29
|
-
declare function parseCustomPeriod(p: Period | string): {
|
|
28
|
+
export declare function isCustomPeriod(p: Period | string): p is CustomPeriod;
|
|
29
|
+
export declare function parseCustomPeriod(p: Period | string): {
|
|
30
30
|
start: string;
|
|
31
31
|
end: string;
|
|
32
32
|
prevStart?: string;
|
|
33
33
|
prevEnd?: string;
|
|
34
34
|
} | null;
|
|
35
|
-
declare function periodToDateRange(period: Period | string, stableDataOrOptions?: boolean | PeriodOptions): DateRangeResult;
|
|
36
|
-
declare function periodToDays(period: Period | string, stableDataOrOptions?: boolean | PeriodOptions): number;
|
|
37
|
-
declare function compareRange(range: DateRangeResult, mode: CompareMode): {
|
|
35
|
+
export declare function periodToDateRange(period: Period | string, stableDataOrOptions?: boolean | PeriodOptions): DateRangeResult;
|
|
36
|
+
export declare function periodToDays(period: Period | string, stableDataOrOptions?: boolean | PeriodOptions): number;
|
|
37
|
+
export declare function compareRange(range: DateRangeResult, mode: CompareMode): {
|
|
38
38
|
start: string;
|
|
39
39
|
end: string;
|
|
40
40
|
} | null;
|
|
@@ -45,5 +45,4 @@ declare function compareRange(range: DateRangeResult, mode: CompareMode): {
|
|
|
45
45
|
*
|
|
46
46
|
* Uses YYYY-MM-DD string math directly to avoid UTC/local timezone shifts.
|
|
47
47
|
*/
|
|
48
|
-
declare function getGscUnstableCutoffDate(): string;
|
|
49
|
-
export { CalendarPeriod, CompareMode, CustomPeriod, DateRangeResult, Period, PeriodOptions, RollingPeriod, compareRange, getGscUnstableCutoffDate, isCustomPeriod, parseCustomPeriod, periodToDateRange, periodToDays };
|
|
48
|
+
export declare function getGscUnstableCutoffDate(): string;
|
package/dist/request.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PartnerApiError } from "./errors.mjs";
|
|
2
2
|
import { Result } from "gscdump/result";
|
|
3
3
|
import { ZodTypeAny } from "zod";
|
|
4
|
-
type HostedFetch = <T = unknown>(request: string, options?: HostedFetchOptions) => Promise<T>;
|
|
5
|
-
type HostedHeaders = HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
6
|
-
interface HostedFetchOptions {
|
|
4
|
+
export type HostedFetch = <T = unknown>(request: string, options?: HostedFetchOptions) => Promise<T>;
|
|
5
|
+
export type HostedHeaders = HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
6
|
+
export interface HostedFetchOptions {
|
|
7
7
|
method?: string;
|
|
8
8
|
headers?: HeadersInit;
|
|
9
9
|
query?: Record<string, unknown>;
|
|
@@ -12,7 +12,7 @@ interface HostedFetchOptions {
|
|
|
12
12
|
dedupe?: boolean;
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
|
-
interface HostedClientOptions {
|
|
15
|
+
export interface HostedClientOptions {
|
|
16
16
|
apiBase?: string;
|
|
17
17
|
fetch?: HostedFetch;
|
|
18
18
|
headers?: HostedHeaders;
|
|
@@ -21,5 +21,4 @@ interface HostedClientOptions {
|
|
|
21
21
|
dedupe?: boolean;
|
|
22
22
|
/** Optional shared in-flight map for de-duping across related client instances. */
|
|
23
23
|
dedupeScope?: Map<string, Promise<Result<unknown, PartnerApiError>>>;
|
|
24
|
-
}
|
|
25
|
-
export { HostedClientOptions, HostedFetch, HostedFetchOptions, HostedHeaders };
|
|
24
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
type SearchConsoleStageKey = 'not_connected' | 'waiting_for_data' | 'weak_discovery' | 'discovery_backlog' | 'crawl_blocked' | 'indexability_blocked' | 'index_rejection' | 'partially_indexed' | 'indexed_invisible' | 'visible_not_clicked' | 'ranking_stalled' | 'declining_visibility' | 'healthy_growth_ready';
|
|
2
|
-
type SearchConsoleStageSeverity = 'success' | 'error' | 'warning' | 'info' | 'neutral';
|
|
3
|
-
interface SearchConsoleStageEvidence {
|
|
1
|
+
export type SearchConsoleStageKey = 'not_connected' | 'waiting_for_data' | 'weak_discovery' | 'discovery_backlog' | 'crawl_blocked' | 'indexability_blocked' | 'index_rejection' | 'partially_indexed' | 'indexed_invisible' | 'visible_not_clicked' | 'ranking_stalled' | 'declining_visibility' | 'healthy_growth_ready';
|
|
2
|
+
export type SearchConsoleStageSeverity = 'success' | 'error' | 'warning' | 'info' | 'neutral';
|
|
3
|
+
export interface SearchConsoleStageEvidence {
|
|
4
4
|
label: string;
|
|
5
5
|
value: string;
|
|
6
6
|
source: 'connection' | 'indexing' | 'sitemap' | 'performance' | 'inspection' | 'canonical';
|
|
7
7
|
}
|
|
8
|
-
interface SearchConsoleStage {
|
|
8
|
+
export interface SearchConsoleStage {
|
|
9
9
|
key: SearchConsoleStageKey;
|
|
10
10
|
label: string;
|
|
11
11
|
severity: SearchConsoleStageSeverity;
|
|
@@ -15,13 +15,13 @@ interface SearchConsoleStage {
|
|
|
15
15
|
evidence: SearchConsoleStageEvidence[];
|
|
16
16
|
sprintFindingTypes: string[];
|
|
17
17
|
}
|
|
18
|
-
interface SearchConsoleStageIssue {
|
|
18
|
+
export interface SearchConsoleStageIssue {
|
|
19
19
|
type: string;
|
|
20
20
|
label: string;
|
|
21
21
|
severity?: 'error' | 'warning' | 'info';
|
|
22
22
|
count: number;
|
|
23
23
|
}
|
|
24
|
-
interface SearchConsoleStageSummary {
|
|
24
|
+
export interface SearchConsoleStageSummary {
|
|
25
25
|
totalUrls: number;
|
|
26
26
|
indexed: number;
|
|
27
27
|
indexedPercent: number;
|
|
@@ -37,7 +37,7 @@ interface SearchConsoleStageSummary {
|
|
|
37
37
|
* days before computing these, and the 7-day window is intentionally absent —
|
|
38
38
|
* it is too lag-contaminated to classify on.
|
|
39
39
|
*/
|
|
40
|
-
interface SearchConsoleStageTrajectory {
|
|
40
|
+
export interface SearchConsoleStageTrajectory {
|
|
41
41
|
clicksPct90d?: number | null;
|
|
42
42
|
impressionsPct90d?: number | null;
|
|
43
43
|
positionDelta90d?: number | null;
|
|
@@ -49,18 +49,18 @@ interface SearchConsoleStageTrajectory {
|
|
|
49
49
|
*/
|
|
50
50
|
clicksPrior28d?: number | null;
|
|
51
51
|
}
|
|
52
|
-
interface SearchConsoleStageSitemap {
|
|
52
|
+
export interface SearchConsoleStageSitemap {
|
|
53
53
|
errors?: number | null;
|
|
54
54
|
warnings?: number | null;
|
|
55
55
|
lastError?: string | null;
|
|
56
56
|
urlCount?: number | null;
|
|
57
57
|
}
|
|
58
|
-
interface SearchConsoleStagePage {
|
|
58
|
+
export interface SearchConsoleStagePage {
|
|
59
59
|
impressions: number;
|
|
60
60
|
clicks: number;
|
|
61
61
|
position?: number | null;
|
|
62
62
|
}
|
|
63
|
-
interface ClassifySearchConsoleStageInput {
|
|
63
|
+
export interface ClassifySearchConsoleStageInput {
|
|
64
64
|
connected: boolean;
|
|
65
65
|
indexingStatus?: 'pending' | 'partial' | 'complete' | 'unknown' | string | null;
|
|
66
66
|
summary?: SearchConsoleStageSummary | null;
|
|
@@ -95,5 +95,4 @@ interface ClassifySearchConsoleStageInput {
|
|
|
95
95
|
* v2 classifier. Direct indexing evidence remains actionable at any traffic
|
|
96
96
|
* volume. Comparative reach claims require enough current observations.
|
|
97
97
|
*/
|
|
98
|
-
declare function classifySearchConsoleStage(input: ClassifySearchConsoleStageInput): SearchConsoleStage;
|
|
99
|
-
export { ClassifySearchConsoleStageInput, SearchConsoleStage, SearchConsoleStageEvidence, SearchConsoleStageIssue, SearchConsoleStageKey, SearchConsoleStagePage, SearchConsoleStageSeverity, SearchConsoleStageSitemap, SearchConsoleStageSummary, SearchConsoleStageTrajectory, classifySearchConsoleStage };
|
|
98
|
+
export declare function classifySearchConsoleStage(input: ClassifySearchConsoleStageInput): SearchConsoleStage;
|
package/dist/site-baseline.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
type SiteType = 'saas' | 'ecommerce' | 'docs' | 'blog' | 'agency' | 'portfolio' | 'other';
|
|
1
|
+
export type SiteType = 'saas' | 'ecommerce' | 'docs' | 'blog' | 'agency' | 'portfolio' | 'other';
|
|
2
2
|
/**
|
|
3
3
|
* Normalise the AI profile `type` to the closed enum. The categoriser mostly
|
|
4
4
|
* emits the 7 values but occasionally leaks free-text (e.g. "event") or null
|
|
5
5
|
* (~40% of live sites are unprofiled) — everything unknown collapses to `other`
|
|
6
6
|
* so downstream logic always has a defined bucket.
|
|
7
7
|
*/
|
|
8
|
-
declare function normalizeSiteType(raw: string | null | undefined): SiteType;
|
|
9
|
-
interface SiteTypeBaseline {
|
|
8
|
+
export declare function normalizeSiteType(raw: string | null | undefined): SiteType;
|
|
9
|
+
export interface SiteTypeBaseline {
|
|
10
10
|
label: string;
|
|
11
11
|
/**
|
|
12
12
|
* Whether indexed-coverage% is a meaningful health signal for this type.
|
|
@@ -24,10 +24,10 @@ interface SiteTypeBaseline {
|
|
|
24
24
|
/** The default growth lever when the site is healthy and leading. */
|
|
25
25
|
primaryGoal: 'content' | 'authority' | 'conversion' | 'coverage';
|
|
26
26
|
}
|
|
27
|
-
declare function siteTypeBaseline(raw: string | null | undefined): SiteTypeBaseline;
|
|
28
|
-
type PeerStanding = 'leader' | 'on_par' | 'behind' | 'unknown';
|
|
27
|
+
export declare function siteTypeBaseline(raw: string | null | undefined): SiteTypeBaseline;
|
|
28
|
+
export type PeerStanding = 'leader' | 'on_par' | 'behind' | 'unknown';
|
|
29
29
|
/** How much to trust the standing: a median over 1–2 peers is noisy. */
|
|
30
|
-
type PeerConfidence = 'high' | 'low' | 'none';
|
|
30
|
+
export type PeerConfidence = 'high' | 'low' | 'none';
|
|
31
31
|
/**
|
|
32
32
|
* Peer metrics from tracked competitors (`siteCompetitors`). Domain rank is the
|
|
33
33
|
* DataForSEO-derived 0–100 score (`min(100, log10(keywordCount)*20)`), NOT a
|
|
@@ -35,13 +35,13 @@ type PeerConfidence = 'high' | 'low' | 'none';
|
|
|
35
35
|
* The site's OWN metrics are not stored alongside competitors, so callers must
|
|
36
36
|
* supply them (one cheap cached `estimateDomainTraffic` call).
|
|
37
37
|
*/
|
|
38
|
-
interface PeerBaselineInput {
|
|
38
|
+
export interface PeerBaselineInput {
|
|
39
39
|
siteDomainRank?: number | null;
|
|
40
40
|
siteOrganicTraffic?: number | null;
|
|
41
41
|
competitorDomainRanks?: number[] | null;
|
|
42
42
|
competitorOrganicTraffic?: number[] | null;
|
|
43
43
|
}
|
|
44
|
-
interface SiteBaseline {
|
|
44
|
+
export interface SiteBaseline {
|
|
45
45
|
siteType: SiteType;
|
|
46
46
|
baseline: SiteTypeBaseline;
|
|
47
47
|
peerStanding: PeerStanding;
|
|
@@ -53,7 +53,7 @@ interface SiteBaseline {
|
|
|
53
53
|
goalKind: SiteTypeBaseline['primaryGoal'];
|
|
54
54
|
}
|
|
55
55
|
/** Standing is decided on domain rank first; organic traffic breaks the tie. */
|
|
56
|
-
declare function derivePeerStanding(input: PeerBaselineInput): {
|
|
56
|
+
export declare function derivePeerStanding(input: PeerBaselineInput): {
|
|
57
57
|
standing: PeerStanding;
|
|
58
58
|
confidence: PeerConfidence;
|
|
59
59
|
peerMedianDomainRank: number | null;
|
|
@@ -64,5 +64,4 @@ declare function derivePeerStanding(input: PeerBaselineInput): {
|
|
|
64
64
|
* defends and expands on its type's lever; a site that's behind closes the gap
|
|
65
65
|
* on the same lever; unknown standing falls back to the type default.
|
|
66
66
|
*/
|
|
67
|
-
declare function deriveSiteBaseline(rawType: string | null | undefined, peer?: PeerBaselineInput): SiteBaseline;
|
|
68
|
-
export { PeerBaselineInput, PeerConfidence, PeerStanding, SiteBaseline, SiteType, SiteTypeBaseline, derivePeerStanding, deriveSiteBaseline, normalizeSiteType, siteTypeBaseline };
|
|
67
|
+
export declare function deriveSiteBaseline(rawType: string | null | undefined, peer?: PeerBaselineInput): SiteBaseline;
|
package/dist/site-triage.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SearchConsoleStageIssue } from "./search-console-stage.mjs";
|
|
2
|
-
type ReachStage = 'emerging' | 'growing' | 'plateaued' | 'declining' | 'faded' | 'decayed';
|
|
3
|
-
type HealthStage = 'healthy' | 'crawl_faults' | 'quality_rejection';
|
|
4
|
-
interface TriageEvidence {
|
|
2
|
+
export type ReachStage = 'emerging' | 'growing' | 'plateaued' | 'declining' | 'faded' | 'decayed';
|
|
3
|
+
export type HealthStage = 'healthy' | 'crawl_faults' | 'quality_rejection';
|
|
4
|
+
export interface TriageEvidence {
|
|
5
5
|
label: string;
|
|
6
6
|
value: string;
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ interface TriageEvidence {
|
|
|
16
16
|
*
|
|
17
17
|
* `gapLabel` is always a concrete count (pages/clicks/points), never a bare %.
|
|
18
18
|
*/
|
|
19
|
-
interface StageProgression {
|
|
19
|
+
export interface StageProgression {
|
|
20
20
|
nextStage: ReachStage | HealthStage | null;
|
|
21
21
|
metric: string;
|
|
22
22
|
value: number;
|
|
@@ -25,27 +25,27 @@ interface StageProgression {
|
|
|
25
25
|
gapLabel: string;
|
|
26
26
|
direction: 'advance' | 'escape' | 'sustain';
|
|
27
27
|
}
|
|
28
|
-
interface ReachVerdict {
|
|
28
|
+
export interface ReachVerdict {
|
|
29
29
|
stage: ReachStage;
|
|
30
30
|
summary: string;
|
|
31
31
|
primaryAction: string;
|
|
32
32
|
evidence: TriageEvidence[];
|
|
33
33
|
progression: StageProgression;
|
|
34
34
|
}
|
|
35
|
-
interface HealthVerdict {
|
|
35
|
+
export interface HealthVerdict {
|
|
36
36
|
stage: HealthStage;
|
|
37
37
|
summary: string;
|
|
38
38
|
primaryAction: string;
|
|
39
39
|
evidence: TriageEvidence[];
|
|
40
40
|
progression: StageProgression;
|
|
41
41
|
}
|
|
42
|
-
interface SiteTriage {
|
|
42
|
+
export interface SiteTriage {
|
|
43
43
|
reach: ReachVerdict;
|
|
44
44
|
health: HealthVerdict;
|
|
45
45
|
/** Which axis leads the dashboard headline. */
|
|
46
46
|
headline: 'reach' | 'health';
|
|
47
47
|
}
|
|
48
|
-
interface SiteTriageInput {
|
|
48
|
+
export interface SiteTriageInput {
|
|
49
49
|
/** Impressions over the trailing 28 days — the maturity tier. */
|
|
50
50
|
impressions28d?: number | null;
|
|
51
51
|
/** Lifetime-ish impressions (trailing 12 months) — separates new from decayed/faded. */
|
|
@@ -76,10 +76,9 @@ interface SiteTriageInput {
|
|
|
76
76
|
* (GSC reporting lag) are trimmed before the latest-week sum. Returns null when
|
|
77
77
|
* the series is too short to judge.
|
|
78
78
|
*/
|
|
79
|
-
declare function reachLivenessRatio(daily: Array<{
|
|
79
|
+
export declare function reachLivenessRatio(daily: Array<{
|
|
80
80
|
impressions: number;
|
|
81
81
|
}> | null | undefined): number | null;
|
|
82
|
-
declare function classifyHealthStage(input: SiteTriageInput): HealthVerdict;
|
|
83
|
-
declare function classifyReachStage(input: SiteTriageInput): ReachVerdict;
|
|
84
|
-
declare function classifySiteTriage(input: SiteTriageInput): SiteTriage;
|
|
85
|
-
export { HealthStage, HealthVerdict, ReachStage, ReachVerdict, SiteTriage, SiteTriageInput, StageProgression, TriageEvidence, classifyHealthStage, classifyReachStage, classifySiteTriage, reachLivenessRatio };
|
|
82
|
+
export declare function classifyHealthStage(input: SiteTriageInput): HealthVerdict;
|
|
83
|
+
export declare function classifyReachStage(input: SiteTriageInput): ReachVerdict;
|
|
84
|
+
export declare function classifySiteTriage(input: SiteTriageInput): SiteTriage;
|
package/dist/v1/http.d.mts
CHANGED
|
@@ -15,8 +15,8 @@ interface GscdumpV1ClientMethodAliases {
|
|
|
15
15
|
type GscdumpV1ClientMethodFor<TMethod extends GscdumpV1RegistryMethodName> = TMethod extends keyof GscdumpV1ClientMethodAliases ? GscdumpV1ClientMethodAliases[TMethod] : TMethod;
|
|
16
16
|
type GscdumpV1NamedOperations = { [TMethod in GscdumpV1RegistryMethodName as GscdumpV1ClientMethodFor<TMethod>]: GscdumpV1RegistryOperations[TMethod]; };
|
|
17
17
|
type GscdumpV1ClientMethodName = keyof GscdumpV1NamedOperations & string;
|
|
18
|
-
type GscdumpV1Operation = GscdumpV1Operation$1;
|
|
19
|
-
type GscdumpV1OperationId = GscdumpV1OperationId$1;
|
|
18
|
+
export type GscdumpV1Operation = GscdumpV1Operation$1;
|
|
19
|
+
export type GscdumpV1OperationId = GscdumpV1OperationId$1;
|
|
20
20
|
type OperationById<TId extends GscdumpV1OperationId> = Extract<GscdumpV1Operation, {
|
|
21
21
|
id: TId;
|
|
22
22
|
}>;
|
|
@@ -24,14 +24,14 @@ type SchemaInput<TSchema> = TSchema extends ZodTypeAny ? z.input<TSchema> : neve
|
|
|
24
24
|
type SchemaOutput<TSchema> = TSchema extends ZodTypeAny ? z.output<TSchema> : never;
|
|
25
25
|
type RequiredLocation<TKey extends string, TSchema> = TSchema extends ZodTypeAny ? { [K in TKey]: SchemaInput<TSchema>; } : { [K in TKey]?: never; };
|
|
26
26
|
type OptionalLocation<TKey extends string, TSchema> = TSchema extends ZodTypeAny ? { [K in TKey]?: SchemaInput<TSchema>; } : { [K in TKey]?: never; };
|
|
27
|
-
type GscdumpV1OperationInput<TId extends GscdumpV1OperationId> = RequiredLocation<'params', OperationById<TId>['request']['params']> & RequiredLocation<'query', OperationById<TId>['request']['query']> & OptionalLocation<'headers', OperationById<TId>['request']['headers']> & RequiredLocation<'body', OperationById<TId>['request']['body']>;
|
|
27
|
+
export type GscdumpV1OperationInput<TId extends GscdumpV1OperationId> = RequiredLocation<'params', OperationById<TId>['request']['params']> & RequiredLocation<'query', OperationById<TId>['request']['query']> & OptionalLocation<'headers', OperationById<TId>['request']['headers']> & RequiredLocation<'body', OperationById<TId>['request']['body']>;
|
|
28
28
|
type OperationResponseSchema<TId extends GscdumpV1OperationId> = ValueOf<OperationById<TId>['responses']> extends (infer TResponse) ? TResponse extends {
|
|
29
29
|
client: infer TClient extends ZodTypeAny;
|
|
30
30
|
} ? TClient : never : never;
|
|
31
|
-
type GscdumpV1OperationResponse<TId extends GscdumpV1OperationId> = SchemaOutput<OperationResponseSchema<TId>>;
|
|
32
|
-
type GscdumpV1CredentialResolver = string | (() => MaybePromise<string>);
|
|
33
|
-
type GscdumpV1HeadersResolver = HeadersInit | (() => MaybePromise<HeadersInit>);
|
|
34
|
-
interface GscdumpV1RetryOptions {
|
|
31
|
+
export type GscdumpV1OperationResponse<TId extends GscdumpV1OperationId> = SchemaOutput<OperationResponseSchema<TId>>;
|
|
32
|
+
export type GscdumpV1CredentialResolver = string | (() => MaybePromise<string>);
|
|
33
|
+
export type GscdumpV1HeadersResolver = HeadersInit | (() => MaybePromise<HeadersInit>);
|
|
34
|
+
export interface GscdumpV1RetryOptions {
|
|
35
35
|
/** Total attempts, including the initial request. Defaults to 3 and is capped at 5. */
|
|
36
36
|
maxAttempts?: number;
|
|
37
37
|
/** Deterministic exponential-backoff base. Defaults to 250 ms. */
|
|
@@ -39,7 +39,7 @@ interface GscdumpV1RetryOptions {
|
|
|
39
39
|
/** Backoff ceiling. Defaults to 2 seconds. Retry-After can exceed this ceiling. */
|
|
40
40
|
maxDelayMs?: number;
|
|
41
41
|
}
|
|
42
|
-
interface CreateGscdumpV1ClientOptions {
|
|
42
|
+
export interface CreateGscdumpV1ClientOptions {
|
|
43
43
|
/**
|
|
44
44
|
* Root replacing the contract's `/api` segment. Direct calls default to
|
|
45
45
|
* `https://gscdump.com/api`; a same-origin proxy can use `/api/_gscdump`.
|
|
@@ -50,13 +50,13 @@ interface CreateGscdumpV1ClientOptions {
|
|
|
50
50
|
headers?: GscdumpV1HeadersResolver;
|
|
51
51
|
retry?: GscdumpV1RetryOptions;
|
|
52
52
|
}
|
|
53
|
-
interface GscdumpV1ExecuteOptions {
|
|
53
|
+
export interface GscdumpV1ExecuteOptions {
|
|
54
54
|
signal?: AbortSignal;
|
|
55
55
|
requestId?: string;
|
|
56
56
|
idempotencyKey?: string;
|
|
57
57
|
}
|
|
58
|
-
type GscdumpV1SdkErrorCode = GscdumpV1ErrorEnvelope['error']['code'] | 'aborted' | 'credential_resolution' | 'network_error' | 'protocol_error' | 'request_validation' | 'response_validation';
|
|
59
|
-
interface GscdumpV1ErrorOptions {
|
|
58
|
+
export type GscdumpV1SdkErrorCode = GscdumpV1ErrorEnvelope['error']['code'] | 'aborted' | 'credential_resolution' | 'network_error' | 'protocol_error' | 'request_validation' | 'response_validation';
|
|
59
|
+
export interface GscdumpV1ErrorOptions {
|
|
60
60
|
code: GscdumpV1SdkErrorCode;
|
|
61
61
|
message: string;
|
|
62
62
|
status?: number;
|
|
@@ -66,7 +66,7 @@ interface GscdumpV1ErrorOptions {
|
|
|
66
66
|
cause?: unknown;
|
|
67
67
|
}
|
|
68
68
|
/** One stable, tagged failure shape for validation, transport, and API errors. */
|
|
69
|
-
declare class GscdumpV1Error extends Error {
|
|
69
|
+
export declare class GscdumpV1Error extends Error {
|
|
70
70
|
readonly tag: "GscdumpV1Error";
|
|
71
71
|
readonly code: GscdumpV1SdkErrorCode;
|
|
72
72
|
readonly status?: number;
|
|
@@ -76,14 +76,13 @@ declare class GscdumpV1Error extends Error {
|
|
|
76
76
|
readonly cause?: unknown;
|
|
77
77
|
constructor(options: GscdumpV1ErrorOptions);
|
|
78
78
|
}
|
|
79
|
-
declare function isGscdumpV1Error(error: unknown): error is GscdumpV1Error;
|
|
79
|
+
export declare function isGscdumpV1Error(error: unknown): error is GscdumpV1Error;
|
|
80
80
|
type MethodId<TMethod extends GscdumpV1ClientMethodName> = GscdumpV1NamedOperations[TMethod] extends {
|
|
81
81
|
id: infer TId extends GscdumpV1OperationId;
|
|
82
82
|
} ? TId : never;
|
|
83
83
|
type GscdumpV1OperationMethod<TId extends GscdumpV1OperationId> = Record<never, never> extends GscdumpV1OperationInput<TId> ? (input?: GscdumpV1OperationInput<TId>, options?: GscdumpV1ExecuteOptions) => Promise<GscdumpV1OperationResponse<TId>> : (input: GscdumpV1OperationInput<TId>, options?: GscdumpV1ExecuteOptions) => Promise<GscdumpV1OperationResponse<TId>>;
|
|
84
|
-
type GscdumpV1Client = {
|
|
84
|
+
export type GscdumpV1Client = {
|
|
85
85
|
execute: <TId extends GscdumpV1OperationId>(operation: TId, input: NoInfer<GscdumpV1OperationInput<TId>>, options?: GscdumpV1ExecuteOptions) => Promise<GscdumpV1OperationResponse<TId>>;
|
|
86
86
|
} & { [TMethod in GscdumpV1ClientMethodName]: GscdumpV1OperationMethod<MethodId<TMethod>>; };
|
|
87
87
|
/** Create one framework-neutral client whose behavior is driven by the v1 registry. */
|
|
88
|
-
declare function createGscdumpV1Client(options: CreateGscdumpV1ClientOptions): GscdumpV1Client;
|
|
89
|
-
export { CreateGscdumpV1ClientOptions, GscdumpV1Client, GscdumpV1CredentialResolver, GscdumpV1Error, GscdumpV1ErrorOptions, GscdumpV1ExecuteOptions, GscdumpV1HeadersResolver, GscdumpV1Operation, GscdumpV1OperationId, GscdumpV1OperationInput, GscdumpV1OperationResponse, GscdumpV1RetryOptions, GscdumpV1SdkErrorCode, createGscdumpV1Client, isGscdumpV1Error };
|
|
88
|
+
export declare function createGscdumpV1Client(options: CreateGscdumpV1ClientOptions): GscdumpV1Client;
|
package/dist/v1/http.mjs
CHANGED
|
@@ -372,6 +372,7 @@ function createGscdumpV1Client(options) {
|
|
|
372
372
|
updateUserTokens: (input, executeOptions) => execute("partner.users.tokens.update", input, executeOptions),
|
|
373
373
|
getSiteIndexing: (input, executeOptions) => execute("partner.sites.indexing.get", input, executeOptions),
|
|
374
374
|
listSiteIndexingUrls: (input, executeOptions) => execute("partner.sites.indexing.urls.list", input, executeOptions),
|
|
375
|
+
getSiteBingData: (input, executeOptions) => execute("partner.sites.bing.data.get", input, executeOptions),
|
|
375
376
|
listSiteBingIndexingEvidence: (input, executeOptions) => execute("partner.sites.indexing.bing.evidence.list", input, executeOptions),
|
|
376
377
|
getSiteBingConnection: (input, executeOptions) => execute("partner.sites.indexing.bing.connection.get", input, executeOptions),
|
|
377
378
|
verifySiteBingConnection: (input, executeOptions) => execute("partner.sites.indexing.bing.connection.verify", input, executeOptions),
|
package/dist/v1/realtime.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RealtimeV1Cursor, RealtimeV1Event, RealtimeV1StreamHead, RealtimeV1StreamId } from "@gscdump/contracts/v1/realtime";
|
|
2
2
|
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
-
declare const GSCDUMP_REALTIME_V1_SDK_VERSION: "3.
|
|
4
|
-
type GscdumpRealtimeV1TransportState = 'idle' | 'ticketing' | 'connecting' | 'handshaking' | 'replaying' | 'live' | 'waiting' | 'stopped' | 'terminal';
|
|
5
|
-
type GscdumpRealtimeV1Freshness = 'unknown' | 'stale' | 'applying' | 'fresh' | 'resyncing' | 'degraded';
|
|
6
|
-
type GscdumpRealtimeV1ErrorCode = 'cursor_store_failed' | 'effect_failed' | 'heartbeat_stale' | 'integration_failed' | 'protocol_error' | 'resync_failed' | 'runtime_unavailable' | 'socket_error' | 'ticket_invalid' | 'ticket_provider_failed' | 'upgrade_rejected';
|
|
7
|
-
interface GscdumpRealtimeV1ErrorOptions {
|
|
3
|
+
export declare const GSCDUMP_REALTIME_V1_SDK_VERSION: "3.6.0";
|
|
4
|
+
export type GscdumpRealtimeV1TransportState = 'idle' | 'ticketing' | 'connecting' | 'handshaking' | 'replaying' | 'live' | 'waiting' | 'stopped' | 'terminal';
|
|
5
|
+
export type GscdumpRealtimeV1Freshness = 'unknown' | 'stale' | 'applying' | 'fresh' | 'resyncing' | 'degraded';
|
|
6
|
+
export type GscdumpRealtimeV1ErrorCode = 'cursor_store_failed' | 'effect_failed' | 'heartbeat_stale' | 'integration_failed' | 'protocol_error' | 'resync_failed' | 'runtime_unavailable' | 'socket_error' | 'ticket_invalid' | 'ticket_provider_failed' | 'upgrade_rejected';
|
|
7
|
+
export interface GscdumpRealtimeV1ErrorOptions {
|
|
8
8
|
code: GscdumpRealtimeV1ErrorCode;
|
|
9
9
|
message: string;
|
|
10
10
|
retryable: boolean;
|
|
@@ -12,7 +12,7 @@ interface GscdumpRealtimeV1ErrorOptions {
|
|
|
12
12
|
details?: Record<string, unknown>;
|
|
13
13
|
cause?: unknown;
|
|
14
14
|
}
|
|
15
|
-
declare class GscdumpRealtimeV1Error extends Error {
|
|
15
|
+
export declare class GscdumpRealtimeV1Error extends Error {
|
|
16
16
|
readonly tag: "GscdumpRealtimeV1Error";
|
|
17
17
|
readonly code: GscdumpRealtimeV1ErrorCode;
|
|
18
18
|
readonly retryable: boolean;
|
|
@@ -21,11 +21,11 @@ declare class GscdumpRealtimeV1Error extends Error {
|
|
|
21
21
|
readonly cause?: unknown;
|
|
22
22
|
constructor(options: GscdumpRealtimeV1ErrorOptions);
|
|
23
23
|
}
|
|
24
|
-
interface GscdumpRealtimeV1CursorStore {
|
|
24
|
+
export interface GscdumpRealtimeV1CursorStore {
|
|
25
25
|
load: () => MaybePromise<RealtimeV1Cursor | null>;
|
|
26
26
|
save: (cursor: RealtimeV1Cursor) => MaybePromise<void>;
|
|
27
27
|
}
|
|
28
|
-
interface GscdumpRealtimeV1SocketLike {
|
|
28
|
+
export interface GscdumpRealtimeV1SocketLike {
|
|
29
29
|
readonly readyState: number;
|
|
30
30
|
readonly protocol: string;
|
|
31
31
|
onopen: ((event: unknown) => void) | null;
|
|
@@ -41,15 +41,15 @@ interface GscdumpRealtimeV1SocketLike {
|
|
|
41
41
|
send: (data: string) => void;
|
|
42
42
|
close: (code?: number, reason?: string) => void;
|
|
43
43
|
}
|
|
44
|
-
interface GscdumpRealtimeV1Runtime {
|
|
44
|
+
export interface GscdumpRealtimeV1Runtime {
|
|
45
45
|
createSocket: (url: string, protocols: readonly string[]) => GscdumpRealtimeV1SocketLike;
|
|
46
46
|
setTimeout: (handler: () => void, ms: number) => unknown;
|
|
47
47
|
clearTimeout: (handle: unknown) => void;
|
|
48
48
|
random: () => number;
|
|
49
49
|
now: () => number;
|
|
50
50
|
}
|
|
51
|
-
type GscdumpRealtimeV1ResyncReason = 'cursor_expired' | 'retention_gap' | 'sequence_gap' | 'stream_mismatch' | 'initial_cursor_missing' | 'effect_application_failed';
|
|
52
|
-
interface GscdumpRealtimeV1ResyncRequest {
|
|
51
|
+
export type GscdumpRealtimeV1ResyncReason = 'cursor_expired' | 'retention_gap' | 'sequence_gap' | 'stream_mismatch' | 'initial_cursor_missing' | 'effect_application_failed';
|
|
52
|
+
export interface GscdumpRealtimeV1ResyncRequest {
|
|
53
53
|
reason: GscdumpRealtimeV1ResyncReason;
|
|
54
54
|
source: 'server' | 'client';
|
|
55
55
|
streamId: RealtimeV1StreamId;
|
|
@@ -58,7 +58,7 @@ interface GscdumpRealtimeV1ResyncRequest {
|
|
|
58
58
|
failedEvent?: RealtimeV1Event;
|
|
59
59
|
cause?: unknown;
|
|
60
60
|
}
|
|
61
|
-
interface GscdumpRealtimeV1Snapshot {
|
|
61
|
+
export interface GscdumpRealtimeV1Snapshot {
|
|
62
62
|
transport: GscdumpRealtimeV1TransportState;
|
|
63
63
|
freshness: GscdumpRealtimeV1Freshness;
|
|
64
64
|
attempt: number;
|
|
@@ -67,7 +67,7 @@ interface GscdumpRealtimeV1Snapshot {
|
|
|
67
67
|
head: RealtimeV1StreamHead | null;
|
|
68
68
|
error: GscdumpRealtimeV1Error | null;
|
|
69
69
|
}
|
|
70
|
-
type GscdumpRealtimeV1Observation = {
|
|
70
|
+
export type GscdumpRealtimeV1Observation = {
|
|
71
71
|
type: 'state';
|
|
72
72
|
state: GscdumpRealtimeV1Snapshot;
|
|
73
73
|
} | {
|
|
@@ -83,7 +83,7 @@ type GscdumpRealtimeV1Observation = {
|
|
|
83
83
|
code: 'unknown_event' | 'unknown_resource' | 'unsupported_event_version';
|
|
84
84
|
event: RealtimeV1Event;
|
|
85
85
|
};
|
|
86
|
-
interface CreateGscdumpRealtimeV1ClientOptions {
|
|
86
|
+
export interface CreateGscdumpRealtimeV1ClientOptions {
|
|
87
87
|
/** Called for every connection attempt. A ticket is never reused. */
|
|
88
88
|
ticketProvider: () => MaybePromise<unknown>;
|
|
89
89
|
/** Required correctness effect for each contiguous durable event. */
|
|
@@ -96,7 +96,7 @@ interface CreateGscdumpRealtimeV1ClientOptions {
|
|
|
96
96
|
runtime?: GscdumpRealtimeV1Runtime;
|
|
97
97
|
sdkVersion?: string;
|
|
98
98
|
}
|
|
99
|
-
interface GscdumpRealtimeV1Client {
|
|
99
|
+
export interface GscdumpRealtimeV1Client {
|
|
100
100
|
start: () => Promise<void>;
|
|
101
101
|
stop: () => void;
|
|
102
102
|
getSnapshot: () => GscdumpRealtimeV1Snapshot;
|
|
@@ -105,5 +105,4 @@ interface GscdumpRealtimeV1Client {
|
|
|
105
105
|
* Own the v1 cursor/ACK correctness state machine. Framework adapters provide
|
|
106
106
|
* required effects; they never need to reproduce transport ordering rules.
|
|
107
107
|
*/
|
|
108
|
-
declare function createGscdumpRealtimeV1Client(options: CreateGscdumpRealtimeV1ClientOptions): GscdumpRealtimeV1Client;
|
|
109
|
-
export { CreateGscdumpRealtimeV1ClientOptions, GSCDUMP_REALTIME_V1_SDK_VERSION, GscdumpRealtimeV1Client, GscdumpRealtimeV1CursorStore, GscdumpRealtimeV1Error, GscdumpRealtimeV1ErrorCode, GscdumpRealtimeV1ErrorOptions, GscdumpRealtimeV1Freshness, GscdumpRealtimeV1Observation, GscdumpRealtimeV1ResyncReason, GscdumpRealtimeV1ResyncRequest, GscdumpRealtimeV1Runtime, GscdumpRealtimeV1Snapshot, GscdumpRealtimeV1SocketLike, GscdumpRealtimeV1TransportState, createGscdumpRealtimeV1Client };
|
|
108
|
+
export declare function createGscdumpRealtimeV1Client(options: CreateGscdumpRealtimeV1ClientOptions): GscdumpRealtimeV1Client;
|
package/dist/v1/realtime.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { utf8Size } from "../utf8.mjs";
|
|
2
2
|
import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_SUBPROTOCOL, REALTIME_V1_EVENT_NAMES, REALTIME_V1_RESOURCE_TYPES, createRealtimeV1Schemas } from "@gscdump/contracts/v1/realtime";
|
|
3
|
-
const GSCDUMP_REALTIME_V1_SDK_VERSION = "3.
|
|
3
|
+
const GSCDUMP_REALTIME_V1_SDK_VERSION = "3.6.0";
|
|
4
4
|
var GscdumpRealtimeV1Error = class extends Error {
|
|
5
5
|
tag = "GscdumpRealtimeV1Error";
|
|
6
6
|
code;
|
|
@@ -87,7 +87,7 @@ function createGscdumpRealtimeV1Client(options) {
|
|
|
87
87
|
const schemas = createRealtimeV1Schemas();
|
|
88
88
|
const runtime = options.runtime ?? defaultRuntime();
|
|
89
89
|
const cursorStore = options.cursorStore ?? createMemoryCursorStore();
|
|
90
|
-
const sdkVersion = options.sdkVersion ?? "3.
|
|
90
|
+
const sdkVersion = options.sdkVersion ?? "3.6.0";
|
|
91
91
|
if (!sdkVersion) throw new TypeError("sdkVersion cannot be empty.");
|
|
92
92
|
let running = false;
|
|
93
93
|
let epoch = 0;
|
package/dist/webhook.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CANONICAL_WEBHOOK_EVENTS, PartnerWebhookHeaders, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookEnvelope } from "@gscdump/contracts";
|
|
2
|
-
declare function signWebhookPayload(payload: string | object, secret: string): Promise<string>;
|
|
3
|
-
declare function verifyWebhookSignature(payload: string | object, signature: string | null | undefined, secret: string): Promise<boolean>;
|
|
4
|
-
declare function parseWebhookPayload<TData extends Record<string, unknown> = Record<string, unknown>>(payload: string | object, options?: {
|
|
2
|
+
export declare function signWebhookPayload(payload: string | object, secret: string): Promise<string>;
|
|
3
|
+
export declare function verifyWebhookSignature(payload: string | object, signature: string | null | undefined, secret: string): Promise<boolean>;
|
|
4
|
+
export declare function parseWebhookPayload<TData extends Record<string, unknown> = Record<string, unknown>>(payload: string | object, options?: {
|
|
5
5
|
secret?: string;
|
|
6
6
|
signature?: string | null;
|
|
7
7
|
headers?: PartnerWebhookHeaders | Headers;
|
|
8
8
|
validateSignature?: boolean;
|
|
9
9
|
}): Promise<WebhookEnvelope<TData>>;
|
|
10
|
-
declare function readWebhookHeaders(headers: Headers | PartnerWebhookHeaders | null | undefined): Required<PartnerWebhookHeaders>;
|
|
11
|
-
export { CANONICAL_WEBHOOK_EVENTS, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER
|
|
10
|
+
export declare function readWebhookHeaders(headers: Headers | PartnerWebhookHeaders | null | undefined): Required<PartnerWebhookHeaders>;
|
|
11
|
+
export { CANONICAL_WEBHOOK_EVENTS, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.6.0",
|
|
5
5
|
"description": "Consumer SDK for hosted gscdump.com integrations.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -144,14 +144,14 @@
|
|
|
144
144
|
"node": ">=22"
|
|
145
145
|
},
|
|
146
146
|
"dependencies": {
|
|
147
|
-
"@gscdump/contracts": "^3.
|
|
148
|
-
"gscdump": "^3.
|
|
147
|
+
"@gscdump/contracts": "^3.6.0",
|
|
148
|
+
"gscdump": "^3.6.0",
|
|
149
149
|
"ofetch": "^1.5.1",
|
|
150
|
-
"zod": "^4.
|
|
150
|
+
"zod": "^4.6.1"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
153
|
-
"typescript": "
|
|
154
|
-
"vitest": "^
|
|
153
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
154
|
+
"vitest": "^5.0.0"
|
|
155
155
|
},
|
|
156
156
|
"scripts": {
|
|
157
157
|
"build": "obuild",
|