Skip to content

Commit 1e87d88

Browse files
authored
Merge branch 'master' into je/connect-proxy-support
2 parents 3ec43b5 + d57c8f6 commit 1e87d88

File tree

33 files changed

+1360
-63
lines changed

33 files changed

+1360
-63
lines changed

components/google_docs/actions/append-image/append-image.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-append-image",
55
name: "Append Image to Document",
66
description: "Appends an image to the end of a document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertInlineImageRequest)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
googleDocs,

components/google_docs/actions/append-text/append-text.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-append-text",
55
name: "Append Text",
66
description: "Append text to an existing document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertTextRequest)",
7-
version: "0.1.4",
7+
version: "0.1.5",
88
type: "action",
99
props: {
1010
googleDocs,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import app from "../../google_docs.app.mjs";
2+
import common from "@pipedream/google_drive/actions/create-file-from-template/create-file-from-template.mjs";
3+
4+
import utils from "../../common/utils.mjs";
5+
6+
const {
7+
// eslint-disable-next-line no-unused-vars
8+
name, description, type, ...others
9+
} = common;
10+
const props = utils.adjustPropDefinitions(others.props, app);
11+
12+
export default {
13+
...others,
14+
key: "google_docs-create-document-from-template",
15+
name: "Create New Document From Template",
16+
version: "0.0.1",
17+
description,
18+
type,
19+
props: {
20+
googleDrive: app,
21+
...props,
22+
templateId: {
23+
propDefinition: [
24+
app,
25+
"docId",
26+
],
27+
label: "Template",
28+
description:
29+
"Select the template document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step. Template documents should contain placeholders in the format `{{xyz}}`.",
30+
},
31+
},
32+
};

components/google_docs/actions/create-document/create-document.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-create-document",
55
name: "Create a New Document",
66
description: "Create a new document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/create)",
7-
version: "0.1.4",
7+
version: "0.1.5",
88
type: "action",
99
props: {
1010
googleDocs,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import app from "../../google_docs.app.mjs";
2+
import common from "@pipedream/google_drive/actions/find-file/find-file.mjs";
3+
import { getListFilesOpts } from "@pipedream/google_drive/common/utils.mjs";
4+
5+
import utils from "../../common/utils.mjs";
6+
7+
const {
8+
// eslint-disable-next-line no-unused-vars
9+
name, description, type, ...others
10+
} = common;
11+
const props = utils.adjustPropDefinitions(others.props, app);
12+
13+
export default {
14+
...others,
15+
key: "google_docs-find-document",
16+
name: "Find Document",
17+
version: "0.0.1",
18+
description,
19+
type,
20+
props: {
21+
googleDrive: app,
22+
...props,
23+
},
24+
async run({ $ }) {
25+
const q = this.getQuery();
26+
const opts = getListFilesOpts(this.drive, {
27+
q,
28+
});
29+
const files = (await this.googleDrive.listFilesInPage(null, opts)).files?.filter(({ mimeType }) => mimeType === "application/vnd.google-apps.document") || [];
30+
31+
$.export("$summary", `Successfully found ${files.length} file${files.length === 1
32+
? ""
33+
: "s"} with the query "${q}"`);
34+
return files;
35+
},
36+
};

components/google_docs/actions/get-document/get-document.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-get-document",
55
name: "Get Document",
66
description: "Get the contents of the latest version of a document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/get)",
7-
version: "0.1.3",
7+
version: "0.1.4",
88
type: "action",
99
props: {
1010
googleDocs,
@@ -17,7 +17,9 @@ export default {
1717
},
1818
async run({ $ }) {
1919
const response = await this.googleDocs.getDocument(this.docId);
20+
2021
$.export("$summary", `Successfully retrieved document with ID: ${this.docId}`);
22+
2123
return response;
2224
},
2325
};

components/google_docs/actions/replace-image/replace-image.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-replace-image",
55
name: "Replace Image",
66
description: "Replace image in a existing document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#ReplaceImageRequest)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
googleDocs,

components/google_docs/actions/replace-text/replace-text.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_docs-replace-text",
55
name: "Replace Text",
66
description: "Replace all instances of matched text in an existing document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#ReplaceAllTextRequest)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
googleDocs,
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function getTextContentFromDocument(content) {
2+
let textContent = "";
3+
content.forEach((element) => {
4+
if (element.paragraph) {
5+
element.paragraph.elements.forEach((textRun) => {
6+
if (textRun.textRun) {
7+
textContent += textRun.textRun.content;
8+
}
9+
});
10+
}
11+
});
12+
return textContent;
13+
}
14+
15+
function addTextContentToDocument(response) {
16+
const textContent = getTextContentFromDocument(response.body.content);
17+
return {
18+
textContent,
19+
...response,
20+
};
21+
}
22+
23+
function adjustPropDefinitions(props, app) {
24+
return Object.fromEntries(
25+
Object.entries(props).map(([
26+
key,
27+
prop,
28+
]) => {
29+
if (typeof prop === "string") return [
30+
key,
31+
prop,
32+
];
33+
const {
34+
propDefinition, ...otherValues
35+
} = prop;
36+
if (propDefinition) {
37+
const [
38+
, ...otherDefs
39+
] = propDefinition;
40+
return [
41+
key,
42+
{
43+
propDefinition: [
44+
app,
45+
...otherDefs,
46+
],
47+
...otherValues,
48+
},
49+
];
50+
}
51+
return [
52+
key,
53+
otherValues.type === "app"
54+
? null
55+
: otherValues,
56+
];
57+
})
58+
.filter(([
59+
, value,
60+
]) => value),
61+
);
62+
}
63+
64+
export default {
65+
getTextContentFromDocument,
66+
addTextContentToDocument,
67+
adjustPropDefinitions,
68+
};

components/google_docs/google_docs.app.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import docs from "@googleapis/docs";
22
import googleDrive from "@pipedream/google_drive";
3+
import utils from "./common/utils.mjs";
34

45
export default {
56
type: "app",
@@ -36,7 +37,7 @@ export default {
3637
imageUri: {
3738
type: "string",
3839
label: "Image URL",
39-
description: "The URL of the image you want to insert to the doc",
40+
description: "The URL of the image you want to insert into the doc",
4041
},
4142
text: {
4243
type: "string",
@@ -105,7 +106,8 @@ export default {
105106
const { data } = await this.docs().documents.get({
106107
documentId,
107108
});
108-
return data;
109+
const doc = utils.addTextContentToDocument(data);
110+
return doc;
109111
},
110112
async createEmptyDoc(title) {
111113
const { data: createdDoc } = await this.docs().documents.create({

0 commit comments

Comments
 (0)