@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,416 @@
1
+
2
+
3
+ import { BLUEPRINT_BLOCK_OPTIONS, BLUEPRINT_BLOCK_TYPES, BLUEPRINT_SCHEMA_VERSION, BLUEPRINT_SCREEN_AUDIENCES } from './document.js';
4
+ const VERTICAL_KEY = /^[a-z][a-z0-9-]{2,39}$/;
5
+ const LOCAL_KEY = /^[a-z][a-z0-9_]{1,39}$/;
6
+ const CAPABILITY = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/;
7
+ const COLOUR = /^#[0-9a-fA-F]{6}$/;
8
+ const TOP_LEVEL = [
9
+ 'schema_version', 'key', 'identity', 'branding', 'modules', 'vocabulary', 'policies', 'roles', 'session_types',
10
+ 'field_sets', 'data_requests', 'onboarding_steps', 'site', 'screens', 'composed_screens', 'nav', 'demo_profile',
11
+ ];
12
+ const AUDIENCES = [...BLUEPRINT_SCREEN_AUDIENCES];
13
+ const PERSON_BLOCKS = ['wishlist', 'wallet', 'cart', 'shopping_assistant', 'catalog_browse'];
14
+ const BLOCK_PROPERTIES = ['key', 'type', 'title', 'text', 'binding', 'actions', 'open_screen', 'options'];
15
+ const BINDING_PROPERTIES = ['operation', 'sort', 'filters', 'limit', 'fields', 'measure', 'categories'];
16
+ const FIELD_TYPES = ['text', 'long_text', 'number', 'date', 'yes_no', 'choice'];
17
+ const FIELD_SET_TARGETS = ['client', 'staff', 'booking', 'item'];
18
+ const PURPOSES = ['service_delivery', 'communication', 'billing', 'legal_obligation', 'safety', 'personalisation', 'analytics', 'advertising'];
19
+ const RETENTIONS = ['legal_obligation', 'ongoing_service', 'contract'];
20
+ const RECIPIENT_MODES = ['whole_app', 'per_business'];
21
+ const DEMO_PROFILES = ['none', 'small', 'realistic'];
22
+ function isRecord(value) {
23
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
24
+ }
25
+ class IssueList {
26
+ issues = [];
27
+ add(path, en, ar) {
28
+ this.issues.push({ path, message: { en, ar } });
29
+ }
30
+ required(path) {
31
+ this.add(path, 'This is required.', 'هذا الحقل مطلوب.');
32
+ }
33
+ unknownProperties(value, allowed, path) {
34
+ for (const key of Object.keys(value)) {
35
+ if (!allowed.includes(key)) {
36
+ this.add(join(path, key), 'This field is not part of the blueprint format.', 'هذا الحقل ليس من صيغة المخطط.');
37
+ }
38
+ }
39
+ }
40
+ bilingual(value, path, maximum = 160) {
41
+ if (!isRecord(value)) {
42
+ this.add(path, 'Give this in English and Arabic.', 'اكتب هذا بالإنجليزية والعربية.');
43
+ return false;
44
+ }
45
+ this.unknownProperties(value, ['en', 'ar'], path);
46
+ let valid = true;
47
+ for (const language of ['en', 'ar']) {
48
+ const text = value[language];
49
+ if (typeof text !== 'string' || text.trim() === '') {
50
+ this.add(join(path, language), language === 'en' ? 'The English text is missing.' : 'The Arabic text is missing.', language === 'en' ? 'النص الإنجليزي ناقص.' : 'النص العربي ناقص.');
51
+ valid = false;
52
+ }
53
+ else if (text.length > maximum) {
54
+ this.add(join(path, language), `Keep this to ${maximum} characters.`, `اجعل هذا في حدود ${maximum} حرفاً.`);
55
+ valid = false;
56
+ }
57
+ }
58
+ return valid;
59
+ }
60
+
61
+ name(value, path, primary, maximum = 160) {
62
+ if (!isRecord(value)) {
63
+ this.add(path, 'Write this in English or Arabic.', 'اكتب هذا بالعربية أو بالإنجليزية.');
64
+ return false;
65
+ }
66
+ this.unknownProperties(value, ['en', 'ar'], path);
67
+ const written = [];
68
+ let valid = true;
69
+ for (const language of ['en', 'ar']) {
70
+ const text = value[language];
71
+ if (text === undefined || text === null || (typeof text === 'string' && text.trim() === ''))
72
+ continue;
73
+ if (typeof text !== 'string') {
74
+ this.add(join(path, language), 'This is text.', 'هذا نص.');
75
+ valid = false;
76
+ }
77
+ else if (text.length > maximum) {
78
+ this.add(join(path, language), `Keep this to ${maximum} characters.`, `اجعل هذا في حدود ${maximum} حرفاً.`);
79
+ valid = false;
80
+ }
81
+ else {
82
+ written.push(language);
83
+ }
84
+ }
85
+ if (primary !== null && !written.includes(primary)) {
86
+ if (primary === 'ar')
87
+ this.add(join(path, 'ar'), 'Write this in Arabic, the main language of this app. English is optional.', 'اكتب هذا بالعربية، وهي اللغة الأساسية لهذا التطبيق. الإنجليزية اختيارية.');
88
+ else
89
+ this.add(join(path, 'en'), 'Write this in English, the main language of this app. Arabic is optional.', 'اكتب هذا بالإنجليزية، وهي اللغة الأساسية لهذا التطبيق. العربية اختيارية.');
90
+ return false;
91
+ }
92
+ if (written.length === 0 && valid) {
93
+ this.add(path, 'Write this in at least one language, English or Arabic.', 'اكتب هذا بلغة واحدة على الأقل، العربية أو الإنجليزية.');
94
+ return false;
95
+ }
96
+ return valid;
97
+ }
98
+ pattern(value, pattern, path, en, ar) {
99
+ if (typeof value !== 'string' || !pattern.test(value))
100
+ this.add(path, en, ar);
101
+ }
102
+ oneOf(value, options, path) {
103
+ if (typeof value !== 'string' || !options.includes(value)) {
104
+ this.add(path, `Choose one of: ${options.join(', ')}.`, `اختر واحداً من: ${options.join('، ')}.`);
105
+ }
106
+ }
107
+ list(value, path, maximum, minimum = 0) {
108
+ if (!Array.isArray(value)) {
109
+ this.add(path, 'This must be a list.', 'يجب أن تكون هذه قائمة.');
110
+ return false;
111
+ }
112
+ if (value.length > maximum)
113
+ this.add(path, `At most ${maximum} entries.`, `${maximum} عنصراً على الأكثر.`);
114
+ if (value.length < minimum)
115
+ this.add(path, `At least ${minimum} entry is needed.`, `يلزم ${minimum} عنصر على الأقل.`);
116
+ return true;
117
+ }
118
+ localKey(value, path, seen) {
119
+ this.pattern(value, LOCAL_KEY, path, 'Use 2 to 40 lowercase letters, digits or underscores, starting with a letter.', 'استخدم من 2 إلى 40 حرفاً لاتينياً صغيراً أو رقماً أو شرطة سفلية، تبدأ بحرف.');
120
+ if (typeof value === 'string') {
121
+ if (seen.has(value))
122
+ this.add(path, 'This key is used twice.', 'هذا المفتاح مستخدم مرتين.');
123
+ seen.add(value);
124
+ }
125
+ }
126
+ }
127
+ function join(path, key) {
128
+ return path === '' ? String(key) : `${path}.${key}`;
129
+ }
130
+
131
+ export function validateBlueprint(document) {
132
+ const list = new IssueList();
133
+ if (!isRecord(document)) {
134
+ list.add('', 'A blueprint is a JSON object.', 'المخطط كائن JSON.');
135
+ return list.issues;
136
+ }
137
+ list.unknownProperties(document, TOP_LEVEL, '');
138
+ if (document.schema_version !== BLUEPRINT_SCHEMA_VERSION) {
139
+ list.add('schema_version', `This reader understands schema version "${BLUEPRINT_SCHEMA_VERSION}".`, `هذا القارئ يفهم إصدار الصيغة "${BLUEPRINT_SCHEMA_VERSION}".`);
140
+ }
141
+ if (document.key === undefined)
142
+ list.required('key');
143
+ else
144
+ list.pattern(document.key, VERTICAL_KEY, 'key', 'Use 3 to 40 lowercase letters, digits or hyphens, starting with a letter.', 'استخدم من 3 إلى 40 حرفاً لاتينياً صغيراً أو رقماً أو شرطة، تبدأ بحرف.');
145
+
146
+ const declared = isRecord(document.identity) ? document.identity.primary_language : undefined;
147
+ const primary = declared === 'en' || declared === 'ar' ? declared : null;
148
+ if (!isRecord(document.identity)) {
149
+ list.required('identity');
150
+ }
151
+ else {
152
+ list.unknownProperties(document.identity, ['name', 'tagline', 'primary_language'], 'identity');
153
+ list.name(document.identity.name, 'identity.name', primary);
154
+ if (document.identity.tagline !== undefined && document.identity.tagline !== null)
155
+ list.name(document.identity.tagline, 'identity.tagline', primary);
156
+ if (declared !== undefined && declared !== null && primary === null)
157
+ list.oneOf(declared, ['en', 'ar'], 'identity.primary_language');
158
+ }
159
+ if (document.branding !== undefined) {
160
+ if (!isRecord(document.branding)) {
161
+ list.add('branding', 'Branding is an object of colours.', 'الهوية كائن من الألوان.');
162
+ }
163
+ else {
164
+ list.unknownProperties(document.branding, ['primary_color', 'accent_color'], 'branding');
165
+ for (const colour of ['primary_color', 'accent_color']) {
166
+ const value = document.branding[colour];
167
+ if (value === undefined || (colour === 'accent_color' && value === null))
168
+ continue;
169
+ list.pattern(value, COLOUR, `branding.${colour}`, 'Use a colour like #0F766E.', 'استخدم لوناً مثل #0F766E.');
170
+ }
171
+ }
172
+ }
173
+ if (document.modules === undefined)
174
+ list.required('modules');
175
+ else
176
+ uniqueStrings(list, document.modules, 'modules', 40);
177
+ for (const section of ['vocabulary', 'policies']) {
178
+ const value = document[section];
179
+ if (value === undefined)
180
+ continue;
181
+ if (!isRecord(value)) {
182
+ list.add(section, 'This is a map of keys to values.', 'هذه خريطة من المفاتيح إلى القيم.');
183
+ continue;
184
+ }
185
+ const limit = section === 'vocabulary' ? 200 : 100;
186
+ if (Object.keys(value).length > limit)
187
+ list.add(section, `At most ${limit} entries.`, `${limit} عنصراً على الأكثر.`);
188
+ for (const [key, entry] of Object.entries(value)) {
189
+ if (section === 'vocabulary')
190
+ list.bilingual(entry, join(section, key));
191
+ else if (typeof entry !== 'string' || entry === '')
192
+ list.add(join(section, key), 'Choose an option for this policy.', 'اختر خياراً لهذه السياسة.');
193
+ }
194
+ }
195
+ entries(list, document.roles, 'roles', 30, (role, path, seen) => {
196
+ list.unknownProperties(role, ['key', 'label', 'capabilities', 'bookable', 'compliance'], path);
197
+ list.localKey(role.key, join(path, 'key'), seen);
198
+ list.name(role.label, join(path, 'label'), primary);
199
+ if (role.capabilities !== undefined && list.list(role.capabilities, join(path, 'capabilities'), 50)) {
200
+ role.capabilities.forEach((capability, index) => list.pattern(capability, CAPABILITY, join(join(path, 'capabilities'), index), 'Use a dotted capability key like bookings.recurring.', 'استخدم مفتاح قدرة منقّطاً مثل bookings.recurring.'));
201
+ }
202
+ for (const flag of ['bookable', 'compliance']) {
203
+ if (role[flag] !== undefined && typeof role[flag] !== 'boolean')
204
+ list.add(join(path, flag), 'This is yes or no.', 'هذا نعم أو لا.');
205
+ }
206
+ });
207
+ entries(list, document.session_types, 'session_types', 50, (sessionType, path, seen) => {
208
+ list.unknownProperties(sessionType, ['key', 'label', 'duration_minutes'], path);
209
+ list.localKey(sessionType.key, join(path, 'key'), seen);
210
+ list.name(sessionType.label, join(path, 'label'), primary);
211
+ const minutes = sessionType.duration_minutes;
212
+ if (typeof minutes !== 'number' || !Number.isInteger(minutes) || minutes < 5 || minutes > 1440) {
213
+ list.add(join(path, 'duration_minutes'), 'Use whole minutes from 5 to 1440.', 'استخدم دقائق صحيحة من 5 إلى 1440.');
214
+ }
215
+ });
216
+ entries(list, document.field_sets, 'field_sets', 20, (fieldSet, path, seen) => {
217
+ list.unknownProperties(fieldSet, ['key', 'label', 'applies_to', 'fields'], path);
218
+ list.localKey(fieldSet.key, join(path, 'key'), seen);
219
+ list.name(fieldSet.label, join(path, 'label'), primary);
220
+ list.oneOf(fieldSet.applies_to, FIELD_SET_TARGETS, join(path, 'applies_to'));
221
+ if (fieldSet.fields === undefined) {
222
+ list.required(join(path, 'fields'));
223
+ return;
224
+ }
225
+ entries(list, fieldSet.fields, join(path, 'fields'), 40, (field, fieldPath, fieldKeys) => {
226
+ list.unknownProperties(field, ['key', 'label', 'type', 'options', 'required'], fieldPath);
227
+ list.localKey(field.key, join(fieldPath, 'key'), fieldKeys);
228
+ list.name(field.label, join(fieldPath, 'label'), primary);
229
+ list.oneOf(field.type, FIELD_TYPES, join(fieldPath, 'type'));
230
+ if (field.options !== undefined && list.list(field.options, join(fieldPath, 'options'), 30)) {
231
+ field.options.forEach((option, index) => list.name(option, join(join(fieldPath, 'options'), index), primary));
232
+ }
233
+ if (field.required !== undefined && typeof field.required !== 'boolean')
234
+ list.add(join(fieldPath, 'required'), 'This is yes or no.', 'هذا نعم أو لا.');
235
+ }, 1);
236
+ });
237
+ entries(list, document.data_requests, 'data_requests', 30, (request, path) => {
238
+ list.unknownProperties(request, ['category', 'purpose', 'retention', 'recipient_mode', 'why'], path);
239
+ if (typeof request.category !== 'string' || request.category === '')
240
+ list.required(join(path, 'category'));
241
+ list.oneOf(request.purpose, PURPOSES, join(path, 'purpose'));
242
+ list.oneOf(request.retention, RETENTIONS, join(path, 'retention'));
243
+ list.oneOf(request.recipient_mode, RECIPIENT_MODES, join(path, 'recipient_mode'));
244
+ list.bilingual(request.why, join(path, 'why'));
245
+ });
246
+ entries(list, document.onboarding_steps, 'onboarding_steps', 12, (step, path, seen) => {
247
+ list.unknownProperties(step, ['key', 'label'], path);
248
+ list.localKey(step.key, join(path, 'key'), seen);
249
+ list.name(step.label, join(path, 'label'), primary);
250
+ });
251
+ if (document.site !== undefined && document.site !== null) {
252
+ if (!isRecord(document.site)) {
253
+ list.add('site', 'The public page is an object with a headline.', 'الصفحة العامة كائن فيه عنوان.');
254
+ }
255
+ else {
256
+ list.unknownProperties(document.site, ['headline', 'about'], 'site');
257
+ list.bilingual(document.site.headline, 'site.headline');
258
+ if (document.site.about !== undefined)
259
+ list.bilingual(document.site.about, 'site.about', 2000);
260
+ }
261
+ }
262
+ if (document.screens !== undefined)
263
+ uniqueStrings(list, document.screens, 'screens', 20);
264
+ composition(list, document, primary);
265
+ if (document.demo_profile !== undefined)
266
+ list.oneOf(document.demo_profile, DEMO_PROFILES, 'demo_profile');
267
+ return list.issues;
268
+ }
269
+
270
+ function composition(list, document, primary) {
271
+ const screenKeys = new Set();
272
+ entries(list, document.composed_screens, 'composed_screens', 20, (screen, path, seen) => {
273
+ list.unknownProperties(screen, ['key', 'title', 'audience', 'roles', 'blocks'], path);
274
+ list.localKey(screen.key, join(path, 'key'), seen);
275
+ if (typeof screen.key === 'string')
276
+ screenKeys.add(screen.key);
277
+ list.name(screen.title, join(path, 'title'), primary);
278
+ if (screen.audience !== undefined)
279
+ list.oneOf(screen.audience, AUDIENCES, join(path, 'audience'));
280
+ if (screen.roles !== undefined)
281
+ uniqueStrings(list, screen.roles, join(path, 'roles'), 30);
282
+ const audience = typeof screen.audience === 'string' ? screen.audience : 'staff';
283
+ if (audience === 'person' && Array.isArray(screen.roles) && screen.roles.length > 0) {
284
+ list.add(join(path, 'roles'), 'A person screen is for every signed-in customer, so it names no roles.', 'شاشة الأشخاص لكل عميل مسجّل، فلا تحدد أدواراً.');
285
+ }
286
+ if (screen.blocks === undefined) {
287
+ list.required(join(path, 'blocks'));
288
+ return;
289
+ }
290
+ entries(list, screen.blocks, join(path, 'blocks'), 30, (block, blockPath, blockKeys) => {
291
+ list.unknownProperties(block, BLOCK_PROPERTIES, blockPath);
292
+ list.localKey(block.key, join(blockPath, 'key'), blockKeys);
293
+ list.oneOf(block.type, [...BLUEPRINT_BLOCK_TYPES], join(blockPath, 'type'));
294
+ const personBlock = typeof block.type === 'string' && PERSON_BLOCKS.includes(block.type);
295
+ if (personBlock && audience !== 'person') {
296
+ list.add(join(blockPath, 'type'), 'This block shows the signed-in person\'s own records, so it goes on a person screen.', 'هذه الكتلة تعرض سجلات الشخص المسجّل، فمكانها شاشة الأشخاص.');
297
+ }
298
+ if (block.type === 'assistant' && audience !== 'staff') {
299
+ list.add(join(blockPath, 'type'), 'The staff assistant is for staff screens.', 'مساعد الموظفين لشاشات الموظفين.');
300
+ }
301
+ if (block.options !== undefined) {
302
+ const declared = typeof block.type === 'string' ? (BLUEPRINT_BLOCK_OPTIONS[block.type] ?? []) : [];
303
+ if (!isRecord(block.options)) {
304
+ list.add(join(blockPath, 'options'), 'Options are named yes/no choices.', 'الخيارات اختيارات مسمّاة بنعم أو لا.');
305
+ }
306
+ else {
307
+ for (const [name, value] of Object.entries(block.options)) {
308
+ if (!declared.includes(name))
309
+ list.add(join(join(blockPath, 'options'), name), 'This block does not take that option.', 'هذه الكتلة لا تأخذ هذا الخيار.');
310
+ else if (typeof value !== 'boolean')
311
+ list.add(join(join(blockPath, 'options'), name), 'An option is yes or no.', 'الخيار نعم أو لا.');
312
+ }
313
+ }
314
+ }
315
+ if (block.title !== undefined)
316
+ list.name(block.title, join(blockPath, 'title'), primary);
317
+ if (block.text !== undefined)
318
+ list.bilingual(block.text, join(blockPath, 'text'), 2000);
319
+ if (block.binding !== undefined) {
320
+ const bindingPath = join(blockPath, 'binding');
321
+ if (!isRecord(block.binding)) {
322
+ list.add(bindingPath, 'A binding names an operation.', 'الربط يسمّي عملية.');
323
+ }
324
+ else {
325
+ list.unknownProperties(block.binding, BINDING_PROPERTIES, bindingPath);
326
+ if (typeof block.binding.operation !== 'string' || block.binding.operation === '')
327
+ list.required(join(bindingPath, 'operation'));
328
+ const limit = block.binding.limit;
329
+ if (limit !== undefined && (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 50)) {
330
+ list.add(join(bindingPath, 'limit'), 'Show 1 to 50 rows.', 'اعرض من 1 إلى 50 صفاً.');
331
+ }
332
+ if (block.binding.fields !== undefined)
333
+ uniqueStrings(list, block.binding.fields, join(bindingPath, 'fields'), 20);
334
+ if (block.binding.categories !== undefined)
335
+ uniqueStrings(list, block.binding.categories, join(bindingPath, 'categories'), 20);
336
+ }
337
+ }
338
+ entries(list, block.actions, join(blockPath, 'actions'), 4, (action, actionPath, actionKeys) => {
339
+ list.unknownProperties(action, ['key', 'operation', 'label'], actionPath);
340
+ list.localKey(action.key, join(actionPath, 'key'), actionKeys);
341
+ if (typeof action.operation !== 'string' || action.operation === '')
342
+ list.required(join(actionPath, 'operation'));
343
+ list.name(action.label, join(actionPath, 'label'), primary);
344
+ });
345
+ });
346
+ });
347
+ const parents = new Map();
348
+ entries(list, document.nav, 'nav', 30, (entry, path, seen) => {
349
+ list.unknownProperties(entry, ['key', 'label', 'screen', 'pack', 'parent'], path);
350
+ list.localKey(entry.key, join(path, 'key'), seen);
351
+ list.name(entry.label, join(path, 'label'), primary);
352
+ const opensScreen = typeof entry.screen === 'string' && entry.screen !== '';
353
+ const opensPack = typeof entry.pack === 'string' && entry.pack !== '';
354
+ if (opensScreen === opensPack)
355
+ list.add(path, 'An entry opens one composed screen or one ready-made screen.', 'يفتح العنصر شاشة مركّبة واحدة أو شاشة جاهزة واحدة.');
356
+ if (opensScreen && !screenKeys.has(entry.screen))
357
+ list.add(join(path, 'screen'), 'There is no composed screen with this key.', 'لا توجد شاشة مركّبة بهذا المفتاح.');
358
+ if (typeof entry.key === 'string')
359
+ parents.set(entry.key, typeof entry.parent === 'string' ? entry.parent : null);
360
+ });
361
+ if (!Array.isArray(document.nav))
362
+ return;
363
+ document.nav.forEach((entry, index) => {
364
+ if (!isRecord(entry) || typeof entry.key !== 'string')
365
+ return;
366
+ const path = join('nav', index);
367
+ let depth = 0;
368
+ let cursor = parents.get(entry.key) ?? null;
369
+ const visited = new Set([entry.key]);
370
+ while (cursor !== null) {
371
+ if (!parents.has(cursor)) {
372
+ list.add(join(path, 'parent'), 'There is no navigation entry with this key.', 'لا يوجد عنصر تنقل بهذا المفتاح.');
373
+ return;
374
+ }
375
+ if (visited.has(cursor)) {
376
+ list.add(join(path, 'parent'), 'This entry sits inside itself; navigation never goes in a circle.', 'هذا العنصر داخل نفسه؛ التنقل لا يدور في حلقة.');
377
+ return;
378
+ }
379
+ visited.add(cursor);
380
+ depth += 1;
381
+ cursor = parents.get(cursor) ?? null;
382
+ }
383
+ if (depth > 2)
384
+ list.add(join(path, 'parent'), 'Navigation is at most three levels deep.', 'التنقل ثلاثة مستويات على الأكثر.');
385
+ });
386
+ }
387
+ function uniqueStrings(list, value, path, maximum) {
388
+ if (!list.list(value, path, maximum))
389
+ return;
390
+ const seen = new Set();
391
+ value.forEach((entry, index) => {
392
+ if (typeof entry !== 'string' || entry === '') {
393
+ list.add(join(path, index), 'Each entry is a key.', 'كل عنصر مفتاح.');
394
+ }
395
+ else if (seen.has(entry)) {
396
+ list.add(join(path, index), 'This is listed twice.', 'هذا مذكور مرتين.');
397
+ }
398
+ else {
399
+ seen.add(entry);
400
+ }
401
+ });
402
+ }
403
+ function entries(list, value, path, maximum, check, minimum = 0) {
404
+ if (value === undefined)
405
+ return;
406
+ if (!list.list(value, path, maximum, minimum))
407
+ return;
408
+ const seen = new Set();
409
+ value.forEach((entry, index) => {
410
+ const entryPath = join(path, index);
411
+ if (!isRecord(entry))
412
+ list.add(entryPath, 'Each entry is an object.', 'كل عنصر كائن.');
413
+ else
414
+ check(entry, entryPath, seen);
415
+ });
416
+ }
@@ -0,0 +1,118 @@
1
+ import type { Http } from './http.js';
2
+ import { type Party } from './party.js';
3
+ import type { Paginated } from './types.js';
4
+ import type { BookingClient, BookingPractitioner, ClientListQuery, CreateClientInput, PractitionerEmploymentType, UpdateClientInput } from './bookings.js';
5
+ import type { CreatePractitionerInput } from './bookings-extra.js';
6
+ /** The practitioner list query the shim accepted — `search`, `status`, paging. */
7
+ export interface DirectoryPractitionerListQuery {
8
+ search?: string;
9
+ status?: string;
10
+ /** `former` lists the people whose practitioner role has ended (the reinstatement view). */
11
+ role_state?: 'current' | 'former';
12
+ page?: number;
13
+ per_page?: number;
14
+ }
15
+ /**
16
+ * What a practitioner update may change — the same keys and the same omit/null rule as the
17
+ * shim's `PATCH /api/bookings/practitioners/{id}`: OMIT a key to leave it alone, send `null`
18
+ * to clear it. `is_senior: false` clears the flag (the server stores only `true`).
19
+ */
20
+ export interface DirectoryPractitionerUpdate {
21
+ display_name?: string;
22
+ email?: string | null;
23
+ phone?: string | null;
24
+ status?: 'active' | 'inactive';
25
+ specialty?: string | null;
26
+ employment_type?: PractitionerEmploymentType | null;
27
+ is_senior?: boolean;
28
+ notes?: string | null;
29
+ }
30
+ /**
31
+ * What a client update may change. `platform_person_id` is not here: linking an identity can
32
+ * be REFUSED and has its own endpoint (`sdk.party.link`); the shim silently ignored it.
33
+ */
34
+ export type DirectoryClientUpdate = Omit<UpdateClientInput, 'platform_person_id'>;
35
+ /**
36
+ * An instant in the shim's spelling. The directory answers `toIso8601String()`
37
+ * (`2026-01-04T08:00:00+00:00`); the shim answered Carbon's `toJSON()`
38
+ * (`2026-01-04T08:00:00.000000Z`). Same instant; the string is kept identical because a screen
39
+ * may compare it. An unparseable value is passed through rather than invented.
40
+ */
41
+ export declare function shimInstant(value: string | null | undefined): string | null;
42
+ /** A directory party holding `client`, in the flat shape `GET /api/bookings/clients` returned. */
43
+ export declare function bookingClientFromParty(party: Party): BookingClient;
44
+ /** A directory party holding `practitioner`, in the flat shape the practitioner shim returned. */
45
+ export declare function bookingPractitionerFromParty(party: Party): BookingPractitioner;
46
+ /**
47
+ * A directory error path, as the shim's flat field key.
48
+ *
49
+ * `attributes.gender` → `gender`
50
+ * `role_attributes.client.notes` → `notes`
51
+ * `role_attributes.client.*` → `role` (the party does not hold the role)
52
+ * anything else (`display_name`, `email`) → unchanged — the shim used the same names
53
+ */
54
+ export declare function shimErrorKey(directoryPath: string): string;
55
+ /** What a translated 422 body carries — the shim's keys first, the directory's kept beside them. */
56
+ export interface ShimValidationBody {
57
+ message: string;
58
+ message_ar?: string;
59
+ /** The shim's shape: flat field key → messages (English, as Laravel's were). */
60
+ errors: Record<string, string[]>;
61
+ /** The same keys, each message in both languages, for a screen that renders Arabic. */
62
+ errors_bilingual: Record<string, {
63
+ en: string;
64
+ ar: string;
65
+ }>;
66
+ /** The directory's own `errors`, untouched — keyed by request path. */
67
+ directory_errors: Record<string, unknown>;
68
+ }
69
+ /**
70
+ * The directory's 422 body with `errors` re-keyed to the shim's flat field names.
71
+ *
72
+ * Both of the directory's error shapes are handled: an attribute refusal (`{ en, ar }` per path)
73
+ * and Laravel's own request validation (`string[]` per path). Two paths landing on one key (a
74
+ * party `notes` and a role `notes`) keep every message. Anything that is not a 422 body with
75
+ * `errors` is returned as it came.
76
+ */
77
+ export declare function shimErrorsFromDirectory(body: unknown): unknown;
78
+ export declare function createBookingsDirectoryNamespace(http: Http): {
79
+ clients: {
80
+ /** GET /api/v1/party/parties?role=client — the shim's list. Guard `party.view`. */
81
+ list: (query?: ClientListQuery) => Promise<Paginated<BookingClient>>;
82
+ /** GET /api/v1/party/parties/{id}, then 404 unless the party is a client now. */
83
+ get: (partyId: string) => Promise<BookingClient>;
84
+ /**
85
+ * POST /api/v1/party/parties with `role: 'client'` — one request, one transaction:
86
+ * the party (matched on email when it already exists, as the shim did), the role,
87
+ * date of birth and gender, and the role's notes and usual appointment length.
88
+ * Guard `party.manage` plus each field's write grant.
89
+ */
90
+ create: (input: CreateClientInput) => Promise<BookingClient>;
91
+ /**
92
+ * The shim's PATCH, as one directory write (party and role fields, one transaction).
93
+ * Omit a key to leave it alone; `null` clears it.
94
+ */
95
+ update: (partyId: string, input: DirectoryClientUpdate) => Promise<BookingClient>;
96
+ };
97
+ practitioners: {
98
+ /**
99
+ * GET /api/v1/party/parties?role=practitioner. Guard `party.view`. `search` covers
100
+ * name, email, phone and specialty (a `searchable` field), as the shim's did.
101
+ */
102
+ list: (query?: DirectoryPractitionerListQuery) => Promise<Paginated<BookingPractitioner>>;
103
+ /**
104
+ * POST /api/v1/party/parties with `role: 'practitioner'` — one request, one
105
+ * transaction: the party (matched on email when it already exists, so a patient who
106
+ * joins the staff gains a role rather than a second record), the practitioner role
107
+ * AND every role the vertical implies (a club coach also gets `coach`), and the
108
+ * role's specialty, employment type, seniority and notes. Guard `party.manage` plus
109
+ * each field's write grant. Replaces `sdk.bookingsExtra.practitioners.create`.
110
+ */
111
+ create: (input: CreatePractitionerInput) => Promise<BookingPractitioner>;
112
+ /** GET /api/v1/party/parties/{id}, then 404 unless the party practises here now. */
113
+ get: (partyId: string) => Promise<BookingPractitioner>;
114
+ /** The shim's PATCH, as one directory write. `is_senior: false` clears the flag. */
115
+ update: (partyId: string, input: DirectoryPractitionerUpdate) => Promise<BookingPractitioner>;
116
+ };
117
+ };
118
+ export type BookingsDirectoryNamespace = ReturnType<typeof createBookingsDirectoryNamespace>;