@decaf-ts/integrations 0.12.0 → 0.14.0

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 (144) hide show
  1. package/dist/integrations.cjs +1 -1
  2. package/lib/cjs/calendar/environment.cjs +48 -0
  3. package/lib/cjs/calendar/environment.cjs.map +1 -0
  4. package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs +338 -0
  5. package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs.map +1 -0
  6. package/lib/cjs/calendar/google-calendar/index.cjs +20 -0
  7. package/lib/cjs/calendar/google-calendar/index.cjs.map +1 -0
  8. package/lib/cjs/comms/discord/DiscordService.cjs +318 -0
  9. package/lib/cjs/comms/discord/DiscordService.cjs.map +1 -0
  10. package/lib/cjs/comms/discord/index.cjs +19 -0
  11. package/lib/cjs/comms/discord/index.cjs.map +1 -0
  12. package/lib/cjs/comms/environment.cjs +16 -0
  13. package/lib/cjs/comms/environment.cjs.map +1 -1
  14. package/lib/cjs/comms/index.cjs +3 -0
  15. package/lib/cjs/comms/index.cjs.map +1 -1
  16. package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs +325 -0
  17. package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs.map +1 -0
  18. package/lib/cjs/comms/outlook/index.cjs +19 -0
  19. package/lib/cjs/comms/outlook/index.cjs.map +1 -0
  20. package/lib/cjs/comms/whatsapp/WhatsAppService.cjs +274 -0
  21. package/lib/cjs/comms/whatsapp/WhatsAppService.cjs.map +1 -0
  22. package/lib/cjs/comms/whatsapp/index.cjs +19 -0
  23. package/lib/cjs/comms/whatsapp/index.cjs.map +1 -0
  24. package/lib/cjs/index.cjs +3 -3
  25. package/lib/cjs/io/confluence/ConfluenceService.cjs +317 -0
  26. package/lib/cjs/io/confluence/ConfluenceService.cjs.map +1 -0
  27. package/lib/cjs/io/confluence/index.cjs +19 -0
  28. package/lib/cjs/io/confluence/index.cjs.map +1 -0
  29. package/lib/cjs/io/environment.cjs +28 -0
  30. package/lib/cjs/io/environment.cjs.map +1 -1
  31. package/lib/cjs/io/google-docs/GoogleDocsService.cjs +275 -0
  32. package/lib/cjs/io/google-docs/GoogleDocsService.cjs.map +1 -0
  33. package/lib/cjs/io/google-docs/index.cjs +19 -0
  34. package/lib/cjs/io/google-docs/index.cjs.map +1 -0
  35. package/lib/cjs/io/index.cjs +5 -0
  36. package/lib/cjs/io/index.cjs.map +1 -1
  37. package/lib/cjs/io/jira/JiraService.cjs +354 -0
  38. package/lib/cjs/io/jira/JiraService.cjs.map +1 -0
  39. package/lib/cjs/io/jira/index.cjs +19 -0
  40. package/lib/cjs/io/jira/index.cjs.map +1 -0
  41. package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs +253 -0
  42. package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs.map +1 -0
  43. package/lib/cjs/io/microsoft-excel/index.cjs +19 -0
  44. package/lib/cjs/io/microsoft-excel/index.cjs.map +1 -0
  45. package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs +261 -0
  46. package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs.map +1 -0
  47. package/lib/cjs/io/microsoft-sharepoint/index.cjs +19 -0
  48. package/lib/cjs/io/microsoft-sharepoint/index.cjs.map +1 -0
  49. package/lib/esm/calendar/environment.js +44 -0
  50. package/lib/esm/calendar/environment.js.map +1 -0
  51. package/lib/esm/calendar/google-calendar/GoogleCalendarService.js +333 -0
  52. package/lib/esm/calendar/google-calendar/GoogleCalendarService.js.map +1 -0
  53. package/lib/esm/calendar/google-calendar/index.js +3 -0
  54. package/lib/esm/calendar/google-calendar/index.js.map +1 -0
  55. package/lib/esm/comms/discord/DiscordService.js +313 -0
  56. package/lib/esm/comms/discord/DiscordService.js.map +1 -0
  57. package/lib/esm/comms/discord/index.js +2 -0
  58. package/lib/esm/comms/discord/index.js.map +1 -0
  59. package/lib/esm/comms/environment.js +16 -0
  60. package/lib/esm/comms/environment.js.map +1 -1
  61. package/lib/esm/comms/index.js +3 -0
  62. package/lib/esm/comms/index.js.map +1 -1
  63. package/lib/esm/comms/outlook/MicrosoftOutlookService.js +320 -0
  64. package/lib/esm/comms/outlook/MicrosoftOutlookService.js.map +1 -0
  65. package/lib/esm/comms/outlook/index.js +2 -0
  66. package/lib/esm/comms/outlook/index.js.map +1 -0
  67. package/lib/esm/comms/whatsapp/WhatsAppService.js +269 -0
  68. package/lib/esm/comms/whatsapp/WhatsAppService.js.map +1 -0
  69. package/lib/esm/comms/whatsapp/index.js +2 -0
  70. package/lib/esm/comms/whatsapp/index.js.map +1 -0
  71. package/lib/esm/index.js +3 -3
  72. package/lib/esm/io/confluence/ConfluenceService.js +312 -0
  73. package/lib/esm/io/confluence/ConfluenceService.js.map +1 -0
  74. package/lib/esm/io/confluence/index.js +2 -0
  75. package/lib/esm/io/confluence/index.js.map +1 -0
  76. package/lib/esm/io/environment.js +28 -0
  77. package/lib/esm/io/environment.js.map +1 -1
  78. package/lib/esm/io/google-docs/GoogleDocsService.js +270 -0
  79. package/lib/esm/io/google-docs/GoogleDocsService.js.map +1 -0
  80. package/lib/esm/io/google-docs/index.js +2 -0
  81. package/lib/esm/io/google-docs/index.js.map +1 -0
  82. package/lib/esm/io/index.js +5 -0
  83. package/lib/esm/io/index.js.map +1 -1
  84. package/lib/esm/io/jira/JiraService.js +349 -0
  85. package/lib/esm/io/jira/JiraService.js.map +1 -0
  86. package/lib/esm/io/jira/index.js +2 -0
  87. package/lib/esm/io/jira/index.js.map +1 -0
  88. package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js +248 -0
  89. package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js.map +1 -0
  90. package/lib/esm/io/microsoft-excel/index.js +2 -0
  91. package/lib/esm/io/microsoft-excel/index.js.map +1 -0
  92. package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js +256 -0
  93. package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js.map +1 -0
  94. package/lib/esm/io/microsoft-sharepoint/index.js +2 -0
  95. package/lib/esm/io/microsoft-sharepoint/index.js.map +1 -0
  96. package/lib/types/calendar/environment.d.cts +48 -0
  97. package/lib/types/calendar/environment.d.mts +48 -0
  98. package/lib/types/calendar/google-calendar/GoogleCalendarService.d.cts +316 -0
  99. package/lib/types/calendar/google-calendar/GoogleCalendarService.d.mts +316 -0
  100. package/lib/types/calendar/google-calendar/index.d.cts +2 -0
  101. package/lib/types/calendar/google-calendar/index.d.mts +2 -0
  102. package/lib/types/comms/discord/DiscordService.d.cts +285 -0
  103. package/lib/types/comms/discord/DiscordService.d.mts +285 -0
  104. package/lib/types/comms/discord/index.d.cts +1 -0
  105. package/lib/types/comms/discord/index.d.mts +1 -0
  106. package/lib/types/comms/environment.d.cts +34 -8
  107. package/lib/types/comms/environment.d.mts +34 -8
  108. package/lib/types/comms/index.d.cts +3 -0
  109. package/lib/types/comms/index.d.mts +3 -0
  110. package/lib/types/comms/outlook/MicrosoftOutlookService.d.cts +282 -0
  111. package/lib/types/comms/outlook/MicrosoftOutlookService.d.mts +282 -0
  112. package/lib/types/comms/outlook/index.d.cts +1 -0
  113. package/lib/types/comms/outlook/index.d.mts +1 -0
  114. package/lib/types/comms/whatsapp/WhatsAppService.d.cts +258 -0
  115. package/lib/types/comms/whatsapp/WhatsAppService.d.mts +258 -0
  116. package/lib/types/comms/whatsapp/index.d.cts +1 -0
  117. package/lib/types/comms/whatsapp/index.d.mts +1 -0
  118. package/lib/types/index.d.cts +2 -2
  119. package/lib/types/index.d.mts +2 -2
  120. package/lib/types/io/confluence/ConfluenceService.d.cts +250 -0
  121. package/lib/types/io/confluence/ConfluenceService.d.mts +250 -0
  122. package/lib/types/io/confluence/index.d.cts +1 -0
  123. package/lib/types/io/confluence/index.d.mts +1 -0
  124. package/lib/types/io/environment.d.cts +52 -12
  125. package/lib/types/io/environment.d.mts +52 -12
  126. package/lib/types/io/google-docs/GoogleDocsService.d.cts +188 -0
  127. package/lib/types/io/google-docs/GoogleDocsService.d.mts +188 -0
  128. package/lib/types/io/google-docs/index.d.cts +1 -0
  129. package/lib/types/io/google-docs/index.d.mts +1 -0
  130. package/lib/types/io/index.d.cts +5 -0
  131. package/lib/types/io/index.d.mts +5 -0
  132. package/lib/types/io/jira/JiraService.d.cts +300 -0
  133. package/lib/types/io/jira/JiraService.d.mts +300 -0
  134. package/lib/types/io/jira/index.d.cts +1 -0
  135. package/lib/types/io/jira/index.d.mts +1 -0
  136. package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.cts +230 -0
  137. package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.mts +230 -0
  138. package/lib/types/io/microsoft-excel/index.d.cts +1 -0
  139. package/lib/types/io/microsoft-excel/index.d.mts +1 -0
  140. package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.cts +226 -0
  141. package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.mts +226 -0
  142. package/lib/types/io/microsoft-sharepoint/index.d.cts +1 -0
  143. package/lib/types/io/microsoft-sharepoint/index.d.mts +1 -0
  144. package/package.json +101 -5
