Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "customjs-convert-html-to-pdf",
name: "Convert HTML to PDF",
description: "Converts an HTML string to a PDF document. [See the documentation](https://www.customjs.space/api/docs#_1-html-to-pdf)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
customjs,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import customjs from "../../customjs.app.mjs";
import fs from "fs";
import { normalizeFilepath } from "../common/utils.mjs";

export default {
key: "customjs-convert-html-to-png",
name: "Convert HTML to PNG",
description: "Converts an HTML string to a PNG image. [See the documentation](https://www.customjs.space/api/docs#_4-html-to-png)",
version: "0.0.1",
type: "action",
props: {
customjs,
html: {
type: "string",
label: "HTML",
description: "The HTML string to be converted to a PNG",
},
filename: {
propDefinition: [
customjs,
"filename",
],
},
},
async run({ $ }) {
const fileContent = await this.customjs.convertHtmlToPng({
$,
data: {
input: this.html,
code: "const { HTML2PNG } = require('./utils'); return HTML2PNG(input);",
returnBinary: "true",
},
});

const filepath = normalizeFilepath(this.filename, "png");
fs.writeFileSync(filepath, Buffer.from(fileContent));

$.export("$summary", "Successfully converted HTML to PNG");
return {
filename: this.filename,
filepath,
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "customjs-create-screenshot",
name: "Create Screenshot",
description: "Create a screenshot of a website. [See the documentation](https://www.customjs.space/api/docs#_3-create-screenshot)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
customjs,
Expand All @@ -20,6 +20,7 @@ export default {
customjs,
"filename",
],
description: "Download the PNG file to the `/tmp` directory with the specified filename.",
},
},
async run({ $ }) {
Expand Down
2 changes: 1 addition & 1 deletion components/customjs/actions/merge-pdfs/merge-pdfs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "customjs-merge-pdfs",
name: "Merge PDFs",
description: "Merges multiple PDF documents into one. [See the documentation](https://www.customjs.space/api/docs#_2-merge-pdfs)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
customjs,
Expand Down
45 changes: 45 additions & 0 deletions components/customjs/actions/run-puppeteer/run-puppeteer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import customjs from "../../customjs.app.mjs";
import fs from "fs";
import { normalizeFilepath } from "../common/utils.mjs";

export default {
key: "customjs-run-puppeteer",
name: "Run Puppeteer",
description: "Run Puppeteer. [See the documentation](https://www.customjs.space/api/docs#_5-run-puppeteer)",
version: "0.0.1",
type: "action",
props: {
customjs,
code: {
type: "string",
label: "Code",
description: "Enter the code you want to run on puppeteer. For example: `await page.goto(\"https://example.com\");` will return a screenshot of https://example.com.",
},
filename: {
propDefinition: [
customjs,
"filename",
],
description: "Download the PNG file to the `/tmp` directory with the specified filename.",
},
},
async run({ $ }) {
const fileContent = await this.customjs.runPuppeteer({
$,
data: {
input: this.code,
code: "const { PUPPETEER } = require('./utils'); return PUPPETEER(input);",
returnBinary: "true",
},
});

const filepath = normalizeFilepath(this.filename, "png");
fs.writeFileSync(filepath, Buffer.from(fileContent));

$.export("$summary", "Successfully ran the puppeteer code.");
return {
filename: this.filename,
filepath,
};
},
};
22 changes: 19 additions & 3 deletions components/customjs/customjs.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,39 @@ export default {
convertHtmlToPdf(opts = {}) {
return this._makeRequest({
headers: {
"customjs-origin": "zapier/generatePDF",
"customjs-origin": "pipedream/generatePDF",
},
...opts,
});
},
convertHtmlToPng(opts = {}) {
return this._makeRequest({
headers: {
"customjs-origin": "pipedream/generatePNG",
},
...opts,
});
},
createScreenshot(opts = {}) {
return this._makeRequest({
headers: {
"customjs-origin": "zapier/screenshot",
"customjs-origin": "pipedream/screenshot",
},
...opts,
});
},
mergePdfs(opts = {}) {
return this._makeRequest({
headers: {
"customjs-origin": "zapier/mergePDFs",
"customjs-origin": "pipedream/mergePDFs",
},
...opts,
});
},
runPuppeteer(opts = {}) {
return this._makeRequest({
headers: {
"customjs-origin": "pipedream/puppeteer",
},
...opts,
});
Expand Down
2 changes: 1 addition & 1 deletion components/customjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/customjs",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream CustomJS Components",
"main": "customjs.app.mjs",
"keywords": [
Expand Down