semanticdb-v2 2.0.0-alpha.1 → 2.0.0-alpha.11

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 (278) hide show
  1. package/README.md +346 -46
  2. package/dist/cache/index.d.ts +2 -1
  3. package/dist/cache/manager.d.ts +5 -0
  4. package/dist/cache/registry.d.ts +14 -0
  5. package/dist/cache/types.d.ts +17 -0
  6. package/dist/close.d.ts +1 -0
  7. package/dist/compatibility/index.d.ts +2 -2
  8. package/dist/compatibility/logicform.d.ts +1 -7
  9. package/dist/compiler/compile-cte.d.ts +17 -2
  10. package/dist/compiler/index.d.ts +2 -1
  11. package/dist/compiler/shorten-sql.d.ts +1 -1
  12. package/dist/errors.d.ts +3 -0
  13. package/dist/executor/compatibility.d.ts +13 -0
  14. package/dist/executor/components.d.ts +8 -3
  15. package/dist/executor/connection-registry.d.ts +1 -12
  16. package/dist/executor/execute-query.d.ts +8 -2
  17. package/dist/executor/execute.d.ts +1 -1
  18. package/dist/executor/federated-execution.d.ts +39 -0
  19. package/dist/executor/fetch-entities.d.ts +7 -1
  20. package/dist/executor/index.d.ts +1 -1
  21. package/dist/executor/partition.d.ts +17 -0
  22. package/dist/executor/result-hydrator/types.d.ts +2 -0
  23. package/dist/executor/row-identity.d.ts +2 -1
  24. package/dist/executor/total.d.ts +11 -0
  25. package/dist/executor/types.d.ts +70 -21
  26. package/dist/i18n/index.d.ts +4 -0
  27. package/dist/i18n/locales/en-US.d.ts +2 -0
  28. package/dist/i18n/locales/zh-CN.d.ts +2 -0
  29. package/dist/i18n/registry.d.ts +13 -0
  30. package/dist/i18n/types.d.ts +9 -0
  31. package/dist/index.d.ts +18 -16
  32. package/dist/logicform/dimensions.d.ts +16 -0
  33. package/dist/logicform/index.d.ts +2 -0
  34. package/dist/logicform-types.d.ts +56 -36
  35. package/dist/normalizer/core.d.ts +17 -3
  36. package/dist/normalizer/default-pred-name.d.ts +2 -0
  37. package/dist/normalizer/index.d.ts +1 -0
  38. package/dist/normalizer/pred-expression.d.ts +6 -0
  39. package/dist/normalizer/property-resolve.d.ts +6 -0
  40. package/dist/operators/builtins/constant.d.ts +2 -0
  41. package/dist/operators/builtins/period-name.d.ts +2 -1
  42. package/dist/operators/builtins/period-value.d.ts +2 -0
  43. package/dist/operators/builtins/query-expression.d.ts +3 -0
  44. package/dist/operators/builtins/scalar-extremum.d.ts +3 -0
  45. package/dist/operators/index.d.ts +2 -1
  46. package/dist/operators/registry.d.ts +5 -3
  47. package/dist/operators/resolve.d.ts +3 -0
  48. package/dist/operators/types.d.ts +110 -50
  49. package/dist/physical/clickhouse-provider.d.ts +29 -2
  50. package/dist/physical/connection-registry.d.ts +13 -0
  51. package/dist/physical/connection.d.ts +57 -15
  52. package/dist/physical/dameng-provider.d.ts +66 -0
  53. package/dist/physical/databricks-provider.d.ts +88 -0
  54. package/dist/physical/db-connector.d.ts +23 -0
  55. package/dist/physical/display-query.d.ts +3 -0
  56. package/dist/physical/doris-provider.d.ts +7 -1
  57. package/dist/physical/duckdb-coordinator-provider.d.ts +37 -0
  58. package/dist/physical/gbase-provider.d.ts +11 -0
  59. package/dist/physical/index.d.ts +24 -9
  60. package/dist/physical/load-driver.d.ts +1 -0
  61. package/dist/physical/maxcompute-provider.d.ts +44 -0
  62. package/dist/physical/mysql-protocol-provider.d.ts +27 -7
  63. package/dist/physical/mysql-provider.d.ts +2 -1
  64. package/dist/physical/oracle-provider.d.ts +21 -4
  65. package/dist/physical/postgresql-provider.d.ts +25 -4
  66. package/dist/physical/provider.d.ts +66 -2
  67. package/dist/physical/snowflake-provider.d.ts +20 -3
  68. package/dist/physical/sqlserver-provider.d.ts +69 -0
  69. package/dist/physical/starrocks-provider.d.ts +7 -1
  70. package/dist/physical/table-description.d.ts +5 -0
  71. package/dist/physical/table-discovery.d.ts +10 -0
  72. package/dist/planner/build-lineage.d.ts +1 -1
  73. package/dist/planner/build-mapping-source-plan.d.ts +6 -0
  74. package/dist/planner/create-logical-plan.d.ts +11 -0
  75. package/dist/planner/index.d.ts +4 -2
  76. package/dist/planner/mapping-granularity.d.ts +7 -0
  77. package/dist/planner/rewrite-nested-components.d.ts +8 -0
  78. package/dist/planner/select-schema-mapping.d.ts +19 -2
  79. package/dist/planner/semantics/index.d.ts +0 -3
  80. package/dist/planner/semantics/periods.d.ts +13 -0
  81. package/dist/planner/semantics/registry-defaults.d.ts +2 -1
  82. package/dist/planner/semantics/registry.d.ts +2 -1
  83. package/dist/planner/types.d.ts +106 -14
  84. package/dist/plugins/hierarchy/index.d.ts +1 -1
  85. package/dist/plugins/hierarchy/mapping-granularity.d.ts +4 -0
  86. package/dist/plugins/hierarchy/types.d.ts +20 -2
  87. package/dist/plugins/index.d.ts +10 -1
  88. package/dist/{planner/semantics → plugins}/observation/classification.d.ts +1 -1
  89. package/dist/plugins/observation/index.d.ts +17 -0
  90. package/dist/{planner/semantics → plugins}/observation/operator-policy.d.ts +4 -5
  91. package/dist/plugins/observation/periods.d.ts +18 -0
  92. package/dist/{planner/semantics → plugins}/observation/rule.d.ts +1 -1
  93. package/dist/plugins/observation/types.d.ts +3 -0
  94. package/dist/plugins/property-hierarchy/index.d.ts +11 -0
  95. package/dist/plugins/recursive/index.d.ts +26 -0
  96. package/dist/plugins/temporal/index.d.ts +13 -0
  97. package/dist/plugins/types.d.ts +165 -1
  98. package/dist/plugins/validity/classification.d.ts +5 -0
  99. package/dist/plugins/validity/index.d.ts +15 -0
  100. package/dist/plugins/validity/periods.d.ts +15 -0
  101. package/dist/plugins/validity/query-policy.d.ts +3 -0
  102. package/dist/plugins/validity/rule.d.ts +2 -0
  103. package/dist/plugins/validity/semantic-types.d.ts +3 -0
  104. package/dist/schema/dependent-projection.d.ts +8 -0
  105. package/dist/schema/entity-identity.d.ts +1 -1
  106. package/dist/schema/index.d.ts +1 -0
  107. package/dist/schema-mappings/freshness.d.ts +1 -1
  108. package/dist/schema-mappings/granularity.d.ts +5 -0
  109. package/dist/schema-mappings/index.d.ts +5 -1
  110. package/dist/schema-mappings/registry.d.ts +7 -3
  111. package/dist/schema-mappings/supported-dimensions.d.ts +10 -0
  112. package/dist/schema-mappings/types.d.ts +59 -9
  113. package/dist/schema-mappings/yiask.d.ts +27 -0
  114. package/dist/semantic-types/builtins/tag.d.ts +2 -0
  115. package/dist/semantic-types/index.d.ts +5 -3
  116. package/dist/semantic-types/registry.d.ts +2 -0
  117. package/dist/semantic-types/resolve-schema.d.ts +1 -1
  118. package/dist/semantic-types/types.d.ts +51 -11
  119. package/dist/semantic-types/validate-resolved-schema.d.ts +2 -5
  120. package/dist/semanticdb.esm.js +5 -0
  121. package/dist/semanticdb.js +5 -0
  122. package/package.json +49 -17
  123. package/dist/cache/expiry.js +0 -1
  124. package/dist/cache/identity.js +0 -1
  125. package/dist/cache/redis-query-cache.js +0 -1
  126. package/dist/cache/serialization.js +0 -1
  127. package/dist/calendar/constants.d.ts +0 -7
  128. package/dist/calendar/constants.js +0 -1
  129. package/dist/calendar/index.d.ts +0 -6
  130. package/dist/calendar/provider-relation-store.d.ts +0 -9
  131. package/dist/calendar/provider-relation-store.js +0 -1
  132. package/dist/calendar/resolver.d.ts +0 -10
  133. package/dist/calendar/resolver.js +0 -1
  134. package/dist/calendar/system-schemas.d.ts +0 -3
  135. package/dist/calendar/system-schemas.js +0 -1
  136. package/dist/calendar/types.d.ts +0 -31
  137. package/dist/compatibility/logicform.js +0 -1
  138. package/dist/compiler/compile-cte.js +0 -1
  139. package/dist/compiler/compile-plan.js +0 -1
  140. package/dist/compiler/shorten-sql.js +0 -2
  141. package/dist/custom-functions/custom-functions.d.ts +0 -6
  142. package/dist/custom-functions/custom-functions.js +0 -1
  143. package/dist/custom-functions/index.d.ts +0 -3
  144. package/dist/custom-functions/operator-adapter.d.ts +0 -12
  145. package/dist/custom-functions/operator-adapter.js +0 -1
  146. package/dist/custom-functions/types.d.ts +0 -62
  147. package/dist/errors.js +0 -1
  148. package/dist/executor/compatibility.js +0 -1
  149. package/dist/executor/components.js +0 -1
  150. package/dist/executor/connection-registry.js +0 -1
  151. package/dist/executor/evaluate.js +0 -1
  152. package/dist/executor/execute-query.js +0 -1
  153. package/dist/executor/execute.js +0 -1
  154. package/dist/executor/fetch-entities.js +0 -1
  155. package/dist/executor/result-hydrator/entity-loader.js +0 -1
  156. package/dist/executor/result-hydrator/format-values.js +0 -1
  157. package/dist/executor/result-hydrator/hydrate-result.js +0 -1
  158. package/dist/executor/result-hydrator/missing-entity.js +0 -1
  159. package/dist/executor/result-hydrator/populate-entities.js +0 -1
  160. package/dist/executor/row-identity.js +0 -1
  161. package/dist/index.js +0 -1
  162. package/dist/logicform-types.js +0 -1
  163. package/dist/normalizer/core.js +0 -1
  164. package/dist/normalizer/default-pred-name.js +0 -1
  165. package/dist/normalizer/entity-id.js +0 -1
  166. package/dist/normalizer/groupby.js +0 -1
  167. package/dist/normalizer/normalize-logicform.js +0 -1
  168. package/dist/normalizer/pagination.js +0 -1
  169. package/dist/normalizer/pred-query-name.js +0 -1
  170. package/dist/normalizer/preds.js +0 -1
  171. package/dist/normalizer/query.js +0 -1
  172. package/dist/normalizer/version.js +0 -1
  173. package/dist/operators/builtins/abs.js +0 -1
  174. package/dist/operators/builtins/accumulate.js +0 -1
  175. package/dist/operators/builtins/add.js +0 -1
  176. package/dist/operators/builtins/arithmetic.js +0 -1
  177. package/dist/operators/builtins/average-per-period.js +0 -1
  178. package/dist/operators/builtins/avg.js +0 -1
  179. package/dist/operators/builtins/case.js +0 -1
  180. package/dist/operators/builtins/concat.js +0 -1
  181. package/dist/operators/builtins/count-distinct.js +0 -1
  182. package/dist/operators/builtins/count.js +0 -1
  183. package/dist/operators/builtins/date-bucket.js +0 -1
  184. package/dist/operators/builtins/divide.js +0 -1
  185. package/dist/operators/builtins/index.js +0 -1
  186. package/dist/operators/builtins/max.js +0 -1
  187. package/dist/operators/builtins/min.js +0 -1
  188. package/dist/operators/builtins/multiply.js +0 -1
  189. package/dist/operators/builtins/newly.js +0 -1
  190. package/dist/operators/builtins/period-boundary.js +0 -1
  191. package/dist/operators/builtins/period-difference.js +0 -1
  192. package/dist/operators/builtins/period-growth.js +0 -1
  193. package/dist/operators/builtins/period-name.js +0 -1
  194. package/dist/operators/builtins/period-shift.js +0 -1
  195. package/dist/operators/builtins/rank.js +0 -1
  196. package/dist/operators/builtins/row-number.js +0 -1
  197. package/dist/operators/builtins/share-of-total.js +0 -1
  198. package/dist/operators/builtins/sql.js +0 -1
  199. package/dist/operators/builtins/substring.js +0 -1
  200. package/dist/operators/builtins/subtract.js +0 -1
  201. package/dist/operators/builtins/sum.js +0 -1
  202. package/dist/operators/builtins/time-range.js +0 -1
  203. package/dist/operators/groupby.js +0 -1
  204. package/dist/operators/index.js +0 -1
  205. package/dist/operators/registry.js +0 -1
  206. package/dist/operators/sql-expression.js +0 -1
  207. package/dist/permissions/permissions.js +0 -1
  208. package/dist/physical/clickhouse-provider.js +0 -1
  209. package/dist/physical/connection.js +0 -1
  210. package/dist/physical/display-query.js +0 -1
  211. package/dist/physical/doris-provider.js +0 -1
  212. package/dist/physical/mysql-compatible-sql.js +0 -1
  213. package/dist/physical/mysql-protocol-provider.js +0 -1
  214. package/dist/physical/mysql-provider.js +0 -1
  215. package/dist/physical/oracle-provider.js +0 -1
  216. package/dist/physical/postgresql-provider.js +0 -1
  217. package/dist/physical/snowflake-provider.js +0 -1
  218. package/dist/physical/starrocks-provider.js +0 -1
  219. package/dist/planner/build-lineage.js +0 -1
  220. package/dist/planner/create-logical-plan.js +0 -1
  221. package/dist/planner/select-schema-mapping.js +0 -1
  222. package/dist/planner/semantics/lifecycle/classification.d.ts +0 -7
  223. package/dist/planner/semantics/lifecycle/classification.js +0 -1
  224. package/dist/planner/semantics/lifecycle/index.d.ts +0 -3
  225. package/dist/planner/semantics/lifecycle/query-policy.d.ts +0 -3
  226. package/dist/planner/semantics/lifecycle/query-policy.js +0 -1
  227. package/dist/planner/semantics/lifecycle/rule.d.ts +0 -2
  228. package/dist/planner/semantics/lifecycle/rule.js +0 -1
  229. package/dist/planner/semantics/observation/classification.js +0 -1
  230. package/dist/planner/semantics/observation/index.d.ts +0 -4
  231. package/dist/planner/semantics/observation/operator-policy.js +0 -1
  232. package/dist/planner/semantics/observation/rule.js +0 -1
  233. package/dist/planner/semantics/observation/types.d.ts +0 -3
  234. package/dist/planner/semantics/registry-defaults.js +0 -1
  235. package/dist/planner/semantics/registry.js +0 -1
  236. package/dist/planner/types.js +0 -1
  237. package/dist/plugins/hierarchy/compatibility.js +0 -1
  238. package/dist/plugins/hierarchy/entity-identity.js +0 -1
  239. package/dist/plugins/hierarchy/index.js +0 -1
  240. package/dist/plugins/hierarchy/operator.js +0 -1
  241. package/dist/plugins/hierarchy/resolve-schema.js +0 -1
  242. package/dist/plugins/index.js +0 -1
  243. package/dist/schema/entity-identity.js +0 -1
  244. package/dist/schema/resolve-property-path.js +0 -1
  245. package/dist/schema/schema-registry.js +0 -1
  246. package/dist/schema-mappings/freshness.js +0 -1
  247. package/dist/schema-mappings/registry.js +0 -1
  248. package/dist/semantic-types/builtins/boolean.js +0 -1
  249. package/dist/semantic-types/builtins/category.js +0 -1
  250. package/dist/semantic-types/builtins/currency.js +0 -1
  251. package/dist/semantic-types/builtins/date.js +0 -1
  252. package/dist/semantic-types/builtins/duration.js +0 -1
  253. package/dist/semantic-types/builtins/end-date.d.ts +0 -2
  254. package/dist/semantic-types/builtins/end-date.js +0 -1
  255. package/dist/semantic-types/builtins/entity.js +0 -1
  256. package/dist/semantic-types/builtins/file.js +0 -1
  257. package/dist/semantic-types/builtins/human-name.js +0 -1
  258. package/dist/semantic-types/builtins/id.js +0 -1
  259. package/dist/semantic-types/builtins/image.js +0 -1
  260. package/dist/semantic-types/builtins/index.js +0 -1
  261. package/dist/semantic-types/builtins/int.js +0 -1
  262. package/dist/semantic-types/builtins/name.js +0 -1
  263. package/dist/semantic-types/builtins/number.js +0 -1
  264. package/dist/semantic-types/builtins/object.js +0 -1
  265. package/dist/semantic-types/builtins/order.js +0 -1
  266. package/dist/semantic-types/builtins/percentage.js +0 -1
  267. package/dist/semantic-types/builtins/start-date.d.ts +0 -2
  268. package/dist/semantic-types/builtins/start-date.js +0 -1
  269. package/dist/semantic-types/builtins/string.js +0 -1
  270. package/dist/semantic-types/builtins/timestamp.js +0 -1
  271. package/dist/semantic-types/index.js +0 -1
  272. package/dist/semantic-types/primal-types/date.js +0 -1
  273. package/dist/semantic-types/primal-types/index.js +0 -1
  274. package/dist/semantic-types/registry.js +0 -1
  275. package/dist/semantic-types/resolve-schema.js +0 -1
  276. package/dist/semantic-types/validate-resolved-schema.js +0 -1
  277. package/dist/utils/clone.js +0 -1
  278. /package/dist/operators/builtins/{period-boundary.d.ts → period-boundary-expression.d.ts} +0 -0
