@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,76 @@
1
+ import { personDomainRequest } from './actors.js';
2
+
3
+ export const PICKUP_FAILURE_REASONS = [
4
+ 'goods_not_ready',
5
+ 'goods_damaged',
6
+ 'address_not_found',
7
+ 'unsafe_to_deliver',
8
+ 'vehicle_problem',
9
+ 'other',
10
+ ];
11
+ const BASE = '/api/field-ops/fulfilment';
12
+ export function createFulfilmentJobsNamespace(http) {
13
+ const segment = encodeURIComponent;
14
+ return {
15
+
16
+ dispatch: {
17
+
18
+ board: (runDate) => http.get(`${BASE}/board`, { params: runDate ? { run_date: runDate } : {} }),
19
+
20
+ jobs: (query = {}) => http.get(`${BASE}/jobs`, {
21
+ params: Object.fromEntries(Object.entries({ ...query, waiting: query.waiting === undefined ? undefined : query.waiting ? 1 : 0 }).filter(([, value]) => value !== undefined && value !== null && value !== '')),
22
+ }),
23
+
24
+ job: (jobId) => http.get(`${BASE}/jobs/${segment(jobId)}`),
25
+
26
+ cancelJob: (jobId, reason) => http.post(`${BASE}/jobs/${segment(jobId)}/cancel`, { reason }),
27
+
28
+ runs: (runDate) => http.get(`${BASE}/runs`, { params: runDate ? { run_date: runDate } : {} }),
29
+
30
+ run: (runId) => http.get(`${BASE}/runs/${segment(runId)}`),
31
+
32
+ createRun: (jobIds, runDate) => http.post(`${BASE}/runs`, { job_ids: jobIds, run_date: runDate }),
33
+
34
+ assign: (runId, courierPersonId) => http.post(`${BASE}/runs/${segment(runId)}/assign`, { courier_person_id: courierPersonId }),
35
+
36
+ offerToPool: (runId) => http.post(`${BASE}/runs/${segment(runId)}/offer-to-pool`),
37
+
38
+ withdraw: (runId) => http.post(`${BASE}/runs/${segment(runId)}/withdraw`),
39
+
40
+ couriers: () => http.get(`${BASE}/couriers`),
41
+
42
+ policies: () => http.get(`${BASE}/policies`),
43
+
44
+ updatePolicies: (request) => http.put(`${BASE}/policies`, request),
45
+ },
46
+
47
+ courier: {
48
+
49
+ myRuns: (runDate) => http.get(`${BASE}/runs/mine`, { params: runDate ? { run_date: runDate } : {} }),
50
+
51
+ pool: () => http.get(`${BASE}/runs/pool`),
52
+
53
+ run: (runId) => http.get(`${BASE}/runs/${segment(runId)}/courier-view`),
54
+
55
+ accept: (runId) => http.post(`${BASE}/runs/${segment(runId)}/accept`),
56
+
57
+ decline: (runId, reason) => http.post(`${BASE}/runs/${segment(runId)}/decline`, { reason }),
58
+
59
+ claim: (runId) => http.post(`${BASE}/runs/${segment(runId)}/claim`),
60
+
61
+ start: (runId) => http.post(`${BASE}/runs/${segment(runId)}/start`),
62
+
63
+ reportPosition: (runId, latitude, longitude) => http.post(`${BASE}/runs/${segment(runId)}/position`, { latitude, longitude }),
64
+
65
+ arrive: (stopId) => http.post(`${BASE}/stops/${segment(stopId)}/arrive`),
66
+
67
+ complete: (stopId, request = {}) => http.post(`${BASE}/stops/${segment(stopId)}/complete`, request),
68
+
69
+ fail: (stopId, request) => http.post(`${BASE}/stops/${segment(stopId)}/fail`, request),
70
+
71
+ proofUploadBase: `${BASE}/staged-uploads/proof`,
72
+ },
73
+
74
+ track: (organisationId, trackingToken, options) => http.get(`/api/person/fulfilment-tracking/${segment(organisationId)}/${segment(trackingToken)}`, personDomainRequest(options, false)),
75
+ };
76
+ }
@@ -0,0 +1,205 @@
1
+ import type { Http } from './http.js';
2
+ import { type BilingualText, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
3
+ /** One opening period: `day` 0 (Sunday) – 6, `opens`/`closes` as `HH:MM` local time. */
4
+ export interface OpeningPeriod {
5
+ day: number;
6
+ opens: string;
7
+ closes: string;
8
+ }
9
+ export interface PickupPoint {
10
+ id: string;
11
+ name: BilingualText;
12
+ /** The full address of the counter, published. */
13
+ address: string;
14
+ /** The neighbourhood or city. */
15
+ area_label: string | null;
16
+ /** 7-place decimal strings. */
17
+ latitude: string;
18
+ longitude: string;
19
+ opening_hours: OpeningPeriod[];
20
+ instructions: string | null;
21
+ /** Owner reads only. */
22
+ position?: number;
23
+ archived_at?: string | null;
24
+ }
25
+ export type ServiceAreaShape = 'radius' | 'polygon';
26
+ export type DeliveryFeeRule = 'free' | 'flat' | 'distance';
27
+ export interface ServiceArea {
28
+ id: string;
29
+ name: BilingualText;
30
+ shape: ServiceAreaShape;
31
+ /** The dispatch point: a circle's centre, or (default) a polygon's first vertex. */
32
+ centre_latitude: string;
33
+ centre_longitude: string;
34
+ /** Radius only: 50 – 200000 metres. */
35
+ radius_metres: number | null;
36
+ /** Polygon only: 3 – 200 `[latitude, longitude]` vertices as 7-place strings; empty for a radius. */
37
+ polygon: Array<[string, string]>;
38
+ fee_rule: DeliveryFeeRule;
39
+ /** Flat fee, or the distance rule's base. */
40
+ fee_amount: string;
41
+ /** Distance rule: per started kilometre from the dispatch point, in a straight line. */
42
+ fee_per_kilometre: string;
43
+ /** The fee is waived when the order reaches this amount; null: never waived. */
44
+ free_from_order_amount: string | null;
45
+ currency_code: string;
46
+ position?: number;
47
+ archived_at?: string | null;
48
+ }
49
+ export interface FulfilmentOptions {
50
+ pickup_points: PickupPoint[];
51
+ service_areas: ServiceArea[];
52
+ /** True when the business declared no served area: it delivers anywhere. */
53
+ delivers_anywhere: boolean;
54
+ /** `refuse` (default) or `accept`. */
55
+ outside_area_policy: 'refuse' | 'accept';
56
+ }
57
+ export interface DestinationCheck {
58
+ served: boolean;
59
+ /** `in_area`, `unlimited` (no areas), `accepted_outside` (policy `accept`), `outside`. */
60
+ basis: 'in_area' | 'unlimited' | 'accepted_outside' | 'outside';
61
+ /** `outside_served_areas` when not served, else null. */
62
+ reason: string | null;
63
+ service_area_id: string | null;
64
+ /** The quoted fee, or null (no area applies). */
65
+ fee: string | null;
66
+ currency_code: string | null;
67
+ }
68
+ export interface CheckDestinationRequest {
69
+ latitude: number;
70
+ longitude: number;
71
+ /** The order's amount, for a `free_from_order_amount` waiver. */
72
+ order_amount?: string | null;
73
+ }
74
+ export interface SavePickupPointRequest {
75
+ name: BilingualText;
76
+ address: string;
77
+ area_label?: string | null;
78
+ latitude: number;
79
+ longitude: number;
80
+ opening_hours?: OpeningPeriod[];
81
+ instructions?: string | null;
82
+ position?: number;
83
+ }
84
+ export interface SaveServiceAreaRequest {
85
+ name: BilingualText;
86
+ shape: ServiceAreaShape;
87
+ centre_latitude?: number;
88
+ centre_longitude?: number;
89
+ radius_metres?: number | null;
90
+ polygon?: Array<[number, number]> | null;
91
+ fee_rule: DeliveryFeeRule;
92
+ fee_amount?: string;
93
+ fee_per_kilometre?: string;
94
+ free_from_order_amount?: string | null;
95
+ position?: number;
96
+ }
97
+ export type FulfilmentListStatus = 'live' | 'archived' | 'all';
98
+ /**
99
+ * Where an order for someone else goes, as THIS reader may see it (`RecipientOrder.destination`).
100
+ * The buyer never sees anything of a place the recipient chose beyond `kind`; the recipient sees a
101
+ * buyer's destination as its `area_label` only.
102
+ */
103
+ export interface RecipientOrderDestination {
104
+ set_by: 'sender' | 'recipient' | null;
105
+ kind: 'delivery' | 'pickup' | null;
106
+ area_label: string | null;
107
+ pickup_point_id: string | null;
108
+ delivery_fee: string | null;
109
+ }
110
+ /** What the BUYER sets: leave it to the recipient, a pickup point, or an address (optional pin). */
111
+ export type SetRecipientDestinationRequest = {
112
+ kind: 'recipient_chooses';
113
+ } | {
114
+ kind: 'pickup';
115
+ pickup_point_id: string;
116
+ } | {
117
+ kind: 'delivery';
118
+ /** Required unless a pin is given. */
119
+ address_line?: string | null;
120
+ latitude?: number | null;
121
+ longitude?: number | null;
122
+ /** The neighbourhood or city — the only part the recipient will see. */
123
+ area_label?: string | null;
124
+ note?: string | null;
125
+ };
126
+ /** What the RECIPIENT chooses — exactly one. */
127
+ export type ChooseRecipientDestinationRequest = {
128
+ address_id: string;
129
+ } | {
130
+ map_point: {
131
+ latitude: number;
132
+ longitude: number;
133
+ area_label?: string | null;
134
+ note?: string | null;
135
+ };
136
+ } | {
137
+ pickup_point_id: string;
138
+ } | {
139
+ use_sender_destination: true;
140
+ };
141
+ /** Refusal reasons a destination write may answer with. */
142
+ export type DestinationRefusalReason = 'outside_served_areas' | 'pickup_point_unknown' | 'destination_unknown' | 'destination_fixed';
143
+ export declare function createFulfilmentNamespace(http: Http): {
144
+ /** The business's own screens (tenant API). Lists answer `{data: [...]}`, at most 200, by position. */
145
+ owner: {
146
+ /** GET /pickup-points — `status` defaults to `live`. Needs `shop.view`. */
147
+ pickupPoints: (status?: FulfilmentListStatus) => Promise<{
148
+ data: PickupPoint[];
149
+ }>;
150
+ /** POST /pickup-points — 201. Needs `shop.manage`. */
151
+ createPickupPoint: (request: SavePickupPointRequest) => Promise<{
152
+ data: PickupPoint;
153
+ }>;
154
+ /** PATCH /pickup-points/{id} — any subset of the fields. */
155
+ updatePickupPoint: (id: string, request: Partial<SavePickupPointRequest>) => Promise<{
156
+ data: PickupPoint;
157
+ }>;
158
+ /** POST /pickup-points/{id}/archive — hides it from buyers; orders already pointed at it keep it. */
159
+ archivePickupPoint: (id: string) => Promise<{
160
+ data: PickupPoint;
161
+ }>;
162
+ /** POST /pickup-points/{id}/restore — the undo of archive. */
163
+ restorePickupPoint: (id: string) => Promise<{
164
+ data: PickupPoint;
165
+ }>;
166
+ /** GET /service-areas — `status` defaults to `live`. */
167
+ serviceAreas: (status?: FulfilmentListStatus) => Promise<{
168
+ data: ServiceArea[];
169
+ }>;
170
+ /** POST /service-areas — 201. A radius needs a centre and `radius_metres`; a polygon 3–200 vertices. */
171
+ createServiceArea: (request: SaveServiceAreaRequest) => Promise<{
172
+ data: ServiceArea;
173
+ }>;
174
+ updateServiceArea: (id: string, request: Partial<SaveServiceAreaRequest>) => Promise<{
175
+ data: ServiceArea;
176
+ }>;
177
+ archiveServiceArea: (id: string) => Promise<{
178
+ data: ServiceArea;
179
+ }>;
180
+ restoreServiceArea: (id: string) => Promise<{
181
+ data: ServiceArea;
182
+ }>;
183
+ /** POST /check — try a point against your own areas: served, which area, what fee. */
184
+ check: (request: CheckDestinationRequest) => Promise<{
185
+ data: DestinationCheck;
186
+ }>;
187
+ };
188
+ /** GET /api/person/shops/{slug}/fulfilment-options — the shop's live pickup points and served areas. */
189
+ options: (shopSlug: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<FulfilmentOptions>>;
190
+ /** POST /api/person/shops/{slug}/fulfilment-options/check — does the shop deliver to this point, and at what fee. Never refuses: `served` says. */
191
+ check: (shopSlug: string, request: CheckDestinationRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<DestinationCheck>>;
192
+ /**
193
+ * PUT /api/person/recipient-orders/{id}/destination — the BUYER decides where it goes, or
194
+ * leaves it to the recipient. Until the recipient has chosen (409 `destination_fixed` after).
195
+ * Answers the order (`destination` as the buyer may see it).
196
+ */
197
+ setRecipientDestination: <TOrder = unknown>(recipientOrderId: string, request: SetRecipientDestinationRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<TOrder>>;
198
+ /**
199
+ * POST /api/person/recipient-orders/{id}/delivery — the RECIPIENT chooses delivery and where:
200
+ * a saved place, a map pin, a pickup point, or the buyer's destination. Answers the order,
201
+ * with `consent_request_id` when the business needs consent to read the place.
202
+ */
203
+ chooseRecipientDestination: <TOrder = unknown>(recipientOrderId: string, request: ChooseRecipientDestinationRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<TOrder>>;
204
+ };
205
+ export type FulfilmentNamespace = ReturnType<typeof createFulfilmentNamespace>;
@@ -0,0 +1,39 @@
1
+ import { personDomainRequest } from './actors.js';
2
+ const OWNER_BASE = '/api/shop/fulfilment';
3
+ export function createFulfilmentNamespace(http) {
4
+ const segment = encodeURIComponent;
5
+ const read = (options) => personDomainRequest(options, false);
6
+ const write = (options) => personDomainRequest(options, true);
7
+ return {
8
+
9
+ owner: {
10
+
11
+ pickupPoints: (status = 'live') => http.get(`${OWNER_BASE}/pickup-points`, { params: { status } }),
12
+
13
+ createPickupPoint: (request) => http.post(`${OWNER_BASE}/pickup-points`, request),
14
+
15
+ updatePickupPoint: (id, request) => http.patch(`${OWNER_BASE}/pickup-points/${segment(id)}`, request),
16
+
17
+ archivePickupPoint: (id) => http.post(`${OWNER_BASE}/pickup-points/${segment(id)}/archive`),
18
+
19
+ restorePickupPoint: (id) => http.post(`${OWNER_BASE}/pickup-points/${segment(id)}/restore`),
20
+
21
+ serviceAreas: (status = 'live') => http.get(`${OWNER_BASE}/service-areas`, { params: { status } }),
22
+
23
+ createServiceArea: (request) => http.post(`${OWNER_BASE}/service-areas`, request),
24
+ updateServiceArea: (id, request) => http.patch(`${OWNER_BASE}/service-areas/${segment(id)}`, request),
25
+ archiveServiceArea: (id) => http.post(`${OWNER_BASE}/service-areas/${segment(id)}/archive`),
26
+ restoreServiceArea: (id) => http.post(`${OWNER_BASE}/service-areas/${segment(id)}/restore`),
27
+
28
+ check: (request) => http.post(`${OWNER_BASE}/check`, request),
29
+ },
30
+
31
+ options: (shopSlug, options) => http.get(`/api/person/shops/${segment(shopSlug)}/fulfilment-options`, read(options)),
32
+
33
+ check: (shopSlug, request, options) => http.post(`/api/person/shops/${segment(shopSlug)}/fulfilment-options/check`, request, read(options)),
34
+
35
+ setRecipientDestination: (recipientOrderId, request, options) => http.put(`/api/person/recipient-orders/${segment(recipientOrderId)}/destination`, request, write(options)),
36
+
37
+ chooseRecipientDestination: (recipientOrderId, request, options) => http.post(`/api/person/recipient-orders/${segment(recipientOrderId)}/delivery`, request, write(options)),
38
+ };
39
+ }
package/dist/hr.d.ts ADDED
@@ -0,0 +1,350 @@
1
+ import type { Http } from './http.js';
2
+ import type { LaravelPaginator, LaravelResourceCollection, ListQuery } from './types.js';
3
+ export type EmploymentType = 'full_time' | 'part_time' | 'contract' | 'intern' | 'temporary';
4
+ export type EmployeeStatus = 'probation' | 'active' | 'inactive' | 'terminated' | 'on_leave';
5
+ /** Shape from EmployeeResource. */
6
+ export interface Employee {
7
+ id: string;
8
+ employee_number: string;
9
+ first_name: string;
10
+ last_name: string;
11
+ full_name: string;
12
+ email: string | null;
13
+ phone: string | null;
14
+ employment_type: EmploymentType | string;
15
+ status: EmployeeStatus | string;
16
+ hire_date: string | null;
17
+ termination_date: string | null;
18
+ /** When a probation ends; null when none is running or it is open-ended. Optional for older cores. */
19
+ probation_end_date?: string | null;
20
+ department_id: string | null;
21
+ position_id: string | null;
22
+ direct_manager_id: string | null;
23
+ /**
24
+ * The PARTY this employment belongs to — the human, as the directory knows them.
25
+ *
26
+ * `EmployeeResource` has emitted this since the HR convergence and it was missing from
27
+ * this interface, which made the one usable join key in the people plane invisible to
28
+ * `tsc`. It is the ONLY key that joins an employment to the rest of a person: a coach is
29
+ * a party holding a `practitioner`/`coach` role, a member is a party holding `member`,
30
+ * and `hr.employment_records.party_id` is what ties those to a job.
31
+ *
32
+ * Do NOT reach for `person_id` instead. That is the platform identity ANCHOR and it is
33
+ * null for anyone who has never signed in — which is most coaches and most members, i.e.
34
+ * exactly the records worth joining.
35
+ *
36
+ * One party may hold SEVERAL employments over time (resign, re-hire), so this is
37
+ * many-to-one: never key a map on it expecting uniqueness without filtering to the
38
+ * current employment (`termination_date === null`).
39
+ */
40
+ party_id: string;
41
+ /** The platform identity anchor. Null = never signed in. Not a join key — see `party_id`. */
42
+ person_id: string | null;
43
+ }
44
+ export interface CreateEmployeeInput {
45
+ /**
46
+ * Hire somebody the DIRECTORY ALREADY KNOWS, by their party id.
47
+ *
48
+ * Send this and the names become unnecessary: the identity exists and the only thing being
49
+ * created is the job. Omit it and they are required, because a person the directory has not
50
+ * met has to be described somehow — which is why the two below are optional-with-a-caveat
51
+ * rather than plainly optional (`required_without:party_id` server-side).
52
+ *
53
+ * Prefer this over relying on an email match whenever you hold the id. Without it the only
54
+ * way to attach an employment to an existing person was to post a name and an email and
55
+ * hope the server matched on the email; when it did not, the hire silently created a SECOND
56
+ * party — the duplication the directory exists to end — and answered 201 either way.
57
+ *
58
+ * A party id that does not resolve is a 422, not a fresh person. A pre-merge id is followed
59
+ * to its survivor.
60
+ */
61
+ party_id?: string;
62
+ first_name?: string;
63
+ last_name?: string;
64
+ email?: string | null;
65
+ phone?: string | null;
66
+ employment_type?: EmploymentType | string;
67
+ hire_date?: string | null;
68
+ department_id?: string | null;
69
+ position_id?: string | null;
70
+ direct_manager_id?: string | null;
71
+ person_id?: string | null;
72
+ /** The organisation's own staff number. Null clears it on update. */
73
+ employee_number?: string | null;
74
+ /**
75
+ * Identity facts, stored on the PERSON (the party), not the job. Core accepts them on create
76
+ * and update (null clears on update), but `Employee` reads do not return them, so an edit
77
+ * form cannot prefill them — sending null from an empty control would erase them.
78
+ */
79
+ nationality?: string | null;
80
+ national_id?: string | null;
81
+ date_of_birth?: string | null;
82
+ /** Core's rule is `in:male,female`; typed as string so a form's select value passes through. */
83
+ gender?: 'male' | 'female' | string | null;
84
+ }
85
+ /**
86
+ * `employment_type` may be omitted on update but never sent as null: its column is NOT NULL and
87
+ * core refuses null there (a null on CREATE means "the default", as omitting it does).
88
+ */
89
+ export type UpdateEmployeeInput = Partial<CreateEmployeeInput>;
90
+ export interface EmployeeContract {
91
+ id: string;
92
+ employee_id: string;
93
+ [field: string]: unknown;
94
+ }
95
+ export type SalaryAllowanceType = 'housing' | 'transportation' | 'food' | 'telephone' | 'performance' | 'other';
96
+ export interface SalaryAllowance {
97
+ id: string;
98
+ allowance_type: SalaryAllowanceType | string;
99
+ /** bcmath decimal string. */
100
+ amount: string;
101
+ is_taxable: boolean;
102
+ }
103
+ export interface SalaryStructure {
104
+ id: string;
105
+ /** bcmath decimal string. */
106
+ base_salary: string;
107
+ currency: string;
108
+ effective_from: string | null;
109
+ effective_to: string | null;
110
+ is_active: boolean;
111
+ allowances: SalaryAllowance[];
112
+ }
113
+ export interface CreateSalaryStructureInput {
114
+ /** bcmath decimal string. */
115
+ base_salary: string;
116
+ /** ISO 4217, three letters. Omitted ⇒ server defaults to SAR. */
117
+ currency?: string | null;
118
+ effective_from: string;
119
+ effective_to?: string | null;
120
+ allowances?: {
121
+ allowance_type: SalaryAllowanceType;
122
+ /** bcmath decimal string. */
123
+ amount: string;
124
+ is_taxable?: boolean;
125
+ }[];
126
+ }
127
+ export type AttendanceSource = 'manual' | 'clockify' | 'biometric';
128
+ export interface AttendanceRecord {
129
+ id: string;
130
+ tenant_id?: string;
131
+ employee_id: string;
132
+ date: string;
133
+ check_in: string | null;
134
+ check_out: string | null;
135
+ duration_minutes: number | null;
136
+ source: AttendanceSource | string;
137
+ created_at: string | null;
138
+ updated_at: string | null;
139
+ /** Embedded on `list` (eager-loaded); absent on `create`. */
140
+ employee?: Record<string, unknown>;
141
+ }
142
+ export interface CreateAttendanceInput {
143
+ employee_id: string;
144
+ date: string;
145
+ check_in?: string | null;
146
+ check_out?: string | null;
147
+ source?: AttendanceSource;
148
+ }
149
+ export interface AttendanceListQuery extends ListQuery {
150
+ employee_id?: string;
151
+ /** One day, `YYYY-MM-DD`. */
152
+ date?: string;
153
+ date_from?: string;
154
+ /** Last day of a range (inclusive). */
155
+ date_to?: string;
156
+ /** `manual` | `biometric` | … — the record's source. */
157
+ source?: string;
158
+ }
159
+ export type LeaveRequestStatus = 'pending' | 'approved' | 'rejected' | 'cancelled';
160
+ /** `LeaveRequestResource` — single wrapped in `{ data }`, list is a resource collection. */
161
+ export interface LeaveRequest {
162
+ id: string;
163
+ employee_id: string;
164
+ leave_type_id: string;
165
+ from_date: string;
166
+ to_date: string;
167
+ total_days: string | number;
168
+ reason: string | null;
169
+ status: LeaveRequestStatus | string;
170
+ rejection_reason: string | null;
171
+ approved_at: string | null;
172
+ }
173
+ export interface CreateLeaveRequestInput {
174
+ employee_id: string;
175
+ leave_type_id: string;
176
+ from_date: string;
177
+ to_date: string;
178
+ reason?: string | null;
179
+ }
180
+ export interface LeaveRequestListQuery extends ListQuery {
181
+ employee_id?: string;
182
+ leave_type_id?: string;
183
+ status?: LeaveRequestStatus;
184
+ }
185
+ export interface LeaveType {
186
+ id: string;
187
+ code: string | null;
188
+ name_en: string;
189
+ name_ar: string;
190
+ is_paid: boolean;
191
+ requires_approval: boolean;
192
+ accrual_rate_days_per_year: string | number;
193
+ max_carry_over_days: string | number;
194
+ is_active: boolean;
195
+ }
196
+ export interface CreateLeaveTypeInput {
197
+ name_en: string;
198
+ name_ar: string;
199
+ code?: string | null;
200
+ is_paid?: boolean;
201
+ requires_approval?: boolean;
202
+ accrual_rate_days_per_year?: number;
203
+ max_carry_over_days?: number;
204
+ is_active?: boolean;
205
+ }
206
+ export interface Department {
207
+ id: string;
208
+ name: string;
209
+ /** The Arabic name, when one was given. Screens fall back to `name`. */
210
+ name_ar: string | null;
211
+ code: string | null;
212
+ parent_id: string | null;
213
+ /** Present when the relation is loaded (index, show). */
214
+ children?: Department[];
215
+ positions?: Position[];
216
+ }
217
+ export interface CreateDepartmentInput {
218
+ name: string;
219
+ /** On update: omit to keep the stored Arabic name, send null to clear it. */
220
+ name_ar?: string | null;
221
+ code?: string | null;
222
+ parent_id?: string | null;
223
+ }
224
+ export type UpdateDepartmentInput = CreateDepartmentInput;
225
+ export interface Position {
226
+ id: string;
227
+ title: string;
228
+ /** The Arabic title, when one was given. Screens fall back to `title`. */
229
+ title_ar: string | null;
230
+ code: string | null;
231
+ department_id: string | null;
232
+ is_active: boolean;
233
+ }
234
+ export interface CreatePositionInput {
235
+ title: string;
236
+ /** On update: omit to keep the stored Arabic title, send null to clear it. */
237
+ title_ar?: string | null;
238
+ code?: string | null;
239
+ department_id?: string | null;
240
+ }
241
+ export interface UpdatePositionInput extends CreatePositionInput {
242
+ is_active?: boolean;
243
+ }
244
+ export declare function createHrNamespace(http: Http): {
245
+ employees: {
246
+ /** GET /api/hr/employees — Laravel resource-collection envelope. */
247
+ list: (query?: ListQuery) => Promise<LaravelResourceCollection<Employee>>;
248
+ /** GET /api/hr/employees/{employee} */
249
+ get: (id: string) => Promise<Employee>;
250
+ /** POST /api/hr/employees */
251
+ create: (input: CreateEmployeeInput) => Promise<Employee>;
252
+ /** PUT /api/hr/employees/{employee} */
253
+ update: (id: string, input: UpdateEmployeeInput) => Promise<Employee>;
254
+ /** POST /api/hr/employees/{employee}/start-probation */
255
+ startProbation: (id: string) => Promise<Employee>;
256
+ /** POST /api/hr/employees/{employee}/complete-probation */
257
+ completeProbation: (id: string) => Promise<Employee>;
258
+ /** POST /api/hr/employees/{employee}/activate */
259
+ activate: (id: string) => Promise<Employee>;
260
+ /** POST /api/hr/employees/{employee}/deactivate */
261
+ deactivate: (id: string) => Promise<Employee>;
262
+ /** POST /api/hr/employees/{employee}/terminate */
263
+ terminate: (id: string, input?: Record<string, unknown>) => Promise<Employee>;
264
+ /** POST /api/hr/employees/{employee}/transfer */
265
+ transfer: (id: string, input?: Record<string, unknown>) => Promise<Employee>;
266
+ /** GET /api/hr/employees/{employee}/contracts — a bare array, newest first. */
267
+ contracts: (id: string) => Promise<EmployeeContract[]>;
268
+ /** POST /api/hr/employees/{employee}/contracts */
269
+ addContract: (id: string, input: Record<string, unknown>) => Promise<EmployeeContract>;
270
+ /** GET /api/hr/employees/{employee}/salary-structures — bare array (Payroll module). */
271
+ salaryStructures: (id: string) => Promise<SalaryStructure[]>;
272
+ /** POST /api/hr/employees/{employee}/salary-structures — 201 `{ id, base_salary }`. */
273
+ addSalaryStructure: (id: string, input: CreateSalaryStructureInput) => Promise<{
274
+ id: string;
275
+ base_salary: string;
276
+ }>;
277
+ };
278
+ me: {
279
+ /** GET /api/hr/me/employee — the current IAM identity's employee record. */
280
+ employee: () => Promise<Employee>;
281
+ };
282
+ attendance: {
283
+ /** GET /api/hr/attendance — RAW Laravel paginator (per-page fixed at 50). */
284
+ list: (query?: AttendanceListQuery) => Promise<LaravelPaginator<AttendanceRecord>>;
285
+ /** POST /api/hr/attendance */
286
+ create: (input: CreateAttendanceInput) => Promise<AttendanceRecord>;
287
+ };
288
+ leaveRequests: {
289
+ /** GET /api/hr/leave-requests — Laravel resource-collection (`{data,links,meta}`). */
290
+ list: (query?: LeaveRequestListQuery) => Promise<LaravelResourceCollection<LeaveRequest>>;
291
+ /** GET /api/hr/leave-requests/{id} — wrapped in `{ data }`. */
292
+ get: (id: string) => Promise<{
293
+ data: LeaveRequest;
294
+ }>;
295
+ /** POST /api/hr/leave-requests — the submitted request as a bare object (201), unlike its wrapped siblings. */
296
+ create: (input: CreateLeaveRequestInput) => Promise<LeaveRequest>;
297
+ /**
298
+ * POST /api/hr/leave-requests/{id}/approve
299
+ *
300
+ * Core records the SIGNED-IN person's employment as the approver and ignores any id
301
+ * sent (`LeaveController::approve`), so the second argument is optional and inert.
302
+ * It is still forwarded when given, for callers written before that change; new
303
+ * callers should omit it rather than let a reader think it chooses the approver.
304
+ */
305
+ approve: (id: string, approvedByEmployeeId?: string) => Promise<{
306
+ data: LeaveRequest;
307
+ }>;
308
+ /** POST /api/hr/leave-requests/{id}/reject */
309
+ reject: (id: string, rejectionReason: string) => Promise<{
310
+ data: LeaveRequest;
311
+ }>;
312
+ /** POST /api/hr/leave-requests/{id}/cancel */
313
+ cancel: (id: string) => Promise<{
314
+ data: LeaveRequest;
315
+ }>;
316
+ };
317
+ leaveTypes: {
318
+ /** GET /api/hr/leave-types — `{ data }` only (unpaginated). */
319
+ list: () => Promise<{
320
+ data: LeaveType[];
321
+ }>;
322
+ /** POST /api/hr/leave-types — the created type as a bare object (201). */
323
+ create: (input: CreateLeaveTypeInput) => Promise<LeaveType>;
324
+ };
325
+ departments: {
326
+ /** GET /api/hr/departments — bare array (roots with nested children/positions). */
327
+ list: () => Promise<Department[]>;
328
+ /** GET /api/hr/departments/{id} — bare object. */
329
+ get: (id: string) => Promise<Department>;
330
+ /** POST /api/hr/departments */
331
+ create: (input: CreateDepartmentInput) => Promise<Department>;
332
+ /** PUT /api/hr/departments/{id} */
333
+ update: (id: string, input: UpdateDepartmentInput) => Promise<Department>;
334
+ /** DELETE /api/hr/departments/{id} — 204. */
335
+ remove: (id: string) => Promise<void>;
336
+ };
337
+ positions: {
338
+ /** GET /api/hr/positions — bare array. */
339
+ list: () => Promise<Position[]>;
340
+ /** GET /api/hr/positions/{id} — bare object. */
341
+ get: (id: string) => Promise<Position>;
342
+ /** POST /api/hr/positions */
343
+ create: (input: CreatePositionInput) => Promise<Position>;
344
+ /** PUT /api/hr/positions/{id} */
345
+ update: (id: string, input: UpdatePositionInput) => Promise<Position>;
346
+ /** DELETE /api/hr/positions/{id} — 204. */
347
+ remove: (id: string) => Promise<void>;
348
+ };
349
+ };
350
+ export type HrNamespace = ReturnType<typeof createHrNamespace>;