@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
package/dist/crm.d.ts ADDED
@@ -0,0 +1,533 @@
1
+ import type { Http } from './http.js';
2
+ import type { ListQuery, Paginated, Translatable } from './types.js';
3
+ export interface CrmContact {
4
+ id: string;
5
+ tenant_id?: string;
6
+ platform_person_id: string | null;
7
+ /** Active-locale string on read (translatable; `{en,ar}` on write). */
8
+ first_name: string;
9
+ last_name: string;
10
+ email: string | null;
11
+ phone: string | null;
12
+ title: string | null;
13
+ lead_source_id: string | null;
14
+ address: Record<string, unknown> | null;
15
+ ledger_counterparty_id: string | null;
16
+ created_at: string | null;
17
+ updated_at: string | null;
18
+ /** Eager-loaded on get/list (`with(['leadSource','companies'])`). */
19
+ lead_source?: CrmLeadSource | null;
20
+ /** The contact's employers, ended ones included — newest first. */
21
+ companies?: CrmContactEmployer[];
22
+ }
23
+ /**
24
+ * One employment link on a contact, as `ContactResource` sends it. Not a company record: it
25
+ * carries the company's id and names plus the dates of the employment. `until` set means the
26
+ * employment ended — the link is kept as history, so a screen naming CURRENT employers filters
27
+ * on it.
28
+ */
29
+ export interface CrmContactEmployer {
30
+ id: string;
31
+ /** The company's display name. */
32
+ name: string;
33
+ /** The company's Arabic name, where it has one. */
34
+ name_ar?: string | null;
35
+ since: string | null;
36
+ until: string | null;
37
+ }
38
+ /** The employers a contact works for NOW — `companies` also carries ended employments. */
39
+ export declare function currentEmployers(contact: Pick<CrmContact, 'companies'>): CrmContactEmployer[];
40
+ export interface CreateContactInput {
41
+ first_name: Translatable;
42
+ last_name: Translatable;
43
+ platform_person_id?: string | null;
44
+ email?: string | null;
45
+ phone?: string | null;
46
+ title?: string | null;
47
+ lead_source_id?: string | null;
48
+ address?: Record<string, unknown> | null;
49
+ ledger_counterparty_id?: string | null;
50
+ company_ids?: string[];
51
+ }
52
+ export type UpdateContactInput = Partial<CreateContactInput>;
53
+ export interface ContactListQuery extends ListQuery {
54
+ search?: string;
55
+ per_page?: number;
56
+ /** Only the contact that is this platform person (exact uuid). */
57
+ platform_person_id?: string;
58
+ /** Only contacts linked to a platform person (true), or only unlinked ones (false). */
59
+ has_person?: boolean;
60
+ /** The archived contacts instead of the current ones (the "Archived" view a restore starts from). */
61
+ archived?: boolean;
62
+ }
63
+ export interface CrmCompany {
64
+ id: string;
65
+ /** Active-locale string on read (translatable). */
66
+ name: string;
67
+ industry: string | null;
68
+ size: string | null;
69
+ website: string | null;
70
+ ledger_counterparty_id: string | null;
71
+ created_at?: string | null;
72
+ updated_at?: string | null;
73
+ }
74
+ export interface CreateCompanyInput {
75
+ name: Translatable;
76
+ industry?: string | null;
77
+ size?: string | null;
78
+ website?: string | null;
79
+ ledger_counterparty_id?: string | null;
80
+ email?: string | null;
81
+ phone?: string | null;
82
+ registration_no?: string | null;
83
+ tax_number?: string | null;
84
+ /** Free-form postal address object; core stores it as given. */
85
+ address?: Record<string, unknown> | null;
86
+ /** The company's people — replaces the full set of employment links. */
87
+ contact_ids?: string[];
88
+ }
89
+ export type UpdateCompanyInput = Partial<CreateCompanyInput>;
90
+ export interface CrmLeadSource {
91
+ id: string;
92
+ /** Active-locale string on read (translatable). */
93
+ name: string;
94
+ created_at?: string | null;
95
+ updated_at?: string | null;
96
+ }
97
+ /** Body for `POST /api/crm/lead-sources` (translatable `name`; `en` required). */
98
+ export interface CreateLeadSourceInput {
99
+ name: Translatable;
100
+ }
101
+ export interface CrmTag {
102
+ id: string;
103
+ /** Active-locale string on read (translatable `label`). */
104
+ label: string;
105
+ created_at?: string | null;
106
+ updated_at?: string | null;
107
+ }
108
+ export interface CrmStage {
109
+ id: string;
110
+ pipeline_id: string;
111
+ /** Active-locale string on read (translatable `name`). */
112
+ name: string;
113
+ sort_order: number;
114
+ /** `decimal:2` — bcmath string. */
115
+ win_probability: string;
116
+ created_at?: string | null;
117
+ updated_at?: string | null;
118
+ }
119
+ export interface CrmPipeline {
120
+ id: string;
121
+ /** Active-locale string on read (translatable `name`). */
122
+ name: string;
123
+ is_default: boolean;
124
+ created_at?: string | null;
125
+ updated_at?: string | null;
126
+ /** Eager-loaded on list/get/create (`with('stages')`). */
127
+ stages?: CrmStage[];
128
+ }
129
+ export interface CreatePipelineStageInput {
130
+ name: Translatable;
131
+ win_probability?: number | null;
132
+ }
133
+ export interface CreatePipelineInput {
134
+ name: Translatable;
135
+ is_default?: boolean;
136
+ stages?: CreatePipelineStageInput[];
137
+ }
138
+ export interface UpdatePipelineInput {
139
+ name?: Translatable;
140
+ is_default?: boolean;
141
+ }
142
+ /** Body for `POST /pipelines/{pipeline}/stages` (append a stage). */
143
+ export interface AddStageInput {
144
+ name: Translatable;
145
+ win_probability?: number | null;
146
+ sort_order?: number | null;
147
+ }
148
+ export type CrmDealState = 'open' | 'won' | 'lost' | string;
149
+ export interface CrmDeal {
150
+ id: string;
151
+ /** Plain (non-translatable) string column. */
152
+ name: string;
153
+ contact_id: string | null;
154
+ company_id: string | null;
155
+ pipeline_id: string;
156
+ stage_id: string;
157
+ /** `decimal:4` — bcmath string. */
158
+ value: string;
159
+ currency_code: string | null;
160
+ state: CrmDealState;
161
+ close_date: string | null;
162
+ stage_entered_at: string | null;
163
+ lead_source_id: string | null;
164
+ assigned_to?: string | null;
165
+ quote_id?: string | null;
166
+ won_at: string | null;
167
+ lost_at: string | null;
168
+ payment_received_at?: string | null;
169
+ created_at?: string | null;
170
+ updated_at?: string | null;
171
+ /** Eager-loaded on list/get/mutations. */
172
+ contact?: CrmContact | null;
173
+ company?: CrmCompany | null;
174
+ stage?: CrmStage | null;
175
+ pipeline?: CrmPipeline | null;
176
+ lead_source?: CrmLeadSource | null;
177
+ }
178
+ export interface CreateDealInput {
179
+ name: string;
180
+ pipeline_id: string;
181
+ stage_id: string;
182
+ contact_id?: string | null;
183
+ company_id?: string | null;
184
+ value?: number | string | null;
185
+ currency_code?: string | null;
186
+ close_date?: string | null;
187
+ lead_source_id?: string | null;
188
+ assigned_to?: string | null;
189
+ }
190
+ export type UpdateDealInput = Partial<CreateDealInput>;
191
+ export interface DealListQuery extends ListQuery {
192
+ stage_id?: string;
193
+ state?: CrmDealState;
194
+ pipeline_id?: string;
195
+ search?: string;
196
+ per_page?: number;
197
+ }
198
+ export type CrmQuoteStatus = 'draft' | 'sent' | 'accepted' | 'rejected' | string;
199
+ export interface CrmQuoteLineItem {
200
+ id: string;
201
+ quote_id: string;
202
+ /** Active-locale string on read (translatable `description`). */
203
+ description: string | null;
204
+ /** `decimal:4` — bcmath strings. */
205
+ quantity: string;
206
+ unit_price: string;
207
+ line_total: string;
208
+ account_id: string | null;
209
+ sort_order: number;
210
+ created_at?: string | null;
211
+ updated_at?: string | null;
212
+ }
213
+ export interface CrmQuote {
214
+ id: string;
215
+ deal_id: string;
216
+ number: string | null;
217
+ /** Active-locale string on read (translatable `title`). */
218
+ title: string;
219
+ status: CrmQuoteStatus;
220
+ valid_until: string | null;
221
+ /** `decimal` — bcmath strings. */
222
+ discount: string;
223
+ tax_rate: string;
224
+ subtotal: string;
225
+ tax_total: string;
226
+ grand_total: string;
227
+ document_definition_version: number | null;
228
+ sent_at: string | null;
229
+ accepted_at: string | null;
230
+ rejected_at: string | null;
231
+ created_at?: string | null;
232
+ updated_at?: string | null;
233
+ /** Eager-loaded on list/get (`with(['lineItems','deal'])`). */
234
+ line_items?: CrmQuoteLineItem[];
235
+ deal?: CrmDeal | null;
236
+ }
237
+ export interface QuoteLineItemInput {
238
+ quantity: number | string;
239
+ unit_price: number | string;
240
+ description?: Translatable | null;
241
+ account_id?: string | null;
242
+ sort_order?: number | null;
243
+ }
244
+ export interface CreateQuoteInput {
245
+ deal_id: string;
246
+ title: Translatable;
247
+ valid_until?: string | null;
248
+ discount?: number | string | null;
249
+ tax_rate?: number | string | null;
250
+ document_definition_version?: number | null;
251
+ line_items?: QuoteLineItemInput[];
252
+ }
253
+ /** `deal_id` is prohibited on update. */
254
+ export type UpdateQuoteInput = Omit<Partial<CreateQuoteInput>, 'deal_id'>;
255
+ export interface QuoteListQuery extends ListQuery {
256
+ deal_id?: string;
257
+ status?: CrmQuoteStatus;
258
+ per_page?: number;
259
+ }
260
+ export interface CrmTask {
261
+ id: string;
262
+ activity_id: string | null;
263
+ title: string | null;
264
+ due_date: string | null;
265
+ due_time: string | null;
266
+ assigned_to: string | null;
267
+ completed_at: string | null;
268
+ reminder_sent_at: string | null;
269
+ created_at?: string | null;
270
+ updated_at?: string | null;
271
+ /** Eager-loaded (`with('activity')`). */
272
+ activity?: CrmActivity | null;
273
+ }
274
+ export interface CrmActivity {
275
+ id: string;
276
+ type: string;
277
+ activityable_type: string;
278
+ activityable_id: string;
279
+ /** Active-locale string on read (translatable `subject`). */
280
+ subject: string | null;
281
+ body: string | null;
282
+ performed_by: string | null;
283
+ performed_at: string | null;
284
+ created_at?: string | null;
285
+ updated_at?: string | null;
286
+ /** Eager-loaded (`with('task')`). */
287
+ task?: CrmTask | null;
288
+ }
289
+ /** Optional inline task created alongside the activity. */
290
+ export interface ActivityTaskInput {
291
+ due_date: string;
292
+ title?: string | null;
293
+ due_time?: string | null;
294
+ assigned_to?: string | null;
295
+ }
296
+ /**
297
+ * What an activity can be logged against (core `Activity::TARGET_TYPES`). A person is
298
+ * `crm.contact`; any other spelling is refused, because the contact timeline and the eraser
299
+ * would never read it. A bare `'deal'` was sent by three verticals and refused every time.
300
+ */
301
+ export type CrmActivityTargetType = 'crm.contact' | 'crm.company' | 'crm.deal' | 'crm.quote';
302
+ export interface CreateActivityInput {
303
+ type: string;
304
+ activityable_type: CrmActivityTargetType;
305
+ activityable_id: string;
306
+ subject?: Translatable | null;
307
+ body?: string | null;
308
+ performed_by?: string | null;
309
+ performed_at?: string | null;
310
+ task?: ActivityTaskInput | null;
311
+ }
312
+ export interface ActivityListQuery extends ListQuery {
313
+ activityable_type?: string;
314
+ activityable_id?: string;
315
+ /**
316
+ * Contact-scoped retrieval: returns activities logged directly against the
317
+ * contact plus those against any deal owned by the contact — the full
318
+ * activity history for one contact's timeline.
319
+ */
320
+ contact_id?: string;
321
+ type?: string;
322
+ per_page?: number;
323
+ }
324
+ export interface CreateTaskInput {
325
+ due_date: string;
326
+ activity_id?: string | null;
327
+ title?: string | null;
328
+ due_time?: string | null;
329
+ assigned_to?: string | null;
330
+ }
331
+ export type UpdateTaskInput = Partial<CreateTaskInput>;
332
+ export interface TaskListQuery extends ListQuery {
333
+ assigned_to?: string;
334
+ completed?: boolean;
335
+ due_from?: string;
336
+ due_to?: string;
337
+ per_page?: number;
338
+ }
339
+ export interface ReferralEvent {
340
+ id: string;
341
+ contact_id: string;
342
+ referrer_contact_id: string;
343
+ referred_at: string;
344
+ reason: string | null;
345
+ created_at: string;
346
+ }
347
+ export interface CreateReferralEventInput {
348
+ contact_id: string;
349
+ referrer_contact_id: string;
350
+ referred_at?: string;
351
+ reason?: string | null;
352
+ }
353
+ export interface ReferralBySourceRow {
354
+ referrer_id: string;
355
+ referrer_name: string;
356
+ count: number;
357
+ last_referral_at: string | null;
358
+ }
359
+ export interface RelationshipVisit {
360
+ id: string;
361
+ /** e.g. `'crm.contact'` | `'bookings.insurer'` | … */
362
+ subject_type: string;
363
+ subject_id: string;
364
+ visit_type: 'in_person' | 'call' | 'email';
365
+ visited_by_person_id: string | null;
366
+ visited_at: string;
367
+ summary: string | null;
368
+ promises: string | null;
369
+ next_step: string | null;
370
+ next_step_due: string | null;
371
+ created_at: string;
372
+ }
373
+ export interface CreateRelationshipVisitInput {
374
+ subject_type: string;
375
+ subject_id: string;
376
+ visit_type: 'in_person' | 'call' | 'email';
377
+ visited_at?: string;
378
+ summary?: string | null;
379
+ promises?: string | null;
380
+ next_step?: string | null;
381
+ next_step_due?: string | null;
382
+ }
383
+ export declare function createCrmNamespace(http: Http): {
384
+ contacts: {
385
+ /** GET /api/crm/contacts */
386
+ list: (query?: ContactListQuery) => Promise<Paginated<CrmContact>>;
387
+ /** GET /api/crm/contacts/{id} */
388
+ get: (id: string) => Promise<CrmContact>;
389
+ /** POST /api/crm/contacts */
390
+ create: (input: CreateContactInput) => Promise<CrmContact>;
391
+ /** PUT /api/crm/contacts/{id} */
392
+ update: (id: string, input: UpdateContactInput) => Promise<CrmContact>;
393
+ /** DELETE /api/crm/contacts/{id} — ARCHIVES: ends the contact role and keeps the history. */
394
+ remove: (id: string) => Promise<void>;
395
+ /** POST /api/crm/contacts/{id}/restore — undo an archive; a current contact is answered as it is. */
396
+ restore: (id: string) => Promise<CrmContact>;
397
+ };
398
+ companies: {
399
+ /** GET /api/crm/companies */
400
+ list: (query?: ListQuery) => Promise<Paginated<CrmCompany>>;
401
+ /** GET /api/crm/companies/{id} */
402
+ get: (id: string) => Promise<CrmCompany>;
403
+ /** POST /api/crm/companies */
404
+ create: (input: CreateCompanyInput) => Promise<CrmCompany>;
405
+ /** PUT /api/crm/companies/{id} */
406
+ update: (id: string, input: UpdateCompanyInput) => Promise<CrmCompany>;
407
+ /** DELETE /api/crm/companies/{id} */
408
+ remove: (id: string) => Promise<void>;
409
+ };
410
+ leadSources: {
411
+ /**
412
+ * GET /api/crm/lead-sources — paginated `{data, meta}`, newest first.
413
+ * Core pages it at 25 by default and caps `per_page` at 100.
414
+ */
415
+ list: (query?: ListQuery) => Promise<Paginated<CrmLeadSource>>;
416
+ /** POST /api/crm/lead-sources — returns the created source (201). */
417
+ create: (input: CreateLeadSourceInput) => Promise<CrmLeadSource>;
418
+ /** DELETE /api/crm/lead-sources/{id} — soft-deletes the source (204). */
419
+ remove: (id: string) => Promise<void>;
420
+ };
421
+ tags: {
422
+ /** GET /api/crm/tags — `{ data: CrmTag[] }` (no pagination). */
423
+ list: () => Promise<{
424
+ data: CrmTag[];
425
+ }>;
426
+ };
427
+ pipelines: {
428
+ /** GET /api/crm/pipelines — `{ data: CrmPipeline[] }` (with stages, no pagination). */
429
+ list: () => Promise<{
430
+ data: CrmPipeline[];
431
+ }>;
432
+ /** GET /api/crm/pipelines/{id} */
433
+ get: (id: string) => Promise<CrmPipeline>;
434
+ /** POST /api/crm/pipelines — creates the pipeline (and any inline stages). */
435
+ create: (input: CreatePipelineInput) => Promise<CrmPipeline>;
436
+ /** PUT /api/crm/pipelines/{id} */
437
+ update: (id: string, input: UpdatePipelineInput) => Promise<CrmPipeline>;
438
+ /** DELETE /api/crm/pipelines/{id} */
439
+ remove: (id: string) => Promise<void>;
440
+ /** POST /api/crm/pipelines/{pipeline}/stages — append a stage. */
441
+ addStage: (pipelineId: string, input: AddStageInput) => Promise<CrmStage>;
442
+ /** POST /api/crm/pipelines/{pipeline}/stages/reorder */
443
+ reorderStages: (pipelineId: string, stageIds: string[]) => Promise<CrmPipeline>;
444
+ };
445
+ deals: {
446
+ /** GET /api/crm/deals — paginated `{data, meta}`. */
447
+ list: (query?: DealListQuery) => Promise<Paginated<CrmDeal>>;
448
+ /** GET /api/crm/deals/{id} */
449
+ get: (id: string) => Promise<CrmDeal>;
450
+ /** POST /api/crm/deals */
451
+ create: (input: CreateDealInput) => Promise<CrmDeal>;
452
+ /** PUT /api/crm/deals/{id} */
453
+ update: (id: string, input: UpdateDealInput) => Promise<CrmDeal>;
454
+ /** DELETE /api/crm/deals/{id} */
455
+ remove: (id: string) => Promise<void>;
456
+ /** PATCH /api/crm/deals/{id}/stage — move the deal to another stage. */
457
+ moveStage: (id: string, stageId: string) => Promise<CrmDeal>;
458
+ /** POST /api/crm/deals/{id}/win — optionally tie the closing quote. */
459
+ win: (id: string, quoteId?: string | null) => Promise<CrmDeal>;
460
+ /** POST /api/crm/deals/{id}/lose — `lost_reason` required. */
461
+ lose: (id: string, lostReason: string) => Promise<CrmDeal>;
462
+ };
463
+ quotes: {
464
+ /** GET /api/crm/quotes — paginated `{data, meta}`. */
465
+ list: (query?: QuoteListQuery) => Promise<Paginated<CrmQuote>>;
466
+ /** GET /api/crm/quotes/{id} */
467
+ get: (id: string) => Promise<CrmQuote>;
468
+ /** POST /api/crm/quotes */
469
+ create: (input: CreateQuoteInput) => Promise<CrmQuote>;
470
+ /** PUT /api/crm/quotes/{id} */
471
+ update: (id: string, input: UpdateQuoteInput) => Promise<CrmQuote>;
472
+ /** DELETE /api/crm/quotes/{id} */
473
+ remove: (id: string) => Promise<void>;
474
+ /** POST /api/crm/quotes/{id}/send */
475
+ send: (id: string) => Promise<CrmQuote>;
476
+ /** POST /api/crm/quotes/{id}/accept */
477
+ accept: (id: string) => Promise<CrmQuote>;
478
+ /** POST /api/crm/quotes/{id}/reject */
479
+ reject: (id: string) => Promise<CrmQuote>;
480
+ };
481
+ activities: {
482
+ /** GET /api/crm/activities — paginated `{data, meta}`. */
483
+ list: (query?: ActivityListQuery) => Promise<Paginated<CrmActivity>>;
484
+ /** GET /api/crm/activities/{activity} */
485
+ get: (id: string) => Promise<CrmActivity>;
486
+ /** POST /api/crm/activities — optionally spawns an inline follow-up task. */
487
+ create: (input: CreateActivityInput) => Promise<CrmActivity>;
488
+ /** DELETE /api/crm/activities/{activity} */
489
+ remove: (id: string) => Promise<void>;
490
+ };
491
+ tasks: {
492
+ /** GET /api/crm/tasks — paginated `{data, meta}`. */
493
+ list: (query?: TaskListQuery) => Promise<Paginated<CrmTask>>;
494
+ /** GET /api/crm/tasks/{task} */
495
+ get: (id: string) => Promise<CrmTask>;
496
+ /** POST /api/crm/tasks */
497
+ create: (input: CreateTaskInput) => Promise<CrmTask>;
498
+ /** PUT /api/crm/tasks/{task} */
499
+ update: (id: string, input: UpdateTaskInput) => Promise<CrmTask>;
500
+ /** DELETE /api/crm/tasks/{task} */
501
+ remove: (id: string) => Promise<void>;
502
+ /** POST /api/crm/tasks/{task}/complete */
503
+ complete: (id: string) => Promise<CrmTask>;
504
+ };
505
+ referralEvents: {
506
+ /** GET /api/crm/referral-events — paginated `{data, meta}`. */
507
+ list: (query?: {
508
+ referrer_contact_id?: string;
509
+ contact_id?: string;
510
+ per_page?: number;
511
+ }) => Promise<Paginated<ReferralEvent>>;
512
+ /** GET /api/crm/referral-events/by-source?from=&to= — counts per referrer in a window. */
513
+ bySource: (query: {
514
+ from: string;
515
+ to: string;
516
+ }) => Promise<{
517
+ data: ReferralBySourceRow[];
518
+ }>;
519
+ /** POST /api/crm/referral-events */
520
+ create: (input: CreateReferralEventInput) => Promise<ReferralEvent>;
521
+ };
522
+ relationshipVisits: {
523
+ /** GET /api/crm/relationship-visits?subject_type=&subject_id= — paginated `{data, meta}`. */
524
+ list: (query: {
525
+ subject_type?: string;
526
+ subject_id?: string;
527
+ per_page?: number;
528
+ }) => Promise<Paginated<RelationshipVisit>>;
529
+ /** POST /api/crm/relationship-visits */
530
+ create: (input: CreateRelationshipVisitInput) => Promise<RelationshipVisit>;
531
+ };
532
+ };
533
+ export type CrmNamespace = ReturnType<typeof createCrmNamespace>;
package/dist/crm.js ADDED
@@ -0,0 +1,142 @@
1
+
2
+ export function currentEmployers(contact) {
3
+ return (contact.companies ?? []).filter((employer) => !employer.until);
4
+ }
5
+ export function createCrmNamespace(http) {
6
+ return {
7
+ contacts: {
8
+
9
+ list: (query) => http.get('/api/crm/contacts', { params: query }),
10
+
11
+ get: (id) => http.get(`/api/crm/contacts/${id}`),
12
+
13
+ create: (input) => http.post('/api/crm/contacts', input),
14
+
15
+ update: (id, input) => http.put(`/api/crm/contacts/${id}`, input),
16
+
17
+ remove: (id) => http.delete(`/api/crm/contacts/${id}`),
18
+
19
+ restore: (id) => http.post(`/api/crm/contacts/${id}/restore`),
20
+ },
21
+ companies: {
22
+
23
+ list: (query) => http.get('/api/crm/companies', { params: query }),
24
+
25
+ get: (id) => http.get(`/api/crm/companies/${id}`),
26
+
27
+ create: (input) => http.post('/api/crm/companies', input),
28
+
29
+ update: (id, input) => http.put(`/api/crm/companies/${id}`, input),
30
+
31
+ remove: (id) => http.delete(`/api/crm/companies/${id}`),
32
+ },
33
+ leadSources: {
34
+
35
+ list: (query) => http.get('/api/crm/lead-sources', { params: query }),
36
+
37
+ create: (input) => http.post('/api/crm/lead-sources', input),
38
+
39
+ remove: (id) => http.delete(`/api/crm/lead-sources/${id}`),
40
+ },
41
+ tags: {
42
+
43
+ list: () => http.get('/api/crm/tags'),
44
+ },
45
+ pipelines: {
46
+
47
+ list: () => http.get('/api/crm/pipelines'),
48
+
49
+ get: (id) => http.get(`/api/crm/pipelines/${id}`),
50
+
51
+ create: (input) => http.post('/api/crm/pipelines', input),
52
+
53
+ update: (id, input) => http.put(`/api/crm/pipelines/${id}`, input),
54
+
55
+ remove: (id) => http.delete(`/api/crm/pipelines/${id}`),
56
+
57
+ addStage: (pipelineId, input) => http.post(`/api/crm/pipelines/${pipelineId}/stages`, input),
58
+
59
+ reorderStages: (pipelineId, stageIds) => http.post(`/api/crm/pipelines/${pipelineId}/stages/reorder`, {
60
+ stage_ids: stageIds,
61
+ }),
62
+ },
63
+ deals: {
64
+
65
+ list: (query) => http.get('/api/crm/deals', { params: query }),
66
+
67
+ get: (id) => http.get(`/api/crm/deals/${id}`),
68
+
69
+ create: (input) => http.post('/api/crm/deals', input),
70
+
71
+ update: (id, input) => http.put(`/api/crm/deals/${id}`, input),
72
+
73
+ remove: (id) => http.delete(`/api/crm/deals/${id}`),
74
+
75
+ moveStage: (id, stageId) => http.patch(`/api/crm/deals/${id}/stage`, { stage_id: stageId }),
76
+
77
+ win: (id, quoteId) => http.post(`/api/crm/deals/${id}/win`, { quote_id: quoteId ?? null }),
78
+
79
+ lose: (id, lostReason) => http.post(`/api/crm/deals/${id}/lose`, { lost_reason: lostReason }),
80
+ },
81
+ quotes: {
82
+
83
+ list: (query) => http.get('/api/crm/quotes', { params: query }),
84
+
85
+ get: (id) => http.get(`/api/crm/quotes/${id}`),
86
+
87
+ create: (input) => http.post('/api/crm/quotes', input),
88
+
89
+ update: (id, input) => http.put(`/api/crm/quotes/${id}`, input),
90
+
91
+ remove: (id) => http.delete(`/api/crm/quotes/${id}`),
92
+
93
+ send: (id) => http.post(`/api/crm/quotes/${id}/send`),
94
+
95
+ accept: (id) => http.post(`/api/crm/quotes/${id}/accept`),
96
+
97
+ reject: (id) => http.post(`/api/crm/quotes/${id}/reject`),
98
+ },
99
+ activities: {
100
+
101
+ list: (query) => http.get('/api/crm/activities', { params: query }),
102
+
103
+ get: (id) => http.get(`/api/crm/activities/${id}`),
104
+
105
+ create: (input) => http.post('/api/crm/activities', input),
106
+
107
+ remove: (id) => http.delete(`/api/crm/activities/${id}`),
108
+ },
109
+ tasks: {
110
+
111
+ list: (query) => http.get('/api/crm/tasks', { params: query }),
112
+
113
+ get: (id) => http.get(`/api/crm/tasks/${id}`),
114
+
115
+ create: (input) => http.post('/api/crm/tasks', input),
116
+
117
+ update: (id, input) => http.put(`/api/crm/tasks/${id}`, input),
118
+
119
+ remove: (id) => http.delete(`/api/crm/tasks/${id}`),
120
+
121
+ complete: (id) => http.post(`/api/crm/tasks/${id}/complete`),
122
+ },
123
+ referralEvents: {
124
+
125
+ list: (query) => http.get('/api/crm/referral-events', { params: query }),
126
+
127
+ bySource: (query) => http.get('/api/crm/referral-events/by-source', {
128
+ params: query,
129
+ }),
130
+
131
+ create: (input) => http.post('/api/crm/referral-events', input),
132
+ },
133
+ relationshipVisits: {
134
+
135
+ list: (query) => http.get('/api/crm/relationship-visits', {
136
+ params: query,
137
+ }),
138
+
139
+ create: (input) => http.post('/api/crm/relationship-visits', input),
140
+ },
141
+ };
142
+ }