@@ -19,29 +19,15 @@ export interface AbsoluteDateValue {
19
19
  readonly second?: number;
20
20
  readonly period?: 'am' | 'pm';
21
21
  }
22
- /** A business-calendar period resolved to natural days before planning. */
23
- export interface CalendarDateValue {
24
- readonly calendar: string;
25
- readonly key?: string;
26
- readonly year?: number;
27
- readonly quarter?: number;
28
- readonly month?: number;
29
- readonly week?: number;
30
- readonly day?: number;
31
- readonly relativeDay?: number | readonly number[];
32
- }
33
22
  /** Period reference used by operators such as `$periodShift`. */
34
23
  export type PeriodShiftTime = RelativeDateValue | AbsoluteDateValue;
35
24
  /** A date value before semantic-type normalization. */
36
- export type DateValue = string | RelativeDateValue | AbsoluteDateValue | CalendarDateValue;
37
- export type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$contains' | '$recursive' | '$and' | '$or';
38
- export interface RecursiveQueryType {
39
- readonly schema?: string;
40
- readonly root?: QueryValueType;
41
- readonly roots?: QueryValueType[];
42
- readonly includeSelf?: boolean;
43
- readonly idProperty?: string;
44
- readonly parentProperty?: string;
25
+ export type DateValue = string | RelativeDateValue | AbsoluteDateValue;
26
+ /** Stable entity identity. Numeric IDs must be safe integers. */
27
+ export type EntityIdType = string | number;
28
+ 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>;
29
+ /** Module-augmentation seam for plugin-owned field Query Operators. */
30
+ export interface QueryOperatorExtensions {
45
31
  }
46
32
  export type QueryValueType = null | string | number | boolean | DateValue | RelationQueryType | LogicformType | string[] | number[] | boolean[] | DateValue[] | RelationQueryType[] | LogicformType[];
47
33
  /** A query scoped through an object relation. Version is inherited from the parent LogicForm. */
@@ -50,9 +36,29 @@ export interface RelationQueryType {
50
36
  readonly schema: string;
51
37
  readonly query: QueryType;
52
38
  /** Stable entity identity. `placeholder` preserves context without adding an ID filter. */
53
- readonly entity_id?: string;
39
+ readonly entity_id?: EntityIdType;
54
40
  }
55
41
  export type QueryLogicalOperand = QueryValueType | QueryValueTypeWithCompareOperator;
42
+ /** Apply a scalar pred expression, then test its result against a condition. */
43
+ export interface QueryExpressionType {
44
+ readonly pred: PredItemType;
45
+ readonly condition: QueryLogicalOperand;
46
+ }
47
+ export type NumericQueryOperand = number | number[] | NumericQueryComparison;
48
+ export type NumericQueryComparison = Partial<{
49
+ $eq: number;
50
+ $gt: number;
51
+ $gte: number;
52
+ $lt: number;
53
+ $lte: number;
54
+ $ne: number;
55
+ $in: number[];
56
+ $nin: number[];
57
+ $and: NumericQueryOperand[];
58
+ $or: NumericQueryOperand[];
59
+ }>;
60
+ export type DatePartQueryOperand = NumericQueryOperand;
61
+ export type DatePartQueryComparison = NumericQueryComparison;
56
62
  export type QueryValueTypeWithCompareOperator = Partial<{
57
63
  $eq: QueryValueType;
58
64
  $gt: QueryValueType;
@@ -65,34 +71,49 @@ export type QueryValueTypeWithCompareOperator = Partial<{
65
71
  $exists: QueryValueType;
66
72
  $regex: QueryValueType;
67
73
  $contains: QueryValueType;
74
+ $startsWith: string;
75
+ $length: NumericQueryOperand;
76
+ $second: DatePartQueryOperand;
77
+ $minute: DatePartQueryOperand;
78
+ $hour: DatePartQueryOperand;
79
+ /** ISO weekday: Monday=1 through Sunday=7. */
80
+ $weekday: DatePartQueryOperand;
81
+ /** Day of month. */
82
+ $day: DatePartQueryOperand;
83
+ /** ISO week of year. */
84
+ $week: DatePartQueryOperand;
85
+ $month: DatePartQueryOperand;
86
+ $quarter: DatePartQueryOperand;
87
+ $year: DatePartQueryOperand;
68
88
  args?: {
69
89
  readonly options?: string;
70
90
  };
71
- $recursive: QueryValueType | RecursiveQueryType;
72
91
  $and: QueryLogicalOperand[];
73
92
  $or: QueryLogicalOperand[];
74
- }> & {
93
+ }> & Partial<QueryOperatorExtensions> & {
75
94
  readonly schema?: never;
76
95
  };
77
- export type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryType[] | undefined> & {
96
+ export type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryExpressionType | QueryType[] | undefined> & {
78
97
  readonly $and?: QueryType[];
79
98
  readonly $or?: QueryType[];
99
+ readonly $expr?: QueryExpressionType;
80
100
  };
81
101
  export interface ExpressionItemType {
82
102
  operator?: string;
83
- pred?: string | ExpressionItemType;
84
- /** Structural operands for multi-input operators. Operator options remain in `args`. */
85
- components?: ExpressionItemType[];
103
+ /** Operator input. Arrays represent ordered multi-input predicates. */
104
+ pred?: string | ExpressionItemType | (string | ExpressionItemType)[];
86
105
  name?: string;
87
106
  schema?: string;
88
107
  args?: Record<string, unknown>;
89
108
  }
90
109
  export interface PredItemType extends ExpressionItemType {
91
- pred?: string | PredItemType;
92
- components?: PredItemType[];
110
+ pred?: string | PredItemType | (string | PredItemType)[];
93
111
  query?: QueryType;
94
112
  }
95
- export type LogicformOutputTypeValue = 'url' | 'data' | 'export' | 'sql' | 'sqlComponents';
113
+ /** Module-augmentation seam for plugin-owned output types. */
114
+ export interface LogicformOutputExtensions {
115
+ }
116
+ export type LogicformOutputTypeValue = 'url' | 'data' | 'export' | 'sql' | 'sqlComponents' | Extract<keyof LogicformOutputExtensions, string>;
96
117
  export interface LogicformOutputType {
97
118
  type: LogicformOutputTypeValue;
98
119
  filename?: string;
@@ -102,10 +123,10 @@ export interface LogicformType {
102
123
  version: string;
103
124
  /** Required for a physical leaf. Derived and composed nodes inherit their field space. */
104
125
  schema?: string;
105
- /** Complete child LogicForms whose result columns are combined by their shared row identity. */
106
- logicforms?: LogicformType[];
107
126
  query?: QueryType;
108
127
  preds?: PredItemType[];
128
+ /** Output/reference aliases for properties contributed by another Schema. */
129
+ propertyResolve?: Readonly<Record<string, Readonly<Record<string, string>>>>;
109
130
  groupby?: PredItemType[];
110
131
  sort?: Record<string, 1 | -1>;
111
132
  having?: QueryType;
@@ -115,11 +136,10 @@ export interface LogicformType {
115
136
  page?: number;
116
137
  representation?: RepresentationType;
117
138
  /** Stable entity identity. `placeholder` preserves context without adding an ID filter. */
118
- entity_id?: string;
139
+ entity_id?: EntityIdType;
119
140
  from?: LogicformType;
120
141
  currency?: string;
121
142
  }
143
+ /** Public normalized shape; composition is represented by Planner subplans. */
144
+ export type PublicLogicformType = LogicformType;
122
145
  export declare const isLogicform: (value: unknown) => value is LogicformType;
123
- export declare const isComposedLogicform: (value: LogicformType) => value is LogicformType & {
124
- readonly logicforms: LogicformType[];
125
- };
@@ -2,18 +2,32 @@ import type { LogicformType } from '../logicform-types';
2
2
  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
+ import type { LocaleInput, LocaleRegistry } from '../i18n/index';
5
6
  export interface NormalizeLogicformOptions {
6
7
  readonly semanticTypes: SemanticTypeRegistry;
7
8
  readonly operators?: OperatorRegistry;
8
9
  readonly plugins?: readonly SemanticDBPlugin[];
9
10
  /** Locale used for generated human-readable PredItem names. Defaults to zh-CN. */
10
11
  readonly locale?: string;
12
+ /** Additional or overriding locale files used for generated names. */
13
+ readonly locales?: LocaleInput;
14
+ /** Internal registry shared by recursive normalization calls. */
15
+ readonly localeRegistry?: LocaleRegistry;
11
16
  readonly now?: Date;
12
17
  readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
13
- readonly requestLatestDataDate?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => Promise<Date | undefined>;
14
- readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
18
+ readonly requestTimeWatermark?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty, requestedUpperBound: Date) => Promise<Date | undefined>;
19
+ readonly requestAutoCaseBounds?: (schema: ResolvedSemanticSchema, reference: string, query: LogicformType['query']) => Promise<{
20
+ readonly min: number;
21
+ readonly max: number;
22
+ readonly count: number;
23
+ } | {
24
+ readonly empty: true;
25
+ }>;
26
+ /** Internal root query used to resolve automatic `$case` boundaries. */
27
+ readonly autoCaseQuery?: LogicformType['query'];
28
+ readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema | Promise<ResolvedSemanticSchema>;
15
29
  readonly canProjectProperty?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => boolean;
16
30
  /** Internal recursion hook installed by normalizeLogicform. */
17
31
  readonly normalizeNestedLogicform?: (logicform: LogicformType) => Promise<LogicformType>;
18
32
  }
19
- export declare const resolveLogicformSchema: (logicform: LogicformType, currentSchema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => ResolvedSemanticSchema;
33
+ export declare const resolveFormSchema: (logicform: LogicformType, currentSchema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => ResolvedSemanticSchema;
@@ -1,6 +1,8 @@
1
1
  import type { PredItemType } from '../logicform-types';
2
2
  import type { OperatorRegistry } from '../operators/index';
3
+ import { type LocaleRegistry } from '../i18n/index';
3
4
  export interface DefaultPredNameOptions {
4
5
  readonly locale?: string;
6
+ readonly localeRegistry?: LocaleRegistry;
5
7
  }
6
8
  export declare const defaultPredName: (pred: PredItemType, operators: OperatorRegistry, options?: DefaultPredNameOptions) => string;
@@ -1,3 +1,4 @@
1
1
  export { normalizeLogicform } from './normalize-logicform';
2
2
  export { defaultPredName } from './default-pred-name';
3
3
  export { assertSupportedLogicformVersion } from './version';
4
+ export { inferPropertyResolvePath } from './property-resolve';
@@ -0,0 +1,6 @@
1
+ import type { LogicformType, PredItemType } from '../logicform-types';
2
+ import type { ResolvedSemanticSchema } from '../semantic-types/index';
3
+ import type { NormalizeLogicformOptions } from './core';
4
+ type NormalizePredQuery = (query: LogicformType['query'], schema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => Promise<LogicformType['query']>;
5
+ export declare const normalizePredExpression: (pred: PredItemType, schema: ResolvedSemanticSchema, options: NormalizeLogicformOptions, normalizePredQuery: NormalizePredQuery) => Promise<PredItemType>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { LogicformType } from '../logicform-types';
2
+ import type { ResolvedSemanticSchema } from '../semantic-types/index';
3
+ import type { NormalizeLogicformOptions } from './core';
4
+ export declare const inferPropertyResolvePath: (rootSchema: ResolvedSemanticSchema, reference: string, targetSchema: ResolvedSemanticSchema, resolveSchema?: (schemaId: string) => ResolvedSemanticSchema) => string | undefined;
5
+ /** Adds cross-Schema aliases after both legacy and v2 forms share normalization. */
6
+ export declare const normalizePropertyResolve: (logicform: LogicformType, rootSchema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => LogicformType;
@@ -0,0 +1,2 @@
1
+ import type { OperatorDefinition } from '../types';
2
+ export declare const constantOperator: OperatorDefinition;
@@ -1 +1,2 @@
1
- export declare const periodComparisonName: (args: Readonly<Record<string, unknown>>, locale: string) => string;
1
+ import type { LocaleTranslate } from '../../i18n/index';
2
+ export declare const periodComparisonName: (args: Readonly<Record<string, unknown>>, locale: string, t?: LocaleTranslate) => string;
@@ -0,0 +1,2 @@
1
+ import type { OperatorDefinition } from '../types';
2
+ export declare const periodValueOperator: OperatorDefinition;
@@ -0,0 +1,3 @@
1
+ import type { OperatorDefinition } from '../types';
2
+ export declare const lengthOperator: OperatorDefinition;
3
+ export declare const datePartOperators: readonly OperatorDefinition[];
@@ -0,0 +1,3 @@
1
+ import type { OperatorDefinition } from '../types';
2
+ export declare const leastOperator: OperatorDefinition;
3
+ export declare const greatestOperator: OperatorDefinition;
@@ -1,7 +1,8 @@
1
1
  import type { SemanticDBPlugin } from '../plugins/index';
2
2
  import { OperatorRegistry } from './registry';
3
3
  export { OperatorRegistry } from './registry';
4
+ export { resolveOperator } from './resolve';
4
5
  export { bindTrustedSqlExpression } from './sql-expression';
5
- export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorCteCalculation, OperatorCteComponent, OperatorCteSqlContext, OperatorExecutionComponent, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorObservationPolicy, OperatorObservationPolicyContext, OperatorNormalizePredContext, OperatorPlanExpressionContext, OperatorPeriodEvaluationContext, OperatorPlanInputContext, OperatorPlannedInput, OperatorRewriteLogicformContext, OperatorValidatePlanContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, } from './types';
6
+ export type { OperatorDefinition, OperatorDefaultNameContext, OperatorExecutionContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorPeriodBoundaryPolicy, OperatorPeriodBoundaryPolicyContext, OperatorNormalizePredContext, OperatorPlanExpressionContext, OperatorPeriodEvaluationContext, OperatorPlanInputContext, OperatorPlannedInput, OperatorRewriteLogicformContext, OperatorValidatePlanContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './types';
6
7
  export declare const builtinOperators: readonly import("./types").OperatorDefinition[];
7
8
  export declare const createOperatorRegistry: (plugins?: readonly SemanticDBPlugin[]) => OperatorRegistry;
@@ -1,8 +1,10 @@
1
- import type { OperatorDefinition, OperatorPeriodEvaluationContext } from './types';
1
+ import type { OperatorDefinition, OperatorExecutionContext, OperatorPeriodEvaluationContext } from './types';
2
2
  export declare class OperatorRegistry {
3
3
  #private;
4
- constructor(definitions?: readonly OperatorDefinition[]);
5
- register(definition: OperatorDefinition): this;
4
+ readonly executionContext: OperatorExecutionContext;
5
+ constructor(definitions?: readonly OperatorDefinition[], executionContext?: OperatorExecutionContext);
6
+ withExecutionContext(executionContext: OperatorExecutionContext): OperatorRegistry;
7
+ register(input: OperatorDefinition): this;
6
8
  get(name: string): OperatorDefinition;
7
9
  requiresPerPeriodEvaluation(name: string, context: OperatorPeriodEvaluationContext): boolean;
8
10
  has(name: string): boolean;
@@ -0,0 +1,3 @@
1
+ import type { OperatorDefinition } from './types';
2
+ /** Resolve an operator definition loaded from JSON or another untyped source. */
3
+ export declare const resolveOperator: (input: unknown) => OperatorDefinition;
@@ -1,7 +1,17 @@
1
1
  import type { PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, TimeGranularity, ComparableCategoryDefinition } from '../semantic-types/index';
2
- import type { LogicformType, PredItemType } from '../logicform-types';
2
+ import type { LogicformType, PredItemType, QueryType } from '../logicform-types';
3
3
  import type { DataRow } from '../physical/index';
4
- import type { Expression } from '../planner/index';
4
+ import type { Expression, LogicalPlan } from '../planner/index';
5
+ import type { LocaleTranslate } from '../i18n/index';
6
+ /** Immutable data shared by all Operator hooks during one LogicForm execution. */
7
+ export interface OperatorExecutionContext {
8
+ /** Complete rows from the unique Schema marked with `is_calendar`. */
9
+ readonly calendar?: readonly Readonly<DataRow>[];
10
+ }
11
+ interface OperatorHookContext {
12
+ /** Always supplied by the executor; optional for direct unit-level hook invocation. */
13
+ readonly executionContext?: OperatorExecutionContext;
14
+ }
5
15
  export interface OperatorSqlCapabilities {
6
16
  /** Produce a dialect-specific aggregate function around an expression. */
7
17
  aggregateFunction(name: string, expression?: string): string;
@@ -9,18 +19,25 @@ export interface OperatorSqlCapabilities {
9
19
  quoteIdentifier(identifier: string): string;
10
20
  concat(expressions: readonly string[]): string;
11
21
  substring(expression: string, start: number, length: number): string;
22
+ stringLength(expression: string): string;
23
+ datePart(expression: string, part: 'second' | 'minute' | 'hour' | 'weekday' | 'day' | 'week' | 'month' | 'quarter' | 'year'): string;
12
24
  dateBucket(expression: string, granularity: TimeGranularity): string;
25
+ dateShift(expression: string, granularity: TimeGranularity, offset: number): string;
26
+ /** Render a period boundary directly when the dialect has a concise native form. */
27
+ datePeriodBoundary?(expression: string, granularity: TimeGranularity, boundary: 'start' | 'end'): string;
28
+ /** Render a NULL-ignoring scalar extremum using a dialect-native expression. */
29
+ scalarExtremum?(operator: 'least' | 'greatest', expressions: readonly string[]): string;
13
30
  /** Bind a literal as a SQL parameter. */
14
- value(value: unknown): string;
31
+ value(value: unknown, type?: string): string;
15
32
  /** Compile a field-local LogicForm condition against an expression. */
16
33
  condition(expression: string, condition: unknown): string;
17
34
  }
18
35
  /** Context passed to an operator that pushes its computation into SQL. */
19
- export interface OperatorSqlContext {
36
+ export interface OperatorSqlContext extends OperatorHookContext {
20
37
  readonly sql: OperatorSqlCapabilities;
21
38
  /** SQL for the nested input expression, when this operator has one. */
22
39
  readonly expression?: string;
23
- /** SQL expressions produced by a multi-input operator's structural components. */
40
+ /** SQL expressions produced by a multi-input pred. */
24
41
  readonly expressions?: readonly string[];
25
42
  /** Quoted physical column for a leaf-property operator. */
26
43
  readonly column?: string;
@@ -28,7 +45,7 @@ export interface OperatorSqlContext {
28
45
  readonly args: Readonly<Record<string, unknown>>;
29
46
  }
30
47
  /** Context passed to an operator evaluated after the provider returns rows. */
31
- export interface OperatorEvaluateContext {
48
+ export interface OperatorEvaluateContext extends OperatorHookContext {
32
49
  /** Value produced by the nested expression, or undefined for a propertyless operator. */
33
50
  readonly input: unknown;
34
51
  /** Operator-specific LogicForm arguments. */
@@ -40,6 +57,8 @@ export interface ResultProperty {
40
57
  readonly type: string;
41
58
  readonly primal_type: PrimalType;
42
59
  readonly isArray: boolean;
60
+ /** Description inherited from the source Property or supplied by the operator. */
61
+ readonly description?: string;
43
62
  /** Referenced Schema for object-valued result columns. */
44
63
  readonly ref?: string;
45
64
  readonly granularity?: TimeGranularity;
@@ -47,8 +66,11 @@ export interface ResultProperty {
47
66
  /** Runtime temporal semantics for this output column, when applicable. */
48
67
  readonly temporal?: ResultPropertyTemporalMetadata;
49
68
  }
50
- export interface ResultPropertyTemporalMetadata {
51
- readonly kind: 'period-boundary' | 'period-shift' | 'date-bucket' | 'lifecycle';
69
+ /** Plugin-owned result temporal metadata extends this interface by key. */
70
+ export interface ResultPropertyTemporalMetadataExtensions {
71
+ }
72
+ export type ResultPropertyTemporalMetadata = {
73
+ readonly kind: 'period-boundary' | 'period-shift' | 'date-bucket';
52
74
  readonly boundary?: 'start' | 'end';
53
75
  readonly sourceProperty?: string;
54
76
  readonly requestedRange?: {
@@ -68,39 +90,41 @@ export interface ResultPropertyTemporalMetadata {
68
90
  readonly group: Readonly<Record<string, unknown>>;
69
91
  readonly date: string;
70
92
  }[];
71
- }
72
- export interface OperatorOutputPropertyContext {
93
+ } | ResultPropertyTemporalMetadataExtensions[keyof ResultPropertyTemporalMetadataExtensions];
94
+ export interface OperatorOutputPropertyContext extends OperatorHookContext {
73
95
  /** Final alias assigned to this operator's single output column. */
74
96
  readonly name: string;
75
97
  /** Original Schema property when the operator starts from a physical property. */
76
98
  readonly property?: ResolvedSemanticProperty;
77
99
  /** Semantic metadata produced by a nested expression. */
78
100
  readonly inputProperty?: ResultProperty;
79
- /** Semantic metadata produced by structural components. */
80
- readonly componentProperties?: readonly ResultProperty[];
101
+ /** Semantic metadata produced by a multi-input pred. */
102
+ readonly inputProperties?: readonly ResultProperty[];
81
103
  /** Operator-specific LogicForm arguments. */
82
104
  readonly args: Readonly<Record<string, unknown>>;
83
105
  }
84
106
  /** Context used by operators whose value must be evaluated per time bucket. */
85
- export interface OperatorPeriodEvaluationContext {
107
+ export interface OperatorPeriodEvaluationContext extends OperatorHookContext {
86
108
  readonly logicform: LogicformType;
87
109
  readonly pred: PredItemType;
88
110
  readonly schema: ResolvedSemanticSchema;
89
111
  readonly inputProperty?: ResolvedSemanticProperty;
90
112
  }
91
- export interface OperatorDefaultNameContext {
92
- /** Name produced by the direct pred, structural components, or localized row label. */
113
+ export interface OperatorDefaultNameContext extends OperatorHookContext {
114
+ /** Name produced by the direct pred inputs or localized row label. */
93
115
  readonly operandName: string;
94
116
  /** Name of a direct or nested pred input. */
95
117
  readonly inputName?: string;
96
- /** Names of structural component inputs. */
97
- readonly componentNames: readonly string[];
118
+ /** Names of multi-input pred values. */
119
+ readonly inputNames: readonly string[];
98
120
  /** Operator-specific LogicForm arguments. */
99
121
  readonly args: Readonly<Record<string, unknown>>;
100
- /** Requested locale. Each operator owns its own localized default names. */
122
+ /** Requested locale for generated names. */
101
123
  readonly locale: string;
124
+ /** Translate a stable message key using the requested locale. */
125
+ readonly t?: LocaleTranslate;
102
126
  }
103
- export interface OperatorPlanInputContext {
127
+ export interface OperatorPlanInputContext extends OperatorHookContext {
104
128
  /** Canonical property or relation reference supplied as this operator's direct pred. */
105
129
  readonly reference: string;
106
130
  readonly args: Readonly<Record<string, unknown>>;
@@ -113,46 +137,55 @@ export interface OperatorPlannedInput {
113
137
  /** Provider-independent arguments resolved from semantic metadata. */
114
138
  readonly args: Readonly<Record<string, unknown>>;
115
139
  }
116
- export interface OperatorNormalizePredContext {
140
+ export interface OperatorNormalizePredContext extends OperatorHookContext {
117
141
  readonly pred: PredItemType;
118
142
  readonly schema: ResolvedSemanticSchema;
119
143
  }
120
- export interface OperatorPlanExpressionContext {
144
+ export interface OperatorPlanExpressionContext extends OperatorHookContext {
121
145
  readonly pred: PredItemType;
122
146
  readonly input?: Expression;
123
147
  readonly inputProperty?: ResultProperty;
124
- readonly components: readonly Expression[];
148
+ readonly inputs: readonly Expression[];
125
149
  readonly args: Readonly<Record<string, unknown>>;
126
150
  readonly resolveKey: (reference: string) => Expression;
127
151
  readonly getOperator: (name: string) => OperatorDefinition;
128
152
  readonly planQuery: (query: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
129
153
  }
130
- export interface OperatorObservationPolicyContext {
154
+ export interface OperatorPeriodBoundaryPolicyContext extends OperatorHookContext {
131
155
  readonly pred: PredItemType;
132
156
  }
133
- export interface OperatorObservationPolicy {
157
+ export interface OperatorPeriodBoundaryPolicy {
134
158
  readonly boundary: 'start' | 'end';
135
159
  readonly implicit: boolean;
136
160
  }
137
- export interface OperatorValidatePlanContext {
161
+ export interface OperatorValidatePlanContext extends OperatorHookContext {
138
162
  readonly pred: PredItemType;
139
163
  readonly groupByNames: readonly string[];
140
164
  readonly resolveGroupName: (reference: string) => string | undefined;
141
165
  readonly getOperator: (name: string) => OperatorDefinition;
142
166
  }
143
- export interface OperatorRewriteLogicformContext {
167
+ export interface OperatorValidateGroupbyContext extends OperatorHookContext {
168
+ readonly pred: PredItemType;
169
+ }
170
+ export interface OperatorRewriteLogicformContext extends OperatorHookContext {
144
171
  readonly logicform: LogicformType;
145
172
  readonly schema: ResolvedSemanticSchema;
173
+ /** Resolve operator metadata while rewriting nested expressions. */
174
+ readonly getOperator?: (name: string) => OperatorDefinition;
146
175
  }
147
- export interface OperatorComponentContext {
148
- /** Fully normalized LogicForm containing this top-level operator projection. */
176
+ export interface OperatorComponentContext extends OperatorHookContext {
177
+ /** Normalized input LogicForm; having, sort, limit, limitBy, and page stay on the merged result. */
149
178
  readonly logicform: LogicformType;
150
- /** Caller-authored normalized LogicForm before executor row policies were added. */
179
+ /** Caller-authored normalized input before executor row policies, with result operations removed. */
151
180
  readonly sourceLogicform?: LogicformType;
152
181
  /** The operator projection for which the component is being built. */
153
182
  readonly pred: PredItemType;
154
183
  /** Final output alias assigned by the planner. */
155
184
  readonly outputName: string;
185
+ /** Requested locale for child component names. */
186
+ readonly locale: string;
187
+ /** Translate a stable message key using the requested locale. */
188
+ readonly t: LocaleTranslate;
156
189
  readonly schema: ResolvedSemanticSchema;
157
190
  /** Resolve Schemas referenced by object relation paths used by this component. */
158
191
  readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
@@ -172,32 +205,38 @@ export interface OperatorQueryComponent {
172
205
  readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
173
206
  /** SQL-side transformations that align this component's group keys with the base component. */
174
207
  readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
208
+ /** Shift an already partitioned current query into this comparison period. */
209
+ readonly partitionQuery?: (currentShardQuery: QueryType) => QueryType;
210
+ /** Unshifted metric used to choose the same Mapping for a standalone comparison. */
211
+ readonly partitionCurrentLogicform?: LogicformType;
175
212
  }
176
- export interface OperatorCteSqlContext {
177
- readonly values: Readonly<Record<string, string>>;
178
- readonly quoteIdentifier: (identifier: string) => string;
179
- }
180
- export interface OperatorCteComponent {
213
+ export interface OperatorComponentQuery {
214
+ /** Final result-column name for this child component. */
181
215
  readonly name: string;
182
- readonly component: OperatorQueryComponent;
183
- /** Group output names used to join this component back to the first component. */
216
+ readonly logicform: LogicformType;
217
+ readonly prepare?: boolean;
218
+ readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
219
+ readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
220
+ /** Name of the current-period component whose selected Mapping this query inherits. */
221
+ readonly comparisonOf?: string;
222
+ readonly partitionQuery?: (currentShardQuery: QueryType) => QueryType;
223
+ /**
224
+ * Group output names used to join this component back to the first component.
225
+ * When omitted, the compiler joins on the groupby outputs shared by both components.
226
+ */
184
227
  readonly joinKeys?: readonly string[];
185
228
  }
186
- export interface OperatorCteCalculation {
187
- readonly kind: 'cte';
188
- readonly components: readonly OperatorCteComponent[];
189
- readonly outputName?: string;
190
- readonly toSQL: (context: OperatorCteSqlContext) => string;
191
- readonly exposeComponents?: boolean;
229
+ export interface OperatorComponentCalculation {
230
+ readonly components: readonly OperatorComponentQuery[];
231
+ /** Provider-independent formula referring to component names. */
232
+ readonly expression: string;
192
233
  }
193
234
  export interface OperatorJavaScriptCalculation {
194
235
  readonly kind: 'js';
195
- readonly components: readonly OperatorCteComponent[];
196
- readonly outputName: string;
236
+ readonly components: readonly OperatorComponentQuery[];
197
237
  readonly mergeRow: (values: DataRow) => unknown;
198
- readonly exposeComponents?: boolean;
199
238
  }
200
- export type OperatorExecutionComponent = OperatorQueryComponent | OperatorCteCalculation | OperatorJavaScriptCalculation;
239
+ export type OperatorExecutionComponent = OperatorQueryComponent | OperatorComponentCalculation | OperatorJavaScriptCalculation;
201
240
  /**
202
241
  * Extension contract for one LogicForm operator.
203
242
  *
@@ -207,10 +246,25 @@ export type OperatorExecutionComponent = OperatorQueryComponent | OperatorCteCal
207
246
  * `getOutputProperty` to describe the resulting one-column logical schema.
208
247
  */
209
248
  interface OperatorDefinitionBase {
210
- /** Public registry key, normally using the `$name` convention. */
249
+ /** Public registry key. Built-in operators commonly use a `$` prefix, but it is not required. */
211
250
  readonly name: string;
251
+ /** Description of the computed metric, exposed on its result Property. */
252
+ readonly description?: string;
212
253
  /** Produce the normalized output name when the PredItem does not declare one. */
213
254
  readonly defaultName: (context: OperatorDefaultNameContext) => string;
255
+ /** Translation key for the generated name. Defaults to `operator.${name}`. */
256
+ readonly defaultNameKey?: string | ((context: OperatorDefaultNameContext) => string);
257
+ /** defaultName already used the translator and must not be translated a second time. */
258
+ readonly defaultNameIsLocalized?: boolean;
259
+ /** A grouped physical source may safely apply this operator again to stored partial results. */
260
+ readonly supportsGroupedSourceRollup?: boolean;
261
+ /** This computed operator preserves a grouped physical source's dimension semantics. */
262
+ readonly supportsGroupedSourceGroupby?: boolean;
263
+ /** Requested time grain of a grouped dimension, when this is a time grouping operator. */
264
+ readonly groupedSourceTimeGranularity?: (context: {
265
+ readonly pred: PredItemType;
266
+ readonly property: ResolvedSemanticProperty;
267
+ }) => TimeGranularity | undefined;
214
268
  /** Logical property names read in addition to the direct input property. */
215
269
  readonly dependencies?: readonly string[];
216
270
  /** Set to false for operators such as `$count` that do not require a property. */
@@ -223,11 +277,17 @@ interface OperatorDefinitionBase {
223
277
  readonly normalizePred?: (context: OperatorNormalizePredContext) => PredItemType;
224
278
  /** Build a provider-independent expression for operators with custom planning semantics. */
225
279
  readonly planExpression?: (context: OperatorPlanExpressionContext) => Expression | undefined;
226
- /** Resolve observation temporal semantics for this operator, when applicable. */
227
- readonly observationPolicy?: (context: OperatorObservationPolicyContext) => OperatorObservationPolicy | undefined;
280
+ /** Describe how this operator selects a value at a generated period boundary. */
281
+ readonly periodBoundaryPolicy?: (context: OperatorPeriodBoundaryPolicyContext) => OperatorPeriodBoundaryPolicy | undefined;
228
282
  /** Validate this operator against the completed group key set. */
229
283
  readonly validatePlan?: (context: OperatorValidatePlanContext) => void;
230
- /** Expand high-level operator semantics into ordinary nested LogicForms before planning. */
284
+ /** Validate semantics that apply only when this Operator is used as a group key. */
285
+ readonly validateGroupby?: (context: OperatorValidateGroupbyContext) => void;
286
+ /** The logical planner may fully lower a component, so no executor child query is needed. */
287
+ readonly skipComponentExecution?: (context: OperatorHookContext & {
288
+ readonly plan: LogicalPlan;
289
+ }) => boolean;
290
+ /** Expand high-level operator semantics into ordinary nested LogicForm objects before planning. */
231
291
  readonly rewriteLogicform?: (context: OperatorRewriteLogicformContext) => LogicformType | undefined;
232
292
  /** Whether this operator requires one evaluation per time bucket. */
233
293
  readonly requiresPerPeriodEvaluation?: (context: OperatorPeriodEvaluationContext) => boolean;