@decaf-ts/integrations 0.12.0 → 0.14.2

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 (156) 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/cjs/sftp/aws/index.cjs +24 -0
  50. package/lib/cjs/sftp/aws/index.cjs.map +1 -0
  51. package/lib/cjs/sftp/ssh2/index.cjs +24 -0
  52. package/lib/cjs/sftp/ssh2/index.cjs.map +1 -0
  53. package/lib/esm/calendar/environment.js +44 -0
  54. package/lib/esm/calendar/environment.js.map +1 -0
  55. package/lib/esm/calendar/google-calendar/GoogleCalendarService.js +333 -0
  56. package/lib/esm/calendar/google-calendar/GoogleCalendarService.js.map +1 -0
  57. package/lib/esm/calendar/google-calendar/index.js +3 -0
  58. package/lib/esm/calendar/google-calendar/index.js.map +1 -0
  59. package/lib/esm/comms/discord/DiscordService.js +313 -0
  60. package/lib/esm/comms/discord/DiscordService.js.map +1 -0
  61. package/lib/esm/comms/discord/index.js +2 -0
  62. package/lib/esm/comms/discord/index.js.map +1 -0
  63. package/lib/esm/comms/environment.js +16 -0
  64. package/lib/esm/comms/environment.js.map +1 -1
  65. package/lib/esm/comms/index.js +3 -0
  66. package/lib/esm/comms/index.js.map +1 -1
  67. package/lib/esm/comms/outlook/MicrosoftOutlookService.js +320 -0
  68. package/lib/esm/comms/outlook/MicrosoftOutlookService.js.map +1 -0
  69. package/lib/esm/comms/outlook/index.js +2 -0
  70. package/lib/esm/comms/outlook/index.js.map +1 -0
  71. package/lib/esm/comms/whatsapp/WhatsAppService.js +269 -0
  72. package/lib/esm/comms/whatsapp/WhatsAppService.js.map +1 -0
  73. package/lib/esm/comms/whatsapp/index.js +2 -0
  74. package/lib/esm/comms/whatsapp/index.js.map +1 -0
  75. package/lib/esm/index.js +3 -3
  76. package/lib/esm/io/confluence/ConfluenceService.js +312 -0
  77. package/lib/esm/io/confluence/ConfluenceService.js.map +1 -0
  78. package/lib/esm/io/confluence/index.js +2 -0
  79. package/lib/esm/io/confluence/index.js.map +1 -0
  80. package/lib/esm/io/environment.js +28 -0
  81. package/lib/esm/io/environment.js.map +1 -1
  82. package/lib/esm/io/google-docs/GoogleDocsService.js +270 -0
  83. package/lib/esm/io/google-docs/GoogleDocsService.js.map +1 -0
  84. package/lib/esm/io/google-docs/index.js +2 -0
  85. package/lib/esm/io/google-docs/index.js.map +1 -0
  86. package/lib/esm/io/index.js +5 -0
  87. package/lib/esm/io/index.js.map +1 -1
  88. package/lib/esm/io/jira/JiraService.js +349 -0
  89. package/lib/esm/io/jira/JiraService.js.map +1 -0
  90. package/lib/esm/io/jira/index.js +2 -0
  91. package/lib/esm/io/jira/index.js.map +1 -0
  92. package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js +248 -0
  93. package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js.map +1 -0
  94. package/lib/esm/io/microsoft-excel/index.js +2 -0
  95. package/lib/esm/io/microsoft-excel/index.js.map +1 -0
  96. package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js +256 -0
  97. package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js.map +1 -0
  98. package/lib/esm/io/microsoft-sharepoint/index.js +2 -0
  99. package/lib/esm/io/microsoft-sharepoint/index.js.map +1 -0
  100. package/lib/esm/sftp/aws/index.js +7 -0
  101. package/lib/esm/sftp/aws/index.js.map +1 -0
  102. package/lib/esm/sftp/ssh2/index.js +7 -0
  103. package/lib/esm/sftp/ssh2/index.js.map +1 -0
  104. package/lib/types/calendar/environment.d.cts +48 -0
  105. package/lib/types/calendar/environment.d.mts +48 -0
  106. package/lib/types/calendar/google-calendar/GoogleCalendarService.d.cts +316 -0
  107. package/lib/types/calendar/google-calendar/GoogleCalendarService.d.mts +316 -0
  108. package/lib/types/calendar/google-calendar/index.d.cts +2 -0
  109. package/lib/types/calendar/google-calendar/index.d.mts +2 -0
  110. package/lib/types/comms/discord/DiscordService.d.cts +285 -0
  111. package/lib/types/comms/discord/DiscordService.d.mts +285 -0
  112. package/lib/types/comms/discord/index.d.cts +1 -0
  113. package/lib/types/comms/discord/index.d.mts +1 -0
  114. package/lib/types/comms/environment.d.cts +34 -8
  115. package/lib/types/comms/environment.d.mts +34 -8
  116. package/lib/types/comms/index.d.cts +3 -0
  117. package/lib/types/comms/index.d.mts +3 -0
  118. package/lib/types/comms/outlook/MicrosoftOutlookService.d.cts +282 -0
  119. package/lib/types/comms/outlook/MicrosoftOutlookService.d.mts +282 -0
  120. package/lib/types/comms/outlook/index.d.cts +1 -0
  121. package/lib/types/comms/outlook/index.d.mts +1 -0
  122. package/lib/types/comms/whatsapp/WhatsAppService.d.cts +258 -0
  123. package/lib/types/comms/whatsapp/WhatsAppService.d.mts +258 -0
  124. package/lib/types/comms/whatsapp/index.d.cts +1 -0
  125. package/lib/types/comms/whatsapp/index.d.mts +1 -0
  126. package/lib/types/index.d.cts +2 -2
  127. package/lib/types/index.d.mts +2 -2
  128. package/lib/types/io/confluence/ConfluenceService.d.cts +250 -0
  129. package/lib/types/io/confluence/ConfluenceService.d.mts +250 -0
  130. package/lib/types/io/confluence/index.d.cts +1 -0
  131. package/lib/types/io/confluence/index.d.mts +1 -0
  132. package/lib/types/io/environment.d.cts +52 -12
  133. package/lib/types/io/environment.d.mts +52 -12
  134. package/lib/types/io/google-docs/GoogleDocsService.d.cts +188 -0
  135. package/lib/types/io/google-docs/GoogleDocsService.d.mts +188 -0
  136. package/lib/types/io/google-docs/index.d.cts +1 -0
  137. package/lib/types/io/google-docs/index.d.mts +1 -0
  138. package/lib/types/io/index.d.cts +5 -0
  139. package/lib/types/io/index.d.mts +5 -0
  140. package/lib/types/io/jira/JiraService.d.cts +300 -0
  141. package/lib/types/io/jira/JiraService.d.mts +300 -0
  142. package/lib/types/io/jira/index.d.cts +1 -0
  143. package/lib/types/io/jira/index.d.mts +1 -0
  144. package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.cts +230 -0
  145. package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.mts +230 -0
  146. package/lib/types/io/microsoft-excel/index.d.cts +1 -0
  147. package/lib/types/io/microsoft-excel/index.d.mts +1 -0
  148. package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.cts +226 -0
  149. package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.mts +226 -0
  150. package/lib/types/io/microsoft-sharepoint/index.d.cts +1 -0
  151. package/lib/types/io/microsoft-sharepoint/index.d.mts +1 -0
  152. package/lib/types/sftp/aws/index.d.cts +6 -0
  153. package/lib/types/sftp/aws/index.d.mts +6 -0
  154. package/lib/types/sftp/ssh2/index.d.cts +6 -0
  155. package/lib/types/sftp/ssh2/index.d.mts +6 -0
  156. package/package.json +263 -59
