@ordinatio/scheduling-api 0.4.0 → 0.4.1
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 +24 -0
- package/README.md +1 -1
- package/dist/agent/index.js +545 -22
- package/dist/agent/index.mjs +545 -22
- package/dist/index.js +12 -0
- package/dist/index.mjs +12 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4664,6 +4664,15 @@ async function requireOwnedVisibleCalendar(staff, calendarId) {
|
|
|
4664
4664
|
return calendar ?? NOT_FOUND8();
|
|
4665
4665
|
}
|
|
4666
4666
|
|
|
4667
|
+
// src/availability/clear-availability-cache.ts
|
|
4668
|
+
async function clearAvailabilityCache(host, calendarId) {
|
|
4669
|
+
try {
|
|
4670
|
+
await host.availabilityCache.invalidate(calendarId);
|
|
4671
|
+
} catch (error) {
|
|
4672
|
+
console.warn("[availability-cache-clear-failed]", calendarId, error);
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4667
4676
|
// src/availability/validate-weekly-rules.ts
|
|
4668
4677
|
function validateWeeklyRules(rules) {
|
|
4669
4678
|
for (const rule of rules) {
|
|
@@ -4733,6 +4742,7 @@ async function setWeeklyRules(request, { host, params }) {
|
|
|
4733
4742
|
const validationError = validateWeeklyRules(rules);
|
|
4734
4743
|
if (validationError) return Response.json({ error: validationError }, { status: 400 });
|
|
4735
4744
|
const created = await setWeeklyAvailability(db, calendarId, rules);
|
|
4745
|
+
await clearAvailabilityCache(host, calendarId);
|
|
4736
4746
|
const activeDays = rules.map((r) => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][r.dayOfWeek]).join(", ");
|
|
4737
4747
|
await host.activity.log(db, {
|
|
4738
4748
|
action: "scheduling.availability_updated",
|
|
@@ -4813,6 +4823,7 @@ async function addOverride(request, { host, params }) {
|
|
|
4813
4823
|
endTime: body.endTime
|
|
4814
4824
|
});
|
|
4815
4825
|
}
|
|
4826
|
+
await clearAvailabilityCache(host, calendarId);
|
|
4816
4827
|
let overlapWarning;
|
|
4817
4828
|
if (isBlockedFlag && body.startTime && body.endTime) {
|
|
4818
4829
|
const dateStr = body.date.split("T")[0];
|
|
@@ -4859,6 +4870,7 @@ async function removeOverride(request, { host, params }) {
|
|
|
4859
4870
|
const { ruleId } = await request.json();
|
|
4860
4871
|
if (!ruleId) return Response.json({ error: "ruleId is required" }, { status: 400 });
|
|
4861
4872
|
const deletedRule = await removeDateOverride(db, calendarId, ruleId);
|
|
4873
|
+
await clearAvailabilityCache(host, calendarId);
|
|
4862
4874
|
const deletedIsTimeBlock = deletedRule?.isBlocked && !(deletedRule.startTime === "00:00" && deletedRule.endTime === "00:00");
|
|
4863
4875
|
await host.activity.log(db, {
|
|
4864
4876
|
action: "scheduling.date_override_removed",
|
package/package.json
CHANGED