semanticdb-v2 2.0.0-alpha.5 → 2.0.0-alpha.6

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 (89) hide show
  1. package/README.md +164 -7
  2. package/dist/cache/redis-query-cache.esm.js +1 -1
  3. package/dist/cache/redis-query-cache.js +1 -1
  4. package/dist/cache/types.d.ts +2 -0
  5. package/dist/executor/connection-registry.d.ts +2 -2
  6. package/dist/executor/execute-query.d.ts +6 -1
  7. package/dist/executor/federated-execution.d.ts +37 -0
  8. package/dist/executor/fetch-entities.d.ts +3 -1
  9. package/dist/executor/result-hydrator/types.d.ts +2 -0
  10. package/dist/executor/total.d.ts +11 -0
  11. package/dist/executor/types.d.ts +33 -4
  12. package/dist/index.d.ts +8 -7
  13. package/dist/logicform-types.d.ts +44 -12
  14. package/dist/normalizer/pred-expression.d.ts +6 -0
  15. package/dist/operators/builtins/query-expression.d.ts +3 -0
  16. package/dist/operators/index.d.ts +1 -1
  17. package/dist/operators/types.d.ts +39 -8
  18. package/dist/physical/clickhouse-provider.d.ts +6 -2
  19. package/dist/physical/connection.d.ts +57 -15
  20. package/dist/physical/dameng-provider.d.ts +61 -0
  21. package/dist/physical/databricks-provider.d.ts +83 -0
  22. package/dist/physical/display-query.d.ts +3 -0
  23. package/dist/physical/doris-provider.d.ts +2 -1
  24. package/dist/physical/duckdb-coordinator-provider.d.ts +37 -0
  25. package/dist/physical/gbase-provider.d.ts +11 -0
  26. package/dist/physical/index.d.ts +21 -9
  27. package/dist/physical/load-driver.d.ts +1 -0
  28. package/dist/physical/maxcompute-provider.d.ts +37 -0
  29. package/dist/physical/mysql-protocol-provider.d.ts +21 -6
  30. package/dist/physical/mysql-provider.d.ts +2 -1
  31. package/dist/physical/oracle-provider.d.ts +15 -4
  32. package/dist/physical/postgresql-provider.d.ts +18 -4
  33. package/dist/physical/provider.d.ts +12 -1
  34. package/dist/physical/snowflake-provider.d.ts +15 -3
  35. package/dist/physical/sqlserver-provider.d.ts +65 -0
  36. package/dist/physical/starrocks-provider.d.ts +2 -1
  37. package/dist/planner/build-lineage.d.ts +1 -1
  38. package/dist/planner/create-logical-plan.d.ts +7 -0
  39. package/dist/planner/index.d.ts +4 -2
  40. package/dist/planner/mapping-granularity.d.ts +7 -0
  41. package/dist/planner/rewrite-nested-components.d.ts +8 -0
  42. package/dist/planner/select-schema-mapping.d.ts +16 -2
  43. package/dist/planner/semantics/index.d.ts +0 -4
  44. package/dist/planner/semantics/periods.d.ts +13 -0
  45. package/dist/planner/semantics/registry-defaults.d.ts +2 -1
  46. package/dist/planner/types.d.ts +71 -34
  47. package/dist/plugins/hierarchy/index.d.ts +1 -1
  48. package/dist/plugins/hierarchy/mapping-granularity.d.ts +4 -0
  49. package/dist/plugins/hierarchy/types.d.ts +17 -0
  50. package/dist/plugins/index.d.ts +10 -1
  51. package/dist/{planner/semantics → plugins}/observation/classification.d.ts +1 -1
  52. package/dist/plugins/observation/index.d.ts +17 -0
  53. package/dist/{planner/semantics → plugins}/observation/operator-policy.d.ts +2 -3
  54. package/dist/{planner/semantics → plugins}/observation/periods.d.ts +2 -3
  55. package/dist/{planner/semantics → plugins}/observation/rule.d.ts +1 -1
  56. package/dist/{planner/semantics → plugins}/observation/types.d.ts +1 -1
  57. package/dist/plugins/property-hierarchy/index.d.ts +11 -0
  58. package/dist/plugins/recursive/index.d.ts +26 -0
  59. package/dist/plugins/temporal/index.d.ts +13 -0
  60. package/dist/plugins/types.d.ts +165 -1
  61. package/dist/plugins/validity/classification.d.ts +5 -0
  62. package/dist/{planner/semantics → plugins}/validity/index.d.ts +9 -0
  63. package/dist/{planner/semantics → plugins}/validity/periods.d.ts +2 -3
  64. package/dist/{planner/semantics → plugins}/validity/query-policy.d.ts +1 -2
  65. package/dist/{planner/semantics → plugins}/validity/rule.d.ts +1 -1
  66. package/dist/plugins/validity/semantic-types.d.ts +3 -0
  67. package/dist/schema-mappings/freshness.d.ts +1 -1
  68. package/dist/schema-mappings/granularity.d.ts +5 -0
  69. package/dist/schema-mappings/index.d.ts +2 -1
  70. package/dist/schema-mappings/registry.d.ts +5 -3
  71. package/dist/schema-mappings/types.d.ts +43 -0
  72. package/dist/schema-mappings/yiask.d.ts +6 -2
  73. package/dist/semantic-types/index.d.ts +5 -3
  74. package/dist/semantic-types/registry.d.ts +2 -0
  75. package/dist/semantic-types/resolve-schema.d.ts +1 -1
  76. package/dist/semantic-types/types.d.ts +0 -14
  77. package/dist/semantic-types/validate-resolved-schema.d.ts +2 -5
  78. package/dist/semanticdb.esm.js +4 -3
  79. package/dist/semanticdb.js +4 -3
  80. package/package.json +46 -5
  81. package/dist/planner/semantics/annual-periods.d.ts +0 -11
  82. package/dist/planner/semantics/lifecycle/classification.d.ts +0 -5
  83. package/dist/planner/semantics/lifecycle/index.d.ts +0 -3
  84. package/dist/planner/semantics/lifecycle/query-policy.d.ts +0 -2
  85. package/dist/planner/semantics/lifecycle/rule.d.ts +0 -2
  86. package/dist/planner/semantics/observation/index.d.ts +0 -6
  87. package/dist/planner/semantics/validity/classification.d.ts +0 -14
  88. package/dist/semantic-types/builtins/end-date.d.ts +0 -2
  89. package/dist/semantic-types/builtins/start-date.d.ts +0 -2
