semanticdb-v2 2.0.0-alpha.10 → 2.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +39 -15
  2. package/dist/cache/types.d.ts +2 -1
  3. package/dist/compiler/compile-computation.d.ts +6 -0
  4. package/dist/compiler/compile-source.d.ts +5 -0
  5. package/dist/executor/component-properties.d.ts +22 -0
  6. package/dist/executor/components.d.ts +7 -3
  7. package/dist/executor/execute-query.d.ts +1 -0
  8. package/dist/executor/execute.d.ts +1 -1
  9. package/dist/executor/federated-execution.d.ts +2 -1
  10. package/dist/executor/fetch-entities.d.ts +2 -2
  11. package/dist/executor/index.d.ts +1 -1
  12. package/dist/executor/merge-by-id.d.ts +3 -0
  13. package/dist/executor/partition.d.ts +18 -0
  14. package/dist/executor/random-data.d.ts +5 -0
  15. package/dist/executor/result-hydrator/entity-fetch-conditions.d.ts +4 -0
  16. package/dist/executor/result-hydrator/index.d.ts +1 -0
  17. package/dist/executor/result-hydrator/types.d.ts +7 -0
  18. package/dist/executor/runtime-execution.d.ts +6 -0
  19. package/dist/executor/sample.d.ts +6 -0
  20. package/dist/executor/types.d.ts +23 -13
  21. package/dist/file-import/index.d.ts +2 -0
  22. package/dist/file-import/read-file.d.ts +2 -0
  23. package/dist/file-import/types.d.ts +31 -0
  24. package/dist/index.d.ts +11 -6
  25. package/dist/logicform/dimensions.d.ts +16 -0
  26. package/dist/logicform/index.d.ts +2 -0
  27. package/dist/logicform-types.d.ts +22 -2
  28. package/dist/normalizer/core.d.ts +8 -1
  29. package/dist/normalizer/index.d.ts +1 -0
  30. package/dist/normalizer/main-time-range.d.ts +9 -0
  31. package/dist/normalizer/public-logicform.d.ts +14 -0
  32. package/dist/normalizer/query.d.ts +3 -2
  33. package/dist/normalizer/random-data.d.ts +2 -0
  34. package/dist/operators/builtins/period-name.d.ts +3 -0
  35. package/dist/operators/builtins/time-range.d.ts +2 -2
  36. package/dist/operators/formula-text.d.ts +10 -0
  37. package/dist/operators/index.d.ts +2 -1
  38. package/dist/operators/registry.d.ts +8 -1
  39. package/dist/operators/types.d.ts +115 -25
  40. package/dist/permissions/index.d.ts +2 -1
  41. package/dist/permissions/metric-permissions.d.ts +9 -0
  42. package/dist/permissions/permissions.d.ts +4 -3
  43. package/dist/permissions/types.d.ts +5 -0
  44. package/dist/physical/connection.d.ts +4 -0
  45. package/dist/physical/db-connector.d.ts +10 -0
  46. package/dist/physical/duckdb-coordinator-provider.d.ts +3 -23
  47. package/dist/physical/duckdb-dataset.d.ts +23 -0
  48. package/dist/physical/duckdb-provider.d.ts +26 -0
  49. package/dist/physical/duckdb-sql.d.ts +33 -0
  50. package/dist/physical/import-types.d.ts +23 -0
  51. package/dist/physical/import-validation.d.ts +14 -0
  52. package/dist/physical/index.d.ts +4 -0
  53. package/dist/physical/postgresql-provider.d.ts +1 -0
  54. package/dist/physical/provider.d.ts +4 -0
  55. package/dist/planner/build-lineage.d.ts +1 -1
  56. package/dist/planner/create-logical-plan.d.ts +15 -2
  57. package/dist/planner/index.d.ts +3 -2
  58. package/dist/planner/mapping-granularity.d.ts +1 -1
  59. package/dist/planner/materialize-computations.d.ts +3 -0
  60. package/dist/planner/select-schema-mapping.d.ts +16 -1
  61. package/dist/planner/types.d.ts +52 -9
  62. package/dist/planner/udf-inputs.d.ts +6 -0
  63. package/dist/plugins/types.d.ts +4 -2
  64. package/dist/schema/index.d.ts +1 -0
  65. package/dist/schema/relation-keys.d.ts +11 -0
  66. package/dist/schema-mappings/computations.d.ts +3 -0
  67. package/dist/schema-mappings/index.d.ts +5 -1
  68. package/dist/schema-mappings/registry.d.ts +1 -0
  69. package/dist/schema-mappings/source.d.ts +11 -0
  70. package/dist/schema-mappings/sql-inputs.d.ts +7 -0
  71. package/dist/schema-mappings/supported-dimensions.d.ts +10 -0
  72. package/dist/schema-mappings/types.d.ts +107 -15
  73. package/dist/schema-mappings/yiask.d.ts +6 -18
  74. package/dist/semantic-types/index.d.ts +1 -1
  75. package/dist/semantic-types/types.d.ts +50 -2
  76. package/dist/semanticdb.esm.js +6 -5
  77. package/dist/semanticdb.js +6 -5
  78. package/dist/utils/format-date.d.ts +3 -0
  79. package/package.json +5 -3
  80. package/dist/executor/evaluate.d.ts +0 -4
package/README.md CHANGED
@@ -22,12 +22,13 @@ providers across executions; call `await Logicform.close()` during application s
22
22
 
