scschedule 4.0.0 → 4.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/README.md CHANGED
@@ -263,6 +263,19 @@ ranges.forEach((range) => {
263
263
  })
264
264
  ```
265
265
 
266
+ #### `getApplicableRuleForDate(schedule: Schedule, date: SDate | SDateString): ApplicableRule`
267
+
268
+ Returns the rules that apply for a given date, indicating whether they come from the weekly schedule or an override. When `source` is `'weekly'`, `rules` is the weekly schedule (`true` or `WeeklyScheduleRule[]`). When `source` is `'override'`, `rules` is the override's rules and `overrideIndex` identifies which override applies.
269
+
270
+ ```typescript
271
+ import { getApplicableRuleForDate } from 'scschedule'
272
+ import { sDate } from 'scdate'
273
+
274
+ const result = getApplicableRuleForDate(restaurant, sDate('2025-12-15'))
275
+ // result.source === 'weekly' | 'override'
276
+ // result.rules === true | WeeklyScheduleRule[]
277
+ ```
278
+
266
279
  ## Usage Examples
267
280
 
268
281
  ### Basic Business Hours
@@ -607,6 +620,7 @@ The library is written in TypeScript and provides full type definitions. All typ
607
620
 
608
621
  ```typescript
609
622
  import type {
623
+ ApplicableRule,
610
624
  Schedule,
611
625
  WeeklyScheduleRule,
612
626
  OverrideScheduleRule,
@@ -1,5 +1,5 @@
1
1
  import { SDate } from 'scdate';
2
- import type { Schedule, SDateString, WeeklyScheduleRule } from '../types.js';
2
+ import type { Schedule, SDateString, WeeklyScheduleRule } from './types.js';
3
3
  export type ApplicableRule = {
4
4
  source: 'weekly';
5
5
  rules: WeeklyScheduleRule[] | true;
@@ -1,5 +1,5 @@
1
1
  import { addDaysToDate, doesWeekdaysIncludeWeekday, getTimestampFromDateAndTime, getWeekdayFromDate, isAfterTime, isSameDateOrBefore, } from 'scdate';
2
- import { getApplicableRuleForDate } from './internal/getApplicableRuleForDate.js';
2
+ import { getApplicableRuleForDate } from './getApplicableRuleForDate.js';
3
3
  /**
4
4
  * Returns all available time ranges within a schedule for the specified
5
5
  * date range.
@@ -1,5 +1,5 @@
1
1
  import { addDaysToDate, doesWeekdaysIncludeWeekday, getDateFromTimestamp, getTimeFromTimestamp, getTimestampFromDateAndTime, getWeekdayFromDate, isAfterTime, isBeforeTime, sTimestamp, } from 'scdate';
2
- import { getApplicableRuleForDate } from './internal/getApplicableRuleForDate.js';
2
+ import { getApplicableRuleForDate } from './getApplicableRuleForDate.js';
3
3
  import { isScheduleAvailable } from './isScheduleAvailable.js';
4
4
  /**
5
5
  * Finds the next available timestamp in a schedule starting from the
@@ -1,5 +1,5 @@
1
1
  import { addDaysToDate, addMinutesToTimestamp, doesWeekdaysIncludeWeekday, getDateFromTimestamp, getTimeFromTimestamp, getTimestampFromDateAndTime, getWeekdayFromDate, isAfterTime, isBeforeTimestamp, isSameTimeOrAfter, sTimestamp, } from 'scdate';
2
- import { getApplicableRuleForDate } from './internal/getApplicableRuleForDate.js';
2
+ import { getApplicableRuleForDate } from './getApplicableRuleForDate.js';
3
3
  import { isScheduleAvailable } from './isScheduleAvailable.js';
4
4
  /**
5
5
  * Collects "range end + 1 minute" candidate timestamps for a given date's
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './constants.js';
4
4
  export type * from './types.js';
5
5
  export * from './validateSchedule.js';
6
6
  export * from './cleanupExpiredOverridesFromSchedule.js';
7
+ export * from './getApplicableRuleForDate.js';
7
8
  export * from './getAvailableRangesFromSchedule.js';
8
9
  export * from './getNextAvailableFromSchedule.js';
9
10
  export * from './getNextUnavailableFromSchedule.js';
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './validateSchedule.js';
7
7
  // Export schedule management functions
8
8
  export * from './cleanupExpiredOverridesFromSchedule.js';
9
9
  // Export availability query functions
10
+ export * from './getApplicableRuleForDate.js';
10
11
  export * from './getAvailableRangesFromSchedule.js';
11
12
  export * from './getNextAvailableFromSchedule.js';
12
13
  export * from './getNextUnavailableFromSchedule.js';
@@ -2,7 +2,6 @@ export type * from './types.js';
2
2
  export * from './doOverridesOverlap.js';
3
3
  export * from './doRulesOverlap.js';
4
4
  export * from './doTimeRangesOverlap.js';
5
- export * from './getApplicableRuleForDate.js';
6
5
  export * from './getEffectiveTimesForWeekday.js';
7
6
  export * from './isTimeInTimeRange.js';
8
7
  export * from './normalizeScheduleForValidation.js';
@@ -2,7 +2,6 @@
2
2
  export * from './doOverridesOverlap.js';
3
3
  export * from './doRulesOverlap.js';
4
4
  export * from './doTimeRangesOverlap.js';
5
- export * from './getApplicableRuleForDate.js';
6
5
  export * from './getEffectiveTimesForWeekday.js';
7
6
  export * from './isTimeInTimeRange.js';
8
7
  export * from './normalizeScheduleForValidation.js';
@@ -1,7 +1,7 @@
1
1
  import { addDaysToDate, doesWeekdaysIncludeWeekday, getWeekdayFromDate, sDate, } from 'scdate';
2
2
  import { ValidationIssue } from '../constants.js';
3
3
  import { doTimeRangesOverlap } from './doTimeRangesOverlap.js';
4
- import { getApplicableRuleForDate } from './getApplicableRuleForDate.js';
4
+ import { getApplicableRuleForDate } from '../getApplicableRuleForDate.js';
5
5
  import { splitCrossMidnightTimeRange } from './splitCrossMidnightTimeRange.js';
6
6
  /**
7
7
  * Validates that cross-midnight spillover at override boundaries doesn't
@@ -1,5 +1,5 @@
1
1
  import { addDaysToDate, doesWeekdaysIncludeWeekday, getDateFromTimestamp, getTimeFromTimestamp, getWeekdayFromDate, } from 'scdate';
2
- import { getApplicableRuleForDate } from './internal/getApplicableRuleForDate.js';
2
+ import { getApplicableRuleForDate } from './getApplicableRuleForDate.js';
3
3
  import { isTimeInTimeRange } from './internal/isTimeInTimeRange.js';
4
4
  /**
5
5
  * Checks if a schedule is available at the specified timestamp.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scschedule",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"
@@ -20,15 +20,15 @@
20
20
  "test": "vitest run"
21
21
  },
22
22
  "dependencies": {
23
- "scdate": "4.0.0"
23
+ "scdate": "workspace:*"
24
24
  },
25
25
  "devDependencies": {
26
- "@eslint/js": "^9.39.2",
26
+ "@eslint/js": "^9.39.3",
27
27
  "@tsconfig/strictest": "^2.0.8",
28
- "@types/node": "^24.10.13",
29
- "eslint": "^9.39.2",
28
+ "@types/node": "^24.11.0",
29
+ "eslint": "^9.39.3",
30
30
  "typescript": "^5.9.3",
31
- "typescript-eslint": "^8.55.0",
31
+ "typescript-eslint": "^8.56.1",
32
32
  "vitest": "^4.0.18"
33
33
  },
34
34
  "repository": {
@@ -46,4 +46,4 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  }
49
- }
49
+ }