@@ -1,11 +1,10 @@
1
- import type { PredItemType } from '../../../logicform-types';
2
- import type { OperatorDefinition } from '../../../operators/index';
1
+ import type { PredItemType } from '../../logicform-types';
2
+ import type { OperatorDefinition } from '../../operators/index';
3
3
  declare const periodBoundaryOperator = "$periodValue";
4
4
  export interface ObservationOperatorPolicy {
5
5
  readonly operator: typeof periodBoundaryOperator;
6
6
  readonly boundary: 'start' | 'end';
7
7
  readonly implicit: boolean;
8
8
  }
9
- /** Resolves the point-selection policy without changing the caller LogicForm. */
10
9
  export declare const resolveObservationOperatorPolicy: (pred: Pick<PredItemType, "operator" | "args">, operator?: OperatorDefinition) => ObservationOperatorPolicy;
11
10
  export {};
@@ -1,5 +1,5 @@
1
- import type { LogicformType, PredItemType, QueryType } from '../../../logicform-types';
2
- import type { ResolvedSemanticProperty, ResolvedSemanticSchema } from '../../../semantic-types/index';
1
+ import type { LogicformType, PredItemType, QueryType } from '../../logicform-types';
2
+ import type { ResolvedSemanticProperty, ResolvedSemanticSchema } from '../../semantic-types/index';
3
3
  export interface ObservationPeriodMetric {
4
4
  readonly pred: PredItemType;
5
5
  readonly effectivePred: PredItemType;
@@ -15,5 +15,4 @@ export interface ObservationPeriodSpec {
15
15
  }[];
16
16
  }
17
17
  export declare const removeObservationTimeCondition: (query: QueryType | undefined, timestamp: ResolvedSemanticProperty) => QueryType | undefined;
18
- /** Plan grouped snapshot metrics as one lookup of the latest observation per period. */
19
18
  export declare const resolveObservationPeriodSpec: (logicform: LogicformType, schema: ResolvedSemanticSchema) => ObservationPeriodSpec | undefined;
@@ -1,2 +1,2 @@
1
- import type { PlannerSemanticRule } from '../registry';
1
+ import type { PlannerSemanticRule } from '../../planner/index';
2
2
  export declare const observationSemanticRule: PlannerSemanticRule;
@@ -1,3 +1,3 @@
1
- import type { ResultPropertyTemporalMetadata } from '../../../operators/index';
1
+ import type { ResultPropertyTemporalMetadata } from '../../operators/index';
2
2
  export type ObservationTemporalMetadata = ResultPropertyTemporalMetadata;
3
3
  export type ObservationOperator = '$periodValue';
