@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.
Files changed (66) hide show
  1. package/README.md +10 -137
  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 +26 -176
  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 -214
  15. package/app/components/GscLazyTopResult.vue +0 -47
  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 -196
  21. package/app/components/GscSyncStatusCell.vue +0 -54
  22. package/app/components/GscTopRollupCard.vue +0 -90
  23. package/app/composables/_useGscBackfill.ts +0 -119
  24. package/app/composables/_useGscQueryDispatcher.ts +0 -123
  25. package/app/composables/_useGscResource.ts +0 -202
  26. package/app/composables/_useGscSharedSiteResource.ts +0 -136
  27. package/app/composables/useGscAnalytics.ts +0 -206
  28. package/app/composables/useGscAnalyticsClient.ts +0 -9
  29. package/app/composables/useGscAnalyticsConfig.ts +0 -8
  30. package/app/composables/useGscAnalyticsSourceInfo.ts +0 -165
  31. package/app/composables/useGscAnalyzer.ts +0 -460
  32. package/app/composables/useGscAnalyzerBatch.ts +0 -106
  33. package/app/composables/useGscAnalyzerDefs.ts +0 -119
  34. package/app/composables/useGscAuth.ts +0 -115
  35. package/app/composables/useGscConsoleUrl.ts +0 -45
  36. package/app/composables/useGscCountries.ts +0 -46
  37. package/app/composables/useGscCurrentSite.ts +0 -36
  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/useGscPeriod.ts +0 -243
  42. package/app/composables/useGscQuery.ts +0 -301
  43. package/app/composables/useGscQueryDispatcher.ts +0 -14
  44. package/app/composables/useGscRequestIndexingInspect.ts +0 -29
  45. package/app/composables/useGscResource.ts +0 -11
  46. package/app/composables/useGscRollup.ts +0 -237
  47. package/app/composables/useGscSearchAppearance.ts +0 -46
  48. package/app/composables/useGscSiteAnalyzer.ts +0 -456
  49. package/app/composables/useGscSitemapHistory.ts +0 -41
  50. package/app/composables/useGscSitemaps.ts +0 -45
  51. package/app/composables/useGscTableState.ts +0 -119
  52. package/app/plugins/analytics.ts +0 -57
  53. package/app/queries/gsc.ts +0 -163
  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/gsc-rpc.ts +0 -18
  63. package/app/utils/position.ts +0 -7
  64. package/module.ts +0 -81
  65. package/nuxt.config.ts +0 -61
  66. package/types.ts +0 -115
