@gscdump/engine 0.39.0 → 0.40.2

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
@@ -37,21 +37,20 @@ Optional peers (install only what your runtime needs):
37
37
  | `@gscdump/engine/scope` | Multi-tenant scope predicates. |
38
38
  | `@gscdump/engine/arrow` | Apache Arrow utilities for engine result conversion. |
39
39
  | `@gscdump/engine/node` | Node-only DuckDB handle. |
40
- | `@gscdump/engine/node-harness` | Node test harness for engine integration tests. |
41
40
  | `@gscdump/engine/filesystem` | Node-only `DataSource` + `ManifestStore` adapters. |
42
- | `@gscdump/engine/http` | Read-only HTTP `DataSource` (signed URLs, Range requests). |
43
41
  | `@gscdump/engine/hyparquet` | Pure-JS `ParquetCodec`. |
44
42
  | `@gscdump/engine/r2` | Cloudflare R2 `DataSource` (structurally typed against `R2Bucket`). |
45
43
  | `@gscdump/engine/r2-manifest` | R2-backed `ManifestStore` for hosted deployments. |
46
- | `@gscdump/engine/inspection-sqlite-node` | Node SQLite adapter for URL-inspection cache. |
47
- | `@gscdump/engine/inspection-sqlite-browser` | Browser (wa-sqlite) adapter for URL-inspection cache. |
44
+ | `@gscdump/engine/iceberg` | Edge-safe GSC Iceberg schema/catalog/append sink. |
45
+ | `@gscdump/engine/sink-node` | Node-only Iceberg overwrite/delete recovery writer. |
46
+ | `@gscdump/engine/source` | Query-source contracts and factories. |
48
47
 
49
48
  ## Stability
50
49
 
51
50
  | Surface | Stability |
52
51
  |---|---|
53
52
  | `createStorageEngine` and storage contracts (`StorageEngine`, `Row`, `WriteCtx`, ...) | Public |
54
- | Adapters (`/node`, `/filesystem`, `/http`, `/hyparquet`, `/r2`) | Public |
53
+ | Adapters (`/node`, `/filesystem`, `/hyparquet`, `/r2`, `/r2-manifest`) | Public |
55
54
  | Planner (`resolveToSQL`, `enumeratePartitions`) | Public |
56
55
  | Schema (`SCHEMAS`, `allTables`, ...) | Public |
57
56
  | Internals reached through `@gscdump/engine/<file>` paths not listed above | Private — may break between minors |
@@ -60,7 +59,6 @@ Optional peers (install only what your runtime needs):
60
59
 
61
60
  - [`gscdump`](../gscdump) — REST client + query builder (edge-safe peer dep).
62
61
  - [`@gscdump/analysis`](../analysis) — analyzers; consumes `StorageEngine` via `createEngine` factories.
63
- - [`@gscdump/engine-duckdb-node`](../engine-duckdb-node) — Node DuckDB analyzer adapter.
64
62
  - [`@gscdump/engine-duckdb-wasm`](../engine-duckdb-wasm) — DuckDB-WASM browser adapter.
65
63
  - [`@gscdump/engine-sqlite`](../engine-sqlite) — SQLite / D1 adapter.
66
64
  - [`@gscdump/cli`](../cli) — CLI wrapping engine + analysis.
@@ -103,8 +103,6 @@ declare const engineErrors: {
103
103
  readonly lockAcquireTimeout: (scope: string, timeoutMs: number) => EngineError;
104
104
  };
105
105
  declare function isEngineError(value: unknown): value is EngineError;
106
- /** The human-readable rendering of an `EngineError`, for logs and string sinks. */
107
- declare function formatEngineError(error: EngineError): string;
108
106
  /**
109
107
  * Re-raises an `EngineError` value as a generic `Error`, stashing the union under
110
108
  * `.engineError` for stack-walking. Used by the throwing wrappers over the
@@ -114,4 +112,4 @@ declare function formatEngineError(error: EngineError): string;
114
112
  * mapper so the class identity callers match on is preserved.
115
113
  */
116
114
  declare function engineErrorToException(error: EngineError): Error;
117
- export { EngineError, EngineErrorKind, engineErrorToException, engineErrors, formatEngineError, isEngineError };
115
+ export { EngineError, EngineErrorKind, engineErrorToException, engineErrors, isEngineError };
@@ -105,14 +105,5 @@ declare function createEngineQuerySource(options: EngineQuerySourceOptions): Ana
105
105
  declare function runAnalyzerWithEngine(deps: {
106
106
  engine: StorageEngine;
107
107
  }, ctx: TenantCtx, params: AnalysisParams, registry: AnalyzerRegistry): Promise<AnalysisResult>;