@@ -0,0 +1,312 @@
1
+ /**
2
+ * @module integrations/io/confluence/service
3
+ * @summary Confluence REST API integration service for spaces and pages.
4
+ * @description Exposes Confluence content operations (spaces, pages, and CQL
5
+ * search) as an undecorated client-based service built on
6
+ * {@link HttpApiService}. Configuration comes from an explicit
7
+ * `ConfluenceServiceConfig` or the `io.confluence` environment slice. When both
8
+ * `username` and `token` are configured the service sends HTTP Basic
9
+ * authentication (API token as the password); otherwise the token is sent as a
10
+ * bearer token. The site `baseUrl` is required. Credentials are referenced from
11
+ * configuration (and, from as-graph nodes, from the resolved `confluence`
12
+ * credential secret) and are never embedded in source. Failures are mapped to
13
+ * decaf errors via {@link httpError}.
14
+ */
15
+ import { InternalError } from "@decaf-ts/db-decorators";
16
+ import { IoEnvironment } from "./../environment.js";
17
+ import { envNumber, envString } from "./../../shared/environmentValue.js";
18
+ import { HttpApiService, httpError, } from "./../../shared/http/index.js";
19
+ /** Default Confluence content type written by the service (`"page"`). */
20
+ const DEFAULT_PAGE_TYPE = "page";
21
+ /**
22
+ * @description Confluence REST API integration service
23
+ * @summary An undecorated HTTP service for reading, creating, updating, and
24
+ * deleting pages, listing spaces, and running CQL searches. The site base URL
25
+ * and API token are required; supplying a `username` switches authentication to
26
+ * Basic, and transport failures are mapped to decaf errors via
27
+ * {@link httpError}.
28
+ * @class ConfluenceService
29
+ * @extends HttpApiService
30
+ * @category IO
31
+ * @example
32
+ * ```ts
33
+ * import { ConfluenceService } from "@decaf-ts/integrations/io/confluence";
34
+ *
35
+ * const confluence = new ConfluenceService();
36
+ * await confluence.initialize({
37
+ * baseUrl: "https://example.atlassian.net/wiki",
38
+ * username: process.env.CONFLUENCE_USERNAME,
39
+ * token: process.env.GRAPH_CREDENTIAL_CONFLUENCE_TOKEN,
40
+ * });
41
+ * const page = await confluence.getPage("123456");
42
+ * ```
43
+ * @mermaid
44
+ * sequenceDiagram
45
+ * autonumber
46
+ * participant Caller
47
+ * participant Service as ConfluenceService
48
+ * participant API as Confluence REST API
49
+ * Caller->>Service: updatePage(input)
50
+ * activate Service
51
+ * Service->>Service: requireCredentials()
52
+ * opt version omitted
53
+ * Service->>API: GET /rest/api/content/{id}?expand=version
54
+ * activate API
55
+ * API-->>Service: current version
56
+ * deactivate API
57
+ * end
58
+ * Service->>API: PUT /rest/api/content/{id}
59
+ * activate API
60
+ * API-->>Service: updated page
61
+ * deactivate API
62
+ * Service-->>Caller: updated page
63
+ * deactivate Service
64
+ * @memberOf module:integrations/io/confluence/service
65
+ */
66
+ export class ConfluenceService extends HttpApiService {
67
+ constructor() {
68
+ super(...arguments);
69
+ /**
70
+ * @description The provider name used in error messages
71
+ */
72
+ this.serviceName = "Confluence";
73
+ }
74
+ /**
75
+ * @description The default base URL for Confluence
76
+ * @summary Returns an empty string; Confluence is site-hosted, so the
77
+ * resolved `baseUrl` (from config or `io.confluence.baseUrl`) is required.
78
+ * @returns {string} An empty string.
79
+ */
80
+ defaultBaseUrl() {
81
+ return "";
82
+ }
83
+ /**
84
+ * @description Builds the Confluence authentication headers
85
+ * @summary Uses HTTP Basic (`username:token`) when both values are present,
86
+ * otherwise a bearer token when only `token` is present, otherwise no
87
+ * headers.
88
+ * @param {ConfluenceServiceConfig} config - The resolved service configuration.
89
+ * @returns {Record<string, string>} The authorization headers.
90
+ */
91
+ authHeaders(config) {
92
+ if (config.username && config.token) {
93
+ const encoded = Buffer.from(`${config.username}:${config.token}`, "utf8").toString("base64");
94
+ return { Authorization: `Basic ${encoded}` };
95
+ }
96
+ return config.token ? { Authorization: `Bearer ${config.token}` } : {};
97
+ }
98
+ /**
99
+ * @description Reads the Confluence credentials and defaults from the environment
100
+ * @summary Reads the `io.confluence` slice and returns a partial config when
101
+ * an API token is configured, `undefined` otherwise. Values pass through
102
+ * `envString`/`envNumber` to reject unset-leaf proxies.
103
+ * @returns {Partial<ConfluenceServiceConfig> | undefined} A partial config, or `undefined` when no Confluence token is configured.
104
+ */
105
+ configFromEnvironment() {
106
+ const env = IoEnvironment.io.confluence;
107
+ const token = envString(env?.token);
108
+ if (!token)
109
+ return undefined;
110
+ return {
111
+ token,
112
+ username: envString(env.username),
113
+ baseUrl: envString(env.baseUrl),
114
+ timeout: envNumber(env.timeout),
115
+ };
116
+ }
117
+ /**
118
+ * @description Asserts that the Confluence token and site base URL are configured
119
+ * @summary Called by every operation before it touches the network.
120
+ * @returns {void}
121
+ * @throws {InternalError} When no API token or base URL is configured.
122
+ */
123
+ requireCredentials() {
124
+ if (!this.config.token) {
125
+ throw new InternalError("Confluence requires an API token");
126
+ }
127
+ if (!this.config.baseUrl) {
128
+ throw new InternalError("Confluence requires a base URL");
129
+ }
130
+ }
131
+ /**
132
+ * @description Wraps a body in the Confluence storage representation
133
+ * @summary Produces the `{ storage: { value, representation } }` envelope
134
+ * the content API expects.
135
+ * @param {string} body - The Confluence storage-format body.
136
+ * @returns {Record<string, unknown>} The storage body envelope.
137
+ */
138
+ storageBody(body) {
139
+ return {
140
+ storage: {
141
+ value: body,
142
+ representation: "storage",
143
+ },
144
+ };
145
+ }
146
+ /**
147
+ * @description Fetches a Confluence page
148
+ * @summary `GET`s `/rest/api/content/<id>` with the requested `expand`
149
+ * fields (default `body.storage,version`).
150
+ * @param {string} pageId - The page ID.
151
+ * @param {string} [expand] - Comma-separated fields to expand; defaults to `"body.storage,version"`.
152
+ * @returns {Promise<unknown>} The page payload.
153
+ * @throws {InternalError} When credentials are missing or the page ID is empty.
154
+ * @throws {NotFoundError} When the page does not exist (HTTP 404).
155
+ * @throws {BadRequestError} When the API rejects the request.
156
+ */
157
+ async getPage(pageId, expand = "body.storage,version") {
158
+ this.requireCredentials();
159
+ if (!pageId) {
160
+ throw new InternalError("Confluence requires a page id");
161
+ }
162
+ try {
163
+ const response = await this.client.get(`/rest/api/content/${encodeURIComponent(pageId)}`, { params: { expand } });
164
+ return response.data;
165
+ }
166
+ catch (error) {
167
+ throw httpError("Confluence", "get page", error);
168
+ }
169
+ }
170
+ /**
171
+ * @description Lists Confluence spaces
172
+ * @summary `GET`s `/rest/api/space` with a result `limit` (default `25`).
173
+ * @param {number} [limit] - Maximum number of spaces to return; defaults to `25`.
174
+ * @returns {Promise<unknown>} The space collection payload.
175
+ * @throws {InternalError} When credentials are missing.
176
+ * @throws {BadRequestError} When the API rejects the request.
177
+ */
178
+ async listSpaces(limit = 25) {
179
+ this.requireCredentials();
180
+ try {
181
+ const response = await this.client.get("/rest/api/space", {
182
+ params: { limit },
183
+ });
184
+ return response.data;
185
+ }
186
+ catch (error) {
187
+ throw httpError("Confluence", "list spaces", error);
188
+ }
189
+ }
190
+ /**
191
+ * @description Creates a Confluence page
192
+ * @summary `POST`s a `page` content entry in the target space, optionally
193
+ * under a parent, with the body in storage format.
194
+ * @param {ConfluencePageInput} input - The space, title, body, and optional parent.
195
+ * @returns {Promise<unknown>} The created page payload.
196
+ * @throws {InternalError} When credentials are missing, or the space key or title is empty.
197
+ * @throws {BadRequestError} When the API rejects the page.
198
+ * @example
199
+ * ```ts
200
+ * await confluence.createPage({
201
+ * spaceKey: "OPS",
202
+ * title: "Release 1.2.0",
203
+ * body: "<p>Details…</p>",
204
+ * });
205
+ * ```
206
+ */
207
+ async createPage(input) {
208
+ this.requireCredentials();
209
+ if (!input.spaceKey || !input.title) {
210
+ throw new InternalError("Confluence createPage requires a space key and title");
211
+ }
212
+ try {
213
+ const response = await this.client.post("/rest/api/content", {
214
+ type: DEFAULT_PAGE_TYPE,
215
+ title: input.title,
216
+ space: { key: input.spaceKey },
217
+ ...(input.parentId ? { ancestors: [{ id: input.parentId }] } : {}),
218
+ body: this.storageBody(input.body ?? ""),
219
+ });
220
+ return response.data;
221
+ }
222
+ catch (error) {
223
+ throw httpError("Confluence", "create page", error);
224
+ }
225
+ }
226
+ /**
227
+ * @description Updates a Confluence page
228
+ * @summary `PUT`s the new title and storage body. When `version` is omitted
229
+ * the current version is read first and the next number is submitted, as
230
+ * Confluence requires optimistic versioning.
231
+ * @param {ConfluencePageUpdate} input - The page, new title/body, and optional version.
232
+ * @returns {Promise<unknown>} The updated page payload.
233
+ * @throws {InternalError} When credentials are missing, or the page ID or title is empty.
234
+ * @throws {NotFoundError} When the page does not exist (HTTP 404).
235
+ * @throws {ConflictError} When the submitted version is stale (HTTP 409).
236
+ * @throws {BadRequestError} When the API rejects the update.
237
+ */
238
+ async updatePage(input) {
239
+ this.requireCredentials();
240
+ if (!input.pageId || !input.title) {
241
+ throw new InternalError("Confluence updatePage requires a page id and title");
242
+ }
243
+ try {
244
+ let version = input.version;
245
+ if (version === undefined) {
246
+ const current = await this.client.get(`/rest/api/content/${encodeURIComponent(input.pageId)}`, { params: { expand: "version" } });
247
+ version = (current.data.version?.number ?? 0) + 1;
248
+ }
249
+ const response = await this.client.put(`/rest/api/content/${encodeURIComponent(input.pageId)}`, {
250
+ id: input.pageId,
251
+ type: DEFAULT_PAGE_TYPE,
252
+ title: input.title,
253
+ version: { number: version },
254
+ body: this.storageBody(input.body ?? ""),
255
+ });
256
+ return response.data;
257
+ }
258
+ catch (error) {
259
+ throw httpError("Confluence", "update page", error);
260
+ }
261
+ }
262
+ /**
263
+ * @description Deletes a Confluence page
264
+ * @summary `DELETE`s the content entry and returns `{ deleted: true, pageId }`.
265
+ * @param {string} pageId - The page ID to delete.
266
+ * @returns {Promise<unknown>} `{ deleted: true, pageId }` on success.
267
+ * @throws {InternalError} When credentials are missing or the page ID is empty.
268
+ * @throws {NotFoundError} When the page does not exist (HTTP 404).
269
+ * @throws {BadRequestError} When the API rejects the deletion.
270
+ */
271
+ async deletePage(pageId) {
272
+ this.requireCredentials();
273
+ if (!pageId) {
274
+ throw new InternalError("Confluence requires a page id");
275
+ }
276
+ try {
277
+ await this.client.delete(`/rest/api/content/${encodeURIComponent(pageId)}`);
278
+ return { deleted: true, pageId };
279
+ }
280
+ catch (error) {
281
+ throw httpError("Confluence", "delete page", error);
282
+ }
283
+ }
284
+ /**
285
+ * @description Searches Confluence content with CQL
286
+ * @summary `GET`s `/rest/api/content/search` with the CQL expression and an
287
+ * optional `limit`.
288
+ * @param {ConfluenceSearchInput} input - The CQL query and result limit.
289
+ * @returns {Promise<unknown>} The search result payload.
290
+ * @throws {InternalError} When credentials are missing or the CQL query is empty.
291
+ * @throws {BadRequestError} When the CQL query is invalid.
292
+ */
293
+ async search(input) {
294
+ this.requireCredentials();
295
+ if (!input.cql) {
296
+ throw new InternalError("Confluence search requires a CQL query");
297
+ }
298
+ try {
299
+ const response = await this.client.get("/rest/api/content/search", {
300
+ params: {
301
+ cql: input.cql,
302
+ ...(input.limit !== undefined ? { limit: input.limit } : {}),
303
+ },
304
+ });
305
+ return response.data;
306
+ }
307
+ catch (error) {
308
+ throw httpError("Confluence", "search content", error);
309
+ }
310
+ }
311
+ }
312
+ //# sourceMappingURL=ConfluenceService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfluenceService.js","sourceRoot":"","sources":["../../../../src/io/confluence/ConfluenceService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,4BAAuB;AAC/C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,2CAAsC;AACrE,OAAO,EACL,cAAc,EAEd,SAAS,GACV,qCAA0B;AAuG3B,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAuC;IAA9E;;QACE;;WAEG;QACgB,gBAAW,GAAG,YAAY,CAAC;IAwQhD,CAAC;IAtQC;;;;;OAKG;IACO,cAAc;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;;OAOG;IACO,WAAW,CACnB,MAA+B;QAE/B,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CACzB,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,EAAE,EACpC,MAAM,CACP,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAA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,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE;gBACjE,MAAM,EAAE;oBACN,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC7D;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,CAAC,YAAY,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from "./ConfluenceService.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/io/confluence/index.ts"],"names":[],"mappings":"AAAA,uCAAoC"}
@@ -37,6 +37,34 @@ export const IoEnvironment = LoggedEnvironment.accumulate({
37
37
  token: "",
38
38
  timeout: undefined,
39
39
  },
40
+ microsoftExcel: {
41
+ token: "",
42
+ baseUrl: "",
43
+ timeout: undefined,
44
+ },
45
+ confluence: {
46
+ username: "",
47
+ token: "",
48
+ baseUrl: "",
49
+ timeout: undefined,
50
+ },
51
+ jira: {
52
+ username: "",
53
+ token: "",
54
+ baseUrl: "",
55
+ timeout: undefined,
56
+ },
57
+ googleDocs: {
58
+ token: "",
59
+ apiKey: "",
60
+ baseUrl: "",
61
+ timeout: undefined,
62
+ },
63
+ microsoftSharePoint: {
64
+ token: "",
65
+ baseUrl: "",
66
+ timeout: undefined,
67
+ },
40
68
  },
