@dereekb/date 13.0.6 → 13.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/index.cjs.js +3556 -1011
- package/index.esm.js +3546 -1002
- package/package.json +5 -6
- package/src/lib/date/date.calendar.d.ts +63 -9
- package/src/lib/date/date.cell.d.ts +203 -104
- package/src/lib/date/date.cell.factory.d.ts +319 -86
- package/src/lib/date/date.cell.filter.d.ts +104 -2
- package/src/lib/date/date.cell.index.d.ts +202 -92
- package/src/lib/date/date.cell.schedule.d.ts +285 -102
- package/src/lib/date/date.cell.schedule.day.d.ts +13 -3
- package/src/lib/date/date.cell.validator.d.ts +6 -8
- package/src/lib/date/date.cell.week.d.ts +24 -3
- package/src/lib/date/date.d.ts +481 -54
- package/src/lib/date/date.day.d.ts +139 -49
- package/src/lib/date/date.duration.d.ts +49 -11
- package/src/lib/date/date.format.d.ts +355 -36
- package/src/lib/date/date.hashset.d.ts +11 -0
- package/src/lib/date/date.logical.d.ts +61 -3
- package/src/lib/date/date.range.d.ts +355 -77
- package/src/lib/date/date.range.string.d.ts +39 -0
- package/src/lib/date/date.range.timezone.d.ts +18 -6
- package/src/lib/date/date.round.d.ts +46 -1
- package/src/lib/date/date.rxjs.d.ts +29 -7
- package/src/lib/date/date.sort.d.ts +36 -9
- package/src/lib/date/date.time.d.ts +197 -26
- package/src/lib/date/date.time.limit.d.ts +67 -4
- package/src/lib/date/date.time.minute.d.ts +269 -30
- package/src/lib/date/date.timezone.d.ts +286 -70
- package/src/lib/date/date.unix.d.ts +3 -0
- package/src/lib/date/date.week.d.ts +115 -51
- package/src/lib/query/query.builder.d.ts +91 -0
- package/src/lib/query/query.builder.mongo.d.ts +50 -0
- package/src/lib/query/query.filter.d.ts +29 -2
- package/src/lib/query/query.request.d.ts +16 -0
- package/src/lib/rrule/date.recurrence.d.ts +66 -22
- package/src/lib/rrule/date.rrule.d.ts +131 -8
- package/src/lib/rrule/date.rrule.extension.d.ts +50 -9
- package/src/lib/rrule/date.rrule.parse.d.ts +85 -2
- package/src/lib/timezone/timezone.d.ts +102 -2
- package/src/lib/timezone/timezone.validator.d.ts +9 -4
|
@@ -1,18 +1,120 @@
|
|
|
1
1
|
import { type FilterFunction, type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type DateCell, type DateCellDurationSpan } from './date.cell';
|
|
3
3
|
import { type DateCellRange, type UniqueDateCell } from './date.cell.index';
|
|
4
|
+
/**
|
|
5
|
+
* A filter function that operates on {@link DateCellDurationSpan} values, typically used
|
|
6
|
+
* to select date cells based on their temporal relationship to a reference point.
|
|
7
|
+
*/
|
|
4
8
|
export type DateCellDurationSpanFilterFunction<B extends DateCell = DateCell> = FilterFunction<DateCellDurationSpan<B>>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a filter that passes date cell duration spans whose start time is at or before the given reference time.
|
|
11
|
+
*
|
|
12
|
+
* Useful for identifying events or blocks that have already begun relative to a point in time.
|
|
13
|
+
*
|
|
14
|
+
* @param now - Reference time to compare against. Defaults to the current time.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const hasStarted = dateCellDurationSpanHasStartedFilterFunction(new Date());
|
|
19
|
+
* const startedSpans = allSpans.filter(hasStarted);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
5
22
|
export declare function dateCellDurationSpanHasStartedFilterFunction<B extends DateCell = DateCell>(now?: Date): DateCellDurationSpanFilterFunction<B>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a filter that passes date cell duration spans whose start time is strictly after the given reference time.
|
|
25
|
+
*
|
|
26
|
+
* The inverse of {@link dateCellDurationSpanHasStartedFilterFunction}. Useful for finding upcoming or future events.
|
|
27
|
+
*
|
|
28
|
+
* @param now - Reference time to compare against. Defaults to the current time.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const hasNotStarted = dateCellDurationSpanHasNotStartedFilterFunction(new Date());
|
|
33
|
+
* const futureSpans = allSpans.filter(hasNotStarted);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
6
36
|
export declare function dateCellDurationSpanHasNotStartedFilterFunction<B extends DateCell = DateCell>(now?: Date): DateCellDurationSpanFilterFunction<B>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a filter that passes date cell duration spans whose computed end time is at or before the given reference time.
|
|
39
|
+
*
|
|
40
|
+
* The end time is derived from the span's start time and duration via {@link dateDurationSpanEndDate}.
|
|
41
|
+
* Useful for identifying completed events.
|
|
42
|
+
*
|
|
43
|
+
* @param now - Reference time to compare against. Defaults to the current time.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const hasEnded = dateCellDurationSpanHasEndedFilterFunction(new Date());
|
|
48
|
+
* const completedSpans = allSpans.filter(hasEnded);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
7
51
|
export declare function dateCellDurationSpanHasEndedFilterFunction<B extends DateCell = DateCell>(now?: Date): DateCellDurationSpanFilterFunction<B>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a filter that passes date cell duration spans whose computed end time is strictly after the given reference time.
|
|
54
|
+
*
|
|
55
|
+
* The inverse of {@link dateCellDurationSpanHasEndedFilterFunction}. Useful for finding events that are
|
|
56
|
+
* still in progress or have not yet occurred.
|
|
57
|
+
*
|
|
58
|
+
* @param now - Reference time to compare against. Defaults to the current time.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const hasNotEnded = dateCellDurationSpanHasNotEndedFilterFunction(new Date());
|
|
63
|
+
* const activeOrFutureSpans = allSpans.filter(hasNotEnded);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
8
66
|
export declare function dateCellDurationSpanHasNotEndedFilterFunction<B extends DateCell = DateCell>(now?: Date): DateCellDurationSpanFilterFunction<B>;
|
|
9
67
|
/**
|
|
10
|
-
*
|
|
68
|
+
* Adjusts or removes date cells so they fit within a configured {@link DateCellRange}.
|
|
69
|
+
*
|
|
70
|
+
* Cells fully within the range pass through unchanged. Cells that partially overlap are
|
|
71
|
+
* clamped to the range boundaries. Cells entirely outside the range are removed.
|
|
11
72
|
*/
|
|
12
73
|
export type ModifyDateCellsToFitRangeFunction = <B extends DateCell | DateCellRange | UniqueDateCell>(input: B[]) => B[];
|
|
13
74
|
/**
|
|
14
|
-
*
|
|
75
|
+
* Creates a reusable {@link ModifyDateCellsToFitRangeFunction} that clamps or filters date cells
|
|
76
|
+
* to fit within the given range.
|
|
77
|
+
*
|
|
78
|
+
* Cells fully contained in the range are returned as-is. Overlapping cells have their `i` and `to`
|
|
79
|
+
* indices clamped to the range boundaries. Non-overlapping cells are excluded entirely.
|
|
80
|
+
*
|
|
81
|
+
* @param range - The target range to fit cells into.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const fitToRange = modifyDateCellsToFitRangeFunction({ i: 5, to: 15 });
|
|
86
|
+
* const fitted = fitToRange(dateCells); // cells clamped to [5, 15]
|
|
87
|
+
* ```
|
|
15
88
|
*/
|
|
16
89
|
export declare function modifyDateCellsToFitRangeFunction(range: DateCellRange): ModifyDateCellsToFitRangeFunction;
|
|
90
|
+
/**
|
|
91
|
+
* Convenience function that applies {@link modifyDateCellsToFitRangeFunction} directly to an array of date cells.
|
|
92
|
+
*
|
|
93
|
+
* Prefer {@link modifyDateCellsToFitRangeFunction} when processing multiple arrays against the same range
|
|
94
|
+
* to avoid recomputing the range boundaries each time.
|
|
95
|
+
*
|
|
96
|
+
* @param range - The target range to fit cells into.
|
|
97
|
+
* @param input - The date cells to clamp or filter.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const fitted = modifyDateCellsToFitRange({ i: 0, to: 10 }, dateCells);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
17
104
|
export declare function modifyDateCellsToFitRange<B extends DateCell | DateCellRange | UniqueDateCell>(range: DateCellRange, input: B[]): B[];
|
|
105
|
+
/**
|
|
106
|
+
* Convenience function that fits a single date cell to the given range, returning `undefined` if
|
|
107
|
+
* the cell does not overlap the range at all.
|
|
108
|
+
*
|
|
109
|
+
* @param range - The target range to fit the cell into.
|
|
110
|
+
* @param input - The single date cell to clamp or exclude.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const fitted = modifyDateCellToFitRange({ i: 0, to: 10 }, dateCell);
|
|
115
|
+
* if (fitted) {
|
|
116
|
+
* // cell overlaps the range
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
18
120
|
export declare function modifyDateCellToFitRange<B extends DateCell | DateCellRange | UniqueDateCell>(range: DateCellRange, input: B): Maybe<B>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Maybe, type SortCompareFunction, type RequiredOnKeys, type ArrayOrValue, type UniqueModel, type IndexNumber, type FactoryWithRequiredInput, type DateRelativeState } from '@dereekb/util';
|
|
2
|
-
import { DateCell, type DateOrDateCellIndex, type DateCellIndex } from './date.cell';
|
|
2
|
+
import { type DateCell, type DateOrDateCellIndex, type DateCellIndex } from './date.cell';
|
|
3
3
|
import { type DateRange } from './date.range';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a range of DateCell values.
|
|
@@ -12,17 +12,19 @@ export interface DateCellRange extends DateCell {
|
|
|
12
12
|
*/
|
|
13
13
|
to?: DateCellIndex;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* ArkType schema for {@link DateCellRange}.
|
|
17
|
+
*/
|
|
18
|
+
export declare const dateCellRangeType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
19
|
+
i: number;
|
|
20
|
+
to?: number | undefined;
|
|
21
|
+
}, {}>;
|
|
19
22
|
/**
|
|
20
23
|
* Returns true if the input is a DateCellRange.
|
|
21
24
|
*
|
|
22
|
-
* Does not check validity. Use isValidDateCellRange
|
|
25
|
+
* Does not check validity. Use {@link isValidDateCellRange} for that.
|
|
23
26
|
*
|
|
24
|
-
* @param input
|
|
25
|
-
* @returns
|
|
27
|
+
* @param input - value to check
|
|
26
28
|
*/
|
|
27
29
|
export declare function isDateCellRange(input: unknown): input is DateCellRange;
|
|
28
30
|
/**
|
|
@@ -32,39 +34,56 @@ export type DateCellOrDateCellIndexOrDateCellRange = DateCellIndex | DateCell |
|
|
|
32
34
|
/**
|
|
33
35
|
* Returns true if the input is a valid DateCellRange.
|
|
34
36
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
+
* A valid range has a non-negative integer `i`, and if `to` is defined it must also be a valid index
|
|
38
|
+
* that is greater than or equal to `i`.
|
|
39
|
+
*
|
|
40
|
+
* @param input - range to validate
|
|
37
41
|
*/
|
|
38
42
|
export declare function isValidDateCellRange(input: DateCellRange): boolean;
|
|
39
43
|
/**
|
|
40
44
|
* Returns true if the input is a sorted DateCellRange array and there are no repeat indexes.
|
|
41
45
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
46
|
+
* Validates that each range is individually valid and that no ranges overlap or appear out of order.
|
|
47
|
+
*
|
|
48
|
+
* @param input - array of ranges to validate as a non-overlapping ascending series
|
|
44
49
|
*/
|
|
45
50
|
export declare function isValidDateCellRangeSeries(input: DateCellRange[]): boolean;
|
|
46
51
|
/**
|
|
47
52
|
* Returns the lowest index between all the input date block ranges. Returns 0 by default if there is no minimum or input blocks.
|
|
48
53
|
*
|
|
49
54
|
* The input range is not expected to be sorted.
|
|
55
|
+
*
|
|
56
|
+
* @param input - unsorted array of date cell ranges to scan
|
|
50
57
|
*/
|
|
51
58
|
export declare function getLeastDateCellIndexInDateCellRanges(input: (DateCell | DateCellRange)[]): DateCellIndex;
|
|
52
59
|
/**
|
|
53
60
|
* Returns the largest index between all the input date block ranges. Returns 0 by default.
|
|
54
61
|
*
|
|
55
62
|
* The input range is not expected to be sorted.
|
|
63
|
+
*
|
|
64
|
+
* @param input - unsorted array of date cell ranges to scan
|
|
56
65
|
*/
|
|
57
66
|
export declare function getGreatestDateCellIndexInDateCellRanges(input: (DateCell | DateCellRange)[]): DateCellIndex;
|
|
67
|
+
/**
|
|
68
|
+
* Result containing both the smallest and largest indexes found across a set of date cell ranges,
|
|
69
|
+
* along with references to the items that contain those extreme indexes.
|
|
70
|
+
*/
|
|
58
71
|
export interface LeastAndGreatestDateCellIndexResult<T> {
|
|
72
|
+
/** Smallest starting index found. */
|
|
59
73
|
leastIndex: number;
|
|
74
|
+
/** The item containing the smallest starting index. */
|
|
60
75
|
leastIndexItem: T;
|
|
76
|
+
/** Largest ending index found (considers `to` values). */
|
|
61
77
|
greatestIndex: number;
|
|
78
|
+
/** The item containing the largest ending index. */
|
|
62
79
|
greatestIndexItem: T;
|
|
63
80
|
}
|
|
64
81
|
/**
|
|
65
|
-
* Returns the
|
|
82
|
+
* Returns both the least and greatest indexes across all input date cell ranges, or null if the input is empty.
|
|
66
83
|
*
|
|
67
84
|
* The input range is not expected to be sorted.
|
|
85
|
+
*
|
|
86
|
+
* @param input - unsorted array of date cell ranges to scan
|
|
68
87
|
*/
|
|
69
88
|
export declare function getLeastAndGreatestDateCellIndexInDateCellRanges<T extends DateCellRange>(input: T[]): Maybe<LeastAndGreatestDateCellIndexResult<T>>;
|
|
70
89
|
/**
|
|
@@ -74,28 +93,33 @@ export interface DateCellRangeOrDateRange {
|
|
|
74
93
|
start?: Maybe<DateOrDateCellIndex>;
|
|
75
94
|
end?: Maybe<DateOrDateCellIndex>;
|
|
76
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Union type allowing a Date, DateCellIndex, or DateCellRange as input.
|
|
98
|
+
*/
|
|
77
99
|
export type DateOrDateCellIndexOrDateCellRange = DateOrDateCellIndex | DateCellRange;
|
|
100
|
+
/**
|
|
101
|
+
* Union type extending {@link DateOrDateCellIndexOrDateCellRange} to also accept a {@link DateRange}.
|
|
102
|
+
*/
|
|
78
103
|
export type DateOrDateRangeOrDateCellIndexOrDateCellRange = DateRange | DateOrDateCellIndexOrDateCellRange;
|
|
79
104
|
/**
|
|
80
|
-
* Creates a
|
|
105
|
+
* Creates a {@link DateCellRangeWithRange} with the given start and optional end index.
|
|
106
|
+
* If `to` is omitted the range covers a single cell at index `i`.
|
|
81
107
|
*
|
|
82
|
-
* @param i
|
|
83
|
-
* @param to
|
|
84
|
-
* @returns
|
|
108
|
+
* @param i - starting cell index
|
|
109
|
+
* @param to - ending cell index (inclusive); defaults to `i`
|
|
85
110
|
*/
|
|
86
111
|
export declare function dateCellRange(i: number, to?: number): DateCellRangeWithRange;
|
|
87
112
|
/**
|
|
88
|
-
* Creates a DateCellRangeWithRange
|
|
113
|
+
* Creates a single-cell {@link DateCellRangeWithRange} where both `i` and `to` equal the given index.
|
|
89
114
|
*
|
|
90
|
-
* @param dateCellIndex
|
|
91
|
-
* @returns
|
|
115
|
+
* @param dateCellIndex - the index for both start and end of the range
|
|
92
116
|
*/
|
|
93
117
|
export declare function dateCellRangeWithRangeFromIndex(dateCellIndex: DateCellIndex): DateCellRangeWithRange;
|
|
94
118
|
/**
|
|
95
|
-
*
|
|
119
|
+
* Normalizes any {@link DateCellOrDateCellIndexOrDateCellRange} into a {@link DateCellRangeWithRange},
|
|
120
|
+
* ensuring the result always has an explicit `to` value.
|
|
96
121
|
*
|
|
97
|
-
* @param input
|
|
98
|
-
* @returns
|
|
122
|
+
* @param input - index, cell, or range to normalize
|
|
99
123
|
*/
|
|
100
124
|
export declare function dateCellRangeWithRange(input: DateCellOrDateCellIndexOrDateCellRange): DateCellRangeWithRange;
|
|
101
125
|
/**
|
|
@@ -103,10 +127,10 @@ export declare function dateCellRangeWithRange(input: DateCellOrDateCellIndexOrD
|
|
|
103
127
|
*/
|
|
104
128
|
export type DateCellRangeIncludedByRangeFunction = (range: DateCellOrDateCellIndexOrDateCellRange) => boolean;
|
|
105
129
|
/**
|
|
106
|
-
* Creates a DateCellRangeIncludedByRangeFunction
|
|
130
|
+
* Creates a {@link DateCellRangeIncludedByRangeFunction} that checks whether a given range
|
|
131
|
+
* fully contains the configured `inputRange`.
|
|
107
132
|
*
|
|
108
|
-
* @param inputRange
|
|
109
|
-
* @returns
|
|
133
|
+
* @param inputRange - the range that must be fully included
|
|
110
134
|
*/
|
|
111
135
|
export declare function dateCellRangeIncludedByRangeFunction(inputRange: DateCellOrDateCellIndexOrDateCellRange): DateCellRangeIncludedByRangeFunction;
|
|
112
136
|
/**
|
|
@@ -114,33 +138,29 @@ export declare function dateCellRangeIncludedByRangeFunction(inputRange: DateCel
|
|
|
114
138
|
*/
|
|
115
139
|
export type DateCellRangeOverlapsRangeFunction = (range: DateCellOrDateCellIndexOrDateCellRange) => boolean;
|
|
116
140
|
/**
|
|
117
|
-
* Creates a DateCellRangeOverlapsRangeFunction
|
|
141
|
+
* Creates a {@link DateCellRangeOverlapsRangeFunction} that checks whether a given range
|
|
142
|
+
* has any overlap with the configured `inputRange`.
|
|
118
143
|
*
|
|
119
|
-
* @param inputRange
|
|
120
|
-
* @returns
|
|
144
|
+
* @param inputRange - the range to test for overlap against
|
|
121
145
|
*/
|
|
122
146
|
export declare function dateCellRangeOverlapsRangeFunction(inputRange: DateCellOrDateCellIndexOrDateCellRange): DateCellRangeOverlapsRangeFunction;
|
|
123
147
|
/**
|
|
124
|
-
* Returns true if
|
|
148
|
+
* Returns true if the two ranges share at least one common index.
|
|
125
149
|
*
|
|
126
|
-
* @param rangeA
|
|
127
|
-
* @param rangeB
|
|
128
|
-
* @returns
|
|
150
|
+
* @param rangeA - first range to compare
|
|
151
|
+
* @param rangeB - second range to compare
|
|
129
152
|
*/
|
|
130
153
|
export declare function dateCellRangeOverlapsRange(rangeA: DateCellOrDateCellIndexOrDateCellRange, rangeB: DateCellOrDateCellIndexOrDateCellRange): boolean;
|
|
131
154
|
/**
|
|
132
|
-
*
|
|
155
|
+
* Returns a sort comparator that orders ranges first by starting index (`i`), then by ending index (`to`).
|
|
133
156
|
*
|
|
134
|
-
* In many cases sortAscendingIndexNumberRefFunction may be preferential.
|
|
135
|
-
*
|
|
136
|
-
* @returns
|
|
157
|
+
* In many cases {@link sortAscendingIndexNumberRefFunction} may be preferential when `to` ordering is not needed.
|
|
137
158
|
*/
|
|
138
159
|
export declare function sortDateCellRangeAndSizeFunction<T extends DateCellRange>(): SortCompareFunction<T>;
|
|
139
160
|
/**
|
|
140
|
-
* Sorts the input date ranges
|
|
161
|
+
* Sorts the input date ranges in-place by ascending index using {@link sortAscendingIndexNumberRefFunction}.
|
|
141
162
|
*
|
|
142
|
-
* @param input
|
|
143
|
-
* @returns
|
|
163
|
+
* @param input - array of ranges to sort (mutated in place)
|
|
144
164
|
*/
|
|
145
165
|
export declare function sortDateCellRanges<T extends DateCellRange>(input: T[]): T[];
|
|
146
166
|
/**
|
|
@@ -148,77 +168,109 @@ export declare function sortDateCellRanges<T extends DateCellRange>(input: T[]):
|
|
|
148
168
|
*/
|
|
149
169
|
export type DateCellRangeWithRange = RequiredOnKeys<DateCellRange, 'to'>;
|
|
150
170
|
/**
|
|
151
|
-
*
|
|
171
|
+
* Merges an array of {@link DateCell} or {@link DateCellRange} values into the smallest set of
|
|
172
|
+
* contiguous {@link DateCellRangeWithRange} values. Adjacent or overlapping ranges are combined.
|
|
173
|
+
*
|
|
174
|
+
* The input is sorted internally before grouping.
|
|
175
|
+
*
|
|
176
|
+
* @param input - cells or ranges to merge into contiguous groups
|
|
152
177
|
*
|
|
153
|
-
* @
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* // Three adjacent cells collapse into one range
|
|
181
|
+
* groupToDateCellRanges([{ i: 0 }, { i: 1 }, { i: 2 }]);
|
|
182
|
+
* // => [{ i: 0, to: 2 }]
|
|
183
|
+
*
|
|
184
|
+
* // Non-adjacent cells produce separate ranges
|
|
185
|
+
* groupToDateCellRanges([{ i: 0 }, { i: 5 }]);
|
|
186
|
+
* // => [{ i: 0, to: 0 }, { i: 5, to: 5 }]
|
|
187
|
+
* ```
|
|
154
188
|
*/
|
|
155
189
|
export declare function groupToDateCellRanges(input: (DateCell | DateCellRange)[]): DateCellRangeWithRange[];
|
|
156
190
|
/**
|
|
157
|
-
* Returns an array containing
|
|
191
|
+
* Returns an array containing every individual index in the given date cell range (inclusive of both `i` and `to`).
|
|
192
|
+
*
|
|
193
|
+
* @param input - range to expand into individual indexes
|
|
158
194
|
*/
|
|
159
195
|
export declare function allIndexesInDateCellRange(input: DateCellRange): DateCellIndex[];
|
|
160
196
|
/**
|
|
161
|
-
*
|
|
197
|
+
* Flattens an array of indexes and/or ranges into a single array of individual {@link DateCellIndex} values.
|
|
162
198
|
*
|
|
163
|
-
* @param input
|
|
164
|
-
* @returns
|
|
199
|
+
* @param input - mix of raw indexes and ranges to flatten
|
|
165
200
|
*/
|
|
166
201
|
export declare function allIndexesInDateCellRangesToArray(input: (DateCellIndex | DateCellRange)[]): DateCellIndex[];
|
|
167
202
|
/**
|
|
168
|
-
* Returns
|
|
203
|
+
* Returns a deduplicated {@link Set} of all indexes within the input ranges.
|
|
169
204
|
*
|
|
170
|
-
* @param input
|
|
171
|
-
* @returns
|
|
205
|
+
* @param input - mix of raw indexes and ranges to collect
|
|
172
206
|
*/
|
|
173
207
|
export declare function allIndexesInDateCellRanges(input: (DateCellIndex | DateCellRange)[]): Set<DateCellIndex>;
|
|
174
208
|
/**
|
|
175
|
-
*
|
|
209
|
+
* Filters the input blocks, returning only those that fall entirely within the given range.
|
|
176
210
|
*
|
|
177
|
-
* @param blocks
|
|
178
|
-
* @param range
|
|
179
|
-
* @returns
|
|
211
|
+
* @param blocks - cells or ranges to filter
|
|
212
|
+
* @param range - bounding range that blocks must fall within
|
|
180
213
|
*/
|
|
181
214
|
export declare function filterDateCellsInDateCellRange<T extends DateCell | DateCellRange>(blocks: T[], range: DateCellRangeWithRange): T[];
|
|
215
|
+
/**
|
|
216
|
+
* Accepted input types for range-containment checks: a raw index, a {@link DateCell}, or a {@link DateCellRange}.
|
|
217
|
+
*/
|
|
182
218
|
export type IsDateCellWithinDateCellRangeInput = DateCellOrDateCellIndexOrDateCellRange;
|
|
183
219
|
/**
|
|
184
220
|
* Function that returns true if the input range is equal or falls within the configured DateCellRange.
|
|
185
221
|
*/
|
|
186
222
|
export type IsDateCellWithinDateCellRangeFunction = (input: IsDateCellWithinDateCellRangeInput) => boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Creates an {@link IsDateCellWithinDateCellRangeFunction} that tests whether a given cell or range
|
|
225
|
+
* is fully contained within `inputRange`.
|
|
226
|
+
*
|
|
227
|
+
* @param inputRange - the bounding range to test containment against
|
|
228
|
+
*/
|
|
187
229
|
export declare function isDateCellWithinDateCellRangeFunction(inputRange: IsDateCellWithinDateCellRangeInput): IsDateCellWithinDateCellRangeFunction;
|
|
188
230
|
/**
|
|
189
|
-
* Returns true if
|
|
231
|
+
* Returns true if `contains` is fully within `range`.
|
|
190
232
|
*
|
|
191
|
-
* @param range
|
|
192
|
-
* @param
|
|
193
|
-
* @returns
|
|
233
|
+
* @param range - the outer bounding range
|
|
234
|
+
* @param contains - the cell or range to test for containment
|
|
194
235
|
*/
|
|
195
236
|
export declare function isDateCellWithinDateCellRange(range: IsDateCellWithinDateCellRangeInput, contains: IsDateCellWithinDateCellRangeInput): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Statistical information about the blocks in a set of date cell ranges.
|
|
239
|
+
*/
|
|
196
240
|
export interface DateCellRangeBlockCountInfo {
|
|
197
241
|
/**
|
|
198
|
-
* Total number of
|
|
242
|
+
* Total number of individual cell indexes across all ranges.
|
|
199
243
|
*/
|
|
200
244
|
readonly count: number;
|
|
201
245
|
/**
|
|
202
|
-
*
|
|
246
|
+
* Sum of all individual indexes. Used for calculating the average.
|
|
203
247
|
*/
|
|
204
248
|
readonly total: number;
|
|
205
249
|
/**
|
|
206
|
-
* The average block index
|
|
250
|
+
* The average block index (total / count), or 0 if count is 0.
|
|
207
251
|
*/
|
|
208
252
|
readonly average: number;
|
|
209
253
|
}
|
|
210
254
|
/**
|
|
211
|
-
*
|
|
255
|
+
* Computes {@link DateCellRangeBlockCountInfo} (count, total, average) for the given date cell ranges.
|
|
256
|
+
*
|
|
257
|
+
* Internally groups overlapping ranges before counting so each index is counted only once.
|
|
212
258
|
*
|
|
213
|
-
* @param inputDateCellRange
|
|
214
|
-
* @returns
|
|
259
|
+
* @param inputDateCellRange - one or more cells/ranges to analyze
|
|
215
260
|
*/
|
|
216
261
|
export declare function dateCellRangeBlocksCountInfo(inputDateCellRange: ArrayOrValue<DateCell | DateCellRange>): DateCellRangeBlockCountInfo;
|
|
217
262
|
/**
|
|
218
|
-
* Counts the number of
|
|
263
|
+
* Counts the total number of individual cell indexes across the given date cell ranges.
|
|
264
|
+
*
|
|
265
|
+
* Shorthand for `dateCellRangeBlocksCountInfo(input).count`.
|
|
219
266
|
*
|
|
220
|
-
* @param inputDateCellRange
|
|
221
|
-
*
|
|
267
|
+
* @param inputDateCellRange - one or more cells/ranges to count
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* dateCellRangeBlocksCount({ i: 0, to: 4 }); // => 5
|
|
272
|
+
* dateCellRangeBlocksCount([{ i: 0, to: 2 }, { i: 10, to: 12 }]); // => 6
|
|
273
|
+
* ```
|
|
222
274
|
*/
|
|
223
275
|
export declare function dateCellRangeBlocksCount(inputDateCellRange: ArrayOrValue<DateCell | DateCellRange>): number;
|
|
224
276
|
/**
|
|
@@ -226,66 +278,98 @@ export declare function dateCellRangeBlocksCount(inputDateCellRange: ArrayOrValu
|
|
|
226
278
|
*/
|
|
227
279
|
export type DateCellRangesFullyCoverDateCellRangeFunction = (range: DateCellRange) => boolean;
|
|
228
280
|
/**
|
|
229
|
-
* Creates a
|
|
281
|
+
* Creates a {@link DateCellRangesFullyCoverDateCellRangeFunction} that checks whether any single
|
|
282
|
+
* grouped range from `ranges` fully covers a given input range.
|
|
230
283
|
*
|
|
231
|
-
* @param ranges
|
|
232
|
-
* @returns
|
|
284
|
+
* @param ranges - the covering ranges to test against
|
|
233
285
|
*/
|
|
234
286
|
export declare function dateCellRangesFullyCoverDateCellRangeFunction(ranges: ArrayOrValue<DateCellRange>): DateCellRangesFullyCoverDateCellRangeFunction;
|
|
287
|
+
/**
|
|
288
|
+
* Input configuration for {@link getNextDateCellTimingIndex}.
|
|
289
|
+
*/
|
|
235
290
|
export interface GetNextDateCellTimingIndexInput<T extends DateCellRange> {
|
|
236
291
|
/**
|
|
237
|
-
*
|
|
292
|
+
* The "current" index to evaluate against (typically represents "now").
|
|
238
293
|
*/
|
|
239
294
|
readonly currentIndex: DateCellIndex;
|
|
240
295
|
/**
|
|
241
|
-
* All possible ranges to
|
|
296
|
+
* All possible ranges to classify as past, present, or future relative to `currentIndex`.
|
|
242
297
|
*/
|
|
243
298
|
readonly ranges: ArrayOrValue<T>;
|
|
244
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Result of {@link getNextDateCellTimingIndex}, classifying ranges relative to a current index
|
|
302
|
+
* and identifying the next upcoming index/range.
|
|
303
|
+
*/
|
|
245
304
|
export interface GetNextDateCellTimingIndexResult<T extends DateCellRange> {
|
|
246
305
|
/**
|
|
247
|
-
* The
|
|
306
|
+
* The first range that contains the current index, if any.
|
|
248
307
|
*/
|
|
249
308
|
readonly currentResult: Maybe<T>;
|
|
250
309
|
/**
|
|
251
|
-
* The next
|
|
310
|
+
* The next index after `currentIndex` that is covered by a range, or undefined if no future ranges exist.
|
|
252
311
|
*/
|
|
253
312
|
readonly nextIndex: Maybe<DateCellIndex>;
|
|
254
313
|
/**
|
|
255
|
-
* The
|
|
314
|
+
* The range that contains {@link nextIndex}, if available.
|
|
256
315
|
*/
|
|
257
316
|
readonly nextResult: Maybe<T>;
|
|
258
317
|
/**
|
|
259
|
-
* All ranges that
|
|
318
|
+
* All ranges that contain the current index (i.e., the index falls within their `i..to` span).
|
|
260
319
|
*/
|
|
261
320
|
readonly presentResults: T[];
|
|
262
321
|
/**
|
|
263
|
-
* All ranges
|
|
322
|
+
* All ranges whose `to` is before the current index.
|
|
264
323
|
*/
|
|
265
324
|
readonly pastResults: T[];
|
|
266
325
|
/**
|
|
267
|
-
* All ranges
|
|
326
|
+
* All ranges whose `i` is after the current index.
|
|
268
327
|
*/
|
|
269
328
|
readonly futureResults: T[];
|
|
270
329
|
}
|
|
271
330
|
/**
|
|
272
|
-
*
|
|
331
|
+
* Classifies the given ranges as past, present, or future relative to `currentIndex`, and determines
|
|
332
|
+
* the next upcoming index. Useful for "what comes next" scheduling logic against date cell timings.
|
|
273
333
|
*
|
|
274
|
-
*
|
|
334
|
+
* If a present range continues past `currentIndex`, its next index is preferred. Otherwise the
|
|
335
|
+
* nearest future range's starting index is used.
|
|
336
|
+
*
|
|
337
|
+
* @param input - the current index and ranges to evaluate
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* const result = getNextDateCellTimingIndex({
|
|
342
|
+
* currentIndex: 5,
|
|
343
|
+
* ranges: [
|
|
344
|
+
* { i: 0, to: 3 }, // past
|
|
345
|
+
* { i: 4, to: 7 }, // present (contains 5)
|
|
346
|
+
* { i: 10, to: 12 } // future
|
|
347
|
+
* ]
|
|
348
|
+
* });
|
|
349
|
+
* // result.currentResult => { i: 4, to: 7 }
|
|
350
|
+
* // result.nextIndex => 6
|
|
351
|
+
* // result.pastResults.length => 1
|
|
352
|
+
* ```
|
|
275
353
|
*/
|
|
276
354
|
export declare function getNextDateCellTimingIndex<T extends DateCellRange>(input: GetNextDateCellTimingIndexInput<T>): GetNextDateCellTimingIndexResult<T>;
|
|
277
355
|
/**
|
|
278
|
-
*
|
|
356
|
+
* Determines whether a range is in the past, present, or future relative to a given index.
|
|
279
357
|
*
|
|
280
|
-
* @param
|
|
281
|
-
* @param
|
|
358
|
+
* @param range - the date cell range to classify
|
|
359
|
+
* @param nowIndex - the reference index representing "now"
|
|
282
360
|
*/
|
|
283
361
|
export declare function dateRelativeStateForDateCellRangeComparedToIndex(range: DateCellRange, nowIndex: DateCellIndex): DateRelativeState;
|
|
284
362
|
/**
|
|
285
|
-
* Expands a DateCellRange into an array of
|
|
363
|
+
* Expands a {@link DateCellRange} into an array of individual single-cell copies, one per index
|
|
364
|
+
* from `i` to `to` (inclusive). Each copy retains all properties of the original block.
|
|
365
|
+
*
|
|
366
|
+
* @param block - the range to expand
|
|
286
367
|
*
|
|
287
|
-
* @
|
|
288
|
-
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* expandDateCellRange({ i: 2, to: 4, data: 'x' });
|
|
371
|
+
* // => [{ i: 2, to: 2, data: 'x' }, { i: 3, to: 3, data: 'x' }, { i: 4, to: 4, data: 'x' }]
|
|
372
|
+
* ```
|
|
289
373
|
*/
|
|
290
374
|
export declare function expandDateCellRange<B extends DateCellRange | DateCellRangeWithRange>(block: B): B[];
|
|
291
375
|
/**
|
|
@@ -299,16 +383,15 @@ export interface UniqueDateCell extends DateCell, UniqueModel {
|
|
|
299
383
|
export interface UniqueDateCellRange extends UniqueDateCell, DateCellRange {
|
|
300
384
|
}
|
|
301
385
|
/**
|
|
302
|
-
* Returns true if the input
|
|
386
|
+
* Returns true if the input spans more than one cell (i.e., has a `to` value strictly greater than `i`).
|
|
303
387
|
*
|
|
304
|
-
* @param input
|
|
388
|
+
* @param input - range or cell to check
|
|
305
389
|
*/
|
|
306
390
|
export declare function dateCellRangeHasRange(input: DateCellRange | UniqueDateCell): input is DateCellRangeWithRange;
|
|
307
391
|
/**
|
|
308
|
-
*
|
|
392
|
+
* Returns the effective ending index of a range: `to` if defined, otherwise `i`.
|
|
309
393
|
*
|
|
310
|
-
* @param input
|
|
311
|
-
* @returns
|
|
394
|
+
* @param input - range or cell to read
|
|
312
395
|
*/
|
|
313
396
|
export declare function dateCellEndIndex(input: DateCellRange | UniqueDateCell): IndexNumber;
|
|
314
397
|
/**
|
|
@@ -321,7 +404,11 @@ export interface UniqueDateCellRangeGroup<B extends DateCellRange | UniqueDateCe
|
|
|
321
404
|
blocks: B[];
|
|
322
405
|
}
|
|
323
406
|
/**
|
|
324
|
-
* Groups all input DateCellRange or UniqueDateCell values into a
|
|
407
|
+
* Groups all input {@link DateCellRange} or {@link UniqueDateCell} values into a single
|
|
408
|
+
* {@link UniqueDateCellRangeGroup}, sorting them by index. The group's `i` is always 0
|
|
409
|
+
* and `to` is the maximum ending index across all blocks.
|
|
410
|
+
*
|
|
411
|
+
* @param input - cells or ranges to group
|
|
325
412
|
*/
|
|
326
413
|
export declare function groupUniqueDateCells<B extends DateCellRange | UniqueDateCell>(input: B[]): UniqueDateCellRangeGroup<B>;
|
|
327
414
|
/**
|
|
@@ -368,9 +455,14 @@ export interface ExpandUniqueDateCellsConfig<B extends DateCellRange | UniqueDat
|
|
|
368
455
|
*/
|
|
369
456
|
fillFactory?: FactoryWithRequiredInput<B, DateCellRangeWithRange>;
|
|
370
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Result of {@link ExpandUniqueDateCellsFunction}, containing the merged/expanded blocks
|
|
460
|
+
* and any blocks that were fully discarded during the merge process.
|
|
461
|
+
*/
|
|
371
462
|
export interface ExpandUniqueDateCellsResult<B extends DateCellRange | UniqueDateCell> extends UniqueDateCellRangeGroup<B> {
|
|
372
463
|
/**
|
|
373
|
-
* Blocks that were
|
|
464
|
+
* Blocks that were completely removed due to overlap resolution. Some blocks may be partially retained
|
|
465
|
+
* (with adjusted `i`/`to`) and appear in `blocks` instead.
|
|
374
466
|
*/
|
|
375
467
|
discarded: B[];
|
|
376
468
|
}
|
|
@@ -380,4 +472,22 @@ export interface ExpandUniqueDateCellsResult<B extends DateCellRange | UniqueDat
|
|
|
380
472
|
* Can optionally specify a second array/group of blocks that are treated as "next" blocks which can take priority or not depending on the retain options.
|
|
381
473
|
*/
|
|
382
474
|
export type ExpandUniqueDateCellsFunction<B extends DateCellRange | UniqueDateCell> = (input: B[] | UniqueDateCellRangeGroup<B>, newBlocks?: B[] | UniqueDateCellRangeGroup<B>) => ExpandUniqueDateCellsResult<B>;
|
|
475
|
+
/**
|
|
476
|
+
* Creates an {@link ExpandUniqueDateCellsFunction} that sorts, merges, and fills date cell ranges
|
|
477
|
+
* according to the provided configuration. Handles overlap resolution, gap filling, and boundary clamping.
|
|
478
|
+
*
|
|
479
|
+
* @param config - controls start/end bounds, fill strategy, and overlap retention behavior
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* const expand = expandUniqueDateCellsFunction({
|
|
484
|
+
* fillOption: 'empty',
|
|
485
|
+
* startAtIndex: 0,
|
|
486
|
+
* endAtIndex: 10
|
|
487
|
+
* });
|
|
488
|
+
*
|
|
489
|
+
* const result = expand([{ i: 2, to: 5 }, { i: 8, to: 10 }]);
|
|
490
|
+
* // result.blocks => [{ i: 2, to: 5 }, { i: 8, to: 10 }]
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
383
493
|
export declare function expandUniqueDateCellsFunction<B extends DateCellRange | UniqueDateCell>(config: ExpandUniqueDateCellsConfig<B>): ExpandUniqueDateCellsFunction<B>;
|