@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,123 @@
1
+ import type { Http } from './http.js';
2
+ import { type BilingualText, type PartyReference, type PersonDomainCallOptions, type PersonDomainCursorPage, type PersonDomainEnvelope } from './actors.js';
3
+ import { type ListPage, type ListQueryState } from './list-query.js';
4
+ /** `single`: one key per party (reacting with another replaces it). `multiple`: several keys. */
5
+ export type ReactionSelection = 'single' | 'multiple';
6
+ export type ReactionAudience = 'everyone' | 'owner' | 'nobody';
7
+ export interface ReactionKey {
8
+ key: string;
9
+ label: BilingualText;
10
+ symbol: string;
11
+ }
12
+ export interface ReactionSet {
13
+ subject_type: string;
14
+ selection: ReactionSelection;
15
+ count_audience: ReactionAudience;
16
+ reactor_audience: ReactionAudience;
17
+ accepts_any_symbol?: boolean;
18
+ /** `counter`: eventually consistent (queued). `current_reactions`: exact at read time. */
19
+ count_source?: 'counter' | 'current_reactions';
20
+ keys: ReactionKey[];
21
+ }
22
+ export interface ReactionSummary {
23
+ subject_type: string;
24
+ subject_id: string;
25
+ /** Per key (`{}` when nobody reacted), or NULL when counts are hidden from this viewer. */
26
+ counts: Record<string, number> | null;
27
+ total: number | null;
28
+ /** What the viewer's acting party holds. */
29
+ viewer_keys: string[];
30
+ /** The author hid this item's counts (the author still sees them; `counts` is null for others). */
31
+ counts_hidden_by_owner: boolean;
32
+ /** Open-symbol key (`symbol_…`) → the emoji to draw; declared keys carry theirs in the set. */
33
+ symbols?: Record<string, string>;
34
+ }
35
+ /**
36
+ * The key an open-symbol set stores an emoji under — the server's formula:
37
+ * `symbol_` + the first 24 hex characters of sha256(NFC(trimmed emoji)). The server checks that
38
+ * the `symbol` sent hashes to the key and is exactly one emoji (else 422 `reaction_symbol_invalid`).
39
+ */
40
+ export declare function reactionSymbolKey(emoji: string): Promise<string>;
41
+ export interface Reactor {
42
+ reaction_id: string;
43
+ reactor: PartyReference;
44
+ reaction_key: string;
45
+ reacted_at: string;
46
+ }
47
+ /** @deprecated since A3 — use {@link ReactorListQuery} with `reactorList`. Still accepted by the server. */
48
+ export interface ReactorPageQuery {
49
+ reaction_key?: string | null;
50
+ cursor?: string | null;
51
+ limit?: number;
52
+ }
53
+ /** `connected`: parties the viewer follows or is followed by (any connection kind). */
54
+ export type ReactorRelation = 'connected' | 'others';
55
+ /** The `reactions.reactors` declaration, typed narrowly; the server refuses anything else. */
56
+ export interface ReactorListQuery extends Omit<ListQueryState, 'sort' | 'filter' | 'search'> {
57
+ sort?: 'reacted_at' | '-reacted_at' | null;
58
+ filter?: {
59
+ /** One or more of the set's keys. */
60
+ reaction_key?: string[] | null;
61
+ relation?: ReactorRelation[] | null;
62
+ };
63
+ }
64
+ export type ReactionInsightInterval = 'hour' | 'day';
65
+ export interface ReactionInsightsQuery {
66
+ /** ISO-8601 instants with offset. Default: the last 30 days. */
67
+ from?: string;
68
+ to?: string;
69
+ /** `hour` spans at most 7 days, `day` at most 366. Default `day`. */
70
+ interval?: ReactionInsightInterval;
71
+ /** IANA zone; day buckets start at local midnight. Default `UTC`. */
72
+ time_zone?: string;
73
+ }
74
+ export interface ReactionInsightBucket {
75
+ starts_at: string;
76
+ added: Record<string, number>;
77
+ removed: Record<string, number>;
78
+ net: number;
79
+ }
80
+ /** The author's view of one item: totals now, and a SPARSE series (empty buckets omitted). */
81
+ export interface ReactionInsights {
82
+ subject_type: string;
83
+ subject_id: string;
84
+ from: string;
85
+ to: string;
86
+ interval: ReactionInsightInterval;
87
+ time_zone: string;
88
+ totals: Record<string, number>;
89
+ total: number;
90
+ series: ReactionInsightBucket[];
91
+ }
92
+ /** The most subject ids one `summaries` call accepts (a page of a feed). */
93
+ export declare const MAXIMUM_REACTION_SUMMARY_IDS = 100;
94
+ export declare function createReactionsNamespace(http: Http): {
95
+ /** GET /summaries — once per screen for every item it shows (≤ 100 ids). */
96
+ summaries: (subjectType: string, subjectIds: string[], options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ReactionSummary[]>>;
97
+ /** GET /sets/{type} — the keys a type offers, for the picker. */
98
+ set: (subjectType: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ReactionSet>>;
99
+ /** GET /{type}/{id}/reactors — a cursor page; hidden by the set's reactor audience. Prefer `reactorList`. */
100
+ reactors: (subjectType: string, subjectId: string, query?: ReactorPageQuery, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Reactor>>;
101
+ /**
102
+ * GET /{type}/{id}/reactors as a declared list: sort, `reaction_key` and `relation`
103
+ * filters, `describe: true` for the declaration. A cursor is bound to its question.
104
+ */
105
+ reactorList: (subjectType: string, subjectId: string, query?: ReactorListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<Reactor>>;
106
+ /** GET /{type}/{id}/insights — the owner only (404 for anyone else). */
107
+ insights: (subjectType: string, subjectId: string, query?: ReactionInsightsQuery, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ReactionInsights>>;
108
+ /** PUT /{type}/{id}/display — the owner hides or shows this item's counts; answers the owner's summary. */
109
+ setCountsHidden: (subjectType: string, subjectId: string, hidden: boolean, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ReactionSummary>>;
110
+ /**
111
+ * PUT /{type}/{id}/{key} — react. `changed` is false when it was already held. Past 12
112
+ * changes a minute on one item: 429 `reaction_too_many_changes`. For an open-symbol key
113
+ * (`reactionSymbolKey(emoji)`) pass the emoji as `symbol`.
114
+ */
115
+ react: (subjectType: string, subjectId: string, reactionKey: string, options?: PersonDomainCallOptions, symbol?: string) => Promise<PersonDomainEnvelope<ReactionSummary> & {
116
+ changed: boolean;
117
+ }>;
118
+ /** DELETE /{type}/{id}/{key} — withdraw. `changed` is false when it was not held. */
119
+ withdraw: (subjectType: string, subjectId: string, reactionKey: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ReactionSummary> & {
120
+ changed: boolean;
121
+ }>;
122
+ };
123
+ export type ReactionsNamespace = ReturnType<typeof createReactionsNamespace>;
@@ -0,0 +1,41 @@
1
+ import { personDomainRequest, } from './actors.js';
2
+ import { listQueryParams } from './list-query.js';
3
+
4
+ export async function reactionSymbolKey(emoji) {
5
+ const normalised = emoji.trim().normalize('NFC');
6
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(normalised));
7
+ const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
8
+ return `symbol_${hex.slice(0, 24)}`;
9
+ }
10
+
11
+ export const MAXIMUM_REACTION_SUMMARY_IDS = 100;
12
+ const BASE = '/api/person/reactions';
13
+ export function createReactionsNamespace(http) {
14
+ return {
15
+
16
+ summaries: (subjectType, subjectIds, options) => http.get(`${BASE}/summaries`, personDomainRequest(options, false, { subject_type: subjectType, subject_ids: subjectIds })),
17
+
18
+ set: (subjectType, options) => http.get(`${BASE}/sets/${subjectType}`, personDomainRequest(options)),
19
+
20
+ reactors: (subjectType, subjectId, query, options) => http.get(`${BASE}/${subjectType}/${subjectId}/reactors`, personDomainRequest(options, false, {
21
+ reaction_key: query?.reaction_key ?? undefined,
22
+ cursor: query?.cursor ?? undefined,
23
+ limit: query?.limit,
24
+ })),
25
+
26
+ reactorList: (subjectType, subjectId, query, options) => http.get(`${BASE}/${subjectType}/${subjectId}/reactors`, personDomainRequest(options, false, listQueryParams(query))),
27
+
28
+ insights: (subjectType, subjectId, query, options) => http.get(`${BASE}/${subjectType}/${subjectId}/insights`, personDomainRequest(options, false, {
29
+ from: query?.from,
30
+ to: query?.to,
31
+ interval: query?.interval,
32
+ time_zone: query?.time_zone,
33
+ })),
34
+
35
+ setCountsHidden: (subjectType, subjectId, hidden, options) => http.put(`${BASE}/${subjectType}/${subjectId}/display`, { counts_hidden: hidden }, personDomainRequest(options, true)),
36
+
37
+ react: (subjectType, subjectId, reactionKey, options, symbol) => http.put(`${BASE}/${subjectType}/${subjectId}/${reactionKey}`, symbol === undefined ? undefined : { symbol }, personDomainRequest(options, true)),
38
+
39
+ withdraw: (subjectType, subjectId, reactionKey, options) => http.delete(`${BASE}/${subjectType}/${subjectId}/${reactionKey}`, personDomainRequest(options, true)),
40
+ };
41
+ }
@@ -0,0 +1,294 @@
1
+ import type { Http } from './http.js';
2
+ import { type BilingualText, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
3
+ import { type ListPage, type ListQueryState } from './list-query.js';
4
+ export type RecipientOrderStatus = 'placing' | 'purchased' | 'sent' | 'opened' | 'claimed' | 'delivering' | 'delivered' | 'cashed' | 'expired' | 'cancelled' | 'failed' | (string & {});
5
+ /** Which side the reader is on: `sent` — I bought it; `received` — it was bought for me. */
6
+ export type RecipientOrderRole = 'sent' | 'received';
7
+ /** What the recipient did with a claimed order. */
8
+ export type RecipientOrderChoice = 'deliver' | 'cash';
9
+ /** The statuses in which the buyer may still cancel and issue a new link. */
10
+ export declare const RECIPIENT_ORDER_AWAITING_CLAIM: readonly RecipientOrderStatus[];
11
+ /** The statuses after which nothing more happens. */
12
+ export declare const RECIPIENT_ORDER_FINAL: readonly RecipientOrderStatus[];
13
+ /** Localised names keyed by language (`{en, ar}`), as the shop wrote them. */
14
+ export type RecipientOrderLocalisedName = Partial<BilingualText> & Record<string, string>;
15
+ export interface RecipientOrderShop {
16
+ slug: string;
17
+ name: RecipientOrderLocalisedName | string | null;
18
+ }
19
+ export interface RecipientOrderItem {
20
+ shop_item_id: string;
21
+ name: RecipientOrderLocalisedName;
22
+ quantity: number;
23
+ image_url: string | null;
24
+ }
25
+ /** What the recipient may choose once they claimed (detail and claim answers only). */
26
+ export interface RecipientOrderChoices {
27
+ deliver: boolean;
28
+ cash: {
29
+ available: boolean;
30
+ unit_key: string | null;
31
+ unit_label: RecipientOrderLocalisedName | null;
32
+ amount: string | null;
33
+ currency_code: string | null;
34
+ };
35
+ }
36
+ /** One recipient order as its reader may see it (`role` says which side). */
37
+ export interface RecipientOrder {
38
+ id: string;
39
+ role: RecipientOrderRole;
40
+ pooled?: boolean;
41
+ status: RecipientOrderStatus;
42
+ status_label: BilingualText;
43
+ choice: RecipientOrderChoice | null;
44
+ shop: RecipientOrderShop;
45
+ order_reference: string | null;
46
+ recipient_name: string;
47
+ /** Null for the recipient until moderation let it through. */
48
+ message: string | null;
49
+ /** The buyer only: `shown`, `held`, … */
50
+ message_state: string | null;
51
+ price_shown: boolean;
52
+ items: RecipientOrderItem[];
53
+ amount: string | null;
54
+ currency_code: string | null;
55
+ /** The buyer only: the balance the value is held from. */
56
+ payment_unit_key: string | null;
57
+ cash: {
58
+ unit_key: string | null;
59
+ entry_id: string | null;
60
+ } | null;
61
+ /** The buyer only: `refund` / `credit_buyer` when it ended unclaimed. */
62
+ return_outcome: string | null;
63
+ failure_reason: string | null;
64
+ /** The buyer only. */
65
+ link: {
66
+ issued_at: string | null;
67
+ links_issued: number;
68
+ live: boolean;
69
+ } | null;
70
+ expires_at: string | null;
71
+ opened_at: string | null;
72
+ claimed_at: string | null;
73
+ chosen_at: string | null;
74
+ ended_at: string | null;
75
+ created_at: string;
76
+ updated_at: string;
77
+ actions: {
78
+ issue_link: boolean;
79
+ cancel: boolean;
80
+ choose: boolean;
81
+ return_to_wallet?: boolean;
82
+ };
83
+ return?: RecipientOrderReturnTrail | null;
84
+ choices: RecipientOrderChoices | null;
85
+ /** Set by `deliver`: the consent request that lets the shop read the address. */
86
+ consent_request_id: string | null;
87
+ }
88
+ /**
89
+ * Where a return to wallet stands: `awaiting_inspection` (the shop checks the goods first),
90
+ * `partially_credited`, `credited` (final), `rejected` (the shop declined; nothing moved).
91
+ */
92
+ export type RecipientOrderReturnState = 'awaiting_inspection' | 'partially_credited' | 'credited' | 'rejected' | (string & {});
93
+ export interface RecipientOrderReturnTrail {
94
+ state: RecipientOrderReturnState | null;
95
+ /** ISO-8601, set once fully credited. */
96
+ returned_at: string | null;
97
+ }
98
+ /**
99
+ * GET /api/person/recipient-orders/{id}/return-options — what returning it would do, for the
100
+ * person it was for only (404 otherwise). Never carries a price.
101
+ *
102
+ * - `stage` — `claimed` (taken as credit at once), `before_fulfilment` (credited at once),
103
+ * `after_delivery` (per the shop's `beneficiary_return_policy`).
104
+ * - `settles` — `at_once`, or `after_inspection` (a request the shop accepts once the goods are back).
105
+ * - `refusal_reason` — `method_not_allowed` (the shop turned it off) · `no_credit_unit` ·
106
+ * `return_window_closed` · `return_pending` · `order_already_returned` · `nothing_to_return_to_wallet`.
107
+ */
108
+ export interface RecipientOrderReturnOptions {
109
+ available: boolean;
110
+ refusal_reason: string | null;
111
+ stage: 'claimed' | 'before_fulfilment' | 'after_delivery' | (string & {}) | null;
112
+ settles: 'at_once' | 'after_inspection' | (string & {});
113
+ /** The shop's `shop.beneficiary_return_to_wallet`: `instant` · `after_inspection` · `off`. */
114
+ policy?: string | null;
115
+ credit_unit_key?: string | null;
116
+ lines?: Array<{
117
+ order_line_id: string;
118
+ name: Record<string, string>;
119
+ returnable_quantity: number;
120
+ }>;
121
+ [key: string]: unknown;
122
+ }
123
+ /** POST …/return — `credited` (the value is in the wallet now) or `awaiting_inspection`. */
124
+ export interface RecipientOrderReturned {
125
+ outcome: 'credited' | 'awaiting_inspection' | (string & {});
126
+ return_id: string | null;
127
+ request_id: string | null;
128
+ /** True when this answers an earlier press (same Idempotency-Key, or already credited). */
129
+ replayed: boolean;
130
+ order: RecipientOrder;
131
+ }
132
+ export interface ReturnRecipientOrderToWalletRequest {
133
+ /** Omit for everything still returnable. */
134
+ lines?: Array<{
135
+ order_line_id: string;
136
+ quantity: number;
137
+ }>;
138
+ /** Up to 500 characters; the shop sees it, the buyer never does. */
139
+ reason?: string | null;
140
+ }
141
+ /** A newly issued link. The token is in this answer ONLY. */
142
+ export interface RecipientOrderClaimLinkIssued {
143
+ url: string;
144
+ path: string;
145
+ token: string;
146
+ order: RecipientOrder;
147
+ }
148
+ /** What a claim link shows BEFORE sign-in. Never a price unless the buyer showed it. */
149
+ /** A shop's terms for orders bought for someone else, as an order placed now would carry them. */
150
+ export interface RecipientOrderTerms {
151
+ claim_window: {
152
+ value: 'unlimited' | 'seven_days' | 'thirty_days' | 'ninety_days';
153
+ label: BilingualText;
154
+ days: number | null;
155
+ };
156
+ price_disclosure: {
157
+ value: 'hidden' | 'sender_choice';
158
+ label: BilingualText;
159
+ };
160
+ cash_out: {
161
+ value: 'none' | 'shop_credit';
162
+ label: BilingualText;
163
+ };
164
+ unclaimed_outcome: {
165
+ value: 'refund' | 'credit_buyer';
166
+ label: BilingualText;
167
+ };
168
+ /** The buyer may choose to show the price on the link. */
169
+ sender_may_show_price: boolean;
170
+ /** The recipient may take the value as the shop's credit instead of the goods. */
171
+ recipient_may_take_credit: boolean;
172
+ }
173
+ export interface RecipientOrderClaimLink {
174
+ status: RecipientOrderStatus;
175
+ shop: RecipientOrderShop;
176
+ sender_name: string | null;
177
+ recipient_name: string;
178
+ message: string | null;
179
+ items: Array<{
180
+ name: RecipientOrderLocalisedName;
181
+ quantity: number;
182
+ image_url: string | null;
183
+ }>;
184
+ price: {
185
+ amount: string;
186
+ currency_code: string;
187
+ } | null;
188
+ expires_at: string | null;
189
+ /** What claiming will offer. */
190
+ choices: {
191
+ deliver: boolean;
192
+ cash: boolean;
193
+ };
194
+ }
195
+ export interface PlaceRecipientOrderRequest {
196
+ /** The buyer's contact for the shop, as at any checkout. */
197
+ buyer: {
198
+ name: string;
199
+ phone: string;
200
+ email?: string | null;
201
+ };
202
+ /** 1–50 lines; priced by the shop, never by the client. */
203
+ items: Array<{
204
+ shop_item_id: string;
205
+ quantity: number;
206
+ }>;
207
+ /** What the buyer calls them (1–120), shown on the link. */
208
+ recipient_name: string;
209
+ /** At most 500 characters, screened before anything is placed. */
210
+ message?: string | null;
211
+ /** Honoured only where the shop's policy lets the buyer choose. */
212
+ show_price?: boolean;
213
+ /** The balance to hold the value from (must be accepted at this shop). */
214
+ unit_key: string;
215
+ }
216
+ /**
217
+ * The declared list `shop.recipient_orders`: sort `-created_at` (default) · `created_at` ·
218
+ * `-updated_at` · `updated_at`; filters `status` (one of), `created_at` (date range); folded
219
+ * search over names, shops and items (2–100 characters).
220
+ */
221
+ export type RecipientOrderListQuery = ListQueryState;
222
+ export declare const RECIPIENT_ORDER_MESSAGE_MAXIMUM_LENGTH = 500;
223
+ export declare const RECIPIENT_ORDER_RECIPIENT_NAME_MAXIMUM_LENGTH = 120;
224
+ /** A claim-link token: 43 base64url characters. */
225
+ export declare const RECIPIENT_ORDER_TOKEN_PATTERN: RegExp;
226
+ /** Stable refusal reasons (`body.reason`) of the recipient-order routes. */
227
+ export declare const RECIPIENT_ORDER_REFUSAL: {
228
+ readonly notFound: "recipient_order_not_found";
229
+ readonly ownOrder: "own_order";
230
+ readonly recipientUnavailable: "recipient_unavailable";
231
+ readonly messageRefused: "message_refused";
232
+ readonly wrongState: "recipient_order_state";
233
+ readonly cashOutUnavailable: "cash_out_unavailable";
234
+ readonly tooManyOrders: "too_many_orders";
235
+ readonly idempotencyKeyInvalid: "idempotency_key_invalid";
236
+ readonly idempotencyKeyReused: "idempotency_key_reused";
237
+ /** StoredValue's, when the hold is refused. */
238
+ readonly notAcceptedHere: "not_accepted_here";
239
+ readonly insufficientBalance: "insufficient_balance";
240
+ };
241
+ /** True when `value` looks like a claim-link token (the server is still the authority). */
242
+ export declare function isRecipientOrderToken(value: string): boolean;
243
+ export declare function createRecipientOrdersNamespace(http: Http): {
244
+ /**
245
+ * POST /api/person/shops/{slug}/recipient-orders — place an order for someone else and hold
246
+ * its value from one of your balances. `idempotencyKey` is REQUIRED: mint one per press and
247
+ * pass the SAME key on the retry of that press (201 first, 200 on a replay).
248
+ */
249
+ place: (shopSlug: string, request: PlaceRecipientOrderRequest, idempotencyKey: string, options?: Omit<PersonDomainCallOptions, "idempotencyKey">) => Promise<PersonDomainEnvelope<RecipientOrder>>;
250
+ /** GET /api/person/shops/{slug}/recipient-orders/terms — the shop's terms (price disclosure, claim window, cashing, unclaimed outcome) before placing. */
251
+ terms: (shopSlug: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrderTerms>>;
252
+ /** GET /sent — the orders I placed for others; one cursor page. Pass `describe: true` for `meta.list`. */
253
+ sent: (query?: RecipientOrderListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<RecipientOrder>>;
254
+ /** GET /received — the orders placed for me that I claimed; one cursor page. */
255
+ received: (query?: RecipientOrderListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<RecipientOrder>>;
256
+ /** GET /{id} — from either side; a claimed one also carries `choices` for the recipient. 404 when not yours. */
257
+ show: (recipientOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrder>>;
258
+ /**
259
+ * POST /{id}/link — issue the claim link, or a new one (the old stops working). The token is
260
+ * in this answer only. Sent WITHOUT an Idempotency-Key on purpose.
261
+ */
262
+ issueLink: (recipientOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrderClaimLinkIssued>>;
263
+ /** POST /{id}/cancellation — the buyer takes it back before a claim; the held value returns. */
264
+ cancel: (recipientOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrder>>;
265
+ /** POST /claims `{token}` — claim the order a link opens; the link is then spent. Answers with `choices`. */
266
+ claim: (token: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrder>>;
267
+ /** POST /openings `{token}` — the page was rendered for a signed-in person (204). The buyer's own is ignored. */
268
+ recordOpening: (token: string, options?: PersonDomainCallOptions) => Promise<void>;
269
+ /** POST /{id}/delivery `{address_id}` — one of the recipient's saved addresses (`GET /api/person/addresses`). */
270
+ deliver: (recipientOrderId: string, addressId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrder>>;
271
+ /** POST /{id}/cash — take the value as stored value in the shop's credit unit. */
272
+ cash: (recipientOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrder>>;
273
+ /**
274
+ * GET /api/person/recipient-orders/{id}/return-options — may the person it was for hand it
275
+ * back for its value in their wallet, and would it be credited at once or after the shop
276
+ * inspects it? 404 for anyone else (the buyer included).
277
+ */
278
+ returnOptions: (recipientOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<RecipientOrderReturnOptions>>;
279
+ /**
280
+ * POST /api/person/recipient-orders/{id}/return — return it to your wallet, in the shop's
281
+ * own credit (spendable wherever that credit is accepted). `idempotencyKey` is REQUIRED:
282
+ * mint one per press and resend the SAME key on a retry; a double press is one credit.
283
+ * 201 first, 200 on a replay. Refused 409 `nothing_to_return_to_wallet` ·
284
+ * `order_already_returned` · `return_pending` · `no_credit_unit`; 422 `method_not_allowed`.
285
+ */
286
+ returnToWallet: (recipientOrderId: string, request: ReturnRecipientOrderToWalletRequest, idempotencyKey: string, options?: Omit<PersonDomainCallOptions, "idempotencyKey">) => Promise<PersonDomainEnvelope<RecipientOrderReturned>>;
287
+ /** GET /api/public/recipient-orders/{token} — the claim page before sign-in. One 404 for unknown, spent or expired. */
288
+ publicLink: (token: string, options?: {
289
+ signal?: AbortSignal;
290
+ }) => Promise<PersonDomainEnvelope<RecipientOrderClaimLink>>;
291
+ /** POST /api/public/recipient-orders/{token}/opening — the page rendered for somebody not signed in (204). */
292
+ publicOpening: (token: string) => Promise<void>;
293
+ };
294
+ export type RecipientOrdersNamespace = ReturnType<typeof createRecipientOrdersNamespace>;
@@ -0,0 +1,73 @@
1
+ import { personDomainRequest } from './actors.js';
2
+ import { listQueryParams } from './list-query.js';
3
+
4
+ export const RECIPIENT_ORDER_AWAITING_CLAIM = ['purchased', 'sent', 'opened'];
5
+
6
+ export const RECIPIENT_ORDER_FINAL = ['delivered', 'cashed', 'expired', 'cancelled', 'failed'];
7
+ export const RECIPIENT_ORDER_MESSAGE_MAXIMUM_LENGTH = 500;
8
+ export const RECIPIENT_ORDER_RECIPIENT_NAME_MAXIMUM_LENGTH = 120;
9
+
10
+ export const RECIPIENT_ORDER_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
11
+
12
+ export const RECIPIENT_ORDER_REFUSAL = {
13
+ notFound: 'recipient_order_not_found',
14
+ ownOrder: 'own_order',
15
+ recipientUnavailable: 'recipient_unavailable',
16
+ messageRefused: 'message_refused',
17
+ wrongState: 'recipient_order_state',
18
+ cashOutUnavailable: 'cash_out_unavailable',
19
+ tooManyOrders: 'too_many_orders',
20
+ idempotencyKeyInvalid: 'idempotency_key_invalid',
21
+ idempotencyKeyReused: 'idempotency_key_reused',
22
+
23
+ notAcceptedHere: 'not_accepted_here',
24
+ insufficientBalance: 'insufficient_balance',
25
+ };
26
+
27
+ export function isRecipientOrderToken(value) {
28
+ return RECIPIENT_ORDER_TOKEN_PATTERN.test(value);
29
+ }
30
+ function assertToken(token) {
31
+ if (!isRecipientOrderToken(token))
32
+ throw new TypeError('recipient orders: a claim token is 43 base64url characters.');
33
+ return token;
34
+ }
35
+ const PERSON_BASE = '/api/person/recipient-orders';
36
+ const PUBLIC_BASE = '/api/public/recipient-orders';
37
+ export function createRecipientOrdersNamespace(http) {
38
+ const read = (options) => personDomainRequest(options, false);
39
+ const write = (options) => personDomainRequest(options, true);
40
+ const segment = encodeURIComponent;
41
+ return {
42
+
43
+ place: (shopSlug, request, idempotencyKey, options) => http.post(`/api/person/shops/${segment(shopSlug)}/recipient-orders`, request, personDomainRequest({ ...options, idempotencyKey }, true)),
44
+
45
+ terms: (shopSlug, options) => http.get(`/api/person/shops/${segment(shopSlug)}/recipient-orders/terms`, read(options)),
46
+
47
+ sent: (query = {}, options) => http.get(`${PERSON_BASE}/sent`, personDomainRequest(options, false, listQueryParams(query))),
48
+
49
+ received: (query = {}, options) => http.get(`${PERSON_BASE}/received`, personDomainRequest(options, false, listQueryParams(query))),
50
+
51
+ show: (recipientOrderId, options) => http.get(`${PERSON_BASE}/${segment(recipientOrderId)}`, read(options)),
52
+
53
+ issueLink: (recipientOrderId, options) => http.post(`${PERSON_BASE}/${segment(recipientOrderId)}/link`, undefined, read(options)),
54
+
55
+ cancel: (recipientOrderId, options) => http.post(`${PERSON_BASE}/${segment(recipientOrderId)}/cancellation`, undefined, write(options)),
56
+
57
+ claim: (token, options) => http.post(`${PERSON_BASE}/claims`, { token: assertToken(token) }, write(options)),
58
+
59
+ recordOpening: (token, options) => http.post(`${PERSON_BASE}/openings`, { token: assertToken(token) }, read(options)),
60
+
61
+ deliver: (recipientOrderId, addressId, options) => http.post(`${PERSON_BASE}/${segment(recipientOrderId)}/delivery`, { address_id: addressId }, write(options)),
62
+
63
+ cash: (recipientOrderId, options) => http.post(`${PERSON_BASE}/${segment(recipientOrderId)}/cash`, undefined, write(options)),
64
+
65
+ returnOptions: (recipientOrderId, options) => http.get(`${PERSON_BASE}/${segment(recipientOrderId)}/return-options`, read(options)),
66
+
67
+ returnToWallet: (recipientOrderId, request, idempotencyKey, options) => http.post(`${PERSON_BASE}/${segment(recipientOrderId)}/return`, { ...(request.lines ? { lines: request.lines } : {}), ...(request.reason ? { reason: request.reason } : {}) }, personDomainRequest({ ...options, idempotencyKey }, true)),
68
+
69
+ publicLink: (token, options) => http.get(`${PUBLIC_BASE}/${segment(assertToken(token))}`, options?.signal ? { signal: options.signal } : {}),
70
+
71
+ publicOpening: (token) => http.post(`${PUBLIC_BASE}/${segment(assertToken(token))}/opening`, undefined),
72
+ };
73
+ }
@@ -0,0 +1,18 @@
1
+ import type { Http } from './http.js';
2
+ import { type PersonDomainCallOptions } from './actors.js';
3
+ export interface RelationshipCandidate {
4
+ person_id: string;
5
+ name: string | null;
6
+ handle: string | null;
7
+ avatar_url: string | null;
8
+ /** `connection`: already connected; `directory`: found by exact handle. */
9
+ source: 'connection' | 'directory' | (string & {});
10
+ }
11
+ export declare function createRelationshipsNamespace(http: Http): {
12
+ /** People matching `query` the requester may pick (connections first, then one exact handle). */
13
+ candidates: (query: string, options?: PersonDomainCallOptions) => Promise<{
14
+ data: RelationshipCandidate[];
15
+ next_cursor: null;
16
+ }>;
17
+ };
18
+ export type RelationshipsNamespace = ReturnType<typeof createRelationshipsNamespace>;
@@ -0,0 +1,8 @@
1
+ import { personDomainRequest } from './actors.js';
2
+ const BASE = '/api/person/relationships';
3
+ export function createRelationshipsNamespace(http) {
4
+ return {
5
+
6
+ candidates: (query, options) => http.get(`${BASE}/candidates`, personDomainRequest(options, false, { q: query })),
7
+ };
8
+ }
@@ -0,0 +1,107 @@
1
+ import { type Http } from './http.js';
2
+ /** A `{en, ar}` label the config ships for suggested prompts / the panel title. */
3
+ export interface LocalizedLabel {
4
+ en: string;
5
+ ar: string;
6
+ [locale: string]: string;
7
+ }
8
+ /**
9
+ * One citation backing the answer — the concrete row/aggregate a figure traces
10
+ * to. Shape is intentionally open (`[key: string]: unknown`): the backend evolves
11
+ * the provenance payload and the UI renders whatever `label`/`entity` it finds.
12
+ */
13
+ export interface AssistantCitation {
14
+ /** The entity/source the cited datum came from (e.g. `accounting.bills`). */
15
+ entity?: string;
16
+ /** A human label for the citation (row title, metric name…). */
17
+ label?: string;
18
+ /** The cited value/aggregate, when the backend attaches one. */
19
+ value?: string | number | null;
20
+ [key: string]: unknown;
21
+ }
22
+ /** Token usage for one turn (empty `{}` when the provider reports none). */
23
+ export interface AssistantUsage {
24
+ prompt_tokens?: number;
25
+ completion_tokens?: number;
26
+ total_tokens?: number;
27
+ }
28
+ /**
29
+ * The POST `/ai/reporting/ask` response — the grounded outcome of one turn.
30
+ * Mirrors `App\Modules\AiReporting\Assistant\AssistantResult::toArray()` plus the
31
+ * `conversation_id` the controller appends.
32
+ */
33
+ export interface AssistantResult {
34
+ /** The natural-language answer (markdown). */
35
+ answer: string;
36
+ /** The real rows/aggregates that back the answer — the "sources" affordance. */
37
+ citations: AssistantCitation[];
38
+ /** The entity keys the assistant actually touched this turn. */
39
+ used_entities: string[];
40
+ /** Composed report definitions the model validated (savable). Usually `[]`. */
41
+ definitions: Array<Record<string, unknown>>;
42
+ /** The last report result (a table/preview), or `null` when the turn produced none. */
43
+ report_result: Record<string, unknown> | null;
44
+ /** Token usage for the turn. */
45
+ usage: AssistantUsage;
46
+ /** The conversation this turn belongs to — pass back to continue multi-turn. */
47
+ conversation_id?: string;
48
+ }
49
+ /** GET `/ai/config` — the launcher config the assistant UI reads. */
50
+ export interface AiReportingConfig {
51
+ /** Whether AI is enabled for this tenant. When false, hide the launcher. */
52
+ enabled: boolean;
53
+ /** How the launcher opens (`panel` | `chat` | `modal` | `page`). */
54
+ launch_mode?: string;
55
+ /** Conversation memory mode (`none` | `session` | `persisted`). */
56
+ history_mode?: string;
57
+ /** Whether the "save as report" affordance is offered. */
58
+ allow_save?: boolean;
59
+ /** Where the FAB sits (`bottom-right` | `bottom-left` | `hidden`). */
60
+ fab_position?: string;
61
+ /** Starter prompts the panel offers before the first question. */
62
+ suggested_prompts: LocalizedLabel[];
63
+ /** The bilingual panel title. */
64
+ title?: LocalizedLabel;
65
+ }
66
+ /** Arguments for a single assistant turn. */
67
+ export interface AskArgs {
68
+ /** The user's natural-language question. */
69
+ question: string;
70
+ /** The conversation to continue (from a prior `AssistantResult.conversation_id`). */
71
+ conversationId?: string;
72
+ /** Answer locale — defaults to `en` server-side. */
73
+ locale?: 'en' | 'ar' | string;
74
+ /** Prior turns to seed context when the server is not tracking the conversation. */
75
+ history?: Array<{
76
+ role: 'user' | 'assistant';
77
+ content: string;
78
+ }>;
79
+ }
80
+ export interface ReportingNamespace {
81
+ /**
82
+ * POST `/api/v1/ai/reporting/ask` — ask the ERP a question in natural
83
+ * language. Resolves with the grounded {@link AssistantResult}. Rejects with
84
+ * an `NuwahApiError` on 403 / 503 (`ai_disabled`) / 402 (`ai_credits_exhausted`)
85
+ * / 429 (`rate_limited`) — read `error.status` / `error.body.code` to branch.
86
+ *
87
+ * The server answers `text/event-stream` (`token` deltas, then one `done` frame
88
+ * carrying the result, or one `error` frame). Its guard failures arrive INSIDE a
89
+ * 200 stream, so they are re-raised here as the same `NuwahApiError` (status
90
+ * mapped from the frame's `code`) a pre-stream failure would raise.
91
+ */
92
+ ask(args: AskArgs): Promise<AssistantResult>;
93
+ /**
94
+ * GET `/api/v1/ai/config` — the launcher config. Never 503s; returns
95
+ * `{ enabled: false }` when AI is off.
96
+ */
97
+ config(): Promise<AiReportingConfig>;
98
+ }
99
+ /**
100
+ * Turn the `/ask` answer into the final {@link AssistantResult}, mirroring core's
101
+ * own client (`@nuwah/ui/lib/ai-reporting-api`): ignore `token` frames, resolve on
102
+ * `done`, throw on `error`. The transport hands back the raw text when the body is
103
+ * not JSON (an SSE stream never is); a JSON object is accepted as-is so a server
104
+ * that answers plain JSON keeps working.
105
+ */
106
+ export declare function assistantResultFromAskResponse(response: unknown): AssistantResult;
107
+ export declare function createReportingNamespace(http: Http): ReportingNamespace;