@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,278 @@
1
+ /**
2
+ * Connections — `/api/person/connections/*`: the social graph between parties.
3
+ *
4
+ * Core declares two neutral kinds, `directed` (one way, open by default) and `mutual` (both ways,
5
+ * by approval); a vertical declares its own (`<vertical>.<name>`) and NAMES them through its
6
+ * vocabulary — "follow", "subscribe", "friend" are product words and never appear here.
7
+ *
8
+ * Every party the acting party may not see answers 404 `not_found`, whether it exists, is hidden
9
+ * or has blocked the viewer — the API never says "this party blocked you", and neither should a
10
+ * client. Every list is a DECLARED list (`list-query.ts`): `sort`, `filter[...]`, `search`,
11
+ * `cursor`, `limit`, `describe`; follow `next_cursor`, never count.
12
+ *
13
+ * Act through a profile with `actingAs` (see `actors.ts`); writes carry an `Idempotency-Key`.
14
+ */
15
+ import type { Http } from './http.js';
16
+ import { type PartyReference, type PartyReferenceString, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
17
+ import { type ListPage, type ListQueryState } from './list-query.js';
18
+ export type ConnectionEdgeState = 'active' | 'ended';
19
+ export type ConnectionRequestState = 'pending' | 'accepted' | 'declined' | 'withdrawn' | 'expired';
20
+ /**
21
+ * `block` ends everything both ways; `mute` hides the party's activity from the acting party;
22
+ * `limit` quietly keeps the party's replies to itself (and, by policy, the acting party) —
23
+ * nothing ends and the limited party is never told.
24
+ */
25
+ export type RestrictionKind = 'block' | 'mute' | 'limit';
26
+ /** `outgoing`: whom the party connected to. `incoming`: who connected to the party. */
27
+ export type ConnectionListDirection = 'outgoing' | 'incoming';
28
+ export interface Connection {
29
+ id: string;
30
+ from: PartyReference;
31
+ to: PartyReference;
32
+ kind: string;
33
+ mutual: boolean;
34
+ state: ConnectionEdgeState;
35
+ source: string;
36
+ attributes: Record<string, unknown>;
37
+ created_at: string;
38
+ ended_at: string | null;
39
+ }
40
+ export interface ConnectionRequest {
41
+ id: string;
42
+ requester: PartyReference;
43
+ target: PartyReference;
44
+ kind: string;
45
+ /** A pending request past its expiry reads `expired` before the sweep marks it. */
46
+ state: ConnectionRequestState;
47
+ attributes: Record<string, unknown>;
48
+ created_at: string;
49
+ decided_at: string | null;
50
+ expires_at: string | null;
51
+ }
52
+ /**
53
+ * `PUT edges/{kind}/{party}` answers EITHER a connection (open kinds) OR a request (kinds needing
54
+ * approval). `created` is false when the same call had already succeeded — the call is idempotent.
55
+ */
56
+ export type ConnectOutcome = {
57
+ data: Connection;
58
+ outcome: 'connected';
59
+ created: boolean;
60
+ } | {
61
+ data: ConnectionRequest;
62
+ outcome: 'requested';
63
+ created: boolean;
64
+ };
65
+ /** One row of a connection list: a party REFERENCE; resolve names through `actors.describe`. */
66
+ export interface ConnectedParty {
67
+ connection_id: string;
68
+ party: PartyReference;
69
+ kind: string;
70
+ since: string;
71
+ /** Only on the acting party's OWN list: the same kind runs the other way too. */
72
+ reciprocated?: boolean;
73
+ }
74
+ /** One kind's counts for a party: edges it holds (`outgoing`) and edges held towards it (`incoming`). */
75
+ export interface ConnectionCountPair {
76
+ outgoing: number;
77
+ incoming: number;
78
+ }
79
+ /**
80
+ * One party's counts per kind, exactly as the server sends them. A kind whose count the viewer may
81
+ * not see is ABSENT, not zero. For a followers/following display, `incoming` of the follow kind is
82
+ * the followers and `outgoing` is the following.
83
+ */
84
+ export interface ConnectionCounts {
85
+ party: PartyReference;
86
+ counts: Record<string, ConnectionCountPair>;
87
+ }
88
+ /**
89
+ * Flattens the per-kind pairs into `"<kind>:incoming"` / `"<kind>:outgoing"` keys — the flat map the
90
+ * UI's `ConnectionCounts` component draws. Absent kinds stay absent.
91
+ */
92
+ export declare function flattenConnectionCounts(counts: ConnectionCounts['counts']): Record<string, number>;
93
+ /** How the acting party stands with one other party. */
94
+ export interface ConnectionState {
95
+ party: PartyReference;
96
+ /** Kinds the acting party holds TOWARDS the party. */
97
+ outgoing: string[];
98
+ /** Kinds the party holds towards the acting party. */
99
+ incoming: string[];
100
+ pending_outgoing: string[];
101
+ pending_incoming: string[];
102
+ /** The acting party blocked this party. (The reverse is never said.) */
103
+ blocked: boolean;
104
+ muted: boolean;
105
+ /** The acting party limited this party. (The reverse is never said.) */
106
+ limited: boolean;
107
+ }
108
+ export interface Restriction {
109
+ id: string;
110
+ restricted: PartyReference;
111
+ kind: RestrictionKind;
112
+ created_at: string;
113
+ }
114
+ /**
115
+ * "Connected to X and N others you know". `sample` holds at most three parties the viewer may be
116
+ * told about (resolve names through `actors.describe`); `others` = `count` − the named ones.
117
+ * Persons are never counted; a vertical may reduce it to a count or switch it off.
118
+ */
119
+ export interface MutualConnections {
120
+ party: PartyReference;
121
+ count: number;
122
+ others: number;
123
+ sample: PartyReference[];
124
+ }
125
+ /** A party the acting party may know. `reasons` strongest first; there is no score, on purpose. */
126
+ export interface ConnectionSuggestion {
127
+ party: PartyReference;
128
+ /** `connections.mutual_connections`, `connections.follows_you`, or a vertical's own key. */
129
+ reasons: string[];
130
+ mutuals: Omit<MutualConnections, 'party'>;
131
+ }
132
+ /** A named audience list ("family", "clients"), shown only to its owner. */
133
+ export interface AudienceList {
134
+ id: string;
135
+ /** What a composer sends as the audience key to publish to this list. */
136
+ audience_key: 'connections.audience_list';
137
+ owner: PartyReference;
138
+ name: string;
139
+ member_count: number;
140
+ attributes: Record<string, unknown>;
141
+ created_at: string;
142
+ updated_at: string;
143
+ }
144
+ export interface AudienceListMember {
145
+ party: PartyReference;
146
+ added_at: string;
147
+ }
148
+ /** `GET export` — the acting party's connections, for moving elsewhere. */
149
+ export interface ConnectionsExport {
150
+ format: 'nuwah.connections.export';
151
+ version: 1;
152
+ party: PartyReference;
153
+ generated_at: string;
154
+ connections: ConnectionsExportRow[];
155
+ requests: ConnectionsExportRow[];
156
+ restrictions: ConnectionsExportRow[];
157
+ audience_lists: Array<{
158
+ name: string;
159
+ created_at: string;
160
+ members: Array<{
161
+ party: ConnectionsExportParty;
162
+ added_at: string;
163
+ }>;
164
+ }>;
165
+ }
166
+ export interface ConnectionsExportParty extends PartyReference {
167
+ handle?: string | null;
168
+ name?: {
169
+ en: string;
170
+ ar: string;
171
+ };
172
+ }
173
+ export interface ConnectionsExportRow {
174
+ direction: 'outgoing' | 'incoming' | 'placed';
175
+ kind: string;
176
+ party: ConnectionsExportParty;
177
+ since: string;
178
+ }
179
+ /**
180
+ * A connection list query. `direction` picks followers or following; the rest is the declared
181
+ * list: `connections.edges` sorts by `connected_at`, filters `connected_at` (date range) and
182
+ * `reciprocated` (own list only), and searches by name or handle.
183
+ */
184
+ export interface ConnectionPageQuery extends ListQueryState {
185
+ direction?: ConnectionListDirection;
186
+ }
187
+ export interface ConnectionRequestsQuery extends ListQueryState {
188
+ /** Shorthand for `filter: { kind }`. */
189
+ kind?: string;
190
+ }
191
+ export declare function createConnectionsNamespace(http: Http): {
192
+ /** GET /counts?parties[]= — at most 200; parties the viewer cannot see are absent. */
193
+ counts: (parties: Array<PartyReference | PartyReferenceString>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionCounts[]>>;
194
+ /** POST /relations — how the acting party stands with each visible party (≤ 200). */
195
+ relations: (parties: Array<PartyReference | PartyReferenceString>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionState[]>>;
196
+ /** GET /edges/{kind} — the acting party's own list of one kind (`connections.edges`). */
197
+ mine: (kind: string, query?: ConnectionPageQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ConnectedParty>>;
198
+ /** GET /parties/{party}/edges/{kind} — someone else's list, as its list policy allows (`connections.party_edges`). */
199
+ theirs: (party: PartyReference, kind: string, query?: ConnectionPageQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ConnectedParty>>;
200
+ /** PUT /edges/{kind}/{party} — connect, or open a request when the kind needs approval. */
201
+ connect: (party: PartyReference, kind: string, attributes?: Record<string, unknown>, options?: PersonDomainCallOptions) => Promise<ConnectOutcome>;
202
+ /**
203
+ * DELETE /edges/{kind}/{party} — end a connection. `incoming` removes the party's edge TO
204
+ * the acting party; prefer `removeFollower`, which names that. Idempotent.
205
+ */
206
+ end: (party: PartyReference, kind: string, direction?: ConnectionListDirection, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
207
+ ended: boolean;
208
+ }>>;
209
+ /** DELETE /followers/{kind}/{party} — remove a follower: quiet, no block, they may follow again. */
210
+ removeFollower: (party: PartyReference, kind: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
211
+ ended: boolean;
212
+ }>>;
213
+ /** GET /mutuals?parties[]= — at most 50; every party asked is answered (zero when nothing may be said). */
214
+ mutuals: (parties: Array<PartyReference | PartyReferenceString>, kind?: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<MutualConnections[]>>;
215
+ suggestions: {
216
+ /** GET /suggestions — ranked, at most 50, each with its connections in common. */
217
+ list: (query?: {
218
+ kind?: string;
219
+ limit?: number;
220
+ }, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionSuggestion[]>>;
221
+ /** POST /suggestions/{party}/dismiss — "not interested"; idempotent, never suggested again. */
222
+ dismiss: (party: PartyReference, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
223
+ dismissed: true;
224
+ created: boolean;
225
+ }>>;
226
+ };
227
+ requests: {
228
+ /** GET /requests/incoming — the inbox: pending and not lapsed (`connections.requests`). */
229
+ incoming: (query?: ConnectionRequestsQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ConnectionRequest>>;
230
+ /** GET /requests/outgoing — what the acting party is still waiting on. */
231
+ outgoing: (query?: ConnectionRequestsQuery, options?: PersonDomainCallOptions) => Promise<ListPage<ConnectionRequest>>;
232
+ /** Deciding again the same way answers the same request (idempotent). */
233
+ accept: (requestId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionRequest>>;
234
+ decline: (requestId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionRequest>>;
235
+ withdraw: (requestId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ConnectionRequest>>;
236
+ };
237
+ restrictions: {
238
+ /** GET /restrictions/{block|mute|limit} — the acting party's own list (`connections.restrictions`). */
239
+ list: (kind: RestrictionKind, query?: ListQueryState, options?: PersonDomainCallOptions) => Promise<ListPage<Restriction>>;
240
+ /** PUT — idempotent; a block also ends live connections both ways and settles requests. */
241
+ apply: (kind: RestrictionKind, party: PartyReference, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Restriction> & {
242
+ created: boolean;
243
+ }>;
244
+ /** DELETE — `lifted` is false when there was nothing to lift. */
245
+ lift: (kind: RestrictionKind, party: PartyReference, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
246
+ lifted: boolean;
247
+ }>>;
248
+ };
249
+ audienceLists: {
250
+ /** GET /audience-lists — `sort=-created_at|name|-member_count`, `search` over the name. */
251
+ list: (query?: ListQueryState, options?: PersonDomainCallOptions) => Promise<ListPage<AudienceList>>;
252
+ get: (listId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<AudienceList>>;
253
+ /** POST — 409 `audience_list_name_taken` (compared folded), 422 `audience_list_limit_reached` / `audience_lists_closed`. */
254
+ create: (name: string, attributes?: Record<string, unknown>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<AudienceList>>;
255
+ rename: (listId: string, name: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<AudienceList>>;
256
+ /** DELETE — idempotent. */
257
+ remove: (listId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
258
+ deleted: boolean;
259
+ }>>;
260
+ /** GET /audience-lists/{id}/members — `sort=-added_at`, `filter[party_kind]`. */
261
+ members: (listId: string, query?: ListQueryState, options?: PersonDomainCallOptions) => Promise<ListPage<AudienceListMember>>;
262
+ /**
263
+ * POST — at most 200 a call. A party the owner is not connected to (or cannot see, or
264
+ * has restricted) is SKIPPED, never an error: `skipped` counts them. 422 `audience_list_full`.
265
+ */
266
+ addMembers: (listId: string, parties: Array<PartyReference | PartyReferenceString>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<AudienceList> & {
267
+ added: number;
268
+ skipped: number;
269
+ }>;
270
+ /** DELETE — idempotent. */
271
+ removeMember: (listId: string, party: PartyReference, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<{
272
+ removed: boolean;
273
+ }>>;
274
+ };
275
+ /** GET /export — the acting party's whole graph as one document; three an hour (429 `export_too_frequent`). */
276
+ exportAll: (options?: PersonDomainCallOptions) => Promise<ConnectionsExport>;
277
+ };
278
+ export type ConnectionsNamespace = ReturnType<typeof createConnectionsNamespace>;
@@ -0,0 +1,96 @@
1
+ import { partyReferenceToString, personDomainRequest, } from './actors.js';
2
+ import { listQueryParams } from './list-query.js';
3
+
4
+ export function flattenConnectionCounts(counts) {
5
+ const flat = {};
6
+ for (const [kind, pair] of Object.entries(counts)) {
7
+ flat[`${kind}:incoming`] = pair.incoming;
8
+ flat[`${kind}:outgoing`] = pair.outgoing;
9
+ }
10
+ return flat;
11
+ }
12
+ const BASE = '/api/person/connections';
13
+ function partyPath(party) {
14
+ return `${party.kind}/${party.id}`;
15
+ }
16
+ function referenceStrings(parties) {
17
+ return parties.map((party) => (typeof party === 'string' ? party : partyReferenceToString(party)));
18
+ }
19
+ function pageParams(query = {}) {
20
+ const { direction, ...list } = query;
21
+
22
+ return { direction, ...listQueryParams(list) };
23
+ }
24
+ function requestParams(query = {}) {
25
+ const { kind, ...list } = query;
26
+ return listQueryParams(kind ? { ...list, filter: { ...(list.filter ?? {}), kind } } : list);
27
+ }
28
+ export function createConnectionsNamespace(http) {
29
+ const read = (options, params) => personDomainRequest(options, false, params);
30
+ const write = (options) => personDomainRequest(options, true);
31
+ return {
32
+
33
+ counts: (parties, options) => http.get(`${BASE}/counts`, read(options, { parties: referenceStrings(parties) })),
34
+
35
+ relations: (parties, options) => http.post(`${BASE}/relations`, { parties: referenceStrings(parties) }, read(options)),
36
+
37
+ mine: (kind, query, options) => http.get(`${BASE}/edges/${kind}`, read(options, pageParams(query))),
38
+
39
+ theirs: (party, kind, query, options) => http.get(`${BASE}/parties/${partyPath(party)}/edges/${kind}`, read(options, pageParams(query))),
40
+
41
+ connect: (party, kind, attributes, options) => http.put(`${BASE}/edges/${kind}/${partyPath(party)}`, attributes ? { attributes } : undefined, write(options)),
42
+
43
+ end: (party, kind, direction = 'outgoing', options) => http.delete(`${BASE}/edges/${kind}/${partyPath(party)}`, {
44
+ ...write(options),
45
+ params: { direction },
46
+ }),
47
+
48
+ removeFollower: (party, kind, options) => http.delete(`${BASE}/followers/${kind}/${partyPath(party)}`, write(options)),
49
+
50
+ mutuals: (parties, kind = 'directed', options) => http.get(`${BASE}/mutuals`, read(options, { parties: referenceStrings(parties), kind })),
51
+ suggestions: {
52
+
53
+ list: (query, options) => http.get(`${BASE}/suggestions`, read(options, {
54
+ kind: query?.kind, limit: query?.limit,
55
+ })),
56
+
57
+ dismiss: (party, options) => http.post(`${BASE}/suggestions/${partyPath(party)}/dismiss`, undefined, write(options)),
58
+ },
59
+ requests: {
60
+
61
+ incoming: (query, options) => http.get(`${BASE}/requests/incoming`, read(options, requestParams(query))),
62
+
63
+ outgoing: (query, options) => http.get(`${BASE}/requests/outgoing`, read(options, requestParams(query))),
64
+
65
+ accept: (requestId, options) => http.post(`${BASE}/requests/${requestId}/accept`, undefined, write(options)),
66
+ decline: (requestId, options) => http.post(`${BASE}/requests/${requestId}/decline`, undefined, write(options)),
67
+ withdraw: (requestId, options) => http.post(`${BASE}/requests/${requestId}/withdraw`, undefined, write(options)),
68
+ },
69
+ restrictions: {
70
+
71
+ list: (kind, query, options) => http.get(`${BASE}/restrictions/${kind}`, read(options, listQueryParams(query))),
72
+
73
+ apply: (kind, party, options) => http.put(`${BASE}/restrictions/${kind}/${partyPath(party)}`, undefined, write(options)),
74
+
75
+ lift: (kind, party, options) => http.delete(`${BASE}/restrictions/${kind}/${partyPath(party)}`, write(options)),
76
+ },
77
+ audienceLists: {
78
+
79
+ list: (query, options) => http.get(`${BASE}/audience-lists`, read(options, listQueryParams(query))),
80
+ get: (listId, options) => http.get(`${BASE}/audience-lists/${listId}`, read(options)),
81
+
82
+ create: (name, attributes, options) => http.post(`${BASE}/audience-lists`, attributes ? { name, attributes } : { name }, write(options)),
83
+ rename: (listId, name, options) => http.patch(`${BASE}/audience-lists/${listId}`, { name }, write(options)),
84
+
85
+ remove: (listId, options) => http.delete(`${BASE}/audience-lists/${listId}`, write(options)),
86
+
87
+ members: (listId, query, options) => http.get(`${BASE}/audience-lists/${listId}/members`, read(options, listQueryParams(query))),
88
+
89
+ addMembers: (listId, parties, options) => http.post(`${BASE}/audience-lists/${listId}/members`, { parties: referenceStrings(parties) }, write(options)),
90
+
91
+ removeMember: (listId, party, options) => http.delete(`${BASE}/audience-lists/${listId}/members/${partyPath(party)}`, write(options)),
92
+ },
93
+
94
+ exportAll: (options) => http.get(`${BASE}/export`, read(options)),
95
+ };
96
+ }
@@ -0,0 +1,121 @@
1
+ import type { Http } from './http.js';
2
+ import { type PersonDomainCallOptions } from './actors.js';
3
+ export interface ContentControlBilingualText {
4
+ en: string;
5
+ ar: string;
6
+ }
7
+ export type ScreeningDecision = 'allow' | 'allow_with_label' | 'hold_for_review' | 'refuse';
8
+ export type ScreeningClassifierState = 'ran' | 'cached' | 'deferred' | 'skipped' | 'failed';
9
+ /** Declared surfaces; verticals may declare more. */
10
+ export type ScreenedSurface = 'post' | 'listing' | 'profile' | 'values_statement' | 'review' | 'promotion' | 'blueprint_text' | 'inbox_inbound' | (string & {});
11
+ export interface ScreeningVerdict {
12
+ screening_id: string;
13
+ decision: ScreeningDecision;
14
+ decision_label: ContentControlBilingualText;
15
+ /** What the author is told. Null when there is nothing to say (an allow). */
16
+ explanation: ContentControlBilingualText | null;
17
+ /** Label keys found (`contact_info`, `scam_or_fraud`, …). */
18
+ labels: string[];
19
+ /** The fields the reasons point at. */
20
+ fields: string[];
21
+ classifier: ScreeningClassifierState;
22
+ moderation_case_id: string | null;
23
+ }
24
+ export interface ScreeningSummary {
25
+ id: string;
26
+ surface: ScreenedSurface;
27
+ subject_type: string | null;
28
+ subject_id: string | null;
29
+ decision: ScreeningDecision;
30
+ decision_label: ContentControlBilingualText;
31
+ explanation: ContentControlBilingualText | null;
32
+ labels: string[];
33
+ fields: string[];
34
+ /** A hold whose Moderation case is not decided yet. */
35
+ under_review: boolean;
36
+ review_outcome: string | null;
37
+ created_at: string;
38
+ }
39
+ export interface ContentPreviewRequest {
40
+ surface: ScreenedSurface;
41
+ /** `{name: text}` — at most 20 fields of at most 20,000 characters; names like `body`, `title`. */
42
+ fields: Record<string, string | null>;
43
+ /** Prices the price-band rules check, as decimal strings: `{amount: "12.50", currency: "JOD", field: "price"}`. */
44
+ amounts?: Array<{
45
+ amount: string;
46
+ currency: string;
47
+ field?: string;
48
+ }>;
49
+ locale?: 'ar' | 'en';
50
+ }
51
+ export type ContentRuleKind = 'keyword' | 'phrase' | 'regex' | 'domain' | 'contact_info' | 'price_band';
52
+ /** Rules have no `allow`: a tenant can only add strictness. */
53
+ export type ContentRuleAction = 'label' | 'hold' | 'refuse';
54
+ export interface ContentRule {
55
+ id: string;
56
+ kind: ContentRuleKind;
57
+ action: ContentRuleAction;
58
+ /** The pattern is returned to the organisation that wrote it; never to an author. */
59
+ pattern?: string | null;
60
+ label?: string | null;
61
+ surfaces?: string[];
62
+ explanation?: ContentControlBilingualText | null;
63
+ enabled?: boolean;
64
+ [field: string]: unknown;
65
+ }
66
+ export interface ContentRuleSet {
67
+ id: string;
68
+ name: string;
69
+ enabled?: boolean;
70
+ rules?: ContentRule[];
71
+ [field: string]: unknown;
72
+ }
73
+ export interface ContentControlNamespace {
74
+ /** The verdict a composer shows before posting. Previews never reach the AI classifier. */
75
+ preview(request: ContentPreviewRequest, options?: PersonDomainCallOptions): Promise<{
76
+ data: ScreeningVerdict;
77
+ }>;
78
+ /** The author's own screening — what happened to something they posted. */
79
+ screening(id: string, options?: PersonDomainCallOptions): Promise<{
80
+ data: ScreeningSummary;
81
+ }>;
82
+ ruleSets: {
83
+ list(options?: {
84
+ signal?: AbortSignal;
85
+ }): Promise<{
86
+ data: ContentRuleSet[];
87
+ }>;
88
+ get(id: string, options?: {
89
+ signal?: AbortSignal;
90
+ }): Promise<{
91
+ data: ContentRuleSet;
92
+ }>;
93
+ create(body: Partial<ContentRuleSet>, options?: {
94
+ signal?: AbortSignal;
95
+ }): Promise<{
96
+ data: ContentRuleSet;
97
+ }>;
98
+ update(id: string, body: Partial<ContentRuleSet>, options?: {
99
+ signal?: AbortSignal;
100
+ }): Promise<{
101
+ data: ContentRuleSet;
102
+ }>;
103
+ remove(id: string, options?: {
104
+ signal?: AbortSignal;
105
+ }): Promise<void>;
106
+ addRule(ruleSetId: string, rule: Partial<ContentRule>, options?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<{
109
+ data: ContentRule;
110
+ }>;
111
+ updateRule(ruleSetId: string, ruleId: string, rule: Partial<ContentRule>, options?: {
112
+ signal?: AbortSignal;
113
+ }): Promise<{
114
+ data: ContentRule;
115
+ }>;
116
+ removeRule(ruleSetId: string, ruleId: string, options?: {
117
+ signal?: AbortSignal;
118
+ }): Promise<void>;
119
+ };
120
+ }
121
+ export declare function createContentControlNamespace(http: Http): ContentControlNamespace;
@@ -0,0 +1,23 @@
1
+ import { personDomainRequest } from './actors.js';
2
+ const PERSON = '/api/person/content-control';
3
+ const RULE_SETS = '/api/content-control/rule-sets';
4
+ function plain(options = {}) {
5
+ return options.signal ? { signal: options.signal } : {};
6
+ }
7
+ export function createContentControlNamespace(http) {
8
+ const id = encodeURIComponent;
9
+ return {
10
+ preview: (request, options = {}) => http.post(`${PERSON}/preview`, request, personDomainRequest(options)),
11
+ screening: (screeningId, options = {}) => http.get(`${PERSON}/screenings/${id(screeningId)}`, personDomainRequest(options)),
12
+ ruleSets: {
13
+ list: (options) => http.get(RULE_SETS, plain(options)),
14
+ get: (ruleSetId, options) => http.get(`${RULE_SETS}/${id(ruleSetId)}`, plain(options)),
15
+ create: (body, options) => http.post(RULE_SETS, body, plain(options)),
16
+ update: (ruleSetId, body, options) => http.patch(`${RULE_SETS}/${id(ruleSetId)}`, body, plain(options)),
17
+ remove: (ruleSetId, options) => http.delete(`${RULE_SETS}/${id(ruleSetId)}`, plain(options)),
18
+ addRule: (ruleSetId, rule, options) => http.post(`${RULE_SETS}/${id(ruleSetId)}/rules`, rule, plain(options)),
19
+ updateRule: (ruleSetId, ruleId, rule, options) => http.put(`${RULE_SETS}/${id(ruleSetId)}/rules/${id(ruleId)}`, rule, plain(options)),
20
+ removeRule: (ruleSetId, ruleId, options) => http.delete(`${RULE_SETS}/${id(ruleSetId)}/rules/${id(ruleId)}`, plain(options)),
21
+ },
22
+ };
23
+ }