@@ -1,72 +0,0 @@
1
- // Shape-canonicalising helpers for GSC row payloads.
2
- //
3
- // Free-tier rows (GSC API) ship `position`; engine rows ship `sum_position`.
4
- // Both formats coerce to the same denominator: `sum_position = position * impressions`,
5
- // so downstream `weightedPosition / impressions` math works without branching.
6
- //
7
- // Lifted from the per-page detail pages where the coalesce + totals reducer
8
- // was duplicated. The `+1` in `position` is GSC's 1-indexed convention
9
- // (position 1 == top result), applied once after weighting.
10
-
11
- export interface RawDailyRow {
12
- date: string
13
- clicks: number
14
- impressions: number
15
- sum_position?: number
16
- position?: number
17
- }
18
-
19
- export interface CanonicalDailyRow {
20
- date: string
21
- clicks: number
22
- impressions: number
23
- sum_position: number
24
- }
25
-
26
- export interface GscRowTotals {
27
- clicks: number
28
- impressions: number
29
- ctr: number
30
- position: number
31
- }
32
-
33
- export interface GscDailySummary {
34
- daily: CanonicalDailyRow[]
35
- totals: GscRowTotals
36
- chartData: Array<{ date: string, clicks: number, impressions: number }>
37
- }
38
-
39
- /** Fill `sum_position` from `position * impressions` when the row only carries `position`. */
40
- export function coerceRowMetrics<
41
- T extends { impressions: number, sum_position?: number, position?: number },
42
- >(row: T): T & { sum_position: number } {
43
- return {
44
- ...row,
45
- sum_position: row.sum_position ?? (row.position ?? 0) * row.impressions,
46
- }
47
- }
48
-
49
- /** Sort daily rows by date asc, coerce `sum_position`, reduce totals, derive chartData. */
50
- export function summarizeDailyRows(raw: readonly RawDailyRow[]): GscDailySummary {
51
- const daily: CanonicalDailyRow[] = raw
52
- .map(coerceRowMetrics)
53
- .map(r => ({ date: r.date, clicks: r.clicks, impressions: r.impressions, sum_position: r.sum_position }))
54
- .sort((a, b) => a.date.localeCompare(b.date))
55
-
56
- let clicks = 0
57
- let impressions = 0
58
- let weightedPosition = 0
59
- for (const d of daily) {
60
- clicks += d.clicks
61
- impressions += d.impressions
62
- weightedPosition += d.sum_position
63
- }
64
- const totals: GscRowTotals = {
65
- clicks,
66
- impressions,
67
- ctr: impressions > 0 ? clicks / impressions : 0,
68
- position: impressions > 0 ? weightedPosition / impressions + 1 : 0,
69
- }
70
- const chartData = daily.map(d => ({ date: d.date, clicks: d.clicks, impressions: d.impressions }))
71
- return { daily, totals, chartData }
72
- }
@@ -1,18 +0,0 @@
1
- import type { NuxtRpcErrorEvent, UseNuxtRpcOptions } from 'nuxt-use-query/rpc'
2
- import { toHumanNuxtRpcError, useNuxtRpc } from 'nuxt-use-query/rpc'
3
- import { useGscFetch } from './gsc-fetch'
4
-
5
- // Layer-shared RPC executor. Routes through `useGscFetch()` so auth headers and
6
- // the configured `apiBase` (cross-origin gscdump.com deployments) are honoured.
7
- // Defaults `onError` to log a humanised message via `toHumanNuxtRpcError`; the
8
- // toast is already emitted by `useGscFetch`'s `onResponseError`, so this is
9
- // non-duplicate diagnostic output that hosts can override.
10
- export function useGscRpc(options: UseNuxtRpcOptions = {}): ReturnType<typeof useNuxtRpc> {
11
- return useNuxtRpc({
12
- ...options,
13
- fetch: options.fetch ?? (useGscFetch() as UseNuxtRpcOptions['fetch']),
14
- onError: options.onError ?? ((event: NuxtRpcErrorEvent) => {
15
- console.warn(`[gsc-rpc] ${event.operation.method} ${event.operation.path}: ${toHumanNuxtRpcError(event.error)}`)
16
- }),
17
- })
18
- }
@@ -1,7 +0,0 @@
1
- // Rollup-row position helper. `sum_position` is GSC's average-position sum
2
- // across impressions; dividing back out (+1 because GSC is 1-indexed) gives
3
- // the impression-weighted average position. Returns 0 when there were no
4
- // impressions so the column renders blank rather than NaN.
5
- export function positionFor(r: { impressions: number, sum_position: number }): number {
6
- return r.impressions > 0 ? r.sum_position / r.impressions + 1 : 0
7
- }
package/module.ts DELETED
@@ -1,81 +0,0 @@
1
- // Nuxt module for @gscdump/nuxt.
2
- //
3
- // Responsibilities:
4
- // - Merge the layer's public runtime-config defaults (apiBase, duckdbBundleBase)
5
- // with env-var fallbacks. The layer is a portable client; hosts pick where
6
- // `/api/__gsc/*` calls go via `GSCDUMP_ANALYTICS_API_BASE`.
7
- // - Generate the `$gscAnalyzers` plugin from `options.analyzers` so hosts
8
- // only declare their analyzer registry path in `nuxt.config.ts` — no
9
- // plugin boilerplate.
10
- //
11
- // Auth-provider wiring is NOT a Nuxt module hook; the host wires its own
12
- // Nitro server handlers using primitives from @gscdump/cloudflare,
13
- // @gscdump/engine-sqlite, and @gscdump/analysis. Using a build-time hook
14
- // here would fire before the host's plugin has a chance to register.
15
-
16
- import type { GscAnalyticsRuntimeConfig } from './types'
17
- import process from 'node:process'
18
- import { addPluginTemplate, defineNuxtModule } from '@nuxt/kit'
19
- import { defu } from 'defu'
20
-
21
- export interface ModuleOptions {
22
- /**
23
- * Path to a TS/JS file exporting `ANALYZERS` (a `GscAnalyzerDefinition[]`).
24
- * Accepts Nuxt aliases (`~/gscAnalyzers`) or absolute paths. When set, the
25
- * module generates a plugin that provides `$gscAnalyzers` so hosts do not
26
- * need to hand-roll their own plugin file.
27
- */
28
- analyzers?: string
29
- }
30
-
31
- declare module 'nuxt/schema' {
32
- interface NuxtConfig { gscdumpAnalytics?: ModuleOptions }
33
- interface NuxtOptions { gscdumpAnalytics: ModuleOptions }
34
- }
35
-
36
- export default defineNuxtModule<ModuleOptions>({
37
- meta: {
38
- name: '@gscdump/nuxt',
39
- configKey: 'gscdumpAnalytics',
40
- compatibility: { nuxt: '>=4.0.0' },
41
- },
42
- setup(options, nuxt) {
43
- const defaults: GscAnalyticsRuntimeConfig = {
44
- apiBase: process.env.GSCDUMP_ANALYTICS_API_BASE ?? '',
45
- duckdbBundleBase: process.env.GSCDUMP_DUCKDB_BUNDLE_BASE ?? '',
46
- timezone: process.env.GSCDUMP_ANALYTICS_TIMEZONE ?? '',
47
- toastErrors: process.env.GSCDUMP_ANALYTICS_TOAST_ERRORS === 'true',
48
- defaultEngine: (process.env.GSCDUMP_ANALYTICS_DEFAULT_ENGINE as GscAnalyticsRuntimeConfig['defaultEngine'] | undefined) ?? 'auto',
49
- }
50
- nuxt.options.runtimeConfig.public.analytics = defu(
51
- nuxt.options.runtimeConfig.public.analytics as Partial<GscAnalyticsRuntimeConfig> | undefined,
52
- defaults,
53
- )
54
-
55
- if (options.analyzers) {
56
- // Generated plugin imports the host's analyzer file and provides
57
- // `$gscAnalyzers`. Runs after the layer's `analytics.ts` plugin (which
58
- // doesn't provide `$gscAnalyzers`), so consumers see this array.
59
- addPluginTemplate({
60
- filename: 'gscdump-analyzers.plugin.mjs',
61
- getContents: () => [
62
- `import { defineNuxtPlugin } from '#app'`,
63
- `import { ANALYZERS } from ${JSON.stringify(options.analyzers)}`,
64
- `export default defineNuxtPlugin(() => ({ provide: { gscAnalyzers: ANALYZERS } }))`,
65
- ``,
66
- ].join('\n'),
67
- })
68
- }
69
-
70
- // Strip internal composables from the consumer auto-import surface.
71
- // `app/composables/_useFoo.ts` stays usable inside the layer via explicit
72
- // relative imports, but never appears as a global auto-import in host apps.
73
- nuxt.hook('imports:extend', (imports) => {
74
- for (let i = imports.length - 1; i >= 0; i--) {
75
- const from = imports[i]?.from ?? ''
76
- if (/\/_use[A-Z]/.test(from))
77
- imports.splice(i, 1)
78
- }
79
- })
80
- },
81
- })
package/nuxt.config.ts DELETED
@@ -1,61 +0,0 @@
1
- // Layer-mode Nuxt config for @gscdump/nuxt.
2
- //
3
- // Consuming apps pull this in via `extends: ['@gscdump/nuxt']` in
4
- // their own nuxt.config.ts. Anything declared here is a shared default; hosts
5
- // can override in the normal Nuxt fashion (defu-merged, app config wins).
6
- //
7
- // Contract: the layer assumes every consumer is a Nuxt UI v4 app. We register
8
- // `@nuxt/ui` here and ship the shared main.css so hosts don't have to
9
- // rediscover the setup — components in this layer freely use UButton,
10
- // UPopover, UIcon, etc.
11
-
12
- import { fileURLToPath } from 'node:url'
13
-
14
- export default defineNuxtConfig({
15
- // Register the layer's module so hooks + runtime config land on host apps
16
- // without them having to wire each module individually.
17
- //
18
- // `nuxt-use-query` provides `useNuxtQuery` / `useQueryCache` — TanStack-Query-
19
- // shaped wrapper over `useFetch`. Composables in this layer fetch through
20
- // it for SWR + dedup.
21
- modules: [
22
- fileURLToPath(new URL('./module.ts', import.meta.url)),
23
- '@nuxt/ui',
24
- '@vueuse/nuxt',
25
- 'nuxt-use-query',
26
- ],
27
-
28
- // Enforce shared/contracts + app/queries pattern at build time so host apps
29
- // can't drift back to hardcoded `/api/*` literals in components / composables.
30
- // Hosts can opt out per-site by overriding `nuxtUseQuery.contracts.enabled`.
31
- nuxtUseQuery: {
32
- contracts: {
33
- enabled: true,
34
- // `@gscdump/contracts` is the shared package alias for hosted-API wire
35
- // shapes — query files must import from there (or a host
36
- // `shared/contracts/*`).
37
- apiPrefixes: ['/api/__gsc', '/api/sync-progress'],
38
- queryDirs: ['app/queries', 'layers/*/app/queries'],
39
- contractDirs: ['shared/contracts', 'layers/*/shared/contracts', '@gscdump/contracts'],
40
- serverApiDirs: ['server/api', 'layers/*/server/api'],
41
- requireServerContracts: false,
42
- // The config file declares these prefixes so the scanner must skip it.
43
- // (overrides the default ignore set — keep the defaults alongside it.)
44
- ignore: ['.git', '.nuxt', '.output', 'coverage', 'dist', 'node_modules', 'nuxt.config.ts'],
45
- },
46
- },
47
-
48
- css: [
49
- fileURLToPath(new URL('./app/assets/css/main.css', import.meta.url)),
50
- ],
51
-
52
- // runtimeConfig defaults live in module.ts (single source of truth).
53
-
54
- vite: {
55
- optimizeDeps: {
56
- // DuckDB-WASM workers use URL imports Vite's prebundler cannot resolve.
57
- // Keep them outside optimizeDeps so they stream as-is.
58
- exclude: ['@duckdb/duckdb-wasm'],
59
- },
60
- },
61
- })
package/types.ts DELETED
@@ -1,115 +0,0 @@
1
- // Public API surface of @gscdump/nuxt.
2
- // Anything not exported here is considered internal and may change without a major bump.
3
- //
4
- // This package is a frontend-only Nuxt layer. Server-side primitives (auth
5
- // providers, query sources, GSC API helpers) live in their respective sibling
6
- // packages: `@gscdump/analysis` (sources), `gscdump` (GSC API client), and
7
- // host-specific Nitro server code in the consuming app.
8
-
9
- import type { AnalyticsClient } from '@gscdump/sdk'
10
- import type { $Fetch } from 'ofetch'
11
- import type { GscAnalyticsContext } from './app/composables/useGscAnalytics'
12
- import type { GscAnalyzerDefinition } from './app/composables/useGscAnalyzerDefs'
13
- import type { GscQueryDispatcher } from './app/composables/useGscQueryDispatcher'
14
-
15
- export interface GscAnalyticsRuntimeConfig {
16
- /**
17
- * Base URL the client uses to reach the analytics API (`/api/__gsc/*`).
18
- * Empty string = same-origin. Hosts running the layer as a portable client
19
- * against a remote origin (e.g. an embedded dashboard pointing at
20
- * https://gscdump.com) set this via `GSCDUMP_ANALYTICS_API_BASE`.
21
- */
22
- apiBase: string
23
- /** Base URL for DuckDB-WASM worker + bundle assets. Empty = layer default. */
24
- duckdbBundleBase: string
25
- /** IANA tz name; empty = browser default. */
26
- timezone: string
27
- /** When true, layer auto-toasts classified fetch errors via Nuxt UI. */
28
- toastErrors: boolean
29
- /** Default engine when caller doesn't pass `opts.engine`. */
30
- defaultEngine: 'auto' | 'browser' | 'server'
31
- }
32
-
33
- declare module '@nuxt/schema' {
34
- interface PublicRuntimeConfig {
35
- analytics: GscAnalyticsRuntimeConfig
36
- }
37
- }
38
-
39
- declare module '#app' {
40
- interface NuxtApp {
41
- $gscAnalytics: GscAnalyticsContext
42
- $gscQueryDispatcher: GscQueryDispatcher
43
- $gscFetch: $Fetch
44
- $gscAnalyticsClient: AnalyticsClient
45
- $gscAnalyzers?: GscAnalyzerDefinition[]
46
- }
47
- }
48
-
49
- export type { GscAnalyzerInstance, GscAnalyzerTimings } from './app/composables/useGscAnalyzer'
50
- export type {
51
- GscAnalyzerBatchEntry,
52
- GscAnalyzerBatchRunner,
53
- GscAnalyzerBatchStatus,
54
- UseGscAnalyzerBatchOptions,
55
- } from './app/composables/useGscAnalyzerBatch'
56
- export { defineGscAnalyzer } from './app/composables/useGscAnalyzerDefs'
57
- export type {
58
- GscAnalyzerAccent,
59
- GscAnalyzerCapabilities,
60
- GscAnalyzerCapability,
61
- GscAnalyzerDefinition,
62
- GscAnalyzerDefinitionWithCapability,
63
- GscAnalyzerInsightCard,
64
- GscAnalyzerKind,
65
- GscAnalyzerPanelResult,
66
- GscAnalyzerPanelSpec,
67
- GscAnalyzerStatTile,
68
- } from './app/composables/useGscAnalyzerDefs'
69
- export { gscPanelRunnerKey, useGscPanelRunner } from './app/composables/useGscPanelContext'
70
-
71
- export type { GscPanelRunnerContext } from './app/composables/useGscPanelContext'
72
-
73
- export type {
74
- GscBackfillRunner,
75
- GscQueryDecision,
76
- GscQueryDecisionReason,
77
- GscQueryEngine,
78
- GscQueryMeta,
79
- GscQueryStatus,
80
- UseGscQueryOptions,
81
- UseGscQueryReturn,
82
- } from './app/composables/useGscQuery'
83
-
84
- export type {
85
- GscFactTable,
86
- GscTableStage,
87
- GscTableStatus,
88
- UseGscSiteAnalyzerReturn,
89
- } from './app/composables/useGscSiteAnalyzer'
90
-
91
- export type {
92
- AnalysisSourcesResponse,
93
- CountriesResponse,
94
- CountryRow,
95
- GscApiRange,
96
- GscRowQueryMeta,
97
- GscRowQueryResponse,
98
- IndexingDiagnostics,
99
- IndexingIssue,
100
- IndexingIssueSeverity,
101
- IndexingUrlRow,
102
- IndexingUrlsResponse,
103
- IndexingUrlStatus,
104
- InspectionHistoryRecord,
105
- InspectionHistoryResponse,
106
- SearchAppearanceResponse,
107
- SearchAppearanceRow,
108
- SiteListItem,
109
- SitemapAddedRow,
110
- SitemapChangesResponse,
111
- SitemapHistoryRecord,
112
- SitemapHistoryResponse,
113
- SitemapRemovedRow,
114
- SourceInfoResponse,
115
- } from '@gscdump/contracts'