@@ -0,0 +1,11 @@
1
+ import type { PropertyHierarchyDefinition } from '../../semantic-types/index';
2
+ import type { SemanticDBPlugin } from '../types';
3
+ type PropertyHierarchyMetadata = PropertyHierarchyDefinition;
4
+ declare module '../../semantic-types/types' {
5
+ interface SemanticPropertyDraft {
6
+ /** Same-Schema drill relationship. `up` identifies the single-valued parent Property. */
7
+ readonly hierarchy?: PropertyHierarchyMetadata;
8
+ }
9
+ }
10
+ export declare const propertyHierarchyPlugin: SemanticDBPlugin;
11
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { SemanticDBPlugin } from '../types';
2
+ import type { QueryValueType } from '../../logicform-types';
3
+ export interface RecursiveQueryType {
4
+ readonly schema?: string;
5
+ readonly root?: QueryValueType;
6
+ readonly roots?: QueryValueType[];
7
+ readonly includeSelf?: boolean;
8
+ readonly idProperty?: string;
9
+ readonly parentProperty?: string;
10
+ }
11
+ declare module '../../logicform-types' {
12
+ interface QueryOperatorExtensions {
13
+ readonly $recursive?: QueryValueType | RecursiveQueryType;
14
+ }
15
+ }
16
+ declare module '../../semantic-types/types' {
17
+ interface SemanticSchemaMetadata {
18
+ /** Property that stores a tree node's parent id. */
19
+ readonly parentProperty?: string;
20
+ }
21
+ interface ResolvedSemanticSchemaMetadata {
22
+ /** Canonical logical name of the Property that stores a tree node's parent id. */
23
+ readonly parentProperty?: string;
24
+ }
25
+ }
26
+ export declare const recursivePlugin: SemanticDBPlugin;
@@ -0,0 +1,13 @@
1
+ import type { SemanticDBPlugin } from '../types';
2
+ declare module '../../semantic-types/types' {
3
+ interface SemanticPropertyDraft {
4
+ readonly timeWatermark?: TimeWatermarkPolicy;
5
+ }
6
+ interface SemanticSchemaMetadata {
7
+ readonly timeWatermark?: TimeWatermarkPolicy;
8
+ }
9
+ interface ResolvedSemanticSchemaMetadata {
10
+ readonly timeWatermark?: TimeWatermarkPolicy;
11
+ }
12
+ }
13
+ export declare const temporalPlugin: SemanticDBPlugin;
@@ -1,20 +1,184 @@
1
1
  import type { OperatorDefinition } from '../operators/types';
2
- import type { ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticSchemaDraft } from '../semantic-types/types';
2
+ import type { LocaleDefinition } from '../i18n/types';
3
+ import type { PlannerSemanticRule } from '../planner/semantics/registry';
4
+ import type { CoreComputeProvider, DataRow } from '../physical/provider';
5
+ import type { LogicformType, PredItemType, QueryType } from '../logicform-types';
6
+ import type { SchemaMappingDefinition, SchemaMappingItem } from '../schema-mappings/types';
7
+ import type { ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticSchemaDraft, SemanticTypeDefinition, TimeWatermarkPolicy } from '../semantic-types/types';
3
8
  export interface SchemaMetadataPlugin {
4
9
  readonly keys: readonly string[];
5
10
  readonly resolve: (schema: SemanticSchemaDraft, properties: readonly ResolvedSemanticProperty[]) => Readonly<Record<string, unknown>>;
6
11
  }
12
+ export interface PropertyMetadataPlugin {
13
+ readonly keys: readonly string[];
14
+ readonly resolve: (property: SemanticSchemaDraft['properties'][number], resolved: ResolvedSemanticProperty, schema: SemanticSchemaDraft) => Readonly<Record<string, unknown>>;
15
+ readonly resolveAll?: (properties: readonly ResolvedSemanticProperty[], drafts: readonly SemanticSchemaDraft['properties'][number][], schema: SemanticSchemaDraft) => readonly ResolvedSemanticProperty[];
16
+ }
7
17
  export interface LegacySchemaPluginContext {
8
18
  readonly source: Readonly<Record<string, unknown>>;
9
19
  readonly properties: readonly SemanticSchemaDraft['properties'][number][];
10
20
  }
