@nuxtseo/pro-indexing 0.0.0-stage → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -2
- package/app/app.config.ts +14 -0
- package/app/components/IndexingCapabilityGate.vue +20 -0
- package/app/components/IndexingCohortList.vue +130 -0
- package/app/components/IndexingCoverageTrend.vue +145 -0
- package/app/components/IndexingCrawlPipeline.vue +211 -0
- package/app/components/IndexingDiagnosisPanel.vue +266 -0
- package/app/components/IndexingPortfolioChanges.vue +320 -0
- package/app/components/IndexingPortfolioIssues.vue +202 -0
- package/app/components/IndexingPortfolioOverview.vue +200 -0
- package/app/components/IndexingSiteIssues.vue +123 -0
- package/app/components/IndexingUrlsTable.vue +1084 -0
- package/app/components/IndexingUrlsTableShell.vue +237 -0
- package/app/composables/useIndexingSource.ts +27 -0
- package/app/composables/useProIndexingConfig.ts +10 -0
- package/app/composables/useProIndexingCopy.ts +10 -0
- package/app/composables/useProIndexingRoute.ts +23 -0
- package/nuxt.config.ts +33 -0
- package/package.json +67 -3
- package/shared/changes.ts +124 -0
- package/shared/config.ts +36 -0
- package/shared/copy.ts +306 -0
- package/shared/coverage-trend.ts +72 -0
- package/shared/issue-display.ts +77 -0
- package/shared/portfolio-overview.ts +120 -0
- package/shared/portfolio.ts +79 -0
- package/shared/routes.ts +63 -0
- package/shared/source.ts +153 -0
- package/shared/urls-query.ts +45 -0
package/shared/routes.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The indexing route map: each site maps the sections' logical routes to its
|
|
2
|
+
// own paths in app.config `proIndexing.routes`. A Site route holds the `[site]`
|
|
3
|
+
// token of the shell's route map, filled with `IndexingSite.ref`. A route the
|
|
4
|
+
// site leaves out resolves to null, and the link that needs it hides.
|
|
5
|
+
|
|
6
|
+
import { encodeProShellSiteRef, SITE_ROUTE_TOKEN } from '@nuxtseo/pro-shell/shared/routes'
|
|
7
|
+
|
|
8
|
+
/** Logical routes with no Site in the path. */
|
|
9
|
+
export const PRO_INDEXING_APP_ROUTES = [
|
|
10
|
+
'connectSearchConsole',
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
/** Logical routes inside one Site. Each template holds the `[site]` token. */
|
|
14
|
+
export const PRO_INDEXING_SITE_ROUTES = [
|
|
15
|
+
'siteIndexing',
|
|
16
|
+
'siteIndexingUrls',
|
|
17
|
+
'siteIndexingSitemaps',
|
|
18
|
+
] as const
|
|
19
|
+
|
|
20
|
+
export type ProIndexingAppRoute = typeof PRO_INDEXING_APP_ROUTES[number]
|
|
21
|
+
export type ProIndexingSiteRoute = typeof PRO_INDEXING_SITE_ROUTES[number]
|
|
22
|
+
|
|
23
|
+
/** `proIndexing.routes` in app.config. Every key is optional. */
|
|
24
|
+
export type ProIndexingRouteMap = {
|
|
25
|
+
readonly [K in ProIndexingAppRoute]?: string
|
|
26
|
+
} & {
|
|
27
|
+
readonly [K in ProIndexingSiteRoute]?: `${string}[site]${string}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ProIndexingQuery = Readonly<Record<string, string | undefined>>
|
|
31
|
+
|
|
32
|
+
function withQuery(path: string, query: ProIndexingQuery | undefined): string {
|
|
33
|
+
const entries = Object.entries(query ?? {}).filter((entry): entry is [string, string] => typeof entry[1] === 'string' && entry[1].length > 0)
|
|
34
|
+
if (entries.length === 0)
|
|
35
|
+
return path
|
|
36
|
+
const hashAt = path.indexOf('#')
|
|
37
|
+
const base = hashAt === -1 ? path : path.slice(0, hashAt)
|
|
38
|
+
const hash = hashAt === -1 ? '' : path.slice(hashAt)
|
|
39
|
+
return `${base}${base.includes('?') ? '&' : '?'}${new URLSearchParams(entries).toString()}${hash}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The site's path for an app route, or null when the site maps none. */
|
|
43
|
+
export function resolveIndexingAppRoute(routes: ProIndexingRouteMap, name: ProIndexingAppRoute, query?: ProIndexingQuery): string | null {
|
|
44
|
+
const template = routes[name]
|
|
45
|
+
return typeof template === 'string' && template.length > 0 ? withQuery(template, query) : null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The site's path for a Site route, or null when the site maps none. A template
|
|
50
|
+
* without the `[site]` token also resolves to null: it would link every Site
|
|
51
|
+
* to the same page.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveIndexingSiteRoute(routes: ProIndexingRouteMap, name: ProIndexingSiteRoute, site: string, query?: ProIndexingQuery): string | null {
|
|
54
|
+
const template = routes[name]
|
|
55
|
+
if (typeof template !== 'string' || !site || !template.includes(SITE_ROUTE_TOKEN))
|
|
56
|
+
return null
|
|
57
|
+
return withQuery(template.split(SITE_ROUTE_TOKEN).join(encodeProShellSiteRef(site)), query)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The URLs list filter an issue row links to, as `?issue=` or `?facet=`. */
|
|
61
|
+
export function indexingIssueQuery(filter: { readonly key: 'issue' | 'facet', readonly value: string }): ProIndexingQuery {
|
|
62
|
+
return { [filter.key]: filter.value }
|
|
63
|
+
}
|
package/shared/source.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// The IndexingSource: the one adapter every indexing section reads. Each site
|
|
2
|
+
// builds it once from its own data layer and provides it above the sections
|
|
3
|
+
// (`provideIndexingSource`). The layer calls its reads in a section's setup and
|
|
4
|
+
// renders their state; it never fetches.
|
|
5
|
+
//
|
|
6
|
+
// A required read is one every site can answer from the hosted gscdump API. An
|
|
7
|
+
// optional field is a capability: a site that leaves it out does not have the
|
|
8
|
+
// feature, and the section that needs it does not render.
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
GscdumpCanonicalMismatchesResponse,
|
|
12
|
+
GscdumpIndexingDiagnosticsResponse,
|
|
13
|
+
GscdumpIndexingUrl,
|
|
14
|
+
GscdumpIndexingUrlsResponse,
|
|
15
|
+
IndexingInspectRateLimited,
|
|
16
|
+
IndexingInspectResponse,
|
|
17
|
+
IndexingUrlsParams,
|
|
18
|
+
} from '@gscdump/contracts'
|
|
19
|
+
import type { IndexCohortsResponse, IndexingDiagnoseInput, IndexingOverviewDiagnosis } from '@gscdump/sdk/indexing'
|
|
20
|
+
import type { MaybeRefOrGetter, Ref } from 'vue'
|
|
21
|
+
import type { IndexingChangesRollup } from './changes'
|
|
22
|
+
|
|
23
|
+
/** The state of one read. `idle` has not started; `pending` is in flight. */
|
|
24
|
+
export type IndexingReadStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* One reactive read. Map the site's own query composable onto it, so caching,
|
|
28
|
+
* SSR, and deduping stay the site's. `data` keeps the last good value while a
|
|
29
|
+
* refresh runs.
|
|
30
|
+
*/
|
|
31
|
+
export interface IndexingRead<T> {
|
|
32
|
+
readonly data: Readonly<Ref<T | null | undefined>>
|
|
33
|
+
readonly status: Readonly<Ref<IndexingReadStatus>>
|
|
34
|
+
readonly error: Readonly<Ref<unknown>>
|
|
35
|
+
readonly refresh: () => Promise<void>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A Site as the indexing sections address it. */
|
|
39
|
+
export interface IndexingSite {
|
|
40
|
+
/** The site's own Site id. */
|
|
41
|
+
readonly id: string
|
|
42
|
+
/** What the route map's `[site]` token takes: an id, a public id, or a Site URL. */
|
|
43
|
+
readonly ref: string
|
|
44
|
+
readonly label: string
|
|
45
|
+
/** The Site URL, for its favicon. Null when unknown. */
|
|
46
|
+
readonly url: string | null
|
|
47
|
+
/**
|
|
48
|
+
* The id the source reads indexing data with, such as a gscdump Site id.
|
|
49
|
+
* Null when Search Console is not linked: every read stays idle.
|
|
50
|
+
*/
|
|
51
|
+
readonly dataId: string | null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** One reference action of a diagnosis, as the URLs table explains it. */
|
|
55
|
+
export interface IndexingDiagnosisAction {
|
|
56
|
+
readonly id: IndexingOverviewDiagnosis['recommendedActions'][number]['id']
|
|
57
|
+
readonly title: string
|
|
58
|
+
readonly detail: string
|
|
59
|
+
readonly why: string
|
|
60
|
+
readonly source: { readonly url: string, readonly label: string }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The diagnosis a site computes. The layer reads its reason, summary, and actions. */
|
|
64
|
+
export interface IndexingSiteDiagnosis extends IndexingOverviewDiagnosis {
|
|
65
|
+
/** `severe` reads as "Action needed", `watch` as "Review", `ok` as "Healthy" unless a reason remains. */
|
|
66
|
+
readonly severity: 'ok' | 'watch' | 'severe'
|
|
67
|
+
readonly summary: string
|
|
68
|
+
readonly recommendedActions: ReadonlyArray<IndexingDiagnosisAction>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type IndexingInspectResult = IndexingInspectResponse | IndexingInspectRateLimited
|
|
72
|
+
|
|
73
|
+
/** Sites with a Sitemap problem across the Portfolio, by `IndexingSite.id`. */
|
|
74
|
+
export interface IndexingSitemapProblems {
|
|
75
|
+
/** Sites whose Sitemap does not answer. */
|
|
76
|
+
readonly unreachable: readonly string[]
|
|
77
|
+
/** Sites whose Sitemap Search Console reports with errors. */
|
|
78
|
+
readonly errors: readonly string[]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type SiteInput = MaybeRefOrGetter<IndexingSite | null | undefined>
|
|
82
|
+
|
|
83
|
+
export interface IndexingSource {
|
|
84
|
+
/** The Site's indexing diagnostics: summary, issues, and meta. */
|
|
85
|
+
readonly diagnostics: (site: SiteInput) => IndexingRead<GscdumpIndexingDiagnosticsResponse>
|
|
86
|
+
/** One page of the Site's inspected URLs. */
|
|
87
|
+
readonly urls: (site: SiteInput, params: MaybeRefOrGetter<IndexingUrlsReadParams>) => IndexingRead<GscdumpIndexingUrlsResponse>
|
|
88
|
+
|
|
89
|
+
// Capabilities. A section that needs a missing one does not render.
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The site's diagnosis of a Site's indexing. With it, the URLs table explains
|
|
93
|
+
* the filtered issue. `diagnoseIndexing` reads Crawl evidence, so it stays in
|
|
94
|
+
* the site.
|
|
95
|
+
*/
|
|
96
|
+
readonly diagnose?: (input: IndexingDiagnoseInput<GscdumpIndexingUrl>) => IndexingSiteDiagnosis
|
|
97
|
+
/**
|
|
98
|
+
* Re-inspect URLs with Google now. With it, each URL row offers "Re-check
|
|
99
|
+
* with Google". The section calls it once in setup and keeps the function.
|
|
100
|
+
*/
|
|
101
|
+
readonly inspect?: () => (site: IndexingSite, urls: readonly string[]) => Promise<IndexingInspectResult>
|
|
102
|
+
/** Google's chosen canonicals. With it, the URLs table shows consolidation targets. */
|
|
103
|
+
readonly canonicalMismatches?: (site: SiteInput, enabled: MaybeRefOrGetter<boolean>) => IndexingRead<GscdumpCanonicalMismatchesResponse>
|
|
104
|
+
/** Index cohorts for a Site. With it, the Index cohorts section renders. */
|
|
105
|
+
readonly cohorts?: (site: SiteInput) => IndexingRead<IndexCohortsResponse>
|
|
106
|
+
/** The live Sitemap check across the Portfolio. With it, the Sitemap problems tile renders. */
|
|
107
|
+
readonly sitemapProblems?: () => IndexingRead<IndexingSitemapProblems>
|
|
108
|
+
/** The Portfolio changes roll-up. With it, the Portfolio Changes section renders. */
|
|
109
|
+
readonly changesRollup?: () => IndexingRead<IndexingChangesRollup>
|
|
110
|
+
/** IndexNow submission. The site draws its own IndexNow panel inside `IndexingCapabilityGate`. */
|
|
111
|
+
readonly indexNow?: true
|
|
112
|
+
/** Watched URLs. The site draws its own Watched URLs panel inside `IndexingCapabilityGate`. */
|
|
113
|
+
readonly watchedUrls?: true
|
|
114
|
+
/**
|
|
115
|
+
* The `urls` read honours `params.cohort`. With it, Index cohort rows link
|
|
116
|
+
* to their exact cohort (`?cohort=`), and the URLs table passes the filter
|
|
117
|
+
* on. Without it, a cohort row links by its path prefix.
|
|
118
|
+
*/
|
|
119
|
+
readonly cohortFilter?: true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The `urls` read's parameters. `cohort` is an Index cohort filter value from
|
|
124
|
+
* `indexCohortFilterValue` (`@gscdump/sdk/indexing`), such as
|
|
125
|
+
* `lifecycle:versioned`. The table sends it only to a source with the
|
|
126
|
+
* `cohortFilter` capability; parse it with `parseIndexCohortFilter`.
|
|
127
|
+
*/
|
|
128
|
+
export type IndexingUrlsReadParams = IndexingUrlsParams & { readonly cohort?: string }
|
|
129
|
+
|
|
130
|
+
/** The optional fields of an IndexingSource. */
|
|
131
|
+
export const INDEXING_CAPABILITIES = [
|
|
132
|
+
'diagnose',
|
|
133
|
+
'inspect',
|
|
134
|
+
'canonicalMismatches',
|
|
135
|
+
'cohorts',
|
|
136
|
+
'sitemapProblems',
|
|
137
|
+
'changesRollup',
|
|
138
|
+
'indexNow',
|
|
139
|
+
'watchedUrls',
|
|
140
|
+
'cohortFilter',
|
|
141
|
+
] as const satisfies ReadonlyArray<keyof IndexingSource>
|
|
142
|
+
|
|
143
|
+
export type IndexingCapability = typeof INDEXING_CAPABILITIES[number]
|
|
144
|
+
|
|
145
|
+
/** True when the source has the capability. A missing source has none. */
|
|
146
|
+
export function hasIndexingCapability(source: IndexingSource | null | undefined, capability: IndexingCapability): boolean {
|
|
147
|
+
return source?.[capability] !== undefined
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The capabilities a source has, in `INDEXING_CAPABILITIES` order. */
|
|
151
|
+
export function indexingCapabilities(source: IndexingSource | null | undefined): IndexingCapability[] {
|
|
152
|
+
return INDEXING_CAPABILITIES.filter(capability => hasIndexingCapability(source, capability))
|
|
153
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { indexCohortFilterValue, parseIndexCohortFilter } from '@gscdump/sdk/indexing'
|
|
2
|
+
import { issueDetails } from '@gscdump/sdk/indexing-issues'
|
|
3
|
+
|
|
4
|
+
/** A URLs-table facet: a panel above the rows. */
|
|
5
|
+
export type IndexingUrlsFacet = 'canonical_mismatch' | 'rich_results'
|
|
6
|
+
|
|
7
|
+
/** The URLs-table filters a route query carries. */
|
|
8
|
+
export interface IndexingUrlsQuery {
|
|
9
|
+
/** A known issue type. The `canonical_mismatch` facet implies its issue. */
|
|
10
|
+
readonly issue: string | undefined
|
|
11
|
+
readonly facet: IndexingUrlsFacet | undefined
|
|
12
|
+
/** Undefined while an issue filter is active: the API takes one of the two. */
|
|
13
|
+
readonly status: 'indexed' | 'not_indexed' | undefined
|
|
14
|
+
readonly search: string | undefined
|
|
15
|
+
/** An Index cohort filter value, such as `lifecycle:versioned`. Kept beside a status filter. */
|
|
16
|
+
readonly cohort: string | undefined
|
|
17
|
+
readonly page: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type QueryValue = string | null | undefined | ReadonlyArray<string | null>
|
|
21
|
+
|
|
22
|
+
function text(value: QueryValue): string | undefined {
|
|
23
|
+
return typeof value === 'string' && value ? value : undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parses a route query into the URLs-table filters. An unknown issue, facet,
|
|
28
|
+
* status or page reads as absent, so a stale link still shows the table.
|
|
29
|
+
* `IndexingUrlsTable` follows this on every route change.
|
|
30
|
+
*/
|
|
31
|
+
export function parseIndexingUrlsQuery(query: Readonly<Record<string, QueryValue>>): IndexingUrlsQuery {
|
|
32
|
+
const rawIssue = text(query.issue)
|
|
33
|
+
const rawFacet = text(query.facet)
|
|
34
|
+
const facet = rawFacet === 'canonical_mismatch' || rawFacet === 'rich_results' ? rawFacet : undefined
|
|
35
|
+
const issue = rawIssue && issueDetails[rawIssue]
|
|
36
|
+
? rawIssue
|
|
37
|
+
: facet === 'canonical_mismatch' ? 'canonical_mismatch' : undefined
|
|
38
|
+
const rawStatus = text(query.status)
|
|
39
|
+
const status = !issue && (rawStatus === 'indexed' || rawStatus === 'not_indexed') ? rawStatus : undefined
|
|
40
|
+
const rawPage = text(query.page)
|
|
41
|
+
const page = rawPage && /^[1-9]\d*$/.test(rawPage) ? Number(rawPage) : 1
|
|
42
|
+
const parsedCohort = parseIndexCohortFilter(text(query.cohort))
|
|
43
|
+
const cohort = parsedCohort._tag === 'ok' ? indexCohortFilterValue(parsedCohort.filter) : undefined
|
|
44
|
+
return { issue, facet, status, search: text(query.search), cohort, page }
|
|
45
|
+
}
|