@dereekb/date 13.0.7 → 13.2.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.
Files changed (40) hide show
  1. package/index.cjs.js +3526 -993
  2. package/index.esm.js +3515 -983
  3. package/package.json +5 -6
  4. package/src/lib/date/date.calendar.d.ts +63 -9
  5. package/src/lib/date/date.cell.d.ts +203 -104
  6. package/src/lib/date/date.cell.factory.d.ts +319 -86
  7. package/src/lib/date/date.cell.filter.d.ts +104 -2
  8. package/src/lib/date/date.cell.index.d.ts +202 -92
  9. package/src/lib/date/date.cell.schedule.d.ts +285 -102
  10. package/src/lib/date/date.cell.schedule.day.d.ts +13 -3
  11. package/src/lib/date/date.cell.validator.d.ts +17 -8
  12. package/src/lib/date/date.cell.week.d.ts +24 -3
  13. package/src/lib/date/date.d.ts +481 -54
  14. package/src/lib/date/date.day.d.ts +139 -49
  15. package/src/lib/date/date.duration.d.ts +49 -11
  16. package/src/lib/date/date.format.d.ts +355 -36
  17. package/src/lib/date/date.hashset.d.ts +11 -0
  18. package/src/lib/date/date.logical.d.ts +61 -3
  19. package/src/lib/date/date.range.d.ts +355 -77
  20. package/src/lib/date/date.range.string.d.ts +39 -0
  21. package/src/lib/date/date.range.timezone.d.ts +18 -6
  22. package/src/lib/date/date.round.d.ts +46 -1
  23. package/src/lib/date/date.rxjs.d.ts +29 -7
  24. package/src/lib/date/date.sort.d.ts +36 -9
  25. package/src/lib/date/date.time.d.ts +197 -26
  26. package/src/lib/date/date.time.limit.d.ts +67 -4
  27. package/src/lib/date/date.time.minute.d.ts +269 -30
  28. package/src/lib/date/date.timezone.d.ts +286 -70
  29. package/src/lib/date/date.unix.d.ts +3 -0
  30. package/src/lib/date/date.week.d.ts +115 -51
  31. package/src/lib/query/query.builder.d.ts +91 -0
  32. package/src/lib/query/query.builder.mongo.d.ts +50 -0
  33. package/src/lib/query/query.filter.d.ts +29 -2
  34. package/src/lib/query/query.request.d.ts +16 -0
  35. package/src/lib/rrule/date.recurrence.d.ts +66 -22
  36. package/src/lib/rrule/date.rrule.d.ts +131 -8
  37. package/src/lib/rrule/date.rrule.extension.d.ts +50 -9
  38. package/src/lib/rrule/date.rrule.parse.d.ts +85 -2
  39. package/src/lib/timezone/timezone.d.ts +102 -2
  40. package/src/lib/timezone/timezone.validator.d.ts +9 -4
@@ -21,10 +21,15 @@ export type UnknownYearWeekCode = typeof UNKNOWN_YEAR_WEEK_CODE;
21
21
  */
22
22
  export type YearWeekCodeIndex = number;
23
23
  /**
24
- * Returns the YearWeekCodeIndex for the YearWeekCode.
24
+ * Extracts the week-of-year index (1-52) from a {@link YearWeekCode}.
25
25
  *
26
- * @param yearWeekCode
27
- * @returns
26
+ * @param yearWeekCode - the encoded year+week code (e.g. 202401 = week 1 of 2024)
27
+ * @returns the week index portion
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * yearWeekCodeIndex(202415); // 15
32
+ * ```
28
33
  */
29
34
  export declare function yearWeekCodeIndex(yearWeekCode: YearWeekCode): YearWeekCodeIndex;
