slotlock 0.1.0 → 0.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.
- package/CHANGELOG.md +138 -0
- package/CONTRIBUTING.md +35 -9
- package/README.md +153 -79
- package/SECURITY.md +40 -4
- package/SPEC.md +19 -6
- package/agent-server.d.ts +64 -7
- package/agent-server.js +273 -68
- package/agent-store-backend.d.ts +16 -0
- package/agent-store-backend.js +257 -2
- package/api-keys.d.ts +11 -4
- package/api-keys.js +9 -2
- package/application-api.d.ts +54 -0
- package/application-api.js +290 -0
- package/dashboard.d.ts +4 -1
- package/dashboard.js +6 -4
- package/ddl.d.ts +2 -1
- package/ddl.js +143 -15
- package/hooks.d.ts +7 -0
- package/hooks.js +13 -0
- package/index.d.ts +8 -4
- package/index.js +4 -2
- package/maintenance.d.ts +57 -0
- package/maintenance.js +181 -0
- package/node-server.js +121 -5
- package/package.json +1 -1
- package/rest-api.d.ts +33 -18
- package/rest-api.js +131 -63
- package/rules.d.ts +19 -0
- package/rules.js +32 -4
- package/self-host.d.ts +5 -2
- package/self-host.js +127 -20
- package/slotlock.manifest.json +1 -1
- package/store.d.ts +30 -8
- package/store.js +69 -27
- package/sync.js +530 -49
- package/timezone.d.ts +19 -0
- package/timezone.js +16 -1
- package/types.d.ts +4 -1
- package/weekly-hours.js +2 -2
package/timezone.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface TimeZoneConverter {
|
|
|
14
14
|
*/
|
|
15
15
|
wallFrameToUtc(wallFrameMs: number): Date;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Date.UTC remaps years 0..99 to 1900..1999. Slotlock accepts ISO calendar years down to 1,
|
|
19
|
+
* so construct UTC frames through setUTCFullYear instead of inheriting that legacy quirk.
|
|
20
|
+
*/
|
|
21
|
+
export declare function utcFrame(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): Date;
|
|
17
22
|
export declare function createTimeZoneConverter(timezone: string): TimeZoneConverter;
|
|
18
23
|
export interface ZonedCalendarDate {
|
|
19
24
|
/** Civil date of the instant in the zone, `YYYY-MM-DD`. */
|
|
@@ -41,4 +46,18 @@ export interface ZonedWallTime {
|
|
|
41
46
|
export declare function zonedWallTime(instant: Date, timezone: string): ZonedWallTime;
|
|
42
47
|
/** How far `timezone` is ahead of UTC at `instant`, in whole minutes (negative west of UTC). */
|
|
43
48
|
export declare function zonedOffsetMinutes(instant: Date, timezone: string): number;
|
|
49
|
+
/** A wall clock's fields, to the second. */
|
|
50
|
+
export interface ZonedDateTimeFields {
|
|
51
|
+
year: number;
|
|
52
|
+
month: number;
|
|
53
|
+
day: number;
|
|
54
|
+
hour: number;
|
|
55
|
+
minute: number;
|
|
56
|
+
second: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The wall-clock fields an instant reads as in `timezone`, to the second: what a calendar writes
|
|
60
|
+
* beside a TZID. Reads through the cached formatters, as every conversion here does.
|
|
61
|
+
*/
|
|
62
|
+
export declare function zonedDateTimeFields(instant: Date, timezone: string): ZonedDateTimeFields;
|
|
44
63
|
export declare function zonedDateTimeToUtc(value: LocalDateTime, timezone: string): Date;
|
package/timezone.js
CHANGED
|
@@ -3,7 +3,7 @@ const FOURTEEN_HOURS_MS = 14 * 60 * 60 * 1000;
|
|
|
3
3
|
* Date.UTC remaps years 0..99 to 1900..1999. Slotlock accepts ISO calendar years down to 1,
|
|
4
4
|
* so construct UTC frames through setUTCFullYear instead of inheriting that legacy quirk.
|
|
5
5
|
*/
|
|
6
|
-
function utcFrame(year, month, day, hour, minute, second, millisecond) {
|
|
6
|
+
export function utcFrame(year, month, day, hour, minute, second, millisecond) {
|
|
7
7
|
const frame = new Date(0);
|
|
8
8
|
frame.setUTCFullYear(year, month - 1, day);
|
|
9
9
|
frame.setUTCHours(hour, minute, second, millisecond);
|
|
@@ -106,6 +106,21 @@ export function zonedWallTime(instant, timezone) {
|
|
|
106
106
|
export function zonedOffsetMinutes(instant, timezone) {
|
|
107
107
|
return Math.round((wallFrame(instant, timezone).getTime() - instant.getTime()) / 60_000);
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The wall-clock fields an instant reads as in `timezone`, to the second: what a calendar writes
|
|
111
|
+
* beside a TZID. Reads through the cached formatters, as every conversion here does.
|
|
112
|
+
*/
|
|
113
|
+
export function zonedDateTimeFields(instant, timezone) {
|
|
114
|
+
const wall = wallFrame(instant, timezone);
|
|
115
|
+
return {
|
|
116
|
+
year: wall.getUTCFullYear(),
|
|
117
|
+
month: wall.getUTCMonth() + 1,
|
|
118
|
+
day: wall.getUTCDate(),
|
|
119
|
+
hour: wall.getUTCHours(),
|
|
120
|
+
minute: wall.getUTCMinutes(),
|
|
121
|
+
second: wall.getUTCSeconds(),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
109
124
|
/** The instant shifted so its UTC fields read as the wall clock in `timezone`. */
|
|
110
125
|
function wallFrame(instant, timezone) {
|
|
111
126
|
const ms = instant.getTime();
|
package/types.d.ts
CHANGED
|
@@ -333,7 +333,10 @@ export interface CalendarHorizonRollCursor {
|
|
|
333
333
|
export interface CalendarHorizonRollResult {
|
|
334
334
|
/** Due recurring masters examined in deterministic order. */
|
|
335
335
|
examined: number;
|
|
336
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* Masters atomically rematerialized from the requested window's start through the later of their
|
|
338
|
+
* stored end and the window's: a roll never moves a series' end back.
|
|
339
|
+
*/
|
|
337
340
|
extended: number;
|
|
338
341
|
/** Masters whose new occurrence collided; their previous coverage remains intact. */
|
|
339
342
|
conflicts: number;
|
package/weekly-hours.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Bookable hours: the one validator for weekly availability rules, and the conversion between rules
|
|
2
2
|
// and a week of windows, the form people edit them in (two windows a day at most).
|
|
3
|
-
import { expandRules } from './rules.js';
|
|
3
|
+
import { SLOTLOCK_MAX_RULE_DURATION_MINUTES, expandRules } from './rules.js';
|
|
4
4
|
/** Rules one schedule may hold: the server default, or one resource's own hours. */
|
|
5
5
|
export const SLOTLOCK_MAX_AVAILABILITY_RULES = 50;
|
|
6
6
|
const RULE_KEYS = new Set(['rrule', 'startMinutes', 'durationMinutes']);
|
|
7
7
|
const MAX_RRULE_CHARACTERS = 500;
|
|
8
|
-
const MAX_DURATION_MINUTES =
|
|
8
|
+
const MAX_DURATION_MINUTES = SLOTLOCK_MAX_RULE_DURATION_MINUTES;
|
|
9
9
|
const DAY_MINUTES = 1_440;
|
|
10
10
|
/** Two weeks every supported weekly rule produces a window in. */
|
|
11
11
|
const SAMPLE = { start: new Date('2026-01-05T00:00:00Z'), end: new Date('2026-01-19T00:00:00Z') };
|