Skip to content

Commit

Permalink
Merge branch 'master' into 13965-bug-linkedin-components-api-version-…
Browse files Browse the repository at this point in the history
…update
  • Loading branch information
luancazarine committed Sep 19, 2024
2 parents b9be91e + a407a12 commit 1b85293
Show file tree
Hide file tree
Showing 25 changed files with 519 additions and 154 deletions.
11 changes: 11 additions & 0 deletions components/dust/dust.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
type: "app",
app: "dust",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
},
},
};
15 changes: 15 additions & 0 deletions components/dust/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@pipedream/dust",
"version": "0.0.1",
"description": "Pipedream Dust Components",
"main": "dust.app.mjs",
"keywords": [
"pipedream",
"dust"
],
"homepage": "https://pipedream.com/apps/dust",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
}
}
27 changes: 27 additions & 0 deletions components/error/actions/throw-error/throw-error.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import error from "../../error.app.mjs";

export default {
name: "Throw Error",
version: "0.0.1",
key: "error-throw-error",
description: "Quickly throw an error from your workflow.",
props: {
error,
name: {
propDefinition: [
error,
"name",
],
},
errorMessage: {
propDefinition: [
error,
"errorMessage",
],
},
},
type: "action",
async run() {
this.error.maybeCreateAndThrowError(this.name, this.errorMessage);
},
};
41 changes: 41 additions & 0 deletions components/error/error.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export default {
type: "app",
app: "error",
propDefinitions: {
name: {
type: "string",
label: "Error Name",
description:
"The **name** (class) of error to throw, which you can define as any custom string. This will show up in all of the standard Pipedream error handling destinations.",
default: "Error",
},
errorMessage: {
type: "string",
label: "Error Message",
description:
"The error **message** to throw. This will show up in all of the standard Pipedream error handling destinations.",
optional: true,
},
},
methods: {
maybeCreateAndThrowError(name, message) {
const errorClass = global[name];

// Check if the error class exists and is a subclass of Error
if (
typeof errorClass === "function" &&
errorClass.prototype.isPrototypeOf.call(Error)
) {
throw new errorClass(message);
}

class DynamicError extends Error {
constructor(msg) {
super(msg);
this.name = name;
}
}
throw new DynamicError(message);
},
},
};
15 changes: 15 additions & 0 deletions components/error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@pipedream/error",
"version": "0.0.2",
"description": "Pipedream Error Components",
"main": "error.app.mjs",
"keywords": [
"pipedream",
"error"
],
"homepage": "https://pipedream.com/apps/error",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
}
}
16 changes: 7 additions & 9 deletions components/google_docs/actions/append-image/append-image.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-append-image",
name: "Append Image to Document",
description: "Appends an image to the end of a document. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertInlineImageRequest)",
version: "0.0.3",
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)",
version: "0.0.4",
type: "action",
props: {
googleDocs,
Expand All @@ -28,13 +28,11 @@ export default {
},
},
async run({ $ }) {
const image = {
await this.googleDocs.appendImage(this.docId, {
uri: this.imageUri,
};
const { data } = await this.googleDocs.appendImage(this.docId, image, this.appendAtBeginning);
$.export("$summary", "Successfully appended image to doc");
return {
documentId: data.documentId,
};
}, this.appendAtBeginning);
const doc = this.googleDocs.getDocument(this.docId);
$.export("$summary", `Successfully appended image to document with ID: ${this.docId}`);
return doc;
},
};
16 changes: 7 additions & 9 deletions components/google_docs/actions/append-text/append-text.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-append-text",
name: "Append Text",
description: "Append text to an existing document. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertTextRequest)",
version: "0.1.2",
description: "Append text to an existing document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertTextRequest)",
version: "0.1.3",
type: "action",
props: {
googleDocs,
Expand All @@ -28,13 +28,11 @@ export default {
},
},
async run({ $ }) {
const text = {
await this.googleDocs.insertText(this.docId, {
text: this.text,
};
await this.googleDocs.insertText(this.docId, text, this.appendAtBeginning);
$.export("$summary", "Successfully appended text to doc");
return {
documentId: this.docId,
};
}, this.appendAtBeginning);
const doc = this.googleDocs.getDocument(this.docId);
$.export("$summary", `Successfully appended text to document with ID: ${this.docId}`);
return doc;
},
};

This file was deleted.