23
23
  ```ts
24
24
  import { Logicform } from 'semanticdb-v2';
25
+ import type { SchemaMappingDefinition } from 'semanticdb-v2';
25
26
 
26
- const schemaMappings = [
27
+ const schemaMappings: SchemaMappingDefinition[] = [
27
28
  {
28
29
  schemaId: 'sales',
29
30
  connectionId: 'analytics',
30
- source: 'analytics.sales_detail',
31
+ source: { kind: 'table', table: 'analytics.sales_detail' },
31
32
  mappings: [],
32
33
  freshness: { mode: 'ttl', ttlSeconds: 300 },
33
34
  },
@@ -68,6 +69,10 @@ A successful response always includes `total`, the number of result rows before
68
69
  `limit`/`page` pagination. For grouped LogicForms this is the number of groups after `having` and
69
70
  `limitBy`. Paginated physical queries include a separate `sqls` entry with `type: 'total'` for the
70
71
  count query; unpaginated and executor-merged results derive the value without another SQL query.
72
+ For entity sampling, `total` counts distinct eligible entities before sampling. See
73
+ [Entity sampling](docs/entity-sampling.md) for boolean `sample`, top-level `limit`, and sorting rules.
74
+ See [Demo data perturbation](docs/random-data.md) for `randomData`, which applies random multipliers
75
+ to final numeric output values while preserving group keys and identities.
71
76
 
72
77
  The v2 LogicForm contract requires `version` on executable LogicForms, including LogicForm objects
73
78
  used as subqueries, and accepts semantic versions greater than or equal to `2.0`. At the public
@@ -280,7 +285,7 @@ commands that have already reached the database.
280
285
 
281
286
  ### Permissions
282
287
 
283
- Pass table, row, and column permissions together through `ExecuteOptions.permissions`:
288
+ Pass table, row, column, and custom metric permissions through `ExecuteOptions.permissions`:
284
289
 
285
290
  ```ts
286
291
  import type { Permissions } from 'semanticdb-v2';
@@ -326,6 +331,15 @@ filters, grouping, operator inputs, and relation paths. A row policy may still u
326
331
  column as an internal filter. If an ID is not whitelisted, SemanticDB generates the executor-owned
327
332
  result-row `_id` instead of exposing the physical ID as that identity.
328
333
 
334
+ Custom metrics have a separate Schema catalog (`metrics: ['均价']`) and user policy
335
+ (`metricPermissions: { whitelist: ['均价'] }`). Omission preserves unrestricted metric access;
336
+ `[]` denies all custom metrics and `'*'` permits the current Schema's catalog. Metric names never
337
+ belong in `columnPermissions`. Compound metrics require permission for their internal custom
338
+ metrics and underlying properties; generated child queries retain table and row checks.
339
+ Permissions are validated only for Schemas reached by the execution.
340
+ See [the interface and YiAsk migration example](docs/metric-permissions.md) for dependency
341
+ contracts, compatibility behavior, and complete configuration examples.
342
+
329
343
  ### Component operators
330
344
 
331
345
  Composite metrics are regular `OperatorDefinition` values with `kind: 'component'`. Their
@@ -341,7 +355,14 @@ names shared by both sides unless an exceptional custom operator explicitly supp
341
355
 
342
356
  See [Register an operator](docs/register-operator.md) for the component contract.
343
357
 
344
- The root entry point accepts a `connections` array of `DatabaseConnection` items. Every item has a unique `id`; set `kind` to `mysql`,
358
+ DuckDB accepts customer `.duckdb` files (`path`, read-only by default) and managed
359
+ shared upload datasets (`directory`). `DBConnector.importFile()` supports `.xlsx`
360
+ and CSV, fixed column definitions, idempotent batches and batch replacement.
361
+ CSV automatically accepts UTF-8/BOM-marked Unicode; specify `gbk` or `gb18030` for
362
+ legacy Chinese files. See [DuckDB and file imports](docs/file-import.md) for PM2
363
+ sharing, configuration, encoding rules and operational limits.
364
+
365
+ The root entry point accepts a `connections` array of `DatabaseConnection` items. Every item has a unique `id`; set `kind` to `duckdb`, `mysql`,
345
366
  `doris`, `starrocks`, `gbase`, `maxcompute`, `clickhouse`, `databricks`, `dameng`, `snowflake`,
346
367
  `sqlserver`, `oracle`, or `postgresql`, then add that driver's
347
368
  native connection fields directly on the item. Each Schema Mapping selects an item through
@@ -496,6 +517,13 @@ driver's ordinal parameter binding and are not interpolated into executable SQL.
496
517
  required: PAT and OAuth fields are mutually exclusive, and authentication is never inferred from
497
518
  the presence of credentials.
498
519
 
520
+ To check a real connection, fill in the Databricks fields in `.env` (see `.env.example`) and run
521
+ `npm run test:databricks`. Set `DATABRICKS_AUTH_TYPE=databricks-oauth` with
522
+ `DATABRICKS_CLIENT_ID` and `DATABRICKS_CLIENT_SECRET`, or use `access-token` with
523
+ `DATABRICKS_TOKEN`. The command opens a session through `DatabricksProvider`, applies `TZ` with
524
+ `SET TIME ZONE` when present, and prints the current session time zone, catalog, and schema.
525
+ The `.env` file is ignored by Git.
526
+
499
527
  ### Dameng connection
500
528
 
501
529
  Dameng uses the official `dmdb` pool and the `dameng` connection kind:
@@ -584,6 +612,13 @@ trusted model metadata, must match the active provider dialect, and cannot conta
584
612
  comments, or parameter placeholders. Property UDFs do not support the legacy `function` or
585
613
  `dependencies` fields; application-side computed values belong outside this query SDK.
586
614
 
615
+ ### Schema Mapping and data weaving
616
+
617
+ One logical Schema can use multiple physical sources, conditional measure columns,
618
+ time partitions, and same-connection feature tables. See
619
+ [Schema Mapping and data weaving](docs/data-weaving.md) for the current design and
620
+ links to detailed configuration guides.
621
+
587
622
  ### Query cache
588
623
 
589
624
  All compiled provider queries, including the internal time-watermark query, can share one
@@ -592,17 +627,6 @@ cache identity includes namespace, connection id, provider, SQL, and parameters.
592
627
  expiration belongs to each Schema mapping's `freshness` policy. See
593
628
  [Query cache and Redis](docs/query-cache.md).
594
629
 
595
- Schema mappings can also expose same-connection entity feature tables as lazy physical
596
- enrichments. A mapped feature property adds a `LEFT JOIN` only when referenced, and a point-in-time
597
- feature can be assigned to the containing valid-time entity row. See
598
- [Schema Mapping feature enrichments](docs/schema-mapping-enrichments.md).
599
-
600
- For aggregate sources, set `granularity` on mapped date or hierarchy Properties.
601
- Other available dimensions are inferred from their Property mappings, so there is no
602
- separate Schema Mapping `dimensions` field. The planner selects a source that covers
603
- the requested properties and physical time or hierarchy grain. See
604
- [Schema Mapping physical granularity](docs/schema-mapping-granularity.md).
605
-
606
630
  When Redis is shared with other applications, pass an application-specific key prefix in the
