@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,305 @@
1
+
2
+
3
+ import { createHttp } from './http.js';
4
+ import { createBookingsDirectoryNamespace } from './bookings-directory.js';
5
+ export * from './bookings-directory.js';
6
+
7
+ export * from './names.js';
8
+
9
+ export const SPACE_TYPES = [
10
+ 'room',
11
+ 'jacuzzi',
12
+ 'gym',
13
+ 'pool',
14
+ 'assessment',
15
+ 'treatment',
16
+
17
+ 'field',
18
+ 'court',
19
+ 'lane',
20
+ 'hall',
21
+ 'studio',
22
+ 'track',
23
+ 'other',
24
+ ];
25
+
26
+ export function sessionTypeAllowsSpaceType(sessionType, spaceType) {
27
+ const allowed = sessionType?.space_types;
28
+ if (!Array.isArray(allowed) || allowed.length === 0)
29
+ return true;
30
+ if (!spaceType)
31
+ return true;
32
+ return allowed.includes(spaceType);
33
+ }
34
+
35
+ export function isRevealedRating(row) {
36
+ return !row.withheld && row.stars !== null;
37
+ }
38
+ export function createBookingsNamespace(http) {
39
+ return {
40
+
41
+ clients: {
42
+
43
+ list: (query) => http.get('/api/bookings/clients', { params: query }),
44
+
45
+ get: (id) => http.get(`/api/bookings/clients/${id}`),
46
+
47
+ create: (input) => http.post('/api/bookings/clients', input),
48
+
49
+ update: (id, input) => http.patch(`/api/bookings/clients/${id}`, input),
50
+
51
+ sessions: (id, query) => http.get(`/api/bookings/clients/${id}/sessions`, { params: query }),
52
+ },
53
+
54
+ directory: createBookingsDirectoryNamespace(http),
55
+
56
+ practitioners: {
57
+
58
+ list: (query) => http.get('/api/bookings/practitioners', { params: query }),
59
+
60
+ get: (id) => http.get(`/api/bookings/practitioners/${id}`),
61
+ },
62
+ sessionTypes: {
63
+
64
+ list: (query) => http.get('/api/bookings/session-types', { params: query }),
65
+
66
+ create: (input) => http.post('/api/bookings/session-types', input),
67
+
68
+ update: (id, input) => http.patch(`/api/bookings/session-types/${id}`, input),
69
+
70
+ remove: (id) => http.delete(`/api/bookings/session-types/${id}`),
71
+ },
72
+ locations: {
73
+
74
+ list: (query) => http.get('/api/bookings/locations', { params: query }),
75
+
76
+ get: (id) => http.get(`/api/bookings/locations/${id}`),
77
+
78
+ create: (input) => http.post('/api/bookings/locations', input),
79
+
80
+ update: (id, input) => http.patch(`/api/bookings/locations/${id}`, input),
81
+
82
+ remove: (id) => http.delete(`/api/bookings/locations/${id}`),
83
+
84
+ hours: {
85
+
86
+ get: (locationId) => http.get(`/api/bookings/locations/${locationId}/hours`),
87
+
88
+ set: (locationId, days) => http.put(`/api/bookings/locations/${locationId}/hours`, { hours: days }),
89
+ },
90
+ },
91
+ spaces: {
92
+
93
+ list: (query) => http.get('/api/bookings/spaces', { params: query }),
94
+
95
+ get: (id) => http.get(`/api/bookings/spaces/${id}`),
96
+
97
+ create: (input) => http.post('/api/bookings/spaces', input),
98
+
99
+ update: (id, input) => http.patch(`/api/bookings/spaces/${id}`, input),
100
+
101
+ remove: (id) => http.delete(`/api/bookings/spaces/${id}`),
102
+
103
+ uploadPhoto: (id, file) => {
104
+ const body = new FormData();
105
+ body.append('file', file);
106
+ return http.post(`/api/bookings/spaces/${id}/photo`, body);
107
+ },
108
+
109
+ photoStaging: '/api/bookings/staged-uploads/space-photos',
110
+
111
+ setStagedPhoto: (id, token) => http.post(`/api/bookings/spaces/${id}/photo`, { staged_upload_token: token }),
112
+
113
+ deletePhoto: (id) => http.delete(`/api/bookings/spaces/${id}/photo`),
114
+ },
115
+ sessions: {
116
+
117
+ list: (query) => http.get('/api/bookings/sessions', { params: query }),
118
+
119
+ get: (id) => http.get(`/api/bookings/sessions/${id}`),
120
+
121
+ create: (input) => http.post('/api/bookings/sessions', input),
122
+
123
+ update: (id, input) => http.patch(`/api/bookings/sessions/${id}`, input),
124
+
125
+ confirm: (id) => http.post(`/api/bookings/sessions/${id}/confirm`),
126
+
127
+ cancel: (id, reason, waiveFee) => http.post(`/api/bookings/sessions/${id}/cancel`, { reason, waive_fee: waiveFee }),
128
+
129
+ complete: (id) => http.post(`/api/bookings/sessions/${id}/complete`),
130
+
131
+ start: (id, startedByUserId) => http.post(`/api/bookings/sessions/${id}/start`, {
132
+ started_by_user_id: startedByUserId,
133
+ }),
134
+
135
+ noShow: (id, waiveFee) => http.post(`/api/bookings/sessions/${id}/no-show`, waiveFee === undefined ? undefined : { waive_fee: waiveFee }),
136
+
137
+ reinstate: (id) => http.post(`/api/bookings/sessions/${id}/reinstate`),
138
+
139
+ undoCheckIn: (id) => http.post(`/api/bookings/sessions/${id}/undo-check-in`),
140
+
141
+ undoNoShow: (id) => http.post(`/api/bookings/sessions/${id}/undo-no-show`),
142
+
143
+ history: (id) => http.get(`/api/bookings/sessions/${id}/history`),
144
+
145
+ punctuality: (query) => http.get('/api/bookings/reports/punctuality', { params: query }),
146
+
147
+ reschedule: (id, input) => http.post(`/api/bookings/sessions/${id}/reschedule`, input),
148
+
149
+ checkConflict: (query) => http.get('/api/bookings/sessions/check-conflict', { params: query }),
150
+ },
151
+
152
+ availability: (query) => http.get('/api/bookings/availability', { params: query }),
153
+
154
+ activity: (query) => http.get('/api/bookings/reports/activity', {
155
+ params: query,
156
+ }),
157
+
158
+ clinicProfile: {
159
+
160
+ get: () => http.get('/api/bookings/clinic-profile'),
161
+
162
+ update: (input) => http.put('/api/bookings/clinic-profile', input),
163
+ },
164
+
165
+ bookingSettings: {
166
+
167
+ get: () => http.get('/api/bookings/booking-settings'),
168
+
169
+ update: (input) => http.put('/api/bookings/booking-settings', input),
170
+ },
171
+
172
+ reschedulePolicy: {
173
+
174
+ get: () => http
175
+ .get('/api/bookings/reschedule-policy')
176
+ .then((r) => r.data),
177
+
178
+ update: (input) => http
179
+ .put('/api/bookings/reschedule-policy', input)
180
+ .then((r) => r.data),
181
+ },
182
+
183
+ confirmationPolicy: {
184
+
185
+ get: () => http
186
+ .get('/api/bookings/confirmation-policy')
187
+ .then((r) => r.data),
188
+
189
+ update: (input) => http
190
+ .put('/api/bookings/confirmation-policy', input)
191
+ .then((r) => r.data),
192
+ },
193
+
194
+ confirmations: {
195
+
196
+ list: (date) => http
197
+ .get('/api/bookings/confirmations', {
198
+ params: date ? { date } : undefined,
199
+ })
200
+ .then((r) => r.data),
201
+
202
+ recordOutcome: (sessionId, outcome, note) => http
203
+ .post(`/api/bookings/confirmations/${sessionId}/outcome`, { outcome, note })
204
+ .then((r) => r.data),
205
+ },
206
+ insurance: {
207
+ insurers: {
208
+
209
+ list: (query) => http.get('/api/bookings/insurers', { params: query }),
210
+
211
+ get: (id) => http.get(`/api/bookings/insurers/${id}`),
212
+
213
+ create: (input) => http.post('/api/bookings/insurers', input),
214
+
215
+ update: (id, input) => http.patch(`/api/bookings/insurers/${id}`, input),
216
+
217
+ remove: (id) => http.delete(`/api/bookings/insurers/${id}`),
218
+ },
219
+ plans: {
220
+
221
+ list: (query) => http.get('/api/bookings/insurance-plans', {
222
+ params: query,
223
+ }),
224
+
225
+ get: (id) => http.get(`/api/bookings/insurance-plans/${id}`),
226
+
227
+ create: (input) => http.post('/api/bookings/insurance-plans', input),
228
+
229
+ update: (id, input) => http.patch(`/api/bookings/insurance-plans/${id}`, input),
230
+
231
+ remove: (id) => http.delete(`/api/bookings/insurance-plans/${id}`),
232
+ },
233
+ policies: {
234
+
235
+ list: (query) => http.get('/api/bookings/insurance-policies', {
236
+ params: query,
237
+ }),
238
+
239
+ get: (id) => http.get(`/api/bookings/insurance-policies/${id}`),
240
+
241
+ create: (input) => http.post('/api/bookings/insurance-policies', input),
242
+
243
+ update: (id, input) => http.patch(`/api/bookings/insurance-policies/${id}`, input),
244
+ },
245
+ },
246
+ insuranceAuthorizations: {
247
+
248
+ list: (query) => http.get('/api/bookings/insurance-authorizations', { params: query }),
249
+
250
+ create: (input) => http.post('/api/bookings/insurance-authorizations', input),
251
+ },
252
+
253
+ ratings: {
254
+
255
+ list: (query) => http.get('/api/bookings/ratings', { params: query }),
256
+
257
+ forSession: (sessionId) => http.get(`/api/bookings/sessions/${sessionId}/rating`),
258
+
259
+ rate: (sessionId, input) => http.post(`/api/bookings/sessions/${sessionId}/rate`, input),
260
+ },
261
+
262
+ waitlist: {
263
+
264
+ list: (status) => http
265
+ .get('/api/bookings/waitlist', { params: { status } })
266
+ .then((r) => r.data),
267
+
268
+ get: (id) => http
269
+ .get(`/api/bookings/waitlist/${id}`)
270
+ .then((r) => r.data),
271
+
272
+ create: (input) => http
273
+ .post('/api/bookings/waitlist', input)
274
+ .then((r) => r.data),
275
+
276
+ update: (id, input) => http
277
+ .patch(`/api/bookings/waitlist/${id}`, input)
278
+ .then((r) => r.data),
279
+
280
+ remove: (id) => http.delete(`/api/bookings/waitlist/${id}`),
281
+
282
+ accept: (id) => http
283
+ .post(`/api/bookings/waitlist/${id}/accept`, {})
284
+ .then((r) => r.data),
285
+
286
+ decline: (id, response) => http.post(`/api/bookings/waitlist/${id}/decline`, { response }),
287
+ },
288
+ };
289
+ }
290
+
291
+ export function createPublicBookingClient(config) {
292
+ const httpConfig = {
293
+ baseUrl: config.baseUrl,
294
+ getToken: () => '',
295
+ fetch: config.fetch,
296
+ defaultHeaders: config.defaultHeaders,
297
+ };
298
+ const http = createHttp(httpConfig);
299
+ const base = (slug) => `/api/public/${encodeURIComponent(slug)}`;
300
+ return {
301
+ clinic: (slug) => http.get(`${base(slug)}/clinic`),
302
+ availability: (slug, query) => http.get(`${base(slug)}/availability`, { params: query }),
303
+ book: (slug, input) => http.post(`${base(slug)}/bookings`, input),
304
+ };
305
+ }
@@ -0,0 +1,164 @@
1
+ import type { AiBilingualText } from './ai.js';
2
+ import type { Http, RequestOptions } from './http.js';
3
+ export type BuilderCodeCiStatus = 'passed' | 'failed' | 'pending';
4
+ export type BuilderCodeReviewDecision = 'pending' | 'approved' | 'rejected';
5
+ export type BuilderCodeCheckKey = 'install' | 'tests' | 'npm_audit' | 'semgrep' | 'gitleaks' | 'contract_check' | 'build';
6
+ export interface BuilderCodeFile {
7
+ path: string;
8
+ bytes: number;
9
+ digest: string;
10
+ written_at: string;
11
+ is_test: boolean;
12
+ }
13
+ export interface BuilderCodeAdapter {
14
+ directory: string;
15
+ core_gap_id: string;
16
+ }
17
+ export interface BuilderCodeDiffFile {
18
+ path: string;
19
+ change: 'added' | 'modified' | 'deleted' | 'renamed';
20
+ additions: number;
21
+ deletions: number;
22
+ }
23
+ export interface BuilderCodeDiffSummary {
24
+ files: BuilderCodeDiffFile[];
25
+ totals: {
26
+ files: number;
27
+ additions: number;
28
+ deletions: number;
29
+ };
30
+ /** `builder_files` when CI sent no diff and the builder's own file index stood in. */
31
+ source?: string;
32
+ }
33
+ export interface BuilderCodeCiResult {
34
+ id: string;
35
+ commit_sha: string;
36
+ status: BuilderCodeCiStatus;
37
+ test_count: number | null;
38
+ checks: {
39
+ key: BuilderCodeCheckKey;
40
+ status: BuilderCodeCiStatus;
41
+ }[];
42
+ diff_summary: BuilderCodeDiffSummary | null;
43
+ warnings: string[];
44
+ source: 'ci' | 'operator';
45
+ run_url: string | null;
46
+ reported_at: string;
47
+ }
48
+ export interface BuilderCodeRelease {
49
+ id: string;
50
+ blueprint: {
51
+ id: string;
52
+ key: string;
53
+ name: AiBilingualText;
54
+ };
55
+ commit_sha: string;
56
+ ci_status: BuilderCodeCiStatus;
57
+ test_count: number | null;
58
+ previous_test_count: number | null;
59
+ test_count_dropped: boolean;
60
+ test_count_acknowledged_at: string | null;
61
+ decision: BuilderCodeReviewDecision;
62
+ requested_at: string;
63
+ decided_at: string | null;
64
+ /** The reviewer's notes, which the developer reads on a rejection. */
65
+ notes: string | null;
66
+ diff_summary: BuilderCodeDiffSummary;
67
+ ci: {
68
+ status: BuilderCodeCiStatus;
69
+ checks: {
70
+ key: BuilderCodeCheckKey;
71
+ status: BuilderCodeCiStatus;
72
+ }[];
73
+ warnings: string[];
74
+ run_url: string | null;
75
+ reported_at: string;
76
+ source: 'ci' | 'operator';
77
+ } | null;
78
+ session_id: string | null;
79
+ }
80
+ export interface BuilderCodeCommit {
81
+ id: string;
82
+ branch: string;
83
+ commit_sha: string;
84
+ parent_sha: string | null;
85
+ origin: 'builder' | 'outside';
86
+ change_ids: string[];
87
+ toolkit_run_id: string | null;
88
+ paths: string[];
89
+ committed_at: string;
90
+ ci: {
91
+ status: BuilderCodeCiStatus;
92
+ reported_at: string;
93
+ run_url: string | null;
94
+ source: 'ci' | 'operator';
95
+ } | null;
96
+ }
97
+ /**
98
+ * The working branch the builder commits confirmed code to (`nuwah/workspace`, never `main`) and
99
+ * the head the sandbox workspace is built on. `latest_green_commit` is what a release takes.
100
+ */
101
+ export interface BuilderCodeWorkspace {
102
+ branch: string;
103
+ head_sha: string | null;
104
+ refreshed_at: string | null;
105
+ commits: BuilderCodeCommit[];
106
+ latest_green_commit: string | null;
107
+ }
108
+ /** What `refresh` answers: the workspace plus what the refresh brought back into the sandbox. */
109
+ export interface BuilderCodeRefreshResult extends BuilderCodeWorkspace {
110
+ refreshed: {
111
+ from: string | null;
112
+ to: string | null;
113
+ files_written: string[];
114
+ truncated: boolean;
115
+ };
116
+ }
117
+ /**
118
+ * `details` of the 409 `workspace_out_of_date` a confirm answers when the working branch moved
119
+ * outside the builder: call `refresh`, then confirm again. Nothing was committed or force-pushed.
120
+ */
121
+ export interface BuilderCodeWorkspaceOutOfDate {
122
+ action: 'refresh_workspace';
123
+ branch: string;
124
+ workspace_head: string | null;
125
+ repository_head: string | null;
126
+ }
127
+ export interface BuilderCodeOverview {
128
+ /** `builder.availability = level_3` on the platform. */
129
+ level_3_open: boolean;
130
+ /** The blueprint was moved to custom code (it has a repository). */
131
+ ejected: boolean;
132
+ has_open_session: boolean;
133
+ writable_folders: string[];
134
+ files: BuilderCodeFile[];
135
+ adapters: BuilderCodeAdapter[];
136
+ ci: BuilderCodeCiResult | null;
137
+ releases: BuilderCodeRelease[];
138
+ approved_commit: string | null;
139
+ /** The working branch and its commits; null before the app has a repository. */
140
+ workspace: BuilderCodeWorkspace | null;
141
+ }
142
+ export interface BuilderCodeFileContent {
143
+ path: string;
144
+ exists: boolean;
145
+ writable: boolean;
146
+ bytes?: number;
147
+ truncated?: boolean;
148
+ content?: string;
149
+ }
150
+ /** The code tools whose proposals the Code tab lists (the rest stay in the chat). */
151
+ export declare const BUILDER_CODE_TOOLS: readonly ["write_file", "apply_patch", "create_adapter", "propose_release"];
152
+ export declare function createBuilderCodeNamespace(http: Http): {
153
+ /** GET api/builder/blueprints/{id}/code */
154
+ get: (blueprintId: string, options?: RequestOptions) => Promise<BuilderCodeOverview>;
155
+ /** GET api/builder/blueprints/{id}/code/file?path= */
156
+ file: (blueprintId: string, path: string, options?: RequestOptions) => Promise<BuilderCodeFileContent>;
157
+ /**
158
+ * POST api/builder/blueprints/{id}/code/refresh — bring the working branch's files back into
159
+ * the sandbox after pushes from outside the builder (the action of a 409
160
+ * `workspace_out_of_date`). Needs an open building session.
161
+ */
162
+ refresh: (blueprintId: string, options?: RequestOptions) => Promise<BuilderCodeRefreshResult>;
163
+ };
164
+ export type BuilderCodeNamespace = ReturnType<typeof createBuilderCodeNamespace>;
@@ -0,0 +1,12 @@
1
+
2
+ export const BUILDER_CODE_TOOLS = ['write_file', 'apply_patch', 'create_adapter', 'propose_release'];
3
+ export function createBuilderCodeNamespace(http) {
4
+ return {
5
+
6
+ get: (blueprintId, options) => http.get(`/api/builder/blueprints/${encodeURIComponent(blueprintId)}/code`, options).then((response) => response.data),
7
+
8
+ file: (blueprintId, path, options) => http.get(`/api/builder/blueprints/${encodeURIComponent(blueprintId)}/code/file?path=${encodeURIComponent(path)}`, options).then((response) => response.data),
9
+
10
+ refresh: (blueprintId, options) => http.post(`/api/builder/blueprints/${encodeURIComponent(blueprintId)}/code/refresh`, {}, options).then((response) => response.data),
11
+ };
12
+ }
@@ -0,0 +1,83 @@
1
+ import type { AiBilingualText } from './ai.js';
2
+ import type { Http } from './http.js';
3
+ export type BuilderCoreGapStatusValue = 'recorded' | 'triaged' | 'duplicate' | 'planned' | 'shipped' | 'wont_do';
4
+ export type BuilderCoreGapClusterStatus = 'suggested' | 'open' | 'decided' | 'dismissed';
5
+ export type BuilderCoreGapDecision = 'planned' | 'wont_do' | 'duplicate' | 'shipped';
6
+ export type BuilderSwapProposalState = 'open' | 'accepted' | 'rejected' | 'failed';
7
+ export interface BuilderSwapProposal {
8
+ id: string;
9
+ gap_id: string;
10
+ cluster_id: string | null;
11
+ blueprint_id: string;
12
+ shipped_ref: string;
13
+ driver: 'local_bare_git' | 'github_org';
14
+ repository_name: string;
15
+ /** Always under `nuwah/`; never `main`. */
16
+ branch: string;
17
+ base_branch: 'main';
18
+ base_commit: string | null;
19
+ head_commit: string | null;
20
+ /** Set when the host has pull requests of its own (GitHub). */
21
+ pull_request_number: number | null;
22
+ pull_request_url: string | null;
23
+ changed_paths: string[];
24
+ title: AiBilingualText | null;
25
+ body: AiBilingualText | null;
26
+ state: BuilderSwapProposalState;
27
+ /** `repo_host_unavailable`, `nothing_to_change`. */
28
+ failure_reason: string | null;
29
+ merged_commit: string | null;
30
+ decision_note: string | null;
31
+ decided_at: string | null;
32
+ created_at: string;
33
+ }
34
+ export interface BuilderCoreGapWithStatus {
35
+ id: string;
36
+ need: AiBilingualText | null;
37
+ why: AiBilingualText | null;
38
+ category: string;
39
+ workaround_kind: 'adapter' | 'extension' | 'manual' | 'none';
40
+ adapter_path: string | null;
41
+ status: BuilderCoreGapStatusValue;
42
+ shipped_ref: string | null;
43
+ created_at: string;
44
+ blueprint: {
45
+ id: string;
46
+ key: string;
47
+ name?: {
48
+ en: string;
49
+ ar: string;
50
+ };
51
+ } | null;
52
+ /** The builder session it was asked in (B-UX), for a link back to the conversation. */
53
+ session_id?: string | null;
54
+ /** What the operator who triaged it wrote back to the developer, and when. */
55
+ operator_note?: string | null;
56
+ triaged_at?: string | null;
57
+ cluster: {
58
+ id: string;
59
+ title: AiBilingualText | null;
60
+ status: BuilderCoreGapClusterStatus;
61
+ decision: BuilderCoreGapDecision | null;
62
+ decided_at: string | null;
63
+ /** Developers whose gap is in the same cluster, this one included. */
64
+ developers_sharing: number;
65
+ } | null;
66
+ proposals: BuilderSwapProposal[];
67
+ }
68
+ export interface BuilderCoreGapStatus {
69
+ gaps: BuilderCoreGapWithStatus[];
70
+ proposals: BuilderSwapProposal[];
71
+ counts: {
72
+ total: number;
73
+ shipped: number;
74
+ planned: number;
75
+ open_proposals: number;
76
+ };
77
+ }
78
+ export interface BuilderCoreGapsNamespace {
79
+ status(blueprintId?: string | null): Promise<BuilderCoreGapStatus>;
80
+ acceptSwap(proposalId: string, note?: string | null): Promise<BuilderSwapProposal>;
81
+ rejectSwap(proposalId: string, note?: string | null): Promise<BuilderSwapProposal>;
82
+ }
83
+ export declare function createBuilderCoreGapsNamespace(http: Http): BuilderCoreGapsNamespace;
@@ -0,0 +1,8 @@
1
+ export function createBuilderCoreGapsNamespace(http) {
2
+ const id = encodeURIComponent;
3
+ return {
4
+ status: async (blueprintId) => (await http.get(`/api/builder/core-gaps/status${blueprintId ? `?blueprint_id=${id(blueprintId)}` : ''}`)).data,
5
+ acceptSwap: async (proposalId, note) => (await http.post(`/api/builder/core-gap-swaps/${id(proposalId)}/accept`, { note: note ?? null })).data,
6
+ rejectSwap: async (proposalId, note) => (await http.post(`/api/builder/core-gap-swaps/${id(proposalId)}/reject`, { note: note ?? null })).data,
7
+ };
8
+ }
@@ -0,0 +1,73 @@
1
+ import type { AiBilingualText } from './ai.js';
2
+ import type { Http, NuwahClientConfig, RequestOptions } from './http.js';
3
+ export type BuilderRepoDriver = 'local_bare_git' | 'github_org';
4
+ export type BuilderRepoHostingChoice = 'none' | BuilderRepoDriver;
5
+ export interface BuilderRepoConsequences {
6
+ /** The statement's version; the accepted one is stored on the repository. */
7
+ version: string;
8
+ points: AiBilingualText[];
9
+ }
10
+ export interface BuilderRepoState {
11
+ default_branch: string;
12
+ head_commit: string | null;
13
+ last_committed_at: string | null;
14
+ /** History length of the default branch; null when the host cannot answer it cheaply. */
15
+ commit_count: number | null;
16
+ branches: {
17
+ name: string;
18
+ commit: string;
19
+ }[];
20
+ default_branch_protected: boolean;
21
+ }
22
+ export interface BuilderRepository {
23
+ driver: BuilderRepoDriver;
24
+ /** What the platform policy asked for; differs when the local driver stood in for GitHub. */
25
+ requested_driver: BuilderRepoDriver;
26
+ repository_name: string;
27
+ /** What to clone: a server path (local driver) or an https URL. Never carries a credential. */
28
+ clone_address: string;
29
+ default_branch: string;
30
+ protected_branch: string;
31
+ seed_commit: string;
32
+ seed_version: number;
33
+ contract_digest: string;
34
+ consequences_accepted: string;
35
+ ejected_at: string;
36
+ last_exported_at: string | null;
37
+ export_count: number;
38
+ state: BuilderRepoState | null;
39
+ /** The host could not be read just now; the stored facts above still hold. */
40
+ state_unavailable: boolean;
41
+ }
42
+ export interface BuilderRepoStatus {
43
+ ejected: boolean;
44
+ /** Whether the platform currently allows level 3 (`builder.availability = level_3`). */
45
+ level_3_open: boolean;
46
+ hosting: {
47
+ chosen: BuilderRepoHostingChoice;
48
+ effective: BuilderRepoDriver | null;
49
+ };
50
+ consequences: BuilderRepoConsequences;
51
+ repository: BuilderRepository | null;
52
+ }
53
+ export interface BuilderEjectInput {
54
+ /** The app key, typed by the developer as the confirmation. */
55
+ confirm_key: string;
56
+ accept_consequences: true;
57
+ }
58
+ export interface BuilderRepoBundle {
59
+ blob: Blob;
60
+ filename: string;
61
+ }
62
+ export declare function createBuilderReposNamespace(http: Http, config: NuwahClientConfig): {
63
+ /** GET api/builder/blueprints/{id}/repo */
64
+ get: (blueprintId: string, options?: RequestOptions) => Promise<BuilderRepoStatus>;
65
+ /** POST api/builder/blueprints/{id}/repo — eject to level 3 (one-way, audited). 201. */
66
+ eject: (blueprintId: string, input: BuilderEjectInput, options?: RequestOptions) => Promise<BuilderRepoStatus>;
67
+ /**
68
+ * POST api/builder/blueprints/{id}/repo/export — the repository as a git bundle, full history.
69
+ * Binary, so fetched directly with the same bearer token (the transport parses JSON).
70
+ */
71
+ exportBundle: (blueprintId: string) => Promise<BuilderRepoBundle>;
72
+ };
73
+ export type BuilderReposNamespace = ReturnType<typeof createBuilderReposNamespace>;
@@ -0,0 +1,37 @@
1
+ export function createBuilderReposNamespace(http, config) {
2
+ const baseUrl = config.baseUrl.replace(/\/$/, '');
3
+ return {
4
+
5
+ get: (blueprintId, options) => http.get(`/api/builder/blueprints/${blueprintId}/repo`, options).then((response) => response.data),
6
+
7
+ eject: (blueprintId, input, options) => http.post(`/api/builder/blueprints/${blueprintId}/repo`, input, options).then((response) => response.data),
8
+
9
+ exportBundle: async (blueprintId) => {
10
+ const fetchImplementation = config.fetch ?? globalThis.fetch;
11
+ const token = await config.getToken();
12
+ const response = await fetchImplementation(`${baseUrl}/api/builder/blueprints/${blueprintId}/repo/export`, {
13
+ method: 'POST',
14
+ headers: {
15
+ Accept: 'application/x-git-bundle, application/json',
16
+ 'X-Requested-With': 'XMLHttpRequest',
17
+ ...(token ? { Authorization: `Bearer ${token}` } : {}),
18
+ },
19
+ });
20
+ if (!response.ok) {
21
+ let reason = '';
22
+ try {
23
+ const body = (await response.json());
24
+ reason = body.reason ?? '';
25
+ }
26
+ catch {
27
+
28
+ }
29
+ throw new Error(`Repository export failed with status ${response.status}${reason ? ` (${reason})` : ''}`);
30
+ }
31
+ const blob = await response.blob();
32
+ const disposition = response.headers.get('content-disposition') ?? '';
33
+ const match = disposition.match(/filename\*?=(?:UTF-8'')?"?([^;"]+)"?/i);
34
+ return { blob, filename: match ? decodeURIComponent(match[1]) : `${blueprintId}.bundle` };
35
+ },
36
+ };
37
+ }