@dereekb/date 13.2.1 → 13.2.2

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 CHANGED
@@ -5,6 +5,7 @@ var dateFns = require('date-fns');
5
5
  var dateFnsTz = require('date-fns-tz');
6
6
  var arktype = require('arktype');
7
7
  var tzdb = require('@vvo/tzdb');
8
+ var model = require('@dereekb/model');
8
9
  var rxjs = require('rxjs');
9
10
  var rrule = require('rrule');
10
11
 
@@ -6616,37 +6617,37 @@ const knownTimezoneType = arktype.type('string > 0').narrow((val, ctx) => (val !
6616
6617
  /**
6617
6618
  * ArkType DTO schema for {@link DateDurationSpan}.
6618
6619
  *
6619
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6620
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6620
6621
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6621
- * into the corresponding runtime types.
6622
+ * or runtime Date objects into the corresponding runtime types.
6622
6623
  */
6623
6624
  const dateDurationSpanType = arktype.type({
6624
- startsAt: 'string.date.parse',
6625
+ startsAt: model.ARKTYPE_DATE_DTO_TYPE,
6625
6626
  duration: 'number >= 0'
6626
6627
  });
6627
6628
  // MARK: DateRange
6628
6629
  /**
6629
6630
  * ArkType DTO schema for {@link DateRange}.
6630
6631
  *
6631
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6632
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6632
6633
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6633
- * into the corresponding runtime types.
6634
+ * or runtime Date objects into the corresponding runtime types.
6634
6635
  */
6635
6636
  const dateRangeType = arktype.type({
6636
- start: 'string.date.parse',
6637
- end: 'string.date.parse'
6637
+ start: model.ARKTYPE_DATE_DTO_TYPE,
6638
+ end: model.ARKTYPE_DATE_DTO_TYPE
6638
6639
  });
6639
6640
  // MARK: DateRangeParams
6640
6641
  /**
6641
6642
  * ArkType DTO schema for {@link DateRangeParams}.
6642
6643
  *
6643
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6644
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6644
6645
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6645
- * into the corresponding runtime types.
6646
+ * or runtime Date objects into the corresponding runtime types.
6646
6647
  */
6647
6648
  const dateRangeParamsType = arktype.type({
6648
6649
  type: arktype.type.enumerated(...Object.values(exports.DateRangeType)),
6649
- date: 'string.date.parse',
6650
+ date: model.ARKTYPE_DATE_DTO_TYPE,
6650
6651
  'distance?': 'number'
6651
6652
  });
6652
6653
  // MARK: DateCell
@@ -6675,21 +6676,21 @@ const dateCellRangeType = dateCellType.merge({
6675
6676
  /**
6676
6677
  * ArkType DTO schema for {@link DateCellTiming}.
6677
6678
  *
6678
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6679
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6679
6680
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6680
- * into the corresponding runtime types.
6681
+ * or runtime Date objects into the corresponding runtime types.
6681
6682
  */
6682
6683
  const dateCellTimingType = dateDurationSpanType.merge({
6683
- end: 'string.date.parse',
6684
+ end: model.ARKTYPE_DATE_DTO_TYPE,
6684
6685
  timezone: knownTimezoneType
6685
6686
  });
6686
6687
  // MARK: CalendarDate
6687
6688
  /**
6688
6689
  * ArkType DTO schema for {@link CalendarDate}.
6689
6690
  *
6690
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6691
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6691
6692
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6692
- * into the corresponding runtime types.
6693
+ * or runtime Date objects into the corresponding runtime types.
6693
6694
  */
6694
6695
  const calendarDateType = dateDurationSpanType.merge({
6695
6696
  type: arktype.type.enumerated(...Object.values(exports.CalendarDateType))
@@ -6711,22 +6712,22 @@ const dateCellScheduleType = arktype.type({
6711
6712
  /**
6712
6713
  * ArkType DTO schema for {@link ModelRecurrenceInfo}.
6713
6714
  *
6714
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6715
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6715
6716
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6716
- * into the corresponding runtime types.
6717
+ * or runtime Date objects into the corresponding runtime types.
6717
6718
  */
6718
6719
  const modelRecurrenceInfoType = arktype.type({
6719
6720
  'timezone?': 'string',
6720
6721
  rrule: 'string',
6721
- start: 'string.date.parse',
6722
- end: 'string.date.parse',
6722
+ start: model.ARKTYPE_DATE_DTO_TYPE,
6723
+ end: model.ARKTYPE_DATE_DTO_TYPE,
6723
6724
  'forever?': 'boolean'
6724
6725
  });
6725
6726
  // MARK: Validators
6726
6727
  /**
6727
6728
  * ArkType DTO schema that validates a value is a valid {@link DateCellTiming}.
6728
6729
  *
6729
- * Parses date strings from JSON/DTO input into Date objects, then validates the resulting timing
6730
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`), then validates the resulting timing
6730
6731
  * using {@link isValidDateCellTiming}.
6731
6732
  */
6732
6733
  const validDateCellTimingType = dateCellTimingType.narrow((val, ctx) => (val != null && isValidDateCellTiming(val)) || ctx.mustBe('a valid DateCellTiming'));
package/index.esm.js CHANGED
@@ -4,6 +4,7 @@ import { isEqual, isSameDay, isDate as isDate$1, startOfMinute, isValid, parseIS
4
4
  import { toZonedTime, format, formatInTimeZone } from 'date-fns-tz';
5
5
  import { type } from 'arktype';
6
6
  import { timeZonesNames } from '@vvo/tzdb';
7
+ import { ARKTYPE_DATE_DTO_TYPE } from '@dereekb/model';
7
8
  import { interval, startWith, map, distinctUntilChanged } from 'rxjs';
8
9
  import { RRule } from 'rrule';
9
10
 
@@ -6615,37 +6616,37 @@ const knownTimezoneType = type('string > 0').narrow((val, ctx) => (val != null &
6615
6616
  /**
6616
6617
  * ArkType DTO schema for {@link DateDurationSpan}.
6617
6618
  *
6618
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6619
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6619
6620
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6620
- * into the corresponding runtime types.
6621
+ * or runtime Date objects into the corresponding runtime types.
6621
6622
  */
6622
6623
  const dateDurationSpanType = type({
6623
- startsAt: 'string.date.parse',
6624
+ startsAt: ARKTYPE_DATE_DTO_TYPE,
6624
6625
  duration: 'number >= 0'
6625
6626
  });
6626
6627
  // MARK: DateRange
6627
6628
  /**
6628
6629
  * ArkType DTO schema for {@link DateRange}.
6629
6630
  *
6630
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6631
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6631
6632
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6632
- * into the corresponding runtime types.
6633
+ * or runtime Date objects into the corresponding runtime types.
6633
6634
  */
6634
6635
  const dateRangeType = type({
6635
- start: 'string.date.parse',
6636
- end: 'string.date.parse'
6636
+ start: ARKTYPE_DATE_DTO_TYPE,
6637
+ end: ARKTYPE_DATE_DTO_TYPE
6637
6638
  });
6638
6639
  // MARK: DateRangeParams
6639
6640
  /**
6640
6641
  * ArkType DTO schema for {@link DateRangeParams}.
6641
6642
  *
6642
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6643
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6643
6644
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6644
- * into the corresponding runtime types.
6645
+ * or runtime Date objects into the corresponding runtime types.
6645
6646
  */
6646
6647
  const dateRangeParamsType = type({
6647
6648
  type: type.enumerated(...Object.values(DateRangeType)),
6648
- date: 'string.date.parse',
6649
+ date: ARKTYPE_DATE_DTO_TYPE,
6649
6650
  'distance?': 'number'
6650
6651
  });
6651
6652
  // MARK: DateCell
@@ -6674,21 +6675,21 @@ const dateCellRangeType = dateCellType.merge({
6674
6675
  /**
6675
6676
  * ArkType DTO schema for {@link DateCellTiming}.
6676
6677
  *
6677
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6678
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6678
6679
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6679
- * into the corresponding runtime types.
6680
+ * or runtime Date objects into the corresponding runtime types.
6680
6681
  */
6681
6682
  const dateCellTimingType = dateDurationSpanType.merge({
6682
- end: 'string.date.parse',
6683
+ end: ARKTYPE_DATE_DTO_TYPE,
6683
6684
  timezone: knownTimezoneType
6684
6685
  });
6685
6686
  // MARK: CalendarDate
6686
6687
  /**
6687
6688
  * ArkType DTO schema for {@link CalendarDate}.
6688
6689
  *
6689
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6690
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6690
6691
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6691
- * into the corresponding runtime types.
6692
+ * or runtime Date objects into the corresponding runtime types.
6692
6693
  */
6693
6694
  const calendarDateType = dateDurationSpanType.merge({
6694
6695
  type: type.enumerated(...Object.values(CalendarDateType))
@@ -6710,22 +6711,22 @@ const dateCellScheduleType = type({
6710
6711
  /**
6711
6712
  * ArkType DTO schema for {@link ModelRecurrenceInfo}.
6712
6713
  *
6713
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
6714
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
6714
6715
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
6715
- * into the corresponding runtime types.
6716
+ * or runtime Date objects into the corresponding runtime types.
6716
6717
  */
6717
6718
  const modelRecurrenceInfoType = type({
6718
6719
  'timezone?': 'string',
6719
6720
  rrule: 'string',
6720
- start: 'string.date.parse',
6721
- end: 'string.date.parse',
6721
+ start: ARKTYPE_DATE_DTO_TYPE,
6722
+ end: ARKTYPE_DATE_DTO_TYPE,
6722
6723
  'forever?': 'boolean'
6723
6724
  });
6724
6725
  // MARK: Validators
6725
6726
  /**
6726
6727
  * ArkType DTO schema that validates a value is a valid {@link DateCellTiming}.
6727
6728
  *
6728
- * Parses date strings from JSON/DTO input into Date objects, then validates the resulting timing
6729
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`), then validates the resulting timing
6729
6730
  * using {@link isValidDateCellTiming}.
6730
6731
  */
6731
6732
  const validDateCellTimingType = dateCellTimingType.narrow((val, ctx) => (val != null && isValidDateCellTiming(val)) || ctx.mustBe('a valid DateCellTiming'));
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dereekb/date",
3
- "version": "13.2.1",
3
+ "version": "13.2.2",
4
4
  "peerDependencies": {
5
- "@dereekb/rxjs": "13.2.1",
6
- "@dereekb/util": "13.2.1",
5
+ "@dereekb/rxjs": "13.2.2",
6
+ "@dereekb/util": "13.2.2",
7
7
  "@vvo/tzdb": "^6.0.0",
8
8
  "arktype": "^2.2.0",
9
9
  "date-fns": "^4.0.0",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {},
15
15
  "devDependencies": {
16
- "@dereekb/rxjs": "13.2.1"
16
+ "@dereekb/rxjs": "13.2.2"
17
17
  },
18
18
  "exports": {
19
19
  "./package.json": "./package.json",
@@ -16,35 +16,35 @@ export declare const knownTimezoneType: import("arktype/internal/variants/string
16
16
  /**
17
17
  * ArkType DTO schema for {@link DateDurationSpan}.
18
18
  *
19
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
19
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
20
20
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
21
- * into the corresponding runtime types.
21
+ * or runtime Date objects into the corresponding runtime types.
22
22
  */
23
23
  export declare const dateDurationSpanType: import("arktype/internal/variants/object.ts").ObjectType<{
24
- startsAt: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
24
+ startsAt: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
25
25
  duration: number;
26
26
  }, {}>;
27
27
  /**
28
28
  * ArkType DTO schema for {@link DateRange}.
29
29
  *
30
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
30
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
31
31
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
32
- * into the corresponding runtime types.
32
+ * or runtime Date objects into the corresponding runtime types.
33
33
  */
34
34
  export declare const dateRangeType: import("arktype/internal/variants/object.ts").ObjectType<{
35
- start: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
36
- end: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
35
+ start: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
36
+ end: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
37
37
  }, {}>;
38
38
  /**
39
39
  * ArkType DTO schema for {@link DateRangeParams}.
40
40
  *
41
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
41
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
42
42
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
43
- * into the corresponding runtime types.
43
+ * or runtime Date objects into the corresponding runtime types.
44
44
  */
45
45
  export declare const dateRangeParamsType: import("arktype/internal/variants/object.ts").ObjectType<{
46
46
  type: DateRangeType;
47
- date: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
47
+ date: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
48
48
  distance?: number | undefined;
49
49
  }, {}>;
50
50
  /**
@@ -71,25 +71,25 @@ export declare const dateCellRangeType: import("arktype/internal/variants/object
71
71
  /**
72
72
  * ArkType DTO schema for {@link DateCellTiming}.
73
73
  *
74
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
74
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
75
75
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
76
- * into the corresponding runtime types.
76
+ * or runtime Date objects into the corresponding runtime types.
77
77
  */
78
78
  export declare const dateCellTimingType: import("arktype/internal/variants/object.ts").ObjectType<{
79
- startsAt: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
79
+ startsAt: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
80
80
  duration: number;
81
- end: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
81
+ end: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
82
82
  timezone: string;
83
83
  }, {}>;
84
84
  /**
85
85
  * ArkType DTO schema for {@link CalendarDate}.
86
86
  *
87
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
87
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
88
88
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
89
- * into the corresponding runtime types.
89
+ * or runtime Date objects into the corresponding runtime types.
90
90
  */
91
91
  export declare const calendarDateType: import("arktype/internal/variants/object.ts").ObjectType<{
92
- startsAt: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
92
+ startsAt: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
93
93
  duration: number;
94
94
  type: CalendarDateType;
95
95
  }, {}>;
@@ -108,27 +108,27 @@ export declare const dateCellScheduleType: import("arktype/internal/variants/obj
108
108
  /**
109
109
  * ArkType DTO schema for {@link ModelRecurrenceInfo}.
110
110
  *
111
- * Parses date strings from JSON/DTO input into Date objects using `string.date.parse`.
111
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`).
112
112
  * Use this schema when validating and converting serialized data (e.g., API responses, JSON payloads)
113
- * into the corresponding runtime types.
113
+ * or runtime Date objects into the corresponding runtime types.
114
114
  */
115
115
  export declare const modelRecurrenceInfoType: import("arktype/internal/variants/object.ts").ObjectType<{
116
116
  rrule: string;
117
- start: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
118
- end: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
117
+ start: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
118
+ end: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
119
119
  timezone?: string | undefined;
120
120
  forever?: boolean | undefined;
121
121
  }, {}>;
122
122
  /**
123
123
  * ArkType DTO schema that validates a value is a valid {@link DateCellTiming}.
124
124
  *
125
- * Parses date strings from JSON/DTO input into Date objects, then validates the resulting timing
125
+ * Accepts both Date objects and date strings (parsed via `string.date.parse`), then validates the resulting timing
126
126
  * using {@link isValidDateCellTiming}.
127
127
  */
128
128
  export declare const validDateCellTimingType: import("arktype/internal/variants/object.ts").ObjectType<{
129
- startsAt: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
129
+ startsAt: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
130
130
  duration: number;
131
- end: (In: string) => import("arktype/internal/attributes.ts").To<Date>;
131
+ end: Date | ((In: string) => import("arktype/internal/attributes.ts").To<Date>);
132
132
  timezone: string;
133
133
  }, {}>;
134
134
  /**