30
35
  /**
@@ -35,35 +40,59 @@ export interface YearWeekCodePair {
35
40
  year: number;
36
41
  }
37
42
  /**
38
- * Returns the YearWeekCodePair for the YearWeekCode.
43
+ * Decodes a {@link YearWeekCode} into its year and week components.
44
+ *
45
+ * @param yearWeekCode - the encoded year+week code
46
+ * @returns the decoded pair with year and week
39
47
  *
40
- * @param yearWeekCode
41
- * @returns
48
+ * @example
49
+ * ```ts
50
+ * yearWeekCodePair(202415); // { year: 2024, week: 15 }
51
+ * ```
42
52
  */
43
53
  export declare function yearWeekCodePair(yearWeekCode: YearWeekCode): YearWeekCodePair;
44
54
  /**
45
- * Creates a YearWeekCodePair using the input date and the current/system timezone.
55
+ * Creates a {@link YearWeekCodePair} from a Date using the system timezone.
56
+ *
57
+ * Handles year-boundary weeks correctly (e.g. Dec 31 that falls in week 1 of the next year).
58
+ *
59
+ * @param date - the date to compute the week pair for
60
+ * @returns the year and week-of-year pair
46
61
  *
47
- * @param date
48
- * @returns
62
+ * @example
63
+ * ```ts
64
+ * yearWeekCodePairFromDate(new Date('2024-04-15'));
65
+ * // { year: 2024, week: 16 }
66
+ * ```
49
67
  */
50
68
  export declare function yearWeekCodePairFromDate(date: Date): YearWeekCodePair;
51
69
  /**
52
- * Creates a YearWeekCode from the input pair.
70
+ * Encodes a {@link YearWeekCodePair} into a single {@link YearWeekCode} number.
53
71
  *
54
- * @param pair
55
- * @returns
72
+ * @param pair - the year and week to encode
73
+ * @returns the encoded code (e.g. { year: 2024, week: 15 } => 202415)
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * yearWeekCodeFromPair({ year: 2024, week: 15 }); // 202415
78
+ * ```
56
79
  */
57
80
  export declare function yearWeekCodeFromPair(pair: YearWeekCodePair): YearWeekCode;
58
81
  /**
59
- * Creates a YearWeekCode from the input Date.
82
+ * Computes the {@link YearWeekCode} for a Date, optionally in a specific timezone.
83
+ *
84
+ * @param date - the date to compute the week code for
85
+ * @param timezone - optional timezone (defaults to system timezone)
86
+ * @returns the encoded year+week code
60
87
  *
61
- * @param date
62
- * @returns
88
+ * @example
89
+ * ```ts
90
+ * yearWeekCodeFromDate(new Date('2024-04-15')); // 202416
91
+ * ```
63
92
  */
64
93
  export declare function yearWeekCodeFromDate(date: Date, timezone?: YearWeekCodeDateTimezoneInput): YearWeekCode;
65
94
  /**
66
- * Used to convert the input to a YearWeekCode.
95
+ * A function that computes a {@link YearWeekCode} from either a Date or explicit year+week values.
67
96
  */