607
631
  execution JSON. SemanticDB reuses the connection by `cache.id`:
608
632
 
@@ -4,6 +4,7 @@ export interface QueryCacheIdentity {
4
4
  readonly provider: CoreComputeProvider['kind'];
5
5
  /** Distinguishes separate databases using the same provider dialect. */
6
6
  readonly connectionId?: string;
7
+ readonly dataVersion?: string;
7
8
  readonly sql: string;
8
9
  readonly parameters: SqlParameters;
9
10
  }
@@ -39,6 +40,6 @@ export interface QueryCacheConfiguration {
39
40
  }
40
41
  export interface InvalidateQueryCacheSourceOptions {
41
42
  readonly cache: QueryCacheConfiguration;
42
- /** Physical Schema Mapping source to invalidate. */
43
+ /** Source identity returned by sourceIdentity(mapping.source). */
43
44
  readonly source: string;
44
45
  }
@@ -0,0 +1,6 @@
1
+ import type { Expression } from '../planner/index';
2
+ import type { CoreComputeProvider } from '../physical/index';
3
+ /** Render a scoped row-level computation. Inputs have already been resolved by Planner. */
4
+ export declare const compileComputation: (computation: Extract<Expression, {
5
+ kind: "mapping-computation";
6
+ }>, provider: CoreComputeProvider, renderInput: (expression: Expression) => string, bind: (value: unknown) => string) => string;
@@ -0,0 +1,5 @@
1
+ import type { ResolvedMappingSource } from '../schema-mappings/index';
2
+ import type { CoreComputeProvider } from '../physical/index';
3
+ /** The only SQL renderer for a resolved table/query row-set source. */
4
+ export declare const compileSource: (source: unknown, provider: CoreComputeProvider) => string;
5
+ export declare const sourceRequiresAlias: (source: ResolvedMappingSource | undefined) => boolean;
@@ -0,0 +1,22 @@
1
+ import type { LogicformType } from '../logicform-types';
2
+ import type { OperatorQueryComponent } from '../operators/index';
3
+ import type { LogicalPlan } from '../planner/index';
4
+ import type { ResolvedSemanticSchema } from '../semantic-types/index';
5
+ import { type ExecutionUnit } from './components';
6
+ export interface PreparedComponentPlan {
7
+ readonly logicform: LogicformType;
8
+ readonly plan: LogicalPlan;
9
+ readonly schema: ResolvedSemanticSchema;
10
+ }
11
+ /** Prepare metadata from the same normalized queries and hook results used for computation. */
12
+ export declare const createComponentPropertyResolver: (options: {
13
+ readonly createUnits: (form: LogicformType, plan: LogicalPlan, schema: ResolvedSemanticSchema, source?: LogicformType) => readonly ExecutionUnit[] | undefined;
14
+ readonly prepareQuery: (component: OperatorQueryComponent) => Promise<PreparedComponentPlan>;
15
+ readonly replanSource: (form: LogicformType, schema: ResolvedSemanticSchema, sourceForm: LogicformType, sourcePlan: LogicalPlan) => LogicalPlan;
16
+ readonly resolveSchema: (form: LogicformType) => ResolvedSemanticSchema;
17
+ readonly prepareUnits: (units: readonly ExecutionUnit[]) => Promise<void>;
18
+ }) => {
19
+ getUnits: (form: LogicformType, plan: LogicalPlan, schema: ResolvedSemanticSchema, source?: LogicformType) => readonly ExecutionUnit[] | undefined;
20
+ prepareQuery: (component: OperatorQueryComponent) => Promise<PreparedComponentPlan>;
21
+ resolvePlan: (form: LogicformType, original: LogicalPlan, schema: ResolvedSemanticSchema, source?: LogicformType) => Promise<LogicalPlan>;
22
+ };
@@ -1,14 +1,18 @@
1
1
  import type { LogicformType } from '../logicform-types';
2
- import type { OperatorComponentCalculation, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorRegistry } from '../operators/index';
2
+ import type { OperatorComponentCalculation, OperatorComponentInput, OperatorComponentQuery, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorRegistry } from '../operators/index';
3
3
  import type { DataRow } from '../physical/index';
4
4
  import type { LogicalPlan } from '../planner/index';
5
5
  import type { ResolvedSemanticSchema } from '../semantic-types/index';
6
6
  import { type LocaleTranslate } from '../i18n/index';