41
69
  });
42
70
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/io/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA8CtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,UAAU,CAAC;IACxD,EAAE,EAAE;QACF,QAAQ,EAAE;YACR,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,SAA8B;SACxC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,SAA8B;SACxC;KACF;CACoB,CAAC,CAAC"}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/io/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAsFtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,UAAU,CAAC;IACxD,EAAE,EAAE;QACF,QAAQ,EAAE;YACR,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,SAA8B;SACxC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,SAA8B;SACxC;QACD,cAAc,EAAE;YACd,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,UAAU,EAAE;YACV,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;QACD,mBAAmB,EAAE;YACnB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,SAA8B;SACxC;KACF;CACoB,CAAC,CAAC"}
@@ -0,0 +1,270 @@
1
+ /**
2
+ * @module integrations/io/google-docs/service
3
+ * @summary Google Docs API integration service for document content operations.
4
+ * @description Exposes Google Docs document operations (get, create, batch
5
+ * update, append text, and replace-all) as an undecorated client-based service
6
+ * built on {@link HttpApiService}. Configuration comes from an explicit
7
+ * `GoogleDocsServiceConfig` or the `io.googleDocs` environment slice. An OAuth
8
+ * access token is sent as a bearer token when present; otherwise an API key is
9
+ * sent as `X-Goog-Api-Key` (writes generally require OAuth). Credentials are
10
+ * referenced from configuration (and, from as-graph nodes, from the resolved
11
+ * `google-docs` credential secret) and are never embedded in source. Failures
12
+ * are mapped to decaf errors via {@link httpError}.
13
+ */
14
+ import { InternalError } from "@decaf-ts/db-decorators";
15
+ import { IoEnvironment } from "./../environment.js";
16
+ import { envNumber, envString } from "./../../shared/environmentValue.js";
17
+ import { HttpApiService, httpError, } from "./../../shared/http/index.js";
18
+ /**
19
+ * @description Google Docs API integration service
20
+ * @summary An undecorated HTTP service for reading and creating documents,
21
+ * running raw batch updates, appending text, and replacing all matching text.
22
+ * Every operation needs either an OAuth token or an API key; missing
23
+ * credentials or identifiers raise `InternalError`, and transport failures are
24
+ * mapped to decaf errors via {@link httpError}.
25
+ * @class GoogleDocsService
26
+ * @extends HttpApiService
27
+ * @category IO
28
+ * @example
29
+ * ```ts
30
+ * import { GoogleDocsService } from "@decaf-ts/integrations/io/google-docs";
31
+ *
32
+ * const docs = new GoogleDocsService();
33
+ * await docs.initialize({
34
+ * token: process.env.GRAPH_CREDENTIAL_GOOGLE_DOCS_TOKEN,
35
+ * });
36
+ * await docs.appendText(process.env.GOOGLE_DOC_ID ?? "", "New paragraph");
37
+ * ```
38
+ * @mermaid
39
+ * sequenceDiagram
40
+ * autonumber
41
+ * participant Caller
42
+ * participant Service as GoogleDocsService
43
+ * participant API as Google Docs API
44
+ * Caller->>Service: appendText(documentId, text)
45
+ * activate Service
46
+ * Service->>Service: requireAuth()
47
+ * Service->>API: GET /documents/{id}
48
+ * activate API
49
+ * API-->>Service: body content endIndex
50
+ * deactivate API
51
+ * Service->>API: POST /documents/{id}:batchUpdate
52
+ * activate API
53
+ * API-->>Service: batch update result
54
+ * deactivate API
55
+ * Service-->>Caller: batch update result
56
+ * deactivate Service
57
+ * @memberOf module:integrations/io/google-docs/service
58
+ */
59
+ export class GoogleDocsService extends HttpApiService {
60
+ constructor() {
61
+ super(...arguments);
62
+ /**
63
+ * @description The provider name used in error messages
64
+ */
65
+ this.serviceName = "Google Docs";
66
+ }
67
+ /**
68
+ * @description The Google Docs API base URL
69
+ * @summary Used when the resolved config carries no `baseUrl`.
70
+ * @returns {string} `"https://docs.googleapis.com/v1"`.
71
+ */
72
+ defaultBaseUrl() {
73
+ return "https://docs.googleapis.com/v1";
74
+ }
75
+ /**
76
+ * @description Builds the Google Docs authentication headers
77
+ * @summary Prefers `Authorization: Bearer <token>`, falls back to
78
+ * `X-Goog-Api-Key: <apiKey>`, and returns no headers when neither is set.
79
+ * @param {GoogleDocsServiceConfig} config - The resolved service configuration.
80
+ * @returns {Record<string, string>} The authentication headers.
81
+ */
82
+ authHeaders(config) {
83
+ if (config.token)
84
+ return { Authorization: `Bearer ${config.token}` };
85
+ if (config.apiKey)
86
+ return { "X-Goog-Api-Key": config.apiKey };
87
+ return {};
88
+ }
89
+ /**
90
+ * @description Reads the Google Docs credentials and defaults from the environment
91
+ * @summary Reads the `io.googleDocs` slice and returns a partial config when
92
+ * a token or API key is configured, `undefined` otherwise. Values pass
93
+ * through `envString`/`envNumber` to reject unset-leaf proxies.
94
+ * @returns {Partial<GoogleDocsServiceConfig> | undefined} A partial config, or `undefined` when no credential is configured.
95
+ */
96
+ configFromEnvironment() {
97
+ const env = IoEnvironment.io.googleDocs;
98
+ const token = envString(env?.token);
99
+ const apiKey = envString(env?.apiKey);
100
+ if (!token && !apiKey)
101
+ return undefined;
102
+ return {
103
+ token,
104
+ apiKey,
105
+ baseUrl: envString(env.baseUrl),
106
+ timeout: envNumber(env.timeout),
107
+ };
108
+ }
109
+ /**
110
+ * @description Asserts that an OAuth token or API key is configured
111
+ * @summary Called by every operation before it touches the network.
112
+ * @returns {void}
113
+ * @throws {InternalError} When neither a token nor an API key is configured.
114
+ */
115
+ requireAuth() {
116
+ if (!this.config.token && !this.config.apiKey) {
117
+ throw new InternalError("Google Docs requires an OAuth token or an API key");
118
+ }
119
+ }
120
+ /**
121
+ * @description Fetches a Google Docs document
122
+ * @summary `GET`s `/documents/<id>` and returns the full document payload.
123
+ * @param {string} documentId - The document ID.
124
+ * @returns {Promise<unknown>} The document payload.
125
+ * @throws {InternalError} When no credential is configured or the document ID is empty.
126
+ * @throws {NotFoundError} When the document does not exist (HTTP 404).
127
+ * @throws {BadRequestError} When Google rejects the request.
128
+ */
129
+ async getDocument(documentId) {
130
+ this.requireAuth();
131
+ if (!documentId) {
132
+ throw new InternalError("Google Docs requires a document id");
133
+ }
134
+ try {
135
+ const response = await this.client.get(`/documents/${encodeURIComponent(documentId)}`);
136
+ return response.data;
137
+ }
138
+ catch (error) {
139
+ throw httpError("Google Docs", "get document", error);
140
+ }
141
+ }
142
+ /**
143
+ * @description Creates a Google Docs document
144
+ * @summary `POST`s a new document with the given title and returns its
145
+ * payload (including `documentId`).
146
+ * @param {string} title - The new document title.
147
+ * @returns {Promise<unknown>} The created document payload.
148
+ * @throws {InternalError} When no credential is configured or the title is empty.
149
+ * @throws {BadRequestError} When Google rejects the request.
150
+ */
151
+ async createDocument(title) {
152
+ this.requireAuth();
153
+ if (!title) {
154
+ throw new InternalError("Google Docs requires a document title");
155
+ }
156
+ try {
157
+ const response = await this.client.post("/documents", { title });
158
+ return response.data;
159
+ }
160
+ catch (error) {
161
+ throw httpError("Google Docs", "create document", error);
162
+ }
163
+ }
164
+ /**
165
+ * @description Applies a raw Google Docs batch update
166
+ * @summary `POST`s the `requests` array to `/documents/<id>:batchUpdate`
167
+ * unchanged, allowing any Docs API request type.
168
+ * @param {string} documentId - The document ID.
169
+ * @param {unknown[]} requests - The Docs API request objects.
170
+ * @returns {Promise<unknown>} The batch update response payload.
171
+ * @throws {InternalError} When no credential is configured, or the document ID or requests are missing.
172
+ * @throws {NotFoundError} When the document does not exist (HTTP 404).
173
+ * @throws {BadRequestError} When Google rejects a request.
174
+ */
175
+ async batchUpdate(documentId, requests) {
176
+ this.requireAuth();
177
+ if (!documentId || !Array.isArray(requests) || !requests.length) {
178
+ throw new InternalError("Google Docs batchUpdate requires a document id and requests");
179
+ }
180
+ try {
181
+ const response = await this.client.post(`/documents/${encodeURIComponent(documentId)}:batchUpdate`, { requests });
182
+ return response.data;
183
+ }
184
+ catch (error) {
185
+ throw httpError("Google Docs", "batch update", error);
186
+ }
187
+ }
188
+ /**
189
+ * @description Appends text to the end of a Google Docs document
190
+ * @summary Reads the document to find the final `endIndex`, then inserts the
191
+ * text just before it through a `batchUpdate`.
192
+ * @param {string} documentId - The document ID.
193
+ * @param {string} text - The text to append.
194
+ * @returns {Promise<unknown>} The batch update response payload.
195
+ * @throws {InternalError} When no credential is configured, or the document ID or text is empty.
196
+ * @throws {NotFoundError} When the document does not exist (HTTP 404).
197
+ * @throws {BadRequestError} When Google rejects the update.
198
+ */
199
+ async appendText(documentId, text) {
200
+ this.requireAuth();
201
+ if (!documentId || !text) {
202
+ throw new InternalError("Google Docs appendText requires a document id and text");
203
+ }
204
+ try {
205
+ const document = await this.client.get(`/documents/${encodeURIComponent(documentId)}`);
206
+ const content = document.data.body?.content ?? [];
207
+ const last = content[content.length - 1];
208
+ const endIndex = last?.endIndex ?? 1;
209
+ const response = await this.client.post(`/documents/${encodeURIComponent(documentId)}:batchUpdate`, {
210
+ requests: [
211
+ {
212
+ insertText: {
213
+ location: { index: Math.max(endIndex - 1, 1) },
214
+ text,
215
+ },
216
+ },
217
+ ],
218
+ });
219
+ return response.data;
220
+ }
221
+ catch (error) {
222
+ throw httpError("Google Docs", "append text", error);
223
+ }
224
+ }
225
+ /**
226
+ * @description Replaces all matching text in a Google Docs document
227
+ * @summary Sends a `replaceAllText` request honoring the `matchCase` option
228
+ * and returns the batch update response payload.
229
+ * @param {GoogleDocsReplaceInput} input - The document, find/replace text, and case option.
230
+ * @returns {Promise<unknown>} The batch update response payload.
231
+ * @throws {InternalError} When no credential is configured, or the document ID or find text is empty.
232
+ * @throws {NotFoundError} When the document does not exist (HTTP 404).
233
+ * @throws {BadRequestError} When Google rejects the update.
234
+ * @example
235
+ * ```ts
236
+ * await docs.replaceAllText({
237
+ * documentId: "abc123",
238
+ * find: "TODO",
239
+ * replace: "DONE",
240
+ * matchCase: true,
241
+ * });
242
+ * ```
243
+ */
244
+ async replaceAllText(input) {
245
+ this.requireAuth();
246
+ if (!input.documentId || !input.find) {
247
+ throw new InternalError("Google Docs replaceAllText requires a document id and find text");
248
+ }
249
+ try {
250
+ const response = await this.client.post(`/documents/${encodeURIComponent(input.documentId)}:batchUpdate`, {
251
+ requests: [
252
+ {
253
+ replaceAllText: {
254
+ containsText: {
255
+ text: input.find,
256
+ matchCase: input.matchCase ?? false,
257
+ },
258
+ replaceText: input.replace ?? "",
259
+ },
260
+ },
261
+ ],
262
+ });
263
+ return response.data;
264
+ }
265
+ catch (error) {
266
+ throw httpError("Google Docs", "replace all text", error);
267
+ }
268
+ }
269
+ }
270
+ //# sourceMappingURL=GoogleDocsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleDocsService.js","sourceRoot":"","sources":["../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appingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/io/google-docs/index.ts"],"names":[],"mappings":"AAAA,uCAAoC"}
@@ -9,5 +9,10 @@ export * from "./airtable/index.js";
9
9
  export * from "./google-sheets/index.js";
10
10
  export * from "./graphql/index.js";
11
11
  export * from "./spreadsheet/index.js";
12
+ export * from "./microsoft-excel/index.js";
13
+ export * from "./confluence/index.js";
14
+ export * from "./jira/index.js";
15
+ export * from "./google-docs/index.js";
16
+ export * from "./microsoft-sharepoint/index.js";
12
17
  export * from "./environment.js";
13
18
  //# sourceMappingURL=index.js.map