@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,405 @@
1
+ import type { Http } from './http.js';
2
+ import { type ActorSummary, type PersonDomainCallOptions } from './actors.js';
3
+ import { type ListPage, type ListQueryState } from './list-query.js';
4
+ export type PersonConversationKind = 'direct' | 'group' | 'dm' | 'space_room' | 'actor_inbox';
5
+ /** Another person of a room, named by the platform's person directory (null when none can name them). */
6
+ export interface PersonConversationParticipant {
7
+ person_id: string;
8
+ display_name: string | null;
9
+ }
10
+ export interface PersonConversationSummary {
11
+ id: string;
12
+ type: PersonConversationKind | string;
13
+ title: string | null;
14
+ /** The room's title, else its other people's names joined — what a chat picker shows; null when nobody could be named. */
15
+ display_title?: string | null;
16
+ org_context_id: string | null;
17
+ participant_person_ids: string[];
18
+ other_participants?: PersonConversationParticipant[];
19
+ last_message_at: string | null;
20
+ last_message_preview: string | null;
21
+ last_read_at: string | null;
22
+ unread_count: number;
23
+ party_actor_id?: string | null;
24
+ archived: boolean;
25
+ archived_at: string | null;
26
+ created_at: string | null;
27
+ }
28
+ /** The `messaging.person_conversations` declaration, typed narrowly; the server refuses anything else. */
29
+ export interface PersonConversationListQuery extends Omit<ListQueryState, 'sort' | 'filter'> {
30
+ sort?: 'last_activity' | '-last_activity' | null;
31
+ filter?: {
32
+ unread?: boolean | null;
33
+ /** true: only archived rooms. false: only the inbox. Absent: the inbox (archived hidden). */
34
+ archived?: boolean | null;
35
+ kind?: PersonConversationKind[] | null;
36
+ };
37
+ }
38
+ export interface PersonMessageSearchResult {
39
+ id: string;
40
+ conversation_id: string;
41
+ sender_person_id: string;
42
+ type: string;
43
+ body: string;
44
+ reply_to_message_id: string | null;
45
+ created_at: string;
46
+ edited_at: string | null;
47
+ }
48
+ export interface PersonMessageSearchQuery extends Omit<ListQueryState, 'sort' | 'filter'> {
49
+ sort?: 'sent_at' | '-sent_at' | null;
50
+ filter?: {
51
+ type?: string[] | null;
52
+ };
53
+ }
54
+ export interface PersonMessageReactionCount {
55
+ emoji: string;
56
+ count: number;
57
+ /** The caller reacted with this emoji. */
58
+ reacted: boolean;
59
+ }
60
+ export interface PersonMessageReactions {
61
+ message_id: string;
62
+ reactions: PersonMessageReactionCount[];
63
+ }
64
+ export interface SpaceRoom {
65
+ conversation_id: string;
66
+ space_id: string;
67
+ /** This call created the room. */
68
+ created: boolean;
69
+ /** This call added the caller to it. */
70
+ joined: boolean;
71
+ }
72
+ /** The card a `private_reply` message carries (server-built, never client metadata). */
73
+ export interface PrivateReplyCard {
74
+ share_id: null;
75
+ context: 'private_reply';
76
+ subject_type: 'publications.item';
77
+ subject_id: string;
78
+ state: 'available' | 'unavailable';
79
+ card: Record<string, unknown> | null;
80
+ }
81
+ /**
82
+ * The 24 emoji the server records in the Reactions module (others stay chat-only). Order is the
83
+ * picker's order; a UI may offer any emoji, these are the ones counted platform-wide.
84
+ */
85
+ export declare const MESSAGE_REACTION_PALETTE: readonly ["👍", "❤️", "😂", "😮", "😢", "🙏", "🔥", "👏", "😍", "🎉", "💯", "😡", "👎", "🤔", "😊", "🥰", "😆", "😭", "🤝", "💪", "✅", "👀", "🌹", "🤲"];
86
+ /** At most this many grapheme clusters in one reaction. */
87
+ export declare const MAXIMUM_MESSAGE_REACTION_GRAPHEMES = 8;
88
+ export declare function createPersonMessagingNamespace(http: Http): {
89
+ /** One page of the caller's conversations. Ask `describe: true` once for `meta.list`. */
90
+ conversations: (query?: PersonConversationListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<PersonConversationSummary>>;
91
+ /** Search one conversation's messages (404 when the caller is not in it). */
92
+ searchMessages: (conversationId: string, query?: PersonMessageSearchQuery, options?: PersonDomainCallOptions) => Promise<ListPage<PersonMessageSearchResult>>;
93
+ archive: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
94
+ conversation_id: string;
95
+ archived: boolean;
96
+ }>;
97
+ unarchive: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
98
+ conversation_id: string;
99
+ archived: boolean;
100
+ }>;
101
+ /** React to a message with an emoji (idempotent: reacting twice changes nothing). */
102
+ react: (messageId: string, emoji: string, options?: PersonDomainCallOptions) => Promise<PersonMessageReactions>;
103
+ unreact: (messageId: string, emoji: string, options?: PersonDomainCallOptions) => Promise<PersonMessageReactions>;
104
+ /** Open a space's chat room as a member (404 when the space is not readable by the caller). */
105
+ openSpaceRoom: (spaceId: string, options?: PersonDomainCallOptions) => Promise<SpaceRoom>;
106
+ /**
107
+ * Open (or find) the caller's conversation with a profile. 404 for a missing, private, closed
108
+ * or blocked profile (one answer); 422 `own_profile` for a member; 429 after 20 new rooms an
109
+ * hour. Then read and send with the ordinary conversation routes.
110
+ */
111
+ openActorConversation: (actorId: string, options?: PersonDomainCallOptions) => Promise<{
112
+ data: OpenedActorConversation;
113
+ }>;
114
+ /** The caller's conversations with profiles, each naming its profile (`messaging.actor_conversations`). */
115
+ actorConversations: (query?: ActorConversationListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ActorConversation>>;
116
+ /** The profile's SHARED inbox. Pass `actingAs: 'actor:<id>'`; needs `messages.reply`. */
117
+ actorInbox: {
118
+ conversations: (query?: ActorInboxListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ActorInboxConversation>>;
119
+ conversation: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
120
+ data: ActorInboxConversation;
121
+ }>;
122
+ /** Answer AS the profile. Pass the same `idempotencyKey` when retrying; a replay answers `replayed: true`. */
123
+ reply: (conversationId: string, body: string, replyToMessageId?: string | null, options?: PersonDomainCallOptions, files?: ActorInboxReplyFiles | ActorInboxReplyAttachment | null) => Promise<{
124
+ data: Record<string, unknown>;
125
+ replayed: boolean;
126
+ }>;
127
+ /** Correct a reply: its author only, within the profile's `reply_edit_window`. Marks it edited. */
128
+ editReply: (conversationId: string, messageId: string, body: string, options?: PersonDomainCallOptions) => Promise<{
129
+ data: Record<string, unknown>;
130
+ }>;
131
+ /** Take a reply back: its author, or an inbox manager. */
132
+ unsendReply: (conversationId: string, messageId: string, options?: PersonDomainCallOptions) => Promise<{
133
+ data: {
134
+ id: string;
135
+ deleted: true;
136
+ };
137
+ }>;
138
+ markRead: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
139
+ data: {
140
+ conversation_id: string;
141
+ actor_read_at: string;
142
+ };
143
+ }>;
144
+ setStatus: (conversationId: string, status: ActorInboxStatus, options?: PersonDomainCallOptions) => Promise<{
145
+ data: ActorInboxConversation;
146
+ }>;
147
+ /** `null` hands the room back to the whole inbox. */
148
+ assign: (conversationId: string, assigneePersonId: string | null, options?: PersonDomainCallOptions) => Promise<{
149
+ data: ActorInboxConversation;
150
+ }>;
151
+ /** The complete set of labels; `[]` clears. */
152
+ setLabels: (conversationId: string, labelIds: string[], options?: PersonDomainCallOptions) => Promise<{
153
+ data: ActorInboxConversation;
154
+ }>;
155
+ /** Who wrote each profile reply (the business's audit view), ≤ 100 at once. */
156
+ replyAuthors: (conversationId: string, messageIds: string[], options?: PersonDomainCallOptions) => Promise<{
157
+ data: Record<string, {
158
+ person_id: string | null;
159
+ display_name: string | null;
160
+ }>;
161
+ }>;
162
+ /** The customer's rooms with the organisation's other profiles this member can work (≤ 20). */
163
+ customerHistory: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
164
+ data: ActorInboxCustomerPastConversation[];
165
+ }>;
166
+ /** The team's notes on this room's customer, newest first — never shown to the customer. */
167
+ customerNotes: (conversationId: string, options?: PersonDomainCallOptions) => Promise<{
168
+ data: ActorInboxCustomerNote[];
169
+ }>;
170
+ addCustomerNote: (conversationId: string, body: string, options?: PersonDomainCallOptions) => Promise<{
171
+ data: ActorInboxCustomerNote;
172
+ }>;
173
+ /** Its author, or an inbox manager. */
174
+ editCustomerNote: (conversationId: string, noteId: string, body: string, options?: PersonDomainCallOptions) => Promise<{
175
+ data: ActorInboxCustomerNote;
176
+ }>;
177
+ /** Soft: `restoreCustomerNote` brings it back (an Undo). */
178
+ deleteCustomerNote: (conversationId: string, noteId: string, options?: PersonDomainCallOptions) => Promise<void>;
179
+ restoreCustomerNote: (conversationId: string, noteId: string, options?: PersonDomainCallOptions) => Promise<{
180
+ data: ActorInboxCustomerNote;
181
+ }>;
182
+ labels: (query?: Omit<ListQueryState, "filter">, options?: PersonDomainCallOptions) => Promise<ListPage<ActorInboxLabel>>;
183
+ createLabel: (name: string, colour?: ActorInboxLabelColour, options?: PersonDomainCallOptions) => Promise<{
184
+ data: ActorInboxLabel;
185
+ }>;
186
+ updateLabel: (labelId: string, changes: {
187
+ name?: string;
188
+ colour?: ActorInboxLabelColour;
189
+ }, options?: PersonDomainCallOptions) => Promise<{
190
+ data: ActorInboxLabel;
191
+ }>;
192
+ deleteLabel: (labelId: string, options?: PersonDomainCallOptions) => Promise<void>;
193
+ quickReplies: (query?: Omit<ListQueryState, "filter">, options?: PersonDomainCallOptions) => Promise<ListPage<ActorQuickReply>>;
194
+ createQuickReply: (shortcut: string, body: string, options?: PersonDomainCallOptions) => Promise<{
195
+ data: ActorQuickReply;
196
+ }>;
197
+ updateQuickReply: (quickReplyId: string, changes: {
198
+ shortcut?: string;
199
+ body?: string;
200
+ }, options?: PersonDomainCallOptions) => Promise<{
201
+ data: ActorQuickReply;
202
+ }>;
203
+ deleteQuickReply: (quickReplyId: string, options?: PersonDomainCallOptions) => Promise<void>;
204
+ /** Who can be assigned (members holding `messages.reply`), named; one bounded page (≤ 200). */
205
+ members: (options?: PersonDomainCallOptions) => Promise<{
206
+ data: ActorInboxMember[];
207
+ }>;
208
+ settings: (options?: PersonDomainCallOptions) => Promise<{
209
+ data: ActorInboxSettings;
210
+ }>;
211
+ saveSettings: (awayMessage: string | null, options?: PersonDomainCallOptions) => Promise<{
212
+ data: ActorInboxSettings;
213
+ }>;
214
+ };
215
+ };
216
+ /** What a customer sees of their conversation with a profile — never the business's working state. */
217
+ export interface ActorConversation {
218
+ id: string;
219
+ actor_id: string;
220
+ /** The profile as the caller may see it; null when they no longer may (closed, private, blocked). */
221
+ profile: {
222
+ handle: string | null;
223
+ display_name: {
224
+ en?: string | null;
225
+ ar?: string | null;
226
+ };
227
+ avatar_url: string | null;
228
+ verified: boolean;
229
+ } | null;
230
+ last_message_at: string | null;
231
+ last_message_preview: string | null;
232
+ created_at: string;
233
+ }
234
+ export interface OpenedActorConversation {
235
+ conversation_id: string;
236
+ actor_id: string;
237
+ created: boolean;
238
+ }
239
+ export interface ActorConversationListQuery extends Omit<ListQueryState, 'sort' | 'filter'> {
240
+ sort?: 'last_activity' | '-last_activity' | null;
241
+ filter?: {
242
+ actor?: string | null;
243
+ };
244
+ }
245
+ export type ActorInboxStatus = 'open' | 'closed';
246
+ /** A team note on a room's customer; the customer never sees it. */
247
+ export interface ActorInboxCustomerNote {
248
+ id: string;
249
+ body: string;
250
+ author: {
251
+ person_id: string;
252
+ display_name: string | null;
253
+ } | null;
254
+ created_at: string | null;
255
+ edited_at: string | null;
256
+ deleted_at: string | null;
257
+ /** The author, or an inbox manager. */
258
+ may_change: boolean;
259
+ }
260
+ /** The customer's room with another profile linked to the same organisation. */
261
+ export interface ActorInboxCustomerPastConversation {
262
+ conversation_id: string;
263
+ actor: {
264
+ id: string;
265
+ display_name: {
266
+ en: string;
267
+ ar: string;
268
+ };
269
+ handle: string;
270
+ };
271
+ status: ActorInboxStatus | string;
272
+ last_message_at: string | null;
273
+ last_message_preview: string | null;
274
+ created_at: string | null;
275
+ }
276
+ export type ActorInboxLabelColour = 'neutral' | 'blue' | 'green' | 'amber' | 'red' | 'purple';
277
+ /** One room of a profile's shared inbox, as its members see it. */
278
+ export interface ActorInboxConversation {
279
+ id: string;
280
+ actor_id: string;
281
+ /** `profile`: their public personal profile as the reader may see it (null when hidden or none). */
282
+ customer: {
283
+ person_id: string;
284
+ display_name: string | null;
285
+ profile?: ActorSummary | null;
286
+ };
287
+ status: ActorInboxStatus;
288
+ assignee: {
289
+ person_id: string;
290
+ display_name: string | null;
291
+ } | null;
292
+ labels: string[];
293
+ last_message_at: string | null;
294
+ last_message_preview: string | null;
295
+ last_customer_message_at: string | null;
296
+ first_response_at: string | null;
297
+ actor_read_at: string | null;
298
+ unread_count: number;
299
+ closed_at: string | null;
300
+ created_at: string;
301
+ }
302
+ export interface ActorInboxListQuery extends Omit<ListQueryState, 'sort' | 'filter'> {
303
+ sort?: 'last_activity' | '-last_activity' | null;
304
+ filter?: {
305
+ status?: ActorInboxStatus | null;
306
+ assigned?: boolean | null;
307
+ /** A member's person id — pass your own for "mine". */
308
+ assignee?: string | null;
309
+ label?: string | null;
310
+ unread?: boolean | null;
311
+ };
312
+ }
313
+ export interface ActorInboxLabel {
314
+ id: string;
315
+ actor_id: string;
316
+ name: string;
317
+ colour: ActorInboxLabelColour;
318
+ updated_at: string;
319
+ }
320
+ export interface ActorQuickReply {
321
+ id: string;
322
+ actor_id: string;
323
+ shortcut: string;
324
+ body: string;
325
+ updated_at: string;
326
+ }
327
+ /** The inbox policies' wire values (declared by core's `ActorInboxPolicies`, quiet by default). */
328
+ export type ActorInboxAwayMessageMode = 'off' | 'outside_opening_hours';
329
+ export type ActorInboxReplierReveal = 'none' | 'first_name';
330
+ /** Who may change the inbox policies: the profile's managers (default), or inbox managers too. */
331
+ export type ActorInboxSettingsManagers = 'actor_managers' | 'inbox_managers';
332
+ /** How long the author may still edit a reply (`off` = never). Default `15_minutes`. */
333
+ export type ActorInboxReplyEditWindow = 'off' | '5_minutes' | '15_minutes' | '1_hour' | '24_hours';
334
+ /** The inbox policy keys, for Actors' `PUT api/person/actors/{actor}/policies/{policyKey}`. */
335
+ export declare const ACTOR_INBOX_POLICY_KEYS: {
336
+ readonly awayMessage: "actor_inbox.away_message";
337
+ readonly revealReplier: "actor_inbox.reveal_replier";
338
+ readonly settingsManagedBy: "actor_inbox.settings_managed_by";
339
+ readonly replyEditWindow: "actor_inbox.reply_edit_window";
340
+ };
341
+ /** The policy route's refusal for a member it does not admit ("Only the profile's managers can change this."). */
342
+ export declare const ACTOR_POLICY_CHOICE_NEEDS_MANAGER = "actor_policy_choice_needs_manager";
343
+ /**
344
+ * The media purpose of a chat message's files (person or profile). Upload with
345
+ * `media.upload(file, { purpose: PERSON_MESSAGE_ATTACHMENT_PURPOSE })` — acting as the profile for
346
+ * a profile reply — and send the ready asset ids as `media_ids`. A message answers its files as
347
+ * `attachments` (Media's asset shape: signed, short-lived links, for the room's participants only).
348
+ */
349
+ export declare const PERSON_MESSAGE_ATTACHMENT_PURPOSE = "messaging.person_attachment";
350
+ /** Files on a profile reply: person media owned by the profile, settled `ready` (at most 10). */
351
+ export interface ActorInboxReplyFiles {
352
+ media_ids: string[];
353
+ }
354
+ export interface ActorInboxReplyAttachment {
355
+ path: string;
356
+ original_name?: string | null;
357
+ }
358
+ export interface ActorInboxSettings {
359
+ actor_id: string;
360
+ away_message: string | null;
361
+ updated_at: string | null;
362
+ /**
363
+ * The RESOLVED policies for this profile (platform → vertical → organisation → profile). The
364
+ * defaults are the quiet ones: no automatic answer, and customers never see who replied.
365
+ */
366
+ policies: {
367
+ away_message: ActorInboxAwayMessageMode;
368
+ reveal_replier: ActorInboxReplierReveal;
369
+ settings_managed_by: ActorInboxSettingsManagers;
370
+ reply_edit_window: ActorInboxReplyEditWindow;
371
+ };
372
+ /**
373
+ * `may_manage`: holds `messages.manage_inbox` (labels, quick replies, away text).
374
+ * `may_change_policies`: the policy route will accept this caller's choice of the inbox policies.
375
+ * `may_choose_settings_managers`: a profile manager, who alone chooses `settings_managed_by`.
376
+ */
377
+ viewer: {
378
+ may_manage: boolean;
379
+ may_change_policies: boolean;
380
+ may_choose_settings_managers: boolean;
381
+ };
382
+ }
383
+ /** A member who can work the inbox (holds `messages.reply`) — an assignment choice. */
384
+ export interface ActorInboxMember {
385
+ person_id: string;
386
+ /** Null when no directory can name them: show a neutral label, never the id. */
387
+ display_name: string | null;
388
+ is_viewer: boolean;
389
+ }
390
+ /**
391
+ * Where a profile-inbox notification lands: the person messenger acting as the profile, the room
392
+ * open (`/messenger?as=actor:<id>&conversation=<id>`). Core writes the same path on the bell item.
393
+ */
394
+ export declare function actorInboxDestination(actorId: string, conversationId?: string | null): string;
395
+ /**
396
+ * A profile reply's message metadata. Trust it ONLY on a message whose `sender_person_id` is the
397
+ * room's profile (`actor_id`): only the profile's inbox can write such a message.
398
+ */
399
+ export interface ActorReplyMetadata {
400
+ actor_reply?: {
401
+ replier_first_name?: string;
402
+ automatic?: 'away_message';
403
+ };
404
+ }
405
+ export type PersonMessagingNamespace = ReturnType<typeof createPersonMessagingNamespace>;
@@ -0,0 +1,112 @@
1
+ import { personDomainRequest } from './actors.js';
2
+ import { listQueryParams } from './list-query.js';
3
+
4
+ export const MESSAGE_REACTION_PALETTE = [
5
+ '👍', '❤️', '😂', '😮', '😢', '🙏', '🔥', '👏', '😍', '🎉', '💯', '😡',
6
+ '👎', '🤔', '😊', '🥰', '😆', '😭', '🤝', '💪', '✅', '👀', '🌹', '🤲',
7
+ ];
8
+
9
+ export const MAXIMUM_MESSAGE_REACTION_GRAPHEMES = 8;
10
+ const BASE = '/api/person';
11
+ function filterParams(filter) {
12
+ if (!filter)
13
+ return undefined;
14
+ const result = {};
15
+ for (const [key, value] of Object.entries(filter)) {
16
+ if (value === null || value === undefined)
17
+ continue;
18
+ if (Array.isArray(value) && value.length === 0)
19
+ continue;
20
+ result[key] = value;
21
+ }
22
+ return result;
23
+ }
24
+ export function createPersonMessagingNamespace(http) {
25
+ return {
26
+
27
+ conversations: (query = {}, options) => http.get(`${BASE}/conversations`, personDomainRequest(options, false, listQueryParams({ ...query, filter: filterParams(query.filter) }))),
28
+
29
+ searchMessages: (conversationId, query = {}, options) => http.get(`${BASE}/conversations/${encodeURIComponent(conversationId)}/messages/search`, personDomainRequest(options, false, listQueryParams({ ...query, filter: filterParams(query.filter) }))),
30
+ archive: (conversationId, options) => http.put(`${BASE}/conversations/${encodeURIComponent(conversationId)}/archive`, undefined, personDomainRequest(options, true)),
31
+ unarchive: (conversationId, options) => http.delete(`${BASE}/conversations/${encodeURIComponent(conversationId)}/archive`, personDomainRequest(options, true)),
32
+
33
+ react: (messageId, emoji, options) => http.post(`${BASE}/messages/${encodeURIComponent(messageId)}/reactions`, { emoji }, personDomainRequest(options, true)),
34
+ unreact: (messageId, emoji, options) => http.delete(`${BASE}/messages/${encodeURIComponent(messageId)}/reactions/${encodeURIComponent(emoji)}`, personDomainRequest(options, true)),
35
+
36
+ openSpaceRoom: (spaceId, options) => http.post(`${BASE}/spaces/${encodeURIComponent(spaceId)}/room`, undefined, personDomainRequest(options, true)),
37
+
38
+ openActorConversation: (actorId, options) => http.post(`${BASE}/actor-conversations`, { actor_id: actorId }, personDomainRequest({ ...options, actingAs: null }, true)),
39
+
40
+ actorConversations: (query = {}, options) => http.get(`${BASE}/actor-conversations`, personDomainRequest({ ...options, actingAs: null }, false, listQueryParams({ ...query, filter: filterParams(query.filter) }))),
41
+
42
+ actorInbox: createActorInboxNamespace(http),
43
+ };
44
+ }
45
+
46
+ export const ACTOR_INBOX_POLICY_KEYS = {
47
+ awayMessage: 'actor_inbox.away_message',
48
+ revealReplier: 'actor_inbox.reveal_replier',
49
+ settingsManagedBy: 'actor_inbox.settings_managed_by',
50
+ replyEditWindow: 'actor_inbox.reply_edit_window',
51
+ };
52
+
53
+ export const ACTOR_POLICY_CHOICE_NEEDS_MANAGER = 'actor_policy_choice_needs_manager';
54
+
55
+ export const PERSON_MESSAGE_ATTACHMENT_PURPOSE = 'messaging.person_attachment';
56
+
57
+ export function actorInboxDestination(actorId, conversationId) {
58
+ const query = new URLSearchParams({ as: `actor:${actorId.toLowerCase()}` });
59
+ if (conversationId)
60
+ query.set('conversation', conversationId.toLowerCase());
61
+ return `/messenger?${query.toString()}`;
62
+ }
63
+ function createActorInboxNamespace(http) {
64
+ const inbox = `${BASE}/actor-inbox`;
65
+ const room = (conversationId) => `${inbox}/conversations/${encodeURIComponent(conversationId)}`;
66
+ return {
67
+ conversations: (query = {}, options) => http.get(`${inbox}/conversations`, personDomainRequest(options, false, listQueryParams({ ...query, filter: filterParams(query.filter) }))),
68
+ conversation: (conversationId, options) => http.get(room(conversationId), personDomainRequest(options)),
69
+
70
+ reply: (conversationId, body, replyToMessageId, options, files) => http.post(`${room(conversationId)}/messages`, {
71
+ body,
72
+ reply_to_message_id: replyToMessageId ?? null,
73
+ ...(files && 'media_ids' in files && files.media_ids.length > 0 ? { media_ids: files.media_ids } : {}),
74
+
75
+ ...(files && 'path' in files ? { attachment: files } : {}),
76
+ }, personDomainRequest(options, true)),
77
+
78
+ editReply: (conversationId, messageId, body, options) => http.patch(`${room(conversationId)}/messages/${encodeURIComponent(messageId)}`, { body }, personDomainRequest(options, true)),
79
+
80
+ unsendReply: (conversationId, messageId, options) => http.delete(`${room(conversationId)}/messages/${encodeURIComponent(messageId)}`, personDomainRequest(options, true)),
81
+ markRead: (conversationId, options) => http.put(`${room(conversationId)}/read`, undefined, personDomainRequest(options, true)),
82
+ setStatus: (conversationId, status, options) => http.put(`${room(conversationId)}/status`, { status }, personDomainRequest(options, true)),
83
+
84
+ assign: (conversationId, assigneePersonId, options) => http.put(`${room(conversationId)}/assignment`, { assignee_person_id: assigneePersonId }, personDomainRequest(options, true)),
85
+
86
+ setLabels: (conversationId, labelIds, options) => http.put(`${room(conversationId)}/labels`, { label_ids: labelIds }, personDomainRequest(options, true)),
87
+
88
+ replyAuthors: (conversationId, messageIds, options) => http.get(`${room(conversationId)}/reply-authors`, personDomainRequest(options, false, { 'message_ids[]': messageIds })),
89
+
90
+ customerHistory: (conversationId, options) => http.get(`${room(conversationId)}/customer/history`, personDomainRequest(options, false)),
91
+
92
+ customerNotes: (conversationId, options) => http.get(`${room(conversationId)}/customer/notes`, personDomainRequest(options, false)),
93
+ addCustomerNote: (conversationId, body, options) => http.post(`${room(conversationId)}/customer/notes`, { body }, personDomainRequest(options, true)),
94
+
95
+ editCustomerNote: (conversationId, noteId, body, options) => http.patch(`${room(conversationId)}/customer/notes/${encodeURIComponent(noteId)}`, { body }, personDomainRequest(options, true)),
96
+
97
+ deleteCustomerNote: (conversationId, noteId, options) => http.delete(`${room(conversationId)}/customer/notes/${encodeURIComponent(noteId)}`, personDomainRequest(options, true)),
98
+ restoreCustomerNote: (conversationId, noteId, options) => http.post(`${room(conversationId)}/customer/notes/${encodeURIComponent(noteId)}/restore`, {}, personDomainRequest(options, true)),
99
+ labels: (query = {}, options) => http.get(`${inbox}/labels`, personDomainRequest(options, false, listQueryParams(query))),
100
+ createLabel: (name, colour = 'neutral', options) => http.post(`${inbox}/labels`, { name, colour }, personDomainRequest(options, true)),
101
+ updateLabel: (labelId, changes, options) => http.patch(`${inbox}/labels/${encodeURIComponent(labelId)}`, changes, personDomainRequest(options, true)),
102
+ deleteLabel: (labelId, options) => http.delete(`${inbox}/labels/${encodeURIComponent(labelId)}`, personDomainRequest(options, true)),
103
+ quickReplies: (query = {}, options) => http.get(`${inbox}/quick-replies`, personDomainRequest(options, false, listQueryParams(query))),
104
+ createQuickReply: (shortcut, body, options) => http.post(`${inbox}/quick-replies`, { shortcut, body }, personDomainRequest(options, true)),
105
+ updateQuickReply: (quickReplyId, changes, options) => http.patch(`${inbox}/quick-replies/${encodeURIComponent(quickReplyId)}`, changes, personDomainRequest(options, true)),
106
+ deleteQuickReply: (quickReplyId, options) => http.delete(`${inbox}/quick-replies/${encodeURIComponent(quickReplyId)}`, personDomainRequest(options, true)),
107
+
108
+ members: (options) => http.get(`${inbox}/members`, personDomainRequest(options)),
109
+ settings: (options) => http.get(`${inbox}/settings`, personDomainRequest(options)),
110
+ saveSettings: (awayMessage, options) => http.put(`${inbox}/settings`, { away_message: awayMessage }, personDomainRequest(options, true)),
111
+ };
112
+ }