21
+ export interface MappingGranularityContext {
22
+ readonly schema: ResolvedSemanticSchema;
23
+ readonly mapping: SchemaMappingDefinition;
24
+ readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
25
+ }
26
+ export interface MappingGranularityPlugin {
27
+ /** Object-grain discriminator; one plugin owns each kind. */
28
+ readonly kind: string;
29
+ readonly isGranularity: (value: unknown) => boolean;
30
+ readonly validateItem?: (item: SchemaMappingItem, context: MappingGranularityContext) => string | undefined;
31
+ /** Reject a grouped source when it cannot preserve a requested dimension or filter. */
32
+ readonly candidateReason?: (logicform: LogicformType, context: MappingGranularityContext) => string | undefined;
33
+ /** True only for a computed grouping this plugin can verify in candidateReason. */
34
+ readonly supportsGroupby?: (group: PredItemType) => boolean;
35
+ }
36
+ export interface SchemaMappingPlugin {
37
+ readonly validate?: (mapping: SchemaMappingDefinition) => string | undefined;
38
+ readonly candidateReason?: (logicform: LogicformType, context: MappingGranularityContext) => string | undefined;
39
+ }
40
+ export interface QueryOperatorNormalizeContext {
41
+ readonly schema: ResolvedSemanticSchema;
42
+ readonly property: ResolvedSemanticProperty;
43
+ readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
44
+ readonly normalizeValue: (value: unknown, schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => Promise<unknown>;
45
+ }
46
+ export interface QueryOperatorPlanContext {
47
+ readonly schema: ResolvedSemanticSchema;
48
+ readonly property: ResolvedSemanticProperty;
49
+ readonly connectionId: string;
50
+ readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
51
+ readonly resolveMapping: (schemaId: string, preferredConnectionId?: string) => SchemaMappingDefinition;
52
+ }
53
+ export interface QueryOperatorCompileContext {
54
+ readonly field: string;
55
+ readonly provider: CoreComputeProvider;
56
+ readonly bind: (value: unknown) => string;
57
+ readonly renderSource: (source: string, sourceSql?: string) => string;
58
+ }
59
+ export interface QueryOperatorAuthorizeContext {
60
+ readonly schema: ResolvedSemanticSchema;
61
+ readonly property: ResolvedSemanticProperty;
62
+ readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
63
+ readonly assertSchemaAllowed: (schemaId: string) => void;
64
+ readonly assertPropertyAllowed: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => void;
65
+ readonly hasRowPermissions: (schemaId: string) => boolean;
66
+ }
67
+ export interface QueryOperatorPhysicalSource {
68
+ readonly schemaId: string;
69
+ readonly source: string;
70
+ readonly connectionId?: string;
71
+ }
72
+ export interface QueryOperatorPlanResult {
73
+ readonly value: unknown;
74
+ readonly sources?: readonly QueryOperatorPhysicalSource[];
75
+ }
76
+ export interface OutputHandlerContext {
77
+ readonly rows: readonly DataRow[];
78
+ readonly logicform: LogicformType;
79
+ readonly schema: ResolvedSemanticSchema;
80
+ }
81
+ export interface OutputHandlerDefinition {
82
+ readonly type: string;
83
+ readonly handle: (context: OutputHandlerContext) => unknown;
84
+ }
85
+ export interface TimeWatermarkLogicformContext {
86
+ readonly logicform: LogicformType;
87
+ readonly rootSchema: ResolvedSemanticSchema;
88
+ readonly rootProperty: ResolvedSemanticProperty;
89
+ readonly requestedUpperBound: Date;
90
+ readonly now: Date;
91
+ readonly defaultPolicy?: TimeWatermarkPolicy;
92
+ readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
93
+ readonly inferPropertyPath: (sourceSchema: ResolvedSemanticSchema, sourceProperty: string, targetSchema: ResolvedSemanticSchema) => string | undefined;
94
+ }
95
+ /** Stable interval roles used by generic point-in-interval planning. */
96
+ export interface IntervalSemanticProperties {
97
+ readonly id: ResolvedSemanticProperty;
98
+ readonly timestamp: ResolvedSemanticProperty;
99
+ readonly start: ResolvedSemanticProperty;
100
+ readonly end: ResolvedSemanticProperty;
101
+ }
102
+ export interface IntervalSemanticsDefinition {
103
+ readonly resolve: (schema: ResolvedSemanticSchema) => IntervalSemanticProperties | undefined;
104
+ }
105
+ export type RelationTemporalPlan = {
106
+ readonly kind: 'date-bucket-equal';
107
+ readonly sourceTimestamp: ResolvedSemanticProperty;
108
+ readonly targetTimestamp: ResolvedSemanticProperty;
109
+ } | {
110
+ readonly kind: 'point-in-interval';
111
+ readonly point: ResolvedSemanticProperty;
112
+ readonly start: ResolvedSemanticProperty;
113
+ readonly end: ResolvedSemanticProperty;
114
+ };
115
+ export interface RelationSemanticsDefinition {
116
+ readonly plan: (context: {
117
+ readonly sourceSchema: ResolvedSemanticSchema;
118
+ readonly targetSchema: ResolvedSemanticSchema;
119
+ }) => RelationTemporalPlan | undefined;
120
+ }
121
+ export interface PlannerPeriodEvaluation {
122
+ readonly group: PredItemType;
123
+ readonly property: ResolvedSemanticProperty;
124
+ readonly periods: readonly {
125
+ readonly label: string;
126
+ readonly asOf: string;
127
+ }[];
128
+ readonly source: {
129
+ readonly kind: 'interval';
130
+ readonly start: ResolvedSemanticProperty;
131
+ readonly end: ResolvedSemanticProperty;
132
+ } | {
133
+ readonly kind: 'latest';
134
+ readonly timestamp: ResolvedSemanticProperty;
135
+ };
136
+ readonly rewriteQuery?: (query: QueryType | undefined) => QueryType | undefined;
137
+ readonly rewritePred?: (pred: PredItemType) => PredItemType;
138
+ }
139
+ export interface PlannerPeriodDefinition {
140
+ readonly resolve: (logicform: LogicformType, schema: ResolvedSemanticSchema) => PlannerPeriodEvaluation | undefined;
141
+ }
142
+ /** A field-level query Operator spanning normalization, planning, and SQL compilation. */
143
+ export interface QueryOperatorDefinition {
144
+ readonly name: string;
145
+ /** Validate the full field condition before this exclusive Operator is normalized. */
146
+ readonly validateCondition?: (condition: Readonly<Record<string, unknown>>) => void;
147
+ readonly normalize: (value: unknown, context: QueryOperatorNormalizeContext) => unknown;
148
+ readonly authorize?: (value: unknown, context: QueryOperatorAuthorizeContext) => void;
149
+ readonly plan: (value: unknown, context: QueryOperatorPlanContext) => QueryOperatorPlanResult;
150
+ readonly compile: (value: unknown, context: QueryOperatorCompileContext) => string;
151
+ }
11
152
  export interface SemanticDBPlugin {
12
153
  /** Stable name used for diagnostics and duplicate detection. */
13
154
  readonly name: string;
14
155
  readonly schemaMetadata?: SchemaMetadataPlugin;
156
+ readonly propertyMetadata?: PropertyMetadataPlugin;
157
+ /** Prepare canonical v2 Schema metadata before Properties are resolved. */
158
+ readonly prepareSchema?: (schema: SemanticSchemaDraft) => SemanticSchemaDraft;
159
+ /** Validate invariants that require the complete resolved Schema. */
160
+ readonly validateResolvedSchema?: (schema: ResolvedSemanticSchema) => void;
15
161
  /** Legacy-only Schema fields removed after normalizeLegacySchema runs. */
16
162
  readonly legacySchemaKeys?: readonly string[];
17
163
  readonly normalizeLegacySchema?: (context: LegacySchemaPluginContext) => Readonly<Record<string, unknown>>;
18
164
  readonly resolveEntityFilterProperty?: (schema: ResolvedSemanticSchema) => ResolvedSemanticProperty | undefined;
19
165
  readonly operators?: readonly OperatorDefinition[];
166
+ readonly semanticTypes?: readonly SemanticTypeDefinition[];
167
+ /** Planner-level semantic rewrites contributed by this capability. */
168
+ readonly plannerSemantics?: readonly PlannerSemanticRule[];
169
+ readonly queryOperators?: readonly QueryOperatorDefinition[];
170
+ /** Translations owned by this capability. Explicit execution locales override these. */
171
+ readonly locales?: readonly LocaleDefinition[];
172
+ readonly outputHandlers?: readonly OutputHandlerDefinition[];
173
+ /** Build the internal query used to resolve a shared temporal data watermark. */
174
+ readonly createTimeWatermarkLogicform?: (context: TimeWatermarkLogicformContext) => LogicformType;
175
+ readonly mappingGranularity?: MappingGranularityPlugin;
176
+ /** Extend physical mapping validation and candidate selection beyond granularity. */
177
+ readonly schemaMapping?: SchemaMappingPlugin;
178
+ /** Recognize a Schema whose rows own half-open validity intervals. */
179
+ readonly intervalSemantics?: IntervalSemanticsDefinition;
180
+ /** Add temporal conditions to a logical relation without coupling the core to a model. */
181
+ readonly relationSemantics?: RelationSemanticsDefinition;
182
+ /** Turn a bounded time group into a generic generated-period source. */
183
+ readonly plannerPeriod?: PlannerPeriodDefinition;
20
184
  }
@@ -0,0 +1,5 @@
1
+ import type { ResolvedSemanticSchema } from '../../semantic-types/index';
2
+ import type { IntervalSemanticProperties } from '../types';
3
+ export type ValidityProperties = IntervalSemanticProperties;
4
+ /** Recognize a stable entity whose physical rows are valid over half-open intervals. */
5
+ export declare const resolveValidityProperties: (schema: ResolvedSemanticSchema) => ValidityProperties | undefined;
@@ -1,6 +1,15 @@
1
+ import type { SemanticDBPlugin } from '../types';
2
+ declare module '../../operators/types' {
3
+ interface ResultPropertyTemporalMetadataExtensions {
4
+ readonly validity: {
5
+ readonly kind: 'validity';
6
+ };
7
+ }
8
+ }
1
9
  export { resolveValidityProperties } from './classification';
2
10
  export type { ValidityProperties } from './classification';
3
11
  export { applyValidityQuery } from './query-policy';
4
12
  export { hasValidityTimeGroup, removeValidityTimeCondition, resolveValidityPeriodSpec, } from './periods';
5
13
  export type { ValidityPeriod, ValidityPeriodSpec } from './periods';
6
14
  export { validitySemanticRule } from './rule';
15
+ export declare const validityPlugin: SemanticDBPlugin;
@@ -1,5 +1,5 @@
1
- import type { LogicformType, PredItemType, QueryType } from '../../../logicform-types';
2
- import type { TimeGranularity } from '../../../semantic-types/index';
1
+ import type { LogicformType, PredItemType, QueryType } from '../../logicform-types';
2
+ import type { TimeGranularity } from '../../semantic-types/index';
3
3
  import type { ValidityProperties } from './classification';
4
4
  export interface ValidityPeriod {
5
5
  readonly label: string;
@@ -12,5 +12,4 @@ export interface ValidityPeriodSpec {
12
12
  }
13
13
  export declare const hasValidityTimeGroup: (logicform: LogicformType, properties: ValidityProperties) => boolean;
14
14
  export declare const removeValidityTimeCondition: (query: QueryType | undefined, properties: ValidityProperties) => QueryType | undefined;
15
- /** Resolve a bounded virtual-time grouping into explicit period-end instants. */
16
15
  export declare const resolveValidityPeriodSpec: (logicform: LogicformType, properties: ValidityProperties) => ValidityPeriodSpec | undefined;
@@ -1,4 +1,3 @@
1
- import type { QueryType } from '../../../logicform-types';
1
+ import type { QueryType } from '../../logicform-types';
2
2
  import type { ValidityProperties } from './classification';
3
- /** Rewrite a public time-axis condition to the half-open validity interval [start, end). */
4
3
  export declare const applyValidityQuery: (query: QueryType | undefined, properties: ValidityProperties) => QueryType | undefined;
@@ -1,2 +1,2 @@
1
- import type { PlannerSemanticRule } from '../registry';
1
+ import type { PlannerSemanticRule } from '../../planner/index';
2
2
  export declare const validitySemanticRule: PlannerSemanticRule;
@@ -0,0 +1,3 @@
1
+ import type { SemanticTypeDefinition } from '../../semantic-types/index';
2
+ export declare const startDateSemanticType: SemanticTypeDefinition;
3
+ export declare const endDateSemanticType: SemanticTypeDefinition;
@@ -4,4 +4,4 @@ export declare const parseDailyExpireAt: (value: string) => {
4
4
  readonly minute: number;
5
5
  readonly second: number;
6
6
  } | undefined;
7
- export declare const validateSourceFreshness: (definition: SchemaMappingDefinition) => void;
7
+ export declare const validateSourceFreshness: (definition: Pick<SchemaMappingDefinition, "freshness">) => void;
@@ -0,0 +1,5 @@
1
+ import type { SemanticDBPlugin } from '../plugins/types';
2
+ import type { TimeGranularity } from '../semantic-types/index';
3
+ import type { SchemaMappingGranularity } from './types';
4
+ export declare const isMappingTimeGranularity: (value: unknown) => value is TimeGranularity;
5
+ export declare const isSchemaMappingGranularity: (value: unknown, plugins?: readonly SemanticDBPlugin[]) => value is SchemaMappingGranularity;
@@ -1,6 +1,7 @@
1
1
  export { SchemaMappingRegistry } from './registry';
2
2
  export { parseDailyExpireAt } from './freshness';
3
- export type { SchemaMappingDefinition, SchemaMappingItem, SourceFreshnessPolicy } from './types';
3
+ export { isMappingTimeGranularity, isSchemaMappingGranularity, } from './granularity';
4
+ export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, } from './types';
4
5
  export type { SchemaMappingPredDefinition, SchemaMappingPredMatch, } from './types';
5
6
  export { fromYiAskSchemaMapping } from './yiask';
6
7
  export type { YiAskSchemaMappingItem, YiAskSchemaMappingRecord } from './yiask';
@@ -1,9 +1,11 @@
1
+ import type { SemanticDBPlugin } from '../plugins/index';
1
2
  import type { SchemaMappingDefinition } from './types';
2
3
  export declare class SchemaMappingRegistry {
3
4
  #private;
4
- constructor(definitions?: readonly SchemaMappingDefinition[]);
5
+ readonly plugins: readonly SemanticDBPlugin[];
6
+ constructor(definitions?: readonly SchemaMappingDefinition[], plugins?: readonly SemanticDBPlugin[]);
5
7
  register(definition: SchemaMappingDefinition): this;
6
- get(schemaId: string): SchemaMappingDefinition;
8
+ get(schemaId: string, connectionId?: string): SchemaMappingDefinition;
7
9
  list(schemaId: string): readonly SchemaMappingDefinition[];
8
- findSource(schemaId: string, source: string): SchemaMappingDefinition | undefined;
10
+ findSource(schemaId: string, source: string, connectionId?: string): SchemaMappingDefinition | undefined;
9
11
  }
@@ -1,4 +1,10 @@
1
1
  import type { PredItemType, QueryType } from '../logicform-types';
2
+ import type { TimeGranularity } from '../semantic-types/index';
3
+ /** Plugin-owned physical grains extend this interface through module augmentation. */
4
+ export interface SchemaMappingGranularityExtensions {
5
+ }
6
+ /** Finest physical grain represented by one mapped Property column. */
7
+ export type SchemaMappingGranularity = TimeGranularity | SchemaMappingGranularityExtensions[keyof SchemaMappingGranularityExtensions];
2
8
  export type SourceFreshnessPolicy = {
3
9
  readonly mode: 'ttl';
4
10
  readonly ttlSeconds: number;
@@ -24,9 +30,34 @@ export interface SchemaMappingPredDefinition {
24
30
  }
25
31
  export interface SchemaMappingItem {
26
32
  readonly sourceColumn?: string;
33
+ /** Enrichment id that owns sourceColumn. Missing means the mapping's base source. */
34
+ readonly sourceRef?: string;
27
35
  readonly mappingType?: 'property' | 'predItem' | 'ignored';
28
36
  readonly propertyTarget?: readonly string[];
29
37
  readonly predItem?: PredItemType;
38
+ /** Finest physical grain of a mapped Property. */
39
+ readonly granularity?: SchemaMappingGranularity;
40
+ }
41
+ export interface SchemaMappingEnrichmentKey {
42
+ /** Physical column on the mapping's base source. */
43
+ readonly baseColumn: string;
44
+ /** Physical entity-id column on the enrichment source. */
45
+ readonly targetColumn: string;
46
+ }
47
+ export interface SchemaMappingPointTemporalDefinition {
48
+ readonly kind: 'point';
49
+ /** Point whose containing base-source interval owns the feature row. */
50
+ readonly pointColumn: string;
51
+ }
52
+ /** A same-connection physical extension of one logical Schema. */
53
+ export interface SchemaMappingEnrichmentDefinition {
54
+ readonly id: string;
55
+ readonly source: string;
56
+ readonly sourceSql?: string;
57
+ readonly on: readonly SchemaMappingEnrichmentKey[];
58
+ readonly temporal?: SchemaMappingPointTemporalDefinition;
59
+ /** Missing means queries depending on this enrichment are not cached. */
60
+ readonly freshness?: SourceFreshnessPolicy;
30
61
  }
31
62
  export interface SchemaMappingDefinition {
32
63
  /** Stable identity when a Schema has multiple physical mappings. */
@@ -38,6 +69,8 @@ export interface SchemaMappingDefinition {
38
69
  readonly source: string;
39
70
  /** Optional trusted query compiled as a derived-table source instead of reading source directly. */
40
71
  readonly sourceSql?: string;
72
+ /** Optional physical tables that extend base rows without becoming logical Schema relations. */
73
+ readonly enrichments?: readonly SchemaMappingEnrichmentDefinition[];
41
74
  /** Unified logical-to-physical mappings for properties and conditional PredItems. */
42
75
  readonly mappings?: readonly SchemaMappingItem[];
43
76
  /** Higher values win when multiple candidates cover the same LogicForm. */
@@ -45,3 +78,13 @@ export interface SchemaMappingDefinition {
45
78
  /** Missing means queries depending on this physical source are not cached. */
46
79
  readonly freshness?: SourceFreshnessPolicy;
47
80
  }
81
+ export interface RejectedSchemaMapping {
82
+ readonly mappingId: string;
83
+ readonly reason: string;
84
+ }
85
+ /** Planner diagnostics for one physical Schema mapping decision. */
86
+ export interface SchemaMappingSelection {
87
+ readonly schemaId: string;
88
+ readonly selectedMappingId: string;
89
+ readonly rejectedMappings: readonly RejectedSchemaMapping[];
90
+ }
@@ -1,10 +1,13 @@
1
+ import type { SemanticDBPlugin } from '../plugins/index';
1
2
  import type { PredItemType } from '../logicform-types';
2
- import type { SchemaMappingDefinition } from './types';
3
+ import type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingGranularity } from './types';
3
4
  export interface YiAskSchemaMappingItem {
4
5
  readonly sourceColumn?: string;
6
+ readonly sourceRef?: string;
5
7
  readonly mappingType?: 'property' | 'predItem' | 'ignored';
6
8
  readonly propertyTarget?: readonly string[];
7
9
  readonly predItem?: PredItemType;
10
+ readonly granularity?: SchemaMappingGranularity;
8
11
  }
9
12
  export interface YiAskSchemaMappingRecord {
10
13
  readonly id: string | number;
@@ -16,7 +19,8 @@ export interface YiAskSchemaMappingRecord {
16
19
  readonly physicalDatabase?: string;
17
20
  readonly physicalSchema?: string;
18
21
  readonly physicalTable?: string;
22
+ readonly enrichments?: readonly SchemaMappingEnrichmentDefinition[];
19
23
  readonly mappings: readonly YiAskSchemaMappingItem[];
20
24
  readonly enabled?: boolean;
21
25
  }
22
- export declare const fromYiAskSchemaMapping: (record: YiAskSchemaMappingRecord) => SchemaMappingDefinition;
26
+ export declare const fromYiAskSchemaMapping: (record: YiAskSchemaMappingRecord, plugins?: readonly SemanticDBPlugin[]) => SchemaMappingDefinition;
@@ -1,9 +1,11 @@
1
+ import type { SemanticDBPlugin } from '../plugins/index';
1
2
  import { SemanticTypeRegistry } from './registry';
2
3
  export { builtinSemanticTypes } from './builtins/index';
3
4
  export { SemanticTypeRegistry } from './registry';
4
5
  export { resolveSchema } from './resolve-schema';
5
6
  export { validateResolvedSchema } from './validate-resolved-schema';
6
7
  export { normalizePrimalQuery } from './primal-types/index';
7
- export type { ComparableCategoryDefinition, PropertyHierarchyDefinition, PropertySqlDefinition, PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, LegacySemanticSchemaMetadata, ResolvedSemanticSchemaMetadata, SemanticSchemaMetadata, SemanticTypeNormalizeContext, SemanticPeriodEvaluationContext, SemanticTypeResultContext, SemanticTypeResultProperty, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, TimeGranularity, TemporalSemantics, TimeWatermarkPolicy, } from './types';
8
- export type { HierarchyDefinition, HierarchyLevelDefinition, ResolvedHierarchyDefinition, } from '../plugins/hierarchy/index';
9
- export declare const createSemanticTypeRegistry: () => SemanticTypeRegistry;
8
+ export type { ComparableCategoryDefinition, PropertyHierarchyDefinition, PropertySqlDefinition, PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, LegacySemanticSchemaMetadata, ResolvedSemanticSchemaMetadata, SemanticSchemaMetadata, SemanticTypeNormalizeContext, SemanticPeriodEvaluationContext, SemanticTypeResultContext, SemanticTypeResultProperty, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, TimeGranularity, TimeWatermarkPolicy, } from './types';
9
+ export declare const createSemanticTypeRegistry: (plugins?: readonly SemanticDBPlugin[]) => SemanticTypeRegistry;
10
+ /** Copies a caller-owned Registry and appends plugin types without mutating the input. */
11
+ export declare const addPluginSemanticTypes: (registry: SemanticTypeRegistry, plugins: readonly SemanticDBPlugin[]) => SemanticTypeRegistry;
@@ -5,6 +5,8 @@ export declare class SemanticTypeRegistry {
5
5
  constructor(definitions?: readonly SemanticTypeDefinition[]);
6
6
  register(definition: SemanticTypeDefinition): this;
7
7
  get(name: string): SemanticTypeDefinition;
8
+ has(name: string): boolean;
9
+ definitions(): readonly SemanticTypeDefinition[];
8
10
  requiresPerPeriodEvaluation(context: {
9
11
  readonly logicform: LogicformType;
10
12
  readonly pred: PredItemType;
@@ -1,4 +1,4 @@
1
1
  import type { SemanticDBPlugin } from '../plugins/index';
2
2
  import type { SemanticTypeRegistry } from './registry';
3
3
  import type { ResolvedSemanticSchema, SemanticSchemaDraft } from './types';
4
- export declare const resolveSchema: (schema: SemanticSchemaDraft, registry: SemanticTypeRegistry, externalPlugins?: readonly SemanticDBPlugin[]) => ResolvedSemanticSchema;
4
+ export declare const resolveSchema: (inputSchema: SemanticSchemaDraft, registry: SemanticTypeRegistry, externalPlugins?: readonly SemanticDBPlugin[]) => ResolvedSemanticSchema;
@@ -3,7 +3,6 @@ import type { LogicformType, PredItemType } from '../logicform-types';
3
3
  /** Canonical primitive types use `entity`; `object` remains a legacy input alias. */
4
4
  export type PrimalType = 'string' | 'number' | 'boolean' | 'date' | 'entity' | 'object';
5
5
  export type TimeGranularity = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
6
- export type TemporalSemantics = 'normal' | 'snapshot';
7
6
  export type TimeWatermarkPolicy = {
8
7
  readonly type: 'database_latest';
9
8
  } | {
@@ -37,15 +36,10 @@ export interface SemanticPropertyDraft extends Omit<PropertyTypeDraft, '_id' | '
37
36
  readonly primal_type?: PrimalType;
38
37
  readonly isArray?: boolean;
39
38
  readonly granularity?: TimeGranularity;
40
- /** Default hierarchy level when this Property references a hierarchy Entity. */
41
- readonly level?: string;
42
39
  /** Derived during schema resolution from whether the property has udf.sql. */
43
40
  readonly is_dynamic?: boolean;
44
41
  readonly udf?: PropertySqlDefinition;
45
42
  readonly comparable?: ComparableCategoryDefinition;
46
- readonly timeWatermark?: TimeWatermarkPolicy;
47
- /** Same-Schema drill relationship. `up` identifies the single-valued parent Property. */
48
- readonly hierarchy?: PropertyHierarchyDefinition;
49
43
  }
50
44
  export interface ResolvedSemanticProperty extends Omit<SemanticPropertyDraft, 'id' | 'primal_type' | 'isArray' | 'is_dynamic'> {
51
45
  readonly id: string;
@@ -57,19 +51,11 @@ export interface SemanticSchemaDraft extends Omit<SchemaTypeDraft, '_id' | 'id'
57
51
  readonly [key: string]: unknown;
58
52
  readonly id: string;
59
53
  readonly properties: readonly SemanticPropertyDraft[];
60
- readonly temporalSemantics?: TemporalSemantics;
61
- readonly timeWatermark?: TimeWatermarkPolicy;
62
- /** Property that stores the parent node id for recursive tree queries. */
63
- readonly parentProperty?: string;
64
54
  }
65
55
  export interface ResolvedSemanticSchema extends Omit<SchemaTypeDraft, '_id' | 'id' | 'sid' | 'properties' | 'db' | 'from' | 'fromSQL' | 'projections' | keyof SemanticSchemaMetadata | keyof LegacySemanticSchemaMetadata>, ResolvedSemanticSchemaMetadata {
66
56
  readonly [key: string]: unknown;
67
57
  readonly id: string;
68
58
  readonly properties: readonly ResolvedSemanticProperty[];
69
- readonly temporalSemantics?: TemporalSemantics;
70
- readonly timeWatermark?: TimeWatermarkPolicy;
71
- /** Canonical logical name of the parent Property used by recursive tree queries. */
72
- readonly parentProperty?: string;
73
59
  }
74
60
  export interface SemanticTypeNormalizeContext {
75
61
  readonly schema: ResolvedSemanticSchema;
@@ -1,6 +1,3 @@
1
- import type { ResolvedSemanticProperty, TemporalSemantics } from './types';
1
+ import type { ResolvedSemanticProperty } from './types';
2
2
  /** Validates invariants that require the complete set of resolved Properties. */
3
- export declare const validateResolvedSchema: (properties: readonly ResolvedSemanticProperty[], options?: {
4
- readonly temporalSemantics?: TemporalSemantics;
5
- readonly schemaId?: string;
6
- }) => void;
3
+ export declare const validateResolvedSchema: (properties: readonly ResolvedSemanticProperty[]) => void;