@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.
Files changed (239) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +229 -2
  3. package/bin/nuwah-contract-check-rules.d.mts +41 -0
  4. package/bin/nuwah-contract-check-rules.mjs +333 -0
  5. package/bin/nuwah-contract-check.mjs +64 -0
  6. package/dist/accounting.d.ts +1417 -0
  7. package/dist/accounting.js +274 -0
  8. package/dist/active-org.d.ts +13 -0
  9. package/dist/active-org.js +59 -0
  10. package/dist/actors.d.ts +448 -0
  11. package/dist/actors.js +143 -0
  12. package/dist/ai.d.ts +359 -0
  13. package/dist/ai.js +229 -0
  14. package/dist/analytics.d.ts +37 -0
  15. package/dist/analytics.js +8 -0
  16. package/dist/atlas.d.ts +291 -0
  17. package/dist/atlas.js +78 -0
  18. package/dist/audit.d.ts +193 -0
  19. package/dist/audit.js +26 -0
  20. package/dist/authentication.d.ts +119 -0
  21. package/dist/authentication.js +83 -0
  22. package/dist/awards.d.ts +38 -0
  23. package/dist/awards.js +10 -0
  24. package/dist/blueprint/document.d.ts +178 -0
  25. package/dist/blueprint/document.js +17 -0
  26. package/dist/blueprint/index.d.ts +3 -0
  27. package/dist/blueprint/index.js +5 -0
  28. package/dist/blueprint/manifest.d.ts +105 -0
  29. package/dist/blueprint/manifest.js +11 -0
  30. package/dist/blueprint/validate.d.ts +14 -0
  31. package/dist/blueprint/validate.js +416 -0
  32. package/dist/bookings-directory.d.ts +118 -0
  33. package/dist/bookings-directory.js +289 -0
  34. package/dist/bookings-extra.d.ts +1448 -0
  35. package/dist/bookings-extra.js +582 -0
  36. package/dist/bookings.d.ts +1365 -0
  37. package/dist/bookings.js +305 -0
  38. package/dist/builder-code.d.ts +164 -0
  39. package/dist/builder-code.js +12 -0
  40. package/dist/builder-core-gaps.d.ts +83 -0
  41. package/dist/builder-core-gaps.js +8 -0
  42. package/dist/builder-repos.d.ts +73 -0
  43. package/dist/builder-repos.js +37 -0
  44. package/dist/builder.d.ts +730 -0
  45. package/dist/builder.js +105 -0
  46. package/dist/campaigns.d.ts +105 -0
  47. package/dist/campaigns.js +25 -0
  48. package/dist/catalogs.d.ts +188 -0
  49. package/dist/catalogs.js +36 -0
  50. package/dist/commerce-ai.d.ts +182 -0
  51. package/dist/commerce-ai.js +27 -0
  52. package/dist/connections.d.ts +278 -0
  53. package/dist/connections.js +96 -0
  54. package/dist/content-control.d.ts +121 -0
  55. package/dist/content-control.js +23 -0
  56. package/dist/contributions.d.ts +560 -0
  57. package/dist/contributions.js +140 -0
  58. package/dist/conversation-assist.d.ts +154 -0
  59. package/dist/conversation-assist.js +51 -0
  60. package/dist/conversation-info.d.ts +219 -0
  61. package/dist/conversation-info.js +43 -0
  62. package/dist/crm.d.ts +533 -0
  63. package/dist/crm.js +142 -0
  64. package/dist/dashboards.d.ts +119 -0
  65. package/dist/dashboards.js +22 -0
  66. package/dist/delegations.d.ts +161 -0
  67. package/dist/delegations.js +39 -0
  68. package/dist/docs.d.ts +289 -0
  69. package/dist/docs.js +49 -0
  70. package/dist/documents.d.ts +317 -0
  71. package/dist/documents.js +84 -0
  72. package/dist/drafts.d.ts +132 -0
  73. package/dist/drafts.js +56 -0
  74. package/dist/engagements.d.ts +133 -0
  75. package/dist/engagements.js +15 -0
  76. package/dist/event-stream.d.ts +54 -0
  77. package/dist/event-stream.js +228 -0
  78. package/dist/exchanges.d.ts +447 -0
  79. package/dist/exchanges.js +145 -0
  80. package/dist/exports.d.ts +113 -0
  81. package/dist/exports.js +81 -0
  82. package/dist/feeds.d.ts +228 -0
  83. package/dist/feeds.js +52 -0
  84. package/dist/files.d.ts +56 -0
  85. package/dist/files.js +55 -0
  86. package/dist/finance-insights.d.ts +41 -0
  87. package/dist/finance-insights.js +61 -0
  88. package/dist/fixed-assets.d.ts +155 -0
  89. package/dist/fixed-assets.js +28 -0
  90. package/dist/fulfilment-jobs.d.ts +405 -0
  91. package/dist/fulfilment-jobs.js +76 -0
  92. package/dist/fulfilment.d.ts +205 -0
  93. package/dist/fulfilment.js +39 -0
  94. package/dist/hr.d.ts +350 -0
  95. package/dist/hr.js +94 -0
  96. package/dist/http.d.ts +124 -0
  97. package/dist/http.js +392 -0
  98. package/dist/inbox.d.ts +206 -0
  99. package/dist/inbox.js +36 -0
  100. package/dist/index.d.ts +384 -0
  101. package/dist/index.js +294 -0
  102. package/dist/insights.d.ts +176 -0
  103. package/dist/insights.js +52 -0
  104. package/dist/inventory.d.ts +797 -0
  105. package/dist/inventory.js +120 -0
  106. package/dist/list-query.d.ts +211 -0
  107. package/dist/list-query.js +158 -0
  108. package/dist/listings.d.ts +381 -0
  109. package/dist/listings.js +173 -0
  110. package/dist/location-sharing.d.ts +83 -0
  111. package/dist/location-sharing.js +20 -0
  112. package/dist/marketplace.d.ts +268 -0
  113. package/dist/marketplace.js +59 -0
  114. package/dist/matching.d.ts +103 -0
  115. package/dist/matching.js +22 -0
  116. package/dist/media.d.ts +221 -0
  117. package/dist/media.js +239 -0
  118. package/dist/metrics.d.ts +125 -0
  119. package/dist/metrics.js +45 -0
  120. package/dist/moderation.d.ts +240 -0
  121. package/dist/moderation.js +40 -0
  122. package/dist/money.d.ts +41 -0
  123. package/dist/money.js +79 -0
  124. package/dist/my-data.d.ts +266 -0
  125. package/dist/my-data.js +32 -0
  126. package/dist/names.d.ts +14 -0
  127. package/dist/names.js +17 -0
  128. package/dist/occasions.d.ts +256 -0
  129. package/dist/occasions.js +40 -0
  130. package/dist/onboarding.d.ts +88 -0
  131. package/dist/onboarding.js +38 -0
  132. package/dist/pagination.d.ts +204 -0
  133. package/dist/pagination.js +141 -0
  134. package/dist/party-baseline-attributes.d.ts +245 -0
  135. package/dist/party-baseline-attributes.js +36 -0
  136. package/dist/party.d.ts +401 -0
  137. package/dist/party.js +56 -0
  138. package/dist/patient.d.ts +161 -0
  139. package/dist/patient.js +45 -0
  140. package/dist/payroll.d.ts +378 -0
  141. package/dist/payroll.js +60 -0
  142. package/dist/person-addresses.d.ts +88 -0
  143. package/dist/person-addresses.js +18 -0
  144. package/dist/person-cart.d.ts +250 -0
  145. package/dist/person-cart.js +63 -0
  146. package/dist/person-chat-assist.d.ts +47 -0
  147. package/dist/person-chat-assist.js +13 -0
  148. package/dist/person-data-webhooks.d.ts +72 -0
  149. package/dist/person-data-webhooks.js +86 -0
  150. package/dist/person-data.d.ts +212 -0
  151. package/dist/person-data.js +162 -0
  152. package/dist/person-locations.d.ts +54 -0
  153. package/dist/person-locations.js +6 -0
  154. package/dist/person-messaging.d.ts +405 -0
  155. package/dist/person-messaging.js +112 -0
  156. package/dist/person-notifications.d.ts +319 -0
  157. package/dist/person-notifications.js +164 -0
  158. package/dist/personalisation.d.ts +21 -0
  159. package/dist/personalisation.js +8 -0
  160. package/dist/platform.d.ts +63 -0
  161. package/dist/platform.js +45 -0
  162. package/dist/portfolio.d.ts +163 -0
  163. package/dist/portfolio.js +28 -0
  164. package/dist/pos.d.ts +743 -0
  165. package/dist/pos.js +129 -0
  166. package/dist/procurement.d.ts +664 -0
  167. package/dist/procurement.js +157 -0
  168. package/dist/promotions.d.ts +169 -0
  169. package/dist/promotions.js +39 -0
  170. package/dist/publications.d.ts +583 -0
  171. package/dist/publications.js +164 -0
  172. package/dist/ranking.d.ts +43 -0
  173. package/dist/ranking.js +34 -0
  174. package/dist/ratings.d.ts +293 -0
  175. package/dist/ratings.js +109 -0
  176. package/dist/reactions.d.ts +123 -0
  177. package/dist/reactions.js +41 -0
  178. package/dist/recipient-orders.d.ts +294 -0
  179. package/dist/recipient-orders.js +73 -0
  180. package/dist/relationships.d.ts +18 -0
  181. package/dist/relationships.js +8 -0
  182. package/dist/reporting.d.ts +107 -0
  183. package/dist/reporting.js +56 -0
  184. package/dist/sales.d.ts +270 -0
  185. package/dist/sales.js +66 -0
  186. package/dist/shares.d.ts +105 -0
  187. package/dist/shares.js +27 -0
  188. package/dist/shop.d.ts +993 -0
  189. package/dist/shop.js +215 -0
  190. package/dist/shopping-assistant.d.ts +65 -0
  191. package/dist/shopping-assistant.js +14 -0
  192. package/dist/spaces.d.ts +422 -0
  193. package/dist/spaces.js +118 -0
  194. package/dist/stored-value.d.ts +754 -0
  195. package/dist/stored-value.js +177 -0
  196. package/dist/types.d.ts +83 -0
  197. package/dist/types.js +2 -0
  198. package/dist/vault.d.ts +290 -0
  199. package/dist/vault.js +55 -0
  200. package/dist/vertical-runtime.d.ts +17 -0
  201. package/dist/vertical-runtime.js +8 -0
  202. package/dist/vite/build-manifest-plugin.d.ts +42 -0
  203. package/dist/vite/build-manifest-plugin.js +42 -0
  204. package/dist/vite/first-paint-plugin.d.ts +26 -0
  205. package/dist/vite/first-paint-plugin.js +57 -0
  206. package/dist/wishlists.d.ts +591 -0
  207. package/dist/wishlists.js +188 -0
  208. package/dist/workbench.d.ts +114 -0
  209. package/dist/workbench.js +22 -0
  210. package/dist/workspace.d.ts +190 -0
  211. package/dist/workspace.js +41 -0
  212. package/package.json +52 -4
  213. package/templates/extension-image.Dockerfile +38 -0
  214. package/templates/nuwah-vertical.yml +102 -0
  215. package/templates/vertical-app/.env.example +34 -0
  216. package/templates/vertical-app/README.md +108 -0
  217. package/templates/vertical-app/github/workflows/ci.yml +51 -0
  218. package/templates/vertical-app/gitignore +5 -0
  219. package/templates/vertical-app/index.html +12 -0
  220. package/templates/vertical-app/package.json +28 -0
  221. package/templates/vertical-app/src/App.tsx +64 -0
  222. package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
  223. package/templates/vertical-app/src/blueprint/screens.ts +15 -0
  224. package/templates/vertical-app/src/env.d.ts +18 -0
  225. package/templates/vertical-app/src/index.css +139 -0
  226. package/templates/vertical-app/src/lib/i18n.ts +5 -0
  227. package/templates/vertical-app/src/lib/iam.ts +19 -0
  228. package/templates/vertical-app/src/lib/operations.ts +93 -0
  229. package/templates/vertical-app/src/lib/router.ts +24 -0
  230. package/templates/vertical-app/src/lib/sdk.ts +21 -0
  231. package/templates/vertical-app/src/lib/theme.ts +18 -0
  232. package/templates/vertical-app/src/lib/words.ts +39 -0
  233. package/templates/vertical-app/src/main.tsx +25 -0
  234. package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
  235. package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
  236. package/templates/vertical-app/src/pages/Home.tsx +36 -0
  237. package/templates/vertical-app/tsconfig.json +24 -0
  238. package/templates/vertical-app/vite.config.ts +23 -0
  239. package/templates/vertical-ci.yml +192 -0