108
- interface TypedQuery<TRow> {
109
- state: BuilderState;
110
- readonly __row?: TRow;
111
- }
112
- declare function typedQuery<TRow>(state: BuilderState): TypedQuery<TRow>;
113
- declare function queryRows<TRow = QueryRow>(source: AnalysisQuerySource, query: BuilderState | TypedQuery<TRow>): Promise<TRow[]>;
114
- declare function queryComparisonRows<TRow = QueryRow>(source: AnalysisQuerySource, current: BuilderState | TypedQuery<TRow>, previous: BuilderState | TypedQuery<TRow>): Promise<{
115
- current: TRow[];
116
- previous: TRow[];
117
- }>;
118
- export { AttachedTableMissingError, AttachedTableRunner, AttachedTableSourceOptions, CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, TypedQuery, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
108
+ declare function queryRows<TRow = QueryRow>(source: AnalysisQuerySource, state: BuilderState): Promise<TRow[]>;
109
+ export { AttachedTableMissingError, AttachedTableRunner, AttachedTableSourceOptions, CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine };
@@ -30,9 +30,6 @@ declare function defaultStartDate(): string;
30
30
  declare function periodOf(params: AnalysisParams): AnalysisPeriod;
31
31
  declare function comparisonOf(params: AnalysisParams): ComparisonPeriod;
32
32
  declare function resolveWindow(opts: ResolveWindowOptions): ResolvedWindow;
33
- /** Convert a ResolvedWindow into the AnalysisPeriod / ComparisonPeriod shape. */
34
- declare function windowToPeriod(w: ResolvedWindow): AnalysisPeriod;
35
- declare function windowToComparisonPeriod(w: ResolvedWindow): ComparisonPeriod | undefined;
36
33
  interface PadTimeseriesOptions<T> {
37
34
  /** ISO date (YYYY-MM-DD), inclusive lower bound. */
38
35
  startDate: string;
@@ -54,4 +51,4 @@ type DateRowShape = Record<string, unknown> & {
54
51
  * once. Existing dates keep all their rows (grouped timeseries safe).
55
52
  */
56
53
  declare function padTimeseries<T extends DateRowShape = DateRowShape>(rows: readonly T[], options: PadTimeseriesOptions<T>): T[];
57
- export { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow, windowToComparisonPeriod, windowToPeriod };
54
+ export { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow };
@@ -14,12 +14,6 @@ declare const pgResolverAdapter: ResolverAdapter<PgTableKey>;
14
14
  * accidental adapter caching that would lock in a stale `{{FILES}}` set.
15
15
  */
16
16
  interface ResolverAdapterOptions {
17
- /**
18
- * Deprecated compatibility flag. Fact tables no longer carry
19
- * `query_canonical`; canonical reads derive from `query_dim`, or from a
20
- * canonical rollup relation when `queryCanonicalSource: 'column'` is set.
21
- */
22
- canonicalFallback?: boolean;
23
17
  /**
24
18
  * `queryDim` reads canonical from a joined query dimension. `column` is only
25
19
  * for derived canonical rollup relations whose primary relation already
@@ -455,7 +455,6 @@ function createParquetResolverAdapter(options = {}) {
455
455
  return createResolverAdapter({
456
456
  ...PG_BASE_CONFIG,
457
457
  tableLabel: "parquet-resolver-adapter",
458
- canonicalFallback: options.canonicalFallback ?? false,
459
458
  queryCanonicalSource: options.queryCanonicalSource ?? "queryDim",
460
459
  tableRef: (tk) => sql.raw(`read_parquet({{FILES}}, union_by_name = true) AS "${tk}"`),
461
460
  queryDimTableRef: () => sql.raw("read_parquet({{QUERY_DIM}}, union_by_name = true) AS \"query_dim\"")
@@ -468,7 +467,6 @@ function createIcebergResolverAdapter(options = {}) {
468
467
  includeSiteId: true,
469
468
  includeSearchType: true,
470
469
  tableLabel: "iceberg-resolver-adapter",
471
- canonicalFallback: options.canonicalFallback ?? false,
472
470
  queryCanonicalSource: options.queryCanonicalSource ?? "queryDim",
473
471
  tableRef: (tk) => sql.raw(`"${tk}"`),
474
472
  queryDimTableRef: () => sql.raw("\"query_dim\"")
@@ -481,7 +479,6 @@ function createR2SqlResolverAdapter(options = {}) {
481
479
  includeSiteId: true,
482
480
  includeSearchType: true,
483
481
  tableLabel: "r2-sql-resolver-adapter",
484
- canonicalFallback: options.canonicalFallback ?? false,
485
482
  queryCanonicalSource: options.queryCanonicalSource ?? "queryDim",
486
483
  capabilities: {
487
484
  regex: false,
@@ -2115,7 +2115,6 @@ declare const TABLE_METADATA: Record<TableName, {
2115
2115
  }>;
2116
2116
  declare const SCHEMAS: Record<TableName, TableSchema>;
2117
2117
  declare function currentSchemaVersion(table: TableName): number;
2118
- declare function schemaFor(table: TableName): TableSchema;
2119
2118
  /**
2120
2119
  * DATE column names for a table. The single schema-derived source every read
2121
2120
  * path uses to build the legacy-VARCHAR date canonicalization (see
@@ -2146,4 +2145,4 @@ declare function naturalKeyColumns(table: TableName): readonly string[];
2146
2145
  */
2147
2146
  declare function dedupeByNaturalKey(table: TableName, rows: readonly Row[]): Row[];
2148
2147
  declare function dimensionToColumn(dim: string, _table: TableName): string;
2149
- export { type ColumnDef$1 as ColumnDef, type ColumnType, DrizzleSchema, SCHEMAS, TABLE_METADATA, type TableSchema$1 as TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
2148
+ export { type ColumnDef$1 as ColumnDef, type ColumnType, DrizzleSchema, SCHEMAS, TABLE_METADATA, type TableSchema$1 as TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
@@ -219,9 +219,6 @@ const SCHEMAS = Object.fromEntries(METRIC_TABLES.map((t) => [t, tableSchemaFrom(
219
219
  function currentSchemaVersion(table) {
220
220
  return SCHEMAS[table].version;
221
221
  }
222
- function schemaFor(table) {
223
- return SCHEMAS[table];
224
- }
225
222
  function dateColumnsFor(table) {
226
223
  return SCHEMAS[table].columns.filter((c) => c.type === "DATE").map((c) => c.name);
227
224
  }
@@ -259,4 +256,4 @@ function dimensionToColumn(dim, _table) {
259
256
  if (dim === "queryCanonical") return "query_canonical";
260
257
  return dim;
261
258
  }
262
- export { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
259
+ export { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
@@ -137,21 +137,7 @@ async function runAnalyzerWithEngine(deps, ctx, params, registry) {
137
137
  searchType: params.searchType ?? "web"
138
138
  }), params, registry);
139
139
  }
140
- function typedQuery(state) {
141
- return { state };
142
- }
143
- function isTypedQuery(value) {
144
- return "state" in value;
145
- }
146
- async function queryRows(source, query) {
147
- const state = isTypedQuery(query) ? query.state : query;
140
+ async function queryRows(source, state) {
148
141
  return await source.queryRows(state);
149
142
  }
150
- async function queryComparisonRows(source, current, previous) {
151
- const [currentRows, previousRows] = await Promise.all([queryRows(source, current), queryRows(source, previous)]);
152
- return {
153
- current: currentRows,
154
- previous: previousRows
155
- };
156
- }
157
- export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
143
+ export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine };
package/dist/errors.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { EngineError, EngineErrorKind, engineErrorToException, engineErrors, formatEngineError, isEngineError } from "./_chunks/errors.mjs";
2
- export { EngineError, EngineErrorKind, engineErrorToException, engineErrors, formatEngineError, isEngineError };
1
+ import { EngineError, EngineErrorKind, engineErrorToException, engineErrors, isEngineError } from "./_chunks/errors.mjs";
2
+ export { EngineError, EngineErrorKind, engineErrorToException, engineErrors, isEngineError };
package/dist/errors.mjs CHANGED
@@ -190,13 +190,10 @@ const ENGINE_ERROR_KINDS = /* @__PURE__ */ new Set([
190
190
  function isEngineError(value) {
191
191
  return typeof value === "object" && value !== null && ENGINE_ERROR_KINDS.has(value.kind) && typeof value.message === "string";
192
192
  }
193
- function formatEngineError(error) {
194
- return error.message;
195
- }
196
193
  function engineErrorToException(error) {
197
194
  const exception = new Error(error.message);
198
195
  if ("cause" in error && error.cause !== void 0) exception.cause = error.cause;
199
196
  exception.engineError = error;
200
197
  return exception;
201
198
  }
202
- export { engineErrorToException, engineErrors, formatEngineError, isEngineError };
199
+ export { engineErrorToException, engineErrors, isEngineError };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CodecCtx, CompactionThresholds, CompactionTier, DataSource, EngineOptions, FileSetRef, GcCtx, Grain, ListLiveFilter, LockScope, ManifestEntry, ManifestPurgeResult, ManifestStore, ParquetCodec, PurgeFilter, PurgeResult, PurgeUrlsResult, QueryCtx, QueryExecuteOptions, QueryExecuteResult, QueryExecutor, QueryProfiler, QueryResult, QuerySpan, Row, RunSQLOptions, SearchType, StorageEngine, SyncState, SyncStateDetail, SyncStateFilter, SyncStateKind, SyncStateScope, TableName, TenantCtx, Watermark, WatermarkFilter, WatermarkScope, WriteCtx, WriteResult, enumeratePartitions } from "./_chunks/storage.mjs";
2
2
  import { DuckDBFactory, DuckDBHandle, canonicalEmptyParquetSchema, createDuckDBCodec, createDuckDBExecutor } from "./_chunks/duckdb.mjs";
3
3
  import { ColumnDef, ColumnType, DrizzleSchema, SCHEMAS, TABLE_METADATA, TableSchema, allTables, countries, currentSchemaVersion, dates, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, page_queries, pages, queries } from "./_chunks/schema.mjs";
4
- import { EngineError, EngineErrorKind, engineErrorToException, engineErrors, formatEngineError, isEngineError } from "./_chunks/errors.mjs";
4
+ import { EngineError, EngineErrorKind, engineErrorToException, engineErrors, isEngineError } from "./_chunks/errors.mjs";
5
5
  import { InspectionVerdict, SchedulePolicy, ScheduleState, fixedPolicy, inspectionPolicy, sitemapPolicy } from "./schedule.mjs";
6
6
  import { IcebergTableName, Sink, SinkCapabilities, SinkCloseResult, SinkOptions, SinkSlice, SinkWriteResult } from "./_chunks/sink.mjs";
7
7
  import { GscApiRow, IngestOptions, RowAccumulator, RowAccumulatorOptions, assembleDatesRow, createRowAccumulator, toPath, toSumPosition, transformGscRow } from "./ingest.mjs";
@@ -109,7 +109,6 @@ interface CreateIngestAccumulatorOptions extends RowAccumulatorOptions {
109
109
  ctx: IngestAccumulatorCtx;
110
110
  hooks: IngestAccumulatorHooks;
111
111
  }
112
- declare function createNoopIngestAccumulator(): IngestAccumulator;
113
112
  declare function createIngestAccumulator(opts: CreateIngestAccumulatorOptions): IngestAccumulator;
114
113
  declare function dayPartition(date: string): string;
115
114
  /**
@@ -209,4 +208,4 @@ declare const MIN_SYNC_IMPRESSIONS = 1;
209
208
  declare const MIN_COUNTRY_IMPRESSIONS = 10;
210
209
  declare const MAX_SITEMAP_URLS_PER_SITE = 50000;
211
210
  declare const MAX_TRACKED_URLS_PER_SITE = 200000;
212
- export { type CodecCtx, type ColumnDef, type ColumnType, type CompactionThresholds, type CompactionTier, type CreateIngestAccumulatorOptions, DEFAULT_SEARCH_TYPE, type DataSource, type DateWeight, type DrizzleSchema, type DuckDBFactory, type DuckDBHandle, ENGINE_QUERY_CAPABILITIES, EngineError, EngineErrorKind, type EngineOptions, FILES_PLACEHOLDER, type FileSetRef, type FinalizeOptions, type FinalizeResult, type GcCtx, type Grain, type GscApiRow, type InMemorySink, type IngestAccumulator, type IngestAccumulatorCtx, type IngestAccumulatorEngine, type IngestAccumulatorHooks, type IngestOptions, type InspectionVerdict, type ListLiveFilter, type LockScope, MAX_DAY_BYTES, MAX_GSC_PAGES_R2, MAX_SITEMAP_URLS_PER_SITE, MAX_TRACKED_URLS_PER_SITE, MIN_COUNTRY_IMPRESSIONS, MIN_SYNC_IMPRESSIONS, type ManifestEntry, type ManifestPurgeResult, type ManifestStore, type ParquetCodec, type PurgeFilter, type PurgeResult, type PurgeUrlsResult, type QueryCtx, type QueryExecuteOptions, type QueryExecuteResult, type QueryExecutor, type QueryProfiler, type QueryResult, type QuerySpan, ROW_LIMIT_R2, type ResolvedQuery, type Row, type RowAccumulator, type RowAccumulatorOptions, type RunSQLOptions, SCHEMAS, type SchedulePolicy, type ScheduleState, type SearchType, type Sink, type SinkCapabilities, type SinkCloseResult, type SinkOptions, type SinkSlice, type SinkWriteResult, type StorageEngine, type StoredRow, type SyncState, type SyncStateDetail, type SyncStateFilter, type SyncStateKind, type SyncStateScope, type SyncTableName, TABLES_BY_SEARCH_TYPE, TABLE_METADATA, TABLE_TIERS, TIER_PRIORITY, type TableName, type TableSchema, type TableTier, type TenantCtx, type TieredTableName, WEIGHT_PRIORITY, type Watermark, type WatermarkFilter, type WatermarkScope, type WriteCtx, type WriteResult, allTables, assembleDatesRow, bindLiterals, canonicalEmptyParquetSchema, coerceRow, coerceRows, collectSpans, countries, createDuckDBCodec, createDuckDBExecutor, createIcebergResolverAdapter, createInMemorySink, createIngestAccumulator, createNoopIngestAccumulator, createParquetResolverAdapter, createQueryProfiler, createR2SqlResolverAdapter, createRowAccumulator, createSqlQuerySource, createStorageEngine, currentSchemaVersion, dates, dayPartition, dimensionToColumn, drizzleSchema, engineErrorToException, engineErrors, enumeratePartitions, fixedPolicy, formatEngineError, formatLiteral, getDateWeight, getTableTier, getTablesForTier, hourPartition, hourly_pages, inferLegacyTier, inferSearchType, inferTable, inspectionPolicy, isEngineError, objectKey, page_queries, pages, parseEnabledSearchTypes, pgResolverAdapter, queries, rebuildDailyFromHourly, resolveParquetSQL, sitemapPolicy, substituteNamedFiles, toPath, toSumPosition, transformGscRow, validateEnabledSearchTypes, validateEnabledSearchTypesResult };
211
+ export { type CodecCtx, type ColumnDef, type ColumnType, type CompactionThresholds, type CompactionTier, type CreateIngestAccumulatorOptions, DEFAULT_SEARCH_TYPE, type DataSource, type DateWeight, type DrizzleSchema, type DuckDBFactory, type DuckDBHandle, ENGINE_QUERY_CAPABILITIES, EngineError, EngineErrorKind, type EngineOptions, FILES_PLACEHOLDER, type FileSetRef, type FinalizeOptions, type FinalizeResult, type GcCtx, type Grain, type GscApiRow, type InMemorySink, type IngestAccumulator, type IngestAccumulatorCtx, type IngestAccumulatorEngine, type IngestAccumulatorHooks, type IngestOptions, type InspectionVerdict, type ListLiveFilter, type LockScope, MAX_DAY_BYTES, MAX_GSC_PAGES_R2, MAX_SITEMAP_URLS_PER_SITE, MAX_TRACKED_URLS_PER_SITE, MIN_COUNTRY_IMPRESSIONS, MIN_SYNC_IMPRESSIONS, type ManifestEntry, type ManifestPurgeResult, type ManifestStore, type ParquetCodec, type PurgeFilter, type PurgeResult, type PurgeUrlsResult, type QueryCtx, type QueryExecuteOptions, type QueryExecuteResult, type QueryExecutor, type QueryProfiler, type QueryResult, type QuerySpan, ROW_LIMIT_R2, type ResolvedQuery, type Row, type RowAccumulator, type RowAccumulatorOptions, type RunSQLOptions, SCHEMAS, type SchedulePolicy, type ScheduleState, type SearchType, type Sink, type SinkCapabilities, type SinkCloseResult, type SinkOptions, type SinkSlice, type SinkWriteResult, type StorageEngine, type StoredRow, type SyncState, type SyncStateDetail, type SyncStateFilter, type SyncStateKind, type SyncStateScope, type SyncTableName, TABLES_BY_SEARCH_TYPE, TABLE_METADATA, TABLE_TIERS, TIER_PRIORITY, type TableName, type TableSchema, type TableTier, type TenantCtx, type TieredTableName, WEIGHT_PRIORITY, type Watermark, type WatermarkFilter, type WatermarkScope, type WriteCtx, type WriteResult, allTables, assembleDatesRow, bindLiterals, canonicalEmptyParquetSchema, coerceRow, coerceRows, collectSpans, countries, createDuckDBCodec, createDuckDBExecutor, createIcebergResolverAdapter, createInMemorySink, createIngestAccumulator, createParquetResolverAdapter, createQueryProfiler, createR2SqlResolverAdapter, createRowAccumulator, createSqlQuerySource, createStorageEngine, currentSchemaVersion, dates, dayPartition, dimensionToColumn, drizzleSchema, engineErrorToException, engineErrors, enumeratePartitions, fixedPolicy, formatLiteral, getDateWeight, getTableTier, getTablesForTier, hourPartition, hourly_pages, inferLegacyTier, inferSearchType, inferTable, inspectionPolicy, isEngineError, objectKey, page_queries, pages, parseEnabledSearchTypes, pgResolverAdapter, queries, rebuildDailyFromHourly, resolveParquetSQL, sitemapPolicy, substituteNamedFiles, toPath, toSumPosition, transformGscRow, validateEnabledSearchTypes, validateEnabledSearchTypesResult };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { DEFAULT_SEARCH_TYPE, dayPartition, hourPartition, inferLegacyTier, infe
3
3
  import { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dates, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, page_queries, pages, queries } from "./_chunks/schema.mjs";
4
4
  import { enumeratePartitions } from "./_chunks/compaction.mjs";
5
5
  import { FILES_PLACEHOLDER, resolveParquetSQL, substituteNamedFiles } from "./_chunks/parquet-plan.mjs";
6
- import { engineErrorToException, engineErrors, formatEngineError, isEngineError } from "./errors.mjs";
6
+ import { engineErrorToException, engineErrors, isEngineError } from "./errors.mjs";
7
7
  import { bindLiterals, formatLiteral } from "./sql-bind.mjs";
8
8
  import { MAX_DAY_BYTES, canonicalEmptyParquetSchema, createDuckDBCodec, createDuckDBExecutor, createStorageEngine } from "./_chunks/engine.mjs";
9
9
  import { assembleDatesRow, createRowAccumulator, toPath, toSumPosition, transformGscRow } from "./ingest.mjs";
@@ -13,12 +13,6 @@ import { rebuildDailyFromHourly } from "./rollups.mjs";
13
13
  import { fixedPolicy, inspectionPolicy, sitemapPolicy } from "./schedule.mjs";
14
14
  import { ENGINE_QUERY_CAPABILITIES, createSqlQuerySource } from "./_chunks/source.mjs";
15
15
  import { err, ok, unwrapResult } from "gscdump/result";
16
- const NOOP_RESULT = {
17
- flushed: 0,
18
- recovered: 0,
19
- failed: 0,
20
- rowsWritten: 0
21
- };
22
16
  function scopeOf(ctx, table, date) {
23
17
  return {
24
18
  userId: String(ctx.userId),
@@ -28,16 +22,6 @@ function scopeOf(ctx, table, date) {
28
22
  ...ctx.searchType !== void 0 ? { searchType: ctx.searchType } : {}
29
23
  };
30
24
  }
31
- function createNoopIngestAccumulator() {
32
- return {
33
- push() {
34
- return false;
35
- },
36
- async finalize() {
37
- return NOOP_RESULT;
38
- }
39
- };
40
- }
41
25
  function createIngestAccumulator(opts) {
42
26
  const { engine, ctx, hooks, ...accOpts } = opts;
43
27
  const acc = createRowAccumulator(accOpts);
@@ -331,4 +315,4 @@ const MIN_SYNC_IMPRESSIONS = 1;
331
315
  const MIN_COUNTRY_IMPRESSIONS = 10;
332
316
  const MAX_SITEMAP_URLS_PER_SITE = 5e4;
333
317
  const MAX_TRACKED_URLS_PER_SITE = 2e5;
334
- export { DEFAULT_SEARCH_TYPE, ENGINE_QUERY_CAPABILITIES, FILES_PLACEHOLDER, MAX_DAY_BYTES, MAX_GSC_PAGES_R2, MAX_SITEMAP_URLS_PER_SITE, MAX_TRACKED_URLS_PER_SITE, MIN_COUNTRY_IMPRESSIONS, MIN_SYNC_IMPRESSIONS, ROW_LIMIT_R2, SCHEMAS, TABLES_BY_SEARCH_TYPE, TABLE_METADATA, TABLE_TIERS, TIER_PRIORITY, WEIGHT_PRIORITY, allTables, assembleDatesRow, bindLiterals, canonicalEmptyParquetSchema, coerceRow, coerceRows, collectSpans, countries, createDuckDBCodec, createDuckDBExecutor, createIcebergResolverAdapter, createInMemorySink, createIngestAccumulator, createNoopIngestAccumulator, createParquetResolverAdapter, createQueryProfiler, createR2SqlResolverAdapter, createRowAccumulator, createSqlQuerySource, createStorageEngine, currentSchemaVersion, dates, dayPartition, dimensionToColumn, drizzleSchema, engineErrorToException, engineErrors, enumeratePartitions, fixedPolicy, formatEngineError, formatLiteral, getDateWeight, getTableTier, getTablesForTier, hourPartition, hourly_pages, inferLegacyTier, inferSearchType, inferTable, inspectionPolicy, isEngineError, objectKey, page_queries, pages, parseEnabledSearchTypes, pgResolverAdapter, queries, rebuildDailyFromHourly, resolveParquetSQL, sitemapPolicy, substituteNamedFiles, toPath, toSumPosition, transformGscRow, validateEnabledSearchTypes, validateEnabledSearchTypesResult };
318
+ export { DEFAULT_SEARCH_TYPE, ENGINE_QUERY_CAPABILITIES, FILES_PLACEHOLDER, MAX_DAY_BYTES, MAX_GSC_PAGES_R2, MAX_SITEMAP_URLS_PER_SITE, MAX_TRACKED_URLS_PER_SITE, MIN_COUNTRY_IMPRESSIONS, MIN_SYNC_IMPRESSIONS, ROW_LIMIT_R2, SCHEMAS, TABLES_BY_SEARCH_TYPE, TABLE_METADATA, TABLE_TIERS, TIER_PRIORITY, WEIGHT_PRIORITY, allTables, assembleDatesRow, bindLiterals, canonicalEmptyParquetSchema, coerceRow, coerceRows, collectSpans, countries, createDuckDBCodec, createDuckDBExecutor, createIcebergResolverAdapter, createInMemorySink, createIngestAccumulator, createParquetResolverAdapter, createQueryProfiler, createR2SqlResolverAdapter, createRowAccumulator, createSqlQuerySource, createStorageEngine, currentSchemaVersion, dates, dayPartition, dimensionToColumn, drizzleSchema, engineErrorToException, engineErrors, enumeratePartitions, fixedPolicy, formatLiteral, getDateWeight, getTableTier, getTablesForTier, hourPartition, hourly_pages, inferLegacyTier, inferSearchType, inferTable, inspectionPolicy, isEngineError, objectKey, page_queries, pages, parseEnabledSearchTypes, pgResolverAdapter, queries, rebuildDailyFromHourly, resolveParquetSQL, sitemapPolicy, substituteNamedFiles, toPath, toSumPosition, transformGscRow, validateEnabledSearchTypes, validateEnabledSearchTypesResult };
package/dist/ingest.d.mts CHANGED
@@ -16,8 +16,6 @@ interface GscApiRow {
16
16
  position: number;
17
17
  }
18
18
  interface IngestOptions {
19
- /** @deprecated Canonical query data is built through query_dim, not fact rows. */
20
- normalizeQuery?: (query: string) => string | null | undefined;
21
19
  /** Date for one-day `searchAppearance` total queries, whose keys omit date. */
22
20
  date?: string;
23
21
  /** Search appearance filter used for contextual second-step rows. */
@@ -1,2 +1,2 @@
1
- import { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow, windowToComparisonPeriod, windowToPeriod } from "../_chunks/index2.mjs";
2
- export { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow, windowToComparisonPeriod, windowToPeriod };
1
+ import { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow } from "../_chunks/index2.mjs";
2
+ export { AnalysisPeriod, ComparisonMode, ComparisonPeriod, PadTimeseriesOptions, ResolveWindowOptions, ResolvedWindow, WindowPreset, comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow };
@@ -96,25 +96,6 @@ function resolveWindow(opts) {
96
96
  }
97
97
  return result;
98
98
  }
99
- function windowToPeriod(w) {
100
- return {
101
- startDate: w.start,
102
- endDate: w.end
103
- };
104
- }
105
- function windowToComparisonPeriod(w) {
106
- if (!w.comparison) return void 0;
107
- return {
108
- current: {
109
- startDate: w.start,
110
- endDate: w.end
111
- },
112
- previous: {
113
- startDate: w.comparison.start,
114
- endDate: w.comparison.end
115
- }
116
- };
117
- }
118
99
  const DEFAULT_FILL = {
119
100
  clicks: 0,
120
101
  impressions: 0,
@@ -147,4 +128,4 @@ function padTimeseries(rows, options) {
147
128
  }
148
129
  return result;
149
130
  }
150
- export { comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow, windowToComparisonPeriod, windowToPeriod };
131
+ export { comparisonOf, defaultEndDate, defaultStartDate, padTimeseries, periodOf, resolveWindow };
@@ -48,8 +48,6 @@ interface SqlFragmentsConfig<TableKey extends string> {
48
48
  queryDimTableRef?: () => SQL;
49
49
  /** When true, also joins query_dim on site_id (SQLite/D1 dimension table). */
50
50
  queryDimSiteScoped?: boolean;
51
- /** @deprecated Canonical reads now derive from query_dim or canonical rollups. */
52
- canonicalFallback?: boolean;
53
51
  }
54
52
  interface SqlFragments<TableKey extends string> {
55
53
  METRIC_NAMES: Metric[];
@@ -175,11 +173,6 @@ interface ResolveExtraFn {
175
173
  interface RunOptimizedQueryOptions {
176
174
  /** Overlay tried per extra before the live SQL; absent → today's live path. */
177
175
  resolveExtra?: ResolveExtraFn;
178
- /**
179
- * Deprecated compatibility flag. Canonical reads now derive from query_dim,
180
- * not a nullable fact-table `query_canonical` column.
181
- */
182
- canonicalFallback?: boolean;
183
176
  /**
184
177
  * Versioned query dimension backing canonical reads over fact rows. Required
185
178
  * whenever a query groups or filters by `queryCanonical`; a canonical rollup
@@ -218,11 +211,6 @@ interface RunOptimizedQueryOptions {
218
211
  coversThrough?: string;
219
212
  queryDim?: CanonicalQueryDimSource;
220
213
  };
221
- /**
222
- * @deprecated Canonical-source misses are recorded on `source.fallbacks`;
223
- * raw daily fallback is controlled by `primarySourceFallback: 'raw'`.
224
- */
225
- canonicalSourceFallback?: 'raw';
226
214
  /** Optional version gates for the query dimension backing `canonicalSource`. */
227
215
  canonicalRequirements?: {
228
216
  normalizerVersion?: number;
package/dist/schema.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { ColumnDef, ColumnType, DrizzleSchema, SCHEMAS, TABLE_METADATA, TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries } from "./_chunks/schema.mjs";
2
- export { type ColumnDef, type ColumnType, type DrizzleSchema, SCHEMAS, TABLE_METADATA, type TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
1
+ import { ColumnDef, ColumnType, DrizzleSchema, SCHEMAS, TABLE_METADATA, TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries } from "./_chunks/schema.mjs";
2
+ export { type ColumnDef, type ColumnType, type DrizzleSchema, SCHEMAS, TABLE_METADATA, type TableSchema, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
package/dist/schema.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries } from "./_chunks/schema.mjs";
2
- export { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, schemaFor, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
1
+ import { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries } from "./_chunks/schema.mjs";
2
+ export { SCHEMAS, TABLE_METADATA, allTables, countries, currentSchemaVersion, dateColumnsFor, dates, dedupeByNaturalKey, dimensionToColumn, drizzleSchema, hourly_pages, inferTable, naturalKeyColumns, page_queries, pages, queries, search_appearance, search_appearance_page_queries, search_appearance_pages, search_appearance_queries };
@@ -17,9 +17,8 @@ interface OverwriteWriterCatalogConfig {
17
17
  catalogToken?: string;
18
18
  }
19
19
  /**
20
- * The JSON job wire-format shared with `scripts/iceberg-writer.py` — identical
21
- * to the shape `LocalIcebergSink` already emits, so one PyIceberg script backs
22
- * both the local sink and this writer. `op` is always `overwrite` here.
20
+ * The JSON job wire-format shared with `scripts/iceberg-writer.py`.
21
+ * `op` is always `overwrite` here.
23
22
  */
24
23
  interface OverwriteJob {
25
24
  op: 'overwrite';
@@ -1,3 +1,3 @@
1
1
  import { AnalysisQuerySource, AnalysisSourceKind, ExecuteSqlOptions, FileSet, QueryRow, SourceCapabilities } from "../_chunks/registry.mjs";
2
- import { AttachedTableMissingError, AttachedTableRunner, AttachedTableSourceOptions, CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, TypedQuery, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery } from "../_chunks/index.mjs";
3
- export { type AnalysisQuerySource, type AnalysisSourceKind, AttachedTableMissingError, type AttachedTableRunner, type AttachedTableSourceOptions, type CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, type ExecuteSqlOptions, type FileSet, type QueryRow, type SourceCapabilities, TypedQuery, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
2
+ import { AttachedTableMissingError, AttachedTableRunner, AttachedTableSourceOptions, CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine } from "../_chunks/index.mjs";
3
+ export { type AnalysisQuerySource, type AnalysisSourceKind, AttachedTableMissingError, type AttachedTableRunner, type AttachedTableSourceOptions, type CreateSqlQuerySourceOptions, ENGINE_QUERY_CAPABILITIES, EngineQuerySourceOptions, type ExecuteSqlOptions, type FileSet, type QueryRow, type SourceCapabilities, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine };
@@ -1,2 +1,2 @@
1
- import { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery } from "../_chunks/source.mjs";
2
- export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
1
+ import { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine } from "../_chunks/source.mjs";
2
+ export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryRows, rewriteForTableSource, runAnalyzerWithEngine };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/engine",
3
3
  "type": "module",
4
- "version": "0.39.0",
4
+ "version": "0.40.2",
5
5
  "description": "Append-only Parquet/DuckDB storage engine + planner + adapters for the gscdump pipeline. Node + edge runtimes; opt-in heavy peers.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -181,9 +181,9 @@
181
181
  "dependencies": {
182
182
  "drizzle-orm": "1.0.0-rc.3",
183
183
  "proper-lockfile": "^4.1.2",
184
- "@gscdump/contracts": "0.39.0",
185
- "@gscdump/lakehouse": "0.39.0",
186
- "gscdump": "0.39.0"
184
+ "@gscdump/contracts": "0.40.2",
185
+ "@gscdump/lakehouse": "0.40.2",
186
+ "gscdump": "0.40.2"
187
187
  },
188
188
  "devDependencies": {
189
189
  "@duckdb/duckdb-wasm": "^1.32.0",