@gscdump/analysis 0.9.2 → 0.11.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 +12 -8
- package/dist/analyzer/index.d.mts +1 -3
- package/dist/analyzer/index.mjs +88 -86
- package/dist/default-registry.d.mts +4 -4
- package/dist/default-registry.mjs +3230 -3232
- package/dist/index.d.mts +52 -77
- package/dist/index.mjs +2870 -3014
- package/dist/query/index.d.mts +17 -5
- package/dist/query/index.mjs +36 -36
- package/dist/report/index.d.mts +1 -1
- package/dist/report/index.mjs +1 -4
- package/dist/semantic/index.d.mts +1 -1
- package/dist/source/index.d.mts +10 -245
- package/dist/source/index.mjs +12 -1525
- package/package.json +4 -14
- package/dist/rollups.d.mts +0 -163
- package/dist/rollups.mjs +0 -346
- package/dist/routing/index.d.mts +0 -23
- package/dist/routing/index.mjs +0 -53
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { AnalysisParams, AnalysisParams as AnalysisParams$1, AnalysisResult, AnalysisResult as AnalysisResult$1, AnalysisTool, num } from "@gscdump/engine/analysis-types";
|
|
2
1
|
import * as _$_gscdump_engine_analyzer0 from "@gscdump/engine/analyzer";
|
|
3
|
-
import { Analyzer, Analyzer as Analyzer$1, AnalyzerCapabilityError, AnalyzerRegistry, AnalyzerRegistry as AnalyzerRegistry$1, AnalyzerRegistryInit, AnalyzerVariants,
|
|
4
|
-
import { AnalysisPeriod,
|
|
2
|
+
import { Analyzer, Analyzer as Analyzer$1, AnalyzerCapabilityError, AnalyzerRegistry, AnalyzerRegistry as AnalyzerRegistry$1, AnalyzerRegistryInit, AnalyzerVariants, DefineAnalyzerOptions, DefinedAnalyzer, Plan, ReduceContext, ReduceCtx, Reducer, RequiredCapability, RowQueriesPlan, SqlExtraQuery, SqlPlan, SqlPlanSpec, TypedRowQuery, createAnalyzerRegistry, defineAnalyzer, runAnalyzerFromSource } from "@gscdump/engine/analyzer";
|
|
3
|
+
import { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, padTimeseries, periodOf, resolveWindow, windowToComparisonPeriod, windowToPeriod } from "@gscdump/engine/period";
|
|
4
|
+
import { AnalysisParams, AnalysisParams as AnalysisParams$1, AnalysisResult, AnalysisResult as AnalysisResult$1, AnalysisTool, num } from "@gscdump/engine/analysis-types";
|
|
5
5
|
import { BuilderState } from "gscdump/query";
|
|
6
|
-
import { AttachedTableRunner, AttachedTableRunner as AnalyzerRunner, AttachedTableSourceOptions, AttachedTableSourceOptions as BrowserAnalyzeOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, TypedQuery, createEngineQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery } from "@gscdump/engine/source";
|
|
7
|
-
import { AnalysisQuerySource, AnalysisQuerySource as AnalysisQuerySource$1, ExecuteSqlOptions, FileSet, QueryRow, QueryRow as QueryRow$1, RowQuerySource, RowQuerySource as RowQuerySource$1, SourceCapabilities, SqlQuerySource, SqlQuerySource as SqlQuerySource$1, isSqlQuerySource } from "@gscdump/engine/resolver";
|
|
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, TypedQuery, createEngineQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery } from "@gscdump/engine/source";
|
|
8
7
|
import * as _$_gscdump_engine_report0 from "@gscdump/engine/report";
|
|
9
8
|
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";
|
|
10
9
|
import { PlannerCapabilities } from "gscdump/query/plan";
|
|
@@ -335,6 +334,40 @@ interface SeasonalityResult {
|
|
|
335
334
|
* variation. Re-exported from `@gscdump/analysis` for portable callers.
|
|
336
335
|
*/
|
|
337
336
|
declare function analyzeSeasonality(dates: DateRow[], options?: SeasonalityOptions): SeasonalityResult;
|
|
337
|
+
/**
|
|
338
|
+
* Unified `striking-distance` analyzer. Spike for the `defineAnalyzer`
|
|
339
|
+
* pattern: one file owns the SQL plan, the row plan, the typed `InputRow`
|
|
340
|
+
* contract, and the shared reducer.
|
|
341
|
+
*
|
|
342
|
+
* SQL and row plans both emit rows matching `StrikingDistanceInputRow`.
|
|
343
|
+
* Filtering (`minPosition`/`maxPosition`/`minImpressions`/`maxCtr`),
|
|
344
|
+
* derivation (`potentialClicks`), and sorting all live in the reducer, so
|
|
345
|
+
* drift between plans cannot silently change results. A SQL-side `LIMIT`
|
|
346
|
+
* push-down can be added later as an optional optimization, but the
|
|
347
|
+
* correctness contract stays with the reducer.
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* Row shape both plans produce. Field names match GSC's native columns so
|
|
351
|
+
* the row-source path needs no rename step; the SQL plan aliases `url → page`.
|
|
352
|
+
*/
|
|
353
|
+
interface StrikingDistanceInputRow {
|
|
354
|
+
query: string;
|
|
355
|
+
page: string | null;
|
|
356
|
+
clicks: number;
|
|
357
|
+
impressions: number;
|
|
358
|
+
ctr: number;
|
|
359
|
+
position: number;
|
|
360
|
+
}
|
|
361
|
+
interface StrikingDistanceResult {
|
|
362
|
+
keyword: string;
|
|
363
|
+
page: string | null;
|
|
364
|
+
clicks: number;
|
|
365
|
+
impressions: number;
|
|
366
|
+
ctr: number;
|
|
367
|
+
position: number;
|
|
368
|
+
/** Estimated clicks at ~15% CTR (the average for positions 1–3). */
|
|
369
|
+
potentialClicks: number;
|
|
370
|
+
}
|
|
338
371
|
/**
|
|
339
372
|
* `zero-click` — high impressions, low CTR, good ranking. SQL groups by
|
|
340
373
|
* (query, url) and applies HAVING/WHERE pushdown; row reducer dedupes to the
|
|
@@ -349,12 +382,12 @@ interface ZeroClickResult {
|
|
|
349
382
|
ctr: number;
|
|
350
383
|
position: number;
|
|
351
384
|
}
|
|
352
|
-
declare function analyzeInBrowser(runner: AttachedTableRunner, opts: AttachedTableSourceOptions, params: AnalysisParams$1): Promise<AnalysisResult$1>;
|
|
385
|
+
declare function analyzeInBrowser(runner: AttachedTableRunner, opts: AttachedTableSourceOptions, params: AnalysisParams$1, registry: AnalyzerRegistry$1): Promise<AnalysisResult$1>;
|
|
353
386
|
/**
|
|
354
|
-
* Default analyzer registry built from every in-tree analyzer
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
387
|
+
* Default analyzer registry built from every in-tree analyzer. Convenience
|
|
388
|
+
* for callers who don't care about bundle size; edge / browser consumers
|
|
389
|
+
* should compose their own narrower registry via `createAnalyzerRegistry`
|
|
390
|
+
* with the flat `ROW_ANALYZERS` / `SQL_ANALYZERS` arrays.
|
|
358
391
|
*/
|
|
359
392
|
declare const defaultAnalyzerRegistry: _$_gscdump_engine_analyzer0.AnalyzerRegistry;
|
|
360
393
|
/**
|
|
@@ -400,16 +433,16 @@ interface DryRunReportResult {
|
|
|
400
433
|
* Useful right now only as an "is this report wired up correctly?" check.
|
|
401
434
|
*/
|
|
402
435
|
declare function dryRunReport<P extends ReportParams = ReportParams>(report: DefinedReport$1<P>, ctx: ReportContext$1<P>): Promise<DryRunReportResult>;
|
|
403
|
-
|
|
436
|
+
interface SyncedRange {
|
|
437
|
+
oldestDateSynced: string | null;
|
|
438
|
+
newestDateSynced: string | null;
|
|
439
|
+
}
|
|
404
440
|
interface CompositeSourceOptions {
|
|
405
|
-
engine:
|
|
441
|
+
engine: AnalysisQuerySource$1;
|
|
406
442
|
live: AnalysisQuerySource$1;
|
|
407
|
-
site:
|
|
408
|
-
oldestDateSynced: string | null;
|
|
409
|
-
newestDateSynced: string | null;
|
|
410
|
-
};
|
|
443
|
+
site: SyncedRange;
|
|
411
444
|
}
|
|
412
|
-
declare function createCompositeSource(opts: CompositeSourceOptions):
|
|
445
|
+
declare function createCompositeSource(opts: CompositeSourceOptions): AnalysisQuerySource$1;
|
|
413
446
|
/**
|
|
414
447
|
* Permissive defaults: in-memory sources are usually test doubles, so they
|
|
415
448
|
* advertise every capability unless the test explicitly narrows them.
|
|
@@ -419,64 +452,6 @@ interface InMemoryQuerySourceOptions {
|
|
|
419
452
|
queryRows: (state: BuilderState) => Promise<QueryRow$1[]> | QueryRow$1[];
|
|
420
453
|
capabilities?: PlannerCapabilities;
|
|
421
454
|
}
|
|
422
|
-
declare function createInMemoryQuerySource(options: InMemoryQuerySourceOptions):
|
|
423
|
-
interface StrikingDistanceResult {
|
|
424
|
-
keyword: string;
|
|
425
|
-
page: string | null;
|
|
426
|
-
clicks: number;
|
|
427
|
-
impressions: number;
|
|
428
|
-
ctr: number;
|
|
429
|
-
position: number;
|
|
430
|
-
/** Estimated clicks at ~15% CTR (the average for positions 1–3). */
|
|
431
|
-
potentialClicks: number;
|
|
432
|
-
}
|
|
433
|
-
type StrikingDistanceSortMetric = 'clicks' | 'impressions' | 'ctr' | 'position' | 'potentialClicks';
|
|
434
|
-
interface StrikingDistanceOptions {
|
|
435
|
-
/** Minimum position (inclusive). Default: 4 */
|
|
436
|
-
minPosition?: number;
|
|
437
|
-
/** Maximum position (inclusive). Default: 20 */
|
|
438
|
-
maxPosition?: number;
|
|
439
|
-
/** Minimum impressions. Default: 100 */
|
|
440
|
-
minImpressions?: number;
|
|
441
|
-
/** Maximum CTR (queries with low CTR have more potential). Default: 0.05 (5%) */
|
|
442
|
-
maxCtr?: number;
|
|
443
|
-
/** Sort metric. Default: potentialClicks */
|
|
444
|
-
sortBy?: StrikingDistanceSortMetric;
|
|
445
|
-
/** Sort order. Default: desc */
|
|
446
|
-
sortOrder?: SortOrder;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Finds striking distance keywords - high impressions, low CTR, position 4-20.
|
|
450
|
-
* These are "quick wins" that could gain significant traffic with small ranking improvements.
|
|
451
|
-
*/
|
|
452
|
-
declare function analyzeStrikingDistance(keywords: KeywordRow[], options?: StrikingDistanceOptions): StrikingDistanceResult[];
|
|
453
|
-
type QueryDimension = 'keywords' | 'pages' | 'dates';
|
|
454
|
-
interface QueryOptions {
|
|
455
|
-
dimension?: QueryDimension;
|
|
456
|
-
limit?: number;
|
|
457
|
-
}
|
|
458
|
-
interface QueryResult {
|
|
459
|
-
keywords: KeywordRow[];
|
|
460
|
-
pages: PageRow[];
|
|
461
|
-
dates: DateRow[];
|
|
462
|
-
}
|
|
463
|
-
interface ComparisonQueryResult {
|
|
464
|
-
current: QueryResult;
|
|
465
|
-
previous: QueryResult;
|
|
466
|
-
}
|
|
467
|
-
interface OpportunityOptions {
|
|
468
|
-
minImpressions?: number;
|
|
469
|
-
}
|
|
470
|
-
declare function queryAnalyticsFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: QueryOptions): Promise<QueryResult>;
|
|
471
|
-
declare function queryComparisonFromSource(source: AnalysisQuerySource$1, periods: ComparisonPeriod$1, options?: QueryOptions): Promise<ComparisonQueryResult>;
|
|
472
|
-
declare function analyzeStrikingDistanceFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: StrikingDistanceOptions): Promise<StrikingDistanceResult[]>;
|
|
473
|
-
declare function analyzeOpportunityFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: OpportunityOptions): Promise<OpportunityResult[]>;
|
|
474
|
-
declare function analyzeBrandSegmentationFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options: BrandSegmentationOptions): Promise<BrandSegmentationResult>;
|
|
475
|
-
declare function analyzePageConcentrationFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: ConcentrationOptions): Promise<ConcentrationResult>;
|
|
476
|
-
declare function analyzeKeywordConcentrationFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: ConcentrationOptions): Promise<ConcentrationResult>;
|
|
477
|
-
declare function analyzeClusteringFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: ClusteringOptions): Promise<ClusteringResult>;
|
|
478
|
-
declare function analyzeSeasonalityFromSource(source: AnalysisQuerySource$1, period: AnalysisPeriod$1, options?: SeasonalityOptions): Promise<SeasonalityResult>;
|
|
479
|
-
declare function analyzeDecayFromSource(source: AnalysisQuerySource$1, periods: ComparisonPeriod$1, options?: DecayOptions): Promise<DecayResult[]>;
|
|
480
|
-
declare function analyzeMoversFromSource(source: AnalysisQuerySource$1, periods: ComparisonPeriod$1, options?: MoversOptions): Promise<MoversResult>;
|
|
455
|
+
declare function createInMemoryQuerySource(options: InMemoryQuerySourceOptions): AnalysisQuerySource$1;
|
|
481
456
|
declare const SQL_ANALYZERS: readonly Analyzer$1[];
|
|
482
|
-
export { type ActionPriorityResult, type ActionPrioritySourceState, type ActionPrioritySourceStatus, type ActionSource, type AnalysisParams, type AnalysisPeriod, type AnalysisQuerySource, type AnalysisResult, type AnalysisTool, type Analyzer, AnalyzerCapabilityError, type AnalyzerRegistry, type AnalyzerRegistryInit, type AnalyzerRunner, type AnalyzerVariants, type BaseMetrics, type BrandSegmentationOptions, type BrandSegmentationResult, type BrandSummary, type BrowserAnalyzeOptions, type CannibalizationCompetitor, type CannibalizationEvent, type CannibalizationOptions, type CannibalizationPage, type CannibalizationResult, type CannibalizationSortMetric, type
|
|
457
|
+
export { type ActionPriorityResult, type ActionPrioritySourceState, type ActionPrioritySourceStatus, type ActionSource, 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 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, IN_MEMORY_DEFAULT_CAPABILITIES, type InMemoryQuerySourceOptions, type KeywordCluster, type KeywordRow, type MonthlyData, type MoverData, type MoversInput, type MoversOptions, type MoversResult, type MoversSortMetric, type OpportunityResult, type PadTimeseriesOptions, type PageRow, type Plan, type PriorityAction, 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, SQL_ANALYZERS, type SeasonalityMetric, type SeasonalityOptions, type SeasonalityResult, type SortOrder, type SourceCapabilities, type SqlExtraQuery, type SqlPlan, type SqlPlanSpec, type StrikingDistanceInputRow, type StrikingDistanceResult, type TypedQuery, type TypedRowQuery, type WindowPreset, type ZeroClickResult, analyzeBrandSegmentation, analyzeCannibalization, analyzeClustering, analyzeConcentration, analyzeDecay, analyzeInBrowser, analyzeKeywordConcentration, analyzeMovers, analyzePageConcentration, analyzeSeasonality, comparisonOf, createAnalyzerRegistry, createCompositeSource, createEngineQuerySource, createInMemoryQuerySource, createSorter, defaultAnalyzerRegistry, defaultReportRegistry, defineAnalyzer, dryRunReport, formatReport, mergePriorityActions, normalizePriorityActions, normalizeQuery, num, padTimeseries, periodOf, queryComparisonRows, queryRows, resolveWindow, rewriteForTableSource, runAnalyzerFromSource, runAnalyzerWithEngine, runReport, scorePriorityActions, typedQuery, windowToComparisonPeriod, windowToPeriod };
|