/** Structured patch format for grepr pipelines: a list of ops applied locally before any production write (see {@link JobBackend} for the two substrates). */ import { SchemaReadJob, SchemaUpdateJob, SchemaOperation, SchemaEventPredicate, SchemaLogReducerTemplateInput, SchemaLogsFilter, SchemaChainNode, SchemaSqlOperation, SchemaMaskingOperator, SqlNodeOutputRouting, SumAttributesMergeStrategyType, MinAttributesMergeStrategyType, MaxAttributesMergeStrategyType, AverageAttributesMergeStrategyType } from '../openapi/openApiTypes.js'; export type AggregationStrategy = `${SumAttributesMergeStrategyType}` | `${MinAttributesMergeStrategyType}` | `${MaxAttributesMergeStrategyType}` | `${AverageAttributesMergeStrategyType}`; /** The processing phases that map to a template `transforms` chain slot. */ export type TemplateTransformPhase = 'pre-parser' | 'pre-warehouse' | 'pre-exceptions'; export type SqlTransformMainStream = 'drop' | 'passthrough'; /** Where a sink lives in the pipeline. */ export type SinkTarget = 'vendor' | 'processed-logs'; /** * Which substrate a patch is applied to. `template`: one `template-operation` * vertex, ops mutate `templateInputs.input`. `job-graph`: ops mutate resolved * vertices directly; topology ops require a canonical UI log graph. */ export type JobBackend = 'template' | 'job-graph'; /** All supported patch operations, applied in list order. */ export type JobPatchOp = { op: 'add-message-attribute'; /** Dot-notation path; multi-part stored as `messageReservedAttributePaths`, single-part as `messageReservedAttributes`. */ attributePath: string; } | { op: 'add-group-by'; /** Dot-notation path. Stored under `input.reducer.partitionByAttributePaths` (multi-part) or `input.reducer.partitionByAttributes` (single-part). */ attributePath: string; } | { op: 'add-aggregation-strategy'; /** Dot-notation path to aggregate. Stored under `input.reducer.attributeMergeStrategyEntries`. */ attributePath: string; strategies: AggregationStrategy[]; } | { op: 'add-reducer-exception'; /** * Predicate logs must match to bypass aggregation. Template: wrapped in a * `TemplateQueryException` appended to `input.exceptions`. Job-graph: * appended raw to the reducer vertex's `logReducerExceptions`. */ predicate: SchemaEventPredicate; } | { op: 'add-grok-rule'; /** Grok rule string; appended to the targeted parser's `grokParsingRules`. */ pattern: string; /** Name of an existing grok-parser. If omitted, exactly one grok-parser must exist. */ parserName?: string; /** Source attribute the parser reads from. Per-parser (not per-rule); overwrites any existing `extractAttribute`. */ extractAttribute?: string; } | { op: 'set-input-field'; /** Sets the field; intermediates must already exist (throws otherwise). */ path: string; value: unknown; } | { op: 'unset-input-field'; /** Deletes the field; no-ops if the path doesn't resolve. */ path: string; } | { op: 'add-parser'; /** * Operation with `name` and `type` (typically `json-log-processor`, * `grok-parser`, or `log-attributes-remapper`). Template: appended to * `input.parsers`. Job-graph: inserted positionally into the parser chain. */ parser: SchemaOperation; } | { op: 'remove-parser'; /** Removes the parser with this `name` from `input.parsers`. */ name: string; } | { op: 'set-filter'; phase: TemplateTransformPhase; /** Filter for this phase (one per phase). Template: written as a transform-chain gate; job-graph: replaces the canonical filter vertex. */ filter: SchemaLogsFilter; } | { op: 'clear-filter'; phase: TemplateTransformPhase; } | { op: 'set-transform-chain'; phase: TemplateTransformPhase; /** Replacement chain root for the slot; written verbatim. */ root: SchemaChainNode; } | { op: 'clear-transform-chain'; phase: TemplateTransformPhase; } | { op: 'set-sql-transform'; phase: TemplateTransformPhase; /** The `sql-operation` to embed in a generated `SqlNode` chain. */ sqlOperation: SchemaSqlOperation; /** Maps each `sql_output.outputName` to the downstream step that consumes it. */ outputRouting: Record; /** What to do with the original/main stream after sending it to SQL. */ mainStream: SqlTransformMainStream; /** * Optional predicate gating which events run the SQL node. Non-matching * events pass through unchanged. */ gate?: SchemaEventPredicate; } | { op: 'set-masking'; /** The masking operator to install as `input.masking`; replaces any existing one. */ masking: SchemaMaskingOperator; } | { op: 'clear-masking'; } | { op: 'add-source'; /** Source operation appended to `input.sources`. */ source: SchemaOperation; } | { op: 'remove-source'; /** Removes the source with this `name` from `input.sources`. */ name: string; } | { op: 'add-sink'; /** Adds a vendor log sink. */ target: 'vendor'; /** A vendor log sink operation. */ sink: SchemaOperation; /** * Filter gating which logs reach this sink. Template: stored on the * `TemplateLogSink`. Raw job-graph: inserted as a single-use `logs-filter` * vertex (`_filter`) between the reducer and the sink. */ filter?: SchemaLogsFilter; } | { op: 'add-sink'; /** Sets the single reduced-logs iceberg sink. */ target: 'processed-logs'; /** A `logs-iceberg-table-sink` operation. */ sink: SchemaOperation; } | { op: 'remove-sink'; target: 'vendor'; /** Name of the vendor sink to remove. */ name: string; } | { op: 'remove-sink'; /** Removes the singular `processed-logs` slot; no name needed. */ target: 'processed-logs'; } | { op: 'set-raw-dataset'; /** New raw-logs dataset ID. Template: `input.datasetId` (and `rawSinkConfig.datasetId` when that override is set). Raw job-graph: `datasetId` on the raw data-lake `logs-iceberg-table-sink` (matched by name prefix). */ datasetId: string; } | { op: 'remove-message-attribute'; /** Dot-notation path to drop from the remapper's `messageReservedAttributes` (single-part) or `messageReservedAttributePaths` (multi-part). */ attributePath: string; } | { op: 'remove-group-by'; /** Dot-notation path to drop from the reducer's `partitionByAttributes` (single-part) or `partitionByAttributePaths` (multi-part). */ attributePath: string; } | { op: 'remove-aggregation-strategy'; /** Dot-notation path whose merge-strategy entries are dropped from `attributeMergeStrategyEntries`. */ attributePath: string; /** Limits removal to these strategies; omit to drop every strategy entry for the path. */ strategies?: AggregationStrategy[]; } | { op: 'remove-reducer-exception'; /** Predicate identifying the exception to drop (matched by serialized equality). Template: removed from `input.exceptions`; job-graph: removed from the reducer's `logReducerExceptions`. */ predicate: SchemaEventPredicate; } | { op: 'remove-grok-rule'; /** Grok rule string to drop from the targeted parser's `grokParsingRules`. */ pattern: string; /** Name of an existing grok-parser. If omitted, exactly one grok-parser must exist. */ parserName?: string; } | { op: 'update-source'; /** Replacement source; the existing source with the same `name` is replaced in place. */ source: SchemaOperation; } | { op: 'update-parser'; /** Replacement parser; the existing parser with the same `name` is replaced in place. */ parser: SchemaOperation; } | { op: 'update-sink'; /** Replaces a vendor sink's config in place, located by `sink.name`. */ target: 'vendor'; sink: SchemaOperation; /** * When provided, replaces an existing template entry filter or generated * `_filter` vertex. Omit to preserve current gating. */ filter?: SchemaLogsFilter; } | { op: 'update-sink'; /** Replaces the singular reduced-logs iceberg sink's config in place. */ target: 'processed-logs'; sink: SchemaOperation; } | { op: 'update-message-attribute'; /** Existing message-attribute path to replace. */ from: string; /** Replacement path. Must share `from`'s arity (both single- or both multi-part); cross-list moves need remove + add. */ to: string; } | { op: 'update-group-by'; /** Existing group-by path to replace. */ from: string; /** Replacement path. Must share `from`'s arity (both single- or both multi-part); cross-list moves need remove + add. */ to: string; } | { op: 'update-aggregation-strategy'; /** Dot-notation path whose merge-strategy set is replaced. Errors if the path has no existing entries. */ attributePath: string; /** New strategy set for the path; replaces all existing entries for it, anchored at the first one's position. */ strategies: AggregationStrategy[]; } | { op: 'update-reducer-exception'; /** Predicate identifying the existing exception (matched by serialized equality). */ from: SchemaEventPredicate; /** Replacement predicate, written at the matched exception's position. */ to: SchemaEventPredicate; }; export interface JobPatch { operations: JobPatchOp[]; } /** * What kind of pipeline elements a patch touches, picking the validation path. * `transform`/`source` are draft-validatable; `sink` (and `mixed`) are not. */ export type PatchClassification = 'transform' | 'source' | 'sink' | 'mixed'; /** * Validate the patch file shape, including each op's name and required fields, so * a typo'd or under-specified op (e.g. `add-group-by` with no `attributePath`) * fails cleanly at the file boundary rather than deep inside `applyPatch` with a * confusing internal error. `applyPatch` still does the deeper * semantic/target-conditional validation. */ export declare function parsePatch(raw: unknown): JobPatch; /** Detect whether a job is template-backed (a `template-operation` vertex) or job-graph. */ export declare function detectBackend(job: { jobGraph?: { vertices?: SchemaOperation[]; }; }): JobBackend; /** * Apply a patch to a fetched job, producing the `SchemaUpdateJob` payload for * `job:apply`. Pure (clones input); dispatches on backend. Throws if an op * targets a missing field/vertex or a topology op hits a non-UI raw graph. */ export declare function applyPatch(job: SchemaReadJob, patch: JobPatch): SchemaUpdateJob; export declare function isDropNode(node: SchemaChainNode): boolean; export declare function isPassthroughNode(node: SchemaChainNode): boolean; export declare function isSqlNode(node: SchemaChainNode): boolean; export declare function isConditionNode(node: SchemaChainNode): boolean; /** Returns limitation strings for the user-facing draft preamble; non-empty when the patch touches sinks (external delivery is not verified). */ export declare function draftVerificationLimitations(patch: JobPatch): string[]; /** Classify a patch by what it touches; recorded on the plan so consumers needn't recompute. */ export declare function classifyPatch(patch: JobPatch): PatchClassification; /** * Find the single `template-operation` vertex (exactly one per template-backed * job); throws on 0 (non-template) or >1 (unsupported). Accepts `SchemaReadJob` * or `SchemaUpdateJob` without casts. */ export declare function findTemplateOperation(job: { jobGraph?: { vertices?: SchemaOperation[]; }; }): SchemaOperation & { draftMode?: boolean; templateInputs?: Record; }; export declare function readTemplateInput(templateOp: { templateInputs?: Record; }): SchemaLogReducerTemplateInput; //# sourceMappingURL=job-patch.d.ts.map