@@ -0,0 +1,1448 @@
1
+ import type { Http } from './http.js';
2
+ import type { Paginated } from './types.js';
3
+ import type { Session, BookingPractitioner, BookingSpace } from './bookings.js';
4
+ export interface ClubSessionKind {
5
+ en: string;
6
+ ar: string;
7
+ icon: string;
8
+ }
9
+ /** The six canonical club session-type keys (mirrors vertical.config session types). */
10
+ export declare const CLUB_SESSION_KINDS: Record<string, ClubSessionKind>;
11
+ /** The club label + icon for a session-type key (falls back to a generic booking glyph). */
12
+ export declare function clubSessionKind(key: string | null | undefined): ClubSessionKind;
13
+ export interface ExclusiveSpaceBlock {
14
+ id: string;
15
+ tenant_id?: string;
16
+ space_id: string;
17
+ title: string;
18
+ starts_at: string;
19
+ ends_at: string;
20
+ booked_by: string | null;
21
+ notes: string | null;
22
+ created_at: string | null;
23
+ updated_at: string | null;
24
+ /** Eager-loaded (`space:id,name_en,name_ar,type`). */
25
+ space?: Pick<BookingSpace, 'id' | 'name_en' | 'name_ar' | 'type'>;
26
+ }
27
+ export interface CreateExclusiveSpaceBlockInput {
28
+ space_id: string;
29
+ title: string;
30
+ starts_at: string;
31
+ ends_at: string;
32
+ booked_by?: string | null;
33
+ notes?: string | null;
34
+ }
35
+ export interface Package {
36
+ id: string;
37
+ tenant_id?: string;
38
+ name: string;
39
+ description: string | null;
40
+ session_type_id: string | null;
41
+ credits: number;
42
+ price: string;
43
+ validity_days: number;
44
+ is_active: boolean;
45
+ created_at: string | null;
46
+ updated_at: string | null;
47
+ }
48
+ export interface ClientPackage {
49
+ id: string;
50
+ client_id: string;
51
+ package_id: string;
52
+ credits_remaining: number;
53
+ purchased_at: string | null;
54
+ expires_at: string | null;
55
+ created_at: string | null;
56
+ updated_at: string | null;
57
+ package?: Pick<Package, 'id' | 'name' | 'credits' | 'validity_days'>;
58
+ }
59
+ export type BookingPaymentMethod = 'cash' | 'card' | 'bank_transfer' | 'cliq';
60
+ export interface PurchasePackageInput {
61
+ package_id: string;
62
+ payment_method: BookingPaymentMethod;
63
+ currency_code?: string;
64
+ reference_number?: string | null;
65
+ notes?: string | null;
66
+ }
67
+ /** How a manual credit change is classified (drives the GL posting + audit). */
68
+ export type PackageAdjustmentType = 'grant' | 'refund' | 'correction';
69
+ export interface AdjustCreditsInput {
70
+ type: PackageAdjustmentType;
71
+ /** Signed change to remaining credits (+ adds, − removes). Never 0. */
72
+ delta: number;
73
+ /** Audit-friendly free-text justification (stored on the adjustment row). */
74
+ reason?: string | null;
75
+ }
76
+ /** The audit row an adjust returns (credits changed + GL posted). */
77
+ export interface PackageCreditAdjustment {
78
+ id: string;
79
+ client_package_id: string;
80
+ type: PackageAdjustmentType;
81
+ delta: number;
82
+ reason: string | null;
83
+ actor_person_id: string | null;
84
+ created_at: string | null;
85
+ updated_at: string | null;
86
+ client_package?: ClientPackage;
87
+ }
88
+ /** One expiring-soon bucket in the tenant-wide outstanding aggregate. */
89
+ export interface OutstandingBucket {
90
+ count: number;
91
+ credits: number;
92
+ /** bcmath money string — the Deferred-Revenue liability in this bucket. */
93
+ liability: string;
94
+ }
95
+ /** Tenant-wide outstanding package aggregate (GET /packages/outstanding). */
96
+ export interface PackagesOutstanding {
97
+ outstanding_credits: number;
98
+ /** Σ credits_remaining × per-credit value — the unearned 2300 liability. */
99
+ outstanding_liability: string;
100
+ sold_credits: number;
101
+ redeemed_credits: number;
102
+ /** 0..1 — redeemed ÷ sold credits. */
103
+ redemption_rate: number;
104
+ expiring_soon: {
105
+ within_30_days: OutstandingBucket;
106
+ within_60_days: OutstandingBucket;
107
+ within_90_days: OutstandingBucket;
108
+ };
109
+ }
110
+ /** One 2300-tagged GL entry in a package's deferred schedule. */
111
+ export interface DeferredScheduleEntry {
112
+ journal_entry_id: string;
113
+ event_key: string | null;
114
+ entry_date: string | null;
115
+ /** DR to 2300 (recognition / refund) — a money string. */
116
+ deferred_debit: string;
117
+ /** CR to 2300 (purchase / grant) — a money string. */
118
+ deferred_credit: string;
119
+ }
120
+ /** Per-package deferred schedule (GET /client-packages/{id}/deferred-schedule). */
121
+ export interface PackageDeferredSchedule {
122
+ client_package_id: string;
123
+ per_credit_value: string;
124
+ credits_remaining: number;
125
+ original_deferred: string;
126
+ deferred_in: string;
127
+ recognized_to_date: string;
128
+ refunded_to_date: string;
129
+ remaining_deferred: string;
130
+ expected_remaining: string;
131
+ /** True when remaining_deferred == credits_remaining × per-credit (within tolerance). */
132
+ reconciles: boolean;
133
+ expires_at: string | null;
134
+ gl_entries: DeferredScheduleEntry[];
135
+ }
136
+ /** Create/edit a package DEFINITION (the catalog entry, not a client's copy). */
137
+ export interface CreatePackageInput {
138
+ name: string;
139
+ description?: string | null;
140
+ session_type_id?: string | null;
141
+ credits: number;
142
+ price: number;
143
+ /** ISO-4217; nullable on create (tenant default), `sometimes` but not nullable on update. */
144
+ currency_code?: string | null;
145
+ validity_days: number;
146
+ is_active?: boolean;
147
+ }
148
+ export type UpdatePackageInput = Partial<Omit<CreatePackageInput, 'session_type_id' | 'currency_code'>> & {
149
+ currency_code?: string;
150
+ };
151
+ /** How often a membership plan bills (drives the period length + MRR weighting). */
152
+ export type BillingInterval = 'monthly' | 'quarterly' | 'yearly' | 'one_time';
153
+ export type MembershipStatus = 'active' | 'paused' | 'cancelled' | 'expired';
154
+ /** A membership PLAN definition (the catalog entry a patient enrols in). */
155
+ export interface MembershipPlan {
156
+ id: string;
157
+ tenant_id?: string;
158
+ name_en: string | null;
159
+ name_ar: string | null;
160
+ code: string;
161
+ price: string;
162
+ currency_code: string;
163
+ billing_interval: BillingInterval;
164
+ session_credits: number | null;
165
+ is_active: boolean;
166
+ description: string | null;
167
+ description_ar?: string | null;
168
+ created_at: string | null;
169
+ updated_at: string | null;
170
+ }
171
+ export interface CreateMembershipPlanInput {
172
+ name_en?: string | null;
173
+ name_ar?: string | null;
174
+ code: string;
175
+ price: number;
176
+ currency_code?: string;
177
+ billing_interval: BillingInterval;
178
+ session_credits?: number | null;
179
+ is_active?: boolean;
180
+ description?: string | null;
181
+ description_ar?: string | null;
182
+ }
183
+ export type UpdateMembershipPlanInput = Partial<Omit<CreateMembershipPlanInput, 'code' | 'billing_interval'>>;
184
+ /** A billing window of a membership (credits granted/used in a period). */
185
+ export interface MembershipPeriod {
186
+ id: string;
187
+ membership_id: string;
188
+ starts_at: string | null;
189
+ ends_at: string | null;
190
+ credits_granted: number | null;
191
+ credits_used: number;
192
+ created_at: string | null;
193
+ }
194
+ /** A patient's enrolment on a plan. */
195
+ /**
196
+ * `GET/PUT /api/bookings/membership-lapse-policy` — the club's grace after a paid period ends.
197
+ * One rule for the turnstile and the till: an `active` membership whose period has started and
198
+ * ended no more than `grace_days` ago counts. `0` is strict; `null` is no limit.
199
+ */
200
+ export interface MembershipLapsePolicy {
201
+ grace_days: number | null;
202
+ /** What a club that has chosen nothing gets (7 today). */
203
+ default_grace_days: number;
204
+ /** The largest number of days the server accepts. */
205
+ maximum_grace_days: number;
206
+ }
207
+ export interface Membership {
208
+ id: string;
209
+ tenant_id?: string;
210
+ client_id: string;
211
+ membership_plan_id: string;
212
+ /** The plan it moves to at the next renewal (plan-change policy `next_period`), or null. */
213
+ scheduled_membership_plan_id?: string | null;
214
+ status: MembershipStatus;
215
+ started_at: string | null;
216
+ current_period_starts_at: string | null;
217
+ current_period_ends_at: string | null;
218
+ cancelled_at: string | null;
219
+ cancellation_reason: string | null;
220
+ auto_renew: boolean;
221
+ created_at: string | null;
222
+ updated_at: string | null;
223
+ plan?: MembershipPlan;
224
+ client?: {
225
+ id: string;
226
+ display_name: string;
227
+ };
228
+ periods?: MembershipPeriod[];
229
+ /** True while a freeze holds the membership (`paused` with a `frozen_until`). Read by `MembershipResource`. */
230
+ is_frozen?: boolean;
231
+ /** The day a freeze ends, if one holds. */
232
+ frozen_until?: string | null;
233
+ /** The period end once any freeze extension is counted. */
234
+ effective_ends_at?: string | null;
235
+ active_freeze?: {
236
+ id: string;
237
+ starts_at: string | null;
238
+ ends_at: string | null;
239
+ days: number;
240
+ reason: string | null;
241
+ } | null;
242
+ /**
243
+ * The moves the server accepts for this membership now (`Memberships/Internal/MembershipMoves`).
244
+ * Offer exactly these: renew is here for an expired membership only while it is inside the
245
+ * club's grace (`bookings.membership_lapse_policy`).
246
+ */
247
+ available_moves?: MembershipMove[];
248
+ /** What to do when the membership cannot continue (cancelled, or expired past the grace). */
249
+ next_step?: 'start_new_membership' | null;
250
+ /** Why an expired membership may not be renewed, in the reader's language; null otherwise. */
251
+ renewal_refusal?: {
252
+ reason: string;
253
+ message: string;
254
+ } | null;
255
+ /** The plan waiting for the next renewal (plan-change policy `next_period`), or null. */
256
+ scheduled_plan?: {
257
+ id: string;
258
+ name_en: string | null;
259
+ name_ar: string | null;
260
+ effective_on: string | null;
261
+ } | null;
262
+ }
263
+ /** A move core accepts on a membership (`available_moves`). */
264
+ export type MembershipMove = 'renew' | 'freeze' | 'unfreeze' | 'change_plan' | 'cancel_scheduled_plan_change' | 'cancel';
265
+ /**
266
+ * `GET /api/bookings/memberships/{id}/unfreeze-preview` — what lifting the freeze today does to the
267
+ * period end under the declared policy `bookings.membership_unfreeze_extension`: `trim` (default)
268
+ * takes back the unused extension days, `keep_full` keeps them. The same calculation the unfreeze
269
+ * action writes.
270
+ */
271
+ export interface MembershipUnfreezePreview {
272
+ membership_id: string;
273
+ unfreeze_extension: 'trim' | 'keep_full';
274
+ unused_days_taken_back: number;
275
+ period_ends_at_before: string | null;
276
+ period_ends_at_after: string | null;
277
+ lifted_on: string;
278
+ }
279
+ /**
280
+ * `GET /api/bookings/memberships/{id}/change-plan-preview?plan_id=` — what moving to `plan_id`
281
+ * settles under the declared policy `bookings.membership_plan_change`: `next_period` (default)
282
+ * schedules the plan for the next renewal and moves no money (all three amounts 0); `prorate_now`
283
+ * moves today, crediting the unused part of the current plan and charging the same window on the
284
+ * new one. Money is in whole MINOR units of `currency` (divide by 10^`minor_unit_exponent`);
285
+ * `net_minor` > 0 is invoiced, < 0 is credited. The same calculation the change-plan action posts.
286
+ */
287
+ export interface MembershipPlanChangePreview {
288
+ membership_id: string;
289
+ from_plan_id: string;
290
+ to_plan_id: string;
291
+ /** A plan change already scheduled for the next renewal, if any. */
292
+ scheduled_plan_id: string | null;
293
+ period_ends_at: string | null;
294
+ plan_change: 'next_period' | 'prorate_now';
295
+ currency: string;
296
+ minor_unit_exponent: number;
297
+ remaining_days: number;
298
+ total_days: number;
299
+ credit_unused_minor: number;
300
+ charge_new_plan_minor: number;
301
+ net_minor: number;
302
+ /** The day the new plan takes effect (today for `prorate_now`; null for a period with no end). */
303
+ effective_on: string | null;
304
+ /** The new plan's full price per period, charged from its first renewal. */
305
+ new_plan_price_minor: number;
306
+ }
307
+ /**
308
+ * `GET /api/bookings/memberships/{id}/renew-preview` — what renewing now does: the next period
309
+ * (on the scheduled plan when a change is waiting), its price in whole MINOR units of `currency`,
310
+ * whether this vertical posts that charge, and the unpaid balance, which the renewal carries
311
+ * forward untouched. The same terms the renew action writes.
312
+ */
313
+ export interface MembershipRenewPreview {
314
+ membership_id: string;
315
+ plan_id: string;
316
+ plan_changes_at_renewal: boolean;
317
+ period_starts_at: string;
318
+ period_ends_at: string | null;
319
+ session_credits: number | null;
320
+ currency: string;
321
+ minor_unit_exponent: number;
322
+ price_minor: number;
323
+ posts_charge: boolean;
324
+ unpaid_balance_minor: number;
325
+ unpaid_balance_handling: 'carried_forward';
326
+ }
327
+ /** `POST /api/bookings/memberships/{id}/freeze` — 1 to 365 days; the paid term is extended by the same. */
328
+ export interface FreezeMembershipInput {
329
+ days: number;
330
+ reason?: string | null;
331
+ }
332
+ export interface CreateMembershipInput {
333
+ plan_id: string;
334
+ client_id: string;
335
+ started_at: string;
336
+ auto_renew?: boolean;
337
+ }
338
+ export interface MembershipPlanAccessRule {
339
+ id: string;
340
+ tenant_id?: string;
341
+ membership_plan_id: string;
342
+ space_id: string | null;
343
+ space_type: string | null;
344
+ created_at?: string | null;
345
+ updated_at?: string | null;
346
+ /** Eager-loaded (`space:id,name_en,name_ar,type`). */
347
+ space?: Pick<BookingSpace, 'id' | 'name_en' | 'name_ar' | 'type'> | null;
348
+ }
349
+ export type MembershipDiscountType = 'percent' | 'fixed';
350
+ export interface MembershipPlanDiscount {
351
+ id: string;
352
+ tenant_id?: string;
353
+ if_member_of_plan_id: string;
354
+ then_plan_id: string;
355
+ discount_type: MembershipDiscountType;
356
+ discount_value: string;
357
+ is_active: boolean;
358
+ created_at?: string | null;
359
+ updated_at?: string | null;
360
+ /** Eager-loaded plan summaries (`id,name_en,name_ar,code`). */
361
+ if_member_of_plan?: Pick<MembershipPlan, 'id' | 'name_en' | 'name_ar' | 'code'> | null;
362
+ then_plan?: Pick<MembershipPlan, 'id' | 'name_en' | 'name_ar' | 'code'> | null;
363
+ }
364
+ /** A field on an assessment form. Numeric/scale fields feed the outcome score. */
365
+ export type AssessmentFieldType = 'number' | 'scale' | 'text' | 'textarea' | 'select';
366
+ export interface AssessmentField {
367
+ key: string;
368
+ label_en: string;
369
+ label_ar: string;
370
+ type: AssessmentFieldType;
371
+ required?: boolean;
372
+ min?: number | null;
373
+ max?: number | null;
374
+ unit?: string | null;
375
+ /** For `select` fields. */
376
+ options?: string[];
377
+ /** Include this field in the total outcome score (default: true for number/scale). */
378
+ scored?: boolean;
379
+ }
380
+ /** A form DEFINITION (schema) — a versioned, publishable assessment tool. */
381
+ /**
382
+ * A form schema row from core's Bookings forms module.
383
+ *
384
+ * Module-prefixed because `@nuwah/ui` exports an unrelated `FormSchema` — the generic
385
+ * FormBuilder/FormRenderer JSON contract, which says of itself "zero domain coupling". Same
386
+ * word, different subject: that one describes a form's SHAPE, this one is a stored row with
387
+ * a tenant, a key and a published flag. Each vertical aliases this back to `FormSchema`
388
+ * locally, the way it keeps its own word for practitioners and coaches.
389
+ */
390
+ export interface BookingsFormSchema {
391
+ id: string;
392
+ tenant_id?: string;
393
+ key: string;
394
+ name_en: string;
395
+ name_ar: string;
396
+ description: string | null;
397
+ fields: AssessmentField[];
398
+ settings: Record<string, unknown> | null;
399
+ is_platform_template: boolean;
400
+ is_published: boolean;
401
+ published_at: string | null;
402
+ superseded_at: string | null;
403
+ version: number;
404
+ parent_schema_id: string | null;
405
+ responses_count?: number;
406
+ created_at: string | null;
407
+ updated_at: string | null;
408
+ }
409
+ export interface CreateFormSchemaInput {
410
+ key: string;
411
+ name_en: string;
412
+ name_ar: string;
413
+ description?: string | null;
414
+ fields: AssessmentField[];
415
+ settings?: Record<string, unknown> | null;
416
+ }
417
+ export type UpdateFormSchemaInput = Partial<Omit<CreateFormSchemaInput, 'key'>>;
418
+ /** A single filled-in assessment (its `data` is a JSON map of field.key → answer). */
419
+ export interface FormResponse {
420
+ id: string;
421
+ tenant_id?: string;
422
+ form_schema_id: string;
423
+ /**
424
+ * Who the response is about — `bookings.subject` + a subject id for a patient. The
425
+ * form engine left Bookings, so these replaced the old `subject_id`/`session_id` FKs.
426
+ */
427
+ subject_type: string | null;
428
+ subject_id: string | null;
429
+ /** The occasion it was captured at — `bookings.session` + a session id. */
430
+ context_type: string | null;
431
+ context_id: string | null;
432
+ submitted_by_user_id: string | null;
433
+ status: 'draft' | 'submitted';
434
+ submitted_at: string | null;
435
+ /** JSON-encoded answer map (core encrypts at rest; decrypted on read). */
436
+ data: string | null;
437
+ schema_version: number;
438
+ created_at: string | null;
439
+ updated_at: string | null;
440
+ }
441
+ /** The form-engine owner keys Bookings uses (core: BookingsPersonalDataEraser, RecordFormSubmittedNotification). */
442
+ export declare const FORM_SUBJECT_TYPE_BOOKINGS_SUBJECT = "bookings.subject";
443
+ export declare const FORM_CONTEXT_TYPE_BOOKINGS_SESSION = "bookings.session";
444
+ /**
445
+ * Who a form response is about and where it was captured. `subject_id` / `session_id` are
446
+ * the Bookings shorthand (a bookings subject, a bookings session); the explicit
447
+ * `subject_type`/`context_type` pairs win when given, for owners outside Bookings.
448
+ */
449
+ export interface FormResponseOwnerInput {
450
+ subject_id?: string | null;
451
+ session_id?: string | null;
452
+ subject_type?: string | null;
453
+ context_type?: string | null;
454
+ context_id?: string | null;
455
+ }
456
+ /** The person a session/assessment is about (belongs to a booking client). */
457
+ export interface Subject {
458
+ id: string;
459
+ client_id: string | null;
460
+ display_name: string;
461
+ date_of_birth: string | null;
462
+ gender: string | null;
463
+ subject_equals_client: boolean;
464
+ created_at: string | null;
465
+ updated_at: string | null;
466
+ }
467
+ export type TreatmentPlanStatus = 'active' | 'completed' | 'cancelled';
468
+ export interface TreatmentPlan {
469
+ id: string;
470
+ tenant_id?: string;
471
+ client_id: string;
472
+ practitioner_id: string | null;
473
+ subject_id: string | null;
474
+ title: string;
475
+ description: string | null;
476
+ goals: string | null;
477
+ start_date: string | null;
478
+ end_date: string | null;
479
+ status: TreatmentPlanStatus;
480
+ notes: string | null;
481
+ sessions_count?: number;
482
+ created_at: string | null;
483
+ updated_at: string | null;
484
+ }
485
+ export interface CreateTreatmentPlanInput {
486
+ client_id: string;
487
+ /** The bookings subject the plan is about, when the client has more than one. */
488
+ subject_id?: string | null;
489
+ practitioner_id?: string | null;
490
+ title: string;
491
+ description?: string | null;
492
+ goals?: string | null;
493
+ start_date?: string | null;
494
+ end_date?: string | null;
495
+ status?: TreatmentPlanStatus;
496
+ notes?: string | null;
497
+ }
498
+ /** All plan fields are editable except `client_id` (a plan never changes patient). */
499
+ export type UpdateTreatmentPlanInput = Omit<Partial<CreateTreatmentPlanInput>, 'client_id'>;
500
+ /** The plan `show` payload eager-loads the client and counts attached sessions. */
501
+ export interface TreatmentPlanDetail extends TreatmentPlan {
502
+ client?: {
503
+ id: string;
504
+ display_name: string;
505
+ } | null;
506
+ sessions_count?: number;
507
+ }
508
+ /**
509
+ * A Session as returned by core — the raw row carries `treatment_plan_id`
510
+ * (the Session model is unguarded) even though the typed SDK Session omits it.
511
+ * We surface it here so the UI can group a plan's attached sessions.
512
+ */
513
+ export type PlanSession = Session & {
514
+ treatment_plan_id?: string | null;
515
+ };
516
+ /**
517
+ * A structured clinical note on ONE session: Subjective / Objective / Assessment
518
+ * / Plan. Core stores these encrypted-at-rest; `show` 404s when none exists yet.
519
+ */
520
+ export interface SoapNote {
521
+ id: string;
522
+ session_id: string;
523
+ subjective: string | null;
524
+ objective: string | null;
525
+ assessment: string | null;
526
+ plan: string | null;
527
+ created_at: string | null;
528
+ updated_at: string | null;
529
+ }
530
+ export interface UpsertSoapNoteInput {
531
+ subjective?: string | null;
532
+ objective?: string | null;
533
+ assessment?: string | null;
534
+ plan?: string | null;
535
+ }
536
+ /** One persisted marker on a clinical diagram (as returned by core). */
537
+ export interface ClinicalAnnotation {
538
+ id: string;
539
+ tenant_id?: string;
540
+ subject_type: string;
541
+ subject_id: string;
542
+ chart_kind: string;
543
+ marker_code: string;
544
+ x: number | null;
545
+ y: number | null;
546
+ value: string | null;
547
+ label: string | null;
548
+ note: string | null;
549
+ created_at: string | null;
550
+ updated_at: string | null;
551
+ }
552
+ /** A marker to write in a replace-set (all fields but marker_code are optional). */
553
+ export interface AnnotationInput {
554
+ marker_code: string;
555
+ x?: number | null;
556
+ y?: number | null;
557
+ value?: string | null;
558
+ label?: string | null;
559
+ note?: string | null;
560
+ }
561
+ /** One grouped-count row of the prevalence report (desc by count). */
562
+ export interface AnnotationPrevalenceRow {
563
+ marker_code: string;
564
+ count: number;
565
+ }
566
+ /**
567
+ * Coarse anatomical region for a normalised point on a front/back outline (the
568
+ * viewBox is 100×220; x,y are 0..1). Lateral clicks resolve to a left/right limb
569
+ * region; central clicks to a trunk region whose name depends on the view.
570
+ */
571
+ export declare function bodyRegionCode(view: 'front' | 'back', x: number, y: number): string;
572
+ /** Bilingual label for a bare region code (e.g. `shoulder_r` → "Shoulder (R)"). */
573
+ export declare function bodyRegionLabel(code: string): {
574
+ en: string;
575
+ ar: string;
576
+ };
577
+ /**
578
+ * Bilingual label for a full body-map `marker_code` ("<view>:<region>", or a bare
579
+ * legacy "<view>"). Combines the region name with the front/back view.
580
+ */
581
+ export declare function bodyMarkerLabel(markerCode: string): {
582
+ en: string;
583
+ ar: string;
584
+ };
585
+ export type SeriesRecurrenceRule = 'daily' | 'weekly';
586
+ export type SeriesStatus = 'active' | 'completed' | 'cancelled';
587
+ export interface SessionSeries {
588
+ id: string;
589
+ tenant_id?: string;
590
+ client_id: string;
591
+ practitioner_id: string;
592
+ session_type_id: string;
593
+ recurrence_rule: SeriesRecurrenceRule;
594
+ recurrence_interval: number;
595
+ recurrence_day_of_week: number | null;
596
+ starts_at: string;
597
+ ends_at: string | null;
598
+ session_count: number | null;
599
+ sessions_created: number;
600
+ status: SeriesStatus;
601
+ notes: string | null;
602
+ created_at: string | null;
603
+ updated_at: string | null;
604
+ /** Eager-loaded on create (`load('sessions')`). */
605
+ sessions?: Session[];
606
+ }
607
+ export interface CreateSeriesInput {
608
+ client_id: string;
609
+ /**
610
+ * Who leads every occurrence — OPTIONAL. "Every Tuesday at six for ten weeks" is how a
611
+ * club lets a pitch for a season, and nobody is leading it.
612
+ *
613
+ * A series must name a coach, a place, or both; core validates `required_without` and
614
+ * answers 422 when it has neither.
615
+ */
616
+ practitioner_id?: string;
617
+ /** The place every occurrence books. Null for a coached series with no fixed room. */
618
+ space_id?: string | null;
619
+ /**
620
+ * Which SQUAD every occurrence is for — the attribution that lets an academy's hours and
621
+ * costs be added up. Optional, and null for a booking that belongs to no squad (a rental,
622
+ * a meeting, a maintenance window).
623
+ *
624
+ * This is the path that matters for an academy: a club enters its week once as a repeating
625
+ * series, so an attribution that only worked on one-off bookings would miss almost every
626
+ * training session the academy ever has.
627
+ */
628
+ team_id?: string | null;
629
+ session_type_id: string;
630
+ recurrence_rule: SeriesRecurrenceRule;
631
+ /** Every N days/weeks (default 1). */
632
+ recurrence_interval?: number;
633
+ /** 0=Sun..6=Sat — pins a weekly series to a weekday (optional). */
634
+ recurrence_day_of_week?: number | null;
635
+ /** ISO datetime of the FIRST occurrence. */
636
+ starts_at: string;
637
+ /** Optional stop date (materialisation stops past this). */
638
+ ends_at?: string | null;
639
+ /** How many occurrences to create (1–52). */
640
+ session_count?: number | null;
641
+ duration_minutes?: number;
642
+ notes?: string | null;
643
+ }
644
+ export type BlockRecurrenceRule = 'daily' | 'weekly';
645
+ export interface AvailabilityBlock {
646
+ id: string;
647
+ tenant_id?: string;
648
+ practitioner_id: string;
649
+ title: string;
650
+ starts_at: string;
651
+ ends_at: string;
652
+ recurrence_rule: BlockRecurrenceRule | null;
653
+ recurrence_interval: number;
654
+ recurrence_day_of_week: number | null;
655
+ recurrence_ends_at: string | null;
656
+ recurrence_exceptions: string[] | null;
657
+ is_all_day: boolean;
658
+ color: string | null;
659
+ notes: string | null;
660
+ created_at: string | null;
661
+ updated_at: string | null;
662
+ }
663
+ export interface CreateCalendarBlockInput {
664
+ practitioner_id: string;
665
+ title: string;
666
+ starts_at: string;
667
+ ends_at: string;
668
+ recurrence_rule?: BlockRecurrenceRule | null;
669
+ recurrence_interval?: number;
670
+ recurrence_day_of_week?: number | null;
671
+ recurrence_ends_at?: string | null;
672
+ recurrence_exceptions?: string[] | null;
673
+ is_all_day?: boolean;
674
+ color?: string | null;
675
+ notes?: string | null;
676
+ }
677
+ export type UpdateCalendarBlockInput = Partial<Omit<CreateCalendarBlockInput, 'practitioner_id'>> & {
678
+ /** Edit/delete scope for a recurring block. Default 'series'. */
679
+ scope?: 'occurrence' | 'series';
680
+ };
681
+ export interface CalendarConfig {
682
+ tenant_id?: string;
683
+ time_start: string;
684
+ time_end: string;
685
+ slot_duration_minutes: number;
686
+ label_interval_minutes: number;
687
+ time_format: '12h' | '24h';
688
+ first_day_of_week: number;
689
+ updated_at: string | null;
690
+ }
691
+ export type ReminderChannel = string;
692
+ /** Who a session reminder is for: one of the session's parties. */
693
+ export type ReminderAudience = 'client' | 'practitioner';
694
+ export type ReminderStatus = 'pending' | 'sent' | 'failed' | 'skipped';
695
+ export interface ReminderSettings {
696
+ enabled: boolean;
697
+ /** Minutes-before-session each reminder fires (sorted longest-lead-first by core). */
698
+ lead_times_minutes: number[];
699
+ channels: ReminderChannel[];
700
+ /** Who is reminded — at least one party; "nobody" is `enabled: false`. */
701
+ audiences: ReminderAudience[];
702
+ /** Channels the platform can dispatch through (drives the settings picker). */
703
+ available_channels: ReminderChannel[];
704
+ /** Parties a tenant may remind (drives the "who is reminded" picker). */
705
+ available_audiences: ReminderAudience[];
706
+ /** True when the tenant has never saved settings (showing platform defaults). */
707
+ is_default: boolean;
708
+ channel_delivery?: Record<ReminderChannel, ReminderChannelDelivery>;
709
+ }
710
+ /** How a reminder channel delivers: `in_app`, `record_only` or `notification_service`. */
711
+ export type ReminderDeliveryRoute = 'in_app' | 'record_only' | 'notification_service' | (string & {});
712
+ export interface ReminderChannelDelivery {
713
+ /** Stable code — branch on this. */
714
+ route: ReminderDeliveryRoute;
715
+ /** The route in the reader's language ("Via the notification service"). */
716
+ label: string;
717
+ /** One sentence on what that means for the reader. */
718
+ hint: string;
719
+ }
720
+ export interface UpdateReminderSettingsInput {
721
+ enabled?: boolean;
722
+ lead_times_minutes?: number[];
723
+ channels?: ReminderChannel[];
724
+ audiences?: ReminderAudience[];
725
+ }
726
+ /** Per-channel delivery counts — a row of the stats `by_channel` breakdown. */
727
+ export interface ReminderChannelStat {
728
+ channel: ReminderChannel;
729
+ pending: number;
730
+ sent: number;
731
+ failed: number;
732
+ skipped: number;
733
+ total: number;
734
+ }
735
+ /** One side of the reminded-vs-not-reminded no-show cross-tab. */
736
+ export interface NoShowSide {
737
+ sessions: number;
738
+ no_shows: number;
739
+ /** 0..1 (no_shows ÷ sessions). */
740
+ no_show_rate: number;
741
+ }
742
+ export interface ReminderStats {
743
+ range: {
744
+ from: string;
745
+ to: string;
746
+ };
747
+ by_channel: ReminderChannelStat[];
748
+ totals: {
749
+ pending: number;
750
+ sent: number;
751
+ failed: number;
752
+ skipped: number;
753
+ };
754
+ no_show_correlation: {
755
+ reminded: NoShowSide;
756
+ not_reminded: NoShowSide;
757
+ };
758
+ }
759
+ /** A single delivery-log row (one per session · lead-window · channel · audience). */
760
+ export interface ReminderDelivery {
761
+ id: string;
762
+ tenant_id?: string;
763
+ session_id: string;
764
+ client_id: string | null;
765
+ channel: ReminderChannel;
766
+ /** The party this reminder was for. */
767
+ audience: ReminderAudience;
768
+ status: ReminderStatus;
769
+ lead_time_label: string;
770
+ lead_time_minutes: number;
771
+ scheduled_for: string;
772
+ sent_at: string | null;
773
+ error: string | null;
774
+ /**
775
+ * The stable reason code behind `error` (`reminder.no_platform_person`, …) — older rows'
776
+ * sentences map to theirs; null for free text. Branch on this, show `error_label`.
777
+ */
778
+ error_code?: string | null;
779
+ /** `error` in the reader's language (core words reason codes and older sentences). */
780
+ error_label?: string | null;
781
+ created_at: string | null;
782
+ updated_at: string | null;
783
+ }
784
+ export interface ReminderDeliveryQuery {
785
+ from?: string;
786
+ to?: string;
787
+ channel?: ReminderChannel;
788
+ status?: ReminderStatus;
789
+ session_id?: string;
790
+ per_page?: number;
791
+ }
792
+ export interface Exercise {
793
+ id: string;
794
+ tenant_id?: string;
795
+ name: string;
796
+ description: string | null;
797
+ body_region: string | null;
798
+ category: string | null;
799
+ default_sets: number | null;
800
+ default_reps: number | null;
801
+ default_hold_seconds: number | null;
802
+ media_url: string | null;
803
+ instructions: string | null;
804
+ is_active: boolean;
805
+ created_at: string | null;
806
+ updated_at: string | null;
807
+ }
808
+ export interface CreateExerciseInput {
809
+ name: string;
810
+ description?: string | null;
811
+ body_region?: string | null;
812
+ category?: string | null;
813
+ default_sets?: number | null;
814
+ default_reps?: number | null;
815
+ default_hold_seconds?: number | null;
816
+ media_url?: string | null;
817
+ instructions?: string | null;
818
+ is_active?: boolean;
819
+ }
820
+ export type UpdateExerciseInput = Partial<CreateExerciseInput>;
821
+ export interface ExerciseQuery {
822
+ body_region?: string;
823
+ category?: string;
824
+ is_active?: boolean;
825
+ search?: string;
826
+ per_page?: number;
827
+ }
828
+ export type PrescriptionStatus = 'active' | 'completed' | 'cancelled';
829
+ export interface PrescriptionItem {
830
+ id: string;
831
+ exercise_id: string | null;
832
+ exercise_name: string;
833
+ body_region: string | null;
834
+ sets: number | null;
835
+ reps: number | null;
836
+ hold_seconds: number | null;
837
+ frequency: string | null;
838
+ notes: string | null;
839
+ sort: number;
840
+ }
841
+ export interface PrescriptionItemInput {
842
+ exercise_id?: string | null;
843
+ exercise_name?: string | null;
844
+ body_region?: string | null;
845
+ sets?: number | null;
846
+ reps?: number | null;
847
+ hold_seconds?: number | null;
848
+ frequency?: string | null;
849
+ notes?: string | null;
850
+ sort?: number | null;
851
+ }
852
+ export interface Prescription {
853
+ id: string;
854
+ tenant_id?: string;
855
+ client_id: string;
856
+ treatment_plan_id: string | null;
857
+ title: string;
858
+ status: PrescriptionStatus;
859
+ notes: string | null;
860
+ assigned_at: string | null;
861
+ created_at: string | null;
862
+ updated_at: string | null;
863
+ items: PrescriptionItem[];
864
+ }
865
+ export interface CreatePrescriptionInput {
866
+ client_id: string;
867
+ treatment_plan_id?: string | null;
868
+ title: string;
869
+ /** `sometimes|in:…` in core — NOT nullable; omit it to keep the default. */
870
+ status?: PrescriptionStatus;
871
+ notes?: string | null;
872
+ assigned_at?: string | null;
873
+ items?: PrescriptionItemInput[];
874
+ }
875
+ export type UpdatePrescriptionInput = Partial<Omit<CreatePrescriptionInput, 'client_id'>>;
876
+ /**
877
+ * One adherence check-in (the patient's "done today" tap). `checkin_date` is
878
+ * normalised to `YYYY-MM-DD` by the wrapper — core casts the column to a `date`
879
+ * whose JSON is a full ISO datetime, but every consumer compares/​groups by day.
880
+ */
881
+ export interface ExerciseCheckin {
882
+ id: string;
883
+ exercise_prescription_id: string;
884
+ checkin_date: string;
885
+ created_at: string | null;
886
+ }
887
+ export interface CarePathwayExercise {
888
+ id: string;
889
+ care_pathway_id?: string;
890
+ exercise_id: string | null;
891
+ sets: number | null;
892
+ reps: number | null;
893
+ hold_seconds: number | null;
894
+ frequency: string | null;
895
+ sort: number | null;
896
+ created_at?: string | null;
897
+ updated_at?: string | null;
898
+ }
899
+ export interface CarePathwayExerciseInput {
900
+ exercise_id?: string | null;
901
+ sets?: number | null;
902
+ reps?: number | null;
903
+ hold_seconds?: number | null;
904
+ frequency?: string | null;
905
+ sort?: number | null;
906
+ }
907
+ export interface CarePathway {
908
+ id: string;
909
+ tenant_id?: string;
910
+ name: string;
911
+ body_region: string | null;
912
+ default_session_count: number | null;
913
+ goals: string[] | null;
914
+ notes: string | null;
915
+ is_active: boolean;
916
+ created_at: string | null;
917
+ updated_at: string | null;
918
+ exercises: CarePathwayExercise[];
919
+ }
920
+ export interface CreateCarePathwayInput {
921
+ name: string;
922
+ body_region?: string | null;
923
+ default_session_count?: number | null;
924
+ goals?: string[] | null;
925
+ notes?: string | null;
926
+ is_active?: boolean;
927
+ exercises?: CarePathwayExerciseInput[];
928
+ }
929
+ export type UpdateCarePathwayInput = Partial<CreateCarePathwayInput>;
930
+ /** Optional overrides when applying a pathway to a client. */
931
+ export interface ApplyCarePathwayInput {
932
+ practitioner_id?: string | null;
933
+ subject_id?: string | null;
934
+ start_date?: string | null;
935
+ /** Plan title override (defaults to the pathway name). */
936
+ title?: string | null;
937
+ /** Starter-HEP title override. */
938
+ hep_title?: string | null;
939
+ }
940
+ /** What POST /care-pathways/{id}/apply returns: the live plan + its starter HEP. */
941
+ export interface ApplyCarePathwayResult {
942
+ treatment_plan: TreatmentPlan;
943
+ prescription: Prescription;
944
+ }
945
+ /** Fields `PractitionersController::store` validates. Only `display_name` is required. */
946
+ export interface CreatePractitionerInput {
947
+ display_name: string;
948
+ specialty?: string | null;
949
+ /** `in:full_time,part_time,contractor` server-side. null = unspecified. */
950
+ employment_type?: 'full_time' | 'part_time' | 'contractor' | null;
951
+ is_senior?: boolean;
952
+ email?: string | null;
953
+ phone?: string | null;
954
+ platform_person_id?: string | null;
955
+ notes?: string | null;
956
+ }
957
+ /**
958
+ * What `PractitionersController::update` accepts, which is NOT the same list as store.
959
+ *
960
+ * It adds `status` (`in:active,inactive`) and takes no `platform_person_id` — linking an
961
+ * identity is refusable and has its own endpoint (`POST /api/v1/party/parties/{id}/link`).
962
+ *
963
+ * Every field is `sometimes`, and the controller distinguishes "sent as null" from "not sent"
964
+ * with `array_key_exists` precisely so a partial update does not wipe a specialty. So OMIT a
965
+ * field to leave it alone and send `null` to CLEAR it — the two are not interchangeable, and
966
+ * {@link coachUpdatePayload} is what enforces that at the call site.
967
+ */
968
+ export interface UpdatePractitionerInput {
969
+ display_name?: string;
970
+ specialty?: string | null;
971
+ employment_type?: 'full_time' | 'part_time' | 'contractor' | null;
972
+ is_senior?: boolean;
973
+ email?: string | null;
974
+ phone?: string | null;
975
+ notes?: string | null;
976
+ status?: 'active' | 'inactive';
977
+ }
978
+ /** Per-tenant terminology overrides for the Bookings nouns (key → {en, ar}). */
979
+ export type TerminologyMap = Record<string, {
980
+ en: string;
981
+ ar: string;
982
+ }>;
983
+ export declare function createBookingsExtraNamespace(http: Http): {
984
+ soapCompletion: (sessions: PlanSession[] | Session[], cap?: number) => Promise<{
985
+ withNote: number;
986
+ considered: number;
987
+ truncated: boolean;
988
+ }>;
989
+ terminology: {
990
+ /** GET /api/bookings/terminology — the tenant's label overrides (may be empty). */
991
+ get: () => Promise<TerminologyMap>;
992
+ /** PUT /api/bookings/terminology — replace the override map (manager only). */
993
+ update: (map: TerminologyMap) => Promise<TerminologyMap>;
994
+ };
995
+ practitioners: {
996
+ /**
997
+ * POST /api/bookings/practitioners — add a coach. Guard
998
+ * `bookings.practitioners.manage`, which `club_admin` does NOT hold (view only), so
999
+ * this is an `admin`/`owner` action in a club today.
1000
+ *
1001
+ * Creating goes through `CreatePractitionerPartyAction`, which matches an existing
1002
+ * party on EMAIL — so adding a coach who is already a member of the club adds a role
1003
+ * to that person rather than creating a second record of them. Pass the email when
1004
+ * you have it; that is what makes the de-duplication work.
1005
+ *
1006
+ * @deprecated The shim carries a `Sunset` header. Use
1007
+ * `sdk.bookings.directory.practitioners.create` — the same input, the same
1008
+ * {@link BookingPractitioner} back, and the same roles granted (the directory's
1009
+ * create and this action share one grant seam server-side). Guard `party.manage`.
1010
+ */
1011
+ create: (input: CreatePractitionerInput) => Promise<BookingPractitioner>;
1012
+ /**
1013
+ * PATCH /api/bookings/practitioners/{id} — edit a coach. Note PATCH, not PUT: the
1014
+ * route is registered as `Route::patch`, and a PUT is a 405.
1015
+ *
1016
+ * @deprecated The shim carries a `Sunset` header. Use
1017
+ * `sdk.bookings.directory.practitioners.update` — the same input, the same
1018
+ * {@link BookingPractitioner} back, written through `/api/v1/party/parties` (guard
1019
+ * `party.manage`).
1020
+ */
1021
+ update: (id: string, input: UpdatePractitionerInput) => Promise<BookingPractitioner>;
1022
+ };
1023
+ series: {
1024
+ /**
1025
+ * POST /api/bookings/sessions/series — create a recurring series. Core
1026
+ * materialises the occurrences server-side (booked status, shared
1027
+ * `series_id`) and returns the series with its `sessions` loaded.
1028
+ */
1029
+ create: (input: CreateSeriesInput) => Promise<SessionSeries>;
1030
+ /**
1031
+ * POST /api/bookings/sessions/series/{id}/cancel-from — cancel every
1032
+ * still-open occurrence on/after `from_date` (a `YYYY-MM-DD`). Returns the
1033
+ * updated series (status flips to `cancelled` when nothing remains).
1034
+ */
1035
+ cancelFrom: (seriesId: string, fromDate: string) => Promise<SessionSeries>;
1036
+ };
1037
+ calendar: {
1038
+ blocks: {
1039
+ /** GET /api/bookings/calendar/blocks?practitioner_id — raw paginator. */
1040
+ list: (query?: {
1041
+ practitioner_id?: string;
1042
+ per_page?: number;
1043
+ }) => Promise<{
1044
+ data: AvailabilityBlock[];
1045
+ meta: {
1046
+ current_page: number;
1047
+ last_page: number;
1048
+ per_page: number;
1049
+ total: number;
1050
+ };
1051
+ }>;
1052
+ /** POST /api/bookings/calendar/blocks — create a working-hours / time-off block. */
1053
+ create: (input: CreateCalendarBlockInput) => Promise<AvailabilityBlock>;
1054
+ /** PUT /api/bookings/calendar/blocks/{id} */
1055
+ update: (id: string, input: UpdateCalendarBlockInput) => Promise<AvailabilityBlock>;
1056
+ /** DELETE /api/bookings/calendar/blocks/{id} — 204. */
1057
+ remove: (id: string, scope?: "occurrence" | "series") => Promise<void>;
1058
+ };
1059
+ config: {
1060
+ /** GET /api/bookings/calendar/config — the tenant day window + slot settings. */
1061
+ get: () => Promise<CalendarConfig>;
1062
+ /** PUT /api/bookings/calendar/config */
1063
+ update: (input: Partial<Omit<CalendarConfig, "tenant_id" | "updated_at">>) => Promise<CalendarConfig>;
1064
+ };
1065
+ };
1066
+ exclusiveSpaceBlocks: {
1067
+ /**
1068
+ * GET /api/bookings/exclusive-space-blocks — windows during which a whole
1069
+ * space is reserved (no new sessions can be booked against it). Paginated
1070
+ * `{ data, meta }`, ordered by start time, with the space eager-loaded.
1071
+ */
1072
+ list: (query?: {
1073
+ space_id?: string;
1074
+ per_page?: number;
1075
+ }) => Promise<{
1076
+ data: ExclusiveSpaceBlock[];
1077
+ meta: {
1078
+ current_page: number;
1079
+ last_page: number;
1080
+ per_page: number;
1081
+ total: number;
1082
+ };
1083
+ }>;
1084
+ /**
1085
+ * POST /api/bookings/exclusive-space-blocks — reserve a space for a window.
1086
+ * Returns `{ data, existing_sessions_overlap }` (the overlap is advisory —
1087
+ * creation is never blocked; the block only prevents FUTURE bookings).
1088
+ */
1089
+ create: (input: CreateExclusiveSpaceBlockInput) => Promise<{
1090
+ data: ExclusiveSpaceBlock;
1091
+ existing_sessions_overlap: number;
1092
+ }>;
1093
+ /** DELETE /api/bookings/exclusive-space-blocks/{id} — release the space. */
1094
+ remove: (id: string) => Promise<void>;
1095
+ };
1096
+ packages: {
1097
+ /** GET /api/bookings/packages */
1098
+ list: (query?: {
1099
+ active_only?: boolean;
1100
+ per_page?: number;
1101
+ }) => Promise<Paginated<Package>>;
1102
+ /** GET /api/bookings/clients/{id}/packages */
1103
+ forClient: (clientId: string) => Promise<Paginated<ClientPackage>>;
1104
+ /** POST /api/bookings/clients/{id}/packages — assign/purchase a package. */
1105
+ purchase: (clientId: string, input: PurchasePackageInput) => Promise<ClientPackage>;
1106
+ /** POST /api/bookings/packages — create a package DEFINITION (catalog). */
1107
+ create: (input: CreatePackageInput) => Promise<Package>;
1108
+ /** PATCH /api/bookings/packages/{id} — edit a definition / deactivate. */
1109
+ update: (id: string, input: UpdatePackageInput) => Promise<Package>;
1110
+ /**
1111
+ * POST /api/bookings/client-packages/{id}/adjust — manually grant / refund /
1112
+ * correct a client package's remaining credits. Core adjusts the balance, posts
1113
+ * the matching Deferred-Revenue (2300) GL entry and writes an audit row.
1114
+ */
1115
+ adjustCredits: (clientPackageId: string, input: AdjustCreditsInput) => Promise<PackageCreditAdjustment>;
1116
+ /**
1117
+ * GET /api/bookings/packages/outstanding — tenant-wide outstanding credits +
1118
+ * Deferred-Revenue liability, redemption rate, and 30/60/90-day expiring buckets.
1119
+ */
1120
+ outstanding: () => Promise<PackagesOutstanding>;
1121
+ /**
1122
+ * GET /api/bookings/client-packages/{id}/deferred-schedule — the per-package
1123
+ * deferred drill-down: deferred-in / recognised / refunded / remaining, the
1124
+ * reconciliation flag, and the 2300 GL entries tagged to this package.
1125
+ */
1126
+ deferredSchedule: (clientPackageId: string) => Promise<PackageDeferredSchedule>;
1127
+ };
1128
+ membershipPlans: {
1129
+ /** GET /api/bookings/membership-plans (returns a plain array, not paginated). */
1130
+ list: () => Promise<MembershipPlan[]>;
1131
+ /** GET /api/bookings/membership-plans/{id} */
1132
+ get: (id: string) => Promise<MembershipPlan>;
1133
+ /** POST /api/bookings/membership-plans */
1134
+ create: (input: CreateMembershipPlanInput) => Promise<MembershipPlan>;
1135
+ /** PATCH /api/bookings/membership-plans/{id} — edit a plan / toggle is_active. */
1136
+ update: (id: string, input: UpdateMembershipPlanInput) => Promise<MembershipPlan>;
1137
+ /**
1138
+ * DELETE /api/bookings/membership-plans/{id} — 204. Core RETIRES the plan (`is_active`
1139
+ * false) rather than deleting it: existing memberships keep pointing at it, and
1140
+ * `update(id, { is_active: true })` brings it back.
1141
+ */
1142
+ remove: (id: string) => Promise<void>;
1143
+ };
1144
+ membershipAccessRules: {
1145
+ /** GET /api/bookings/membership-plans/{plan}/access-rules — `{ data }` (space eager-loaded). */
1146
+ forPlan: (planId: string) => Promise<MembershipPlanAccessRule[]>;
1147
+ /** POST /api/bookings/membership-plans/{plan}/access-rules — grant a space / space-type. */
1148
+ create: (planId: string, input: {
1149
+ space_id?: string | null;
1150
+ space_type?: string | null;
1151
+ }) => Promise<MembershipPlanAccessRule>;
1152
+ /** DELETE /api/bookings/membership-plans/{plan}/access-rules/{id} — 204. */
1153
+ remove: (planId: string, id: string) => Promise<void>;
1154
+ };
1155
+ membershipDiscounts: {
1156
+ /** GET /api/bookings/membership-plan-discounts — paginated `{ data, meta }` (plans eager-loaded). */
1157
+ list: (query?: {
1158
+ if_member_of_plan_id?: string;
1159
+ then_plan_id?: string;
1160
+ per_page?: number;
1161
+ }) => Promise<{
1162
+ data: MembershipPlanDiscount[];
1163
+ meta: {
1164
+ current_page: number;
1165
+ last_page: number;
1166
+ per_page: number;
1167
+ total: number;
1168
+ };
1169
+ }>;
1170
+ /** POST /api/bookings/membership-plan-discounts — add a cross-plan discount. */
1171
+ create: (input: {
1172
+ if_member_of_plan_id: string;
1173
+ then_plan_id: string;
1174
+ discount_type: MembershipDiscountType;
1175
+ discount_value: number;
1176
+ is_active?: boolean;
1177
+ }) => Promise<MembershipPlanDiscount>;
1178
+ /** DELETE /api/bookings/membership-plan-discounts/{id} — 204. */
1179
+ remove: (id: string) => Promise<void>;
1180
+ };
1181
+ memberships: {
1182
+ /** GET /api/bookings/memberships — eager-loads plan + client. */
1183
+ list: (query?: {
1184
+ client_id?: string;
1185
+ status?: MembershipStatus;
1186
+ per_page?: number;
1187
+ }) => Promise<Paginated<Membership>>;
1188
+ /** GET /api/bookings/memberships/{id} — eager-loads plan, client, periods. */
1189
+ get: (id: string) => Promise<Membership>;
1190
+ /** POST /api/bookings/memberships — enrol a patient in a plan. */
1191
+ create: (input: CreateMembershipInput) => Promise<Membership>;
1192
+ /** GET /api/bookings/memberships/{id}/renew-preview — the next period, its price and the unpaid balance. `{data}`-unwrapped. */
1193
+ renewPreview: (id: string) => Promise<MembershipRenewPreview>;
1194
+ /**
1195
+ * POST /api/bookings/memberships/{id}/renew — open the next billing period (on the
1196
+ * scheduled plan when a change is waiting). An unpaid balance stays owed.
1197
+ */
1198
+ renew: (id: string) => Promise<Membership>;
1199
+ /**
1200
+ * POST /api/bookings/memberships/{id}/cancel-scheduled-plan-change — the membership stays
1201
+ * on its current plan; audited, no money moves. 422 `no_scheduled_plan_change` when none waits.
1202
+ */
1203
+ cancelScheduledPlanChange: (id: string) => Promise<Membership>;
1204
+ /** POST /api/bookings/memberships/{id}/cancel */
1205
+ cancel: (id: string, reason: string) => Promise<Membership>;
1206
+ /**
1207
+ * POST /api/bookings/memberships/{id}/freeze — FreezeMembershipAction: active only;
1208
+ * status becomes `paused`, auto-renew is switched off and the paid term is extended by
1209
+ * the frozen days (nothing is forfeited).
1210
+ */
1211
+ freeze: (id: string, input: FreezeMembershipInput) => Promise<Membership>;
1212
+ /** GET /api/bookings/memberships/{id}/unfreeze-preview — the period end an unfreeze today would leave. `{data}`-unwrapped. */
1213
+ unfreezePreview: (id: string) => Promise<MembershipUnfreezePreview>;
1214
+ /**
1215
+ * POST /api/bookings/memberships/{id}/unfreeze — UnfreezeMembershipAction: paused only;
1216
+ * ends the freeze today and sets auto-renew (core's default true); the unused extension
1217
+ * follows the declared unfreeze-extension policy (see `unfreezePreview`).
1218
+ */
1219
+ unfreeze: (id: string, input?: {
1220
+ auto_renew?: boolean;
1221
+ }) => Promise<Membership>;
1222
+ /** GET /api/bookings/memberships/{id}/change-plan-preview — what moving to `planId` settles. `{data}`-unwrapped. */
1223
+ changePlanPreview: (id: string, planId: string) => Promise<MembershipPlanChangePreview>;
1224
+ /**
1225
+ * POST /api/bookings/memberships/{id}/change-plan — ChangePlanAction: active or paused;
1226
+ * follows the declared `bookings.membership_plan_change` policy — `next_period`
1227
+ * (default) schedules the plan for the next renewal with no proration; `prorate_now`
1228
+ * moves today and settles the net (invoice on upgrade, credit note on downgrade).
1229
+ * Sending the current plan while a change is scheduled cancels it.
1230
+ */
1231
+ changePlan: (id: string, planId: string) => Promise<Membership>;
1232
+ };
1233
+ /**
1234
+ * How long a membership keeps counting after its period ends — at the door (turnstile
1235
+ * entitlement) and at the till (member price) alike, since both apply one rule.
1236
+ * `{data}`-unwrapped.
1237
+ */
1238
+ membershipLapsePolicy: {
1239
+ /** GET /api/bookings/membership-lapse-policy */
1240
+ get: () => Promise<MembershipLapsePolicy>;
1241
+ /** PUT /api/bookings/membership-lapse-policy — days, 0 for strict, null for no limit. */
1242
+ update: (input: {
1243
+ grace_days: number | null;
1244
+ }) => Promise<MembershipLapsePolicy>;
1245
+ };
1246
+ forms: {
1247
+ /** GET /api/forms/schemas */
1248
+ listSchemas: (query?: {
1249
+ is_published?: boolean;
1250
+ search?: string;
1251
+ per_page?: number;
1252
+ }) => Promise<Paginated<BookingsFormSchema>>;
1253
+ /** GET /api/forms/schemas/{id} — includes responses_count. */
1254
+ getSchema: (id: string) => Promise<BookingsFormSchema>;
1255
+ /** POST /api/forms/schemas */
1256
+ createSchema: (input: CreateFormSchemaInput) => Promise<BookingsFormSchema>;
1257
+ /** PATCH /api/forms/schemas/{id} — only DRAFT schemas are editable. */
1258
+ updateSchema: (id: string, input: UpdateFormSchemaInput) => Promise<BookingsFormSchema>;
1259
+ /** POST /api/forms/schemas/{id}/publish — lock + make submittable. */
1260
+ publish: (id: string) => Promise<BookingsFormSchema>;
1261
+ /** GET /api/forms/responses */
1262
+ listResponses: (query?: FormResponseOwnerInput & {
1263
+ form_schema_id?: string;
1264
+ status?: string;
1265
+ per_page?: number;
1266
+ page?: number;
1267
+ }) => Promise<Paginated<FormResponse>>;
1268
+ /** POST /api/forms/responses — open a draft response. */
1269
+ createResponse: (input: FormResponseOwnerInput & {
1270
+ form_schema_id: string;
1271
+ }) => Promise<FormResponse>;
1272
+ /** POST /api/forms/responses/{id}/submit — finalise with answers. */
1273
+ submitResponse: (id: string, answers: Record<string, unknown>) => Promise<FormResponse>;
1274
+ /** Convenience: create + submit an assessment in one call. */
1275
+ capture: (input: FormResponseOwnerInput & {
1276
+ form_schema_id: string;
1277
+ }, answers: Record<string, unknown>) => Promise<FormResponse>;
1278
+ };
1279
+ subjects: {
1280
+ /** GET /api/bookings/subjects?client_id= */
1281
+ forClient: (clientId: string) => Promise<Paginated<Subject>>;
1282
+ /** POST /api/bookings/subjects */
1283
+ create: (input: {
1284
+ client_id: string;
1285
+ display_name: string;
1286
+ subject_equals_client?: boolean;
1287
+ }) => Promise<Subject>;
1288
+ /**
1289
+ * The subject for a client, creating a `subject_equals_client` one if none
1290
+ * exists. Assessments hang off a subject, so this guarantees a stable anchor
1291
+ * for a patient's outcome history. Returns null only if subjects are 403.
1292
+ */
1293
+ resolveForClient: (clientId: string, displayName: string) => Promise<Subject | null>;
1294
+ };
1295
+ treatmentPlans: {
1296
+ /** GET /api/bookings/treatment-plans */
1297
+ list: (query?: {
1298
+ client_id?: string;
1299
+ status?: TreatmentPlanStatus;
1300
+ per_page?: number;
1301
+ }) => Promise<Paginated<TreatmentPlan>>;
1302
+ /** GET /api/bookings/treatment-plans/{id} — eager-loads client + sessions_count. */
1303
+ get: (id: string) => Promise<TreatmentPlanDetail>;
1304
+ /** POST /api/bookings/treatment-plans */
1305
+ create: (input: CreateTreatmentPlanInput) => Promise<TreatmentPlan>;
1306
+ /** PATCH /api/bookings/treatment-plans/{id} — edit fields / change status. */
1307
+ update: (id: string, input: UpdateTreatmentPlanInput) => Promise<TreatmentPlan>;
1308
+ /** Discharge = close the plan (status → completed) with an optional summary note. */
1309
+ discharge: (id: string, summary?: string | null) => Promise<TreatmentPlan>;
1310
+ /** POST /api/bookings/treatment-plans/{plan}/sessions/{session} — attach a session; answers the SESSION. */
1311
+ attachSession: (planId: string, sessionId: string) => Promise<Session>;
1312
+ /** The sessions attached to a plan — filtered client-side by `treatment_plan_id`
1313
+ * from the plan's client's session list (core has no plan→sessions route). */
1314
+ sessions: (planId: string, clientId: string) => Promise<PlanSession[]>;
1315
+ };
1316
+ exercises: {
1317
+ /** GET /api/bookings/exercises — the reusable library (unwrapped to an array). */
1318
+ list: (query?: ExerciseQuery) => Promise<Exercise[]>;
1319
+ /** GET /api/bookings/exercises/{id}. */
1320
+ get: (id: string) => Promise<Exercise>;
1321
+ /** POST /api/bookings/exercises. */
1322
+ create: (input: CreateExerciseInput) => Promise<Exercise>;
1323
+ /** PUT /api/bookings/exercises/{id}. */
1324
+ update: (id: string, input: UpdateExerciseInput) => Promise<Exercise>;
1325
+ /** DELETE /api/bookings/exercises/{id} — 204. */
1326
+ remove: (id: string) => Promise<void>;
1327
+ };
1328
+ hep: {
1329
+ /** GET /api/bookings/exercise-prescriptions — staff HEP list (unwrapped). */
1330
+ list: (query?: {
1331
+ client_id?: string;
1332
+ status?: PrescriptionStatus;
1333
+ }) => Promise<Prescription[]>;
1334
+ /** GET /api/bookings/exercise-prescriptions/{id}. */
1335
+ get: (id: string) => Promise<Prescription>;
1336
+ /** POST /api/bookings/exercise-prescriptions. */
1337
+ create: (input: CreatePrescriptionInput) => Promise<Prescription>;
1338
+ /** PUT /api/bookings/exercise-prescriptions/{id} — items REPLACE when supplied. */
1339
+ update: (id: string, input: UpdatePrescriptionInput) => Promise<Prescription>;
1340
+ /** DELETE /api/bookings/exercise-prescriptions/{id} — soft cancel. */
1341
+ remove: (id: string) => Promise<Prescription>;
1342
+ /**
1343
+ * GET /api/bookings/exercise-prescriptions/{id}/checkins — a HEP's adherence
1344
+ * log (newest first). `checkin_date` is normalised to `YYYY-MM-DD`.
1345
+ */
1346
+ checkins: (id: string) => Promise<ExerciseCheckin[]>;
1347
+ };
1348
+ carePathways: {
1349
+ /** GET /api/bookings/care-pathways — reusable pathway templates (unwrapped). */
1350
+ list: (query?: {
1351
+ body_region?: string;
1352
+ is_active?: boolean;
1353
+ search?: string;
1354
+ }) => Promise<CarePathway[]>;
1355
+ /** GET /api/bookings/care-pathways/{id} — eager-loads exercises. */
1356
+ get: (id: string) => Promise<CarePathway>;
1357
+ /** POST /api/bookings/care-pathways. */
1358
+ create: (input: CreateCarePathwayInput) => Promise<CarePathway>;
1359
+ /** PUT /api/bookings/care-pathways/{id} — exercises REPLACE when supplied. */
1360
+ update: (id: string, input: UpdateCarePathwayInput) => Promise<CarePathway>;
1361
+ /** DELETE /api/bookings/care-pathways/{id} — 204. */
1362
+ remove: (id: string) => Promise<void>;
1363
+ /**
1364
+ * POST /api/bookings/care-pathways/{id}/apply — the one-click payoff: spawn a
1365
+ * live treatment plan + starter HEP for a client from this template, atomically.
1366
+ */
1367
+ apply: (id: string, clientId: string, overrides?: ApplyCarePathwayInput) => Promise<ApplyCarePathwayResult>;
1368
+ };
1369
+ soapNotes: {
1370
+ /** GET /api/bookings/sessions/{id}/soap-note — returns null when none exists (404). */
1371
+ get: (sessionId: string) => Promise<SoapNote | null>;
1372
+ /** POST /api/bookings/sessions/{id}/soap-note — structured S/O/A/P upsert. */
1373
+ upsert: (sessionId: string, input: UpsertSoapNoteInput) => Promise<SoapNote>;
1374
+ /** True when a session already has a SOAP note (for completion-rate reporting). */
1375
+ exists: (sessionId: string) => Promise<boolean>;
1376
+ };
1377
+ annotations: {
1378
+ /** GET /api/bookings/annotations — a subject's markers (all chart_kinds). */
1379
+ list: (subjectType: string, subjectId: string) => Promise<ClinicalAnnotation[]>;
1380
+ /** PUT /api/bookings/annotations — replace-set one subject+chart_kind. */
1381
+ replace: (subjectType: string, subjectId: string, chartKind: string, annotations: AnnotationInput[]) => Promise<ClinicalAnnotation[]>;
1382
+ /** GET /api/bookings/annotations/prevalence — grouped counts by marker_code. */
1383
+ prevalence: (chartKind: string, from?: string, to?: string) => Promise<AnnotationPrevalenceRow[]>;
1384
+ };
1385
+ reminders: {
1386
+ /** GET /api/bookings/reminders/settings — enabled + lead times + channels (perm bookings.reminders.view). */
1387
+ getSettings: () => Promise<ReminderSettings>;
1388
+ /** PUT /api/bookings/reminders/settings — update enabled / lead_times_minutes / channels / audiences (perm bookings.reminders.manage). */
1389
+ updateSettings: (input: UpdateReminderSettingsInput) => Promise<ReminderSettings>;
1390
+ /** GET /api/bookings/reminders/stats?from=&to= — delivery counts by channel + no-show correlation. */
1391
+ stats: (from?: string, to?: string) => Promise<ReminderStats>;
1392
+ /** GET /api/bookings/reminders/deliveries — paginated raw delivery log for drill-down / audit. */
1393
+ deliveries: (query?: {
1394
+ from?: string;
1395
+ to?: string;
1396
+ channel?: ReminderChannel;
1397
+ status?: ReminderStatus;
1398
+ session_id?: string;
1399
+ per_page?: number;
1400
+ }) => Promise<{
1401
+ data: ReminderDelivery[];
1402
+ meta: {
1403
+ current_page: number;
1404
+ last_page: number;
1405
+ per_page: number;
1406
+ total: number;
1407
+ };
1408
+ }>;
1409
+ };
1410
+ };
1411
+ export type BookingsExtraNamespace = ReturnType<typeof createBookingsExtraNamespace>;
1412
+ /**
1413
+ * A plan's price normalised to a MONTHLY figure in scaled units (value × 10⁴), so recurring
1414
+ * plans of different cadences can be summed into one monthly-recurring-revenue number.
1415
+ * `one_time` plans contribute nothing to recurring revenue.
1416
+ *
1417
+ * Returns scaled units rather than a string because callers aggregate before rendering;
1418
+ * `fromScaledUnits` is the one step to a decimal string.
1419
+ */
1420
+ export declare function planMonthlyUnits(plan: Pick<MembershipPlan, 'price' | 'billing_interval'>): bigint;
1421
+ /** Sum of the monthly-normalised value of a set of active memberships → a 4dp string. */
1422
+ export declare function membershipsMrr(memberships: Membership[]): string;
1423
+ /** Sum of the monthly-normalised list price of a set of plans → a 4dp string. */
1424
+ export declare function plansMonthlyValue(plans: Pick<MembershipPlan, 'price' | 'billing_interval'>[]): string;
1425
+ /** Parse a form response's JSON `data` blob into an answer map (never throws). */
1426
+ export declare function parseAnswers(data: string | null | undefined): Record<string, unknown>;
1427
+ /** The numeric/scale fields that contribute to the outcome score (opt-out via `scored:false`). */
1428
+ export declare function scoredFields(fields: AssessmentField[]): AssessmentField[];
1429
+ /**
1430
+ * The outcome score for a response = sum of its numeric/scale scored answers.
1431
+ * Returns null when the form has no scored fields or the response has no numbers,
1432
+ * so callers can render "—" rather than a misleading 0.
1433
+ */
1434
+ export declare function assessmentScore(fields: AssessmentField[], answers: Record<string, unknown>): number | null;
1435
+ /** True when an error is a missing-entitlement / forbidden response (re-export for callers). */
1436
+ export declare const isForbidden: (error: unknown) => boolean;
1437
+ /**
1438
+ * Total AVAILABLE working minutes for a practitioner across `[fromISO, toISO]`
1439
+ * (inclusive ISO dates), from their availability blocks: union of working-hour
1440
+ * windows per day, MINUS days fully covered by an all-day time-off block. A
1441
+ * practitioner with NO blocks at all falls back to `defaultWindow` minutes per
1442
+ * day (mirrors core's brand-new-practitioner fallback). Returns 0 for a
1443
+ * practitioner who HAS blocks but none applicable in the window.
1444
+ */
1445
+ export declare function practitionerAvailableMinutes(blocks: AvailabilityBlock[], fromISO: string, toISO: string, defaultWindow?: {
1446
+ start: string;
1447
+ end: string;
1448
+ }): number;