@gscdump/nuxt 0.22.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +10 -125
  2. package/dist/module.d.mts +22 -0
  3. package/dist/module.mjs +30 -0
  4. package/dist/runtime-config.d.mts +12 -0
  5. package/dist/runtime-config.mjs +27 -0
  6. package/package.json +25 -44
  7. package/app/assets/css/main.css +0 -2
  8. package/app/components/GscAnalyzerPanel.vue +0 -94
  9. package/app/components/GscAnonymizationBanner.vue +0 -46
  10. package/app/components/GscBootProgress.vue +0 -297
  11. package/app/components/GscCommandPalette.vue +0 -77
  12. package/app/components/GscDashboardPage.vue +0 -26
  13. package/app/components/GscEngineBadge.vue +0 -28
  14. package/app/components/GscHero.vue +0 -215
  15. package/app/components/GscLazyTopResult.vue +0 -45
  16. package/app/components/GscPerformanceChart.vue +0 -532
  17. package/app/components/GscPositionDistributionChart.vue +0 -63
  18. package/app/components/GscQueryLabel.vue +0 -63
  19. package/app/components/GscSitePageHeader.vue +0 -40
  20. package/app/components/GscSourceDebugPanel.vue +0 -195
  21. package/app/components/GscSyncStatusCell.vue +0 -54
  22. package/app/components/GscTopRollupCard.vue +0 -90
  23. package/app/composables/_useGscBackfill.ts +0 -111
  24. package/app/composables/_useGscQueryDispatcher.ts +0 -123
  25. package/app/composables/_useGscResource.ts +0 -114
  26. package/app/composables/_useGscSharedSiteResource.ts +0 -136
  27. package/app/composables/useGscAnalytics.ts +0 -205
  28. package/app/composables/useGscAnalyticsClient.ts +0 -9
  29. package/app/composables/useGscAnalyticsConfig.ts +0 -8
  30. package/app/composables/useGscAnalyticsSourceInfo.ts +0 -159
  31. package/app/composables/useGscAnalyzer.ts +0 -452
  32. package/app/composables/useGscAnalyzerBatch.ts +0 -106
  33. package/app/composables/useGscAnalyzerDefs.ts +0 -118
  34. package/app/composables/useGscAuth.ts +0 -115
  35. package/app/composables/useGscConsoleUrl.ts +0 -45
  36. package/app/composables/useGscCountries.ts +0 -47
  37. package/app/composables/useGscCurrentSite.ts +0 -15
  38. package/app/composables/useGscInspectionHistory.ts +0 -42
  39. package/app/composables/useGscInspections.ts +0 -52
  40. package/app/composables/useGscPanelContext.ts +0 -31
  41. package/app/composables/useGscParquetTable.ts +0 -198
  42. package/app/composables/useGscPeriod.ts +0 -243
  43. package/app/composables/useGscQuery.ts +0 -303
  44. package/app/composables/useGscQueryDispatcher.ts +0 -14
  45. package/app/composables/useGscRequestIndexingInspect.ts +0 -20
  46. package/app/composables/useGscResource.ts +0 -11
  47. package/app/composables/useGscRollup.ts +0 -252
  48. package/app/composables/useGscSearchAppearance.ts +0 -47
  49. package/app/composables/useGscSiteAnalyzer.ts +0 -500
  50. package/app/composables/useGscSitemapHistory.ts +0 -41
  51. package/app/composables/useGscSitemaps.ts +0 -45
  52. package/app/composables/useGscTableState.ts +0 -119
  53. package/app/plugins/analytics.ts +0 -57
  54. package/app/utils/anonymization.ts +0 -24
  55. package/app/utils/country-names.ts +0 -56
  56. package/app/utils/duckdb-wasm.ts +0 -166
  57. package/app/utils/gsc-constants.ts +0 -10
  58. package/app/utils/gsc-error.ts +0 -58
  59. package/app/utils/gsc-fetch.ts +0 -94
  60. package/app/utils/gsc-filters.ts +0 -32
  61. package/app/utils/gsc-rows.ts +0 -72
  62. package/app/utils/position.ts +0 -7
  63. package/module.ts +0 -81
  64. package/nuxt.config.ts +0 -41
  65. package/types.ts +0 -119
