pond-ts API Reference (core)
    Preparing search index...

    Class LiveAggregation<S, Out>

    Type Parameters

    Index

    Constructors

    • Type Parameters

      Parameters

      • source: LiveSource<S>
      • sequence: Sequence
      • mapping:
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<S>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<S>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
      • Optionaloptions: LiveAggregationOptions

      Returns LiveAggregation<S, Out>

    Properties

    name: string
    schema: Out

    Accessors

    Methods

    • Type Parameters

      • const Targets extends string

      Parameters

      • spec: {
            [K in string]:
                | "sum"
                | "min"
                | "max"
                | "count"
                | ((acc: number, value: number) => number)
        }

      Returns LiveView<
          readonly [
              Out[0],
              ReplaceSmoothedColumn<ValueColumnsForSchema<Out>, Targets>,
          ],
      >

    • Type Parameters

      • const M extends
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<Out>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
            | {
                readonly [K in string
                | number
                | symbol]: K extends ValueColumnsForSchema<Out>[number]["name"]
                    ?
                        | Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind;
                                using: AggregateFunctionsForKind<
                                    Extract<
                                        ValueColumnsForSchema<(...)>[number],
                                        ColumnDef<(...)[(...)], ScalarKind>,
                                    >["kind"],
                                >;
                            },
                        >
                        | AggregateFunctionsForKind<
                            ColumnKindByName<ValueColumnsForSchema<Out>, K & string>,
                        >
                    : string extends K
                        ? | AggregateReducer
                        | Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind | undefined;
                                using: AggregateFunctionsForKind<
                                    Extract<(...)[(...)], ColumnDef<(...), (...)>>["kind"],
                                >;
                            },
                        >
                        : Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind;
                                using: AggregateFunctionsForKind<
                                    Extract<
                                        ValueColumnsForSchema<(...)>[number],
                                        ColumnDef<(...)[(...)], ScalarKind>,
                                    >["kind"],
                                >;
                            },
                        >
            }

      Parameters

      Returns LiveRollingAggregation<
          Out,
          readonly [Out[0], AggregateColumns<ValueColumnsForSchema<Out>, M>],
      >

    • Type Parameters

      • const M extends Readonly<
            Record<
                string,
                | AggregateReducer
                | Readonly<
                    {
                        from: ValueColumnsForSchema<Out>[number]["name"];
                        kind?: ScalarKind | undefined;
                        using: AggregateFunctionsForKind<
                            Extract<
                                ValueColumnsForSchema<Out>[number],
                                ColumnDef<(...)[(...)]["name"], ScalarKind>,
                            >["kind"],
                        >;
                    },
                >,
            >,
        >

      Parameters

      Returns LiveRollingAggregation<
          Out,
          readonly [Out[0], AggregateColumns<ValueColumnsForSchema<Out>, M>],
      >

    • Pipeline stats snapshot — cumulative counters since construction plus current bucket-state. Cheap O(1).

      • eventsObserved: total source events that contributed to a bucket. Includes events replayed at construction from a non-empty source. Late events (those whose bucket was already closed under the watermark + grace window) are silently dropped and do NOT increment this counter — match the silent-drop shape in LiveSeries.stats for late-event handling. Never decreases.
      • bucketsClosed: total buckets finalized (= length of the closed-event stream, also exposed via length). Never decreases.
      • openBuckets: current count of pending (unclosed) buckets. Equal to #pending.size. Drops back as the watermark advances and buckets close.
      • openBucketStart: earliest open bucket's start ms, or undefined if no buckets are pending.

      Note on field omission vs LiveRollingAggregation.stats: this shape doesn't carry an emissions field because every closed bucket pushes exactly one event to the output stream — the count would be identical to bucketsClosed. openBuckets and openBucketStart give the bucket-lifecycle observability users actually reach for.

      Returns {
          bucketsClosed: number;
          eventsObserved: number;
          openBuckets: number;
          openBucketStart?: number;
      }