@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.
- package/dist/integrations.cjs +1 -1
- package/lib/cjs/calendar/environment.cjs +48 -0
- package/lib/cjs/calendar/environment.cjs.map +1 -0
- package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs +338 -0
- package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs.map +1 -0
- package/lib/cjs/calendar/google-calendar/index.cjs +20 -0
- package/lib/cjs/calendar/google-calendar/index.cjs.map +1 -0
- package/lib/cjs/comms/discord/DiscordService.cjs +318 -0
- package/lib/cjs/comms/discord/DiscordService.cjs.map +1 -0
- package/lib/cjs/comms/discord/index.cjs +19 -0
- package/lib/cjs/comms/discord/index.cjs.map +1 -0
- package/lib/cjs/comms/environment.cjs +16 -0
- package/lib/cjs/comms/environment.cjs.map +1 -1
- package/lib/cjs/comms/index.cjs +3 -0
- package/lib/cjs/comms/index.cjs.map +1 -1
- package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs +325 -0
- package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs.map +1 -0
- package/lib/cjs/comms/outlook/index.cjs +19 -0
- package/lib/cjs/comms/outlook/index.cjs.map +1 -0
- package/lib/cjs/comms/whatsapp/WhatsAppService.cjs +274 -0
- package/lib/cjs/comms/whatsapp/WhatsAppService.cjs.map +1 -0
- package/lib/cjs/comms/whatsapp/index.cjs +19 -0
- package/lib/cjs/comms/whatsapp/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +3 -3
- package/lib/cjs/io/confluence/ConfluenceService.cjs +317 -0
- package/lib/cjs/io/confluence/ConfluenceService.cjs.map +1 -0
- package/lib/cjs/io/confluence/index.cjs +19 -0
- package/lib/cjs/io/confluence/index.cjs.map +1 -0
- package/lib/cjs/io/environment.cjs +28 -0
- package/lib/cjs/io/environment.cjs.map +1 -1
- package/lib/cjs/io/google-docs/GoogleDocsService.cjs +275 -0
- package/lib/cjs/io/google-docs/GoogleDocsService.cjs.map +1 -0
- package/lib/cjs/io/google-docs/index.cjs +19 -0
- package/lib/cjs/io/google-docs/index.cjs.map +1 -0
- package/lib/cjs/io/index.cjs +5 -0
- package/lib/cjs/io/index.cjs.map +1 -1
- package/lib/cjs/io/jira/JiraService.cjs +354 -0
- package/lib/cjs/io/jira/JiraService.cjs.map +1 -0
- package/lib/cjs/io/jira/index.cjs +19 -0
- package/lib/cjs/io/jira/index.cjs.map +1 -0
- package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs +253 -0
- package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs.map +1 -0
- package/lib/cjs/io/microsoft-excel/index.cjs +19 -0
- package/lib/cjs/io/microsoft-excel/index.cjs.map +1 -0
- package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs +261 -0
- package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs.map +1 -0
- package/lib/cjs/io/microsoft-sharepoint/index.cjs +19 -0
- package/lib/cjs/io/microsoft-sharepoint/index.cjs.map +1 -0
- package/lib/cjs/sftp/aws/index.cjs +24 -0
- package/lib/cjs/sftp/aws/index.cjs.map +1 -0
- package/lib/cjs/sftp/ssh2/index.cjs +24 -0
- package/lib/cjs/sftp/ssh2/index.cjs.map +1 -0
- package/lib/esm/calendar/environment.js +44 -0
- package/lib/esm/calendar/environment.js.map +1 -0
- package/lib/esm/calendar/google-calendar/GoogleCalendarService.js +333 -0
- package/lib/esm/calendar/google-calendar/GoogleCalendarService.js.map +1 -0
- package/lib/esm/calendar/google-calendar/index.js +3 -0
- package/lib/esm/calendar/google-calendar/index.js.map +1 -0
- package/lib/esm/comms/discord/DiscordService.js +313 -0
- package/lib/esm/comms/discord/DiscordService.js.map +1 -0
- package/lib/esm/comms/discord/index.js +2 -0
- package/lib/esm/comms/discord/index.js.map +1 -0
- package/lib/esm/comms/environment.js +16 -0
- package/lib/esm/comms/environment.js.map +1 -1
- package/lib/esm/comms/index.js +3 -0
- package/lib/esm/comms/index.js.map +1 -1
- package/lib/esm/comms/outlook/MicrosoftOutlookService.js +320 -0
- package/lib/esm/comms/outlook/MicrosoftOutlookService.js.map +1 -0
- package/lib/esm/comms/outlook/index.js +2 -0
- package/lib/esm/comms/outlook/index.js.map +1 -0
- package/lib/esm/comms/whatsapp/WhatsAppService.js +269 -0
- package/lib/esm/comms/whatsapp/WhatsAppService.js.map +1 -0
- package/lib/esm/comms/whatsapp/index.js +2 -0
- package/lib/esm/comms/whatsapp/index.js.map +1 -0
- package/lib/esm/index.js +3 -3
- package/lib/esm/io/confluence/ConfluenceService.js +312 -0
- package/lib/esm/io/confluence/ConfluenceService.js.map +1 -0
- package/lib/esm/io/confluence/index.js +2 -0
- package/lib/esm/io/confluence/index.js.map +1 -0
- package/lib/esm/io/environment.js +28 -0
- package/lib/esm/io/environment.js.map +1 -1
- package/lib/esm/io/google-docs/GoogleDocsService.js +270 -0
- package/lib/esm/io/google-docs/GoogleDocsService.js.map +1 -0
- package/lib/esm/io/google-docs/index.js +2 -0
- package/lib/esm/io/google-docs/index.js.map +1 -0
- package/lib/esm/io/index.js +5 -0
- package/lib/esm/io/index.js.map +1 -1
- package/lib/esm/io/jira/JiraService.js +349 -0
- package/lib/esm/io/jira/JiraService.js.map +1 -0
- package/lib/esm/io/jira/index.js +2 -0
- package/lib/esm/io/jira/index.js.map +1 -0
- package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js +248 -0
- package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js.map +1 -0
- package/lib/esm/io/microsoft-excel/index.js +2 -0
- package/lib/esm/io/microsoft-excel/index.js.map +1 -0
- package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js +256 -0
- package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js.map +1 -0
- package/lib/esm/io/microsoft-sharepoint/index.js +2 -0
- package/lib/esm/io/microsoft-sharepoint/index.js.map +1 -0
- package/lib/esm/sftp/aws/index.js +7 -0
- package/lib/esm/sftp/aws/index.js.map +1 -0
- package/lib/esm/sftp/ssh2/index.js +7 -0
- package/lib/esm/sftp/ssh2/index.js.map +1 -0
- package/lib/types/calendar/environment.d.cts +48 -0
- package/lib/types/calendar/environment.d.mts +48 -0
- package/lib/types/calendar/google-calendar/GoogleCalendarService.d.cts +316 -0
- package/lib/types/calendar/google-calendar/GoogleCalendarService.d.mts +316 -0
- package/lib/types/calendar/google-calendar/index.d.cts +2 -0
- package/lib/types/calendar/google-calendar/index.d.mts +2 -0
- package/lib/types/comms/discord/DiscordService.d.cts +285 -0
- package/lib/types/comms/discord/DiscordService.d.mts +285 -0
- package/lib/types/comms/discord/index.d.cts +1 -0
- package/lib/types/comms/discord/index.d.mts +1 -0
- package/lib/types/comms/environment.d.cts +34 -8
- package/lib/types/comms/environment.d.mts +34 -8
- package/lib/types/comms/index.d.cts +3 -0
- package/lib/types/comms/index.d.mts +3 -0
- package/lib/types/comms/outlook/MicrosoftOutlookService.d.cts +282 -0
- package/lib/types/comms/outlook/MicrosoftOutlookService.d.mts +282 -0
- package/lib/types/comms/outlook/index.d.cts +1 -0
- package/lib/types/comms/outlook/index.d.mts +1 -0
- package/lib/types/comms/whatsapp/WhatsAppService.d.cts +258 -0
- package/lib/types/comms/whatsapp/WhatsAppService.d.mts +258 -0
- package/lib/types/comms/whatsapp/index.d.cts +1 -0
- package/lib/types/comms/whatsapp/index.d.mts +1 -0
- package/lib/types/index.d.cts +2 -2
- package/lib/types/index.d.mts +2 -2
- package/lib/types/io/confluence/ConfluenceService.d.cts +250 -0
- package/lib/types/io/confluence/ConfluenceService.d.mts +250 -0
- package/lib/types/io/confluence/index.d.cts +1 -0
- package/lib/types/io/confluence/index.d.mts +1 -0
- package/lib/types/io/environment.d.cts +52 -12
- package/lib/types/io/environment.d.mts +52 -12
- package/lib/types/io/google-docs/GoogleDocsService.d.cts +188 -0
- package/lib/types/io/google-docs/GoogleDocsService.d.mts +188 -0
- package/lib/types/io/google-docs/index.d.cts +1 -0
- package/lib/types/io/google-docs/index.d.mts +1 -0
- package/lib/types/io/index.d.cts +5 -0
- package/lib/types/io/index.d.mts +5 -0
- package/lib/types/io/jira/JiraService.d.cts +300 -0
- package/lib/types/io/jira/JiraService.d.mts +300 -0
- package/lib/types/io/jira/index.d.cts +1 -0
- package/lib/types/io/jira/index.d.mts +1 -0
- package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.cts +230 -0
- package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.mts +230 -0
- package/lib/types/io/microsoft-excel/index.d.cts +1 -0
- package/lib/types/io/microsoft-excel/index.d.mts +1 -0
- package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.cts +226 -0
- package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.mts +226 -0
- package/lib/types/io/microsoft-sharepoint/index.d.cts +1 -0
- package/lib/types/io/microsoft-sharepoint/index.d.mts +1 -0
- package/lib/types/sftp/aws/index.d.cts +6 -0
- package/lib/types/sftp/aws/index.d.mts +6 -0
- package/lib/types/sftp/ssh2/index.d.cts +6 -0
- package/lib/types/sftp/ssh2/index.d.mts +6 -0
- package/package.json +263 -59
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { HttpApiService, type HttpApiServiceConfig } from "../../shared/http/index.d.cts";
|
|
2
|
+
/**
|
|
3
|
+
* @description Configuration for the Google Docs service
|
|
4
|
+
* @summary Extends {@link HttpApiServiceConfig} with an optional OAuth
|
|
5
|
+
* `token` (preferred) and an optional `apiKey`. When omitted, the
|
|
6
|
+
* `io.googleDocs` environment slice supplies the same values (plus optional
|
|
7
|
+
* `baseUrl`/`timeout`). At least one credential is required; the token wins
|
|
8
|
+
* when both are set.
|
|
9
|
+
* @category IO
|
|
10
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
11
|
+
*/
|
|
12
|
+
export interface GoogleDocsServiceConfig extends HttpApiServiceConfig {
|
|
13
|
+
/**
|
|
14
|
+
* @description Google OAuth access token
|
|
15
|
+
* @summary Sent as `Authorization: Bearer <token>` when present.
|
|
16
|
+
*/
|
|
17
|
+
token?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @description Google API key
|
|
20
|
+
* @summary Sent as `X-Goog-Api-Key` only when no OAuth token is configured.
|
|
21
|
+
*/
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @description Input for replacing all matching text in a document
|
|
26
|
+
* @summary Carries the `documentId`, the `find` text, its `replace`ment, and
|
|
27
|
+
* whether matching is case-sensitive.
|
|
28
|
+
* @category IO
|
|
29
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
30
|
+
*/
|
|
31
|
+
export interface GoogleDocsReplaceInput {
|
|
32
|
+
/**
|
|
33
|
+
* @description Document ID to update
|
|
34
|
+
*/
|
|
35
|
+
documentId: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description Text to search for
|
|
38
|
+
*/
|
|
39
|
+
find: string;
|
|
40
|
+
/**
|
|
41
|
+
* @description Replacement text (defaults to the empty string)
|
|
42
|
+
*/
|
|
43
|
+
replace: string;
|
|
44
|
+
/**
|
|
45
|
+
* @description Whether matching is case-sensitive (default `false`)
|
|
46
|
+
*/
|
|
47
|
+
matchCase?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description Google Docs API integration service
|
|
51
|
+
* @summary An undecorated HTTP service for reading and creating documents,
|
|
52
|
+
* running raw batch updates, appending text, and replacing all matching text.
|
|
53
|
+
* Every operation needs either an OAuth token or an API key; missing
|
|
54
|
+
* credentials or identifiers raise `InternalError`, and transport failures are
|
|
55
|
+
* mapped to decaf errors via {@link httpError}.
|
|
56
|
+
* @class GoogleDocsService
|
|
57
|
+
* @extends HttpApiService
|
|
58
|
+
* @category IO
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { GoogleDocsService } from "@decaf-ts/integrations/io/google-docs";
|
|
62
|
+
*
|
|
63
|
+
* const docs = new GoogleDocsService();
|
|
64
|
+
* await docs.initialize({
|
|
65
|
+
* token: process.env.GRAPH_CREDENTIAL_GOOGLE_DOCS_TOKEN,
|
|
66
|
+
* });
|
|
67
|
+
* await docs.appendText(process.env.GOOGLE_DOC_ID ?? "", "New paragraph");
|
|
68
|
+
* ```
|
|
69
|
+
* @mermaid
|
|
70
|
+
* sequenceDiagram
|
|
71
|
+
* autonumber
|
|
72
|
+
* participant Caller
|
|
73
|
+
* participant Service as GoogleDocsService
|
|
74
|
+
* participant API as Google Docs API
|
|
75
|
+
* Caller->>Service: appendText(documentId, text)
|
|
76
|
+
* activate Service
|
|
77
|
+
* Service->>Service: requireAuth()
|
|
78
|
+
* Service->>API: GET /documents/{id}
|
|
79
|
+
* activate API
|
|
80
|
+
* API-->>Service: body content endIndex
|
|
81
|
+
* deactivate API
|
|
82
|
+
* Service->>API: POST /documents/{id}:batchUpdate
|
|
83
|
+
* activate API
|
|
84
|
+
* API-->>Service: batch update result
|
|
85
|
+
* deactivate API
|
|
86
|
+
* Service-->>Caller: batch update result
|
|
87
|
+
* deactivate Service
|
|
88
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
89
|
+
*/
|
|
90
|
+
export declare class GoogleDocsService extends HttpApiService<GoogleDocsServiceConfig> {
|
|
91
|
+
/**
|
|
92
|
+
* @description The provider name used in error messages
|
|
93
|
+
*/
|
|
94
|
+
protected readonly serviceName = "Google Docs";
|
|
95
|
+
/**
|
|
96
|
+
* @description The Google Docs API base URL
|
|
97
|
+
* @summary Used when the resolved config carries no `baseUrl`.
|
|
98
|
+
* @returns {string} `"https://docs.googleapis.com/v1"`.
|
|
99
|
+
*/
|
|
100
|
+
protected defaultBaseUrl(): string;
|
|
101
|
+
/**
|
|
102
|
+
* @description Builds the Google Docs authentication headers
|
|
103
|
+
* @summary Prefers `Authorization: Bearer <token>`, falls back to
|
|
104
|
+
* `X-Goog-Api-Key: <apiKey>`, and returns no headers when neither is set.
|
|
105
|
+
* @param {GoogleDocsServiceConfig} config - The resolved service configuration.
|
|
106
|
+
* @returns {Record<string, string>} The authentication headers.
|
|
107
|
+
*/
|
|
108
|
+
protected authHeaders(config: GoogleDocsServiceConfig): Record<string, string>;
|
|
109
|
+
/**
|
|
110
|
+
* @description Reads the Google Docs credentials and defaults from the environment
|
|
111
|
+
* @summary Reads the `io.googleDocs` slice and returns a partial config when
|
|
112
|
+
* a token or API key is configured, `undefined` otherwise. Values pass
|
|
113
|
+
* through `envString`/`envNumber` to reject unset-leaf proxies.
|
|
114
|
+
* @returns {Partial<GoogleDocsServiceConfig> | undefined} A partial config, or `undefined` when no credential is configured.
|
|
115
|
+
*/
|
|
116
|
+
protected configFromEnvironment(): Partial<GoogleDocsServiceConfig> | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* @description Asserts that an OAuth token or API key is configured
|
|
119
|
+
* @summary Called by every operation before it touches the network.
|
|
120
|
+
* @returns {void}
|
|
121
|
+
* @throws {InternalError} When neither a token nor an API key is configured.
|
|
122
|
+
*/
|
|
123
|
+
protected requireAuth(): void;
|
|
124
|
+
/**
|
|
125
|
+
* @description Fetches a Google Docs document
|
|
126
|
+
* @summary `GET`s `/documents/<id>` and returns the full document payload.
|
|
127
|
+
* @param {string} documentId - The document ID.
|
|
128
|
+
* @returns {Promise<unknown>} The document payload.
|
|
129
|
+
* @throws {InternalError} When no credential is configured or the document ID is empty.
|
|
130
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
131
|
+
* @throws {BadRequestError} When Google rejects the request.
|
|
132
|
+
*/
|
|
133
|
+
getDocument(documentId: string): Promise<unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* @description Creates a Google Docs document
|
|
136
|
+
* @summary `POST`s a new document with the given title and returns its
|
|
137
|
+
* payload (including `documentId`).
|
|
138
|
+
* @param {string} title - The new document title.
|
|
139
|
+
* @returns {Promise<unknown>} The created document payload.
|
|
140
|
+
* @throws {InternalError} When no credential is configured or the title is empty.
|
|
141
|
+
* @throws {BadRequestError} When Google rejects the request.
|
|
142
|
+
*/
|
|
143
|
+
createDocument(title: string): Promise<unknown>;
|
|
144
|
+
/**
|
|
145
|
+
* @description Applies a raw Google Docs batch update
|
|
146
|
+
* @summary `POST`s the `requests` array to `/documents/<id>:batchUpdate`
|
|
147
|
+
* unchanged, allowing any Docs API request type.
|
|
148
|
+
* @param {string} documentId - The document ID.
|
|
149
|
+
* @param {unknown[]} requests - The Docs API request objects.
|
|
150
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
151
|
+
* @throws {InternalError} When no credential is configured, or the document ID or requests are missing.
|
|
152
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
153
|
+
* @throws {BadRequestError} When Google rejects a request.
|
|
154
|
+
*/
|
|
155
|
+
batchUpdate(documentId: string, requests: unknown[]): Promise<unknown>;
|
|
156
|
+
/**
|
|
157
|
+
* @description Appends text to the end of a Google Docs document
|
|
158
|
+
* @summary Reads the document to find the final `endIndex`, then inserts the
|
|
159
|
+
* text just before it through a `batchUpdate`.
|
|
160
|
+
* @param {string} documentId - The document ID.
|
|
161
|
+
* @param {string} text - The text to append.
|
|
162
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
163
|
+
* @throws {InternalError} When no credential is configured, or the document ID or text is empty.
|
|
164
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
165
|
+
* @throws {BadRequestError} When Google rejects the update.
|
|
166
|
+
*/
|
|
167
|
+
appendText(documentId: string, text: string): Promise<unknown>;
|
|
168
|
+
/**
|
|
169
|
+
* @description Replaces all matching text in a Google Docs document
|
|
170
|
+
* @summary Sends a `replaceAllText` request honoring the `matchCase` option
|
|
171
|
+
* and returns the batch update response payload.
|
|
172
|
+
* @param {GoogleDocsReplaceInput} input - The document, find/replace text, and case option.
|
|
173
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
174
|
+
* @throws {InternalError} When no credential is configured, or the document ID or find text is empty.
|
|
175
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
176
|
+
* @throws {BadRequestError} When Google rejects the update.
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* await docs.replaceAllText({
|
|
180
|
+
* documentId: "abc123",
|
|
181
|
+
* find: "TODO",
|
|
182
|
+
* replace: "DONE",
|
|
183
|
+
* matchCase: true,
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
replaceAllText(input: GoogleDocsReplaceInput): Promise<unknown>;
|
|
188
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { HttpApiService, type HttpApiServiceConfig } from "../../shared/http/index.d.mts";
|
|
2
|
+
/**
|
|
3
|
+
* @description Configuration for the Google Docs service
|
|
4
|
+
* @summary Extends {@link HttpApiServiceConfig} with an optional OAuth
|
|
5
|
+
* `token` (preferred) and an optional `apiKey`. When omitted, the
|
|
6
|
+
* `io.googleDocs` environment slice supplies the same values (plus optional
|
|
7
|
+
* `baseUrl`/`timeout`). At least one credential is required; the token wins
|
|
8
|
+
* when both are set.
|
|
9
|
+
* @category IO
|
|
10
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
11
|
+
*/
|
|
12
|
+
export interface GoogleDocsServiceConfig extends HttpApiServiceConfig {
|
|
13
|
+
/**
|
|
14
|
+
* @description Google OAuth access token
|
|
15
|
+
* @summary Sent as `Authorization: Bearer <token>` when present.
|
|
16
|
+
*/
|
|
17
|
+
token?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @description Google API key
|
|
20
|
+
* @summary Sent as `X-Goog-Api-Key` only when no OAuth token is configured.
|
|
21
|
+
*/
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @description Input for replacing all matching text in a document
|
|
26
|
+
* @summary Carries the `documentId`, the `find` text, its `replace`ment, and
|
|
27
|
+
* whether matching is case-sensitive.
|
|
28
|
+
* @category IO
|
|
29
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
30
|
+
*/
|
|
31
|
+
export interface GoogleDocsReplaceInput {
|
|
32
|
+
/**
|
|
33
|
+
* @description Document ID to update
|
|
34
|
+
*/
|
|
35
|
+
documentId: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description Text to search for
|
|
38
|
+
*/
|
|
39
|
+
find: string;
|
|
40
|
+
/**
|
|
41
|
+
* @description Replacement text (defaults to the empty string)
|
|
42
|
+
*/
|
|
43
|
+
replace: string;
|
|
44
|
+
/**
|
|
45
|
+
* @description Whether matching is case-sensitive (default `false`)
|
|
46
|
+
*/
|
|
47
|
+
matchCase?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description Google Docs API integration service
|
|
51
|
+
* @summary An undecorated HTTP service for reading and creating documents,
|
|
52
|
+
* running raw batch updates, appending text, and replacing all matching text.
|
|
53
|
+
* Every operation needs either an OAuth token or an API key; missing
|
|
54
|
+
* credentials or identifiers raise `InternalError`, and transport failures are
|
|
55
|
+
* mapped to decaf errors via {@link httpError}.
|
|
56
|
+
* @class GoogleDocsService
|
|
57
|
+
* @extends HttpApiService
|
|
58
|
+
* @category IO
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { GoogleDocsService } from "@decaf-ts/integrations/io/google-docs";
|
|
62
|
+
*
|
|
63
|
+
* const docs = new GoogleDocsService();
|
|
64
|
+
* await docs.initialize({
|
|
65
|
+
* token: process.env.GRAPH_CREDENTIAL_GOOGLE_DOCS_TOKEN,
|
|
66
|
+
* });
|
|
67
|
+
* await docs.appendText(process.env.GOOGLE_DOC_ID ?? "", "New paragraph");
|
|
68
|
+
* ```
|
|
69
|
+
* @mermaid
|
|
70
|
+
* sequenceDiagram
|
|
71
|
+
* autonumber
|
|
72
|
+
* participant Caller
|
|
73
|
+
* participant Service as GoogleDocsService
|
|
74
|
+
* participant API as Google Docs API
|
|
75
|
+
* Caller->>Service: appendText(documentId, text)
|
|
76
|
+
* activate Service
|
|
77
|
+
* Service->>Service: requireAuth()
|
|
78
|
+
* Service->>API: GET /documents/{id}
|
|
79
|
+
* activate API
|
|
80
|
+
* API-->>Service: body content endIndex
|
|
81
|
+
* deactivate API
|
|
82
|
+
* Service->>API: POST /documents/{id}:batchUpdate
|
|
83
|
+
* activate API
|
|
84
|
+
* API-->>Service: batch update result
|
|
85
|
+
* deactivate API
|
|
86
|
+
* Service-->>Caller: batch update result
|
|
87
|
+
* deactivate Service
|
|
88
|
+
* @memberOf module:integrations/io/google-docs/service
|
|
89
|
+
*/
|
|
90
|
+
export declare class GoogleDocsService extends HttpApiService<GoogleDocsServiceConfig> {
|
|
91
|
+
/**
|
|
92
|
+
* @description The provider name used in error messages
|
|
93
|
+
*/
|
|
94
|
+
protected readonly serviceName = "Google Docs";
|
|
95
|
+
/**
|
|
96
|
+
* @description The Google Docs API base URL
|
|
97
|
+
* @summary Used when the resolved config carries no `baseUrl`.
|
|
98
|
+
* @returns {string} `"https://docs.googleapis.com/v1"`.
|
|
99
|
+
*/
|
|
100
|
+
protected defaultBaseUrl(): string;
|
|
101
|
+
/**
|
|
102
|
+
* @description Builds the Google Docs authentication headers
|
|
103
|
+
* @summary Prefers `Authorization: Bearer <token>`, falls back to
|
|
104
|
+
* `X-Goog-Api-Key: <apiKey>`, and returns no headers when neither is set.
|
|
105
|
+
* @param {GoogleDocsServiceConfig} config - The resolved service configuration.
|
|
106
|
+
* @returns {Record<string, string>} The authentication headers.
|
|
107
|
+
*/
|
|
108
|
+
protected authHeaders(config: GoogleDocsServiceConfig): Record<string, string>;
|
|
109
|
+
/**
|
|
110
|
+
* @description Reads the Google Docs credentials and defaults from the environment
|
|
111
|
+
* @summary Reads the `io.googleDocs` slice and returns a partial config when
|
|
112
|
+
* a token or API key is configured, `undefined` otherwise. Values pass
|
|
113
|
+
* through `envString`/`envNumber` to reject unset-leaf proxies.
|
|
114
|
+
* @returns {Partial<GoogleDocsServiceConfig> | undefined} A partial config, or `undefined` when no credential is configured.
|
|
115
|
+
*/
|
|
116
|
+
protected configFromEnvironment(): Partial<GoogleDocsServiceConfig> | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* @description Asserts that an OAuth token or API key is configured
|
|
119
|
+
* @summary Called by every operation before it touches the network.
|
|
120
|
+
* @returns {void}
|
|
121
|
+
* @throws {InternalError} When neither a token nor an API key is configured.
|
|
122
|
+
*/
|
|
123
|
+
protected requireAuth(): void;
|
|
124
|
+
/**
|
|
125
|
+
* @description Fetches a Google Docs document
|
|
126
|
+
* @summary `GET`s `/documents/<id>` and returns the full document payload.
|
|
127
|
+
* @param {string} documentId - The document ID.
|
|
128
|
+
* @returns {Promise<unknown>} The document payload.
|
|
129
|
+
* @throws {InternalError} When no credential is configured or the document ID is empty.
|
|
130
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
131
|
+
* @throws {BadRequestError} When Google rejects the request.
|
|
132
|
+
*/
|
|
133
|
+
getDocument(documentId: string): Promise<unknown>;
|
|
134
|
+
/**
|
|
135
|
+
* @description Creates a Google Docs document
|
|
136
|
+
* @summary `POST`s a new document with the given title and returns its
|
|
137
|
+
* payload (including `documentId`).
|
|
138
|
+
* @param {string} title - The new document title.
|
|
139
|
+
* @returns {Promise<unknown>} The created document payload.
|
|
140
|
+
* @throws {InternalError} When no credential is configured or the title is empty.
|
|
141
|
+
* @throws {BadRequestError} When Google rejects the request.
|
|
142
|
+
*/
|
|
143
|
+
createDocument(title: string): Promise<unknown>;
|
|
144
|
+
/**
|
|
145
|
+
* @description Applies a raw Google Docs batch update
|
|
146
|
+
* @summary `POST`s the `requests` array to `/documents/<id>:batchUpdate`
|
|
147
|
+
* unchanged, allowing any Docs API request type.
|
|
148
|
+
* @param {string} documentId - The document ID.
|
|
149
|
+
* @param {unknown[]} requests - The Docs API request objects.
|
|
150
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
151
|
+
* @throws {InternalError} When no credential is configured, or the document ID or requests are missing.
|
|
152
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
153
|
+
* @throws {BadRequestError} When Google rejects a request.
|
|
154
|
+
*/
|
|
155
|
+
batchUpdate(documentId: string, requests: unknown[]): Promise<unknown>;
|
|
156
|
+
/**
|
|
157
|
+
* @description Appends text to the end of a Google Docs document
|
|
158
|
+
* @summary Reads the document to find the final `endIndex`, then inserts the
|
|
159
|
+
* text just before it through a `batchUpdate`.
|
|
160
|
+
* @param {string} documentId - The document ID.
|
|
161
|
+
* @param {string} text - The text to append.
|
|
162
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
163
|
+
* @throws {InternalError} When no credential is configured, or the document ID or text is empty.
|
|
164
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
165
|
+
* @throws {BadRequestError} When Google rejects the update.
|
|
166
|
+
*/
|
|
167
|
+
appendText(documentId: string, text: string): Promise<unknown>;
|
|
168
|
+
/**
|
|
169
|
+
* @description Replaces all matching text in a Google Docs document
|
|
170
|
+
* @summary Sends a `replaceAllText` request honoring the `matchCase` option
|
|
171
|
+
* and returns the batch update response payload.
|
|
172
|
+
* @param {GoogleDocsReplaceInput} input - The document, find/replace text, and case option.
|
|
173
|
+
* @returns {Promise<unknown>} The batch update response payload.
|
|
174
|
+
* @throws {InternalError} When no credential is configured, or the document ID or find text is empty.
|
|
175
|
+
* @throws {NotFoundError} When the document does not exist (HTTP 404).
|
|
176
|
+
* @throws {BadRequestError} When Google rejects the update.
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* await docs.replaceAllText({
|
|
180
|
+
* documentId: "abc123",
|
|
181
|
+
* find: "TODO",
|
|
182
|
+
* replace: "DONE",
|
|
183
|
+
* matchCase: true,
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
replaceAllText(input: GoogleDocsReplaceInput): Promise<unknown>;
|
|
188
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GoogleDocsService.d.cts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GoogleDocsService.d.mts";
|
package/lib/types/io/index.d.cts
CHANGED
|
@@ -9,4 +9,9 @@ export * from "./airtable/index.d.cts";
|
|
|
9
9
|
export * from "./google-sheets/index.d.cts";
|
|
10
10
|
export * from "./graphql/index.d.cts";
|
|
11
11
|
export * from "./spreadsheet/index.d.cts";
|
|
12
|
+
export * from "./microsoft-excel/index.d.cts";
|
|
13
|
+
export * from "./confluence/index.d.cts";
|
|
14
|
+
export * from "./jira/index.d.cts";
|
|
15
|
+
export * from "./google-docs/index.d.cts";
|
|
16
|
+
export * from "./microsoft-sharepoint/index.d.cts";
|
|
12
17
|
export * from "./environment.d.cts";
|
package/lib/types/io/index.d.mts
CHANGED
|
@@ -9,4 +9,9 @@ export * from "./airtable/index.d.mts";
|
|
|
9
9
|
export * from "./google-sheets/index.d.mts";
|
|
10
10
|
export * from "./graphql/index.d.mts";
|
|
11
11
|
export * from "./spreadsheet/index.d.mts";
|
|
12
|
+
export * from "./microsoft-excel/index.d.mts";
|
|
13
|
+
export * from "./confluence/index.d.mts";
|
|
14
|
+
export * from "./jira/index.d.mts";
|
|
15
|
+
export * from "./google-docs/index.d.mts";
|
|
16
|
+
export * from "./microsoft-sharepoint/index.d.mts";
|
|
12
17
|
export * from "./environment.d.mts";
|