55 changes: 49 additions & 6 deletions components/google_docs/actions/create-document/create-document.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,59 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-create-document",
name: "Create a New Document",
description: "Create a new, empty document. To add content after creating the document, pass the document ID exported by this step to the Append Text action. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/create)",
version: "0.1.2",
description: "Create a new document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/create)",
version: "0.1.3",
type: "action",
props: {
googleDocs,
title: "string",
title: {
type: "string",
label: "Title",
description: "Title of the new document",
},
text: {
propDefinition: [
googleDocs,
"text",
],
optional: true,
},
folderId: {
propDefinition: [
googleDocs,
"folderId",
],
optional: true,
},
},
async run({ $ }) {
const createdDoc = await this.googleDocs.createEmptyDoc(this.title);
$.export("$summary", "Successfully created doc");
return createdDoc;
// Create Doc
const { documentId } = await this.googleDocs.createEmptyDoc(this.title);

// Insert text
if (this.text) {
await this.googleDocs.insertText(documentId, {
text: this.text,
});
}

// Move file
if (this.folderId) {
// Get file to get parents to remove
const file = await this.googleDocs.getFile(documentId);

// Move file, removing old parents, adding new parent folder
await this.googleDocs.updateFile(documentId, {
fields: "*",
removeParents: file.parents.join(","),
addParents: this.folderId,
});
}

// Get updated doc resource to return
const doc = await this.googleDocs.getDocument(documentId);

$.export("$summary", `Successfully created document with ID: ${documentId}`);
return doc;
},
};
10 changes: 6 additions & 4 deletions components/google_docs/actions/get-document/get-document.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-get-document",
name: "Get Document",
description: "Get the contents of the latest version of a document. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/get)",
version: "0.1.1",
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)",
version: "0.1.2",
type: "action",
props: {
googleDocs,
Expand All @@ -15,7 +15,9 @@ export default {
],
},
},
async run() {
return this.googleDocs.getDocument(this.docId);
async run({ $ }) {
const response = await this.googleDocs.getDocument(this.docId);
$.export("$summary", `Successfully retrieved document with ID: ${this.docId}`);
return response;
},
};
11 changes: 5 additions & 6 deletions components/google_docs/actions/replace-image/replace-image.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-replace-image",
name: "Replace Image",
description: "Replace image in a existing document. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/request#ReplaceImageRequest)",
version: "0.0.3",
description: "Replace image in a existing document. [See the documentation](https://developers.google.com/docs/api/reference/rest/v1/documents/request#ReplaceImageRequest)",
version: "0.0.4",
type: "action",
props: {
googleDocs,
Expand Down Expand Up @@ -37,9 +37,8 @@ export default {
uri: this.imageUri,
};
await this.googleDocs.replaceImage(this.docId, image);
$.export("$summary", "Successfully replaced image in doc");
return {
documentId: this.docId,
};
const doc = this.googleDocs.getDocument(this.docId);
$.export("$summary", `Successfully replaced image in doc with ID: ${this.docId}`);
return doc;
},
};
11 changes: 5 additions & 6 deletions components/google_docs/actions/replace-text/replace-text.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDocs from "../../google_docs.app.mjs";
export default {
key: "google_docs-replace-text",
name: "Replace Text",
description: "Replace all instances of matched text in a existing document. [See the docs](https://developers.google.com/docs/api/reference/rest/v1/documents/request#ReplaceAllTextRequest)",
version: "0.0.3",
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)",
version: "0.0.4",
type: "action",
props: {
googleDocs,
Expand Down Expand Up @@ -45,9 +45,8 @@ export default {
},
};
await this.googleDocs.replaceText(this.docId, text);
$.export("$summary", "Successfully replaced text in doc");
return {
documentId: this.docId,
};
const doc = this.googleDocs.getDocument(this.docId);
$.export("$summary", `Successfully replaced text in doc with ID: ${this.docId}`);
return doc;
},
};
14 changes: 9 additions & 5 deletions components/google_docs/google_docs.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export default {
docId: {
type: "string",
label: "Document",
description: "Select a document or enter a custom expression to pass a value from a previous step (e.g., `{{steps.foo.$return_value.documentId}}`) or to manually enter a static ID (e.g., `1KuEN7k8jVP3Qi0_svM5OO8oEuiLkq0csihobF67eat8`).",
description: "Search for and select a document. You can also use a custom expression to pass a value from a previous step (e.g., `{{steps.foo.$return_value.documentId}}`) or you can enter a static ID (e.g., `1KuEN7k8jVP3Qi0_svM5OO8oEuiLkq0csihobF67eat8`).",
useQuery: true,
async options({
prevContext, driveId,
prevContext, driveId, query,
}) {
const { nextPageToken } = prevContext;
return this.listDocsOptions(driveId, nextPageToken);
return this.listDocsOptions(driveId, query, nextPageToken);
},
},
imageId: {
Expand Down Expand Up @@ -128,8 +129,11 @@ export default {
async replaceImage(documentId, image) {
return this._batchUpdate(documentId, "replaceImage", image);
},
async listDocsOptions(driveId, pageToken = null) {
const q = "mimeType='application/vnd.google-apps.document'";
async listDocsOptions(driveId, query, pageToken = null) {
let q = "mimeType='application/vnd.google-apps.document'";
if (query) {
q = `${q} and name contains '${query}'`;
}
let request = {
q,
};
Expand Down
4 changes: 2 additions & 2 deletions components/google_docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/google_docs",
"version": "0.3.6",
"version": "0.4.0",
"description": "Pipedream Google_docs Components",
"main": "google_docs.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@googleapis/docs": "^0.2.0"
"@googleapis/docs": "^3.3.0"
}
}
Loading

0 comments on commit 1b85293

Please sign in to comment.