7
- export type ExecutionUnit = OperatorQueryComponent | (OperatorComponentCalculation & {
7
+ export type ExecutionUnit = (OperatorQueryComponent & {
8
+ readonly outputName?: string;
9
+ }) | (OperatorComponentCalculation & {
8
10
  readonly outputName: string;
9
11
  }) | (OperatorJavaScriptCalculation & {
10
12
  readonly outputName: string;
11
13
  });
14
+ export declare const isQueryComponent: (input: OperatorComponentInput) => input is OperatorComponentQuery;
12
15
  export declare const createExecutionUnits: (logicform: LogicformType, plan: LogicalPlan, schema: ResolvedSemanticSchema, operators: OperatorRegistry, resolveSchema: (schemaId: string) => ResolvedSemanticSchema, sourceLogicform?: LogicformType, locale?: string, t?: LocaleTranslate) => readonly ExecutionUnit[] | undefined;
13
16
  export declare const mergeComponentRows: (results: readonly (readonly DataRow[])[], groupNames: readonly string[]) => DataRow[];
14
- export declare const mergeExecutionResults: (results: readonly (readonly DataRow[])[], plan: LogicalPlan) => DataRow[];
17
+ export declare const mergeCalculationRows: (results: readonly (readonly DataRow[])[], groupNames: readonly string[], calculation: OperatorJavaScriptCalculation) => DataRow[];
18
+ export declare const mergeExecutionResults: (results: readonly (readonly DataRow[])[], plan: Pick<LogicalPlan, "groupBy" | "having" | "groupLimit" | "orderBy" | "pagination">) => DataRow[];
@@ -10,6 +10,7 @@ export interface PhysicalQuerySource {
10
10
  readonly connectionId?: string;
11
11
  /** Base mapping source that owns an enrichment source. */
12
12
  readonly mappingSource?: string;
13
+ readonly computationId?: string;
13
14
  }
14
15
  export declare const resolvePhysicalSourceMapping: (source: PhysicalQuerySource, mappings: SchemaMappingRegistry) => SchemaMappingDefinition | undefined;
15
16
  export declare const collectPlanSources: (plan: LogicalPlan) => readonly PhysicalQuerySource[];
@@ -1,4 +1,4 @@
1
- import type { LogicformType } from '../logicform-types';
1
+ import { type LogicformType } from '../logicform-types';
2
2
  import type { ExecuteOptions, ExecuteResult, ExecuteSuccessResult, InternalExecuteOptions } from './types';
3
3
  export declare const executeWithProvider: (inputLogicform: LogicformType, inputOptions: InternalExecuteOptions) => Promise<ExecuteSuccessResult>;
4
4
  export declare const execute: (inputLogicform: LogicformType, inputOptions: ExecuteOptions) => Promise<ExecuteResult>;
@@ -4,11 +4,12 @@ import type { OperatorRegistry } from '../operators/index';
4
4
  import type { CoreComputeProvider, DataRow } from '../physical/index';
5
5
  import type { LogicalPlan } from '../planner/index';
6
6
  import type { SchemaMappingRegistry } from '../schema-mappings/index';
7
- import type { SqlExecutionSourceReporter } from './execute-query';
7
+ import type { PhysicalQuerySource, SqlExecutionSourceReporter } from './execute-query';
8
8
  import type { InternalExecuteOptions } from './types';
9
9
  export declare const coordinatorConnectionId = "__semanticdb_coordinator__";
10
10
  export interface FederatedCompiledQuery {
11
11
  readonly compiled: CompiledQuery;
12
+ readonly sources: readonly PhysicalQuerySource[];
12
13
  readonly connectionId: string;
13
14
  readonly provider: CoreComputeProvider;
14
15
  readonly type: 'computation' | 'total';
@@ -9,7 +9,7 @@ import type { Permissions } from '../permissions/index';
9
9
  import type { ResolvedSemanticSchema, SemanticTypeRegistry } from '../semantic-types/index';
10
10
  import type { EntityFetchRequest } from './result-hydrator/index';
11
11
  import type { SemanticDBPlugin } from '../plugins/index';
12
- import type { SqlExecutionSourceReporter } from './execute-query';
12
+ import type { PhysicalQuerySource, SqlExecutionSourceReporter } from './execute-query';
13
13
  import type { LocaleRegistry } from '../i18n/index';
14
14
  interface FetchEntityOptions {
15
15
  readonly version: string;
@@ -26,7 +26,7 @@ interface FetchEntityOptions {
26
26
  readonly preferredConnectionId?: string;
27
27
  readonly cache?: QueryCacheExecutionOptions;
28
28
  readonly signal?: AbortSignal;
29
- readonly onCompiled?: (compiled: CompiledQuery, logicform: LogicformType, provider: CoreComputeProvider, connectionId?: string) => SqlExecutionSourceReporter | undefined;
29
+ readonly onCompiled?: (compiled: CompiledQuery, logicform: LogicformType, provider: CoreComputeProvider, connectionId: string | undefined, sources: readonly PhysicalQuerySource[]) => SqlExecutionSourceReporter | undefined;
30
30
  }
31
31
  export declare const fetchEntities: (request: EntityFetchRequest, options: FetchEntityOptions) => Promise<DataRow[]>;
32
32
  export {};
@@ -1,3 +1,3 @@
1
1
  export { execute } from './execute';
2
2
  export { closeConnections } from './connection-registry';
3
- export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './types';
3
+ export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlSchemaMapping, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './types';
@@ -0,0 +1,3 @@
1
+ import type { DataRow } from '../physical/index';
2
+ /** Merge result arrays by their executor-owned `_id`; later columns override earlier ones. */
3
+ export declare const mergeByID: (results: readonly (readonly Readonly<DataRow>[])[]) => DataRow[];
@@ -0,0 +1,18 @@
1
+ import type { LogicformType, QueryType } from '../logicform-types';
2
+ import type { OperatorRegistry } from '../operators/index';
3
+ import type { CreateLogicalPlanOptions, LogicalPlan } from '../planner/index';
4
+ import type { SchemaMappingRegistry } from '../schema-mappings/index';
5
+ import type { LogicformPartitionShard, ResolvedSemanticSchema } from '../semantic-types/index';
6
+ /** Intersect range filters so the grain checker sees the effective shard boundary. */
7
+ export declare const partitionQuery: (original: QueryType | undefined, additional: QueryType) => QueryType;
8
+ export declare const validatePartitionShards: (schema: ResolvedSemanticSchema, shards: readonly LogicformPartitionShard[], mappings: SchemaMappingRegistry) => void;
9
+ export declare const isDetailPartition: (logicform: LogicformType) => boolean;
10
+ export interface PartitionedPlans {
11
+ readonly current: LogicalPlan;
12
+ readonly comparison?: LogicalPlan;
13
+ readonly mappingIds: readonly string[];
14
+ }
15
+ export declare const createPartitionedPlans: (logicform: LogicformType, schema: ResolvedSemanticSchema, shards: readonly LogicformPartitionShard[], operators: OperatorRegistry, mappings: SchemaMappingRegistry, options: CreateLogicalPlanOptions, comparison?: {
16
+ readonly logicform: LogicformType;
17
+ readonly queryForCurrentShard: (query: QueryType) => QueryType;
18
+ }) => PartitionedPlans;
@@ -0,0 +1,5 @@
1
+ import type { LogicformRandomDataType } from '../logicform-types';
2
+ import type { DataRow } from '../physical/index';
3
+ import type { LogicalPlan } from '../planner/index';
4
+ /** Runs after all calculations/pagination and before semantic result hooks. Never mutates cached rows. */
5
+ export declare const randomizeResultData: (rows: readonly DataRow[], plan: LogicalPlan, randomData: LogicformRandomDataType | undefined) => readonly DataRow[];
@@ -0,0 +1,4 @@
1
+ import type { LogicformType, QueryType } from '../../logicform-types';
2
+ import type { EntityFetchRequest } from './types';
3
+ /** ID-only display expansion uses the latest version that has already started. */
4
+ export declare const createEntityFetchConditions: (request: EntityFetchRequest, idQuery: QueryType) => Pick<LogicformType, "query" | "sort">;
@@ -1,2 +1,3 @@
1
1
  export { hydrateResult } from './hydrate-result';
2
+ export { createEntityFetchConditions } from './entity-fetch-conditions';
2
3
  export type { EntityFetchRequest, ResultHydratorOptions } from './types';
@@ -7,8 +7,15 @@ export interface EntityFetchRequest {
7
7
  readonly schema: ResolvedSemanticSchema;
8
8
  readonly idProperty: ResolvedSemanticProperty;
9
9
  readonly ids: readonly unknown[];
10
+ /** Fetch candidates ordered by descending start time; retain the first row per ID. */
11
+ readonly latestVersion?: {
12
+ readonly startProperty: string;
13
+ readonly asOf: string;
14
+ };
10
15
  }
11
16
  export interface ResultHydratorOptions {
17
+ readonly expandEntities?: boolean;
18
+ readonly now?: Date;
12
19
  readonly semanticTypes: SemanticTypeRegistry;
13
20
  readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
14
21
  readonly fetchEntities: (request: EntityFetchRequest) => Promise<readonly DataRow[]>;
@@ -0,0 +1,6 @@
1
+ import type { LogicformType } from '../logicform-types';
2
+ import type { OperatorRegistry } from '../operators/index';
3
+ import type { ExecuteOptions, ExecuteResult, ExecuteSuccessResult } from './types';
4
+ /** Runtime operators are handled only as top-level projections. */
5
+ export declare const hasRuntimeProjection: (form: LogicformType, operators: OperatorRegistry) => boolean;
6
+ export declare const executeRuntime: (input: LogicformType, options: ExecuteOptions, operators: OperatorRegistry, executeNested: (form: LogicformType, options: ExecuteOptions) => Promise<ExecuteResult>) => Promise<ExecuteSuccessResult>;
@@ -0,0 +1,6 @@
1
+ import type { DataRow } from '../physical/index';
2
+ import type { OrderPlan } from '../planner/index';
3
+ export declare const sampleEntityRows: (rows: readonly DataRow[], limit: number, orderBy: readonly OrderPlan[]) => {
4
+ readonly rows: DataRow[];
5
+ readonly total: number;
6
+ };
@@ -2,7 +2,7 @@ import type { OperatorDefinition, OperatorExecutionContext, OperatorRegistry } f
2
2
  import type { CoreComputeProvider, DataRow, ProviderRegistry, SqlParameters } from '../physical/index';
3
3
  import type { DatabaseConnection } from '../physical/index';
4
4
  import type { LogicalPlan, QueryLineage } from '../planner/index';
5
- import type { SchemaMappingDefinition, SchemaMappingRegistry, SchemaMappingSelection } from '../schema-mappings/index';
5
+ import type { SchemaMappingDefinition, SchemaMappingRegistry } from '../schema-mappings/index';
6
6
  import type { ResolvedSemanticSchema, SemanticSchemaDraft, SemanticTypeRegistry, TimeWatermarkPolicy } from '../semantic-types/index';
7
7
  import type { LogicformType, PublicLogicformType } from '../logicform-types';
8
8
  import type { QueryCacheConfiguration, QueryCacheExecutionOptions } from '../cache/index';
@@ -67,10 +67,16 @@ interface ExecuteBaseOptions {
67
67
  readonly locale?: string;
68
68
  /** Additional or overriding locale files used by generated names and messages. */
69
69
  readonly locales?: LocaleInput;
70
- /** Table, row, and column permissions for this execution. */
70
+ /** Table, row, column, and custom metric permissions for this execution. */
71
71
  readonly permissions?: Permissions;
72
72
  readonly onProgress?: ProgressCallback;
73
73
  readonly signal?: AbortSignal;
74
+ /** Application helpers (for example axios) passed to runtime Operators. SDK helper names are reserved. */
75
+ readonly runtimeHelpers?: Readonly<Record<string, unknown>>;
76
+ /** Application configuration passed as the third argument to a runtime Operator's run hook. */
77
+ readonly runtimeConfig?: Readonly<Record<string, unknown>>;
78
+ /** Skip entity expansion in this execution; the public result envelope remains unchanged. */
79
+ readonly result_only?: boolean;
74
80
  /** Default time watermark policy; Schema and Property policies override it. */
75
81
  readonly timeWatermark?: TimeWatermarkPolicy;
76
82
  /** Resource limits for in-process combination of separate physical connections. */
@@ -81,9 +87,9 @@ interface ExecuteBaseOptions {
81
87
  }
82
88
  export interface ExecuteOptions extends ExecuteBaseOptions {
83
89
  /** Physical mappings supplied as JSON definitions. */
84
- readonly schemaMappings: readonly SchemaMappingDefinition[];
90
+ readonly schemaMappings?: readonly SchemaMappingDefinition[];
85
91
  /** Database connections addressable by SchemaMappingDefinition.connectionId. */
86
- readonly connections: readonly DatabaseConnection[];
92
+ readonly connections?: readonly DatabaseConnection[];
87
93
  /** Provider factories used for built-in or application-defined connection kinds. */
88
94
  readonly providerRegistry?: ProviderRegistry;
89
95
  /** JSON configuration for an internally owned and reused query-cache connection. */
@@ -91,6 +97,10 @@ export interface ExecuteOptions extends ExecuteBaseOptions {
91
97
  }
92
98
  /** Internal execution seam used by executor tests after a provider has been resolved. */
93
99
  export interface InternalExecuteOptions extends Omit<ExecuteBaseOptions, 'operators'> {
100
+ /** Schema hooks already active in an internal execution, for recursion detection. */
101
+ readonly partitionStack?: readonly string[];
102
+ /** A pinned internal execution does not repartition this Schema. */
103
+ readonly partitionDisabledSchemaIds?: readonly string[];
94
104
  readonly operators?: OperatorRegistry;
95
105
  /** The public execution boundary has already merged built-in, plugin, and explicit Operators. */
96
106
  readonly operatorsResolved?: boolean;
@@ -117,14 +127,6 @@ export interface ExecuteSuccessResult {
117
127
  readonly normedLogicform: PublicLogicformType;
118
128
  readonly sqls: readonly ExecutedSql[];
119
129
  readonly lineage: QueryLineage;
120
- readonly provider: CoreComputeProvider['kind'];
121
- /** Physical connections that contributed rows to this result. */
122
- readonly providers: readonly {
123
- readonly connectionId: string;
124
- readonly provider: CoreComputeProvider['kind'];
125
- }[];
126
- /** Physical mapping decisions, including why every non-selected candidate lost. */
127
- readonly schemaMappingSelections: readonly SchemaMappingSelection[];
128
130
  /** Plugin-owned materialization for a custom LogicForm output type. */
129
131
  readonly output?: unknown;
130
132
  }
@@ -135,12 +137,18 @@ export interface ExecuteFailureResult {
135
137
  readonly schema?: ResolvedSemanticSchema;
136
138
  readonly normedLogicform: PublicLogicformType;
137
139
  readonly sqls: readonly ExecutedSql[];
138
- readonly provider?: CoreComputeProvider['kind'];
139
140
  readonly lineage?: QueryLineage;
140
141
  }
141
142
  export type ExecuteResult = ExecuteSuccessResult | ExecuteFailureResult;
142
143
  export type ExecutedSqlType = 'computation' | 'semantic-resolution' | 'total';
143
144
  export type SqlExecutionSource = 'cache' | 'database';
145
+ export interface ExecutedSqlSchemaMapping {
146
+ readonly schemaId: string;
147
+ /** Schema Mapping id, or its source when no explicit id was configured. */
148
+ readonly mappingId: string;
149
+ readonly connectionId: string;
150
+ readonly source: string;
151
+ }
144
152
  export interface ExecutedSql {
145
153
  /** Why this SQL participates in the LogicForm execution. */
146
154
  readonly type: ExecutedSqlType;
@@ -151,6 +159,8 @@ export interface ExecutedSql {
151
159
  readonly explain: string;
152
160
  /** Normalized LogicForm represented by this SQL statement. */
153
161
  readonly logicform: PublicLogicformType;
162
+ /** Physical Schema Mappings read directly by this SQL; empty for coordinator or materialized-row SQL. */
163
+ readonly schemaMappings: readonly ExecutedSqlSchemaMapping[];
154
164
  /** Parameterized SQL used for provider execution and cache identity. */
155
165
  readonly sql: string;
156
166
  readonly parameters: SqlParameters;
@@ -0,0 +1,2 @@
1
+ export { readImportFile } from './read-file';
2
+ export type { CsvEncoding, ImportFile, ReadImportFileOptions, ReadImportFileResult } from './types';
@@ -0,0 +1,2 @@
1
+ import type { ReadImportFileOptions, ReadImportFileResult } from './types';
2
+ export declare const readImportFile: (options: ReadImportFileOptions) => Promise<ReadImportFileResult>;
@@ -0,0 +1,31 @@
1
+ import type { DataRow } from '../physical/index';
2
+ export type CsvEncoding = 'auto' | 'utf-8' | 'gbk' | 'gb18030' | 'utf-16le' | 'utf-16be';
3
+ export type ImportFile = {
4
+ readonly path: string;
5
+ readonly format?: 'csv' | 'xlsx';
6
+ } | {
7
+ readonly data: Uint8Array;
8
+ readonly format: 'csv' | 'xlsx';
9
+ };
10
+ export interface ReadImportFileOptions {
11
+ readonly file: ImportFile;
12
+ readonly csv?: {
13
+ readonly encoding?: CsvEncoding;
14
+ readonly delimiter?: ',' | ';' | '\t' | '|';
15
+ };
16
+ readonly excel?: {
17
+ readonly sheet?: string;
18
+ readonly headerRow?: number;
19
+ };
20
+ /** Defaults to 50 MiB and 100,000 data rows. */
21
+ readonly maxBytes?: number;
22
+ readonly maxRows?: number;
23
+ readonly signal?: AbortSignal;
24
+ }
25
+ export interface ReadImportFileResult {
26
+ readonly format: 'csv' | 'xlsx';
27
+ readonly encoding?: Exclude<CsvEncoding, 'auto'>;
28
+ readonly sheet?: string;
29
+ readonly columns: readonly string[];
30
+ readonly rows: readonly DataRow[];
31
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { getLogicformPropertyReferences, isDimensionInLogicform } from './logicform/index';
2
+ export type { LogicformPropertyReference } from './logicform/index';
1
3
  export { createLocaleRegistry, defaultLocaleRegistry, LocaleRegistry, enUS, zhCN, } from './i18n/index';
2
4
  export type { LocaleDefinition, LocaleInput, LocaleTranslate } from './i18n/index';
3
5
  export declare const Logicform: Readonly<{
@@ -8,19 +10,22 @@ export { SemanticDBError } from './errors';
8
10
  export { builtinSemanticTypes, createSemanticTypeRegistry, resolveSchema, SemanticTypeRegistry, validateResolvedSchema, } from './semantic-types/index';
9
11
  export { builtinOperators, createOperatorRegistry, OperatorRegistry, resolveOperator, } from './operators/index';
10
12
  export type { LegacySchemaPluginContext, MappingGranularityContext, MappingGranularityPlugin, OutputHandlerContext, OutputHandlerDefinition, IntervalSemanticProperties, IntervalSemanticsDefinition, PlannerPeriodDefinition, PlannerPeriodEvaluation, RelationSemanticsDefinition, RelationTemporalPlan, TimeWatermarkLogicformContext, PropertyMetadataPlugin, QueryOperatorCompileContext, QueryOperatorAuthorizeContext, QueryOperatorDefinition, QueryOperatorNormalizeContext, QueryOperatorPhysicalSource, QueryOperatorPlanContext, QueryOperatorPlanResult, SchemaMetadataPlugin, SchemaMappingPlugin, SemanticDBPlugin, } from './plugins/index';
11
- export { SchemaMappingRegistry, fromYiAskSchemaMapping, } from './schema-mappings/index';
12
- export type { AbsoluteDateValue, CompareOperator, DatePartQueryComparison, DatePartQueryOperand, DateTimeValue, DateValue, EntityIdType, ExpressionItemType, LogicformType, NumericQueryComparison, NumericQueryOperand, PublicLogicformType, PeriodShiftTime, PredItemType, QueryLogicalOperand, QueryExpressionType, RelationQueryType, QueryType, QueryValueType, QueryValueTypeWithCompareOperator, RelativeDateValue, RepresentationType, } from './logicform-types';
13
+ export { SchemaMappingRegistry, sourceIdentity, fromYiAskSchemaMapping, getSupportedDimensions, } from './schema-mappings/index';
14
+ export type { AbsoluteDateValue, CalendarDateQueryValue, CompareOperator, DatePartQueryComparison, DatePartQueryOperand, DateTimeValue, DateValue, EntityIdType, ExpressionItemType, LogicformType, LogicformSampleType, LogicformRandomDataOptions, LogicformRandomDataType, NumericQueryComparison, NumericQueryOperand, PublicLogicformType, PeriodShiftTime, PredItemType, QueryLogicalOperand, QueryExpressionType, RelationQueryType, QueryType, QueryValueType, QueryValueTypeWithCompareOperator, RelativeDateValue, RepresentationType, } from './logicform-types';
13
15
  export type { RecursiveQueryType } from './plugins/index';
14
16
  export type { PrimalType, PropertyHierarchyDefinition, PropertySqlDefinition, ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, SemanticTypeResultContext, SemanticTypeResultProperty, TimeGranularity, TimeWatermarkPolicy, } from './semantic-types/index';
15
17
  export type { DataRow, SqlParameters, BuiltinDatabaseConnection, DatabaseConnection, DatabaseConnectionBase, DatabaseConnectionExtensions, ProviderDefinition, ProviderKind, ProviderKindExtensions, } from './physical/index';
16
18
  export { DBConnector, ProviderRegistry } from './physical/index';
19
+ export { readImportFile } from './file-import/index';
20
+ export type { CsvEncoding, ImportFile, ReadImportFileOptions, ReadImportFileResult } from './file-import/index';
21
+ export type { DuckDBConnectionOptions, ImportColumn, ImportRowsRequest, ImportRowsResult, ImportFileOptions, ImportFileResult } from './physical/index';
17
22
  export type { DBConnectorOptions, RunSQLOptions, GetTableListOptions, DescribeTableOptions, DescribeTableRequest, DatabaseColumn, TableDescription, DatabaseTable, SQLResult, TableListRequest, } from './physical/index';
18
- export type { OperatorDefinition, OperatorDefaultNameContext, OperatorExecutionContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorPlanInputContext, OperatorPlannedInput, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './operators/index';
19
- export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingPredDefinition, SchemaMappingPredMatch, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
23
+ export type { OperatorDefinition, OperatorDefaultNameContext, OperatorFormulaTextContext, OperatorExecutionContext, ResolvedTimeRange, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorComponentLiteral, OperatorComponentInput, OperatorExecutionComponent, OperatorPlanInputContext, OperatorPlannedInput, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorOutputPropertyContext, OperatorRuntimeHelpers, OperatorRuntimeConfig, OperatorRuntimeExecute, OperatorRuntimeRun, OperatorRuntimeValue, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './operators/index';
24
+ export type { SchemaMappingDefinition, SchemaMappingSource, ResolvedMappingSource, PropertyMappingCalculation, PropertyMappingValue, PropertyMapping, PredItemMapping, IgnoredMapping, ComputationExpression, ComputationInput, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, QueryPathBinding, QueryPathMappingDefinition, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingPredDefinition, SchemaMappingPredMatch, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
20
25
  export { QueryCacheManager } from './cache/index';
21
26
  export type { InvalidateQueryCacheSourceOptions, QueryCacheConfiguration, } from './cache/index';
22
- export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './executor/index';
23
- export type { ColumnPermissions, Permissions, SchemaPermissions, } from './permissions/index';
27
+ export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlSchemaMapping, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './executor/index';
28
+ export type { ColumnPermissions, MetricPermissions, Permissions, SchemaPermissions, } from './permissions/index';
24
29
  export type { CreateLogicalPlanOptions, LogicalPlan, QueryLineage, } from './planner/index';
25
30
  export { PlannerSemanticRegistry, createPlannerSemanticRegistry, } from './planner/index';
26
31
  export type { PlannerSemanticResolution, PlannerSemanticQueryContext, PlannerSemanticRule, PlannerSemanticRuleContext, } from './planner/index';
@@ -0,0 +1,16 @@
1
+ import type { LogicformType } from '../logicform-types';
2
+ export interface LogicformPropertyReference {
3
+ readonly reference: string;
4
+ readonly use: 'query' | 'pred' | 'groupby';
5
+ }
6
+ /** Property references in this v2 LogicForm node, retaining their use site. */
7
+ export declare const getLogicformPropertyReferences: (logicform: LogicformType) => readonly LogicformPropertyReference[];
8
+ /**
9
+ * Whether this v2 LogicForm node uses an exact property path in its query,
10
+ * PredItems, or groupby. A related-property filter such as
11
+ * `产品: { schema: 'product', query: { 品类: 'PA' } }` uses `产品_品类`,
12
+ * not the `产品` entity itself. A `from` or full query subquery has its own
13
+ * field scope and is not traversed. Normalize first when comparing property
14
+ * names with IDs or aliases.
15
+ */
16
+ export declare const isDimensionInLogicform: (logicform: LogicformType, dimension: string) => boolean;
@@ -0,0 +1,2 @@
1
+ export { getLogicformPropertyReferences, isDimensionInLogicform } from './dimensions';
2
+ export type { LogicformPropertyReference } from './dimensions';
@@ -3,7 +3,7 @@ export type RepresentationType = 'value' | 'table' | 'pie' | 'bar' | 'column' |
3
3
  /** A concrete timestamp accepted by a LogicForm query. */
4
4
  export type DateTimeValue = `${number}-${number}-${number} ${number}:${number}:${number}`;
5
5
  /** A relative period resolved from the execution clock. */
6
- export interface RelativeDateValue {
6
+ export interface RelativeDateValue extends AbsoluteDateValue {
7
7
  readonly granularity: TimeGranularity;
8
8
  readonly offset: number;
9
9
  }
@@ -22,7 +22,14 @@ export interface AbsoluteDateValue {
22
22
  /** Period reference used by operators such as `$periodShift`. */
23
23
  export type PeriodShiftTime = RelativeDateValue | AbsoluteDateValue;
24
24
  /** A date value before semantic-type normalization. */
25
- export type DateValue = string | RelativeDateValue | AbsoluteDateValue;
25
+ export type DateValue = string | RelativeDateValue | AbsoluteDateValue | CalendarDateQueryValue;
26
+ /** Calendar selections; comparison components and finer parts become date-part filters. */
27
+ export type CalendarDateQueryValue = {
28
+ readonly [Part in Exclude<keyof AbsoluteDateValue, 'period'>]?: DatePartQueryOperand;
29
+ } & {
30
+ readonly granularity?: TimeGranularity;
31
+ readonly offset?: number;
32
+ };
26
33
  /** Stable entity identity. Numeric IDs must be safe integers. */
27
34
  export type EntityIdType = string | number;
28
35
  export type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$contains' | '$startsWith' | '$length' | '$and' | '$or' | '$second' | '$minute' | '$hour' | '$weekday' | '$day' | '$week' | '$month' | '$quarter' | '$year' | Extract<keyof QueryOperatorExtensions, string>;
@@ -118,6 +125,16 @@ export interface LogicformOutputType {
118
125
  type: LogicformOutputTypeValue;
119
126
  filename?: string;
120
127
  }
128
+ /** Enable uniform sampling of distinct entity rows; top-level limit controls the count. */
129
+ export type LogicformSampleType = boolean;
130
+ /** Presentation-only numeric perturbation; each output cell gets an independent multiplier. */
131
+ export interface LogicformRandomDataOptions {
132
+ /** Minimum multiplier (inclusive). Defaults to 0.1. */
133
+ readonly minFactor?: number;
134
+ /** Maximum multiplier (exclusive unless equal to minFactor). Defaults to 1.5. */
135
+ readonly maxFactor?: number;
136
+ }
137
+ export type LogicformRandomDataType = boolean | LogicformRandomDataOptions;
121
138
  export interface LogicformType {
122
139
  /** LogicForm protocol version. This SDK supports version 2.0 and later. */
123
140
  version: string;
@@ -129,6 +146,9 @@ export interface LogicformType {
129
146
  propertyResolve?: Readonly<Record<string, Readonly<Record<string, string>>>>;
130
147
  groupby?: PredItemType[];
131
148
  sort?: Record<string, 1 | -1>;
149
+ sample?: LogicformSampleType;
150
+ /** Perturb final scalar numeric values, excluding grouping keys and identities. Top-level only. */
151
+ randomData?: LogicformRandomDataType;
132
152
  having?: QueryType;
133
153
  output?: LogicformOutputType;
134
154
  limit?: number;
@@ -3,7 +3,14 @@ import type { OperatorRegistry } from '../operators/index';
3
3
  import type { ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeRegistry } from '../semantic-types/index';
4
4
  import type { SemanticDBPlugin } from '../plugins/index';
5
5
  import type { LocaleInput, LocaleRegistry } from '../i18n/index';
6
+ import type { ResolvedTimeRange } from '../operators/index';
6
7
  export interface NormalizeLogicformOptions {
8
+ /** Reports only this call's main query, never nested or metric queries. */
9
+ readonly onTimeRangeResolved?: (range: ResolvedTimeRange | undefined) => void;
10
+ /** Internal recursion guard: sampling is a top-level result operation. */
11
+ readonly allowSample?: boolean;
12
+ /** Internal recursion guard: numeric perturbation applies only to the final result. */
13
+ readonly allowRandomData?: boolean;
7
14
  readonly semanticTypes: SemanticTypeRegistry;
8
15
  readonly operators?: OperatorRegistry;
9
16
  readonly plugins?: readonly SemanticDBPlugin[];
@@ -25,7 +32,7 @@ export interface NormalizeLogicformOptions {
25
32
  }>;
26
33
  /** Internal root query used to resolve automatic `$case` boundaries. */
27
34
  readonly autoCaseQuery?: LogicformType['query'];
28
- readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
35
+ readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema | Promise<ResolvedSemanticSchema>;
29
36
  readonly canProjectProperty?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => boolean;
30
37
  /** Internal recursion hook installed by normalizeLogicform. */
31
38
  readonly normalizeNestedLogicform?: (logicform: LogicformType) => Promise<LogicformType>;
@@ -2,3 +2,4 @@ export { normalizeLogicform } from './normalize-logicform';
2
2
  export { defaultPredName } from './default-pred-name';
3
3
  export { assertSupportedLogicformVersion } from './version';
4
4
  export { inferPropertyResolvePath } from './property-resolve';
5
+ export { expandPublicLogicform } from './public-logicform';
@@ -0,0 +1,9 @@
1
+ import type { ResolvedTimeRange } from '../operators/index';
2
+ import type { ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext } from '../semantic-types/index';
3
+ /** Collect only the root query; metric, relation and nested LF queries never enter here. */
4
+ export declare class MainTimeRangeCollector {
5
+ #private;
6
+ invalidate(): void;
7
+ observe(schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty, queryPath: readonly (string | number)[], customNormalization: boolean): SemanticTypeNormalizeContext['onDateQueryNormalized'];
8
+ get result(): ResolvedTimeRange | undefined;
9
+ }