@@ -1,252 +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 { useGscResource } from './_useGscResource'
15
- import { useGscAnalyticsContext } from './useGscAnalytics'
16
- import { useGscAnalyticsClient } from './useGscAnalyticsClient'
17
-
18
- type RollupsInput = MaybeRefOrGetter<string | readonly string[]>
19
- type SiteLike = string | { id: string } | SiteListItem
20
-
21
- export interface UseGscRollupReturn<T> {
22
- data: Ref<T | null>
23
- envelope: Ref<RollupEnvelope<T> | null>
24
- loading: Readonly<Ref<boolean>>
25
- refresh: () => Promise<void>
26
- }
27
-
28
- export interface UseGscRollupsReturn<T> {
29
- get: (rollupId: string) => RollupEnvelope<T> | null
30
- payload: (rollupId: string) => T | null
31
- envelopes: Ref<Record<string, RollupEnvelope<T> | null>>
32
- loading: Readonly<Ref<boolean>>
33
- refresh: () => Promise<void>
34
- }
35
-
36
- export interface UseGscRollupFanoutReturn<T> {
37
- /** `{ [siteId]: envelope | null }` — null for sites missing the rollup. */
38
- envelopes: Ref<Record<string, RollupEnvelope<T> | null>>
39
- loading: Readonly<Ref<boolean>>
40
- /**
41
- * How many fan-out fetches have resolved so far (incl. nulls). Useful for
42
- * showing "loaded X/Y" hints in tiers where each site is a live API call.
43
- */
44
- progress: Readonly<Ref<{ completed: number, total: number }>>
45
- refresh: () => Promise<void>
46
- }
47
-
48
- export interface UseGscRollupOptions {
49
- /**
50
- * Optional reactive `{ start, end }` ISO-date window. When provided, the
51
- * endpoint is free to synthesize the rollup for that window (how it does
52
- * so is host-specific). Rollups that are range-agnostic (e.g. the
53
- * client-sliced `daily_totals`) safely ignore these params.
54
- */
55
- range?: MaybeRefOrGetter<{ start: string, end: string } | null | undefined>
56
- }
57
-
58
- /** Fetch one rollup for one site. */
59
- export function useGscRollup<T = unknown>(
60
- siteId: MaybeRefOrGetter<string | null | undefined>,
61
- rollupId: MaybeRefOrGetter<string>,
62
- opts: UseGscRollupOptions = {},
63
- ): UseGscRollupReturn<T> {
64
- const ctx = useGscAnalyticsContext()
65
- const resource = useGscResource<[string, string], RollupEnvelope<T> | null>({
66
- keys: [siteId, rollupId],
67
- fetcher: (id, rid) => fetchOne<T>(id, rid, ctx, toValue(opts.range) ?? null),
68
- watchSources: [() => toValue(opts.range)?.start, () => toValue(opts.range)?.end],
69
- isEmpty: env => env == null,
70
- })
71
-
72
- return {
73
- data: computed<T | null>(() => resource.data.value?.payload ?? null),
74
- envelope: resource.data as unknown as Ref<RollupEnvelope<T> | null>,
75
- loading: resource.loading as unknown as Readonly<Ref<boolean>>,
76
- refresh: resource.refresh,
77
- }
78
- }
79
-
80
- /** Fetch N rollups for one site. */
81
- export function useGscRollups<T = unknown>(
82
- siteId: MaybeRefOrGetter<string | null | undefined>,
83
- rollupIds: RollupsInput,
84
- opts: UseGscRollupOptions = {},
85
- ): UseGscRollupsReturn<T> {
86
- const ctx = useGscAnalyticsContext()
87
-
88
- const envelopes = ref<Record<string, RollupEnvelope<T> | null>>({})
89
- const loading = ref(false)
90
-
91
- async function refresh(): Promise<void> {
92
- const sid = toValue(siteId)
93
- const rids = normaliseRollups(toValue(rollupIds))
94
- if (!sid || rids.length === 0) {
95
- envelopes.value = {}
96
- return
97
- }
98
- loading.value = true
99
- const range = toValue(opts.range) ?? null
100
- const next: Record<string, RollupEnvelope<T> | null> = {}
101
- try {
102
- await Promise.all(rids.map(async (rid) => {
103
- next[rid] = await fetchOne<T>(sid, rid, ctx, range)
104
- }))
105
- envelopes.value = next
106
- }
107
- finally {
108
- loading.value = false
109
- }
110
- }
111
-
112
- watch(
113
- () => [toValue(siteId), normaliseRollups(toValue(rollupIds)).join(','), toValue(opts.range)?.start, toValue(opts.range)?.end],
114
- refresh,
115
- { immediate: true },
116
- )
117
-
118
- return {
119
- get: (rollupId: string) => envelopes.value[rollupId] ?? null,
120
- payload: (rollupId: string) => envelopes.value[rollupId]?.payload ?? null,
121
- envelopes,
122
- loading: loading as Readonly<Ref<boolean>>,
123
- refresh,
124
- }
125
- }
126
-
127
- /**
128
- * Fan one rollup id across N sites — returns `{ [siteId]: envelope | null }`.
129
- * Used by the "all sites" overview page; composes without an overload.
130
- */
131
- export function useGscRollupFanout<T = unknown>(
132
- sites: MaybeRefOrGetter<readonly SiteLike[] | null | undefined>,
133
- rollupId: MaybeRefOrGetter<string>,
134
- opts: UseGscRollupOptions = {},
135
- ): UseGscRollupFanoutReturn<T> {
136
- const ctx = useGscAnalyticsContext()
137
- const envelopes = ref<Record<string, RollupEnvelope<T> | null>>({})
138
- const loading = ref(false)
139
- const progress = ref<{ completed: number, total: number }>({ completed: 0, total: 0 })
140
- // Ensures late-arriving promises from a superseded run don't mutate state
141
- // for the current run (e.g. when the range changes rapidly).
142
- let runToken = 0
143
-
144
- async function refresh(): Promise<void> {
145
- const token = ++runToken
146
- const siteIds = normaliseSites(toValue(sites))
147
- const rid = toValue(rollupId)
148
- if (siteIds.length === 0 || !rid) {
149
- envelopes.value = {}
150
- progress.value = { completed: 0, total: 0 }
151
- return
152
- }
153
- loading.value = true
154
- // Seed envelopes with nulls so the UI can render skeleton rows before any
155
- // fetch resolves. Writes land incrementally as each site returns.
156
- const seeded: Record<string, RollupEnvelope<T> | null> = {}
157
- for (const sid of siteIds) seeded[sid] = null
158
- envelopes.value = seeded
159
- progress.value = { completed: 0, total: siteIds.length }
160
- const range = toValue(opts.range) ?? null
161
- try {
162
- await Promise.all(siteIds.map(async (sid) => {
163
- const env = await fetchOne<T>(sid, rid, ctx, range)
164
- if (token !== runToken)
165
- return
166
- envelopes.value = { ...envelopes.value, [sid]: env }
167
- progress.value = { completed: progress.value.completed + 1, total: siteIds.length }
168
- }))
169
- }
170
- finally {
171
- if (token === runToken)
172
- loading.value = false
173
- }
174
- }
175
-
176
- watch(
177
- () => [normaliseSites(toValue(sites)).join(','), toValue(rollupId), toValue(opts.range)?.start, toValue(opts.range)?.end],
178
- refresh,
179
- { immediate: true },
180
- )
181
-
182
- return {
183
- envelopes,
184
- loading: loading as Readonly<Ref<boolean>>,
185
- progress: progress as Readonly<Ref<{ completed: number, total: number }>>,
186
- refresh,
187
- }
188
- }
189
-
190
- function normaliseSites(input: unknown): string[] {
191
- if (!input)
192
- return []
193
- const list = Array.isArray(input) ? input : [input]
194
- const out: string[] = []
195
- for (const s of list) {
196
- if (typeof s === 'string') {
197
- if (s)
198
- out.push(s)
199
- }
200
- else if (s && typeof s === 'object' && 'id' in s && typeof s.id === 'string' && s.id) {
201
- out.push(s.id)
202
- }
203
- }
204
- return out
205
- }
206
-
207
- async function fetchOne<T>(
208
- siteId: string,
209
- rollupId: string,
210
- ctx: ReturnType<typeof useGscAnalyticsContext>,
211
- range: { start: string, end: string } | null = null,
212
- ): Promise<RollupEnvelope<T> | null> {
213
- ctx.patchProgress(siteId, {
214
- source: 'rollup',
215
- stage: 'manifest',
216
- filesTotal: 1,
217
- filesAttached: 0,
218
- startedAt: Date.now(),
219
- error: undefined,
220
- endedAt: undefined,
221
- })
222
- try {
223
- const env = await useGscAnalyticsClient().getRollup<T>(
224
- siteId,
225
- rollupId,
226
- range ? { start: range.start, end: range.end } : undefined,
227
- )
228
- ctx.patchProgress(siteId, { stage: 'ready', filesAttached: 1, endedAt: Date.now() })
229
- return env
230
- }
231
- catch (err: unknown) {
232
- const status = (err as { statusCode?: number, status?: number })?.statusCode
233
- ?? (err as { status?: number })?.status
234
- if (status === 404) {
235
- ctx.patchProgress(siteId, { stage: 'ready', filesAttached: 1, endedAt: Date.now() })
236
- return null
237
- }
238
- const msg = err instanceof Error ? err.message : String(err)
239
- ctx.patchProgress(siteId, { stage: 'error', error: msg, endedAt: Date.now() })
240
- return null
241
- }
242
- }
243
-
244
- function normaliseRollups(input: unknown): string[] {
245
- if (!input)
246
- return []
247
- if (typeof input === 'string')
248
- return input ? [input] : []
249
- if (Array.isArray(input))
250
- return input.filter((v): v is string => typeof v === 'string' && v.length > 0)
251
- return []
252
- }
@@ -1,47 +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 { useGscResource } from './_useGscResource'
9
- import { useGscAnalyticsClient } from './useGscAnalyticsClient'
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: Ref<GscResourceStatus>
18
- error: 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({
27
- keys: [
28
- siteId,
29
- () => toValue(range)?.start,
30
- () => toValue(range)?.end,
31
- ] as const,
32
- fetcher: (id: string, start: string, end: string) =>
33
- useGscAnalyticsClient().getSearchAppearance(id, { start, end }),
34
- isEmpty: r => r.rows.length === 0,
35
- })
36
-
37
- return {
38
- response: data as Readonly<Ref<SearchAppearanceResponse | null>>,
39
- rows: computed(() => data.value?.rows ?? []),
40
- range: computed(() => data.value?.range ?? null),
41
- source: computed(() => data.value?.source ?? null),
42
- loading,
43
- status,
44
- error,
45
- refresh,
46
- }
47
- }