68
97
  export type YearWeekCodeFactory = ((dateOrYear: Date | number, inputWeek?: YearWeekCodeIndex) => YearWeekCode) & {
69
98
  _normal: DateTimezoneUtcNormalInstance;
@@ -78,24 +107,39 @@ export interface YearWeekCodeConfig {
78
107
  timezone?: YearWeekCodeDateTimezoneInput;
79
108
  }
80
109
  /**
81
- * Creates a DateTimezoneUtcNormalInstance using the input config.
110
+ * Resolves a timezone input into a {@link DateTimezoneUtcNormalInstance} for use with YearWeekCode calculations.
82
111
  *
83
- * @param input
84
- * @returns
112
+ * Falls back to the system timezone instance if the input is falsy.
113
+ *
114
+ * @param input - timezone string, config, or instance
115
+ * @returns the resolved normal instance
85
116
  */
86
117
  export declare function yearWeekCodeDateTimezoneInstance(input: YearWeekCodeDateTimezoneInput): DateTimezoneUtcNormalInstance;
87
118
  /**
88
- * Returns the yearWeekCode for the input system Date or Year/Week combo.
119
+ * Computes the {@link YearWeekCode} from a Date (using system timezone) or from explicit year and week values.
89
120
  *
90
- * @param date
121
+ * @example
122
+ * ```ts
123
+ * yearWeekCode(new Date('2024-04-15')); // 202416
124
+ * yearWeekCode(2024, 15); // 202415
125
+ * ```
91
126
  */
92
127
  export declare function yearWeekCode(date: Date): YearWeekCode;
93
128
  export declare function yearWeekCode(year: number, week: YearWeekCodeIndex): YearWeekCode;
94
129
  /**
95
- * Creates a YearWeekCodeFactory using the optional input config.
130
+ * Creates a {@link YearWeekCodeFactory} that computes YearWeekCode values in the configured timezone.
131
+ *
132
+ * The factory accepts either a Date or explicit year+week values.
96
133
  *
97
- * @param config
98
- * @returns
134
+ * @param config - optional timezone configuration (defaults to system timezone)
135
+ * @returns a factory function for computing YearWeekCode values
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const factory = yearWeekCodeFactory({ timezone: 'America/Chicago' });
140
+ * factory(new Date('2024-04-15')); // 202416
141
+ * factory(2024, 15); // 202415
142
+ * ```
99
143
  */
100
144
  export declare function yearWeekCodeFactory(config?: YearWeekCodeConfig): YearWeekCodeFactory;
101
145
  /**
@@ -103,24 +147,24 @@ export declare function yearWeekCodeFactory(config?: YearWeekCodeConfig): YearWe
103
147
  */
104
148
  export type YearWeekCodeForDateRangeFactory = (dateRange: DateRange) => YearWeekCode[];
105
149
  /**
106
- * Returns the yearWeekCodes for the input Date's calendar month.
150
+ * Returns all {@link YearWeekCode} values that overlap with the given date range, using the system timezone.
107
151
  *
108
- * @param date
152
+ * @param dateRange - the date range to compute week codes for
153
+ * @returns an array of YearWeekCode values covering the range
109
154
  */
110
155
  export declare function yearWeekCodeForDateRange(dateRange: DateRange): YearWeekCode[];
111
156
  /**
112
- * Returns the yearWeekCodes for the input date range's calendar month and evaluates those dates from the input timezone.
113
- *
114
- * The timezone of the DateRange should be passed to ensure the proper yearWeekCodes are returned.
157
+ * Returns all {@link YearWeekCode} values that overlap with the given date range, evaluated in the specified timezone.
115
158
  *
116
- * @param date
159
+ * @param dateRange - the range to compute week codes for
160
+ * @param dateRangeTimezone - the timezone context for accurate week boundary calculation
117
161
  */
118
162
  export declare function yearWeekCodeForDateRangeInTimezone(dateRange: DateRange, dateRangeTimezone: YearWeekCodeDateTimezoneInput): YearWeekCode[];
119
163
  /**
120
- * Create a YearWeekCodeForMonthFactory.
164
+ * Creates a {@link YearWeekCodeForDateRangeFactory} that computes all week codes overlapping a date range.
121
165
  *
122
- * @param factory
123
- * @returns
166
+ * @param factory - the YearWeekCodeFactory to use (defaults to system timezone)
167
+ * @returns a factory that accepts a DateRange and returns overlapping YearWeekCode values
124
168
  */
125
169
  export declare function yearWeekCodeForDateRangeFactory(factory?: YearWeekCodeFactory): YearWeekCodeForDateRangeFactory;
126
170
  /**
@@ -128,38 +172,47 @@ export declare function yearWeekCodeForDateRangeFactory(factory?: YearWeekCodeFa
128
172
  */
129
173
  export type YearWeekCodeForCalendarMonthFactory = (date: Date) => YearWeekCode[];
130
174
  /**
131
- * Returns the yearWeekCodes for the input Date's calendar month.
175
+ * Returns all {@link YearWeekCode} values for the calendar month containing the given date, using the system timezone.
132
176
  *
133
- * The date is expected to be relative to UTC.
134
- *
135
- * @param date
177
+ * @param date - a date within the target month
136
178
  */
137
179
  export declare function yearWeekCodeForCalendarMonth(date: Date): YearWeekCode[];
138
180
  /**
139
- * Create a YearWeekCodeForMonthFactory.
181
+ * Creates a {@link YearWeekCodeForCalendarMonthFactory} that computes all week codes for a calendar month.
140
182
  *
141
- * @param factory
142
- * @returns
183
+ * @param factory - the YearWeekCodeFactory to use (defaults to system timezone)
184
+ * @returns a factory that accepts a Date and returns YearWeekCode values for that month
143
185
  */
144
186
  export declare function yearWeekCodeForCalendarMonthFactory(factory?: YearWeekCodeFactory): YearWeekCodeForCalendarMonthFactory;
145
187
  /**
146
- * Used to convert the input to a YearWeekCode.
188
+ * A function that converts a {@link YearWeekCode} back to the start-of-week Date.
147
189
  */
148
190
  export type YearWeekCodeDateFactory = (yearWeekCode: YearWeekCode) => Date;
149
191
  export type YearWeekCodeDateConfig = Pick<YearWeekCodeConfig, 'timezone'>;
150
192
  /**
151
- * Creates a YearWeekCodeDateFactory using the optional input config.
193
+ * Creates a factory that converts a {@link YearWeekCode} back into the start-of-week Date for that week.
194
+ *
195
+ * @param config - optional timezone configuration
196
+ * @returns a function that converts a YearWeekCode to its corresponding start-of-week Date
152
197
  *
153
- * @param config
154
- * @returns
198
+ * @example
199
+ * ```ts
200
+ * const toDate = yearWeekCodeDateFactory({ timezone: 'America/Chicago' });
201
+ * const weekStart = toDate(202415); // Sunday of week 15, 2024
202
+ * ```
155
203
  */
156
204
  export declare function yearWeekCodeDateFactory(config?: YearWeekCodeDateConfig): YearWeekCodeDateFactory;
157
205
  /**
158
- * Convenience function for calling yearWeekCodeDateFactory() with the input year week code and optional timezone.
206
+ * Returns the start-of-week Date for the given {@link YearWeekCode}, optionally in a specific timezone.
159
207
  *
160
- * @param yearWeekCode
161
- * @param timezone
162
- * @returns
208
+ * @param yearWeekCode - the encoded year+week code
209
+ * @param timezone - optional timezone (defaults to system timezone)
210
+ * @returns the Date at the start of the specified week
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * startOfWeekForYearWeekCode(202415); // Sunday of week 15, 2024
215
+ * ```
163
216
  */
164
217
  export declare function startOfWeekForYearWeekCode(yearWeekCode: YearWeekCode, timezone?: YearWeekCodeDateTimezoneInput): Date;
165
218
  /**
@@ -184,9 +237,20 @@ export interface YearWeekCodeGroupFactoryConfig<B> {
184
237
  dateReader: YearWeekCodeDateReader<B>;
185
238
  }
186
239
  /**
187
- * Creates a YearWeekCodeGroupFactory.
240
+ * Creates a {@link YearWeekCodeGroupFactory} that groups items by their {@link YearWeekCode}.
241
+ *
242
+ * Uses the configured date reader to extract a date or week code from each item, then groups items that share the same week.
243
+ *
244
+ * @param config - reader and factory configuration
245
+ * @returns a factory that groups input items by YearWeekCode
188
246
  *
189
- * @param config
190
- * @returns
247
+ * @example
248
+ * ```ts
249
+ * const group = yearWeekCodeGroupFactory({
250
+ * dateReader: (item) => item.date,
251
+ * });
252
+ * const groups = group([{ date: new Date('2024-04-15') }, { date: new Date('2024-04-16') }]);
253
+ * // groups[0].week === 202416, groups[0].items has both items
254
+ * ```
191
255
  */
192
256
  export declare function yearWeekCodeGroupFactory<B>(config: YearWeekCodeGroupFactoryConfig<B>): YearWeekCodeGroupFactory<B>;
@@ -1,5 +1,11 @@
1
1
  import { type Maybe, type TimezoneString } from '@dereekb/util';
2
2
  import { type DateDayTimezoneHintFilter, type DateItemOccuringFilter, type DateItemQueryStartsEndsFilter, type DateItemRangeFilter } from './query.filter';
3
+ /**
4
+ * Paired time and day filters produced by a {@link DaysAndTimeFiltersFunction}.
5
+ *
6
+ * Separates the UTC-based time filter from the timezone-adjusted day filter so
7
+ * that consumers can apply each independently or together.
8
+ */
3
9
  export interface DaysAndTimeFilter<F> {
4
10
  /**
5
11
  * The time filter is the primary filter.
@@ -10,6 +16,13 @@ export interface DaysAndTimeFilter<F> {
10
16
  */
11
17
  daysFilter: Maybe<F>;
12
18
  }
19
+ /**
20
+ * Intermediate representation of a date query before it is compiled into
21
+ * database-specific filters via a {@link DateQueryBuilder}.
22
+ *
23
+ * Captures upper/lower bounds for both the starts-at and ends-at fields,
24
+ * plus the implied recurrence range used internally for range-based filtering.
25
+ */
13
26
  export interface RawDateQuery extends DateDayTimezoneHintFilter {
14
27
  timezone?: Maybe<TimezoneString>;
15
28
  startsLte?: Maybe<Date>;
@@ -27,7 +40,10 @@ export interface RawDateQuery extends DateDayTimezoneHintFilter {
27
40
  rEnd?: Maybe<Date>;
28
41
  }
29
42
  /**
43
+ * Strategy interface that converts {@link RawDateQuery} bounds into
44
+ * database-specific range objects (`R`) and field filter objects (`F`).
30
45
  *
46
+ * Implementations are provided for different query backends (e.g. MongoDB-like).
31
47
  */
32
48
  export interface DateQueryBuilder<R, F> {
33
49
  /**
@@ -47,13 +63,88 @@ export type MakeRangeFilterFunction<R> = (gte: Maybe<Date>, lte: Maybe<Date>) =>
47
63
  * The "ends" should be equal to the endsAt end range first, and then the startsAt end range if provided.
48
64
  */
49
65
  export type MergeStartsAtEndsAtFilterFunction<R> = (startsAt: Maybe<R>, endsAt: Maybe<R>) => R;
66
+ /**
67
+ * Input to {@link MakeFieldFilterFunction} containing the optional range
68
+ * objects for starts-at and ends-at fields.
69
+ */
50
70
  export interface MakeFieldFilterInput<R> {
51
71
  startsAt?: Maybe<R>;
52
72
  endsAt?: Maybe<R>;
53
73
  }
54
74
  export type MakeFieldFilterFunction<R, F> = (input: MakeFieldFilterInput<R>) => F;
75
+ /**
76
+ * Builds a {@link RawDateQuery} that matches items occurring at a single point in time.
77
+ *
78
+ * Sets `startsLte` and `endsGte` to the same instant so only items whose
79
+ * active window contains the target date are included.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const query = makeDateQueryForOccuringFilter({
84
+ * occuringAt: new Date('2026-06-15T12:00:00Z'),
85
+ * timezone: 'America/Chicago'
86
+ * });
87
+ * ```
88
+ *
89
+ * @param find - Filter specifying the target date and optional timezone hint.
90
+ * @returns A raw date query representing the "occurring at" constraint.
91
+ */
55
92
  export declare function makeDateQueryForOccuringFilter(find: DateItemOccuringFilter & DateDayTimezoneHintFilter): RawDateQuery;
93
+ /**
94
+ * Builds a {@link RawDateQuery} from a {@link DateItemRangeFilter}, deriving
95
+ * the concrete start/end dates from the provided {@link DateRangeParams}.
96
+ *
97
+ * When `rangeContained` is true, only items fully enclosed within the range
98
+ * are matched. Otherwise items merely overlapping the range are included.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const query = makeDateQueryForDateItemRangeFilter({
103
+ * range: { type: DateRangeType.WEEK, date: new Date() },
104
+ * timezone: 'America/New_York',
105
+ * rangeContained: false
106
+ * });
107
+ * ```
108
+ *
109
+ * @param find - Range filter with optional timezone and containment flag.
110
+ * @returns A raw date query bounded by the resolved range.
111
+ */
56
112
  export declare function makeDateQueryForDateItemRangeFilter(find: DateItemRangeFilter): RawDateQuery;
113
+ /**
114
+ * Builds a {@link RawDateQuery} from explicit starts/ends boundary constraints.
115
+ *
116
+ * Allows callers to independently control the before/after bounds for both
117
+ * the start and end fields of date items.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * const query = makeDateQueryForDateStartsEndsFilter({
122
+ * starts: { after: new Date('2026-01-01'), before: new Date('2026-12-31') },
123
+ * ends: { after: new Date('2026-06-01') },
124
+ * timezone: 'UTC'
125
+ * });
126
+ * ```
127
+ *
128
+ * @param find - Filter with optional starts/ends boundaries and timezone hint.
129
+ * @returns A raw date query with the corresponding GTE/LTE bounds populated.
130
+ */
57
131
  export declare function makeDateQueryForDateStartsEndsFilter(find: DateItemQueryStartsEndsFilter & DateDayTimezoneHintFilter): RawDateQuery;
58
132
  export type DaysAndTimeFiltersFunction<F> = (dateQueryInstance: RawDateQuery) => DaysAndTimeFilter<F>;
133
+ /**
134
+ * Creates a function that splits a {@link RawDateQuery} into separate time
135
+ * and day filters using the supplied {@link DateQueryBuilder}.
136
+ *
137
+ * The day filter is only produced when a timezone is present, allowing
138
+ * timezone-aware day-level filtering alongside the UTC time filter.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const filtersFunction = makeDaysAndTimeFiltersFunction(mongoBuilder);
143
+ * const rawQuery = makeDateQueryForOccuringFilter({ occuringAt: new Date() });
144
+ * const { timeFilter, daysFilter } = filtersFunction(rawQuery);
145
+ * ```
146
+ *
147
+ * @param builder - Strategy for converting date bounds into backend-specific filters.
148
+ * @returns A function that produces a {@link DaysAndTimeFilter} from a raw query.
149
+ */
59
150
  export declare function makeDaysAndTimeFiltersFunction<R, F>(builder: DateQueryBuilder<R, F>): DaysAndTimeFiltersFunction<F>;
@@ -1,15 +1,46 @@
1
1
  import { type Maybe } from '@dereekb/util';
2
2
  import { type DateQueryBuilder } from './query.builder';
3
+ /**
4
+ * Describes the document field names that store temporal start/end values,
5
+ * used by {@link makeMongoDBLikeDateQueryBuilder} to produce query filters.
6
+ */
3
7
  export interface TimeFieldsNameSet {
8
+ /** Field name storing the start (or combined start+end) timestamp. */
4
9
  start: string;
10
+ /** Field name storing the end timestamp. Ignored when `singleFieldForStartAndEnd` is true. */
5
11
  end?: string;
12
+ /** When true, a single field represents both start and end so range bounds are merged. */
6
13
  singleFieldForStartAndEnd?: boolean;
7
14
  }
15
+ /**
16
+ * A MongoDB-style range filter object with optional upper and lower date bounds.
17
+ */
8
18
  export interface MongoDBLikeDateRangeFilter {
9
19
  $lte?: Date;
10
20
  $gte?: Date;
11
21
  }
12
22
  export type MongoDBLikeDateQueryFilter = object;
23
+ /**
24
+ * Merges separate starts-at and ends-at range filters into a single
25
+ * {@link MongoDBLikeDateRangeFilter} for documents that use one field
26
+ * to represent both start and end.
27
+ *
28
+ * Takes `$lte` from `startsAt` (falling back to `endsAt`) and `$gte` from
29
+ * `endsAt` (falling back to `startsAt`).
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const merged = mergeMongoDBLikeRangeFilters(
34
+ * { $lte: new Date('2026-12-31') },
35
+ * { $gte: new Date('2026-01-01') }
36
+ * );
37
+ * // { $lte: 2026-12-31, $gte: 2026-01-01 }
38
+ * ```
39
+ *
40
+ * @param startsAt - Range filter derived from the starts-at bounds.
41
+ * @param endsAt - Range filter derived from the ends-at bounds.
42
+ * @returns A single merged range filter.
43
+ */
13
44
  export declare function mergeMongoDBLikeRangeFilters(startsAt: Maybe<MongoDBLikeDateRangeFilter>, endsAt: Maybe<MongoDBLikeDateRangeFilter>): {
14
45
  $lte: Date | undefined;
15
46
  $gte: Date | undefined;
@@ -17,4 +48,23 @@ export declare function mergeMongoDBLikeRangeFilters(startsAt: Maybe<MongoDBLike
17
48
  export interface MakeMongoDBLikeDateQueryBuilderConfig {
18
49
  fields: TimeFieldsNameSet;
19
50
  }
51
+ /**
52
+ * Creates a {@link DateQueryBuilder} that produces MongoDB-style `$gte`/`$lte`
53
+ * query filter objects for the configured time fields.
54
+ *
55
+ * Supports both two-field (start + end) and single-field date models.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const builder = makeMongoDBLikeDateQueryBuilder({
60
+ * fields: { start: 'startsAt', end: 'endsAt' }
61
+ * });
62
+ * const filter = builder.makeFieldFilter({
63
+ * startsAt: { $gte: new Date('2026-01-01') }
64
+ * });
65
+ * ```
66
+ *
67
+ * @param config - Configuration specifying the document field names.
68
+ * @returns A date query builder producing MongoDB-like filter objects.
69
+ */
20
70
  export declare function makeMongoDBLikeDateQueryBuilder(config: MakeMongoDBLikeDateQueryBuilderConfig): DateQueryBuilder<MongoDBLikeDateRangeFilter, MongoDBLikeDateQueryFilter>;
@@ -1,11 +1,17 @@
1
1
  import { type Maybe, type TimezoneString } from '@dereekb/util';
2
2
  import { type DateRangeParams } from '../date/date.range';
3
+ /**
4
+ * Filter parameter that matches a date exactly equal to a given value.
5
+ */
3
6
  export interface FindEqualsDateParam {
4
7
  /**
5
8
  * Date exactly equals this.
6
9
  */
7
10
  at?: Date;
8
11
  }
12
+ /**
13
+ * Extends {@link FindEqualsDateParam} with before/after bounds for range-based matching.
14
+ */
9
15
  export interface FindDateParam extends FindEqualsDateParam {
10
16
  /**
11
17
  * Date is before or equal to this point.
@@ -17,7 +23,8 @@ export interface FindDateParam extends FindEqualsDateParam {
17
23
  after?: Date;
18
24
  }
19
25
  /**
20
- * Filter that denotes which timezone to use when searching for full-date items.
26
+ * Provides a timezone hint so that day-level (all-day) items can be correctly
27
+ * resolved relative to the caller's local day boundaries.
21
28
  */
22
29
  export interface DateDayTimezoneHintFilter {
23
30
  /**
@@ -27,6 +34,9 @@ export interface DateDayTimezoneHintFilter {
27
34
  */
28
35
  timezone?: Maybe<TimezoneString>;
29
36
  }
37
+ /**
38
+ * Filter for querying date items that are active ("occurring") at a specific instant.
39
+ */
30
40
  export interface DateItemOccuringFilter {
31
41
  /**
32
42
  * Queries items that will be "ongoing" during this period.
@@ -35,6 +45,9 @@ export interface DateItemOccuringFilter {
35
45
  */
36
46
  occuringAt?: Date;
37
47
  }
48
+ /**
49
+ * Filter that matches items whose start and/or end dates exactly equal the given values.
50
+ */
38
51
  export interface DateItemQueryStartsEndsEqualsFilter {
39
52
  /**
40
53
  * The start of a range.
@@ -46,7 +59,8 @@ export interface DateItemQueryStartsEndsEqualsFilter {
46
59
  ends?: FindEqualsDateParam;
47
60
  }
48
61
  /**
49
- * Simple filter for quering against items that may start and/or end within a certain range.
62
+ * Filter for querying items whose start and/or end dates fall within
63
+ * independently specified before/after boundaries.
50
64
  */
51
65
  export interface DateItemQueryStartsEndsFilter {
52
66
  /**
@@ -58,6 +72,10 @@ export interface DateItemQueryStartsEndsFilter {
58
72
  */
59
73
  ends?: FindDateParam;
60
74
  }
75
+ /**
76
+ * Filter that constrains results to a single date range, optionally
77
+ * adjusted for a specific timezone.
78
+ */
61
79
  export interface DateRangeFilter extends DateDayTimezoneHintFilter {
62
80
  /**
63
81
  * Queries items that start within the specified date range.
@@ -66,6 +84,10 @@ export interface DateRangeFilter extends DateDayTimezoneHintFilter {
66
84
  */
67
85
  range: DateRangeParams;
68
86
  }
87
+ /**
88
+ * Extends {@link DateRangeFilter} with an option to require items to be fully
89
+ * contained within the range rather than merely overlapping it.
90
+ */
69
91
  export interface DateItemRangeFilter extends DateRangeFilter {
70
92
  /**
71
93
  * Whether or not to filter on only items occuring within this range.
@@ -74,5 +96,10 @@ export interface DateItemRangeFilter extends DateRangeFilter {
74
96
  */
75
97
  rangeContained?: boolean;
76
98
  }
99
+ /**
100
+ * Composite filter combining explicit starts/ends boundaries with a
101
+ * range-based filter, enabling both range containment and fine-grained
102
+ * boundary constraints in a single query.
103
+ */
77
104
  export interface DateItemQueryStartsEndsWithRangeFilter extends DateItemQueryStartsEndsFilter, DateItemRangeFilter {
78
105
  }
@@ -1,18 +1,34 @@
1
1
  import { type ISO8601DateString } from '@dereekb/util';
2
2
  import { type DateRangeType } from '../date';
3
+ /**
4
+ * Serializable request counterpart to {@link FindDateParam}, using ISO 8601
5
+ * strings so it can be sent over the wire.
6
+ */
3
7
  export interface FindDateParamRequest {
4
8
  before?: ISO8601DateString;
5
9
  after?: ISO8601DateString;
6
10
  }
11
+ /**
12
+ * Serializable request counterpart to {@link DateItemOccuringFilter}, using
13
+ * an ISO 8601 string for the target instant.
14
+ */
7
15
  export interface DateItemOccuringFilterRequest {
8
16
  occuringAt?: ISO8601DateString;
9
17
  }
18
+ /**
19
+ * Serializable request for filtering by starts/ends boundaries, extending
20
+ * {@link DateItemOccuringFilterRequest} with ISO 8601 string bounds.
21
+ */
10
22
  export interface DateItemQueryStartsEndsFilterRequest extends DateItemOccuringFilterRequest {
11
23
  startsBefore?: ISO8601DateString;
12
24
  startsAfter?: ISO8601DateString;
13
25
  endsBefore?: ISO8601DateString;
14
26
  endsAfter?: ISO8601DateString;
15
27
  }
28
+ /**
29
+ * Serializable request combining starts/ends boundaries with a date range
30
+ * filter, including range type, distance, containment flag, and timezone.
31
+ */
16
32
  export interface DateItemQueryStartsEndsWithRangeFilterRequest extends DateItemQueryStartsEndsFilterRequest {
17
33
  rangeType?: DateRangeType;
18
34
  rangeDate?: ISO8601DateString;