@nuwah/vertical-sdk 0.0.0-stage → 0.2.0-rc.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/LICENSE +17 -0
- package/README.md +229 -2
- package/bin/nuwah-contract-check-rules.d.mts +41 -0
- package/bin/nuwah-contract-check-rules.mjs +333 -0
- package/bin/nuwah-contract-check.mjs +64 -0
- package/dist/accounting.d.ts +1417 -0
- package/dist/accounting.js +274 -0
- package/dist/active-org.d.ts +13 -0
- package/dist/active-org.js +59 -0
- package/dist/actors.d.ts +448 -0
- package/dist/actors.js +143 -0
- package/dist/ai.d.ts +359 -0
- package/dist/ai.js +229 -0
- package/dist/analytics.d.ts +37 -0
- package/dist/analytics.js +8 -0
- package/dist/atlas.d.ts +291 -0
- package/dist/atlas.js +78 -0
- package/dist/audit.d.ts +193 -0
- package/dist/audit.js +26 -0
- package/dist/authentication.d.ts +119 -0
- package/dist/authentication.js +83 -0
- package/dist/awards.d.ts +38 -0
- package/dist/awards.js +10 -0
- package/dist/blueprint/document.d.ts +178 -0
- package/dist/blueprint/document.js +17 -0
- package/dist/blueprint/index.d.ts +3 -0
- package/dist/blueprint/index.js +5 -0
- package/dist/blueprint/manifest.d.ts +105 -0
- package/dist/blueprint/manifest.js +11 -0
- package/dist/blueprint/validate.d.ts +14 -0
- package/dist/blueprint/validate.js +416 -0
- package/dist/bookings-directory.d.ts +118 -0
- package/dist/bookings-directory.js +289 -0
- package/dist/bookings-extra.d.ts +1448 -0
- package/dist/bookings-extra.js +582 -0
- package/dist/bookings.d.ts +1365 -0
- package/dist/bookings.js +305 -0
- package/dist/builder-code.d.ts +164 -0
- package/dist/builder-code.js +12 -0
- package/dist/builder-core-gaps.d.ts +83 -0
- package/dist/builder-core-gaps.js +8 -0
- package/dist/builder-repos.d.ts +73 -0
- package/dist/builder-repos.js +37 -0
- package/dist/builder.d.ts +730 -0
- package/dist/builder.js +105 -0
- package/dist/campaigns.d.ts +105 -0
- package/dist/campaigns.js +25 -0
- package/dist/catalogs.d.ts +188 -0
- package/dist/catalogs.js +36 -0
- package/dist/commerce-ai.d.ts +182 -0
- package/dist/commerce-ai.js +27 -0
- package/dist/connections.d.ts +278 -0
- package/dist/connections.js +96 -0
- package/dist/content-control.d.ts +121 -0
- package/dist/content-control.js +23 -0
- package/dist/contributions.d.ts +560 -0
- package/dist/contributions.js +140 -0
- package/dist/conversation-assist.d.ts +154 -0
- package/dist/conversation-assist.js +51 -0
- package/dist/conversation-info.d.ts +219 -0
- package/dist/conversation-info.js +43 -0
- package/dist/crm.d.ts +533 -0
- package/dist/crm.js +142 -0
- package/dist/dashboards.d.ts +119 -0
- package/dist/dashboards.js +22 -0
- package/dist/delegations.d.ts +161 -0
- package/dist/delegations.js +39 -0
- package/dist/docs.d.ts +289 -0
- package/dist/docs.js +49 -0
- package/dist/documents.d.ts +317 -0
- package/dist/documents.js +84 -0
- package/dist/drafts.d.ts +132 -0
- package/dist/drafts.js +56 -0
- package/dist/engagements.d.ts +133 -0
- package/dist/engagements.js +15 -0
- package/dist/event-stream.d.ts +54 -0
- package/dist/event-stream.js +228 -0
- package/dist/exchanges.d.ts +447 -0
- package/dist/exchanges.js +145 -0
- package/dist/exports.d.ts +113 -0
- package/dist/exports.js +81 -0
- package/dist/feeds.d.ts +228 -0
- package/dist/feeds.js +52 -0
- package/dist/files.d.ts +56 -0
- package/dist/files.js +55 -0
- package/dist/finance-insights.d.ts +41 -0
- package/dist/finance-insights.js +61 -0
- package/dist/fixed-assets.d.ts +155 -0
- package/dist/fixed-assets.js +28 -0
- package/dist/fulfilment-jobs.d.ts +405 -0
- package/dist/fulfilment-jobs.js +76 -0
- package/dist/fulfilment.d.ts +205 -0
- package/dist/fulfilment.js +39 -0
- package/dist/hr.d.ts +350 -0
- package/dist/hr.js +94 -0
- package/dist/http.d.ts +124 -0
- package/dist/http.js +392 -0
- package/dist/inbox.d.ts +206 -0
- package/dist/inbox.js +36 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +294 -0
- package/dist/insights.d.ts +176 -0
- package/dist/insights.js +52 -0
- package/dist/inventory.d.ts +797 -0
- package/dist/inventory.js +120 -0
- package/dist/list-query.d.ts +211 -0
- package/dist/list-query.js +158 -0
- package/dist/listings.d.ts +381 -0
- package/dist/listings.js +173 -0
- package/dist/location-sharing.d.ts +83 -0
- package/dist/location-sharing.js +20 -0
- package/dist/marketplace.d.ts +268 -0
- package/dist/marketplace.js +59 -0
- package/dist/matching.d.ts +103 -0
- package/dist/matching.js +22 -0
- package/dist/media.d.ts +221 -0
- package/dist/media.js +239 -0
- package/dist/metrics.d.ts +125 -0
- package/dist/metrics.js +45 -0
- package/dist/moderation.d.ts +240 -0
- package/dist/moderation.js +40 -0
- package/dist/money.d.ts +41 -0
- package/dist/money.js +79 -0
- package/dist/my-data.d.ts +266 -0
- package/dist/my-data.js +32 -0
- package/dist/names.d.ts +14 -0
- package/dist/names.js +17 -0
- package/dist/occasions.d.ts +256 -0
- package/dist/occasions.js +40 -0
- package/dist/onboarding.d.ts +88 -0
- package/dist/onboarding.js +38 -0
- package/dist/pagination.d.ts +204 -0
- package/dist/pagination.js +141 -0
- package/dist/party-baseline-attributes.d.ts +245 -0
- package/dist/party-baseline-attributes.js +36 -0
- package/dist/party.d.ts +401 -0
- package/dist/party.js +56 -0
- package/dist/patient.d.ts +161 -0
- package/dist/patient.js +45 -0
- package/dist/payroll.d.ts +378 -0
- package/dist/payroll.js +60 -0
- package/dist/person-addresses.d.ts +88 -0
- package/dist/person-addresses.js +18 -0
- package/dist/person-cart.d.ts +250 -0
- package/dist/person-cart.js +63 -0
- package/dist/person-chat-assist.d.ts +47 -0
- package/dist/person-chat-assist.js +13 -0
- package/dist/person-data-webhooks.d.ts +72 -0
- package/dist/person-data-webhooks.js +86 -0
- package/dist/person-data.d.ts +212 -0
- package/dist/person-data.js +162 -0
- package/dist/person-locations.d.ts +54 -0
- package/dist/person-locations.js +6 -0
- package/dist/person-messaging.d.ts +405 -0
- package/dist/person-messaging.js +112 -0
- package/dist/person-notifications.d.ts +319 -0
- package/dist/person-notifications.js +164 -0
- package/dist/personalisation.d.ts +21 -0
- package/dist/personalisation.js +8 -0
- package/dist/platform.d.ts +63 -0
- package/dist/platform.js +45 -0
- package/dist/portfolio.d.ts +163 -0
- package/dist/portfolio.js +28 -0
- package/dist/pos.d.ts +743 -0
- package/dist/pos.js +129 -0
- package/dist/procurement.d.ts +664 -0
- package/dist/procurement.js +157 -0
- package/dist/promotions.d.ts +169 -0
- package/dist/promotions.js +39 -0
- package/dist/publications.d.ts +583 -0
- package/dist/publications.js +164 -0
- package/dist/ranking.d.ts +43 -0
- package/dist/ranking.js +34 -0
- package/dist/ratings.d.ts +293 -0
- package/dist/ratings.js +109 -0
- package/dist/reactions.d.ts +123 -0
- package/dist/reactions.js +41 -0
- package/dist/recipient-orders.d.ts +294 -0
- package/dist/recipient-orders.js +73 -0
- package/dist/relationships.d.ts +18 -0
- package/dist/relationships.js +8 -0
- package/dist/reporting.d.ts +107 -0
- package/dist/reporting.js +56 -0
- package/dist/sales.d.ts +270 -0
- package/dist/sales.js +66 -0
- package/dist/shares.d.ts +105 -0
- package/dist/shares.js +27 -0
- package/dist/shop.d.ts +993 -0
- package/dist/shop.js +215 -0
- package/dist/shopping-assistant.d.ts +65 -0
- package/dist/shopping-assistant.js +14 -0
- package/dist/spaces.d.ts +422 -0
- package/dist/spaces.js +118 -0
- package/dist/stored-value.d.ts +754 -0
- package/dist/stored-value.js +177 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/vault.d.ts +290 -0
- package/dist/vault.js +55 -0
- package/dist/vertical-runtime.d.ts +17 -0
- package/dist/vertical-runtime.js +8 -0
- package/dist/vite/build-manifest-plugin.d.ts +42 -0
- package/dist/vite/build-manifest-plugin.js +42 -0
- package/dist/vite/first-paint-plugin.d.ts +26 -0
- package/dist/vite/first-paint-plugin.js +57 -0
- package/dist/wishlists.d.ts +591 -0
- package/dist/wishlists.js +188 -0
- package/dist/workbench.d.ts +114 -0
- package/dist/workbench.js +22 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +41 -0
- package/package.json +52 -4
- package/templates/extension-image.Dockerfile +38 -0
- package/templates/nuwah-vertical.yml +102 -0
- package/templates/vertical-app/.env.example +34 -0
- package/templates/vertical-app/README.md +108 -0
- package/templates/vertical-app/github/workflows/ci.yml +51 -0
- package/templates/vertical-app/gitignore +5 -0
- package/templates/vertical-app/index.html +12 -0
- package/templates/vertical-app/package.json +28 -0
- package/templates/vertical-app/src/App.tsx +64 -0
- package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
- package/templates/vertical-app/src/blueprint/screens.ts +15 -0
- package/templates/vertical-app/src/env.d.ts +18 -0
- package/templates/vertical-app/src/index.css +139 -0
- package/templates/vertical-app/src/lib/i18n.ts +5 -0
- package/templates/vertical-app/src/lib/iam.ts +19 -0
- package/templates/vertical-app/src/lib/operations.ts +93 -0
- package/templates/vertical-app/src/lib/router.ts +24 -0
- package/templates/vertical-app/src/lib/sdk.ts +21 -0
- package/templates/vertical-app/src/lib/theme.ts +18 -0
- package/templates/vertical-app/src/lib/words.ts +39 -0
- package/templates/vertical-app/src/main.tsx +25 -0
- package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
- package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
- package/templates/vertical-app/src/pages/Home.tsx +36 -0
- package/templates/vertical-app/tsconfig.json +24 -0
- package/templates/vertical-app/vite.config.ts +23 -0
- package/templates/vertical-ci.yml +192 -0
|
@@ -0,0 +1,1365 @@
|
|
|
1
|
+
import { type Http, type QueryValue } from './http.js';
|
|
2
|
+
import type { LaravelPaginator, ListQuery, Paginated, Translatable } from './types.js';
|
|
3
|
+
export * from './bookings-directory.js';
|
|
4
|
+
export * from './names.js';
|
|
5
|
+
export type ClientStatus = 'active' | 'inactive' | 'archived';
|
|
6
|
+
export type Gender = 'male' | 'female' | 'other' | 'prefer_not_to_say';
|
|
7
|
+
export interface BookingClient {
|
|
8
|
+
id: string;
|
|
9
|
+
tenant_id?: string;
|
|
10
|
+
platform_person_id: string | null;
|
|
11
|
+
last_booked_at?: string | null;
|
|
12
|
+
display_name: string;
|
|
13
|
+
email: string | null;
|
|
14
|
+
phone: string | null;
|
|
15
|
+
date_of_birth: string | null;
|
|
16
|
+
gender: Gender | null;
|
|
17
|
+
/** Preferred appointment length for this patient (minutes); null → use the session type's. */
|
|
18
|
+
default_duration_minutes: number | null;
|
|
19
|
+
status: ClientStatus;
|
|
20
|
+
notes: string | null;
|
|
21
|
+
created_at: string | null;
|
|
22
|
+
updated_at: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface CreateClientInput {
|
|
25
|
+
display_name: string;
|
|
26
|
+
email?: string | null;
|
|
27
|
+
phone?: string | null;
|
|
28
|
+
date_of_birth?: string | null;
|
|
29
|
+
gender?: Gender | null;
|
|
30
|
+
default_duration_minutes?: number | null;
|
|
31
|
+
platform_person_id?: string | null;
|
|
32
|
+
notes?: string | null;
|
|
33
|
+
}
|
|
34
|
+
export type UpdateClientInput = Partial<CreateClientInput> & {
|
|
35
|
+
status?: ClientStatus;
|
|
36
|
+
};
|
|
37
|
+
export interface ClientListQuery extends ListQuery {
|
|
38
|
+
search?: string;
|
|
39
|
+
status?: ClientStatus;
|
|
40
|
+
}
|
|
41
|
+
/** How a practitioner is engaged by the clinic. Null = unspecified. */
|
|
42
|
+
export type PractitionerEmploymentType = 'full_time' | 'part_time' | 'contractor';
|
|
43
|
+
export interface BookingPractitioner {
|
|
44
|
+
id: string;
|
|
45
|
+
tenant_id?: string;
|
|
46
|
+
platform_person_id: string | null;
|
|
47
|
+
display_name: string;
|
|
48
|
+
email: string | null;
|
|
49
|
+
phone: string | null;
|
|
50
|
+
specialty: string | null;
|
|
51
|
+
employment_type: PractitionerEmploymentType | null;
|
|
52
|
+
is_senior: boolean;
|
|
53
|
+
status: string;
|
|
54
|
+
notes: string | null;
|
|
55
|
+
created_at: string | null;
|
|
56
|
+
updated_at: string | null;
|
|
57
|
+
}
|
|
58
|
+
export interface SessionType {
|
|
59
|
+
id: string;
|
|
60
|
+
tenant_id?: string;
|
|
61
|
+
key: string;
|
|
62
|
+
name_en: string | null;
|
|
63
|
+
name_ar: string | null;
|
|
64
|
+
duration_minutes: number;
|
|
65
|
+
default_price: string | null;
|
|
66
|
+
color: string | null;
|
|
67
|
+
is_active: boolean;
|
|
68
|
+
capabilities: Record<string, unknown> | null;
|
|
69
|
+
/**
|
|
70
|
+
* The KINDS of place this booking type belongs in, as `spaces.type` values
|
|
71
|
+
* (`field`, `pool`, `lane`, `treatment`, …). `null` or `[]` means unrestricted —
|
|
72
|
+
* bookable anywhere, including with no place at all.
|
|
73
|
+
*
|
|
74
|
+
* Space TYPE rather than space id on purpose: a club adding a fourth pitch would
|
|
75
|
+
* otherwise have to reconfigure every booking type, and the restriction would not
|
|
76
|
+
* transfer to the next tenant. `SPACE_TYPES` is extensible per vertical, so this
|
|
77
|
+
* scales to verticals that do not exist yet.
|
|
78
|
+
*/
|
|
79
|
+
space_types: string[] | null;
|
|
80
|
+
created_at: string | null;
|
|
81
|
+
updated_at: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface CreateSessionTypeInput {
|
|
84
|
+
key: string;
|
|
85
|
+
name_en?: string | null;
|
|
86
|
+
name_ar?: string | null;
|
|
87
|
+
duration_minutes: number;
|
|
88
|
+
default_price?: number | null;
|
|
89
|
+
color?: string | null;
|
|
90
|
+
capabilities?: Record<string, unknown> | null;
|
|
91
|
+
/**
|
|
92
|
+
* The kinds of place this activity belongs in, as `spaces.type` values —
|
|
93
|
+
* `['pool', 'lane']` for a swimming lesson.
|
|
94
|
+
*
|
|
95
|
+
* Omit it, or send `null` or `[]`, to leave the type unrestricted; that is both
|
|
96
|
+
* the back-compatible answer and the right one for an activity that may happen
|
|
97
|
+
* anywhere (a venue hire). Space TYPES and never space ids, so the setting
|
|
98
|
+
* survives the tenant adding a fourth pitch and transfers to the next tenant.
|
|
99
|
+
*
|
|
100
|
+
* The server enforces the same rule on booking, so a client cannot widen it by
|
|
101
|
+
* leaving this out — see `sessionTypeAllowsSpaceType`.
|
|
102
|
+
*/
|
|
103
|
+
space_types?: string[] | null;
|
|
104
|
+
}
|
|
105
|
+
export type UpdateSessionTypeInput = Partial<Omit<CreateSessionTypeInput, 'key'>> & {
|
|
106
|
+
is_active?: boolean;
|
|
107
|
+
};
|
|
108
|
+
export interface BookingLocation {
|
|
109
|
+
id: string;
|
|
110
|
+
tenant_id?: string;
|
|
111
|
+
/** `{en,ar}` map (LocationResource). Absent on the raw nested-in-Session variant. */
|
|
112
|
+
name?: Translatable;
|
|
113
|
+
name_en: string | null;
|
|
114
|
+
name_ar: string | null;
|
|
115
|
+
code: string | null;
|
|
116
|
+
/** Free-form JSON blob (validated as an array/object). Absent on the nested variant. */
|
|
117
|
+
address?: Record<string, unknown> | null;
|
|
118
|
+
is_active: boolean;
|
|
119
|
+
created_at?: string | null;
|
|
120
|
+
updated_at?: string | null;
|
|
121
|
+
}
|
|
122
|
+
export interface CreateBookingLocationInput {
|
|
123
|
+
name_en?: string | null;
|
|
124
|
+
name_ar?: string | null;
|
|
125
|
+
code?: string | null;
|
|
126
|
+
address?: Record<string, unknown> | null;
|
|
127
|
+
is_active?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export type UpdateBookingLocationInput = Partial<CreateBookingLocationInput>;
|
|
130
|
+
export interface LocationListQuery extends ListQuery {
|
|
131
|
+
is_active?: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface LocationHours {
|
|
134
|
+
id: string;
|
|
135
|
+
tenant_id?: string;
|
|
136
|
+
location_id: string;
|
|
137
|
+
/** 0 = Sunday … 6 = Saturday. */
|
|
138
|
+
day_of_week: number;
|
|
139
|
+
/** `HH:MM` (24h) or `null`. */
|
|
140
|
+
open_time: string | null;
|
|
141
|
+
/** `HH:MM` (24h) or `null`. */
|
|
142
|
+
close_time: string | null;
|
|
143
|
+
is_open: boolean;
|
|
144
|
+
created_at: string | null;
|
|
145
|
+
updated_at: string | null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* One day in the PUT `hours[]` payload. `open_time` must be before `close_time`
|
|
149
|
+
* (`date_format:H:i`). `is_open` defaults to `true` server-side when omitted.
|
|
150
|
+
*/
|
|
151
|
+
export interface LocationHoursInput {
|
|
152
|
+
/** 0 = Sunday … 6 = Saturday. */
|
|
153
|
+
day_of_week: number;
|
|
154
|
+
/** `HH:MM` (24h). */
|
|
155
|
+
open_time?: string | null;
|
|
156
|
+
/** `HH:MM` (24h). */
|
|
157
|
+
close_time?: string | null;
|
|
158
|
+
is_open?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The code-level starter set of space types. It is NOT a DB enum — core validates
|
|
162
|
+
* against this list but new types can be introduced without a migration, so
|
|
163
|
+
* `SpaceType` stays an extensible string.
|
|
164
|
+
*
|
|
165
|
+
* MIRRORS `App\Modules\Bookings\Facilities\Models\Space::TYPES`, and that is a
|
|
166
|
+
* promise this list broke. Core carried thirteen types — the six sports ones added
|
|
167
|
+
* on top of the clinic set, with `SportsSpaceTypesTest` proving they validate — while
|
|
168
|
+
* this list still held the original seven. Everything a vertical app offers in a
|
|
169
|
+
* space-type picker comes from here, so a sports club creating a tennis court was
|
|
170
|
+
* shown Room, Jacuzzi, Gym, Pool, Assessment, Treatment, Other and had to pick
|
|
171
|
+
* "Other". Caught by creating one in the club UI, not by any test: both sides were
|
|
172
|
+
* internally consistent and nothing compares them.
|
|
173
|
+
*/
|
|
174
|
+
export declare const SPACE_TYPES: readonly ["room", "jacuzzi", "gym", "pool", "assessment", "treatment", "field", "court", "lane", "hall", "studio", "track", "other"];
|
|
175
|
+
export type SpaceType = (typeof SPACE_TYPES)[number] | (string & {});
|
|
176
|
+
export interface BookingSpace {
|
|
177
|
+
id: string;
|
|
178
|
+
tenant_id?: string;
|
|
179
|
+
location_id: string;
|
|
180
|
+
/** `{en,ar}` map (SpaceResource). Absent on the raw nested-in-Session variant. */
|
|
181
|
+
name?: Translatable;
|
|
182
|
+
name_en: string | null;
|
|
183
|
+
name_ar: string | null;
|
|
184
|
+
type: SpaceType;
|
|
185
|
+
capacity: number | null;
|
|
186
|
+
is_active: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Where this space's photo is served from, or NULL when none has been uploaded.
|
|
189
|
+
*
|
|
190
|
+
* Null, never a placeholder path — a club that has not photographed its pitches should
|
|
191
|
+
* see nothing rather than a grey camera icon pretending to be content. Screens decide
|
|
192
|
+
* what absence looks like.
|
|
193
|
+
*
|
|
194
|
+
* Absent entirely on the raw nested-in-Session variant, which does not load media.
|
|
195
|
+
*/
|
|
196
|
+
photo_url?: string | null;
|
|
197
|
+
/** Eager-loaded via `whenLoaded('location')` (on index/get) and nested in Sessions. */
|
|
198
|
+
location?: BookingLocation | null;
|
|
199
|
+
created_at?: string | null;
|
|
200
|
+
updated_at?: string | null;
|
|
201
|
+
}
|
|
202
|
+
export interface CreateSpaceInput {
|
|
203
|
+
location_id: string;
|
|
204
|
+
name_en?: string | null;
|
|
205
|
+
name_ar?: string | null;
|
|
206
|
+
type?: SpaceType;
|
|
207
|
+
capacity?: number | null;
|
|
208
|
+
is_active?: boolean;
|
|
209
|
+
}
|
|
210
|
+
export type UpdateSpaceInput = Partial<CreateSpaceInput>;
|
|
211
|
+
/**
|
|
212
|
+
* May this booking type be held in a place of this kind?
|
|
213
|
+
*
|
|
214
|
+
* The CLIENT-SIDE twin of core's `SessionType::allowsSpaceType()`, published here so the
|
|
215
|
+
* three verticals and any future one share one definition rather than each deriving the
|
|
216
|
+
* rule from `space_types` slightly differently. The server still enforces it on write —
|
|
217
|
+
* this exists so a form can grey out an impossible pairing instead of letting someone
|
|
218
|
+
* fill in the whole thing and collect a 422 on Save.
|
|
219
|
+
*
|
|
220
|
+
* A type naming no space types is unrestricted. A booking with no place is always allowed:
|
|
221
|
+
* the rule is about WHICH place, not about whether one is required.
|
|
222
|
+
*/
|
|
223
|
+
export declare function sessionTypeAllowsSpaceType(sessionType: Pick<SessionType, 'space_types'> | null | undefined, spaceType: string | null | undefined): boolean;
|
|
224
|
+
export interface SpaceListQuery extends ListQuery {
|
|
225
|
+
location_id?: string;
|
|
226
|
+
type?: SpaceType;
|
|
227
|
+
is_active?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Narrow to the places a given booking type may be held in — the mirror of
|
|
230
|
+
* `sessionTypes.list({ space_id })`, so a form can narrow in whichever order the
|
|
231
|
+
* person fills it. A type that restricts nothing leaves the list untouched.
|
|
232
|
+
*/
|
|
233
|
+
session_type_id?: string;
|
|
234
|
+
}
|
|
235
|
+
export type SessionStatus = 'booked' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled' | 'no_show';
|
|
236
|
+
export interface Session {
|
|
237
|
+
id: string;
|
|
238
|
+
tenant_id?: string;
|
|
239
|
+
client_id: string;
|
|
240
|
+
practitioner_id: string;
|
|
241
|
+
/** The squad this booking is for, when the tenant records one. */
|
|
242
|
+
team_id?: string | null;
|
|
243
|
+
session_type_id: string;
|
|
244
|
+
status: SessionStatus;
|
|
245
|
+
starts_at: string;
|
|
246
|
+
ends_at: string;
|
|
247
|
+
started_at: string | null;
|
|
248
|
+
duration_minutes: number;
|
|
249
|
+
notes: string | null;
|
|
250
|
+
cancellation_reason: string | null;
|
|
251
|
+
cancelled_at: string | null;
|
|
252
|
+
completed_at: string | null;
|
|
253
|
+
/** Stamped when the patient arrived (check-in / reinstate); after starts_at = late. */
|
|
254
|
+
checked_in_at?: string | null;
|
|
255
|
+
/** Stamped when marked a no-show. */
|
|
256
|
+
no_show_at?: string | null;
|
|
257
|
+
/** Stamped when a no-show was reinstated (patient showed up late). */
|
|
258
|
+
reinstated_at?: string | null;
|
|
259
|
+
fee_amount: string;
|
|
260
|
+
currency_code: string;
|
|
261
|
+
/** How the completed session is funded — stamped on completion. Drives the billing tab:
|
|
262
|
+
* self_pay → collect from the patient; package → pre-paid; insurance → billed as a claim. */
|
|
263
|
+
billing_context?: 'self_pay' | 'package' | 'insurance' | null;
|
|
264
|
+
series_id?: string | null;
|
|
265
|
+
space_id?: string | null;
|
|
266
|
+
created_at: string | null;
|
|
267
|
+
updated_at: string | null;
|
|
268
|
+
/** Eager-loaded on list (`client`, `practitioner`, `sessionType`, `space`+`space.location`). */
|
|
269
|
+
client?: Pick<BookingClient, 'id' | 'display_name'>;
|
|
270
|
+
practitioner?: Pick<BookingPractitioner, 'id' | 'display_name'>;
|
|
271
|
+
session_type?: Pick<SessionType, 'id' | 'name_en' | 'name_ar' | 'default_price'>;
|
|
272
|
+
/** Raw nested model (trimmed columns) with its own nested `location`. */
|
|
273
|
+
space?: BookingSpace | null;
|
|
274
|
+
}
|
|
275
|
+
/** One row of the per-client punctuality report (GET /reports/punctuality). */
|
|
276
|
+
export interface ClientPunctuality {
|
|
277
|
+
client_id: string;
|
|
278
|
+
client_name: string;
|
|
279
|
+
total_scheduled: number;
|
|
280
|
+
attended: number;
|
|
281
|
+
late_count: number;
|
|
282
|
+
no_show_count: number;
|
|
283
|
+
reinstated_count: number;
|
|
284
|
+
/** Share of attended visits the patient was late for (0–100). */
|
|
285
|
+
late_rate: number;
|
|
286
|
+
avg_late_minutes: number;
|
|
287
|
+
last_late_at: string | null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* One timeline event from a session's activity log
|
|
291
|
+
* (GET /api/bookings/sessions/{id}/history). Maps a spatie activitylog entry to a
|
|
292
|
+
* front-desk-friendly shape; `changes` carries the before/after diff when present.
|
|
293
|
+
*/
|
|
294
|
+
export interface SessionHistoryEvent {
|
|
295
|
+
action: string;
|
|
296
|
+
at: string;
|
|
297
|
+
causer_name: string | null;
|
|
298
|
+
changes?: Record<string, unknown>;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* One row of the front-desk activity feed (GET /api/bookings/reports/activity) —
|
|
302
|
+
* today's session changes across the desk. `undoable` marks rows whose action has a
|
|
303
|
+
* matching inverse correction (undo check-in / undo no-show).
|
|
304
|
+
*/
|
|
305
|
+
export interface FrontDeskActivity {
|
|
306
|
+
id: string;
|
|
307
|
+
action: string;
|
|
308
|
+
session_id: string;
|
|
309
|
+
patient_name: string;
|
|
310
|
+
at: string;
|
|
311
|
+
causer_name: string | null;
|
|
312
|
+
undoable: boolean;
|
|
313
|
+
}
|
|
314
|
+
export interface CreateSessionInput {
|
|
315
|
+
client_id: string;
|
|
316
|
+
/**
|
|
317
|
+
* Who is leading it — OPTIONAL, because most bookings in a sports club have nobody
|
|
318
|
+
* leading them: a team rents a pitch, a committee books the hall. Omit it and set
|
|
319
|
+
* `booking_type: 'resource'`; core then books the SPACE rather than a person's hour.
|
|
320
|
+
*
|
|
321
|
+
* Required in practice for a clinic, where the thing being sold is a practitioner's
|
|
322
|
+
* time — which is why this used to be mandatory.
|
|
323
|
+
*/
|
|
324
|
+
practitioner_id?: string;
|
|
325
|
+
/**
|
|
326
|
+
* `practitioner` books a person's time, `resource` books a place. Defaults to
|
|
327
|
+
* `practitioner` server-side, so a caller that omits both behaves as before.
|
|
328
|
+
*/
|
|
329
|
+
booking_type?: 'practitioner' | 'resource';
|
|
330
|
+
session_type_id: string;
|
|
331
|
+
starts_at: string;
|
|
332
|
+
duration_minutes?: number;
|
|
333
|
+
notes?: string | null;
|
|
334
|
+
space_id?: string | null;
|
|
335
|
+
/**
|
|
336
|
+
* Which SQUAD this booking is for — an opaque team id, or null for a booking that
|
|
337
|
+
* belongs to no squad (a rental, a meeting, a maintenance window).
|
|
338
|
+
*
|
|
339
|
+
* This is the attribution that makes an academy's hours and costs addable up. Core
|
|
340
|
+
* stores it without interpreting it: Bookings may not depend on Teams, so the meaning
|
|
341
|
+
* lives with whoever reads it, exactly as with `client_id` and a party.
|
|
342
|
+
*
|
|
343
|
+
* Only asked for when the tenant has turned `show_team_selector` on. A clinic never
|
|
344
|
+
* does, and the column defaults to off so it stays that way without anyone deciding.
|
|
345
|
+
*/
|
|
346
|
+
team_id?: string | null;
|
|
347
|
+
client_package_id?: string | null;
|
|
348
|
+
/** Override the session type's fee (≥ 0); omit to price from the session type. */
|
|
349
|
+
fee_amount?: number | string | null;
|
|
350
|
+
/** A membership plan whose discount prices this session. */
|
|
351
|
+
discount_plan_id?: string | null;
|
|
352
|
+
}
|
|
353
|
+
export interface UpdateSessionInput {
|
|
354
|
+
notes?: string | null;
|
|
355
|
+
starts_at?: string;
|
|
356
|
+
duration_minutes?: number;
|
|
357
|
+
fee_amount?: number;
|
|
358
|
+
currency_code?: string;
|
|
359
|
+
space_id?: string | null;
|
|
360
|
+
/** Re-attribute to another squad, or null to remove it from a squad's rollup. */
|
|
361
|
+
team_id?: string | null;
|
|
362
|
+
status?: 'completed';
|
|
363
|
+
}
|
|
364
|
+
export interface SessionListQuery extends ListQuery {
|
|
365
|
+
client_id?: string;
|
|
366
|
+
practitioner_id?: string;
|
|
367
|
+
space_id?: string;
|
|
368
|
+
team_id?: string;
|
|
369
|
+
location_id?: string;
|
|
370
|
+
status?: SessionStatus;
|
|
371
|
+
date?: string;
|
|
372
|
+
date_from?: string;
|
|
373
|
+
date_to?: string;
|
|
374
|
+
}
|
|
375
|
+
export interface ConflictCheckQuery {
|
|
376
|
+
/**
|
|
377
|
+
* Ask about a coach, a PLACE, or both — at least one. Either clashing is a clash, and
|
|
378
|
+
* the endpoint ORs them, so asking about both reports a conflict when EITHER is taken
|
|
379
|
+
* rather than only when one booking holds both.
|
|
380
|
+
*
|
|
381
|
+
* `practitioner_id` used to be the only option and was required, so a booking with no
|
|
382
|
+
* coach — most of a club's diary — could not ask the question at all and the user
|
|
383
|
+
* learned about the clash on Save.
|
|
384
|
+
*/
|
|
385
|
+
practitioner_id?: string;
|
|
386
|
+
space_id?: string;
|
|
387
|
+
scheduled_at: string;
|
|
388
|
+
duration_minutes: number;
|
|
389
|
+
exclude_session_id?: string | null;
|
|
390
|
+
[key: string]: QueryValue;
|
|
391
|
+
}
|
|
392
|
+
export interface ConflictCheckResult {
|
|
393
|
+
has_conflict: boolean;
|
|
394
|
+
conflicting_sessions: Array<Pick<Session, 'id' | 'starts_at' | 'ends_at' | 'status' | 'practitioner_id'>>;
|
|
395
|
+
}
|
|
396
|
+
/** `client.sessions()` returns the client plus a nested paginated session list. */
|
|
397
|
+
export interface ClientSessionsResult {
|
|
398
|
+
client: BookingClient;
|
|
399
|
+
sessions: Paginated<Session>;
|
|
400
|
+
}
|
|
401
|
+
export type AvailabilityStatus = 'free' | 'busy' | 'full' | 'off';
|
|
402
|
+
export interface ResourceAvailability {
|
|
403
|
+
id: string;
|
|
404
|
+
status: AvailabilityStatus;
|
|
405
|
+
next_free_at: string | null;
|
|
406
|
+
note: string | null;
|
|
407
|
+
}
|
|
408
|
+
export interface SlotAvailability {
|
|
409
|
+
date: string;
|
|
410
|
+
start: string;
|
|
411
|
+
duration: number;
|
|
412
|
+
practitioners: ResourceAvailability[];
|
|
413
|
+
spaces: ResourceAvailability[];
|
|
414
|
+
}
|
|
415
|
+
export interface AvailabilityQuery {
|
|
416
|
+
/** `YYYY-MM-DD`. */
|
|
417
|
+
date: string;
|
|
418
|
+
/** `HH:mm` (24h). */
|
|
419
|
+
start: string;
|
|
420
|
+
/** Slot length in minutes (5–600). */
|
|
421
|
+
duration: number;
|
|
422
|
+
[param: string]: string | number | null | undefined;
|
|
423
|
+
}
|
|
424
|
+
export interface Insurer {
|
|
425
|
+
id: string;
|
|
426
|
+
tenant_id?: string;
|
|
427
|
+
name_en: string;
|
|
428
|
+
name_ar: string;
|
|
429
|
+
code: string;
|
|
430
|
+
contact_email: string | null;
|
|
431
|
+
contact_phone: string | null;
|
|
432
|
+
claim_submission_format: string;
|
|
433
|
+
is_active: boolean;
|
|
434
|
+
notes: string | null;
|
|
435
|
+
deleted_at: string | null;
|
|
436
|
+
created_at: string;
|
|
437
|
+
updated_at: string;
|
|
438
|
+
}
|
|
439
|
+
export interface CreateInsurerInput {
|
|
440
|
+
name_en: string;
|
|
441
|
+
name_ar: string;
|
|
442
|
+
code: string;
|
|
443
|
+
contact_email?: string | null;
|
|
444
|
+
contact_phone?: string | null;
|
|
445
|
+
claim_submission_format?: string;
|
|
446
|
+
is_active?: boolean;
|
|
447
|
+
notes?: string | null;
|
|
448
|
+
}
|
|
449
|
+
export type UpdateInsurerInput = Partial<CreateInsurerInput>;
|
|
450
|
+
export interface InsurerListQuery extends ListQuery {
|
|
451
|
+
is_active?: boolean;
|
|
452
|
+
}
|
|
453
|
+
export type CoverageStrategy = 'fixed_amount' | 'percentage' | 'copay' | 'capitation';
|
|
454
|
+
export interface InsurancePlan {
|
|
455
|
+
id: string;
|
|
456
|
+
tenant_id?: string;
|
|
457
|
+
insurer_id: string;
|
|
458
|
+
name_en: string | null;
|
|
459
|
+
name_ar: string | null;
|
|
460
|
+
code: string;
|
|
461
|
+
coverage_strategy: CoverageStrategy;
|
|
462
|
+
coverage_value: string | null;
|
|
463
|
+
copay_amount: string | null;
|
|
464
|
+
max_annual_benefit: string | null;
|
|
465
|
+
requires_preauthorization: boolean;
|
|
466
|
+
is_active: boolean;
|
|
467
|
+
notes: string | null;
|
|
468
|
+
created_at: string;
|
|
469
|
+
updated_at: string;
|
|
470
|
+
/** Present on `get` (eager-loaded). */
|
|
471
|
+
insurer?: Insurer;
|
|
472
|
+
}
|
|
473
|
+
export interface CreateInsurancePlanInput {
|
|
474
|
+
insurer_id: string;
|
|
475
|
+
name_en?: string | null;
|
|
476
|
+
name_ar?: string | null;
|
|
477
|
+
code: string;
|
|
478
|
+
coverage_strategy: CoverageStrategy;
|
|
479
|
+
coverage_value?: number | string | null;
|
|
480
|
+
copay_amount?: number | string | null;
|
|
481
|
+
max_annual_benefit?: number | string | null;
|
|
482
|
+
requires_preauthorization?: boolean;
|
|
483
|
+
is_active?: boolean;
|
|
484
|
+
notes?: string | null;
|
|
485
|
+
}
|
|
486
|
+
export type UpdateInsurancePlanInput = Partial<CreateInsurancePlanInput>;
|
|
487
|
+
export interface InsurancePlanListQuery extends ListQuery {
|
|
488
|
+
insurer_id?: string;
|
|
489
|
+
coverage_strategy?: CoverageStrategy;
|
|
490
|
+
is_active?: boolean;
|
|
491
|
+
}
|
|
492
|
+
export interface InsurancePolicy {
|
|
493
|
+
id: string;
|
|
494
|
+
tenant_id?: string;
|
|
495
|
+
client_id: string;
|
|
496
|
+
insurance_plan_id: string;
|
|
497
|
+
policy_number: string;
|
|
498
|
+
member_id: string | null;
|
|
499
|
+
group_number: string | null;
|
|
500
|
+
effective_date: string;
|
|
501
|
+
expiry_date: string | null;
|
|
502
|
+
is_primary: boolean;
|
|
503
|
+
is_active: boolean;
|
|
504
|
+
notes: string | null;
|
|
505
|
+
created_at: string;
|
|
506
|
+
updated_at: string;
|
|
507
|
+
/** Present on `get` (eager-loaded). */
|
|
508
|
+
insurancePlan?: InsurancePlan;
|
|
509
|
+
/**
|
|
510
|
+
* The client's display name — present on `list` rows (batched server-side, one query per
|
|
511
|
+
* page), null when the client record no longer exists. Absent on `get`/`create`/`update`.
|
|
512
|
+
*/
|
|
513
|
+
client_name?: string | null;
|
|
514
|
+
}
|
|
515
|
+
export interface CreateInsurancePolicyInput {
|
|
516
|
+
client_id: string;
|
|
517
|
+
insurance_plan_id: string;
|
|
518
|
+
policy_number: string;
|
|
519
|
+
effective_date: string;
|
|
520
|
+
member_id?: string | null;
|
|
521
|
+
group_number?: string | null;
|
|
522
|
+
expiry_date?: string | null;
|
|
523
|
+
is_primary?: boolean;
|
|
524
|
+
is_active?: boolean;
|
|
525
|
+
notes?: string | null;
|
|
526
|
+
}
|
|
527
|
+
/** `client_id` is NOT updatable. */
|
|
528
|
+
export type UpdateInsurancePolicyInput = Partial<Omit<CreateInsurancePolicyInput, 'client_id'>>;
|
|
529
|
+
export interface InsurancePolicyListQuery extends ListQuery {
|
|
530
|
+
client_id?: string;
|
|
531
|
+
is_active?: boolean;
|
|
532
|
+
}
|
|
533
|
+
/** A raw bilingual `{en,ar}` JSON map (nullable, partial) as stored on the profile. */
|
|
534
|
+
export interface LocalizedText {
|
|
535
|
+
en?: string | null;
|
|
536
|
+
ar?: string | null;
|
|
537
|
+
}
|
|
538
|
+
export interface ClinicProfileTheme {
|
|
539
|
+
primary?: string | null;
|
|
540
|
+
mode?: 'dark' | 'light' | null;
|
|
541
|
+
}
|
|
542
|
+
export interface ClinicProfileContact {
|
|
543
|
+
phone?: string | null;
|
|
544
|
+
whatsapp?: string | null;
|
|
545
|
+
email?: string | null;
|
|
546
|
+
address?: string | null;
|
|
547
|
+
map_lat?: number | null;
|
|
548
|
+
map_lng?: number | null;
|
|
549
|
+
google_maps_url?: string | null;
|
|
550
|
+
}
|
|
551
|
+
export interface ClinicProfileSocial {
|
|
552
|
+
instagram?: string | null;
|
|
553
|
+
facebook?: string | null;
|
|
554
|
+
tiktok?: string | null;
|
|
555
|
+
website?: string | null;
|
|
556
|
+
}
|
|
557
|
+
/** A marketing "service" card — optionally linked to a real bookable `session_type_id`. */
|
|
558
|
+
export interface ClinicProfileService {
|
|
559
|
+
title?: LocalizedText | null;
|
|
560
|
+
description?: string | null;
|
|
561
|
+
session_type_id?: string | null;
|
|
562
|
+
price?: string | number | null;
|
|
563
|
+
}
|
|
564
|
+
/** A marketing "team" card — optionally linked to a real `practitioner_id`. */
|
|
565
|
+
export interface ClinicProfileTeamMember {
|
|
566
|
+
practitioner_id?: string | null;
|
|
567
|
+
name?: string | null;
|
|
568
|
+
role?: string | null;
|
|
569
|
+
bio?: string | null;
|
|
570
|
+
photo_url?: string | null;
|
|
571
|
+
}
|
|
572
|
+
export interface ClinicProfileTestimonial {
|
|
573
|
+
name?: string | null;
|
|
574
|
+
quote?: string | null;
|
|
575
|
+
rating?: number | null;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* The full ADMIN view of the clinic landing profile (ClinicProfileResource) — every
|
|
579
|
+
* editable field plus the `is_published` flag. `hours` and `sections_enabled` are
|
|
580
|
+
* free-form JSON maps the FE owns the schema of.
|
|
581
|
+
*/
|
|
582
|
+
export interface ClinicProfile {
|
|
583
|
+
tenant_id?: string;
|
|
584
|
+
display_name: LocalizedText | null;
|
|
585
|
+
tagline: LocalizedText | null;
|
|
586
|
+
about: LocalizedText | null;
|
|
587
|
+
logo_url: string | null;
|
|
588
|
+
cover_image_url: string | null;
|
|
589
|
+
gallery: string[];
|
|
590
|
+
theme: ClinicProfileTheme | null;
|
|
591
|
+
contact: ClinicProfileContact | null;
|
|
592
|
+
hours: Record<string, unknown> | null;
|
|
593
|
+
services: ClinicProfileService[];
|
|
594
|
+
team: ClinicProfileTeamMember[];
|
|
595
|
+
testimonials: ClinicProfileTestimonial[];
|
|
596
|
+
social: ClinicProfileSocial | null;
|
|
597
|
+
sections_enabled: Record<string, boolean> | null;
|
|
598
|
+
is_published: boolean;
|
|
599
|
+
updated_at: string | null;
|
|
600
|
+
}
|
|
601
|
+
/** PUT body — a partial patch (every field is `sometimes` server-side). */
|
|
602
|
+
export interface ClinicProfileInput {
|
|
603
|
+
display_name?: LocalizedText | null;
|
|
604
|
+
tagline?: LocalizedText | null;
|
|
605
|
+
about?: LocalizedText | null;
|
|
606
|
+
logo_url?: string | null;
|
|
607
|
+
cover_image_url?: string | null;
|
|
608
|
+
gallery?: string[] | null;
|
|
609
|
+
theme?: ClinicProfileTheme | null;
|
|
610
|
+
contact?: ClinicProfileContact | null;
|
|
611
|
+
hours?: Record<string, unknown> | null;
|
|
612
|
+
services?: ClinicProfileService[] | null;
|
|
613
|
+
team?: ClinicProfileTeamMember[] | null;
|
|
614
|
+
testimonials?: ClinicProfileTestimonial[] | null;
|
|
615
|
+
social?: ClinicProfileSocial | null;
|
|
616
|
+
sections_enabled?: Record<string, boolean> | null;
|
|
617
|
+
is_published?: boolean;
|
|
618
|
+
}
|
|
619
|
+
export type ConfirmationMode = 'auto_confirm' | 'require_confirmation';
|
|
620
|
+
export interface BookingSettings {
|
|
621
|
+
tenant_id?: string;
|
|
622
|
+
public_booking_enabled: boolean;
|
|
623
|
+
confirmation_mode: ConfirmationMode;
|
|
624
|
+
min_lead_time_minutes: number;
|
|
625
|
+
max_advance_days: number;
|
|
626
|
+
/** `null` ⇒ ALL active session types are bookable. */
|
|
627
|
+
bookable_session_type_ids: string[] | null;
|
|
628
|
+
/** `null` ⇒ ALL active practitioners are bookable. */
|
|
629
|
+
bookable_practitioner_ids: string[] | null;
|
|
630
|
+
slot_granularity_minutes: number;
|
|
631
|
+
buffer_minutes: number;
|
|
632
|
+
/** Which selectors the public widget renders. */
|
|
633
|
+
show_service_selector: boolean;
|
|
634
|
+
show_practitioner_selector: boolean;
|
|
635
|
+
show_space_selector: boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Whether the booking form asks WHICH SQUAD a booking is for.
|
|
638
|
+
*
|
|
639
|
+
* Unlike its three siblings this is NOT read as default-on. Nothing on the platform
|
|
640
|
+
* showed a squad picker before it existed, so a null means OFF — read it as `=== true`.
|
|
641
|
+
* A clinic that never opens the setting keeps the form it always had.
|
|
642
|
+
*/
|
|
643
|
+
show_team_selector: boolean;
|
|
644
|
+
bookable_team_ids?: string[] | null;
|
|
645
|
+
default_team_id?: string | null;
|
|
646
|
+
/** Forced choice used when the matching selector is hidden. `null` ⇒ "Any" / no default. */
|
|
647
|
+
default_session_type_id: string | null;
|
|
648
|
+
default_practitioner_id: string | null;
|
|
649
|
+
default_space_id: string | null;
|
|
650
|
+
updated_at: string | null;
|
|
651
|
+
}
|
|
652
|
+
/** PUT body — a partial patch (every field is `sometimes` server-side). */
|
|
653
|
+
export interface BookingSettingsInput {
|
|
654
|
+
public_booking_enabled?: boolean;
|
|
655
|
+
confirmation_mode?: ConfirmationMode;
|
|
656
|
+
min_lead_time_minutes?: number;
|
|
657
|
+
max_advance_days?: number;
|
|
658
|
+
bookable_session_type_ids?: string[] | null;
|
|
659
|
+
bookable_practitioner_ids?: string[] | null;
|
|
660
|
+
slot_granularity_minutes?: number;
|
|
661
|
+
buffer_minutes?: number;
|
|
662
|
+
show_service_selector?: boolean;
|
|
663
|
+
show_practitioner_selector?: boolean;
|
|
664
|
+
show_space_selector?: boolean;
|
|
665
|
+
show_team_selector?: boolean;
|
|
666
|
+
bookable_team_ids?: string[] | null;
|
|
667
|
+
default_team_id?: string | null;
|
|
668
|
+
default_session_type_id?: string | null;
|
|
669
|
+
default_practitioner_id?: string | null;
|
|
670
|
+
default_space_id?: string | null;
|
|
671
|
+
}
|
|
672
|
+
export type RatingRole = 'client' | 'practitioner';
|
|
673
|
+
/** One side of one session's rating (GET /ratings). Pagination counts ratings, not rows. */
|
|
674
|
+
export interface RatingRow {
|
|
675
|
+
/** `${session_id}:${role}`. */
|
|
676
|
+
id: string;
|
|
677
|
+
session_id: string;
|
|
678
|
+
/** The rated session's start time (ISO-8601), when the session is still loadable. */
|
|
679
|
+
session_date: string | null;
|
|
680
|
+
role: RatingRole;
|
|
681
|
+
/** 1–5, or null while the blind reveal withholds it from the caller. */
|
|
682
|
+
stars: number | null;
|
|
683
|
+
comment: string | null;
|
|
684
|
+
/** True when this side has rated but its answer is hidden from the caller. */
|
|
685
|
+
withheld: boolean;
|
|
686
|
+
/** When this side rated (ISO-8601). */
|
|
687
|
+
created_at: string | null;
|
|
688
|
+
}
|
|
689
|
+
/** A row whose stars the caller may see. */
|
|
690
|
+
export type RevealedRatingRow = RatingRow & {
|
|
691
|
+
stars: number;
|
|
692
|
+
withheld: false;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* Whether a rating row's stars are visible to the caller. Averages, distributions and trends
|
|
696
|
+
* are computed over revealed rows only: a withheld row has rated but carries no stars, and
|
|
697
|
+
* counting it as zero would drag every average down until the other side answers.
|
|
698
|
+
*/
|
|
699
|
+
export declare function isRevealedRating(row: RatingRow): row is RevealedRatingRow;
|
|
700
|
+
export interface RatingListQuery extends ListQuery {
|
|
701
|
+
/** Restrict to one side of the rating (`client` or `practitioner`). */
|
|
702
|
+
role?: RatingRole;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* One session's rating as the caller may see it (GET /sessions/{id}/rating, and the body
|
|
706
|
+
* returned by POST .../rate). A completed session nobody has rated yet answers with both sides
|
|
707
|
+
* unrated and `id: null`; the endpoint 404s only when the session cannot be rated yet.
|
|
708
|
+
*/
|
|
709
|
+
export interface SessionRatingRecord {
|
|
710
|
+
/** Null until somebody has rated. */
|
|
711
|
+
id: string | null;
|
|
712
|
+
session_id: string;
|
|
713
|
+
client_id: string;
|
|
714
|
+
practitioner_id: string | null;
|
|
715
|
+
client_score: number | null;
|
|
716
|
+
client_comment: string | null;
|
|
717
|
+
client_rated_at: string | null;
|
|
718
|
+
client_rated: boolean;
|
|
719
|
+
client_withheld: boolean;
|
|
720
|
+
practitioner_score: number | null;
|
|
721
|
+
practitioner_comment: string | null;
|
|
722
|
+
practitioner_rated_at: string | null;
|
|
723
|
+
practitioner_rated: boolean;
|
|
724
|
+
practitioner_withheld: boolean;
|
|
725
|
+
/** True once nothing is withheld from anyone. */
|
|
726
|
+
revealed: boolean;
|
|
727
|
+
/** The side the caller may rate, or null for staff onlookers. */
|
|
728
|
+
viewer_role: RatingRole | null;
|
|
729
|
+
/** When rating closes (ISO-8601), or null when the tenant set no window. */
|
|
730
|
+
closes_at: string | null;
|
|
731
|
+
}
|
|
732
|
+
/** POST /sessions/{id}/rate body — rates the CALLER's own side; the server derives which. */
|
|
733
|
+
export interface RateSessionInput {
|
|
734
|
+
/** 1–5. */
|
|
735
|
+
score: number;
|
|
736
|
+
comment?: string | null;
|
|
737
|
+
}
|
|
738
|
+
/** Mirrors core `WaitlistEntry::STATUSES` — `notified` is set when a freed slot was offered. */
|
|
739
|
+
export type WaitlistStatus = 'waiting' | 'notified' | 'scheduled' | 'removed';
|
|
740
|
+
export interface WaitlistEntry {
|
|
741
|
+
id: string;
|
|
742
|
+
tenant_id?: string;
|
|
743
|
+
/** Name of the person waiting (a prospect not yet a Bookings client). */
|
|
744
|
+
patient_name: string;
|
|
745
|
+
phone: string | null;
|
|
746
|
+
client_id: string | null;
|
|
747
|
+
practitioner_id: string | null;
|
|
748
|
+
session_type_id: string | null;
|
|
749
|
+
/** Higher = more urgent; drives ordering alongside age. */
|
|
750
|
+
priority: number;
|
|
751
|
+
notes: string | null;
|
|
752
|
+
status: WaitlistStatus;
|
|
753
|
+
created_at: string;
|
|
754
|
+
updated_at: string;
|
|
755
|
+
}
|
|
756
|
+
export interface WaitlistInput {
|
|
757
|
+
patient_name: string;
|
|
758
|
+
phone?: string | null;
|
|
759
|
+
client_id?: string | null;
|
|
760
|
+
practitioner_id?: string | null;
|
|
761
|
+
session_type_id?: string | null;
|
|
762
|
+
/** 0–1000. `sometimes` but NOT nullable in core — omit it rather than sending null. */
|
|
763
|
+
priority?: number;
|
|
764
|
+
notes?: string | null;
|
|
765
|
+
}
|
|
766
|
+
export interface InsuranceAuthorization {
|
|
767
|
+
id: string;
|
|
768
|
+
insurance_policy_id: string;
|
|
769
|
+
client_id: string;
|
|
770
|
+
authorized_sessions: number;
|
|
771
|
+
sessions_used: number;
|
|
772
|
+
valid_from: string;
|
|
773
|
+
valid_until: string | null;
|
|
774
|
+
recert_at_session: number | null;
|
|
775
|
+
status: 'active' | 'exhausted' | 'expired';
|
|
776
|
+
notes: string | null;
|
|
777
|
+
created_at: string;
|
|
778
|
+
}
|
|
779
|
+
export interface CreateInsuranceAuthorizationInput {
|
|
780
|
+
insurance_policy_id: string;
|
|
781
|
+
client_id: string;
|
|
782
|
+
authorized_sessions: number;
|
|
783
|
+
valid_from: string;
|
|
784
|
+
valid_until?: string | null;
|
|
785
|
+
recert_at_session?: number | null;
|
|
786
|
+
notes?: string | null;
|
|
787
|
+
}
|
|
788
|
+
/** How a late-cancel / no-show fee is computed. */
|
|
789
|
+
export type FeeMode = 'none' | 'fixed' | 'percent';
|
|
790
|
+
/** How the patient notice window is enforced (staff are never restricted by it). */
|
|
791
|
+
export type NoticeEnforcement = 'advisory' | 'blocked';
|
|
792
|
+
/**
|
|
793
|
+
* Per-tenant reschedule & cancellation policy. Mirrors the core ReschedulePolicy value
|
|
794
|
+
* object exactly; every field round-trips through GET/PUT `/api/bookings/reschedule-policy`.
|
|
795
|
+
*/
|
|
796
|
+
export interface ReschedulePolicy {
|
|
797
|
+
/** May a patient reschedule/cancel their own appointment at all (clinic opts in). */
|
|
798
|
+
patient_self_service: boolean;
|
|
799
|
+
/** When a patient self-serves, does the change need staff approval first. */
|
|
800
|
+
patient_requires_approval: boolean;
|
|
801
|
+
/** Hours of notice a patient must give; 0 means no window. */
|
|
802
|
+
notice_window_hours: number;
|
|
803
|
+
/** Advisory (warn only) vs blocked (refuse) inside the notice window. */
|
|
804
|
+
notice_enforcement: NoticeEnforcement;
|
|
805
|
+
/** Cap on patient self-reschedules of one session; null = unlimited. */
|
|
806
|
+
max_patient_reschedules_per_session: number | null;
|
|
807
|
+
/** Fee basis for a late cancellation. */
|
|
808
|
+
late_cancel_fee: FeeMode;
|
|
809
|
+
/** Late-cancel fee amount (flat for `fixed`, percentage for `percent`), 4-dp string. */
|
|
810
|
+
late_cancel_fee_amount: string;
|
|
811
|
+
/** Fee basis for a no-show. */
|
|
812
|
+
no_show_fee: FeeMode;
|
|
813
|
+
/** No-show fee amount (flat for `fixed`, percentage for `percent`), 4-dp string. */
|
|
814
|
+
no_show_fee_amount: string;
|
|
815
|
+
}
|
|
816
|
+
/** Who to notify when a patient confirms their appointment. */
|
|
817
|
+
export type NotifyTarget = 'none' | 'practitioner' | 'both';
|
|
818
|
+
/** Per-tenant appointment-confirmation rules (GET/PUT /api/bookings/confirmation-policy). */
|
|
819
|
+
export interface ConfirmationPolicy {
|
|
820
|
+
/** Whether the front desk runs confirmation calls at all (clinic opts in). */
|
|
821
|
+
require_confirmation: boolean;
|
|
822
|
+
/** How many days before a session the call ladder opens. */
|
|
823
|
+
call_lead_days: number;
|
|
824
|
+
/** Attempt ceiling before an appointment is flagged at-risk. */
|
|
825
|
+
max_attempts: number;
|
|
826
|
+
/** Number of unanswered attempts after which the appointment is at-risk. */
|
|
827
|
+
at_risk_after_attempts: number;
|
|
828
|
+
/** Who to notify when the patient confirms. */
|
|
829
|
+
notify_on_confirm: NotifyTarget;
|
|
830
|
+
}
|
|
831
|
+
/** The confirmation-call ladder state of an appointment. */
|
|
832
|
+
export type ConfirmationStatus = 'to_call' | 'no_answer' | 'at_risk' | 'confirmed' | 'declined';
|
|
833
|
+
/** A single front-desk call outcome. */
|
|
834
|
+
export type ConfirmationOutcome = 'confirmed' | 'no_answer' | 'left_message' | 'declined';
|
|
835
|
+
/** The confirmation state carried on a call-list appointment (null until a ladder is opened). */
|
|
836
|
+
export interface AppointmentConfirmationState {
|
|
837
|
+
id: string;
|
|
838
|
+
status: ConfirmationStatus;
|
|
839
|
+
attempt_count: number;
|
|
840
|
+
outcome: ConfirmationOutcome | null;
|
|
841
|
+
last_attempt_at: string | null;
|
|
842
|
+
confirmed_at: string | null;
|
|
843
|
+
notes: string | null;
|
|
844
|
+
}
|
|
845
|
+
/** One appointment on the front-desk confirmation call list for a day. */
|
|
846
|
+
export interface ConfirmationCallListRow {
|
|
847
|
+
session_id: string;
|
|
848
|
+
status: string;
|
|
849
|
+
starts_at: string | null;
|
|
850
|
+
ends_at: string | null;
|
|
851
|
+
patient: {
|
|
852
|
+
name: string;
|
|
853
|
+
phone: string | null;
|
|
854
|
+
};
|
|
855
|
+
practitioner: {
|
|
856
|
+
id: string;
|
|
857
|
+
name: string;
|
|
858
|
+
} | null;
|
|
859
|
+
session_type: {
|
|
860
|
+
name_en: string | null;
|
|
861
|
+
name_ar: string | null;
|
|
862
|
+
} | null;
|
|
863
|
+
confirmation: AppointmentConfirmationState | null;
|
|
864
|
+
}
|
|
865
|
+
export declare function createBookingsNamespace(http: Http): {
|
|
866
|
+
/**
|
|
867
|
+
* @deprecated `/api/bookings/clients` is a compatibility shim over the party directory
|
|
868
|
+
* and carries a `Sunset` header. Use {@link BookingsNamespace.directory}`.clients` — the
|
|
869
|
+
* same {@link BookingClient} rows, read from `/api/v1/party/parties`. Only `sessions()`
|
|
870
|
+
* has no successor and stays here.
|
|
871
|
+
*/
|
|
872
|
+
clients: {
|
|
873
|
+
/** GET /api/bookings/clients */
|
|
874
|
+
list: (query?: ClientListQuery) => Promise<Paginated<BookingClient>>;
|
|
875
|
+
/** GET /api/bookings/clients/{id} */
|
|
876
|
+
get: (id: string) => Promise<BookingClient>;
|
|
877
|
+
/** POST /api/bookings/clients */
|
|
878
|
+
create: (input: CreateClientInput) => Promise<BookingClient>;
|
|
879
|
+
/** PATCH /api/bookings/clients/{id} */
|
|
880
|
+
update: (id: string, input: UpdateClientInput) => Promise<BookingClient>;
|
|
881
|
+
/** GET /api/bookings/clients/{id}/sessions */
|
|
882
|
+
sessions: (id: string, query?: {
|
|
883
|
+
per_page?: number;
|
|
884
|
+
}) => Promise<ClientSessionsResult>;
|
|
885
|
+
};
|
|
886
|
+
/**
|
|
887
|
+
* Clients and practitioners read and written through the PARTY DIRECTORY
|
|
888
|
+
* (`/api/v1/party/parties`), answered in the shim's flat shapes — the way off the
|
|
889
|
+
* deprecated `clients` / `practitioners` shims above without changing what a screen
|
|
890
|
+
* renders. Read the module note in `bookings-directory.ts` before moving a screen: the
|
|
891
|
+
* directory guards with `party.view` / `party.manage`, and `update()` is two requests.
|
|
892
|
+
*/
|
|
893
|
+
directory: {
|
|
894
|
+
clients: {
|
|
895
|
+
list: (query?: ClientListQuery) => Promise<Paginated<BookingClient>>;
|
|
896
|
+
get: (partyId: string) => Promise<BookingClient>;
|
|
897
|
+
create: (input: CreateClientInput) => Promise<BookingClient>;
|
|
898
|
+
update: (partyId: string, input: import("./bookings-directory.js").DirectoryClientUpdate) => Promise<BookingClient>;
|
|
899
|
+
};
|
|
900
|
+
practitioners: {
|
|
901
|
+
list: (query?: import("./bookings-directory.js").DirectoryPractitionerListQuery) => Promise<Paginated<BookingPractitioner>>;
|
|
902
|
+
create: (input: import("./bookings-extra.js").CreatePractitionerInput) => Promise<BookingPractitioner>;
|
|
903
|
+
get: (partyId: string) => Promise<BookingPractitioner>;
|
|
904
|
+
update: (partyId: string, input: import("./bookings-directory.js").DirectoryPractitionerUpdate) => Promise<BookingPractitioner>;
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
/**
|
|
908
|
+
* @deprecated `/api/bookings/practitioners` is a compatibility shim over the party
|
|
909
|
+
* directory and carries a `Sunset` header. Use {@link BookingsNamespace.directory}
|
|
910
|
+
* `.practitioners` — the same {@link BookingPractitioner} rows.
|
|
911
|
+
*/
|
|
912
|
+
practitioners: {
|
|
913
|
+
/** GET /api/bookings/practitioners */
|
|
914
|
+
list: (query?: ListQuery) => Promise<Paginated<BookingPractitioner>>;
|
|
915
|
+
/** GET /api/bookings/practitioners/{id} */
|
|
916
|
+
get: (id: string) => Promise<BookingPractitioner>;
|
|
917
|
+
};
|
|
918
|
+
sessionTypes: {
|
|
919
|
+
/** GET /api/bookings/session-types (pass `active_only` to filter). */
|
|
920
|
+
/**
|
|
921
|
+
* `space_id` narrows to the types bookable in that place. The rule lives on
|
|
922
|
+
* the server so every client — this SDK, the public widget, mobile, a
|
|
923
|
+
* mini-app — gets the same answer as the validation that enforces it on write.
|
|
924
|
+
*/
|
|
925
|
+
list: (query?: {
|
|
926
|
+
active_only?: boolean;
|
|
927
|
+
space_id?: string;
|
|
928
|
+
}) => Promise<{
|
|
929
|
+
data: SessionType[];
|
|
930
|
+
}>;
|
|
931
|
+
/** POST /api/bookings/session-types */
|
|
932
|
+
create: (input: CreateSessionTypeInput) => Promise<SessionType>;
|
|
933
|
+
/** PATCH /api/bookings/session-types/{id} */
|
|
934
|
+
update: (id: string, input: UpdateSessionTypeInput) => Promise<SessionType>;
|
|
935
|
+
/** DELETE /api/bookings/session-types/{id} */
|
|
936
|
+
remove: (id: string) => Promise<void>;
|
|
937
|
+
};
|
|
938
|
+
locations: {
|
|
939
|
+
/** GET /api/bookings/locations — plain resource collection `{ data }` (no meta). */
|
|
940
|
+
list: (query?: LocationListQuery) => Promise<{
|
|
941
|
+
data: BookingLocation[];
|
|
942
|
+
}>;
|
|
943
|
+
/** GET /api/bookings/locations/{id} */
|
|
944
|
+
get: (id: string) => Promise<{
|
|
945
|
+
data: BookingLocation;
|
|
946
|
+
}>;
|
|
947
|
+
/** POST /api/bookings/locations — 201, `{ data }`. */
|
|
948
|
+
create: (input: CreateBookingLocationInput) => Promise<{
|
|
949
|
+
data: BookingLocation;
|
|
950
|
+
}>;
|
|
951
|
+
/** PATCH /api/bookings/locations/{id} — `{ data }`. */
|
|
952
|
+
update: (id: string, input: UpdateBookingLocationInput) => Promise<{
|
|
953
|
+
data: BookingLocation;
|
|
954
|
+
}>;
|
|
955
|
+
/** DELETE /api/bookings/locations/{id} — 204. */
|
|
956
|
+
remove: (id: string) => Promise<void>;
|
|
957
|
+
/**
|
|
958
|
+
* Per-location weekly opening hours (capability `working_hours`). Both verbs
|
|
959
|
+
* are the plain resource-collection `{ data: LocationHours[] }` (no `meta`),
|
|
960
|
+
* ordered Sunday→Saturday. Additive: a location with no rows keeps falling back
|
|
961
|
+
* to the tenant default window in the slot engine.
|
|
962
|
+
*/
|
|
963
|
+
hours: {
|
|
964
|
+
/** GET /api/bookings/locations/{id}/hours — `{ data }` (Sun→Sat). */
|
|
965
|
+
get: (locationId: string) => Promise<{
|
|
966
|
+
data: LocationHours[];
|
|
967
|
+
}>;
|
|
968
|
+
/** PUT /api/bookings/locations/{id}/hours — upsert the (≤7) day set, `{ data }`. */
|
|
969
|
+
set: (locationId: string, days: LocationHoursInput[]) => Promise<{
|
|
970
|
+
data: LocationHours[];
|
|
971
|
+
}>;
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
spaces: {
|
|
975
|
+
/** GET /api/bookings/spaces — plain resource collection `{ data }` (no meta). Filters: location_id, type, is_active. */
|
|
976
|
+
list: (query?: SpaceListQuery) => Promise<{
|
|
977
|
+
data: BookingSpace[];
|
|
978
|
+
}>;
|
|
979
|
+
/** GET /api/bookings/spaces/{id} */
|
|
980
|
+
get: (id: string) => Promise<{
|
|
981
|
+
data: BookingSpace;
|
|
982
|
+
}>;
|
|
983
|
+
/** POST /api/bookings/spaces — 201, `{ data }`. */
|
|
984
|
+
create: (input: CreateSpaceInput) => Promise<{
|
|
985
|
+
data: BookingSpace;
|
|
986
|
+
}>;
|
|
987
|
+
/** PATCH /api/bookings/spaces/{id} — `{ data }`. */
|
|
988
|
+
update: (id: string, input: UpdateSpaceInput) => Promise<{
|
|
989
|
+
data: BookingSpace;
|
|
990
|
+
}>;
|
|
991
|
+
/** DELETE /api/bookings/spaces/{id} — 204. */
|
|
992
|
+
remove: (id: string) => Promise<void>;
|
|
993
|
+
/**
|
|
994
|
+
* POST /api/bookings/spaces/{id}/photo — replace the space's photo.
|
|
995
|
+
*
|
|
996
|
+
* The collection is `singleFile`, so this REPLACES rather than appends: a club
|
|
997
|
+
* correcting a bad photo does not end up holding both. Returns the URL to read
|
|
998
|
+
* it back from, which is the same value `photo_url` carries on the space.
|
|
999
|
+
*
|
|
1000
|
+
* Sent as `FormData` — the http client leaves a raw body unencoded and lets the
|
|
1001
|
+
* browser set its own multipart boundary.
|
|
1002
|
+
*/
|
|
1003
|
+
uploadPhoto: (id: string, file: File) => Promise<{
|
|
1004
|
+
photo_url: string | null;
|
|
1005
|
+
}>;
|
|
1006
|
+
photoStaging: string;
|
|
1007
|
+
/** POST /api/bookings/spaces/{id}/photo `{staged_upload_token}` — set the photo the picker already staged. */
|
|
1008
|
+
setStagedPhoto: (id: string, token: string) => Promise<{
|
|
1009
|
+
photo_url: string | null;
|
|
1010
|
+
}>;
|
|
1011
|
+
/** DELETE /api/bookings/spaces/{id}/photo — removes the blob and the row. */
|
|
1012
|
+
deletePhoto: (id: string) => Promise<{
|
|
1013
|
+
photo_url: null;
|
|
1014
|
+
}>;
|
|
1015
|
+
};
|
|
1016
|
+
sessions: {
|
|
1017
|
+
/** GET /api/bookings/sessions */
|
|
1018
|
+
list: (query?: SessionListQuery) => Promise<Paginated<Session>>;
|
|
1019
|
+
/** GET /api/bookings/sessions/{id} */
|
|
1020
|
+
get: (id: string) => Promise<Session>;
|
|
1021
|
+
/** POST /api/bookings/sessions */
|
|
1022
|
+
create: (input: CreateSessionInput) => Promise<Session>;
|
|
1023
|
+
/** PATCH /api/bookings/sessions/{id} */
|
|
1024
|
+
update: (id: string, input: UpdateSessionInput) => Promise<Session>;
|
|
1025
|
+
/** POST /api/bookings/sessions/{id}/confirm */
|
|
1026
|
+
confirm: (id: string) => Promise<Session>;
|
|
1027
|
+
/** POST /api/bookings/sessions/{id}/cancel — `waiveFee` skips any late-cancellation fee. */
|
|
1028
|
+
cancel: (id: string, reason?: string, waiveFee?: boolean) => Promise<Session>;
|
|
1029
|
+
/** POST /api/bookings/sessions/{id}/complete */
|
|
1030
|
+
complete: (id: string) => Promise<Session>;
|
|
1031
|
+
/** POST /api/bookings/sessions/{id}/start */
|
|
1032
|
+
start: (id: string, startedByUserId?: string) => Promise<Session>;
|
|
1033
|
+
/** POST /api/bookings/sessions/{id}/no-show — `waiveFee` skips any no-show fee. */
|
|
1034
|
+
noShow: (id: string, waiveFee?: boolean) => Promise<Session>;
|
|
1035
|
+
/** POST /api/bookings/sessions/{id}/reinstate — undo a no-show (showed up late). */
|
|
1036
|
+
reinstate: (id: string) => Promise<Session>;
|
|
1037
|
+
/** POST /api/bookings/sessions/{id}/undo-check-in — revert a mistaken check-in (confirmed → booked). */
|
|
1038
|
+
undoCheckIn: (id: string) => Promise<Session>;
|
|
1039
|
+
/** POST /api/bookings/sessions/{id}/undo-no-show — revert a mistaken no-show (no_show → booked). */
|
|
1040
|
+
undoNoShow: (id: string) => Promise<Session>;
|
|
1041
|
+
/** GET /api/bookings/sessions/{id}/history — the session's status timeline. */
|
|
1042
|
+
history: (id: string) => Promise<{
|
|
1043
|
+
data: SessionHistoryEvent[];
|
|
1044
|
+
}>;
|
|
1045
|
+
/** GET /api/bookings/reports/punctuality — per-client lateness / no-show report. */
|
|
1046
|
+
punctuality: (query?: {
|
|
1047
|
+
date_from?: string;
|
|
1048
|
+
date_to?: string;
|
|
1049
|
+
}) => Promise<{
|
|
1050
|
+
data: ClientPunctuality[];
|
|
1051
|
+
}>;
|
|
1052
|
+
/** POST /api/bookings/sessions/{id}/reschedule */
|
|
1053
|
+
reschedule: (id: string, input: {
|
|
1054
|
+
scheduled_at: string;
|
|
1055
|
+
duration_minutes?: number;
|
|
1056
|
+
}) => Promise<Session>;
|
|
1057
|
+
/** GET /api/bookings/sessions/check-conflict */
|
|
1058
|
+
checkConflict: (query: ConflictCheckQuery) => Promise<ConflictCheckResult>;
|
|
1059
|
+
};
|
|
1060
|
+
/**
|
|
1061
|
+
* GET /api/bookings/availability?date&start&duration — bulk slot availability.
|
|
1062
|
+
* Returns the payload BARE (no `{ data }` wrapper): free/busy/full/off status
|
|
1063
|
+
* for every practitioner AND active space at the given slot.
|
|
1064
|
+
*/
|
|
1065
|
+
availability: (query: AvailabilityQuery) => Promise<SlotAvailability>;
|
|
1066
|
+
/**
|
|
1067
|
+
* GET /api/bookings/reports/activity?date — the front-desk activity feed:
|
|
1068
|
+
* today's session changes across the desk, each with an `undoable` flag for
|
|
1069
|
+
* one-click inverse corrections.
|
|
1070
|
+
*/
|
|
1071
|
+
activity: (query?: {
|
|
1072
|
+
date?: string;
|
|
1073
|
+
}) => Promise<{
|
|
1074
|
+
data: FrontDeskActivity[];
|
|
1075
|
+
}>;
|
|
1076
|
+
/**
|
|
1077
|
+
* The clinic landing marketing profile — authed admin CRUD, upserts one row per
|
|
1078
|
+
* tenant. Both verbs return `{ data: ClinicProfile }`.
|
|
1079
|
+
*/
|
|
1080
|
+
clinicProfile: {
|
|
1081
|
+
/** GET /api/bookings/clinic-profile */
|
|
1082
|
+
get: () => Promise<{
|
|
1083
|
+
data: ClinicProfile;
|
|
1084
|
+
}>;
|
|
1085
|
+
/** PUT /api/bookings/clinic-profile — partial patch/upsert. */
|
|
1086
|
+
update: (input: ClinicProfileInput) => Promise<{
|
|
1087
|
+
data: ClinicProfile;
|
|
1088
|
+
}>;
|
|
1089
|
+
};
|
|
1090
|
+
/**
|
|
1091
|
+
* The public-booking settings — authed admin CRUD. Both verbs return
|
|
1092
|
+
* `{ data: BookingSettings }`.
|
|
1093
|
+
*/
|
|
1094
|
+
bookingSettings: {
|
|
1095
|
+
/** GET /api/bookings/booking-settings */
|
|
1096
|
+
get: () => Promise<{
|
|
1097
|
+
data: BookingSettings;
|
|
1098
|
+
}>;
|
|
1099
|
+
/** PUT /api/bookings/booking-settings — partial patch. */
|
|
1100
|
+
update: (input: BookingSettingsInput) => Promise<{
|
|
1101
|
+
data: BookingSettings;
|
|
1102
|
+
}>;
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* The per-tenant reschedule / cancellation policy — who may self-serve, the notice
|
|
1106
|
+
* window and its enforcement, and any late-cancel / no-show fee. Both verbs return
|
|
1107
|
+
* `{ data: ReschedulePolicy }`; absent keys fall back to lenient core defaults.
|
|
1108
|
+
*/
|
|
1109
|
+
reschedulePolicy: {
|
|
1110
|
+
/** GET /api/bookings/reschedule-policy (`{data}`-unwrapped). */
|
|
1111
|
+
get: () => Promise<ReschedulePolicy>;
|
|
1112
|
+
/** PUT /api/bookings/reschedule-policy — replace the policy. */
|
|
1113
|
+
update: (input: ReschedulePolicy) => Promise<ReschedulePolicy>;
|
|
1114
|
+
};
|
|
1115
|
+
/**
|
|
1116
|
+
* The per-tenant appointment-confirmation policy — whether confirmation calls run, the
|
|
1117
|
+
* call lead-days, the attempt ceiling, and who is notified on confirm. `{data}`-unwrapped.
|
|
1118
|
+
*/
|
|
1119
|
+
confirmationPolicy: {
|
|
1120
|
+
/** GET /api/bookings/confirmation-policy */
|
|
1121
|
+
get: () => Promise<ConfirmationPolicy>;
|
|
1122
|
+
/** PUT /api/bookings/confirmation-policy — replace the policy. */
|
|
1123
|
+
update: (input: ConfirmationPolicy) => Promise<ConfirmationPolicy>;
|
|
1124
|
+
};
|
|
1125
|
+
/** The front-desk confirmation call list + outcome capture. */
|
|
1126
|
+
confirmations: {
|
|
1127
|
+
/** GET /api/bookings/confirmations?date — a day's appointments + confirmation state (defaults to tomorrow). */
|
|
1128
|
+
list: (date?: string) => Promise<ConfirmationCallListRow[]>;
|
|
1129
|
+
/** POST /api/bookings/confirmations/{session}/outcome — record a call outcome. */
|
|
1130
|
+
recordOutcome: (sessionId: string, outcome: ConfirmationOutcome, note?: string) => Promise<AppointmentConfirmationState>;
|
|
1131
|
+
};
|
|
1132
|
+
insurance: {
|
|
1133
|
+
insurers: {
|
|
1134
|
+
/** GET /api/bookings/insurers — RAW Laravel paginator. */
|
|
1135
|
+
list: (query?: InsurerListQuery) => Promise<LaravelPaginator<Insurer>>;
|
|
1136
|
+
/** GET /api/bookings/insurers/{id} */
|
|
1137
|
+
get: (id: string) => Promise<Insurer>;
|
|
1138
|
+
/** POST /api/bookings/insurers */
|
|
1139
|
+
create: (input: CreateInsurerInput) => Promise<Insurer>;
|
|
1140
|
+
/** PATCH /api/bookings/insurers/{id} */
|
|
1141
|
+
update: (id: string, input: UpdateInsurerInput) => Promise<Insurer>;
|
|
1142
|
+
/** DELETE /api/bookings/insurers/{id} — soft delete, 204. */
|
|
1143
|
+
remove: (id: string) => Promise<void>;
|
|
1144
|
+
};
|
|
1145
|
+
plans: {
|
|
1146
|
+
/** GET /api/bookings/insurance-plans — RAW Laravel paginator. */
|
|
1147
|
+
list: (query?: InsurancePlanListQuery) => Promise<LaravelPaginator<InsurancePlan>>;
|
|
1148
|
+
/** GET /api/bookings/insurance-plans/{id} */
|
|
1149
|
+
get: (id: string) => Promise<InsurancePlan>;
|
|
1150
|
+
/** POST /api/bookings/insurance-plans */
|
|
1151
|
+
create: (input: CreateInsurancePlanInput) => Promise<InsurancePlan>;
|
|
1152
|
+
/** PATCH /api/bookings/insurance-plans/{id} */
|
|
1153
|
+
update: (id: string, input: UpdateInsurancePlanInput) => Promise<InsurancePlan>;
|
|
1154
|
+
/** DELETE /api/bookings/insurance-plans/{id} — soft-disable, 204. */
|
|
1155
|
+
remove: (id: string) => Promise<void>;
|
|
1156
|
+
};
|
|
1157
|
+
policies: {
|
|
1158
|
+
/** GET /api/bookings/insurance-policies — RAW Laravel paginator. */
|
|
1159
|
+
list: (query?: InsurancePolicyListQuery) => Promise<LaravelPaginator<InsurancePolicy>>;
|
|
1160
|
+
/** GET /api/bookings/insurance-policies/{id} */
|
|
1161
|
+
get: (id: string) => Promise<InsurancePolicy>;
|
|
1162
|
+
/** POST /api/bookings/insurance-policies */
|
|
1163
|
+
create: (input: CreateInsurancePolicyInput) => Promise<InsurancePolicy>;
|
|
1164
|
+
/** PATCH /api/bookings/insurance-policies/{id} (no destroy endpoint). */
|
|
1165
|
+
update: (id: string, input: UpdateInsurancePolicyInput) => Promise<InsurancePolicy>;
|
|
1166
|
+
};
|
|
1167
|
+
};
|
|
1168
|
+
insuranceAuthorizations: {
|
|
1169
|
+
/** GET /api/bookings/insurance-authorizations — paginated; optional client filter. */
|
|
1170
|
+
list: (query?: {
|
|
1171
|
+
client_id?: string;
|
|
1172
|
+
per_page?: number;
|
|
1173
|
+
}) => Promise<Paginated<InsuranceAuthorization>>;
|
|
1174
|
+
/** POST /api/bookings/insurance-authorizations */
|
|
1175
|
+
create: (input: CreateInsuranceAuthorizationInput) => Promise<InsuranceAuthorization>;
|
|
1176
|
+
};
|
|
1177
|
+
/**
|
|
1178
|
+
* Session ratings — both sides of a completed session, blind until both have rated,
|
|
1179
|
+
* plus the tenant-wide list for reporting. See the section comment on `RatingRow`.
|
|
1180
|
+
*/
|
|
1181
|
+
ratings: {
|
|
1182
|
+
/** GET /api/bookings/ratings — one row per side that has rated (perm bookings.ratings.view). */
|
|
1183
|
+
list: (query?: RatingListQuery) => Promise<Paginated<RatingRow>>;
|
|
1184
|
+
/** GET /api/bookings/sessions/{id}/rating — as the caller may see it (404 when not rateable yet). */
|
|
1185
|
+
forSession: (sessionId: string) => Promise<SessionRatingRecord>;
|
|
1186
|
+
/** POST /api/bookings/sessions/{id}/rate — rate the caller's own side (perm bookings.ratings.manage). */
|
|
1187
|
+
rate: (sessionId: string, input: RateSessionInput) => Promise<SessionRatingRecord>;
|
|
1188
|
+
};
|
|
1189
|
+
waitlist: {
|
|
1190
|
+
/** GET /api/bookings/waitlist (pass `status` to filter). Unwraps `{data}`. */
|
|
1191
|
+
list: (status?: WaitlistStatus) => Promise<WaitlistEntry[]>;
|
|
1192
|
+
/** GET /api/bookings/waitlist/{id}. Unwraps `{data}`. */
|
|
1193
|
+
get: (id: string) => Promise<WaitlistEntry>;
|
|
1194
|
+
/** POST /api/bookings/waitlist — 201. Unwraps `{data}`. */
|
|
1195
|
+
create: (input: WaitlistInput) => Promise<WaitlistEntry>;
|
|
1196
|
+
/** PATCH /api/bookings/waitlist/{id}. Unwraps `{data}`. */
|
|
1197
|
+
update: (id: string, input: Partial<WaitlistInput> & {
|
|
1198
|
+
status?: WaitlistStatus;
|
|
1199
|
+
}) => Promise<WaitlistEntry>;
|
|
1200
|
+
/** DELETE /api/bookings/waitlist/{id} — 204, no envelope to unwrap. */
|
|
1201
|
+
remove: (id: string) => Promise<void>;
|
|
1202
|
+
/** POST /api/bookings/waitlist/{id}/accept — a `notified` waiter took the offered slot. Unwraps `{data}`. */
|
|
1203
|
+
accept: (id: string) => Promise<WaitlistEntry>;
|
|
1204
|
+
/**
|
|
1205
|
+
* POST /api/bookings/waitlist/{id}/decline — a `notified` waiter declined or did not
|
|
1206
|
+
* answer: the entry returns to `waiting` (fenced from the same slot) and the offer moves
|
|
1207
|
+
* to the next waiter, which core answers with.
|
|
1208
|
+
*/
|
|
1209
|
+
decline: (id: string, response: "declined" | "no_answer") => Promise<{
|
|
1210
|
+
data: unknown;
|
|
1211
|
+
}>;
|
|
1212
|
+
};
|
|
1213
|
+
};
|
|
1214
|
+
export type BookingsNamespace = ReturnType<typeof createBookingsNamespace>;
|
|
1215
|
+
/** The public-safe marketing content folded into the clinic call (ClinicProfile::toPublicArray). */
|
|
1216
|
+
export interface PublicClinicProfile {
|
|
1217
|
+
display_name: LocalizedText | null;
|
|
1218
|
+
tagline: LocalizedText | null;
|
|
1219
|
+
about: LocalizedText | null;
|
|
1220
|
+
logo_url: string | null;
|
|
1221
|
+
cover_image_url: string | null;
|
|
1222
|
+
gallery: string[];
|
|
1223
|
+
theme: ClinicProfileTheme | null;
|
|
1224
|
+
contact: ClinicProfileContact | null;
|
|
1225
|
+
hours: Record<string, unknown> | null;
|
|
1226
|
+
services: ClinicProfileService[];
|
|
1227
|
+
team: ClinicProfileTeamMember[];
|
|
1228
|
+
testimonials: ClinicProfileTestimonial[];
|
|
1229
|
+
social: ClinicProfileSocial | null;
|
|
1230
|
+
sections_enabled: Record<string, boolean> | null;
|
|
1231
|
+
}
|
|
1232
|
+
/** A bookable service (session type) exposed on the public landing page. */
|
|
1233
|
+
export interface PublicClinicService {
|
|
1234
|
+
id: string;
|
|
1235
|
+
name: {
|
|
1236
|
+
en: string;
|
|
1237
|
+
ar: string;
|
|
1238
|
+
};
|
|
1239
|
+
duration_minutes: number;
|
|
1240
|
+
price: string | null;
|
|
1241
|
+
}
|
|
1242
|
+
/** A bookable practitioner exposed on the public landing page (id + display name only). */
|
|
1243
|
+
export interface PublicClinicPractitioner {
|
|
1244
|
+
id: string;
|
|
1245
|
+
display_name: string;
|
|
1246
|
+
}
|
|
1247
|
+
/** A bookable room/space exposed on the public landing page (only when `show_space_selector`). */
|
|
1248
|
+
export interface PublicClinicSpace {
|
|
1249
|
+
id: string;
|
|
1250
|
+
name: {
|
|
1251
|
+
en: string;
|
|
1252
|
+
ar: string;
|
|
1253
|
+
};
|
|
1254
|
+
type: SpaceType;
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* `GET /api/public/{slug}/clinic` — the single landing-page payload. `profile` is `null`
|
|
1258
|
+
* when the clinic has not published its marketing content (booking-only "coming soon").
|
|
1259
|
+
*/
|
|
1260
|
+
export interface PublicClinic {
|
|
1261
|
+
profile: PublicClinicProfile | null;
|
|
1262
|
+
clinic: {
|
|
1263
|
+
name: string;
|
|
1264
|
+
branding: {
|
|
1265
|
+
logo_path: string | null;
|
|
1266
|
+
};
|
|
1267
|
+
contact: {
|
|
1268
|
+
phone: string | null;
|
|
1269
|
+
email: string | null;
|
|
1270
|
+
website: string | null;
|
|
1271
|
+
address: string | null;
|
|
1272
|
+
};
|
|
1273
|
+
hours: {
|
|
1274
|
+
time_start: string | null;
|
|
1275
|
+
time_end: string | null;
|
|
1276
|
+
} | null;
|
|
1277
|
+
};
|
|
1278
|
+
booking: {
|
|
1279
|
+
confirmation_mode: ConfirmationMode;
|
|
1280
|
+
min_lead_time_minutes: number;
|
|
1281
|
+
max_advance_days: number;
|
|
1282
|
+
slot_granularity_minutes: number;
|
|
1283
|
+
/** Which selectors the widget should render. */
|
|
1284
|
+
show_service_selector: boolean;
|
|
1285
|
+
show_practitioner_selector: boolean;
|
|
1286
|
+
show_space_selector: boolean;
|
|
1287
|
+
/** Forced choice when the matching selector is hidden (`null` ⇒ "Any"). */
|
|
1288
|
+
default_session_type_id: string | null;
|
|
1289
|
+
default_practitioner_id: string | null;
|
|
1290
|
+
default_space_id: string | null;
|
|
1291
|
+
};
|
|
1292
|
+
services: PublicClinicService[];
|
|
1293
|
+
practitioners: PublicClinicPractitioner[];
|
|
1294
|
+
/** Bookable rooms/spaces — populated only when `booking.show_space_selector` is true, else `[]`. */
|
|
1295
|
+
spaces: PublicClinicSpace[];
|
|
1296
|
+
}
|
|
1297
|
+
/** One free bookable slot (PublicAvailabilityService::forDay). Times are ISO-8601. */
|
|
1298
|
+
export interface PublicSlot {
|
|
1299
|
+
starts_at: string;
|
|
1300
|
+
ends_at: string;
|
|
1301
|
+
/** The bookable practitioners free for THIS slot. */
|
|
1302
|
+
practitioner_ids: string[];
|
|
1303
|
+
}
|
|
1304
|
+
/** `GET /api/public/{slug}/availability` — echoes the queried `date` plus the free `slots`. */
|
|
1305
|
+
export interface PublicAvailability {
|
|
1306
|
+
date: string;
|
|
1307
|
+
slots: PublicSlot[];
|
|
1308
|
+
}
|
|
1309
|
+
export interface PublicAvailabilityQuery {
|
|
1310
|
+
/** Required. The bookable service to price the slot durations against. */
|
|
1311
|
+
session_type_id: string;
|
|
1312
|
+
/** Optional — narrow to a single practitioner. */
|
|
1313
|
+
practitioner_id?: string | null;
|
|
1314
|
+
/** Optional — restrict slots to a chosen room/space (respected by the availability engine). */
|
|
1315
|
+
space_id?: string | null;
|
|
1316
|
+
/** Required. `YYYY-MM-DD`. */
|
|
1317
|
+
date: string;
|
|
1318
|
+
[key: string]: QueryValue;
|
|
1319
|
+
}
|
|
1320
|
+
/** `POST /api/public/{slug}/bookings` body. */
|
|
1321
|
+
export interface PublicBookingInput {
|
|
1322
|
+
patient: {
|
|
1323
|
+
name: string;
|
|
1324
|
+
phone: string;
|
|
1325
|
+
email?: string | null;
|
|
1326
|
+
};
|
|
1327
|
+
/** Optional — when the service selector is hidden the server uses `default_session_type_id`. */
|
|
1328
|
+
session_type_id?: string | null;
|
|
1329
|
+
practitioner_id?: string | null;
|
|
1330
|
+
/** Optional — the chosen room/space; when the selector is hidden the server uses `default_space_id`. */
|
|
1331
|
+
space_id?: string | null;
|
|
1332
|
+
/** ISO-8601 start time (typically a `PublicSlot.starts_at`). */
|
|
1333
|
+
starts_at: string;
|
|
1334
|
+
/** Optional captcha token — verified server-side only when a secret is configured. */
|
|
1335
|
+
captcha_token?: string | null;
|
|
1336
|
+
}
|
|
1337
|
+
/** `POST /api/public/{slug}/bookings` response (201) — deliberately minimal. */
|
|
1338
|
+
export interface BookingConfirmation {
|
|
1339
|
+
reference: string;
|
|
1340
|
+
status: SessionStatus;
|
|
1341
|
+
starts_at: string | null;
|
|
1342
|
+
}
|
|
1343
|
+
/** Config for the public (token-less) booking client. */
|
|
1344
|
+
export interface PublicBookingClientConfig {
|
|
1345
|
+
/** Base URL of the core monolith, e.g. `http://localhost:8090`. No trailing slash. */
|
|
1346
|
+
baseUrl: string;
|
|
1347
|
+
/** Injectable fetch (tests / Node < 18). Defaults to global `fetch`. */
|
|
1348
|
+
fetch?: typeof fetch;
|
|
1349
|
+
/** Extra headers merged into every request (e.g. `Accept-Language`). */
|
|
1350
|
+
defaultHeaders?: Record<string, string> | (() => Record<string, string>);
|
|
1351
|
+
}
|
|
1352
|
+
export interface PublicBookingClient {
|
|
1353
|
+
/** GET /api/public/{slug}/clinic */
|
|
1354
|
+
clinic: (slug: string) => Promise<PublicClinic>;
|
|
1355
|
+
/** GET /api/public/{slug}/availability?session_type_id&practitioner_id&space_id&date */
|
|
1356
|
+
availability: (slug: string, query: PublicAvailabilityQuery) => Promise<PublicAvailability>;
|
|
1357
|
+
/** POST /api/public/{slug}/bookings — 201 → `{ reference, status, starts_at }`. */
|
|
1358
|
+
book: (slug: string, input: PublicBookingInput) => Promise<BookingConfirmation>;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Build the UNAUTHENTICATED public-booking client for a clinic's landing page. It reuses
|
|
1362
|
+
* the core http transport but forces an EMPTY token, so NO `Authorization` header is ever
|
|
1363
|
+
* attached (`getToken: () => ''`). Slugs are URL-encoded.
|
|
1364
|
+
*/
|
|
1365
|
+
export declare function createPublicBookingClient(config: PublicBookingClientConfig): PublicBookingClient;
|