Skip to content

Commit 68ee470

Browse files
committed
updates
1 parent 7dd5427 commit 68ee470

File tree

12 files changed

+54
-24
lines changed

12 files changed

+54
-24
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,

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,

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
export default {
24+
getTextContentFromDocument,
25+
addTextContentToDocument,
26+
};

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({

components/google_docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_docs",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Pipedream Google_docs Components",
55
"main": "google_docs.app.mjs",
66
"keywords": [
@@ -14,6 +14,6 @@
1414
},
1515
"dependencies": {
1616
"@googleapis/docs": "^3.3.0",
17-
"@pipedream/google_drive": "^0.6.19"
17+
"@pipedream/google_drive": "^0.8.8"
1818
}
1919
}

components/google_docs/sources/common/base.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import newFilesInstant from "@pipedream/google_drive/sources/new-files-instant/new-files-instant.mjs";
2-
import googleDrive from "../../google_docs.app.mjs";
3-
import { MY_DRIVE_VALUE } from "../../../google_drive/common/constants.mjs";
2+
import app from "../../google_docs.app.mjs";
3+
import { MY_DRIVE_VALUE } from "@pipedream/google_drive/common/constants.mjs";
44

55
export default {
66
...newFilesInstant,
77
props: {
8-
googleDrive,
8+
app,
99
db: "$.service.db",
1010
http: "$.interface.http",
1111
timer: newFilesInstant.props.timer,
1212
folders: {
1313
propDefinition: [
14-
googleDrive,
14+
app,
1515
"folderId",
1616
],
1717
type: "string[]",
@@ -30,7 +30,7 @@ export default {
3030
methods: {
3131
...newFilesInstant.methods,
3232
getDriveId() {
33-
return googleDrive.methods.getDriveId(MY_DRIVE_VALUE);
33+
return app.methods.getDriveId(MY_DRIVE_VALUE);
3434
},
3535
shouldProcess(file) {
3636
return (
@@ -48,7 +48,7 @@ export default {
4848
async getDocumentsFromFiles(files, limit) {
4949
return files.reduce(async (acc, file) => {
5050
const docs = await acc;
51-
const fileInfo = await this.googleDrive.getFile(file.id);
51+
const fileInfo = await this.app.getFile(file.id);
5252
return docs.length >= limit
5353
? docs
5454
: docs.concat(fileInfo);
@@ -59,13 +59,13 @@ export default {
5959

6060
if (!foldersIds?.length) {
6161
const opts = this.getDocumentsFromFolderOpts("root");
62-
const { files } = await this.googleDrive.listFilesInPage(null, opts);
62+
const { files } = await this.app.listFilesInPage(null, opts);
6363
return this.getDocumentsFromFiles(files, limit);
6464
}
6565

6666
return foldersIds.reduce(async (docs, folderId) => {
6767
const opts = this.getDocumentsFromFolderOpts(folderId);
68-
const { files } = await this.googleDrive.listFilesInPage(null, opts);
68+
const { files } = await this.app.listFilesInPage(null, opts);
6969
const nextDocuments = await this.getDocumentsFromFiles(files, limit);
7070
return (await docs).concat(nextDocuments);
7171
}, []);
@@ -75,7 +75,7 @@ export default {
7575
if (!this.shouldProcess(file)) {
7676
continue;
7777
}
78-
const doc = await this.googleDrive.getDocument(file.id);
78+
const doc = await this.app.getDocument(file.id);
7979
this.$emit(doc, this.generateMeta(doc));
8080
}
8181
},

0 commit comments

Comments
 (0)