@divyacon/piece-google-docs 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/append-text.d.ts +8 -0
- package/dist/lib/actions/append-text.d.ts.map +1 -0
- package/dist/lib/actions/append-text.js +40 -0
- package/dist/lib/actions/append-text.js.map +1 -0
- package/dist/lib/actions/batch-update.action.d.ts +8 -0
- package/dist/lib/actions/batch-update.action.d.ts.map +1 -0
- package/dist/lib/actions/batch-update.action.js +63 -0
- package/dist/lib/actions/batch-update.action.js.map +1 -0
- package/dist/lib/actions/copy-document.action.d.ts +12 -0
- package/dist/lib/actions/copy-document.action.d.ts.map +1 -0
- package/dist/lib/actions/copy-document.action.js +72 -0
- package/dist/lib/actions/copy-document.action.js.map +1 -0
- package/dist/lib/actions/create-and-populate-table.action.d.ts +8 -0
- package/dist/lib/actions/create-and-populate-table.action.d.ts.map +1 -0
- package/dist/lib/actions/create-and-populate-table.action.js +138 -0
- package/dist/lib/actions/create-and-populate-table.action.js.map +1 -0
- package/dist/lib/actions/create-document-based-on-template.action.d.ts +10 -0
- package/dist/lib/actions/create-document-based-on-template.action.d.ts.map +1 -0
- package/dist/lib/actions/create-document-based-on-template.action.js +107 -0
- package/dist/lib/actions/create-document-based-on-template.action.js.map +1 -0
- package/dist/lib/actions/create-document-from-markdown.action.d.ts +8 -0
- package/dist/lib/actions/create-document-from-markdown.action.d.ts.map +1 -0
- package/dist/lib/actions/create-document-from-markdown.action.js +69 -0
- package/dist/lib/actions/create-document-from-markdown.action.js.map +1 -0
- package/dist/lib/actions/create-document.d.ts +8 -0
- package/dist/lib/actions/create-document.d.ts.map +1 -0
- package/dist/lib/actions/create-document.js +35 -0
- package/dist/lib/actions/create-document.js.map +1 -0
- package/dist/lib/actions/create-footer.action.d.ts +8 -0
- package/dist/lib/actions/create-footer.action.d.ts.map +1 -0
- package/dist/lib/actions/create-footer.action.js +66 -0
- package/dist/lib/actions/create-footer.action.js.map +1 -0
- package/dist/lib/actions/create-footnote.action.d.ts +8 -0
- package/dist/lib/actions/create-footnote.action.d.ts.map +1 -0
- package/dist/lib/actions/create-footnote.action.js +58 -0
- package/dist/lib/actions/create-footnote.action.js.map +1 -0
- package/dist/lib/actions/create-header.action.d.ts +8 -0
- package/dist/lib/actions/create-header.action.d.ts.map +1 -0
- package/dist/lib/actions/create-header.action.js +66 -0
- package/dist/lib/actions/create-header.action.js.map +1 -0
- package/dist/lib/actions/create-named-range.action.d.ts +10 -0
- package/dist/lib/actions/create-named-range.action.d.ts.map +1 -0
- package/dist/lib/actions/create-named-range.action.js +74 -0
- package/dist/lib/actions/create-named-range.action.js.map +1 -0
- package/dist/lib/actions/create-paragraph-bullets.action.d.ts +10 -0
- package/dist/lib/actions/create-paragraph-bullets.action.d.ts.map +1 -0
- package/dist/lib/actions/create-paragraph-bullets.action.js +98 -0
- package/dist/lib/actions/create-paragraph-bullets.action.js.map +1 -0
- package/dist/lib/actions/create-text-document.action.d.ts +8 -0
- package/dist/lib/actions/create-text-document.action.d.ts.map +1 -0
- package/dist/lib/actions/create-text-document.action.js +42 -0
- package/dist/lib/actions/create-text-document.action.js.map +1 -0
- package/dist/lib/actions/delete-content-range.action.d.ts +9 -0
- package/dist/lib/actions/delete-content-range.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-content-range.action.js +64 -0
- package/dist/lib/actions/delete-content-range.action.js.map +1 -0
- package/dist/lib/actions/delete-footer.action.d.ts +8 -0
- package/dist/lib/actions/delete-footer.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-footer.action.js +56 -0
- package/dist/lib/actions/delete-footer.action.js.map +1 -0
- package/dist/lib/actions/delete-header.action.d.ts +8 -0
- package/dist/lib/actions/delete-header.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-header.action.js +56 -0
- package/dist/lib/actions/delete-header.action.js.map +1 -0
- package/dist/lib/actions/delete-named-range.action.d.ts +9 -0
- package/dist/lib/actions/delete-named-range.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-named-range.action.js +69 -0
- package/dist/lib/actions/delete-named-range.action.js.map +1 -0
- package/dist/lib/actions/delete-paragraph-bullets.action.d.ts +9 -0
- package/dist/lib/actions/delete-paragraph-bullets.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-paragraph-bullets.action.js +66 -0
- package/dist/lib/actions/delete-paragraph-bullets.action.js.map +1 -0
- package/dist/lib/actions/delete-table-column.action.d.ts +10 -0
- package/dist/lib/actions/delete-table-column.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-table-column.action.js +72 -0
- package/dist/lib/actions/delete-table-column.action.js.map +1 -0
- package/dist/lib/actions/delete-table-row.action.d.ts +10 -0
- package/dist/lib/actions/delete-table-row.action.d.ts.map +1 -0
- package/dist/lib/actions/delete-table-row.action.js +72 -0
- package/dist/lib/actions/delete-table-row.action.js.map +1 -0
- package/dist/lib/actions/export-as-pdf.action.d.ts +7 -0
- package/dist/lib/actions/export-as-pdf.action.d.ts.map +1 -0
- package/dist/lib/actions/export-as-pdf.action.js +61 -0
- package/dist/lib/actions/export-as-pdf.action.js.map +1 -0
- package/dist/lib/actions/find-document.d.ts +16 -0
- package/dist/lib/actions/find-document.d.ts.map +1 -0
- package/dist/lib/actions/find-document.js +127 -0
- package/dist/lib/actions/find-document.js.map +1 -0
- package/dist/lib/actions/get-document-end-index.action.d.ts +7 -0
- package/dist/lib/actions/get-document-end-index.action.d.ts.map +1 -0
- package/dist/lib/actions/get-document-end-index.action.js +54 -0
- package/dist/lib/actions/get-document-end-index.action.js.map +1 -0
- package/dist/lib/actions/get-document-plaintext.action.d.ts +7 -0
- package/dist/lib/actions/get-document-plaintext.action.d.ts.map +1 -0
- package/dist/lib/actions/get-document-plaintext.action.js +76 -0
- package/dist/lib/actions/get-document-plaintext.action.js.map +1 -0
- package/dist/lib/actions/get-document.action.d.ts +7 -0
- package/dist/lib/actions/get-document.action.d.ts.map +1 -0
- package/dist/lib/actions/get-document.action.js +45 -0
- package/dist/lib/actions/get-document.action.js.map +1 -0
- package/dist/lib/actions/insert-image-in-table-cell.action.d.ts +13 -0
- package/dist/lib/actions/insert-image-in-table-cell.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-image-in-table-cell.action.js +128 -0
- package/dist/lib/actions/insert-image-in-table-cell.action.js.map +1 -0
- package/dist/lib/actions/insert-inline-image.action.d.ts +11 -0
- package/dist/lib/actions/insert-inline-image.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-inline-image.action.js +84 -0
- package/dist/lib/actions/insert-inline-image.action.js.map +1 -0
- package/dist/lib/actions/insert-page-break.action.d.ts +8 -0
- package/dist/lib/actions/insert-page-break.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-page-break.action.js +60 -0
- package/dist/lib/actions/insert-page-break.action.js.map +1 -0
- package/dist/lib/actions/insert-table-column.action.d.ts +11 -0
- package/dist/lib/actions/insert-table-column.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-table-column.action.js +86 -0
- package/dist/lib/actions/insert-table-column.action.js.map +1 -0
- package/dist/lib/actions/insert-table-row.action.d.ts +11 -0
- package/dist/lib/actions/insert-table-row.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-table-row.action.js +86 -0
- package/dist/lib/actions/insert-table-row.action.js.map +1 -0
- package/dist/lib/actions/insert-table.action.d.ts +10 -0
- package/dist/lib/actions/insert-table.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-table.action.js +72 -0
- package/dist/lib/actions/insert-table.action.js.map +1 -0
- package/dist/lib/actions/insert-text-in-table-cell.action.d.ts +11 -0
- package/dist/lib/actions/insert-text-in-table-cell.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-text-in-table-cell.action.js +115 -0
- package/dist/lib/actions/insert-text-in-table-cell.action.js.map +1 -0
- package/dist/lib/actions/insert-text.action.d.ts +9 -0
- package/dist/lib/actions/insert-text.action.d.ts.map +1 -0
- package/dist/lib/actions/insert-text.action.js +66 -0
- package/dist/lib/actions/insert-text.action.js.map +1 -0
- package/dist/lib/actions/read-document.action.d.ts +7 -0
- package/dist/lib/actions/read-document.action.d.ts.map +1 -0
- package/dist/lib/actions/read-document.action.js +44 -0
- package/dist/lib/actions/read-document.action.js.map +1 -0
- package/dist/lib/actions/replace-all-text.action.d.ts +10 -0
- package/dist/lib/actions/replace-all-text.action.d.ts.map +1 -0
- package/dist/lib/actions/replace-all-text.action.js +92 -0
- package/dist/lib/actions/replace-all-text.action.js.map +1 -0
- package/dist/lib/actions/replace-body-with-markdown.action.d.ts +8 -0
- package/dist/lib/actions/replace-body-with-markdown.action.d.ts.map +1 -0
- package/dist/lib/actions/replace-body-with-markdown.action.js +79 -0
- package/dist/lib/actions/replace-body-with-markdown.action.js.map +1 -0
- package/dist/lib/actions/replace-image.action.d.ts +9 -0
- package/dist/lib/actions/replace-image.action.d.ts.map +1 -0
- package/dist/lib/actions/replace-image.action.js +65 -0
- package/dist/lib/actions/replace-image.action.js.map +1 -0
- package/dist/lib/actions/replace-section-with-markdown.action.d.ts +10 -0
- package/dist/lib/actions/replace-section-with-markdown.action.d.ts.map +1 -0
- package/dist/lib/actions/replace-section-with-markdown.action.js +106 -0
- package/dist/lib/actions/replace-section-with-markdown.action.js.map +1 -0
- package/dist/lib/actions/search-documents.action.d.ts +11 -0
- package/dist/lib/actions/search-documents.action.d.ts.map +1 -0
- package/dist/lib/actions/search-documents.action.js +121 -0
- package/dist/lib/actions/search-documents.action.js.map +1 -0
- package/dist/lib/actions/unmerge-table-cells.action.d.ts +12 -0
- package/dist/lib/actions/unmerge-table-cells.action.d.ts.map +1 -0
- package/dist/lib/actions/unmerge-table-cells.action.js +94 -0
- package/dist/lib/actions/unmerge-table-cells.action.js.map +1 -0
- package/dist/lib/actions/update-document-style.action.d.ts +11 -0
- package/dist/lib/actions/update-document-style.action.d.ts.map +1 -0
- package/dist/lib/actions/update-document-style.action.js +95 -0
- package/dist/lib/actions/update-document-style.action.js.map +1 -0
- package/dist/lib/actions/update-table-row-style.action.d.ts +10 -0
- package/dist/lib/actions/update-table-row-style.action.d.ts.map +1 -0
- package/dist/lib/actions/update-table-row-style.action.js +78 -0
- package/dist/lib/actions/update-table-row-style.action.js.map +1 -0
- package/dist/lib/auth.d.ts +11 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +92 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/index.d.ts +11 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +124 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/common/props.d.ts +5 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +53 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/output-schemas.d.ts +43 -0
- package/dist/lib/output-schemas.d.ts.map +1 -0
- package/dist/lib/output-schemas.js +554 -0
- package/dist/lib/output-schemas.js.map +1 -0
- package/dist/lib/triggers/new-document.d.ts +35 -0
- package/dist/lib/triggers/new-document.d.ts.map +1 -0
- package/dist/lib/triggers/new-document.js +104 -0
- package/dist/lib/triggers/new-document.js.map +1 -0
- package/package.json +48 -4
- package/src/index.ts +120 -0
- package/src/lib/actions/append-text.ts +37 -0
- package/src/lib/actions/batch-update.action.ts +58 -0
- package/src/lib/actions/copy-document.action.ts +74 -0
- package/src/lib/actions/create-and-populate-table.action.ts +141 -0
- package/src/lib/actions/create-document-based-on-template.action.ts +110 -0
- package/src/lib/actions/create-document-from-markdown.action.ts +63 -0
- package/src/lib/actions/create-document.ts +36 -0
- package/src/lib/actions/create-footer.action.ts +59 -0
- package/src/lib/actions/create-footnote.action.ts +53 -0
- package/src/lib/actions/create-header.action.ts +59 -0
- package/src/lib/actions/create-named-range.action.ts +70 -0
- package/src/lib/actions/create-paragraph-bullets.action.ts +95 -0
- package/src/lib/actions/create-text-document.action.ts +35 -0
- package/src/lib/actions/delete-content-range.action.ts +59 -0
- package/src/lib/actions/delete-footer.action.ts +51 -0
- package/src/lib/actions/delete-header.action.ts +51 -0
- package/src/lib/actions/delete-named-range.action.ts +65 -0
- package/src/lib/actions/delete-paragraph-bullets.action.ts +62 -0
- package/src/lib/actions/delete-table-column.action.ts +67 -0
- package/src/lib/actions/delete-table-row.action.ts +67 -0
- package/src/lib/actions/export-as-pdf.action.ts +59 -0
- package/src/lib/actions/find-document.ts +136 -0
- package/src/lib/actions/get-document-end-index.action.ts +47 -0
- package/src/lib/actions/get-document-plaintext.action.ts +74 -0
- package/src/lib/actions/get-document.action.ts +37 -0
- package/src/lib/actions/insert-image-in-table-cell.action.ts +139 -0
- package/src/lib/actions/insert-inline-image.action.ts +83 -0
- package/src/lib/actions/insert-page-break.action.ts +56 -0
- package/src/lib/actions/insert-table-column.action.ts +80 -0
- package/src/lib/actions/insert-table-row.action.ts +80 -0
- package/src/lib/actions/insert-table.action.ts +68 -0
- package/src/lib/actions/insert-text-in-table-cell.action.ts +120 -0
- package/src/lib/actions/insert-text.action.ts +62 -0
- package/src/lib/actions/read-document.action.ts +40 -0
- package/src/lib/actions/replace-all-text.action.ts +95 -0
- package/src/lib/actions/replace-body-with-markdown.action.ts +76 -0
- package/src/lib/actions/replace-image.action.ts +60 -0
- package/src/lib/actions/replace-section-with-markdown.action.ts +104 -0
- package/src/lib/actions/search-documents.action.ts +131 -0
- package/src/lib/actions/unmerge-table-cells.action.ts +88 -0
- package/src/lib/actions/update-document-style.action.ts +93 -0
- package/src/lib/actions/update-table-row-style.action.ts +73 -0
- package/src/lib/auth.ts +84 -0
- package/src/lib/common/index.ts +126 -0
- package/src/lib/common/props.ts +55 -0
- package/src/lib/output-schemas.ts +593 -0
- package/src/lib/triggers/new-document.ts +108 -0
- package/README.md +0 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs } from '@googleapis/docs';
|
|
5
|
+
import { editTemplateActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
const PLACEHOLDER_FORMATS: Record<string, string> = {
|
|
8
|
+
'curly_braces': '{{KEY}}',
|
|
9
|
+
'square_brackets': '[[KEY]]',
|
|
10
|
+
'single_curly': '{KEY}',
|
|
11
|
+
'single_square': '[KEY]',
|
|
12
|
+
'{{KEY}}': '{{KEY}}',
|
|
13
|
+
'[[KEY]]': '[[KEY]]',
|
|
14
|
+
'{KEY}': '{KEY}',
|
|
15
|
+
'[KEY]': '[KEY]',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const createDocumentBasedOnTemplate = createAction({
|
|
19
|
+
auth: googleDocsAuth,
|
|
20
|
+
name: 'create_document_based_on_template',
|
|
21
|
+
description:
|
|
22
|
+
'Edit a template file and replace the values with the ones provided',
|
|
23
|
+
audience: 'both',
|
|
24
|
+
aiMetadata: {
|
|
25
|
+
description:
|
|
26
|
+
'Fills a Google Docs template in place by find-and-replacing placeholder tokens (e.g. [[KEY]] or {{KEY}}) with supplied key/value pairs and swapping placeholder images by object ID. Use when an agent has an existing template document and wants to merge data into it rather than build a doc from scratch. Requires the target document ID and the matching placeholder format; idempotent since re-running with the same values replaces no remaining placeholders and leaves the document unchanged.',
|
|
27
|
+
idempotent: true,
|
|
28
|
+
},
|
|
29
|
+
displayName: 'Edit template file',
|
|
30
|
+
props: {
|
|
31
|
+
template: Property.ShortText({
|
|
32
|
+
displayName: 'Destination File',
|
|
33
|
+
description: 'The ID of the file to replace the values',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
values: Property.Object({
|
|
37
|
+
displayName: 'Variables',
|
|
38
|
+
description: 'Dont include the placeholder format "[[]]" or "{{}}", only the key name and its value',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
images: Property.Object({
|
|
42
|
+
displayName: 'Images',
|
|
43
|
+
description:
|
|
44
|
+
'Key: Image ID (get it manually from the Read File Action), Value: Image URL',
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
placeholder_format: Property.StaticDropdown({
|
|
48
|
+
displayName: 'Placeholder Format',
|
|
49
|
+
description: 'Choose the format of placeholders in your template',
|
|
50
|
+
required: true,
|
|
51
|
+
defaultValue: 'square_brackets',
|
|
52
|
+
options: {
|
|
53
|
+
disabled: false,
|
|
54
|
+
options: [
|
|
55
|
+
{ label: 'Curly Braces {{}}', value: 'curly_braces' },
|
|
56
|
+
{ label: 'Square Brackets [[]]', value: 'square_brackets' },
|
|
57
|
+
{ label: 'Single Curly Braces {}', value: 'single_curly' },
|
|
58
|
+
{ label: 'Single Square Brackets []', value: 'single_square' }
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
outputSchema: editTemplateActionOutputSchema,
|
|
64
|
+
async run(context) {
|
|
65
|
+
const documentId: string = context.propsValue.template;
|
|
66
|
+
const values = context.propsValue.values;
|
|
67
|
+
const placeholderType = context.propsValue.placeholder_format;
|
|
68
|
+
const placeholder_format = PLACEHOLDER_FORMATS[placeholderType] || '[[KEY]]';
|
|
69
|
+
|
|
70
|
+
const authClient = await createGoogleClient(context.auth);
|
|
71
|
+
const docs = googleDocs('v1');
|
|
72
|
+
|
|
73
|
+
const requests = [];
|
|
74
|
+
|
|
75
|
+
for (const key in values) {
|
|
76
|
+
const value = values[key];
|
|
77
|
+
const new_key = placeholder_format.replace('KEY', key);
|
|
78
|
+
|
|
79
|
+
requests.push({
|
|
80
|
+
replaceAllText: {
|
|
81
|
+
containsText: {
|
|
82
|
+
text: new_key,
|
|
83
|
+
matchCase: true,
|
|
84
|
+
},
|
|
85
|
+
replaceText: String(value),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const key in context.propsValue.images) {
|
|
91
|
+
const value = context.propsValue.images[key];
|
|
92
|
+
requests.push({
|
|
93
|
+
replaceImage: {
|
|
94
|
+
imageObjectId: key,
|
|
95
|
+
uri: String(value),
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const res = await docs.documents.batchUpdate({
|
|
101
|
+
auth: authClient,
|
|
102
|
+
documentId,
|
|
103
|
+
requestBody: {
|
|
104
|
+
requests: requests,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return res;
|
|
109
|
+
},
|
|
110
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs } from '@googleapis/docs';
|
|
5
|
+
import { createDocumentFromMarkdownActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createDocumentFromMarkdown = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_document_from_markdown',
|
|
10
|
+
displayName: 'Create Document from Markdown',
|
|
11
|
+
description: 'Create a Google Docs document from Markdown content',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a new Google Docs document and populates it from Markdown text, converting headings (#, ##, ###), bullet lists (-, *, +), and paragraphs into native Google Docs formatting. Use when an agent has Markdown content (the format LLMs produce natively) and wants a formatted document in one call. Inline styling such as bold/italic is inserted as plain text. Not idempotent: each call creates a new document.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createDocumentFromMarkdownActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
title: Property.ShortText({
|
|
21
|
+
displayName: 'Title',
|
|
22
|
+
description: 'The title (and file name) of the new document.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
markdown: Property.LongText({
|
|
26
|
+
displayName: 'Markdown Content',
|
|
27
|
+
description: 'Markdown text. Supports headings (#/##/###), bullet lists (-/*/+), and paragraphs.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
async run(context) {
|
|
32
|
+
const { title, markdown } = context.propsValue;
|
|
33
|
+
const authClient = await createGoogleClient(context.auth);
|
|
34
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
35
|
+
|
|
36
|
+
let documentId: string;
|
|
37
|
+
try {
|
|
38
|
+
const created = await docs.documents.create({ requestBody: { title } });
|
|
39
|
+
if (!created.data.documentId) {
|
|
40
|
+
throw new Error('Google Docs did not return a document ID for the new document.');
|
|
41
|
+
}
|
|
42
|
+
documentId = created.data.documentId;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error(docsCommon.formatError(error, 'create'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const requests = docsCommon.markdownToBatchRequests(markdown);
|
|
48
|
+
if (requests.length > 0) {
|
|
49
|
+
try {
|
|
50
|
+
await docs.documents.batchUpdate({ documentId, requestBody: { requests } });
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error(docsCommon.formatError(error, 'populate the new'));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
documentId,
|
|
59
|
+
title,
|
|
60
|
+
url: `https://docs.google.com/document/d/${documentId}/edit`,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { googleDocsAuth, getAccessToken } from '../auth';
|
|
4
|
+
import { createDocumentActionOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const createDocument = createAction({
|
|
7
|
+
auth: googleDocsAuth,
|
|
8
|
+
name: 'create_document',
|
|
9
|
+
description: 'Create a document on Google Docs',
|
|
10
|
+
audience: 'human',
|
|
11
|
+
aiMetadata: {
|
|
12
|
+
description:
|
|
13
|
+
'Creates a brand-new Google Docs document with the given title and writes the provided text into it. Use when an agent needs to generate a fresh document from content it has produced; to add to an existing document use Append Text instead. Not idempotent: every call creates a separate new document.',
|
|
14
|
+
idempotent: false,
|
|
15
|
+
},
|
|
16
|
+
displayName: 'Create Document',
|
|
17
|
+
props: {
|
|
18
|
+
title: docsCommon.title,
|
|
19
|
+
body: docsCommon.body,
|
|
20
|
+
},
|
|
21
|
+
outputSchema: createDocumentActionOutputSchema,
|
|
22
|
+
async run(context) {
|
|
23
|
+
const accessToken = await getAccessToken(context.auth);
|
|
24
|
+
const document = await docsCommon.createDocument(
|
|
25
|
+
context.propsValue.title,
|
|
26
|
+
accessToken
|
|
27
|
+
);
|
|
28
|
+
const response = await docsCommon.writeToDocument(
|
|
29
|
+
document.documentId,
|
|
30
|
+
context.propsValue.body,
|
|
31
|
+
accessToken
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return response;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { createFooterActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createFooter = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_footer',
|
|
10
|
+
displayName: 'Create Footer',
|
|
11
|
+
description: 'Create a footer section in a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a footer section in a Google Docs document and returns the new footerId. Use this when you need to add a footer to a document before inserting footer text — the footerId returned here is required by any subsequent Insert Text call targeting the footer segment. Each call creates a new footer; not idempotent.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createFooterActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to add a footer to (from the document URL or Search Documents).',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
type: Property.StaticDropdown({
|
|
26
|
+
displayName: 'Footer Type',
|
|
27
|
+
description: 'The type of footer to create. DEFAULT is the standard document footer.',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 'DEFAULT',
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{ label: 'Default', value: 'DEFAULT' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
async run(context) {
|
|
38
|
+
const { documentId, type } = context.propsValue;
|
|
39
|
+
const authClient = await createGoogleClient(context.auth);
|
|
40
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
41
|
+
|
|
42
|
+
const request: docs_v1.Schema$Request = {
|
|
43
|
+
createFooter: {
|
|
44
|
+
type: (type ?? 'DEFAULT') as docs_v1.Schema$CreateFooterRequest['type'],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const response = await docs.documents.batchUpdate({
|
|
50
|
+
documentId,
|
|
51
|
+
requestBody: { requests: [request] },
|
|
52
|
+
});
|
|
53
|
+
const footerId = response.data.replies?.[0]?.createFooter?.footerId ?? null;
|
|
54
|
+
return { success: true, documentId, footerId };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new Error(docsCommon.formatError(error, 'create the footer in'));
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { createFootnoteActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createFootnote = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_footnote',
|
|
10
|
+
displayName: 'Create Footnote',
|
|
11
|
+
description: 'Insert a footnote at a character index in a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Inserts a footnote at a specific character index inside an existing paragraph in a Google Docs document, or at the end of the body segment if no index is provided. Returns the new footnoteId, which can then be used to insert text into the footnote segment via Insert Text. The index must fall inside an existing paragraph — obtain a valid index from Get Document End Index or Read Document (cannot be guessed). Not idempotent.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createFootnoteActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to insert a footnote into (from the document URL or Search Documents).',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
index: Property.Number({
|
|
26
|
+
displayName: 'Index',
|
|
27
|
+
description:
|
|
28
|
+
'Character index inside an existing paragraph where the footnote anchor is inserted. Leave empty to append at the end of the body segment. Obtain a valid index from Get Document End Index or Read Document — cannot be guessed.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
async run(context) {
|
|
33
|
+
const { documentId, index } = context.propsValue;
|
|
34
|
+
const authClient = await createGoogleClient(context.auth);
|
|
35
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
36
|
+
|
|
37
|
+
const request: docs_v1.Schema$Request =
|
|
38
|
+
index === undefined || index === null
|
|
39
|
+
? { createFootnote: { endOfSegmentLocation: {} } }
|
|
40
|
+
: { createFootnote: { location: { index } } };
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const response = await docs.documents.batchUpdate({
|
|
44
|
+
documentId,
|
|
45
|
+
requestBody: { requests: [request] },
|
|
46
|
+
});
|
|
47
|
+
const footnoteId = response.data.replies?.[0]?.createFootnote?.footnoteId ?? null;
|
|
48
|
+
return { success: true, documentId, footnoteId };
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new Error(docsCommon.formatError(error, 'create the footnote in'));
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { createHeaderActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createHeader = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_header',
|
|
10
|
+
displayName: 'Create Header',
|
|
11
|
+
description: 'Create a header section in a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a header section in a Google Docs document and returns the new headerId. Use this when you need to add a header to a document before inserting header text — the headerId returned here is required by any subsequent Insert Text call targeting the header segment. Each call creates a new header; not idempotent.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createHeaderActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to add a header to (from the document URL or Search Documents).',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
type: Property.StaticDropdown({
|
|
26
|
+
displayName: 'Header Type',
|
|
27
|
+
description: 'The type of header to create. DEFAULT is the standard document header.',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 'DEFAULT',
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{ label: 'Default', value: 'DEFAULT' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
async run(context) {
|
|
38
|
+
const { documentId, type } = context.propsValue;
|
|
39
|
+
const authClient = await createGoogleClient(context.auth);
|
|
40
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
41
|
+
|
|
42
|
+
const request: docs_v1.Schema$Request = {
|
|
43
|
+
createHeader: {
|
|
44
|
+
type: (type ?? 'DEFAULT') as docs_v1.Schema$CreateHeaderRequest['type'],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const response = await docs.documents.batchUpdate({
|
|
50
|
+
documentId,
|
|
51
|
+
requestBody: { requests: [request] },
|
|
52
|
+
});
|
|
53
|
+
const headerId = response.data.replies?.[0]?.createHeader?.headerId ?? null;
|
|
54
|
+
return { success: true, documentId, headerId };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new Error(docsCommon.formatError(error, 'create the header in'));
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { createNamedRangeActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createNamedRange = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_named_range',
|
|
10
|
+
displayName: 'Create Named Range',
|
|
11
|
+
description: 'Create a named range over a character range in a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a named range over a specified character range in a Google Docs document body and returns the new namedRangeId. Named ranges let you bookmark a region for later operations (e.g. deletion, styling) by ID or by name. The startIndex and endIndex must be valid character positions inside the document body — obtain them from Get Document End Index or Read Document (cannot be guessed). Not idempotent.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createNamedRangeActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to add a named range to (from the document URL or Search Documents).',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
name: Property.ShortText({
|
|
26
|
+
displayName: 'Range Name',
|
|
27
|
+
description: 'A human-readable name for the range. Multiple named ranges in the same document can share the same name.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
startIndex: Property.Number({
|
|
31
|
+
displayName: 'Start Index',
|
|
32
|
+
description:
|
|
33
|
+
'Inclusive start character index of the range. Obtain from Get Document End Index or Read Document — cannot be guessed.',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
endIndex: Property.Number({
|
|
37
|
+
displayName: 'End Index',
|
|
38
|
+
description:
|
|
39
|
+
'Exclusive end character index of the range. Must be greater than Start Index. Obtain from Get Document End Index or Read Document — cannot be guessed.',
|
|
40
|
+
required: true,
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
async run(context) {
|
|
44
|
+
const { documentId, name, startIndex, endIndex } = context.propsValue;
|
|
45
|
+
if (endIndex <= startIndex) {
|
|
46
|
+
throw new Error('End Index must be greater than Start Index.');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const authClient = await createGoogleClient(context.auth);
|
|
50
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
51
|
+
|
|
52
|
+
const request: docs_v1.Schema$Request = {
|
|
53
|
+
createNamedRange: {
|
|
54
|
+
name,
|
|
55
|
+
range: { startIndex, endIndex },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const response = await docs.documents.batchUpdate({
|
|
61
|
+
documentId,
|
|
62
|
+
requestBody: { requests: [request] },
|
|
63
|
+
});
|
|
64
|
+
const namedRangeId = response.data.replies?.[0]?.createNamedRange?.namedRangeId ?? null;
|
|
65
|
+
return { success: true, documentId, name, namedRangeId };
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(docsCommon.formatError(error, 'create the named range in'));
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { createParagraphBulletsActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const createParagraphBullets = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'create_paragraph_bullets',
|
|
10
|
+
displayName: 'Create Paragraph Bullets',
|
|
11
|
+
description: 'Apply a bullet list preset to paragraphs in a character range in a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Applies a bullet list style (e.g. BULLET_DISC_CIRCLE_SQUARE) to all paragraphs within a character range in a Google Docs document. Use this to convert existing paragraphs into a bulleted or numbered list. The startIndex and endIndex must span the paragraphs to bullet — obtain valid indices from Get Document End Index or Read Document (cannot be guessed). Not idempotent (re-running with a different preset changes the glyph style).',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: createParagraphBulletsActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to apply bullets to (from the document URL or Search Documents).',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
startIndex: Property.Number({
|
|
26
|
+
displayName: 'Start Index',
|
|
27
|
+
description:
|
|
28
|
+
'Inclusive start character index of the range of paragraphs to bullet. Obtain from Get Document End Index or Read Document — cannot be guessed.',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
endIndex: Property.Number({
|
|
32
|
+
displayName: 'End Index',
|
|
33
|
+
description:
|
|
34
|
+
'Exclusive end character index of the range of paragraphs to bullet. Must be greater than Start Index. Obtain from Get Document End Index or Read Document — cannot be guessed.',
|
|
35
|
+
required: true,
|
|
36
|
+
}),
|
|
37
|
+
bulletPreset: Property.StaticDropdown({
|
|
38
|
+
displayName: 'Bullet Preset',
|
|
39
|
+
description: 'The bullet list glyph preset to apply to the paragraphs.',
|
|
40
|
+
required: false,
|
|
41
|
+
defaultValue: 'BULLET_DISC_CIRCLE_SQUARE',
|
|
42
|
+
options: {
|
|
43
|
+
options: [
|
|
44
|
+
{ label: 'Disc / Circle / Square (default)', value: 'BULLET_DISC_CIRCLE_SQUARE' },
|
|
45
|
+
{ label: 'Diamond / Circle / Square', value: 'BULLET_DIAMONDX_ARROW3D_SQUARE' },
|
|
46
|
+
{ label: 'Checkbox', value: 'BULLET_CHECKBOX' },
|
|
47
|
+
{ label: 'Arrow / Diamond / Disc', value: 'BULLET_ARROW_DIAMOND_DISC' },
|
|
48
|
+
{ label: 'Star / Circle / Square', value: 'BULLET_STAR_CIRCLE_SQUARE' },
|
|
49
|
+
{ label: 'Arrow3D / Circle / Square', value: 'BULLET_ARROW3D_CIRCLE_SQUARE' },
|
|
50
|
+
{ label: 'Left Triangle / Diamond / Disc', value: 'BULLET_LEFTTRIANGLE_DIAMOND_DISC' },
|
|
51
|
+
{ label: 'Diamond / Circle / Disc', value: 'BULLET_DIAMONDX_HOLLOWDIAMOND_SQUARE' },
|
|
52
|
+
{ label: 'Diamond / Diamond / Square', value: 'BULLET_DIAMOND_DISC_CIRCLE' },
|
|
53
|
+
{ label: 'Numbered: Decimal / Alpha Lower / Roman Lower', value: 'NUMBERED_DECIMAL_ALPHA_ROMAN' },
|
|
54
|
+
{ label: 'Numbered: Decimal / Alpha Lower / Roman Lower (parenthesis)', value: 'NUMBERED_DECIMAL_ALPHA_ROMAN_PARENS' },
|
|
55
|
+
{ label: 'Numbered: Decimal nested', value: 'NUMBERED_DECIMAL_NESTED' },
|
|
56
|
+
{ label: 'Numbered: Upper Alpha / Alpha Lower / Roman Lower', value: 'NUMBERED_UPPERALPHA_ALPHA_ROMAN' },
|
|
57
|
+
{ label: 'Numbered: Upper Roman / Roman Lower / Alpha Lower', value: 'NUMBERED_UPPERROMAN_UPPERALPHA_DECIMAL' },
|
|
58
|
+
{ label: 'Numbered: Zero Decimal / Alpha Lower / Roman Lower', value: 'NUMBERED_ZERODECIMAL_ALPHA_ROMAN' },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
async run(context) {
|
|
64
|
+
const { documentId, startIndex, endIndex, bulletPreset } = context.propsValue;
|
|
65
|
+
if (endIndex <= startIndex) {
|
|
66
|
+
throw new Error('End Index must be greater than Start Index.');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const authClient = await createGoogleClient(context.auth);
|
|
70
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
71
|
+
|
|
72
|
+
const request: docs_v1.Schema$Request = {
|
|
73
|
+
createParagraphBullets: {
|
|
74
|
+
range: { startIndex, endIndex },
|
|
75
|
+
bulletPreset: (bulletPreset ?? 'BULLET_DISC_CIRCLE_SQUARE') as docs_v1.Schema$CreateParagraphBulletsRequest['bulletPreset'],
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
await docs.documents.batchUpdate({
|
|
81
|
+
documentId,
|
|
82
|
+
requestBody: { requests: [request] },
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
documentId,
|
|
87
|
+
startIndex,
|
|
88
|
+
endIndex,
|
|
89
|
+
bulletPreset: bulletPreset ?? 'BULLET_DISC_CIRCLE_SQUARE',
|
|
90
|
+
};
|
|
91
|
+
} catch (error) {
|
|
92
|
+
throw new Error(docsCommon.formatError(error, 'create paragraph bullets in'));
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { googleDocsAuth, getAccessToken } from '../auth';
|
|
4
|
+
import { appendTextActionOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const createTextDocument = createAction({
|
|
7
|
+
auth: googleDocsAuth,
|
|
8
|
+
name: 'create_text_document',
|
|
9
|
+
displayName: 'Create Text Document',
|
|
10
|
+
description: 'Create a new Google Docs document with a title and plain text',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Creates a new Google Docs document with the given title and writes the provided plain text into it, returning the new document metadata (including its ID). Use when an agent has plain text to put in a fresh document; for Markdown-formatted content use Create Document from Markdown instead. Not idempotent: each call creates a separate new document.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: appendTextActionOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
title: Property.ShortText({
|
|
20
|
+
displayName: 'Title',
|
|
21
|
+
description: 'The title (and file name) of the new document.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
body: Property.LongText({
|
|
25
|
+
displayName: 'Content',
|
|
26
|
+
description: 'The plain text to write into the new document.',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
async run(context) {
|
|
31
|
+
const accessToken = await getAccessToken(context.auth);
|
|
32
|
+
const document = await docsCommon.createDocument(context.propsValue.title, accessToken);
|
|
33
|
+
return await docsCommon.writeToDocument(document.documentId, context.propsValue.body, accessToken);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { googleDocsAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { docsCommon } from '../common';
|
|
3
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
4
|
+
import { docs as googleDocs, docs_v1 } from '@googleapis/docs';
|
|
5
|
+
import { deleteContentRangeActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const deleteContentRange = createAction({
|
|
8
|
+
auth: googleDocsAuth,
|
|
9
|
+
name: 'delete_content_range',
|
|
10
|
+
displayName: 'Delete Content Range',
|
|
11
|
+
description: 'Delete a range of content from a Google Docs document',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Deletes all content between a start and end character index in a Google Docs document body. Obtain valid indices from Get Document End Index / Read Document first — indices cannot be guessed. Note that every Google Docs segment ends in a newline that cannot be deleted, so the end index must not exceed the body end index minus one. Destructive and not idempotent.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: deleteContentRangeActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
documentId: Property.ShortText({
|
|
21
|
+
displayName: 'Document ID',
|
|
22
|
+
description: 'The ID of the document to edit.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
startIndex: Property.Number({
|
|
26
|
+
displayName: 'Start Index',
|
|
27
|
+
description: 'Inclusive start character index. Obtain from Get Document End Index / Read Document.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
endIndex: Property.Number({
|
|
31
|
+
displayName: 'End Index',
|
|
32
|
+
description: 'Exclusive end character index. Must be greater than Start Index and not exceed the body end index.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
async run(context) {
|
|
37
|
+
const { documentId, startIndex, endIndex } = context.propsValue;
|
|
38
|
+
if (endIndex <= startIndex) {
|
|
39
|
+
throw new Error('End Index must be greater than Start Index.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const authClient = await createGoogleClient(context.auth);
|
|
43
|
+
const docs = googleDocs({ version: 'v1', auth: authClient });
|
|
44
|
+
|
|
45
|
+
const request: docs_v1.Schema$Request = {
|
|
46
|
+
deleteContentRange: { range: { startIndex, endIndex } },
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await docs.documents.batchUpdate({
|
|
51
|
+
documentId,
|
|
52
|
+
requestBody: { requests: [request] },
|
|
53
|
+
});
|
|
54
|
+
return { success: true, documentId, deletedFrom: startIndex, deletedTo: endIndex };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new Error(docsCommon.formatError(error, 'delete content from'));
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|