pond-ts 0.1.0
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/LICENSE +21 -0
- package/README.md +348 -0
- package/dist/BoundedSequence.d.ts +28 -0
- package/dist/BoundedSequence.d.ts.map +1 -0
- package/dist/BoundedSequence.js +70 -0
- package/dist/BoundedSequence.js.map +1 -0
- package/dist/Event.d.ts +84 -0
- package/dist/Event.d.ts.map +1 -0
- package/dist/Event.js +162 -0
- package/dist/Event.js.map +1 -0
- package/dist/Interval.d.ts +51 -0
- package/dist/Interval.d.ts.map +1 -0
- package/dist/Interval.js +130 -0
- package/dist/Interval.js.map +1 -0
- package/dist/Sequence.d.ts +80 -0
- package/dist/Sequence.d.ts.map +1 -0
- package/dist/Sequence.js +197 -0
- package/dist/Sequence.js.map +1 -0
- package/dist/Time.d.ts +43 -0
- package/dist/Time.d.ts.map +1 -0
- package/dist/Time.js +78 -0
- package/dist/Time.js.map +1 -0
- package/dist/TimeRange.d.ts +45 -0
- package/dist/TimeRange.d.ts.map +1 -0
- package/dist/TimeRange.js +144 -0
- package/dist/TimeRange.js.map +1 -0
- package/dist/TimeSeries.d.ts +337 -0
- package/dist/TimeSeries.d.ts.map +1 -0
- package/dist/TimeSeries.js +1217 -0
- package/dist/TimeSeries.js.map +1 -0
- package/dist/calendar.d.ts +24 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +96 -0
- package/dist/calendar.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/temporal.d.ts +37 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +29 -0
- package/dist/temporal.js.map +1 -0
- package/dist/types.d.ts +175 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +3 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +145 -0
- package/dist/validate.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import type { AlignSchema, AggregateMap, AggregateSchema, CollapseSchema, EventDataForSchema, EventForSchema, FirstColKind, IntervalKeyedSchema, JoinManySchema, JoinSchema, JoinType, NumericColumnNameForSchema, NormalizedRowForSchema, PrefixedJoinManySchema, PrefixedJoinSchema, RenameMap, RenameSchema, RollingAlignment, RollingSchema, ScalarValue, SmoothMethod, SmoothAppendSchema, SmoothSchema, SelectSchema, SeriesSchema, TimeKeyedSchema, TimeSeriesJsonInput, TimeSeriesInput, TimeRangeKeyedSchema } from './types.js';
|
|
2
|
+
import { BoundedSequence } from './BoundedSequence.js';
|
|
3
|
+
import { type TimeZoneOptions } from './calendar.js';
|
|
4
|
+
import { TimeRange } from './TimeRange.js';
|
|
5
|
+
import type { EventKey, IntervalInput, IntervalValue, TemporalLike, TimeRangeInput, TimestampInput } from './temporal.js';
|
|
6
|
+
import { Sequence } from './Sequence.js';
|
|
7
|
+
import type { DurationInput } from './Sequence.js';
|
|
8
|
+
type RangeLike = EventKey | TimeRangeInput | IntervalInput;
|
|
9
|
+
type BoundaryLike = EventKey | TimestampInput;
|
|
10
|
+
type KeyLike = EventKey | TimestampInput | TimeRangeInput | IntervalInput;
|
|
11
|
+
type SeriesRangeLike = TemporalLike | {
|
|
12
|
+
timeRange(): TimeRange | undefined;
|
|
13
|
+
};
|
|
14
|
+
type AlignMethod = 'hold' | 'linear';
|
|
15
|
+
type AlignSample = 'begin' | 'center';
|
|
16
|
+
type SequenceLike = Sequence | BoundedSequence;
|
|
17
|
+
type ErrorJoinOptions = {
|
|
18
|
+
type?: JoinType;
|
|
19
|
+
onConflict?: 'error';
|
|
20
|
+
};
|
|
21
|
+
type PrefixJoinOptions<Prefixes extends readonly string[]> = {
|
|
22
|
+
type?: JoinType;
|
|
23
|
+
onConflict: 'prefix';
|
|
24
|
+
prefixes: Prefixes;
|
|
25
|
+
};
|
|
26
|
+
type SeriesTuple = readonly [
|
|
27
|
+
TimeSeries<SeriesSchema>,
|
|
28
|
+
...TimeSeries<SeriesSchema>[]
|
|
29
|
+
];
|
|
30
|
+
type SchemasForSeriesTuple<T extends SeriesTuple> = {
|
|
31
|
+
[I in keyof T]: T[I] extends TimeSeries<infer Schema> ? Schema : never;
|
|
32
|
+
} extends infer Result ? Result extends readonly [SeriesSchema, ...SeriesSchema[]] ? Result : never : never;
|
|
33
|
+
type PrefixesForSeriesTuple<T extends SeriesTuple> = {
|
|
34
|
+
[I in keyof T]: string;
|
|
35
|
+
} extends infer Result ? Result extends readonly [string, ...string[]] ? Result : never : never;
|
|
36
|
+
/**
|
|
37
|
+
* An immutable ordered collection of typed events sharing a common schema.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const schema = [
|
|
42
|
+
* { name: "time", kind: "time" },
|
|
43
|
+
* { name: "cpu", kind: "number" },
|
|
44
|
+
* { name: "host", kind: "string" },
|
|
45
|
+
* ] as const;
|
|
46
|
+
*
|
|
47
|
+
* const series = new TimeSeries({
|
|
48
|
+
* name: "cpu-usage",
|
|
49
|
+
* schema,
|
|
50
|
+
* rows: [[new Date("2025-01-01T00:00:00.000Z"), 0.42, "api-1"]],
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* series.first()?.get("cpu"); // 0.42
|
|
54
|
+
* series.timeRange(); // overall extent of the series
|
|
55
|
+
* series.within(new TimeRange({ start: 0, end: Date.now() })); // fully contained events
|
|
56
|
+
* series.align(Sequence.every("1m")); // uses the series range over an epoch-anchored minute grid
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class TimeSeries<S extends SeriesSchema> {
|
|
60
|
+
#private;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly schema: S;
|
|
63
|
+
readonly events: ReadonlyArray<EventForSchema<S>>;
|
|
64
|
+
/**
|
|
65
|
+
* Example: `TimeSeries.joinMany([cpu.align(seq), memory.align(seq), errors.align(seq)])`.
|
|
66
|
+
* Performs an exact-key n-ary join across many series.
|
|
67
|
+
*
|
|
68
|
+
* Use `join(...)` for the binary case and `joinMany(...)` when you want to build one wide series
|
|
69
|
+
* from several aligned or aggregated inputs. This avoids repeated manual pairwise joins in
|
|
70
|
+
* feature-building, reporting, and dashboard pipelines.
|
|
71
|
+
*
|
|
72
|
+
* Defaults:
|
|
73
|
+
* - `type`: `"outer"`
|
|
74
|
+
* - `onConflict`: `"error"`
|
|
75
|
+
*/
|
|
76
|
+
static joinMany<const T extends SeriesTuple>(series: T, options?: ErrorJoinOptions): TimeSeries<JoinManySchema<SchemasForSeriesTuple<T>>>;
|
|
77
|
+
static joinMany<const T extends SeriesTuple, const Prefixes extends PrefixesForSeriesTuple<T>>(series: T, options: PrefixJoinOptions<Prefixes>): TimeSeries<PrefixedJoinManySchema<SchemasForSeriesTuple<T>, Prefixes>>;
|
|
78
|
+
/**
|
|
79
|
+
* Example: `TimeSeries.fromJSON({ name, schema, rows, parse: { timeZone: "Europe/Madrid" } })`.
|
|
80
|
+
* Creates a typed series from JSON-style row arrays or object rows keyed by schema column names.
|
|
81
|
+
*
|
|
82
|
+
* `null` values are treated as missing values. Ambiguous local timestamp strings are parsed using
|
|
83
|
+
* the supplied `parse.timeZone`, which defaults to `UTC`.
|
|
84
|
+
*/
|
|
85
|
+
static fromJSON<S extends SeriesSchema>(input: TimeSeriesJsonInput<S> & {
|
|
86
|
+
parse?: TimeZoneOptions;
|
|
87
|
+
}): TimeSeries<S>;
|
|
88
|
+
/** Example: `new TimeSeries({ name, schema, rows })`. Creates an immutable time series from a schema and row-oriented input data. */
|
|
89
|
+
constructor(input: TimeSeriesInput<S>);
|
|
90
|
+
/** Example: `series.firstColumnKind`. Returns the first-column kind from the series schema. */
|
|
91
|
+
get firstColumnKind(): FirstColKind;
|
|
92
|
+
/** Example: `series.rows`. Returns the normalized row view of the series. */
|
|
93
|
+
get rows(): ReadonlyArray<NormalizedRowForSchema<S>>;
|
|
94
|
+
/** Example: `series.at(0)`. Returns the event at the supplied zero-based position, if present. */
|
|
95
|
+
at(index: number): EventForSchema<S> | undefined;
|
|
96
|
+
/** Example: `series.first()`. Returns the first event in the series, if present. */
|
|
97
|
+
first(): EventForSchema<S> | undefined;
|
|
98
|
+
/** Example: `series.last()`. Returns the last event in the series, if present. */
|
|
99
|
+
last(): EventForSchema<S> | undefined;
|
|
100
|
+
/** Example: `series.map(nextSchema, event => event)`. Maps each event into a new typed schema and returns a new series. */
|
|
101
|
+
map<NextSchema extends SeriesSchema>(schema: NextSchema, mapper: (event: EventForSchema<S>, index: number) => EventForSchema<NextSchema>): TimeSeries<NextSchema>;
|
|
102
|
+
/** Example: `series.asTime({ at: "center" })`. Converts the series key type to `"time"` using the supplied anchor within each event extent. */
|
|
103
|
+
asTime(options?: {
|
|
104
|
+
at?: 'begin' | 'center' | 'end';
|
|
105
|
+
}): TimeSeries<TimeKeyedSchema<S>>;
|
|
106
|
+
/** Example: `series.asTimeRange()`. Converts the series key type to `"timeRange"` while preserving each event extent. */
|
|
107
|
+
asTimeRange(): TimeSeries<TimeRangeKeyedSchema<S>>;
|
|
108
|
+
/** Example: `series.asInterval(event => event.begin())`. Converts the series key type to `"interval"` while preserving each event extent and supplying interval labels. */
|
|
109
|
+
asInterval(value: IntervalValue): TimeSeries<IntervalKeyedSchema<S>>;
|
|
110
|
+
asInterval(value: (event: EventForSchema<S>, index: number) => IntervalValue): TimeSeries<IntervalKeyedSchema<S>>;
|
|
111
|
+
/**
|
|
112
|
+
* Example: `left.join(right, { type: "left" })`.
|
|
113
|
+
* Performs an exact-key join of two series with the same key kind.
|
|
114
|
+
*
|
|
115
|
+
* Join types:
|
|
116
|
+
* - `"outer"`: keep keys from either side
|
|
117
|
+
* - `"left"`: keep all keys from the left series
|
|
118
|
+
* - `"right"`: keep all keys from the right series
|
|
119
|
+
* - `"inner"`: keep only keys present on both sides
|
|
120
|
+
*
|
|
121
|
+
* Defaults:
|
|
122
|
+
* - `type`: `"outer"`
|
|
123
|
+
* - `onConflict`: `"error"`
|
|
124
|
+
*
|
|
125
|
+
* Value columns from both series are included in the result and are optional because joined rows
|
|
126
|
+
* may have missing values on either side. If both series use the same payload column name,
|
|
127
|
+
* you can either rename one side before joining or use `{ onConflict: "prefix", prefixes: [...] }`.
|
|
128
|
+
*/
|
|
129
|
+
join<Other extends SeriesSchema>(other: TimeSeries<Other>, options?: ErrorJoinOptions): TimeSeries<JoinSchema<S, Other>>;
|
|
130
|
+
join<Other extends SeriesSchema, const Prefixes extends readonly [string, string]>(other: TimeSeries<Other>, options: PrefixJoinOptions<Prefixes>): TimeSeries<PrefixedJoinSchema<S, Other, Prefixes>>;
|
|
131
|
+
/**
|
|
132
|
+
* Example: `series.align(Sequence.every("1m"))`.
|
|
133
|
+
* Aligns the series onto a `Sequence` grid or `BoundedSequence` and returns an interval-keyed series.
|
|
134
|
+
*
|
|
135
|
+
* `hold` carries forward the latest known value to each sample position. `linear` interpolates
|
|
136
|
+
* numeric columns between neighboring time-keyed events and falls back to hold behavior for
|
|
137
|
+
* non-numeric columns. Aligned columns are optional because edge buckets may have no value.
|
|
138
|
+
*
|
|
139
|
+
* Defaults:
|
|
140
|
+
* - `method`: `"hold"`
|
|
141
|
+
* - `sample`: `"begin"`
|
|
142
|
+
* - `range`: `series.timeRange()`
|
|
143
|
+
*
|
|
144
|
+
* For `Sequence` inputs, the sequence anchor still comes from the grid definition itself. For
|
|
145
|
+
* procedural sequences created with `Sequence.every(...)`, that anchor defaults to Unix epoch
|
|
146
|
+
* `0`. The `range` only decides which finite slice of that grid is bounded for this alignment.
|
|
147
|
+
*
|
|
148
|
+
* When a `BoundedSequence` is supplied, its intervals are used directly.
|
|
149
|
+
*
|
|
150
|
+
* Example:
|
|
151
|
+
* - `Sequence.every("1m")` defines an epoch-anchored minute grid
|
|
152
|
+
* - `series.align(Sequence.every("1m"))` aligns onto the slice of that minute grid spanning the
|
|
153
|
+
* current series extent
|
|
154
|
+
*/
|
|
155
|
+
align(sequence: SequenceLike, options?: {
|
|
156
|
+
method?: AlignMethod;
|
|
157
|
+
sample?: AlignSample;
|
|
158
|
+
range?: TemporalLike;
|
|
159
|
+
}): TimeSeries<AlignSchema<S>>;
|
|
160
|
+
/**
|
|
161
|
+
* Example: `series.aggregate(Sequence.every("1m"), { value: "avg" })`.
|
|
162
|
+
* Aggregates events into sequence buckets using built-in reducer names.
|
|
163
|
+
*
|
|
164
|
+
* Buckets use half-open membership semantics: `[begin, end)`. Point events contribute to the
|
|
165
|
+
* bucket containing their timestamp. Interval-like events contribute to every bucket they
|
|
166
|
+
* overlap under half-open overlap rules.
|
|
167
|
+
*
|
|
168
|
+
* Defaults:
|
|
169
|
+
* - `range`: `series.timeRange()`
|
|
170
|
+
*
|
|
171
|
+
* As with `align(...)`, `Sequence` defines the underlying grid and `range` selects which portion
|
|
172
|
+
* of that grid is bounded. With `Sequence.every(...)`, the default grid anchor is Unix epoch `0`,
|
|
173
|
+
* but the default aggregation range is always the source series extent. When a
|
|
174
|
+
* `BoundedSequence` is supplied, its intervals are used directly.
|
|
175
|
+
*
|
|
176
|
+
* Override `range` when you need multiple series aggregated over the same reporting window,
|
|
177
|
+
* including leading or trailing empty buckets outside an individual series extent.
|
|
178
|
+
*
|
|
179
|
+
* To align buckets to the beginning of the current series instead of epoch boundaries, override
|
|
180
|
+
* the sequence anchor rather than the aggregation range:
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* const range = series.timeRange();
|
|
184
|
+
* if (!range) {
|
|
185
|
+
* throw new Error("empty series");
|
|
186
|
+
* }
|
|
187
|
+
*
|
|
188
|
+
* const aggregated = series.aggregate(
|
|
189
|
+
* Sequence.every("1m", { anchor: range.begin() }),
|
|
190
|
+
* { value: "avg" },
|
|
191
|
+
* );
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
aggregate<const Mapping extends AggregateMap<S>>(sequence: SequenceLike, mapping: Mapping, options?: {
|
|
195
|
+
range?: TemporalLike;
|
|
196
|
+
}): TimeSeries<AggregateSchema<S, Mapping>>;
|
|
197
|
+
/**
|
|
198
|
+
* Example: `series.rolling("1h", { value: "avg" })`.
|
|
199
|
+
* Computes event-driven rolling aggregations over the ordered series.
|
|
200
|
+
*
|
|
201
|
+
* Example: `series.rolling(Sequence.every("1m"), "5m", { value: "avg" })`.
|
|
202
|
+
* Computes sequence-driven rolling aggregations and returns an interval-keyed series on the
|
|
203
|
+
* supplied grid.
|
|
204
|
+
*
|
|
205
|
+
* Rolling windows are anchored either at each event's `begin()` time or at the sample point of
|
|
206
|
+
* each sequence bucket. Membership is determined from source event `begin()` times.
|
|
207
|
+
*
|
|
208
|
+
* Supported alignments:
|
|
209
|
+
* - `"trailing"`: `(t - window, t]`
|
|
210
|
+
* - `"leading"`: `[t, t + window)`
|
|
211
|
+
* - `"centered"`: `[t - window/2, t + window/2)`
|
|
212
|
+
*
|
|
213
|
+
* Defaults:
|
|
214
|
+
* - `alignment`: `"trailing"`
|
|
215
|
+
* - sequence-driven only: `sample: "begin"`
|
|
216
|
+
* - sequence-driven only: `range: series.timeRange()`
|
|
217
|
+
*/
|
|
218
|
+
rolling<const Mapping extends AggregateMap<S>>(window: DurationInput, mapping: Mapping, options?: {
|
|
219
|
+
alignment?: RollingAlignment;
|
|
220
|
+
}): TimeSeries<RollingSchema<S, Mapping>>;
|
|
221
|
+
rolling<const Mapping extends AggregateMap<S>>(sequence: SequenceLike, window: DurationInput, mapping: Mapping, options?: {
|
|
222
|
+
alignment?: RollingAlignment;
|
|
223
|
+
sample?: AlignSample;
|
|
224
|
+
range?: TemporalLike;
|
|
225
|
+
}): TimeSeries<AggregateSchema<S, Mapping>>;
|
|
226
|
+
/**
|
|
227
|
+
* Example: `series.smooth("value", "ema", { alpha: 0.2 })`.
|
|
228
|
+
* Applies a smoothing transform to one numeric payload column while preserving the original key
|
|
229
|
+
* type, key values, and all non-target payload fields.
|
|
230
|
+
*
|
|
231
|
+
* Example: `series.smooth("value", "movingAverage", { window: "5m", alignment: "centered", output: "valueAvg" })`.
|
|
232
|
+
* Computes a moving average over the selected numeric column using anchor points derived from
|
|
233
|
+
* event keys. `Time` keys use their timestamp. `TimeRange` and `Interval` keys use the midpoint
|
|
234
|
+
* of their extent.
|
|
235
|
+
*
|
|
236
|
+
* Example: `series.smooth("value", "loess", { span: 0.75 })`.
|
|
237
|
+
* Computes a LOESS-smoothed value for the selected numeric column using local weighted linear
|
|
238
|
+
* regression over those same anchor points.
|
|
239
|
+
*
|
|
240
|
+
* When `output` is omitted, the smoothed values replace the target column. When `output` is
|
|
241
|
+
* supplied, the smoothed values are appended as a new optional numeric column.
|
|
242
|
+
*/
|
|
243
|
+
smooth<const Target extends NumericColumnNameForSchema<S>, const Output extends string | undefined = undefined>(column: Target, method: SmoothMethod, options: {
|
|
244
|
+
alpha: number;
|
|
245
|
+
output?: Output;
|
|
246
|
+
} | {
|
|
247
|
+
window: DurationInput;
|
|
248
|
+
alignment?: RollingAlignment;
|
|
249
|
+
output?: Output;
|
|
250
|
+
} | {
|
|
251
|
+
span: number;
|
|
252
|
+
output?: Output;
|
|
253
|
+
}): TimeSeries<Output extends string ? SmoothAppendSchema<S, Output> : SmoothSchema<S, Target>>;
|
|
254
|
+
/** Example: `series.slice(0, 10)`. Returns a positional half-open slice of the series. */
|
|
255
|
+
slice(beginIndex?: number, endIndex?: number): TimeSeries<S>;
|
|
256
|
+
/** Example: `series.filter(event => event.get("active"))`. Returns a new series containing only events that match the predicate. */
|
|
257
|
+
filter(predicate: (event: EventForSchema<S>, index: number) => boolean): TimeSeries<S>;
|
|
258
|
+
/** Example: `series.find(event => event.get("value") > 0)`. Returns the first event that matches the predicate, if any. */
|
|
259
|
+
find(predicate: (event: EventForSchema<S>, index: number) => boolean): EventForSchema<S> | undefined;
|
|
260
|
+
/** Example: `series.some(event => event.get("healthy"))`. Returns `true` when at least one event matches the predicate. */
|
|
261
|
+
some(predicate: (event: EventForSchema<S>, index: number) => boolean): boolean;
|
|
262
|
+
/** Example: `series.every(event => event.get("healthy"))`. Returns `true` when every event matches the predicate. */
|
|
263
|
+
every(predicate: (event: EventForSchema<S>, index: number) => boolean): boolean;
|
|
264
|
+
/** Example: `series.includesKey(new Time(Date.now()))`. Returns `true` when the series contains an event with an exactly matching key. */
|
|
265
|
+
includesKey(key: KeyLike): boolean;
|
|
266
|
+
/** Example: `series.bisect(new Time(Date.now()))`. Returns the insertion index for the supplied key in the ordered event sequence. */
|
|
267
|
+
bisect(key: KeyLike): number;
|
|
268
|
+
/** Example: `series.atOrBefore(new Time(Date.now()))`. Returns the event with the exact key or the nearest earlier event, if any. */
|
|
269
|
+
atOrBefore(key: KeyLike): EventForSchema<S> | undefined;
|
|
270
|
+
/** Example: `series.atOrAfter(new Time(Date.now()))`. Returns the event with the exact key or the nearest later event, if any. */
|
|
271
|
+
atOrAfter(key: KeyLike): EventForSchema<S> | undefined;
|
|
272
|
+
/** Example: `series.timeRange()`. Returns the overall temporal extent of the series, if the series is not empty. */
|
|
273
|
+
timeRange(): TimeRange | undefined;
|
|
274
|
+
/** Example: `series.overlaps(range)`. Returns `true` when the overall series extent overlaps the supplied temporal value. */
|
|
275
|
+
overlaps(other: SeriesRangeLike): boolean;
|
|
276
|
+
/** Example: `series.contains(range)`. Returns `true` when the overall series extent fully contains the supplied temporal value. */
|
|
277
|
+
contains(other: SeriesRangeLike): boolean;
|
|
278
|
+
/** Example: `series.intersection(range)`. Returns the overlap between the overall series extent and the supplied temporal value, if any. */
|
|
279
|
+
intersection(other: SeriesRangeLike): TimeRange | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Example: `series.overlapping(range)`.
|
|
282
|
+
* Returns the portion of the series whose event extents overlap the supplied range.
|
|
283
|
+
*
|
|
284
|
+
* Unlike `within(...)`, this keeps partially overlapping events without modifying their keys.
|
|
285
|
+
* Use `trim(...)` when you want those overlapping keys clipped to the supplied range.
|
|
286
|
+
*/
|
|
287
|
+
overlapping(range: RangeLike): TimeSeries<S>;
|
|
288
|
+
/**
|
|
289
|
+
* Example: `series.containedBy(range)`.
|
|
290
|
+
* Returns the portion of the series whose event extents are fully contained by the supplied range.
|
|
291
|
+
*
|
|
292
|
+
* This is the strict containment selector:
|
|
293
|
+
* events must start at or after the range start and end at or before the range end.
|
|
294
|
+
* Unlike `overlapping(...)`, partially overlapping events are excluded.
|
|
295
|
+
*/
|
|
296
|
+
containedBy(range: RangeLike): TimeSeries<S>;
|
|
297
|
+
/**
|
|
298
|
+
* Example: `series.trim(range)`.
|
|
299
|
+
* Returns the series trimmed to the supplied range by clipping overlapping event keys.
|
|
300
|
+
*
|
|
301
|
+
* Non-overlapping events are dropped. Overlapping `TimeRange` and `Interval` keys are clipped
|
|
302
|
+
* to the supplied range. Overlapping `Time` keys are preserved unchanged.
|
|
303
|
+
*/
|
|
304
|
+
trim(range: RangeLike): TimeSeries<S>;
|
|
305
|
+
/** Example: `series.before(Date.now())`. Returns the events ending strictly before the supplied temporal boundary. */
|
|
306
|
+
before(boundary: BoundaryLike): TimeSeries<S>;
|
|
307
|
+
/** Example: `series.after(Date.now())`. Returns the events beginning strictly after the supplied temporal boundary. */
|
|
308
|
+
after(boundary: BoundaryLike): TimeSeries<S>;
|
|
309
|
+
/**
|
|
310
|
+
* Example: `series.within(start, end)`.
|
|
311
|
+
* Returns the portion of the series fully contained by the supplied inclusive temporal range.
|
|
312
|
+
*
|
|
313
|
+
* This is equivalent in behavior to `containedBy(...)`, but accepts either explicit begin/end
|
|
314
|
+
* boundaries or a single range-like value.
|
|
315
|
+
*/
|
|
316
|
+
within(begin: TimestampInput, end: TimestampInput): TimeSeries<S>;
|
|
317
|
+
/**
|
|
318
|
+
* Example: `series.within(range)`.
|
|
319
|
+
* Returns the portion of the series fully contained by the supplied inclusive temporal range.
|
|
320
|
+
*
|
|
321
|
+
* Use `overlapping(...)` for intersection-based selection or `trim(...)` for clipped output.
|
|
322
|
+
*/
|
|
323
|
+
within(range: RangeLike): TimeSeries<S>;
|
|
324
|
+
/** Example: `series.select("cpu", "healthy")`. Returns a new series containing only the selected payload fields. */
|
|
325
|
+
select<const Keys extends readonly (keyof EventDataForSchema<S>)[]>(...keys: Keys): TimeSeries<SelectSchema<S, Keys[number] & string>>;
|
|
326
|
+
/** Example: `series.rename({ cpu: "usage" })`. Returns a new series with payload field names renamed according to the supplied mapping. */
|
|
327
|
+
rename<const Mapping extends RenameMap<EventDataForSchema<S>>>(mapping: Mapping): TimeSeries<RenameSchema<S, Mapping>>;
|
|
328
|
+
/** Example: `series.collapse(["in", "out"], "avg", fn)`. Collapses selected payload fields into a single derived field across each event in the series. */
|
|
329
|
+
collapse<const Keys extends readonly (keyof EventDataForSchema<S>)[], Name extends string, R extends ScalarValue>(keys: Keys, output: Name, reducer: (values: Pick<EventDataForSchema<S>, Keys[number]>) => R): TimeSeries<CollapseSchema<S, Keys[number] & string, Name, R>>;
|
|
330
|
+
collapse<const Keys extends readonly (keyof EventDataForSchema<S>)[], Name extends string, R extends ScalarValue>(keys: Keys, output: Name, reducer: (values: Pick<EventDataForSchema<S>, Keys[number]>) => R, options: {
|
|
331
|
+
append: true;
|
|
332
|
+
}): TimeSeries<CollapseSchema<S, Keys[number] & string, Name, R, true>>;
|
|
333
|
+
/** Example: `series.length`. Returns the number of events in the series. */
|
|
334
|
+
get length(): number;
|
|
335
|
+
}
|
|
336
|
+
export {};
|
|
337
|
+
//# sourceMappingURL=TimeSeries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeSeries.d.ts","sourceRoot":"","sources":["../src/TimeSeries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EACZ,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,mBAAmB,EAInB,cAAc,EACd,UAAU,EACV,QAAQ,E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