@hamelin.sh/compiler 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.ts CHANGED
@@ -169,6 +169,8 @@ type QueryAggregation = {
169
169
  fields: string[];
170
170
  by: string[];
171
171
  sort: QuerySort[];
172
+ /** Index of this command in the main pipeline (`command` list, 0-based). */
173
+ pipelineStageIndex: number;
172
174
  };
173
175
  declare const getAggregations: (query: string) => QueryAggregation[];
174
176
 
@@ -195,9 +197,48 @@ declare function getMainPipelineText(hamelinQuery: string): string;
195
197
 
196
198
  declare const getOutputTimestampColumns: (catalog: Catalog, hamelinInput: string) => Promise<GetOutputTimestampColumnsResult>;
197
199
 
200
+ /**
201
+ * How the main pipeline defines one logical output row for identity purposes.
202
+ *
203
+ * When multiple `AGG` (with `BY`) and/or `SUPPRESS` commands appear, the **last**
204
+ * such command in the main pipeline wins — it defines the final row shape.
205
+ */
206
+ type RowCollapsingIdentity = {
207
+ kind: "none";
208
+ } | {
209
+ kind: "aggregated";
210
+ by: string[];
211
+ } | {
212
+ kind: "suppressed";
213
+ interval: string;
214
+ by: string[];
215
+ };
216
+ /**
217
+ * Returns which row-collapsing command defines output-row identity for the query.
218
+ *
219
+ * - `none` — no `AGG` with `BY` and no `SUPPRESS`; callers typically use per-event identity.
220
+ * - `aggregated` — last `AGG` with non-empty `BY` wins over any earlier `SUPPRESS`.
221
+ * - `suppressed` — last `SUPPRESS` wins over any earlier `AGG` with `BY`.
222
+ */
223
+ declare const getRowCollapsingIdentity: (query: string) => RowCollapsingIdentity;
224
+
198
225
  type FieldNames = string[] | null;
199
226
  declare const getSelectedFields: (query: string) => FieldNames;
200
227
 
228
+ type QuerySuppress = {
229
+ /** Interval literal text (e.g. `15m`, `1h`). */
230
+ interval: string;
231
+ /** Output field names for each BY clause (aliases inferred like AGG). */
232
+ by: string[];
233
+ /** Index of this command in the main pipeline (`command` list, 0-based). */
234
+ pipelineStageIndex: number;
235
+ };
236
+ /**
237
+ * Returns each `SUPPRESS` command in the main query pipeline, in pipeline order.
238
+ */
239
+ declare const getSuppress: (query: string) => QuerySuppress[];
240
+ declare const hasSuppress: (query: string) => boolean;
241
+
201
242
  /**
202
243
  * Inserts `sortInsertion` immediately before the `|` that precedes the last `LIMIT` stage
203
244
  * in the **main** query pipeline (not inside `DEF` bodies). `sortInsertion` should include
@@ -225,4 +266,4 @@ declare const sampleCatalog: Catalog;
225
266
  */
226
267
  declare const substituteTemplateParameters: (hamelinInput: string, templateValues: Record<string, WasmTemplateParameterValue>, templateParameters?: Record<string, WasmTemplateParameterKind>) => Promise<SubstituteTemplateParametersResult>;
227
268
 
228
- export { type BuildCatalogError, type BuildCatalogOutput, type Catalog, type Column, type CompileHamelinQueryResult, type CompileHamelinQueryResultOk, type Completion, type CompletionItem, type ContextualTranslationError, type ContextualTranslationErrors, type FunctionDescription, type GetOutputTimestampColumnsResult, type GetOutputTimestampColumnsResultOk, type HamelinType, type IncrementalEligibilityResult, type OutputTimestampColumn, type QuerySort, type SubstituteTemplateParametersOk, type SubstituteTemplateParametersResult, type TranslationError, type TruncUnit, type WasmTemplateParameterKind, type WasmTemplateParameterValue, buildCatalog, checkIncrementalEligibility, compileHamelinQuery, getAggregations, getCompletions, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getMainPipelineSourceRange, getMainPipelineText, getOutputTimestampColumns, getSelectedFields, getSorts, hamelinGrammar, hamelinPrompt, insertImplicitSortBeforeLastMainLimit, parseTokenValueClass, sampleCatalog, substituteTemplateParameters };
269
+ export { type BuildCatalogError, type BuildCatalogOutput, type Catalog, type Column, type CompileHamelinQueryResult, type CompileHamelinQueryResultOk, type Completion, type CompletionItem, type ContextualTranslationError, type ContextualTranslationErrors, type FunctionDescription, type GetOutputTimestampColumnsResult, type GetOutputTimestampColumnsResultOk, type HamelinType, type IncrementalEligibilityResult, type OutputTimestampColumn, type QueryAggregation, type QuerySort, type QuerySuppress, type RowCollapsingIdentity, type SubstituteTemplateParametersOk, type SubstituteTemplateParametersResult, type TranslationError, type TruncUnit, type WasmTemplateParameterKind, type WasmTemplateParameterValue, buildCatalog, checkIncrementalEligibility, compileHamelinQuery, getAggregations, getCompletions, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getMainPipelineSourceRange, getMainPipelineText, getOutputTimestampColumns, getRowCollapsingIdentity, getSelectedFields, getSorts, getSuppress, hamelinGrammar, hamelinPrompt, hasSuppress, insertImplicitSortBeforeLastMainLimit, parseTokenValueClass, sampleCatalog, substituteTemplateParameters };