@@ -0,0 +1,258 @@
1
+ import { HttpApiService, type HttpApiServiceConfig } from "../../shared/http/index.d.cts";
2
+ /**
3
+ * @description Configuration for the WhatsApp service
4
+ * @summary Extends {@link HttpApiServiceConfig} with the Meta access token
5
+ * (sent as a bearer token) and the sender `phoneNumberId` used in the
6
+ * `/messages` path. When omitted, the `comms.whatsApp` environment slice
7
+ * supplies both (plus optional `baseUrl`/`timeout`). Both values are
8
+ * credential references, never literals in source.
9
+ * @category Comms
10
+ * @memberOf module:integrations/comms/whatsapp/service
11
+ */
12
+ export interface WhatsAppServiceConfig extends HttpApiServiceConfig {
13
+ /**
14
+ * @description Meta WhatsApp Cloud API access token
15
+ * @summary Sent as `Authorization: Bearer <token>` with every API call.
16
+ */
17
+ token?: string;
18
+ /**
19
+ * @description Sender phone number ID used in the messages path
20
+ */
21
+ phoneNumberId?: string;
22
+ }
23
+ /**
24
+ * @description Input for sending a WhatsApp text message
25
+ * @summary Carries the recipient (`to`, E.164 digits without `+`), the text
26
+ * body, and whether link previews are generated.
27
+ * @category Comms
28
+ * @memberOf module:integrations/comms/whatsapp/service
29
+ */
30
+ export interface WhatsAppTextInput {
31
+ /**
32
+ * @description Recipient phone number in international format
33
+ */
34
+ to: string;
35
+ /**
36
+ * @description Text message body
37
+ */
38
+ text: string;
39
+ /**
40
+ * @description Whether WhatsApp generates a link preview
41
+ */
42
+ previewUrl?: boolean;
43
+ }
44
+ /**
45
+ * @description Input for sending a WhatsApp template message
46
+ * @summary Carries the recipient, the approved `templateName`, its
47
+ * `languageCode`, and optional template `components`.
48
+ * @category Comms
49
+ * @memberOf module:integrations/comms/whatsapp/service
50
+ */
51
+ export interface WhatsAppTemplateInput {
52
+ /**
53
+ * @description Recipient phone number in international format
54
+ */
55
+ to: string;
56
+ /**
57
+ * @description Name of the approved message template
58
+ */
59
+ templateName: string;
60
+ /**
61
+ * @description Template language code (e.g. `"en_US"`)
62
+ */
63
+ languageCode: string;
64
+ /**
65
+ * @description Optional template components (header/body/button parameters)
66
+ */
67
+ components?: unknown[];
68
+ }
69
+ /**
70
+ * @description Supported WhatsApp media message types
71
+ * @summary The media kinds the Cloud API accepts in the message `type` field.
72
+ * @category Comms
73
+ * @memberOf module:integrations/comms/whatsapp/service
74
+ */
75
+ export type WhatsAppMediaType = "image" | "audio" | "video" | "document";
76
+ /**
77
+ * @description Input for sending a WhatsApp media message
78
+ * @summary Carries the recipient, the media `type`, and either a previously
79
+ * uploaded `mediaId` or a public `link` (one is required), plus an optional
80
+ * `caption` and `filename`.
81
+ * @category Comms
82
+ * @memberOf module:integrations/comms/whatsapp/service
83
+ */
84
+ export interface WhatsAppMediaInput {
85
+ /**
86
+ * @description Recipient phone number in international format
87
+ */
88
+ to: string;
89
+ /**
90
+ * @description Media kind sent in the message `type` field
91
+ */
92
+ type: WhatsAppMediaType;
93
+ /**
94
+ * @description ID of previously uploaded WhatsApp media
95
+ */
96
+ mediaId?: string;
97
+ /**
98
+ * @description Public URL of the media (alternative to `mediaId`)
99
+ */
100
+ link?: string;
101
+ /**
102
+ * @description Optional caption (images, videos, documents)
103
+ */
104
+ caption?: string;
105
+ /**
106
+ * @description Optional filename (documents)
107
+ */
108
+ filename?: string;
109
+ }
110
+ /**
111
+ * @description Input for marking a WhatsApp message as read
112
+ * @summary Carries the inbound `messageId` to acknowledge.
113
+ * @category Comms
114
+ * @memberOf module:integrations/comms/whatsapp/service
115
+ */
116
+ export interface WhatsAppReadInput {
117
+ /**
118
+ * @description ID of the inbound message to mark read
119
+ */
120
+ messageId: string;
121
+ }
122
+ /**
123
+ * @description WhatsApp Cloud API integration service
124
+ * @summary An undecorated HTTP service for text, template, and media
125
+ * messages, read receipts, and media metadata. Every message operation needs
126
+ * both the access token and the sender phone number ID; missing credentials or
127
+ * identifiers raise `InternalError`, and transport failures are mapped to decaf
128
+ * errors via {@link httpError}.
129
+ * @class WhatsAppService
130
+ * @extends HttpApiService
131
+ * @category Comms
132
+ * @example
133
+ * ```ts
134
+ * import { WhatsAppService } from "@decaf-ts/integrations/comms/whatsapp";
135
+ *
136
+ * const whatsapp = new WhatsAppService();
137
+ * await whatsapp.initialize({
138
+ * token: process.env.GRAPH_CREDENTIAL_WHATSAPP_TOKEN,
139
+ * phoneNumberId: process.env.WHATSAPP_PHONE_NUMBER_ID,
140
+ * });
141
+ * await whatsapp.sendText({ to: "15551234567", text: "Hello" });
142
+ * ```
143
+ * @mermaid
144
+ * sequenceDiagram
145
+ * autonumber
146
+ * participant Caller
147
+ * participant Service as WhatsAppService
148
+ * participant Graph as WhatsApp Cloud API
149
+ * Caller->>Service: sendText(input)
150
+ * activate Service
151
+ * Service->>Service: requireTokenAndPhone()
152
+ * Service->>Graph: POST /{phoneNumberId}/messages
153
+ * activate Graph
154
+ * Graph-->>Service: message payload
155
+ * deactivate Graph
156
+ * Service-->>Caller: message payload
157
+ * deactivate Service
158
+ * @memberOf module:integrations/comms/whatsapp/service
159
+ */
160
+ export declare class WhatsAppService extends HttpApiService<WhatsAppServiceConfig> {
161
+ /**
162
+ * @description The provider name used in error messages
163
+ */
164
+ protected readonly serviceName = "WhatsApp";
165
+ /**
166
+ * @description The WhatsApp Cloud API base URL
167
+ * @summary Used when the resolved config carries no `baseUrl`.
168
+ * @returns {string} `"https://graph.facebook.com/v19.0"`.
169
+ */
170
+ protected defaultBaseUrl(): string;
171
+ /**
172
+ * @description Builds the WhatsApp bearer authorization headers
173
+ * @summary Returns `Authorization: Bearer <token>` when configured, and no
174
+ * headers otherwise.
175
+ * @param {WhatsAppServiceConfig} config - The resolved service configuration.
176
+ * @returns {Record<string, string>} The authorization headers (empty without a token).
177
+ */
178
+ protected authHeaders(config: WhatsAppServiceConfig): Record<string, string>;
179
+ /**
180
+ * @description Reads the WhatsApp credentials and defaults from the environment
181
+ * @summary Reads the `comms.whatsApp` slice and returns a partial config
182
+ * when a token or phone number ID is configured, `undefined` otherwise.
183
+ * Values pass through `envString`/`envNumber` to reject unset-leaf proxies.
184
+ * @returns {Partial<WhatsAppServiceConfig> | undefined} A partial config, or `undefined` when neither credential is configured.
185
+ */
186
+ protected configFromEnvironment(): Partial<WhatsAppServiceConfig> | undefined;
187
+ /**
188
+ * @description Asserts the access token and sender phone number ID
189
+ * @summary Calls `requireToken()` and returns the configured
190
+ * `phoneNumberId` used to build the messages path.
191
+ * @returns {string} The configured sender phone number ID.
192
+ * @throws {InternalError} When no token or phone number ID is configured.
193
+ */
194
+ protected requireTokenAndPhone(): string;
195
+ /**
196
+ * @description Builds the encoded messages path for a sender
197
+ * @summary Encodes the phone number ID into `/<id>/messages`.
198
+ * @param {string} phoneNumberId - The sender phone number ID.
199
+ * @returns {string} The messages API path.
200
+ */
201
+ private messagesPath;
202
+ /**
203
+ * @description Sends a WhatsApp text message
204
+ * @summary `POST`s a `text` message to the sender's `/messages` endpoint
205
+ * and returns the WhatsApp message payload.
206
+ * @param {WhatsAppTextInput} input - The recipient, text, and preview flag.
207
+ * @returns {Promise<unknown>} The WhatsApp message payload.
208
+ * @throws {InternalError} When credentials or the phone number ID are missing.
209
+ * @throws {BadRequestError} When WhatsApp rejects the message.
210
+ * @example
211
+ * ```ts
212
+ * await whatsapp.sendText({ to: "15551234567", text: "Deployment finished" });
213
+ * ```
214
+ */
215
+ sendText(input: WhatsAppTextInput): Promise<unknown>;
216
+ /**
217
+ * @description Sends a WhatsApp template message
218
+ * @summary `POST`s a `template` message referencing an approved template
219
+ * name and language, with optional components.
220
+ * @param {WhatsAppTemplateInput} input - The recipient and template definition.
221
+ * @returns {Promise<unknown>} The WhatsApp message payload.
222
+ * @throws {InternalError} When credentials or the phone number ID are missing.
223
+ * @throws {BadRequestError} When WhatsApp rejects the template message.
224
+ */
225
+ sendTemplate(input: WhatsAppTemplateInput): Promise<unknown>;
226
+ /**
227
+ * @description Sends a WhatsApp media message
228
+ * @summary `POST`s an `image`/`audio`/`video`/`document` message using
229
+ * either an uploaded `mediaId` or a public `link`, with optional caption and
230
+ * filename.
231
+ * @param {WhatsAppMediaInput} input - The recipient and media reference.
232
+ * @returns {Promise<unknown>} The WhatsApp message payload.
233
+ * @throws {InternalError} When credentials or the phone number ID are missing, or neither `mediaId` nor `link` is provided.
234
+ * @throws {BadRequestError} When WhatsApp rejects the media message.
235
+ */
236
+ sendMedia(input: WhatsAppMediaInput): Promise<unknown>;
237
+ /**
238
+ * @description Marks an inbound WhatsApp message as read
239
+ * @summary `POST`s a `read` status for the message to the sender's
240
+ * `/messages` endpoint.
241
+ * @param {WhatsAppReadInput} input - The inbound message ID to acknowledge.
242
+ * @returns {Promise<unknown>} The WhatsApp status payload.
243
+ * @throws {InternalError} When credentials, the phone number ID, or the message ID are missing.
244
+ * @throws {BadRequestError} When WhatsApp rejects the request.
245
+ */
246
+ markAsRead(input: WhatsAppReadInput): Promise<unknown>;
247
+ /**
248
+ * @description Fetches WhatsApp media metadata
249
+ * @summary `GET`s the media descriptor (URL, MIME type, size) by media ID;
250
+ * the descriptor's URL is then used to download the binary.
251
+ * @param {string} mediaId - The WhatsApp media ID.
252
+ * @returns {Promise<unknown>} The media metadata payload.
253
+ * @throws {InternalError} When no token is configured or the media ID is empty.
254
+ * @throws {NotFoundError} When the media does not exist (HTTP 404).
255
+ * @throws {BadRequestError} When WhatsApp rejects the request.
256
+ */
257
+ getMedia(mediaId: string): Promise<unknown>;
258
+ }
@@ -0,0 +1,258 @@
1
+ import { HttpApiService, type HttpApiServiceConfig } from "../../shared/http/index.d.mts";
2
+ /**
3
+ * @description Configuration for the WhatsApp service
4
+ * @summary Extends {@link HttpApiServiceConfig} with the Meta access token
5
+ * (sent as a bearer token) and the sender `phoneNumberId` used in the
6
+ * `/messages` path. When omitted, the `comms.whatsApp` environment slice
7
+ * supplies both (plus optional `baseUrl`/`timeout`). Both values are
8
+ * credential references, never literals in source.
9
+ * @category Comms
10
+ * @memberOf module:integrations/comms/whatsapp/service
11
+ */
12
+ export interface WhatsAppServiceConfig extends HttpApiServiceConfig {
13
+ /**
14
+ * @description Meta WhatsApp Cloud API access token
15
+ * @summary Sent as `Authorization: Bearer <token>` with every API call.
16
+ */
17
+ token?: string;
18
+ /**
19
+ * @description Sender phone number ID used in the messages path
20
+ */
21
+ phoneNumberId?: string;
22
+ }
23
+ /**
24
+ * @description Input for sending a WhatsApp text message
25
+ * @summary Carries the recipient (`to`, E.164 digits without `+`), the text
26
+ * body, and whether link previews are generated.
27
+ * @category Comms
28
+ * @memberOf module:integrations/comms/whatsapp/service
29
+ */
30
+ export interface WhatsAppTextInput {
31
+ /**
32
+ * @description Recipient phone number in international format
33
+ */
34
+ to: string;
35
+ /**
36
+ * @description Text message body
37
+ */
38
+ text: string;
39
+ /**
40
+ * @description Whether WhatsApp generates a link preview
41
+ */
42
+ previewUrl?: boolean;
43
+ }
44
+ /**
45
+ * @description Input for sending a WhatsApp template message
46
+ * @summary Carries the recipient, the approved `templateName`, its
47
+ * `languageCode`, and optional template `components`.
48
+ * @category Comms
49
+ * @memberOf module:integrations/comms/whatsapp/service
50
+ */
51
+ export interface WhatsAppTemplateInput {
52
+ /**
53
+ * @description Recipient phone number in international format
54
+ */
55
+ to: string;
56
+ /**
57
+ * @description Name of the approved message template
58
+ */
59
+ templateName: string;
60
+ /**
61
+ * @description Template language code (e.g. `"en_US"`)
62
+ */
63
+ languageCode: string;
64
+ /**
65
+ * @description Optional template components (header/body/button parameters)
66
+ */
67
+ components?: unknown[];
68
+ }
69
+ /**
70
+ * @description Supported WhatsApp media message types
71
+ * @summary The media kinds the Cloud API accepts in the message `type` field.
72
+ * @category Comms
73
+ * @memberOf module:integrations/comms/whatsapp/service
74
+ */
75
+ export type WhatsAppMediaType = "image" | "audio" | "video" | "document";
76
+ /**
77
+ * @description Input for sending a WhatsApp media message
78
+ * @summary Carries the recipient, the media `type`, and either a previously
79
+ * uploaded `mediaId` or a public `link` (one is required), plus an optional
80
+ * `caption` and `filename`.
81
+ * @category Comms
82
+ * @memberOf module:integrations/comms/whatsapp/service
83
+ */
84
+ export interface WhatsAppMediaInput {
85
+ /**
86
+ * @description Recipient phone number in international format
87
+ */
88
+ to: string;
89
+ /**
90
+ * @description Media kind sent in the message `type` field
91
+ */
92
+ type: WhatsAppMediaType;
93
+ /**
94
+ * @description ID of previously uploaded WhatsApp media
95
+ */
96
+ mediaId?: string;
97
+ /**
98
+ * @description Public URL of the media (alternative to `mediaId`)
99
+ */
100
+ link?: string;
101
+ /**
102
+ * @description Optional caption (images, videos, documents)
103
+ */
104
+ caption?: string;
105
+ /**
106
+ * @description Optional filename (documents)
107
+ */
108
+ filename?: string;
109
+ }
110
+ /**
111
+ * @description Input for marking a WhatsApp message as read
112
+ * @summary Carries the inbound `messageId` to acknowledge.
113
+ * @category Comms
114
+ * @memberOf module:integrations/comms/whatsapp/service
115
+ */
116
+ export interface WhatsAppReadInput {
117
+ /**
118
+ * @description ID of the inbound message to mark read
119
+ */
120
+ messageId: string;
121
+ }
122
+ /**
123
+ * @description WhatsApp Cloud API integration service
124
+ * @summary An undecorated HTTP service for text, template, and media
125
+ * messages, read receipts, and media metadata. Every message operation needs
126
+ * both the access token and the sender phone number ID; missing credentials or
127
+ * identifiers raise `InternalError`, and transport failures are mapped to decaf
128
+ * errors via {@link httpError}.
129
+ * @class WhatsAppService
130
+ * @extends HttpApiService
131
+ * @category Comms
132
+ * @example
133
+ * ```ts
134
+ * import { WhatsAppService } from "@decaf-ts/integrations/comms/whatsapp";
135
+ *
136
+ * const whatsapp = new WhatsAppService();
137
+ * await whatsapp.initialize({
138
+ * token: process.env.GRAPH_CREDENTIAL_WHATSAPP_TOKEN,
139
+ * phoneNumberId: process.env.WHATSAPP_PHONE_NUMBER_ID,
140
+ * });
141
+ * await whatsapp.sendText({ to: "15551234567", text: "Hello" });
142
+ * ```
143
+ * @mermaid
144
+ * sequenceDiagram
145
+ * autonumber
146
+ * participant Caller
147
+ * participant Service as WhatsAppService
148
+ * participant Graph as WhatsApp Cloud API
149
+ * Caller->>Service: sendText(input)
150
+ * activate Service
151
+ * Service->>Service: requireTokenAndPhone()
152
+ * Service->>Graph: POST /{phoneNumberId}/messages
153
+ * activate Graph
154
+ * Graph-->>Service: message payload
155
+ * deactivate Graph
156
+ * Service-->>Caller: message payload
157
+ * deactivate Service
158
+ * @memberOf module:integrations/comms/whatsapp/service
159
+ */
160
+ export declare class WhatsAppService extends HttpApiService<WhatsAppServiceConfig> {
161
+ /**
162
+ * @description The provider name used in error messages
163
+ */
164
+ protected readonly serviceName = "WhatsApp";
165
+ /**
166
+ * @description The WhatsApp Cloud API base URL
167
+ * @summary Used when the resolved config carries no `baseUrl`.
168
+ * @returns {string} `"https://graph.facebook.com/v19.0"`.
169
+ */
170
+ protected defaultBaseUrl(): string;
171
+ /**
172
+ * @description Builds the WhatsApp bearer authorization headers
173
+ * @summary Returns `Authorization: Bearer <token>` when configured, and no
174
+ * headers otherwise.
175
+ * @param {WhatsAppServiceConfig} config - The resolved service configuration.
176
+ * @returns {Record<string, string>} The authorization headers (empty without a token).
177
+ */
178
+ protected authHeaders(config: WhatsAppServiceConfig): Record<string, string>;
179
+ /**
180
+ * @description Reads the WhatsApp credentials and defaults from the environment
181
+ * @summary Reads the `comms.whatsApp` slice and returns a partial config
182
+ * when a token or phone number ID is configured, `undefined` otherwise.
183
+ * Values pass through `envString`/`envNumber` to reject unset-leaf proxies.
184
+ * @returns {Partial<WhatsAppServiceConfig> | undefined} A partial config, or `undefined` when neither credential is configured.
185
+ */
186
+ protected configFromEnvironment(): Partial<WhatsAppServiceConfig> | undefined;
187
+ /**
188
+ * @description Asserts the access token and sender phone number ID
189
+ * @summary Calls `requireToken()` and returns the configured
190
+ * `phoneNumberId` used to build the messages path.
191
+ * @returns {string} The configured sender phone number ID.
192
+ * @throws {InternalError} When no token or phone number ID is configured.
193
+ */
194
+ protected requireTokenAndPhone(): string;
195
+ /**
196
+ * @description Builds the encoded messages path for a sender
197
+ * @summary Encodes the phone number ID into `/<id>/messages`.
198
+ * @param {string} phoneNumberId - The sender phone number ID.
199
+ * @returns {string} The messages API path.
200
+ */
201
+ private messagesPath;
202
+ /**
203
+ * @description Sends a WhatsApp text message
204
+ * @summary `POST`s a `text` message to the sender's `/messages` endpoint
205
+ * and returns the WhatsApp message payload.
206
+ * @param {WhatsAppTextInput} input - The recipient, text, and preview flag.
207
+ * @returns {Promise<unknown>} The WhatsApp message payload.
208
+ * @throws {InternalError} When credentials or the phone number ID are missing.
209
+ * @throws {BadRequestError} When WhatsApp rejects the message.
210
+ * @example
211
+ * ```ts
212
+ * await whatsapp.sendText({ to: "15551234567", text: "Deployment finished" });
213
+ * ```
214
+ */
215
+ sendText(input: WhatsAppTextInput): Promise<unknown>;
216
+ /**
217
+ * @description Sends a WhatsApp template message
218
+ * @summary `POST`s a `template` message referencing an approved template
219
+ * name and language, with optional components.
220
+ * @param {WhatsAppTemplateInput} input - The recipient and template definition.
221
+ * @returns {Promise<unknown>} The WhatsApp message payload.
222
+ * @throws {InternalError} When credentials or the phone number ID are missing.
223
+ * @throws {BadRequestError} When WhatsApp rejects the template message.
224
+ */
225
+ sendTemplate(input: WhatsAppTemplateInput): Promise<unknown>;
226
+ /**
227
+ * @description Sends a WhatsApp media message
228
+ * @summary `POST`s an `image`/`audio`/`video`/`document` message using
229
+ * either an uploaded `mediaId` or a public `link`, with optional caption and
230
+ * filename.
231
+ * @param {WhatsAppMediaInput} input - The recipient and media reference.
232
+ * @returns {Promise<unknown>} The WhatsApp message payload.
233
+ * @throws {InternalError} When credentials or the phone number ID are missing, or neither `mediaId` nor `link` is provided.
234
+ * @throws {BadRequestError} When WhatsApp rejects the media message.
235
+ */
236
+ sendMedia(input: WhatsAppMediaInput): Promise<unknown>;
237
+ /**
238
+ * @description Marks an inbound WhatsApp message as read
239
+ * @summary `POST`s a `read` status for the message to the sender's
240
+ * `/messages` endpoint.
241
+ * @param {WhatsAppReadInput} input - The inbound message ID to acknowledge.
242
+ * @returns {Promise<unknown>} The WhatsApp status payload.
243
+ * @throws {InternalError} When credentials, the phone number ID, or the message ID are missing.
244
+ * @throws {BadRequestError} When WhatsApp rejects the request.
245
+ */
246
+ markAsRead(input: WhatsAppReadInput): Promise<unknown>;
247
+ /**
248
+ * @description Fetches WhatsApp media metadata
249
+ * @summary `GET`s the media descriptor (URL, MIME type, size) by media ID;
250
+ * the descriptor's URL is then used to download the binary.
251
+ * @param {string} mediaId - The WhatsApp media ID.
252
+ * @returns {Promise<unknown>} The media metadata payload.
253
+ * @throws {InternalError} When no token is configured or the media ID is empty.
254
+ * @throws {NotFoundError} When the media does not exist (HTTP 404).
255
+ * @throws {BadRequestError} When WhatsApp rejects the request.
256
+ */
257
+ getMedia(mediaId: string): Promise<unknown>;
258
+ }
@@ -0,0 +1 @@
1
+ export * from "./WhatsAppService.d.cts";
@@ -0,0 +1 @@
1
+ export * from "./WhatsAppService.d.mts";
@@ -7,6 +7,6 @@ export * from "./utils.d.cts";
7
7
  export * from "./namespaces/index.d.cts";
8
8
  export * from "./feature-flags/index.d.cts";
9
9
  export declare const VERSION: string;
10
- export declare const COMMIT = "004735e";
11
- export declare const FULL_VERSION = "0.11.0-004735e";
10
+ export declare const COMMIT = "91b0244";
11
+ export declare const FULL_VERSION = "0.13.0-91b0244";
12
12
  export declare const PACKAGE_NAME: string;
@@ -7,6 +7,6 @@ export * from "./utils.d.mts";
7
7
  export * from "./namespaces/index.d.mts";
8
8
  export * from "./feature-flags/index.d.mts";
9
9
  export declare const VERSION: string;
10
- export declare const COMMIT = "004735e";
11
- export declare const FULL_VERSION = "0.11.0-004735e";
10
+ export declare const COMMIT = "91b0244";
11
+ export declare const FULL_VERSION = "0.13.0-91b0244";
12
12
  export declare const PACKAGE_NAME: string;