@ordinatio/scheduling-api 0.2.0 → 0.3.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 +7 -0
- package/dist/index.js +15 -6
- package/dist/index.mjs +16 -7
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (2026-10-29)
|
|
4
|
+
|
|
5
|
+
- **Security fix: the staff routes `GET /appointments`, `GET /analytics` and `GET /admin/group-sessions` now limit what they return to
|
|
6
|
+
the signed-in person's organization themselves.** Before, they trusted `staff.db` to be limited to one business, so a host that keeps
|
|
7
|
+
several businesses in one database showed staff the other businesses' appointments (names, emails, phones) and revenue totals.
|
|
8
|
+
Needs `@ordinatio/scheduling` 0.5.0 (the peer range is now `^0.5.0`). No host configuration changes: the routes use the organization of the signed-in staff member your `staff.resolve` already returns. Hosts that give each business its own database were not affected. Routes that act on one appointment or calendar by id already checked ownership; this release covers the three list and total routes.
|
|
9
|
+
|
|
3
10
|
## 0.2.0 (2026-10-28)
|
|
4
11
|
|
|
5
12
|
- **Organization brand.** Set `host.brand` to turn it on. Public route: `GET /brand` (what a visitor may see, never an email
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,9 @@ __export(index_exports, {
|
|
|
108
108
|
});
|
|
109
109
|
module.exports = __toCommonJS(index_exports);
|
|
110
110
|
|
|
111
|
+
// src/create-api.ts
|
|
112
|
+
var engine = __toESM(require("@ordinatio/scheduling"));
|
|
113
|
+
|
|
111
114
|
// src/cors.ts
|
|
112
115
|
function defaultCorsHeaders() {
|
|
113
116
|
return {
|
|
@@ -1839,10 +1842,10 @@ async function listNotifications(request, { host, params }) {
|
|
|
1839
1842
|
noRateLimit: true
|
|
1840
1843
|
});
|
|
1841
1844
|
if (staff instanceof Response) return staff;
|
|
1842
|
-
const { db } = staff;
|
|
1845
|
+
const { db, organizationId } = staff;
|
|
1843
1846
|
const { id } = params;
|
|
1844
1847
|
if (!await staff.canSeeAppointment(id)) return NOT_FOUND3();
|
|
1845
|
-
const appointment = await db
|
|
1848
|
+
const appointment = await verifyAppointmentOwnership(db, id, organizationId);
|
|
1846
1849
|
if (!appointment) return NOT_FOUND3();
|
|
1847
1850
|
const notifications = await db.scheduledNotification.findMany({
|
|
1848
1851
|
where: { appointmentId: id },
|
|
@@ -3903,7 +3906,7 @@ async function listGroupSessions(request, { host }) {
|
|
|
3903
3906
|
}
|
|
3904
3907
|
const calendarId = params.get("calendarId") || void 0;
|
|
3905
3908
|
const visibleCalendarIds = await staff.visibleCalendarIds();
|
|
3906
|
-
const { sessions, hasMore } = await (0, import_scheduling28.getGroupSessions)(staff.db, { startDate, endDate, calendarId, visibleCalendarIds });
|
|
3909
|
+
const { sessions, hasMore } = await (0, import_scheduling28.getGroupSessions)(staff.db, { startDate, endDate, calendarId, visibleCalendarIds, organizationId: staff.organizationId });
|
|
3907
3910
|
return Response.json({ sessions, total: sessions.length, hasMore });
|
|
3908
3911
|
} catch (error) {
|
|
3909
3912
|
const err = (0, import_scheduling28.schedError)("SCHED_311", { error });
|
|
@@ -4430,7 +4433,7 @@ async function getAnalytics(request, { host }) {
|
|
|
4430
4433
|
}
|
|
4431
4434
|
}
|
|
4432
4435
|
const visibleCalendarIds = await staff.visibleCalendarIds();
|
|
4433
|
-
const analytics = await (0, import_scheduling34.getBookingAnalytics)(staff.db, { days, calendarId, visibleCalendarIds });
|
|
4436
|
+
const analytics = await (0, import_scheduling34.getBookingAnalytics)(staff.db, { days, calendarId, visibleCalendarIds, organizationId: staff.organizationId });
|
|
4434
4437
|
return Response.json(analytics);
|
|
4435
4438
|
} catch (error) {
|
|
4436
4439
|
const ref = getErrorRef(error);
|
|
@@ -7161,7 +7164,7 @@ async function listAppointments(request, { host }) {
|
|
|
7161
7164
|
MAX_LIMIT2
|
|
7162
7165
|
);
|
|
7163
7166
|
const visibility = await staff.visibleCalendars();
|
|
7164
|
-
const where = {
|
|
7167
|
+
const where = (0, import_scheduling69.withOrganization)({
|
|
7165
7168
|
...visibility ? { calendar: visibility } : {},
|
|
7166
7169
|
...calendarId ? { calendarId } : {},
|
|
7167
7170
|
...clientId ? { clientId } : {},
|
|
@@ -7172,7 +7175,7 @@ async function listAppointments(request, { host }) {
|
|
|
7172
7175
|
...endDate ? { lte: new Date(endDate) } : {}
|
|
7173
7176
|
}
|
|
7174
7177
|
} : {}
|
|
7175
|
-
};
|
|
7178
|
+
}, staff.organizationId);
|
|
7176
7179
|
const [rows, total] = await Promise.all([
|
|
7177
7180
|
staff.db.appointment.findMany({
|
|
7178
7181
|
where,
|
|
@@ -7984,7 +7987,13 @@ function matchPath(pattern, path) {
|
|
|
7984
7987
|
function notFound() {
|
|
7985
7988
|
return Response.json({ error: "Not found" }, { status: 404 });
|
|
7986
7989
|
}
|
|
7990
|
+
function requireOrganizationScoping() {
|
|
7991
|
+
if (typeof engine.withOrganization !== "function") {
|
|
7992
|
+
throw new Error("@ordinatio/scheduling-api 0.3 needs @ordinatio/scheduling 0.5.0 or newer: this engine does not limit results to an organization. Update @ordinatio/scheduling.");
|
|
7993
|
+
}
|
|
7994
|
+
}
|
|
7987
7995
|
function createSchedulingApi(config) {
|
|
7996
|
+
requireOrganizationScoping();
|
|
7988
7997
|
const routes = config.routes ?? ROUTES;
|
|
7989
7998
|
const basePath = (config.basePath ?? "/api/scheduling").replace(/\/+$/, "");
|
|
7990
7999
|
const host = {
|
package/dist/index.mjs
CHANGED
|
@@ -39,6 +39,9 @@ import {
|
|
|
39
39
|
UpdateServicePackageSchema
|
|
40
40
|
} from "./chunk-MQO3VRMU.mjs";
|
|
41
41
|
|
|
42
|
+
// src/create-api.ts
|
|
43
|
+
import * as engine from "@ordinatio/scheduling";
|
|
44
|
+
|
|
42
45
|
// src/cors.ts
|
|
43
46
|
function defaultCorsHeaders() {
|
|
44
47
|
return {
|
|
@@ -1788,10 +1791,10 @@ async function listNotifications(request, { host, params }) {
|
|
|
1788
1791
|
noRateLimit: true
|
|
1789
1792
|
});
|
|
1790
1793
|
if (staff instanceof Response) return staff;
|
|
1791
|
-
const { db } = staff;
|
|
1794
|
+
const { db, organizationId } = staff;
|
|
1792
1795
|
const { id } = params;
|
|
1793
1796
|
if (!await staff.canSeeAppointment(id)) return NOT_FOUND3();
|
|
1794
|
-
const appointment = await db
|
|
1797
|
+
const appointment = await verifyAppointmentOwnership(db, id, organizationId);
|
|
1795
1798
|
if (!appointment) return NOT_FOUND3();
|
|
1796
1799
|
const notifications = await db.scheduledNotification.findMany({
|
|
1797
1800
|
where: { appointmentId: id },
|
|
@@ -3423,7 +3426,7 @@ async function listGroupSessions(request, { host }) {
|
|
|
3423
3426
|
}
|
|
3424
3427
|
const calendarId = params.get("calendarId") || void 0;
|
|
3425
3428
|
const visibleCalendarIds = await staff.visibleCalendarIds();
|
|
3426
|
-
const { sessions, hasMore } = await getGroupSessions(staff.db, { startDate, endDate, calendarId, visibleCalendarIds });
|
|
3429
|
+
const { sessions, hasMore } = await getGroupSessions(staff.db, { startDate, endDate, calendarId, visibleCalendarIds, organizationId: staff.organizationId });
|
|
3427
3430
|
return Response.json({ sessions, total: sessions.length, hasMore });
|
|
3428
3431
|
} catch (error) {
|
|
3429
3432
|
const err = schedError18("SCHED_311", { error });
|
|
@@ -3955,7 +3958,7 @@ async function getAnalytics(request, { host }) {
|
|
|
3955
3958
|
}
|
|
3956
3959
|
}
|
|
3957
3960
|
const visibleCalendarIds = await staff.visibleCalendarIds();
|
|
3958
|
-
const analytics = await getBookingAnalytics(staff.db, { days, calendarId, visibleCalendarIds });
|
|
3961
|
+
const analytics = await getBookingAnalytics(staff.db, { days, calendarId, visibleCalendarIds, organizationId: staff.organizationId });
|
|
3959
3962
|
return Response.json(analytics);
|
|
3960
3963
|
} catch (error) {
|
|
3961
3964
|
const ref = getErrorRef(error);
|
|
@@ -6684,7 +6687,7 @@ async function testRoutingFormRoute(request, { host, params }) {
|
|
|
6684
6687
|
}
|
|
6685
6688
|
|
|
6686
6689
|
// src/handlers/appointments-list.ts
|
|
6687
|
-
import { schedError as schedError28 } from "@ordinatio/scheduling";
|
|
6690
|
+
import { schedError as schedError28, withOrganization } from "@ordinatio/scheduling";
|
|
6688
6691
|
var DEFAULT_LIMIT2 = 50;
|
|
6689
6692
|
var MAX_LIMIT2 = 500;
|
|
6690
6693
|
async function listAppointments(request, { host }) {
|
|
@@ -6707,7 +6710,7 @@ async function listAppointments(request, { host }) {
|
|
|
6707
6710
|
MAX_LIMIT2
|
|
6708
6711
|
);
|
|
6709
6712
|
const visibility = await staff.visibleCalendars();
|
|
6710
|
-
const where = {
|
|
6713
|
+
const where = withOrganization({
|
|
6711
6714
|
...visibility ? { calendar: visibility } : {},
|
|
6712
6715
|
...calendarId ? { calendarId } : {},
|
|
6713
6716
|
...clientId ? { clientId } : {},
|
|
@@ -6718,7 +6721,7 @@ async function listAppointments(request, { host }) {
|
|
|
6718
6721
|
...endDate ? { lte: new Date(endDate) } : {}
|
|
6719
6722
|
}
|
|
6720
6723
|
} : {}
|
|
6721
|
-
};
|
|
6724
|
+
}, staff.organizationId);
|
|
6722
6725
|
const [rows, total] = await Promise.all([
|
|
6723
6726
|
staff.db.appointment.findMany({
|
|
6724
6727
|
where,
|
|
@@ -7530,7 +7533,13 @@ function matchPath(pattern, path) {
|
|
|
7530
7533
|
function notFound() {
|
|
7531
7534
|
return Response.json({ error: "Not found" }, { status: 404 });
|
|
7532
7535
|
}
|
|
7536
|
+
function requireOrganizationScoping() {
|
|
7537
|
+
if (typeof engine.withOrganization !== "function") {
|
|
7538
|
+
throw new Error("@ordinatio/scheduling-api 0.3 needs @ordinatio/scheduling 0.5.0 or newer: this engine does not limit results to an organization. Update @ordinatio/scheduling.");
|
|
7539
|
+
}
|
|
7540
|
+
}
|
|
7533
7541
|
function createSchedulingApi(config) {
|
|
7542
|
+
requireOrganizationScoping();
|
|
7534
7543
|
const routes = config.routes ?? ROUTES;
|
|
7535
7544
|
const basePath = (config.basePath ?? "/api/scheduling").replace(/\/+$/, "");
|
|
7536
7545
|
const host = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordinatio/scheduling-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "HTTP API for @ordinatio/scheduling. Every handler takes a Request and returns a Response.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"sanitize-html": "^2.16.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@ordinatio/scheduling": "^0.
|
|
14
|
+
"@ordinatio/scheduling": "^0.5.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/sanitize-html": "^2.13.0",
|
|
18
18
|
"tsup": "^8.0.0",
|
|
19
19
|
"typescript": "5",
|
|
20
20
|
"vitest": "4.0.18",
|
|
21
|
-
"@ordinatio/scheduling": "0.
|
|
21
|
+
"@ordinatio/scheduling": "0.5.0"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.0.0"
|