@gscdump/nuxt 0.22.4 → 1.5.3
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 +10 -137
- package/dist/module.d.mts +22 -0
- package/dist/module.mjs +30 -0
- package/dist/runtime-config.d.mts +12 -0
- package/dist/runtime-config.mjs +27 -0
- package/package.json +26 -176
- package/app/assets/css/main.css +0 -2
- package/app/components/GscAnalyzerPanel.vue +0 -94
- package/app/components/GscAnonymizationBanner.vue +0 -46
- package/app/components/GscBootProgress.vue +0 -297
- package/app/components/GscCommandPalette.vue +0 -77
- package/app/components/GscDashboardPage.vue +0 -26
- package/app/components/GscEngineBadge.vue +0 -28
- package/app/components/GscHero.vue +0 -214
- package/app/components/GscLazyTopResult.vue +0 -47
- package/app/components/GscPerformanceChart.vue +0 -532
- package/app/components/GscPositionDistributionChart.vue +0 -63
- package/app/components/GscQueryLabel.vue +0 -63
- package/app/components/GscSitePageHeader.vue +0 -40
- package/app/components/GscSourceDebugPanel.vue +0 -196
- package/app/components/GscSyncStatusCell.vue +0 -54
- package/app/components/GscTopRollupCard.vue +0 -90
- package/app/composables/_useGscBackfill.ts +0 -119
- package/app/composables/_useGscQueryDispatcher.ts +0 -123
- package/app/composables/_useGscResource.ts +0 -202
- package/app/composables/_useGscSharedSiteResource.ts +0 -136
- package/app/composables/useGscAnalytics.ts +0 -206
- package/app/composables/useGscAnalyticsClient.ts +0 -9
- package/app/composables/useGscAnalyticsConfig.ts +0 -8
- package/app/composables/useGscAnalyticsSourceInfo.ts +0 -165
- package/app/composables/useGscAnalyzer.ts +0 -460
- package/app/composables/useGscAnalyzerBatch.ts +0 -106
- package/app/composables/useGscAnalyzerDefs.ts +0 -119
- package/app/composables/useGscAuth.ts +0 -115
- package/app/composables/useGscConsoleUrl.ts +0 -45
- package/app/composables/useGscCountries.ts +0 -46
- package/app/composables/useGscCurrentSite.ts +0 -36
- package/app/composables/useGscInspectionHistory.ts +0 -42
- package/app/composables/useGscInspections.ts +0 -52
- package/app/composables/useGscPanelContext.ts +0 -31
- package/app/composables/useGscPeriod.ts +0 -243
- package/app/composables/useGscQuery.ts +0 -301
- package/app/composables/useGscQueryDispatcher.ts +0 -14
- package/app/composables/useGscRequestIndexingInspect.ts +0 -29
- package/app/composables/useGscResource.ts +0 -11
- package/app/composables/useGscRollup.ts +0 -237
- package/app/composables/useGscSearchAppearance.ts +0 -46
- package/app/composables/useGscSiteAnalyzer.ts +0 -456
- package/app/composables/useGscSitemapHistory.ts +0 -41
- package/app/composables/useGscSitemaps.ts +0 -45
- package/app/composables/useGscTableState.ts +0 -119
- package/app/plugins/analytics.ts +0 -57
- package/app/queries/gsc.ts +0 -163
- package/app/utils/anonymization.ts +0 -24
- package/app/utils/country-names.ts +0 -56
- package/app/utils/duckdb-wasm.ts +0 -166
- package/app/utils/gsc-constants.ts +0 -10
- package/app/utils/gsc-error.ts +0 -58
- package/app/utils/gsc-fetch.ts +0 -94
- package/app/utils/gsc-filters.ts +0 -32
- package/app/utils/gsc-rows.ts +0 -72
- package/app/utils/gsc-rpc.ts +0 -18
- package/app/utils/position.ts +0 -7
- package/module.ts +0 -81
- package/nuxt.config.ts +0 -61
- package/types.ts +0 -115
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// Rollup fetchers.
|
|
2
|
-
//
|
|
3
|
-
// useGscRollup(site, id) → { data, envelope, loading, refresh }
|
|
4
|
-
// useGscRollups(site, [id, ...]) → { get, payload, envelopes, loading, refresh }
|
|
5
|
-
// useGscRollupFanout(sites, id) → { envelopes, loading, refresh }
|
|
6
|
-
//
|
|
7
|
-
// The single/multi-site overload on `useGscRollups` from the previous API was
|
|
8
|
-
// split into three focused hooks so each has one return shape.
|
|
9
|
-
//
|
|
10
|
-
// Progress flows to the shared analytics map so <GscBootProgress> lights up.
|
|
11
|
-
|
|
12
|
-
import type { RollupEnvelope } from '@gscdump/contracts'
|
|
13
|
-
import type { SiteListItem } from './useGscAnalytics'
|
|
14
|
-
import { gscQueries } from '../queries/gsc'
|
|
15
|
-
import { useGscRpc } from '../utils/gsc-rpc'
|
|
16
|
-
import { useGscResource } from './_useGscResource'
|
|
17
|
-
import { useGscAnalyticsContext } from './useGscAnalytics'
|
|
18
|
-
|
|
19
|
-
type RollupsInput = MaybeRefOrGetter<string | readonly string[]>
|
|
20
|
-
type SiteLike = string | { id: string } | SiteListItem
|
|
21
|
-
|
|
22
|
-
export interface UseGscRollupReturn<T> {
|
|
23
|
-
data: Ref<T | null>
|
|
24
|
-
envelope: Ref<RollupEnvelope<T> | null>
|
|
25
|
-
loading: Readonly<Ref<boolean>>
|
|
26
|
-
refresh: () => Promise<void>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface UseGscRollupsReturn<T> {
|
|
30
|
-
get: (rollupId: string) => RollupEnvelope<T> | null
|
|
31
|
-
payload: (rollupId: string) => T | null
|
|
32
|
-
envelopes: Ref<Record<string, RollupEnvelope<T> | null>>
|
|
33
|
-
loading: Readonly<Ref<boolean>>
|
|
34
|
-
refresh: () => Promise<void>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface UseGscRollupFanoutReturn<T> {
|
|
38
|
-
/** `{ [siteId]: envelope | null }` — null for sites missing the rollup. */
|
|
39
|
-
envelopes: Ref<Record<string, RollupEnvelope<T> | null>>
|
|
40
|
-
loading: Readonly<Ref<boolean>>
|
|
41
|
-
/**
|
|
42
|
-
* How many fan-out fetches have resolved so far (incl. nulls). Useful for
|
|
43
|
-
* showing "loaded X/Y" hints in tiers where each site is a live API call.
|
|
44
|
-
*/
|
|
45
|
-
progress: Readonly<Ref<{ completed: number, total: number }>>
|
|
46
|
-
refresh: () => Promise<void>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface UseGscRollupOptions {
|
|
50
|
-
/**
|
|
51
|
-
* Optional reactive `{ start, end }` ISO-date window. When provided, the
|
|
52
|
-
* endpoint is free to synthesize the rollup for that window (how it does
|
|
53
|
-
* so is host-specific). Rollups that are range-agnostic (e.g. the
|
|
54
|
-
* client-sliced `daily_totals`) safely ignore these params.
|
|
55
|
-
*/
|
|
56
|
-
range?: MaybeRefOrGetter<{ start: string, end: string } | null | undefined>
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Fetch one rollup for one site. */
|
|
60
|
-
export function useGscRollup<T = unknown>(
|
|
61
|
-
siteId: MaybeRefOrGetter<string | null | undefined>,
|
|
62
|
-
rollupId: MaybeRefOrGetter<string>,
|
|
63
|
-
opts: UseGscRollupOptions = {},
|
|
64
|
-
): UseGscRollupReturn<T> {
|
|
65
|
-
const ctx = useGscAnalyticsContext()
|
|
66
|
-
const rpc = useGscRpc()
|
|
67
|
-
const resource = useGscResource<[string, string], RollupEnvelope<T> | null>({
|
|
68
|
-
namespace: 'gsc-rollup',
|
|
69
|
-
keys: [siteId, rollupId],
|
|
70
|
-
fetcher: (id, rid) => fetchOne<T>(rpc, id, rid, ctx, toValue(opts.range) ?? null),
|
|
71
|
-
watchSources: [() => toValue(opts.range)?.start, () => toValue(opts.range)?.end],
|
|
72
|
-
isEmpty: env => env == null,
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
data: computed<T | null>(() => resource.data.value?.payload ?? null),
|
|
77
|
-
envelope: resource.data as unknown as Ref<RollupEnvelope<T> | null>,
|
|
78
|
-
loading: resource.loading as unknown as Readonly<Ref<boolean>>,
|
|
79
|
-
refresh: resource.refresh,
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Fetch N rollups for one site. */
|
|
84
|
-
export function useGscRollups<T = unknown>(
|
|
85
|
-
siteId: MaybeRefOrGetter<string | null | undefined>,
|
|
86
|
-
rollupIds: RollupsInput,
|
|
87
|
-
opts: UseGscRollupOptions = {},
|
|
88
|
-
): UseGscRollupsReturn<T> {
|
|
89
|
-
const ctx = useGscAnalyticsContext()
|
|
90
|
-
const rpc = useGscRpc()
|
|
91
|
-
const rollupKey = computed(() => encodeStringList(normaliseRollups(toValue(rollupIds))))
|
|
92
|
-
const resource = useGscResource<[string, string], Record<string, RollupEnvelope<T> | null>>({
|
|
93
|
-
namespace: 'gsc-rollups',
|
|
94
|
-
keys: [siteId, rollupKey],
|
|
95
|
-
fetcher: async (sid, encoded) => {
|
|
96
|
-
const rids = decodeStringList(encoded)
|
|
97
|
-
const next: Record<string, RollupEnvelope<T> | null> = {}
|
|
98
|
-
const range = toValue(opts.range) ?? null
|
|
99
|
-
await Promise.all(rids.map(async (rid) => {
|
|
100
|
-
next[rid] = await fetchOne<T>(rpc, sid, rid, ctx, range)
|
|
101
|
-
}))
|
|
102
|
-
return next
|
|
103
|
-
},
|
|
104
|
-
watchSources: [() => toValue(opts.range)?.start, () => toValue(opts.range)?.end],
|
|
105
|
-
isEmpty: value => Object.keys(value).length === 0,
|
|
106
|
-
})
|
|
107
|
-
const envelopes = computed<Record<string, RollupEnvelope<T> | null>>(() => resource.data.value ?? {})
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
get: (rollupId: string) => envelopes.value[rollupId] ?? null,
|
|
111
|
-
payload: (rollupId: string) => envelopes.value[rollupId]?.payload ?? null,
|
|
112
|
-
envelopes: envelopes as unknown as Ref<Record<string, RollupEnvelope<T> | null>>,
|
|
113
|
-
loading: resource.loading as unknown as Readonly<Ref<boolean>>,
|
|
114
|
-
refresh: resource.refresh,
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Fan one rollup id across N sites — returns `{ [siteId]: envelope | null }`.
|
|
120
|
-
* Used by the "all sites" overview page; composes without an overload.
|
|
121
|
-
*/
|
|
122
|
-
export function useGscRollupFanout<T = unknown>(
|
|
123
|
-
sites: MaybeRefOrGetter<readonly SiteLike[] | null | undefined>,
|
|
124
|
-
rollupId: MaybeRefOrGetter<string>,
|
|
125
|
-
opts: UseGscRollupOptions = {},
|
|
126
|
-
): UseGscRollupFanoutReturn<T> {
|
|
127
|
-
const ctx = useGscAnalyticsContext()
|
|
128
|
-
const rpc = useGscRpc()
|
|
129
|
-
const progress = ref<{ completed: number, total: number }>({ completed: 0, total: 0 })
|
|
130
|
-
const siteKey = computed(() => encodeStringList(normaliseSites(toValue(sites))))
|
|
131
|
-
const resource = useGscResource<[string, string], Record<string, RollupEnvelope<T> | null>>({
|
|
132
|
-
namespace: 'gsc-rollup-fanout',
|
|
133
|
-
keys: [siteKey, rollupId],
|
|
134
|
-
fetcher: async (encoded, rid) => {
|
|
135
|
-
const siteIds = decodeStringList(encoded)
|
|
136
|
-
progress.value = { completed: 0, total: siteIds.length }
|
|
137
|
-
const range = toValue(opts.range) ?? null
|
|
138
|
-
const next: Record<string, RollupEnvelope<T> | null> = {}
|
|
139
|
-
await Promise.all(siteIds.map(async (sid) => {
|
|
140
|
-
next[sid] = await fetchOne<T>(rpc, sid, rid, ctx, range)
|
|
141
|
-
progress.value = { completed: progress.value.completed + 1, total: siteIds.length }
|
|
142
|
-
}))
|
|
143
|
-
return next
|
|
144
|
-
},
|
|
145
|
-
watchSources: [() => toValue(opts.range)?.start, () => toValue(opts.range)?.end],
|
|
146
|
-
isEmpty: value => Object.keys(value).length === 0,
|
|
147
|
-
})
|
|
148
|
-
const envelopes = computed<Record<string, RollupEnvelope<T> | null>>(() => resource.data.value ?? {})
|
|
149
|
-
watch(resource.loading, (loading) => {
|
|
150
|
-
if (loading)
|
|
151
|
-
return
|
|
152
|
-
if (!resource.data.value)
|
|
153
|
-
progress.value = { completed: 0, total: 0 }
|
|
154
|
-
}, { immediate: true })
|
|
155
|
-
|
|
156
|
-
return {
|
|
157
|
-
envelopes: envelopes as unknown as Ref<Record<string, RollupEnvelope<T> | null>>,
|
|
158
|
-
loading: resource.loading as unknown as Readonly<Ref<boolean>>,
|
|
159
|
-
progress: progress as Readonly<Ref<{ completed: number, total: number }>>,
|
|
160
|
-
refresh: resource.refresh,
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function normaliseSites(input: unknown): string[] {
|
|
165
|
-
if (!input)
|
|
166
|
-
return []
|
|
167
|
-
const list = Array.isArray(input) ? input : [input]
|
|
168
|
-
const out: string[] = []
|
|
169
|
-
for (const s of list) {
|
|
170
|
-
if (typeof s === 'string') {
|
|
171
|
-
if (s)
|
|
172
|
-
out.push(s)
|
|
173
|
-
}
|
|
174
|
-
else if (s && typeof s === 'object' && 'id' in s && typeof s.id === 'string' && s.id) {
|
|
175
|
-
out.push(s.id)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return out
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function encodeStringList(values: string[]): string {
|
|
182
|
-
return values.length > 0 ? JSON.stringify(values) : ''
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function decodeStringList(encoded: string): string[] {
|
|
186
|
-
const parsed = JSON.parse(encoded) as unknown
|
|
187
|
-
return Array.isArray(parsed)
|
|
188
|
-
? parsed.filter((v): v is string => typeof v === 'string' && v.length > 0)
|
|
189
|
-
: []
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async function fetchOne<T>(
|
|
193
|
-
rpc: ReturnType<typeof useGscRpc>,
|
|
194
|
-
siteId: string,
|
|
195
|
-
rollupId: string,
|
|
196
|
-
ctx: ReturnType<typeof useGscAnalyticsContext>,
|
|
197
|
-
range: { start: string, end: string } | null = null,
|
|
198
|
-
): Promise<RollupEnvelope<T> | null> {
|
|
199
|
-
ctx.patchProgress(siteId, {
|
|
200
|
-
source: 'rollup',
|
|
201
|
-
stage: 'manifest',
|
|
202
|
-
filesTotal: 1,
|
|
203
|
-
filesAttached: 0,
|
|
204
|
-
startedAt: Date.now(),
|
|
205
|
-
error: undefined,
|
|
206
|
-
endedAt: undefined,
|
|
207
|
-
})
|
|
208
|
-
try {
|
|
209
|
-
const env = await rpc.query(
|
|
210
|
-
gscQueries.rollup(siteId, rollupId, range ?? undefined),
|
|
211
|
-
{ silent: true },
|
|
212
|
-
) as RollupEnvelope<T>
|
|
213
|
-
ctx.patchProgress(siteId, { stage: 'ready', filesAttached: 1, endedAt: Date.now() })
|
|
214
|
-
return env
|
|
215
|
-
}
|
|
216
|
-
catch (err: unknown) {
|
|
217
|
-
const status = (err as { statusCode?: number, status?: number })?.statusCode
|
|
218
|
-
?? (err as { status?: number })?.status
|
|
219
|
-
if (status === 404) {
|
|
220
|
-
ctx.patchProgress(siteId, { stage: 'ready', filesAttached: 1, endedAt: Date.now() })
|
|
221
|
-
return null
|
|
222
|
-
}
|
|
223
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
224
|
-
ctx.patchProgress(siteId, { stage: 'error', error: msg, endedAt: Date.now() })
|
|
225
|
-
return null
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function normaliseRollups(input: unknown): string[] {
|
|
230
|
-
if (!input)
|
|
231
|
-
return []
|
|
232
|
-
if (typeof input === 'string')
|
|
233
|
-
return input ? [input] : []
|
|
234
|
-
if (Array.isArray(input))
|
|
235
|
-
return input.filter((v): v is string => typeof v === 'string' && v.length > 0)
|
|
236
|
-
return []
|
|
237
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Fetches per-search-appearance facet performance (AMP, rich results, videos, …)
|
|
2
|
-
// for a site over a date window. Server dispatches tier-aware: free → GSC API
|
|
3
|
-
// live, pro → engine parquet. Uniform row shape regardless of backend.
|
|
4
|
-
|
|
5
|
-
import type { GscApiRange, SearchAppearanceResponse, SearchAppearanceRow } from '@gscdump/contracts'
|
|
6
|
-
import type { ComputedRef, Ref } from '@vue/runtime-core'
|
|
7
|
-
import type { GscResourceStatus } from './_useGscResource'
|
|
8
|
-
import { gscQueries } from '../queries/gsc'
|
|
9
|
-
import { useGscResource } from './_useGscResource'
|
|
10
|
-
|
|
11
|
-
export interface UseGscSearchAppearanceReturn {
|
|
12
|
-
response: Readonly<Ref<SearchAppearanceResponse | null>>
|
|
13
|
-
rows: ComputedRef<SearchAppearanceRow[]>
|
|
14
|
-
range: ComputedRef<GscApiRange | null>
|
|
15
|
-
source: ComputedRef<SearchAppearanceResponse['source'] | null>
|
|
16
|
-
loading: ComputedRef<boolean>
|
|
17
|
-
status: Readonly<Ref<GscResourceStatus>>
|
|
18
|
-
error: Readonly<Ref<Error | null>>
|
|
19
|
-
refresh: () => Promise<void>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useGscSearchAppearance(
|
|
23
|
-
siteId: MaybeRefOrGetter<string | null | undefined>,
|
|
24
|
-
range: MaybeRefOrGetter<{ start: string, end: string } | null | undefined>,
|
|
25
|
-
): UseGscSearchAppearanceReturn {
|
|
26
|
-
const { data, status, loading, error, refresh } = useGscResource<[string, string, string], SearchAppearanceResponse>({
|
|
27
|
-
keys: [
|
|
28
|
-
siteId,
|
|
29
|
-
() => toValue(range)?.start,
|
|
30
|
-
() => toValue(range)?.end,
|
|
31
|
-
] as const,
|
|
32
|
-
operation: (id, start, end) => gscQueries.searchAppearance(id, { start, end }),
|
|
33
|
-
isEmpty: r => r.rows.length === 0,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
response: data as Readonly<Ref<SearchAppearanceResponse | null>>,
|
|
38
|
-
rows: computed(() => data.value?.rows ?? []),
|
|
39
|
-
range: computed(() => data.value?.range ?? null),
|
|
40
|
-
source: computed(() => data.value?.source ?? null),
|
|
41
|
-
loading,
|
|
42
|
-
status,
|
|
43
|
-
error,
|
|
44
|
-
refresh,
|
|
45
|
-
}
|
|
46
|
-
}
|