@gscdump/analysis 0.40.1 → 1.0.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 CHANGED
@@ -17,11 +17,7 @@ npm install @gscdump/analysis
17
17
  | Subpath | Use when |
18
18
  |---|---|
19
19
  | `@gscdump/analysis` | Top-level barrel: row analyzers, source-backed analyzers, `SQL_ANALYZERS`, `analyzeInBrowser`, `defaultAnalyzerRegistry`, contract types re-exported from engine. |
20
- | `@gscdump/analysis/analyzer` | `ROW_ANALYZERS` array + `paginate*` / `adapt-rows` helpers used by analyzer authors. |
21
20
  | `@gscdump/analysis/registry` | Pre-built `defaultAnalyzerRegistry` (rows + sql). Convenience for callers who don't care about bundle size. |
22
- | `@gscdump/analysis/source` | Portable query sources (`createInMemoryQuerySource`, `createCompositeSource`) + source-backed analyzers. |
23
- | `@gscdump/analysis/semantic` | Browser-only semantic analyzers such as content-gap; optional `@huggingface/transformers` peer. |
24
- | `@gscdump/analysis/query` | `buildDataQueryPlan` / `buildDataDetailPlan` for the generic query analyzers. |
25
21
 
26
22
  The contract layer (`Analyzer`, `Plan`, `Capability`, `AnalysisParams`, `AnalysisResult`, `AnalysisQuerySource`, `runAnalyzerFromSource`, `createAnalyzerRegistry`, `defineAnalyzer`, period helpers, `createEngineQuerySource`) lives in `@gscdump/engine` under the `/analyzer`, `/analysis-types`, `/period`, `/source`, and `/resolver` subpaths. Most are re-exported from `@gscdump/analysis` for convenience.
27
23
 
@@ -118,7 +114,7 @@ tables rather than a canonical-schema `createEngine`; see ADR-0001.
118
114
 
119
115
  ## SQLite (D1 / Cloudflare Workers)
120
116
 
121
- Mirror of the DuckDB path, dialect-targeted at sqlite-core. `@gscdump/engine-sqlite` exports `createEngine` (a `SqlQuerySource` over `executor + siteId`), `compileSqlite`, drizzle helpers (`gsc_keywords`, etc.), and `resolveWindow` (re-export from `@gscdump/engine/period`).
117
+ Mirror of the DuckDB path, dialect-targeted at sqlite-core. `@gscdump/engine-sqlite` exports `createSqliteQuerySource` (an `AnalysisQuerySource` over `executor + siteId`), `compileSqlite`, drizzle helpers (`gsc_keywords`, etc.), and `resolveWindow` (re-export from `@gscdump/engine/period`).
122
118
 
123
119
  ## Query composers (dialect-neutral)
124
120
 
@@ -149,28 +145,15 @@ Available source factories:
149
145
 
150
146
  - `createGscApiQuerySource({ client, siteUrl })` — `@gscdump/engine-gsc-api`
151
147
  - `createLiveGscSource({ accessToken, siteUrl })` — `@gscdump/engine-gsc-api`
152
- - `createCompositeSource({ engine, gsc })` — `@gscdump/analysis/source`; engine first, GSC fallback
153
- - `createInMemoryQuerySource({ queryRows })` — `@gscdump/analysis/source`
148
+ - `createCompositeSource({ engine, gsc })` — `@gscdump/analysis`; engine first, GSC fallback
149
+ - `createInMemoryQuerySource({ queryRows })` — `@gscdump/analysis`
154
150
  - `createEngineQuerySource({ engine, ctx })` — `@gscdump/engine/source`
155
- - `createEngine({ ... })` — `@gscdump/engine-sqlite`
151
+ - `createSqliteQuerySource({ ... })` — `@gscdump/engine-sqlite`
156
152
 
157
153
  Portable analyzers currently cover the row-based tools:
158
154
  `striking-distance`, `opportunity`, `brand`, `clustering`, `concentration`,
159
155
  `seasonality`, `movers`, and `decay`.
160
156
 
