@ossy/booking 3.24.0 → 3.24.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/package.json +9 -9
- package/src/cancel-booking.task.js +2 -2
- package/src/confirm-booking.task.js +3 -3
- package/src/create-booking.task.js +4 -4
- package/src/create-booking.task.spec.js +1 -1
- package/src/create-service.task.js +1 -1
- package/src/decline-booking.task.js +3 -3
- package/src/delete-service.task.js +1 -1
- package/src/get-availability.task.js +2 -2
- package/src/get-available-slots.task.js +3 -3
- package/src/get-services.task.js +2 -2
- package/src/list-bookings.task.js +3 -3
- package/src/save-availability.task.js +4 -4
- package/src/send-booking-reminder.task.js +3 -3
- package/src/update-service.task.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/booking",
|
|
3
3
|
"description": "Booking feature package — services, availability, and appointment management for Ossy providers",
|
|
4
|
-
"version": "3.24.
|
|
4
|
+
"version": "3.24.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@ossy/config": "^3.0.9",
|
|
18
|
-
"@ossy/email": "^3.24.
|
|
19
|
-
"@ossy/event-store": "^3.
|
|
20
|
-
"@ossy/observability": "^3.
|
|
21
|
-
"@ossy/platform": "^3.24.
|
|
22
|
-
"@ossy/resources": "^3.24.
|
|
23
|
-
"@ossy/users": "^3.24.
|
|
24
|
-
"@ossy/workspaces": "^3.24.
|
|
18
|
+
"@ossy/email": "^3.24.1",
|
|
19
|
+
"@ossy/event-store": "^3.24.1",
|
|
20
|
+
"@ossy/observability": "^3.24.1",
|
|
21
|
+
"@ossy/platform": "^3.24.1",
|
|
22
|
+
"@ossy/resources": "^3.24.1",
|
|
23
|
+
"@ossy/users": "^3.24.1",
|
|
24
|
+
"@ossy/workspaces": "^3.24.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@ossy/app": ">=1.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"/src",
|
|
39
39
|
"README.md"
|
|
40
40
|
],
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d0e7eda0397239d5e8a8cd5115d9c91959b4103f"
|
|
42
42
|
}
|
|
@@ -21,7 +21,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
21
21
|
if (!bookingId) throw Object.assign(new Error('bookingId is required'), { status: 400 })
|
|
22
22
|
if (!sdk?.invoke) throw Object.assign(new Error('sdk is required'), { status: 500 })
|
|
23
23
|
|
|
24
|
-
log?.
|
|
24
|
+
log?.debug(`[booking/tasks/cancel] Cancelling booking ${bookingId}`)
|
|
25
25
|
|
|
26
26
|
const booking = await loadBooking(sdk, bookingId)
|
|
27
27
|
|
|
@@ -38,7 +38,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
38
38
|
content: { status: 'cancelled' },
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
log?.
|
|
41
|
+
log?.debug(`[booking/tasks/cancel] Booking ${bookingId} cancelled`)
|
|
42
42
|
|
|
43
43
|
const emailClient = integrations?.get?.('email')
|
|
44
44
|
if (emailClient && booking.content?.clientEmail) {
|
|
@@ -25,7 +25,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
25
25
|
if (!bookingId) throw Object.assign(new Error('bookingId is required'), { status: 400 })
|
|
26
26
|
if (!sdk?.invoke) throw Object.assign(new Error('sdk is required'), { status: 500 })
|
|
27
27
|
|
|
28
|
-
log?.
|
|
28
|
+
log?.debug(`[booking/tasks/confirm] Confirming booking ${bookingId}`)
|
|
29
29
|
|
|
30
30
|
const booking = await loadBooking(sdk, bookingId)
|
|
31
31
|
|
|
@@ -45,7 +45,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
45
45
|
content: { status: 'confirmed' },
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
log?.
|
|
48
|
+
log?.debug(`[booking/tasks/confirm] Booking ${bookingId} confirmed`)
|
|
49
49
|
|
|
50
50
|
const emailClient = integrations?.get?.('email')
|
|
51
51
|
if (emailClient && booking.content?.clientEmail) {
|
|
@@ -66,7 +66,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
66
66
|
templateId: bookingConfirmationEmailId,
|
|
67
67
|
},
|
|
68
68
|
)
|
|
69
|
-
log?.
|
|
69
|
+
log?.debug(`[booking/tasks/confirm] Confirmation email sent to ${booking.content.clientEmail}`)
|
|
70
70
|
} catch (err) {
|
|
71
71
|
log?.error('[booking/tasks/confirm] Failed to send confirmation email to client', err)
|
|
72
72
|
}
|
|
@@ -51,7 +51,7 @@ export async function run({ payload, req, log, integrations, sdk }) {
|
|
|
51
51
|
if (!clientName) throw Object.assign(new Error('clientName is required'), { status: 400 })
|
|
52
52
|
if (!clientEmail) throw Object.assign(new Error('clientEmail is required'), { status: 400 })
|
|
53
53
|
|
|
54
|
-
log?.
|
|
54
|
+
log?.debug(`[booking/tasks/create] Creating booking for ${clientEmail} with workspace ${workspaceId}`)
|
|
55
55
|
|
|
56
56
|
const availabilityResources = await getBookingResources({
|
|
57
57
|
schemaId: BookingSchema.availability,
|
|
@@ -146,7 +146,7 @@ export async function run({ payload, req, log, integrations, sdk }) {
|
|
|
146
146
|
|
|
147
147
|
const bookingId = booking.id
|
|
148
148
|
|
|
149
|
-
log?.
|
|
149
|
+
log?.debug(`[booking/tasks/create] Booking ${bookingId} created`)
|
|
150
150
|
|
|
151
151
|
const emailClient = integrations?.get?.('email')
|
|
152
152
|
if (emailClient) {
|
|
@@ -186,7 +186,7 @@ export async function run({ payload, req, log, integrations, sdk }) {
|
|
|
186
186
|
templateId: bookingRequestEmailId,
|
|
187
187
|
},
|
|
188
188
|
)
|
|
189
|
-
log?.
|
|
189
|
+
log?.debug(`[booking/tasks/create] Booking request email sent to provider ${providerEmail}`)
|
|
190
190
|
} catch (err) {
|
|
191
191
|
log?.error('[booking/tasks/create] Failed to send booking request email to provider', err)
|
|
192
192
|
}
|
|
@@ -202,7 +202,7 @@ export async function run({ payload, req, log, integrations, sdk }) {
|
|
|
202
202
|
text: `Hej ${clientName},\n\nVi har tagit emot din bokningsförfrågan. Bokningsansvarig bekräftar inom kort och du får ett nytt mejl med kalenderinbjudan när bokningen är bekräftad.\n\nMvh\nOssy`,
|
|
203
203
|
},
|
|
204
204
|
)
|
|
205
|
-
log?.
|
|
205
|
+
log?.debug(`[booking/tasks/create] Receipt email sent to client ${clientEmail}`)
|
|
206
206
|
} catch (err) {
|
|
207
207
|
log?.error('[booking/tasks/create] Failed to send receipt email to client', err)
|
|
208
208
|
}
|
|
@@ -28,7 +28,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
28
28
|
active: active !== false,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
log?.
|
|
31
|
+
log?.debug(`[booking/tasks/create-service] Creating service for workspace ${workspaceId}`)
|
|
32
32
|
|
|
33
33
|
const service = await sdk.invoke(CreateResource, {
|
|
34
34
|
workspaceId,
|
|
@@ -22,7 +22,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
22
22
|
if (!bookingId) throw Object.assign(new Error('bookingId is required'), { status: 400 })
|
|
23
23
|
if (!sdk?.invoke) throw Object.assign(new Error('sdk is required'), { status: 500 })
|
|
24
24
|
|
|
25
|
-
log?.
|
|
25
|
+
log?.debug(`[booking/tasks/decline] Declining booking ${bookingId}`)
|
|
26
26
|
|
|
27
27
|
const booking = await loadBooking(sdk, bookingId)
|
|
28
28
|
|
|
@@ -43,7 +43,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
43
43
|
content: { status: 'cancelled', declineReason: reason ?? '' },
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
log?.
|
|
46
|
+
log?.debug(`[booking/tasks/decline] Booking ${bookingId} declined`)
|
|
47
47
|
|
|
48
48
|
const emailClient = integrations?.get?.('email')
|
|
49
49
|
if (emailClient && booking.content?.clientEmail) {
|
|
@@ -62,7 +62,7 @@ export async function run ({ payload, req, log, integrations, sdk }) {
|
|
|
62
62
|
subject: 'Din bokningsförfrågan avböjdes',
|
|
63
63
|
},
|
|
64
64
|
)
|
|
65
|
-
log?.
|
|
65
|
+
log?.debug(`[booking/tasks/decline] Decline email sent to ${booking.content.clientEmail}`)
|
|
66
66
|
} catch (err) {
|
|
67
67
|
log?.error('[booking/tasks/decline] Failed to send decline email to client', err)
|
|
68
68
|
}
|
|
@@ -27,7 +27,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
27
27
|
throw Object.assign(new Error('Service not found'), { status: 404 })
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
log?.
|
|
30
|
+
log?.debug(`[booking/tasks/delete-service] Deleting service ${serviceId}`)
|
|
31
31
|
|
|
32
32
|
await sdk.invoke(DeleteResource, { resourceId: serviceId })
|
|
33
33
|
|
|
@@ -10,7 +10,7 @@ export async function run({ payload, req, log, sdk }) {
|
|
|
10
10
|
throw Object.assign(new Error('workspaceId is required'), { status: 400 })
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
log?.
|
|
13
|
+
log?.debug(`[booking/tasks/get-availability] Loading availability for workspace ${workspaceId}`)
|
|
14
14
|
|
|
15
15
|
const resources = await getBookingResources({
|
|
16
16
|
schemaId: BookingSchema.availability,
|
|
@@ -19,7 +19,7 @@ export async function run({ payload, req, log, sdk }) {
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
if (!resources.length) {
|
|
22
|
-
log?.
|
|
22
|
+
log?.debug('[booking/tasks/get-availability] No availability configured')
|
|
23
23
|
return null
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -17,7 +17,7 @@ export async function run ({ payload, log, sdk }) {
|
|
|
17
17
|
throw Object.assign(new Error('providerSlug, workspaceId, or providerId is required'), { status: 400 })
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
log?.
|
|
20
|
+
log?.debug(`[booking/tasks/get-available-slots] Loading slots for workspace ${workspaceId}`)
|
|
21
21
|
|
|
22
22
|
const workspaceSdk = sdkForWorkspace(sdk, workspaceId)
|
|
23
23
|
let slotDuration = duration
|
|
@@ -42,7 +42,7 @@ export async function run ({ payload, log, sdk }) {
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
if (!availabilityResources.length) {
|
|
45
|
-
log?.
|
|
45
|
+
log?.debug('[booking/tasks/get-available-slots] No availability resources found, returning []')
|
|
46
46
|
return []
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -103,6 +103,6 @@ export async function run ({ payload, log, sdk }) {
|
|
|
103
103
|
duration: resolvedDuration,
|
|
104
104
|
})
|
|
105
105
|
|
|
106
|
-
log?.
|
|
106
|
+
log?.debug(`[booking/tasks/get-available-slots] Returning ${slots.length} slots`)
|
|
107
107
|
return slots
|
|
108
108
|
}
|
package/src/get-services.task.js
CHANGED
|
@@ -12,7 +12,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
12
12
|
throw Object.assign(new Error('providerSlug, workspaceId, or providerId is required'), { status: 400 })
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
log?.
|
|
15
|
+
log?.debug(`[booking/tasks/get-services] Loading services for ${workspaceId}`)
|
|
16
16
|
|
|
17
17
|
const resources = await getBookingResources({
|
|
18
18
|
schemaId: BookingSchema.service,
|
|
@@ -35,7 +35,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
35
35
|
.filter(s => includeInactive || s.active)
|
|
36
36
|
.sort((a, b) => (a.name || '').localeCompare(b.name || ''))
|
|
37
37
|
|
|
38
|
-
log?.
|
|
38
|
+
log?.debug(`[booking/tasks/get-services] Returning ${services.length} service(s)`)
|
|
39
39
|
|
|
40
40
|
if (payload?.includeContact === true) {
|
|
41
41
|
const contact = await resolveWorkspaceContact(workspaceId)
|
|
@@ -18,14 +18,14 @@ export async function run({ payload, req, log, sdk }) {
|
|
|
18
18
|
const status = payload?.status ?? null
|
|
19
19
|
|
|
20
20
|
const member = isWorkspaceMember(req, payload, workspaceId)
|
|
21
|
-
log?.
|
|
21
|
+
log?.debug(`[booking/tasks/list] Loading bookings for workspace ${workspaceId}`, { status })
|
|
22
22
|
|
|
23
23
|
if (!member) return []
|
|
24
24
|
|
|
25
25
|
let bookings = await loadFromProjection(workspaceId)
|
|
26
26
|
|
|
27
27
|
if (bookings == null) {
|
|
28
|
-
log?.
|
|
28
|
+
log?.debug('[booking/tasks/list] Projection miss — scanning resources')
|
|
29
29
|
const resources = await getBookingResources({
|
|
30
30
|
schemaId: BookingSchema.booking,
|
|
31
31
|
belongsTo: workspaceId,
|
|
@@ -48,7 +48,7 @@ export async function run({ payload, req, log, sdk }) {
|
|
|
48
48
|
return dateB - dateA
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
log?.
|
|
51
|
+
log?.debug(`[booking/tasks/list] Found ${bookings.length} booking(s)`)
|
|
52
52
|
|
|
53
53
|
return bookings
|
|
54
54
|
}
|
|
@@ -15,7 +15,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
15
15
|
|
|
16
16
|
const { weeklyWindows, sessionDurations, bufferMinutes, timezone } = payload ?? {}
|
|
17
17
|
|
|
18
|
-
log?.
|
|
18
|
+
log?.debug(`[booking/tasks/save-availability] Saving availability for workspace ${workspaceId}`)
|
|
19
19
|
|
|
20
20
|
const content = {
|
|
21
21
|
weeklyWindows: (weeklyWindows ?? []).map(({ dayOfWeek, startTime, endTime }) => ({
|
|
@@ -39,7 +39,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
39
39
|
const configResource = existing.find(r => Array.isArray(r.content?.weeklyWindows))
|
|
40
40
|
|
|
41
41
|
if (configResource) {
|
|
42
|
-
log?.
|
|
42
|
+
log?.debug(`[booking/tasks/save-availability] Updating existing resource ${configResource.id}`)
|
|
43
43
|
|
|
44
44
|
await sdk.invoke(PatchResourceContent, {
|
|
45
45
|
resourceId: configResource.id,
|
|
@@ -50,7 +50,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Schema includes weeklyWindows / sessionDurations / bufferMinutes — create atomically.
|
|
53
|
-
log?.
|
|
53
|
+
log?.debug(`[booking/tasks/save-availability] Creating new availability config`)
|
|
54
54
|
|
|
55
55
|
const resource = await sdk.invoke(CreateResource, {
|
|
56
56
|
workspaceId,
|
|
@@ -60,7 +60,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
60
60
|
content,
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
log?.
|
|
63
|
+
log?.debug(`[booking/tasks/save-availability] Resource ${resource.id} created`)
|
|
64
64
|
|
|
65
65
|
return { id: resource.id, content }
|
|
66
66
|
}
|
|
@@ -16,7 +16,7 @@ export async function run({ sdk, log, integrations }) {
|
|
|
16
16
|
const windowStartMs = now + 23 * 60 * 60 * 1000
|
|
17
17
|
const windowEndMs = now + 25 * 60 * 60 * 1000
|
|
18
18
|
|
|
19
|
-
log?.
|
|
19
|
+
log?.debug(`[booking/tasks/send-reminder] Checking bookings between ${windowStartMs} and ${windowEndMs}`)
|
|
20
20
|
|
|
21
21
|
const allBookings = await getBookingResources({
|
|
22
22
|
schemaId: BookingSchema.booking,
|
|
@@ -32,7 +32,7 @@ export async function run({ sdk, log, integrations }) {
|
|
|
32
32
|
return startsAtMs >= windowStartMs && startsAtMs <= windowEndMs
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
log?.
|
|
35
|
+
log?.debug(`[booking/tasks/send-reminder] Found ${upcoming.length} bookings needing reminders`)
|
|
36
36
|
|
|
37
37
|
const emailClient = integrations?.get?.('email')
|
|
38
38
|
if (!emailClient) {
|
|
@@ -90,7 +90,7 @@ export async function run({ sdk, log, integrations }) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
sent++
|
|
93
|
-
log?.
|
|
93
|
+
log?.debug(`[booking/tasks/send-reminder] Reminder sent to ${clientEmail}`)
|
|
94
94
|
} catch (err) {
|
|
95
95
|
log?.error(`[booking/tasks/send-reminder] Failed to send reminder to ${clientEmail}`, err)
|
|
96
96
|
}
|
|
@@ -38,7 +38,7 @@ export async function run ({ payload, req, log, sdk }) {
|
|
|
38
38
|
...(active != null ? { active: active !== false } : {}),
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
log?.
|
|
41
|
+
log?.debug(`[booking/tasks/update-service] Updating service ${serviceId}`)
|
|
42
42
|
|
|
43
43
|
await sdk.invoke(PatchResourceContent, {
|
|
44
44
|
resourceId: serviceId,
|