slotlock 0.7.0 → 0.9.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 +281 -0
- package/agent-server.d.ts +25 -5
- package/agent-server.js +152 -7
- package/agent-store-backend.d.ts +6 -1
- package/agent-store-backend.js +861 -55
- package/application-api.d.ts +19 -1
- package/application-api.js +578 -21
- package/approvals.d.ts +2 -0
- package/approvals.js +12 -5
- package/assistant.d.ts +64 -9
- package/assistant.js +450 -82
- package/availability-store.d.ts +193 -0
- package/availability-store.js +558 -0
- package/booking-rules.d.ts +92 -5
- package/booking-rules.js +243 -15
- package/dashboard-assistant-ui.d.ts +21 -0
- package/dashboard-assistant-ui.js +539 -0
- package/dashboard-markdown.d.ts +2 -0
- package/dashboard-markdown.js +157 -0
- package/dashboard-settings-ui.d.ts +1 -0
- package/dashboard-settings-ui.js +78 -0
- package/dashboard.d.ts +84 -11
- package/dashboard.js +1654 -384
- package/ddl.d.ts +5 -1
- package/ddl.js +760 -9
- package/event-feed.d.ts +1 -1
- package/event-feed.js +18 -0
- package/holiday-import.d.ts +38 -0
- package/holiday-import.js +57 -0
- package/holidays.d.ts +38 -0
- package/holidays.js +150 -0
- package/hours.d.ts +125 -0
- package/hours.js +224 -0
- package/index.d.ts +14 -3
- package/index.js +10 -2
- package/interop.d.ts +25 -7
- package/interop.js +145 -17
- package/lifecycle.d.ts +31 -0
- package/lifecycle.js +115 -0
- package/maintenance.d.ts +19 -0
- package/maintenance.js +55 -1
- package/metrics.js +3 -0
- package/openapi.json +16237 -7795
- package/package.json +1 -1
- package/ranges.d.ts +28 -0
- package/ranges.js +135 -0
- package/resource-search.d.ts +19 -0
- package/resource-search.js +153 -0
- package/rest-api.js +7 -0
- package/rules.d.ts +2 -0
- package/rules.js +2 -0
- package/self-host.d.ts +1 -1
- package/self-host.js +221 -21
- package/slotlock.manifest.json +1 -1
- package/store.d.ts +367 -24
- package/store.js +1567 -97
- package/types.d.ts +198 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { Sql, TransactionSql } from 'postgres';
|
|
2
|
+
import { type SlotlockAvailabilityException, type SlotlockExceptionOutcome, type SlotlockExceptionSource, type SlotlockExceptionWindow, type SlotlockRankedException } from './hours.js';
|
|
3
|
+
import type { SlotlockHoliday } from './holidays.js';
|
|
4
|
+
import type { SlotlockInheritedAvailability, WeeklyAvailabilityRule } from './types.js';
|
|
5
|
+
type StoreSql = Sql | TransactionSql;
|
|
6
|
+
/** The tenant's stored hours and each location's that has them. */
|
|
7
|
+
export interface SlotlockAvailabilityDefaults {
|
|
8
|
+
tenant: WeeklyAvailabilityRule[] | null;
|
|
9
|
+
locations: {
|
|
10
|
+
location: string;
|
|
11
|
+
rules: WeeklyAvailabilityRule[];
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What storing the tenant's hours does to resources with hours of their own: `none` keeps them,
|
|
16
|
+
* `all` clears them so every resource inherits, and `matching` clears only those whose hours are
|
|
17
|
+
* the same as the tenant's were before, or as the hours being stored: the copies an earlier
|
|
18
|
+
* version (0.8.0 and before) made, while hours set apart on purpose stay.
|
|
19
|
+
*/
|
|
20
|
+
export type SlotlockOverrideResources = 'none' | 'matching' | 'all';
|
|
21
|
+
export declare const SLOTLOCK_OVERRIDE_RESOURCES: readonly SlotlockOverrideResources[];
|
|
22
|
+
/** What setting stored hours changed: resources now on them, and those that keep their own. */
|
|
23
|
+
export interface SlotlockAvailabilityDefaultsResult {
|
|
24
|
+
/** Resources in use whose hours these now are. */
|
|
25
|
+
inheriting: number;
|
|
26
|
+
/** Resources in use the hours reach that keep hours of their own. */
|
|
27
|
+
ownHours: number;
|
|
28
|
+
}
|
|
29
|
+
export interface SlotlockAvailabilityExceptionInput {
|
|
30
|
+
tenantRef: string;
|
|
31
|
+
/** A location: it and every location inside it. */
|
|
32
|
+
location?: string;
|
|
33
|
+
/** One resource. Neither: the whole tenant. */
|
|
34
|
+
resourceId?: string;
|
|
35
|
+
startsOn: string;
|
|
36
|
+
/** The last day, inclusive; the first when absent. */
|
|
37
|
+
endsOn?: string;
|
|
38
|
+
outcome: SlotlockExceptionOutcome;
|
|
39
|
+
hours?: readonly SlotlockExceptionWindow[];
|
|
40
|
+
label: string;
|
|
41
|
+
source?: SlotlockExceptionSource;
|
|
42
|
+
/** An import's own id for the exception: importing again updates the same one. */
|
|
43
|
+
sourceUid?: string;
|
|
44
|
+
/** The holiday calendar it is imported from (importHolidayCalendar); internal. */
|
|
45
|
+
calendarId?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Inherited hours as slotlock.inherited_availability gives them; rules that do not parse read as closed. */
|
|
48
|
+
export declare function storedInheritedAvailability(value: unknown): SlotlockInheritedAvailability | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Store the tenant's weekly hours (or clear them, `null`): every resource without its own and with
|
|
51
|
+
* no location hours above it uses them. `overrideResources` says what becomes of the hours
|
|
52
|
+
* resources keep of their own (SlotlockOverrideResources; `none` by default).
|
|
53
|
+
*/
|
|
54
|
+
export declare function storeTenantAvailability(sql: StoreSql, params: {
|
|
55
|
+
tenantRef: string;
|
|
56
|
+
rules: readonly WeeklyAvailabilityRule[] | null;
|
|
57
|
+
overrideResources?: SlotlockOverrideResources;
|
|
58
|
+
}): Promise<SlotlockAvailabilityDefaultsResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Store a location's weekly hours (or clear them, `null`): resources at it or inside it without
|
|
61
|
+
* their own use them, unless a location nearer them has its own. Null for a location the tenant
|
|
62
|
+
* does not have.
|
|
63
|
+
*/
|
|
64
|
+
export declare function setLocationAvailability(sql: StoreSql, params: {
|
|
65
|
+
tenantRef: string;
|
|
66
|
+
location: string;
|
|
67
|
+
rules: readonly WeeklyAvailabilityRule[] | null;
|
|
68
|
+
}): Promise<SlotlockAvailabilityDefaultsResult | null>;
|
|
69
|
+
export declare function getAvailabilityDefaults(sql: StoreSql, params: {
|
|
70
|
+
tenantRef: string;
|
|
71
|
+
}): Promise<SlotlockAvailabilityDefaults>;
|
|
72
|
+
/**
|
|
73
|
+
* Add an exception, or, for an import's `sourceUid` already stored at that scope, update it.
|
|
74
|
+
* Refuses `invalid_availability_exception`, `location_not_found`, `resource_not_found` and
|
|
75
|
+
* `availability_exceptions_limit_reached` (SLOTLOCK_MAX_AVAILABILITY_EXCEPTIONS a tenant).
|
|
76
|
+
*/
|
|
77
|
+
export declare function createAvailabilityException(sql: StoreSql, input: SlotlockAvailabilityExceptionInput): Promise<SlotlockAvailabilityException>;
|
|
78
|
+
/**
|
|
79
|
+
* The tenant's exceptions by first day: those that apply to `resourceId` (the tenant's, its
|
|
80
|
+
* locations' and its own), or one `location`'s own, or all of them; only those reaching `from` to
|
|
81
|
+
* `to` when given. Keyset-paginated by `after` (the last one's id).
|
|
82
|
+
*/
|
|
83
|
+
export declare function listAvailabilityExceptions(sql: StoreSql, params: {
|
|
84
|
+
tenantRef: string;
|
|
85
|
+
resourceId?: string;
|
|
86
|
+
location?: string;
|
|
87
|
+
from?: string;
|
|
88
|
+
to?: string;
|
|
89
|
+
limit?: number;
|
|
90
|
+
after?: string;
|
|
91
|
+
}): Promise<SlotlockAvailabilityException[]>;
|
|
92
|
+
export declare function deleteAvailabilityException(sql: StoreSql, params: {
|
|
93
|
+
tenantRef: string;
|
|
94
|
+
id: string;
|
|
95
|
+
}): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* Each resource's exceptions that reach local days from `from` to `to` (`YYYY-MM-DD`), ranked as the
|
|
98
|
+
* evaluator applies them: the tenant's (0), each location's from the outermost in, the resource's
|
|
99
|
+
* own (1000).
|
|
100
|
+
*/
|
|
101
|
+
export declare function rankedExceptions(sql: StoreSql, resourceIds: readonly string[], days: {
|
|
102
|
+
from: string;
|
|
103
|
+
to?: string;
|
|
104
|
+
}): Promise<Map<string, SlotlockRankedException[]>>;
|
|
105
|
+
/**
|
|
106
|
+
* Replace the exceptions an import of one resource's VAVAILABILITY made with `ranges`. Refuses as
|
|
107
|
+
* createAvailabilityException does.
|
|
108
|
+
*/
|
|
109
|
+
export declare function replaceImportedExceptions(sql: StoreSql, params: {
|
|
110
|
+
tenantRef: string;
|
|
111
|
+
resourceId: string;
|
|
112
|
+
ranges: readonly {
|
|
113
|
+
startsOn: string;
|
|
114
|
+
endsOn: string;
|
|
115
|
+
outcome: SlotlockExceptionOutcome;
|
|
116
|
+
hours?: SlotlockExceptionWindow[];
|
|
117
|
+
}[];
|
|
118
|
+
}): Promise<number>;
|
|
119
|
+
/** A holiday calendar imported into closures (RFC 0004 B1): a pasted or uploaded one, or a subscription. */
|
|
120
|
+
export interface SlotlockHolidayCalendar {
|
|
121
|
+
id: string;
|
|
122
|
+
/** Unique at its scope: importing under the same name replaces what that calendar said. */
|
|
123
|
+
name: string;
|
|
124
|
+
location?: string;
|
|
125
|
+
resourceId?: string;
|
|
126
|
+
/** A subscription's https URL, imported again by maintenance by `nextImportAt`. */
|
|
127
|
+
url?: string;
|
|
128
|
+
importedAt?: Date;
|
|
129
|
+
nextImportAt?: Date;
|
|
130
|
+
/** Why the last import of a subscription failed; cleared by the next that works. */
|
|
131
|
+
lastError?: string;
|
|
132
|
+
/** Its closures. */
|
|
133
|
+
closures: number;
|
|
134
|
+
createdAt: Date;
|
|
135
|
+
}
|
|
136
|
+
/** What one import of a holiday calendar did. */
|
|
137
|
+
export interface SlotlockHolidayImport {
|
|
138
|
+
calendar: SlotlockHolidayCalendar;
|
|
139
|
+
/** Holidays added or updated. */
|
|
140
|
+
imported: number;
|
|
141
|
+
/** Closures this calendar made that it no longer names in the import's span, deleted. */
|
|
142
|
+
removed: number;
|
|
143
|
+
}
|
|
144
|
+
/** How long a subscription waits between imports, and after a failed one. */
|
|
145
|
+
export declare const SLOTLOCK_HOLIDAY_REIMPORT_DAYS = 30;
|
|
146
|
+
export declare const SLOTLOCK_HOLIDAY_RETRY_HOURS = 24;
|
|
147
|
+
/** Holiday calendars a tenant may keep. */
|
|
148
|
+
export declare const SLOTLOCK_MAX_HOLIDAY_CALENDARS = 50;
|
|
149
|
+
/**
|
|
150
|
+
* Import a holiday calendar's days off as closures at its scope (the tenant, a location or a
|
|
151
|
+
* resource), as the calendar named `name` there: each holiday added or updated by its UID, then
|
|
152
|
+
* the closures this calendar made earlier that it no longer names between `span.from` and
|
|
153
|
+
* `span.to` deleted, so a holiday it dropped goes too. A closure imported before calendars were
|
|
154
|
+
* kept, with the UID of one it names, becomes this calendar's. With `url`, the calendar is a
|
|
155
|
+
* subscription maintenance imports again every SLOTLOCK_HOLIDAY_REIMPORT_DAYS; without, it stops
|
|
156
|
+
* being one. Refuses `invalid_holiday_calendar`, `location_not_found`, `resource_not_found`,
|
|
157
|
+
* `holiday_calendars_limit_reached` and `availability_exceptions_limit_reached`.
|
|
158
|
+
*/
|
|
159
|
+
export declare function importHolidayCalendar(sql: StoreSql, params: {
|
|
160
|
+
tenantRef: string;
|
|
161
|
+
location?: string;
|
|
162
|
+
resourceId?: string;
|
|
163
|
+
name: string;
|
|
164
|
+
url?: string;
|
|
165
|
+
holidays: readonly SlotlockHoliday[];
|
|
166
|
+
span: {
|
|
167
|
+
from: string;
|
|
168
|
+
to: string;
|
|
169
|
+
};
|
|
170
|
+
}): Promise<SlotlockHolidayImport>;
|
|
171
|
+
/** The tenant's holiday calendars, by scope and name. */
|
|
172
|
+
export declare function listHolidayCalendars(sql: StoreSql, params: {
|
|
173
|
+
tenantRef: string;
|
|
174
|
+
}): Promise<SlotlockHolidayCalendar[]>;
|
|
175
|
+
/** Delete a holiday calendar and its closures. Null for one the tenant does not have. */
|
|
176
|
+
export declare function deleteHolidayCalendar(sql: StoreSql, params: {
|
|
177
|
+
tenantRef: string;
|
|
178
|
+
id: string;
|
|
179
|
+
}): Promise<{
|
|
180
|
+
closures: number;
|
|
181
|
+
} | null>;
|
|
182
|
+
/** Subscriptions due to be imported again, the longest waiting first. */
|
|
183
|
+
export declare function dueHolidayCalendars(sql: StoreSql, params: {
|
|
184
|
+
tenantRef: string;
|
|
185
|
+
limit: number;
|
|
186
|
+
}): Promise<SlotlockHolidayCalendar[]>;
|
|
187
|
+
/** Note why a subscription's import failed, and try again in SLOTLOCK_HOLIDAY_RETRY_HOURS. */
|
|
188
|
+
export declare function noteHolidayCalendarFailure(sql: StoreSql, params: {
|
|
189
|
+
tenantRef: string;
|
|
190
|
+
id: string;
|
|
191
|
+
error: string;
|
|
192
|
+
}): Promise<void>;
|
|
193
|
+
export {};
|