161
- ## Semantic (browser-only)
162
-
163
- ```ts
164
- import { analyzeContentGap } from '@gscdump/analysis/semantic'
165
-
166
- const result = await analyzeContentGap(runner, {
167
- maxQueries: 1500,
168
- minDivergence: 0.12,
169
- })
170
- ```
171
-
172
- Loads a MiniLM/BGE embedding model via `@huggingface/transformers`, caches vectors in IndexedDB, and compares top queries to candidate URLs derived from `page_keywords`.
173
-
174
157
  ## Window resolution
175
158
 
176
159
  ```ts
@@ -189,7 +172,7 @@ Presets: `last-7d`, `last-28d`, `last-30d`, `last-90d`, `last-180d`, `last-365d`
189
172
  | Row analyzers (`analyzeMovers`, `analyzeDecay`, ...) | Public |
190
173
  | Source factories + `analyzeFromSource` | Public |
191
174
  | `Analyzer<P, R>` contract + `createAnalyzerRegistry` (re-exported from `@gscdump/engine/analyzer`) | Public |
192
- | `/source`, `/semantic`, `/query` subpaths | Public |
175
+ | Source factories on the package root | Public |
193
176
  | Per-analyzer modules under `analysis/src/analyzers/<name>` | Private |
194
177
 
195
178
  ## Related
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions,
3
3
  import { AnalysisParams, AnalysisParams as AnalysisParams$1, AnalysisResult, AnalysisResult as AnalysisResult$1, AnalysisTool, num } from "@gscdump/engine/analysis-types";
4
4
  import { Result } from "gscdump/result";
5
5
  import { BuilderState } from "gscdump/query";
6
- import { AnalysisQuerySource, AnalysisQuerySource as AnalysisQuerySource$1, AnalysisSourceKind, AttachedTableRunner, AttachedTableRunner as AnalyzerRunner, AttachedTableSourceOptions, AttachedTableSourceOptions as BrowserAnalyzeOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, ExecuteSqlOptions, FileSet, QueryRow, QueryRow as QueryRow$1, SourceCapabilities, createEngineQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine } from "@gscdump/engine/source";
6
+ import { AnalysisQuerySource, AnalysisQuerySource as AnalysisQuerySource$1, AnalysisSourceKind, AttachedTableRunner, AttachedTableRunner as AnalyzerRunner, AttachedTableSourceOptions, AttachedTableSourceOptions as BrowserAnalyzeOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, ExecuteSqlOptions, FileSet, QueryRow, QueryRow as QueryRow$1, SourceCapabilities, createEngineQuerySource, queryRows, runAnalyzerWithEngine } from "@gscdump/engine/source";
7
7
  import { DefineReportOptions, DefinedReport, DefinedReport as DefinedReport$1, ReportAction, ReportContext, ReportContext as ReportContext$1, ReportFinding, ReportParams, ReportPlanStep, ReportResult, ReportResult as ReportResult$1, ReportSection } from "@gscdump/engine/report";
8
8
  import { PlannerCapabilities } from "gscdump/query/plan";
9
9
  type ActionSource = 'cannibalization' | 'striking-distance' | 'ctr-anomaly' | 'change-point' | 'opportunity';
@@ -499,11 +499,6 @@ interface IntentClassification {
499
499
  declare const SEARCH_INTENT_CODE: Record<SearchIntent, number>;
500
500
  /** Pack a classification into one small int for cheap dimension storage. */
501
501
  declare function encodeIntent(c: Pick<IntentClassification, 'intent' | 'howTo'>): number;
502
- /** Inverse of {@link encodeIntent}. */
503
- declare function decodeIntent(code: number): {
504
- intent: SearchIntent;
505
- howTo: boolean;
506
- };
507
502
  /**
508
503
  * Classify the search intent of a raw query from lexical cues. Deterministic;
509
504
  * version it (`INTENT_CLASSIFIER_VERSION`) and bump on any rule change so a
@@ -646,4 +641,4 @@ interface InMemoryQuerySourceOptions {
646
641
  }
647
642
  declare function createInMemoryQuerySource(options: InMemoryQuerySourceOptions): AnalysisQuerySource$1;
648
643
  declare const SQL_ANALYZERS: readonly Analyzer$1[];
649
- export { type ActionPriorityResult, type ActionPrioritySourceState, type ActionPrioritySourceStatus, type ActionSource, type AnalysisError, type AnalysisErrorKind, type AnalysisParams, type AnalysisPeriod, type AnalysisQuerySource, type AnalysisResult, type AnalysisSourceKind, type AnalysisTool, type Analyzer, AnalyzerCapabilityError, type AnalyzerRegistry, type AnalyzerRegistryInit, type AnalyzerRunner, type AnalyzerVariants, type BaseMetrics, type BrandSegmentationOptions, type BrandSegmentationResult, type BrandSegmentationRow, type BrandSummary, type BrowserAnalyzeOptions, type CannibalizationCompetitor, type CannibalizationEvent, type CannibalizationOptions, type CannibalizationPage, type CannibalizationResult, type CannibalizationSortMetric, type ClusterType, type ClusteringOptions, type ClusteringResult, type ComparisonMode, type ComparisonPeriod, type CompositeSourceOptions, type ConcentrationInput, type ConcentrationItem, type ConcentrationOptions, type ConcentrationResult, type ConcentrationRiskLevel, DEFAULT_PRIORITY_SOURCES, type DateRow, type DecayInput, type DecayOptions, type DecayResult, type DecaySeriesPoint, type DecaySortMetric, type DefineAnalyzerOptions, type DefineReportOptions, type DefinedAnalyzer, type DefinedReport, type DryRunReportResult, ENGINE_QUERY_CAPABILITIES, type Effort, type EngineQuerySourceOptions, type ExecuteSqlOptions, type FileSet, type FormatReportOptions, INTENT_CLASSIFIER_VERSION, IN_MEMORY_DEFAULT_CAPABILITIES, type InMemoryQuerySourceOptions, type IntentClassification, type KeywordCluster, type MonthlyData, type MoverData, type MoversInput, type MoversOptions, type MoversResult, type MoversSortMetric, NORMALIZER_VERSION, type OpportunityFactors, type OpportunityOptions, type OpportunityResult, type OpportunitySortMetric, type OpportunityWeights, type PadTimeseriesOptions, type PageRow, type Plan, type PriorityAction, type QueriesRow, type QueryPageRow, type QueryRow, REPORTS, ROW_ANALYZERS, type ReduceContext, type ReduceCtx, type Reducer, type ReportAction, type ReportContext, type ReportFinding, type ReportPlanStep, type ReportResult, type ReportSection, type RequiredCapability, type ResolveWindowOptions, type ResolvedWindow, type RowQueriesPlan, type RunReportOptions, SEARCH_INTENT_CODE, SQL_ANALYZERS, type SearchIntent, type SeasonalityMetric, type SeasonalityOptions, type SeasonalityResult, type SitemapDelta, type SitemapHealthDiff, type SitemapHealthInput, type SitemapHealthRow, type SitemapHealthTotals, type SortOrder, type SourceCapabilities, type SqlExtraQuery, type SqlPlan, type SqlPlanSpec, type StrikingDistanceInputRow, type StrikingDistanceOptions, type StrikingDistanceResult, type TypedRowQuery, type WindowPreset, type ZeroClickOptions, type ZeroClickResult, analysisErrorToException, analysisErrors, analyzeBrandSegmentation, analyzeCannibalization, analyzeClustering, analyzeConcentration, analyzeDecay, analyzeInBrowser, analyzeKeywordConcentration, analyzeMovers, analyzeOpportunity, analyzePageConcentration, analyzeSeasonality, analyzeStrikingDistance, analyzeZeroClick, classifyQueryIntent, comparisonOf, createAnalyzerRegistry, createCompositeSource, createEngineQuerySource, createInMemoryQuerySource, createSorter, decodeIntent, defaultAnalyzerRegistry, defaultReportRegistry, defineAnalyzer, diffSitemapHealth, dryRunReport, encodeIntent, formatAnalysisError, formatReport, isAnalysisError, mergePriorityActions, normalizePriorityActions, normalizeQuery, num, padTimeseries, periodOf, queryRows, resolveWindow, rewriteForTableSource, runAnalyzerFromSource, runAnalyzerWithEngine, runReport, runReportResult, scorePriorityActions };
644
+ export { type ActionPriorityResult, type ActionPrioritySourceState, type ActionPrioritySourceStatus, type ActionSource, type AnalysisError, type AnalysisErrorKind, type AnalysisParams, type AnalysisPeriod, type AnalysisQuerySource, type AnalysisResult, type AnalysisSourceKind, type AnalysisTool, type Analyzer, AnalyzerCapabilityError, type AnalyzerRegistry, type AnalyzerRegistryInit, type AnalyzerRunner, type AnalyzerVariants, type BaseMetrics, type BrandSegmentationOptions, type BrandSegmentationResult, type BrandSegmentationRow, type BrandSummary, type BrowserAnalyzeOptions, type CannibalizationCompetitor, type CannibalizationEvent, type CannibalizationOptions, type CannibalizationPage, type CannibalizationResult, type CannibalizationSortMetric, type ClusterType, type ClusteringOptions, type ClusteringResult, type ComparisonMode, type ComparisonPeriod, type CompositeSourceOptions, type ConcentrationInput, type ConcentrationItem, type ConcentrationOptions, type ConcentrationResult, type ConcentrationRiskLevel, DEFAULT_PRIORITY_SOURCES, type DateRow, type DecayInput, type DecayOptions, type DecayResult, type DecaySeriesPoint, type DecaySortMetric, type DefineAnalyzerOptions, type DefineReportOptions, type DefinedAnalyzer, type DefinedReport, type DryRunReportResult, ENGINE_QUERY_CAPABILITIES, type Effort, type EngineQuerySourceOptions, type ExecuteSqlOptions, type FileSet, type FormatReportOptions, INTENT_CLASSIFIER_VERSION, IN_MEMORY_DEFAULT_CAPABILITIES, type InMemoryQuerySourceOptions, type IntentClassification, type KeywordCluster, type MonthlyData, type MoverData, type MoversInput, type MoversOptions, type MoversResult, type MoversSortMetric, NORMALIZER_VERSION, type OpportunityFactors, type OpportunityOptions, type OpportunityResult, type OpportunitySortMetric, type OpportunityWeights, type PadTimeseriesOptions, type PageRow, type Plan, type PriorityAction, type QueriesRow, type QueryPageRow, type QueryRow, REPORTS, ROW_ANALYZERS, type ReduceContext, type ReduceCtx, type Reducer, type ReportAction, type ReportContext, type ReportFinding, type ReportPlanStep, type ReportResult, type ReportSection, type RequiredCapability, type ResolveWindowOptions, type ResolvedWindow, type RowQueriesPlan, type RunReportOptions, SEARCH_INTENT_CODE, SQL_ANALYZERS, type SearchIntent, type SeasonalityMetric, type SeasonalityOptions, type SeasonalityResult, type SitemapDelta, type SitemapHealthDiff, type SitemapHealthInput, type SitemapHealthRow, type SitemapHealthTotals, type SortOrder, type SourceCapabilities, type SqlExtraQuery, type SqlPlan, type SqlPlanSpec, type StrikingDistanceInputRow, type StrikingDistanceOptions, type StrikingDistanceResult, type TypedRowQuery, type WindowPreset, type ZeroClickOptions, type ZeroClickResult, analysisErrorToException, analysisErrors, analyzeBrandSegmentation, analyzeCannibalization, analyzeClustering, analyzeConcentration, analyzeDecay, analyzeInBrowser, analyzeKeywordConcentration, analyzeMovers, analyzeOpportunity, analyzePageConcentration, analyzeSeasonality, analyzeStrikingDistance, analyzeZeroClick, classifyQueryIntent, comparisonOf, createAnalyzerRegistry, createCompositeSource, createEngineQuerySource, createInMemoryQuerySource, createSorter, defaultAnalyzerRegistry, defaultReportRegistry, defineAnalyzer, diffSitemapHealth, dryRunReport, encodeIntent, formatAnalysisError, formatReport, isAnalysisError, mergePriorityActions, normalizePriorityActions, normalizeQuery, num, padTimeseries, periodOf, queryRows, resolveWindow, runAnalyzerFromSource, runAnalyzerWithEngine, runReport, runReportResult, scorePriorityActions };
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { between, date, extractDateRange, gsc, page, query } from "gscdump/query
8
8
  import { MS_PER_DAY, daysAgoUtc, toIsoDate } from "gscdump/dates";
9
9
  import { buildExtrasQueries, buildTotalsSql, mergeExtras, pgResolverAdapter, resolveComparisonSQL, resolveToSQLOptimized } from "@gscdump/engine/resolver";
10
10
  import pluralize from "pluralize";
11
- import { ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine } from "@gscdump/engine/source";
11
+ import { ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, queryRows, runAnalyzerWithEngine } from "@gscdump/engine/source";
12
12
  import { computeInputHash, createReportRegistry, defineReport } from "@gscdump/engine/report";
13
13
  import { canProxyToGsc } from "@gscdump/engine-gsc-api";
14
14
  import { isStateResolvable } from "gscdump/query/plan";
@@ -2538,22 +2538,10 @@ const SEARCH_INTENT_CODE = {
2538
2538
  commercial: 2,
2539
2539
  transactional: 3
2540
2540
  };
2541
- const INTENT_BY_CODE = [
2542
- "unknown",
2543
- "informational",
2544
- "commercial",
2545
- "transactional"
2546
- ];
2547
2541
  const HOWTO_BIT = 4;
2548
2542
  function encodeIntent(c) {
2549
2543
  return SEARCH_INTENT_CODE[c.intent] | (c.howTo ? HOWTO_BIT : 0);
2550
2544
  }
2551
- function decodeIntent(code) {
2552
- return {
2553
- intent: INTENT_BY_CODE[code & 3] ?? "unknown",
2554
- howTo: (code & HOWTO_BIT) !== 0
2555
- };
2556
- }
2557
2545
  const INFORMATIONAL = /* @__PURE__ */ new Set([
2558
2546
  "how",
2559
2547
  "what",
@@ -7079,4 +7067,4 @@ function createInMemoryQuerySource(options) {
7079
7067
  };
7080
7068
  }
7081
7069
  const SQL_ANALYZERS = ALL_ANALYZERS.flatMap((d) => d.sql ? [d.sql] : []);
7082
- export { AnalyzerCapabilityError, DEFAULT_PRIORITY_SOURCES, ENGINE_QUERY_CAPABILITIES, INTENT_CLASSIFIER_VERSION, IN_MEMORY_DEFAULT_CAPABILITIES, NORMALIZER_VERSION, REPORTS, ROW_ANALYZERS, SEARCH_INTENT_CODE, SQL_ANALYZERS, analysisErrorToException, analysisErrors, analyzeBrandSegmentation, analyzeCannibalization, analyzeClustering, analyzeConcentration, analyzeDecay, analyzeInBrowser, analyzeKeywordConcentration, analyzeMovers, analyzeOpportunity, analyzePageConcentration, analyzeSeasonality, analyzeStrikingDistance, analyzeZeroClick, classifyQueryIntent, comparisonOf, createAnalyzerRegistry, createCompositeSource, createEngineQuerySource, createInMemoryQuerySource, createSorter, decodeIntent, defaultAnalyzerRegistry, defaultReportRegistry, defineAnalyzer, diffSitemapHealth, dryRunReport, encodeIntent, formatAnalysisError, formatReport, isAnalysisError, mergePriorityActions, normalizePriorityActions, normalizeQuery, num, padTimeseries, periodOf, queryRows, resolveWindow, rewriteForTableSource, runAnalyzerFromSource, runAnalyzerWithEngine, runReport, runReportResult, scorePriorityActions };
7070
+ export { AnalyzerCapabilityError, DEFAULT_PRIORITY_SOURCES, ENGINE_QUERY_CAPABILITIES, INTENT_CLASSIFIER_VERSION, IN_MEMORY_DEFAULT_CAPABILITIES, NORMALIZER_VERSION, REPORTS, ROW_ANALYZERS, SEARCH_INTENT_CODE, SQL_ANALYZERS, analysisErrorToException, analysisErrors, analyzeBrandSegmentation, analyzeCannibalization, analyzeClustering, analyzeConcentration, analyzeDecay, analyzeInBrowser, analyzeKeywordConcentration, analyzeMovers, analyzeOpportunity, analyzePageConcentration, analyzeSeasonality, analyzeStrikingDistance, analyzeZeroClick, classifyQueryIntent, comparisonOf, createAnalyzerRegistry, createCompositeSource, createEngineQuerySource, createInMemoryQuerySource, createSorter, defaultAnalyzerRegistry, defaultReportRegistry, defineAnalyzer, diffSitemapHealth, dryRunReport, encodeIntent, formatAnalysisError, formatReport, isAnalysisError, mergePriorityActions, normalizePriorityActions, normalizeQuery, num, padTimeseries, periodOf, queryRows, resolveWindow, runAnalyzerFromSource, runAnalyzerWithEngine, runReport, runReportResult, scorePriorityActions };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/analysis",
3
3
  "type": "module",
4
- "version": "0.40.1",
4
+ "version": "1.0.0",
5
5
  "description": "GSC analyzers — striking-distance, opportunity, movers, decay, brand, clustering, concentration, seasonality. Pure row-based + DuckDB-native.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -26,31 +26,16 @@
26
26
  "import": "./dist/index.mjs",
27
27
  "default": "./dist/index.mjs"
28
28
  },
29
- "./analyzer": {
30
- "types": "./dist/analyzer/index.d.mts",
31
- "import": "./dist/analyzer/index.mjs",
32
- "default": "./dist/analyzer/index.mjs"
33
- },
34
29
  "./registry": {
35
30
  "types": "./dist/default-registry.d.mts",
36
31
  "import": "./dist/default-registry.mjs",
37
32
  "default": "./dist/default-registry.mjs"
38
33
  },
39
- "./source": {
40
- "types": "./dist/source/index.d.mts",
41
- "import": "./dist/source/index.mjs",
42
- "default": "./dist/source/index.mjs"
43
- },
44
34
  "./errors": {
45
35
  "types": "./dist/errors.d.mts",
46
36
  "import": "./dist/errors.mjs",
47
37
  "default": "./dist/errors.mjs"
48
38
  },
49
- "./semantic": {
50
- "types": "./dist/semantic/index.d.mts",
51
- "import": "./dist/semantic/index.mjs",
52
- "default": "./dist/semantic/index.mjs"
53
- },
54
39
  "./report": {
55
40
  "types": "./dist/report/index.d.mts",
56
41
  "import": "./dist/report/index.mjs",
@@ -63,21 +48,13 @@
63
48
  "dist"
64
49
  ],
65
50
  "engines": {
66
- "node": ">=18"
67
- },
68
- "peerDependencies": {
69
- "@huggingface/transformers": "^4.2.0"
70
- },
71
- "peerDependenciesMeta": {
72
- "@huggingface/transformers": {
73
- "optional": true
74
- }
51
+ "node": ">=22"
75
52
  },
76
53
  "dependencies": {
77
54
  "pluralize": "^8.0.0",
78
- "@gscdump/engine": "0.40.1",
79
- "@gscdump/engine-gsc-api": "0.40.1",
80
- "gscdump": "0.40.1"
55
+ "@gscdump/engine": "^1.0.0",
56
+ "gscdump": "^1.0.0",
57
+ "@gscdump/engine-gsc-api": "^1.0.0"
81
58
  },
82
59
  "devDependencies": {
83
60
  "vitest": "^4.1.10"