Skip to content
Open
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
113 changes: 113 additions & 0 deletions components/rendex/actions/create-artifact/create-artifact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import rendex from "../../rendex.app.mjs";

export default {
key: "rendex-create-artifact",
name: "Create Artifact",
description: "Turn Markdown or HTML plus a small branding theme into a branded PDF + PNG and a hosted share page in one call. Returns `pdfUrl`, `pngUrl`, `shareUrl`, and `expiresAt`. [See the documentation](https://rendex.dev/docs/api-reference).",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
rendex,
content: {
type: "string",
label: "Content",
description: "The Markdown or HTML body to render into a branded artifact.",
},
inputFormat: {
type: "string",
label: "Input Format",
description: "How to interpret `content`: `markdown` is converted to styled HTML; `html` is used as a body fragment.",
optional: true,
default: "markdown",
options: [
"markdown",
"html",
],
},
formats: {
type: "string[]",
label: "Formats",
description: "Which artifact formats to produce. Each format charges 1 credit. Defaults to both.",
optional: true,
default: [
"pdf",
"png",
],
options: [
"pdf",
"png",
],
},
brandName: {
type: "string",
label: "Brand Name",
description: "Plain-text header line shown beside the logo (maps to `branding.header`).",
optional: true,
},
title: {
type: "string",
label: "Title",
description: "Title for the hosted share page. Falls back to **Brand Name** when set; both populate `branding.header` (the API's single header field).",
optional: true,
},
accentColor: {
type: "string",
label: "Accent Color",
description: "CSS color for the accent bar, links, and headings (e.g. `#EA580C`, `rebeccapurple`).",
optional: true,
},
logoUrl: {
type: "string",
label: "Logo URL",
description: "Absolute http(s) URL of a logo image shown in the artifact header.",
optional: true,
},
footer: {
type: "string",
label: "Footer",
description: "Plain-text footer line shown at the bottom of every page.",
optional: true,
},
expiresIn: {
propDefinition: [
rendex,
"expiresIn",
],
},
},
async run({ $ }) {
// The API nests branding in a `branding` object (logo/accentColor/header/footer),
// not flat top-level fields — assemble it from the flat props and omit it when
// empty. The API exposes a single header line, so brandName wins over title.
const branding = {
logo: this.logoUrl,
accentColor: this.accentColor,
header: this.brandName || this.title,
footer: this.footer,
};
const hasBranding = Object.values(branding).some((value) =>
value !== undefined && value !== "");

const response = await this.rendex.createArtifact({
$,
data: {
content: this.content,
inputFormat: this.inputFormat,
formats: this.formats,
branding: hasBranding
? branding
: undefined,
expiresIn: this.expiresIn,
},
});

const data = response.data;
$.export("$summary", `Created artifact (share ${data?.shareUrl})`);
return data;
},
};
260 changes: 260 additions & 0 deletions components/rendex/actions/create-render-link/create-render-link.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
import { ConfigurationError } from "@pipedream/platform";
import rendex from "../../rendex.app.mjs";

export default {
key: "rendex-create-render-link",
name: "Create Render Link",
description: "Mint a signed, hosted render URL for a page or HTML — ideal for `og:image` tags. The returned URL serves the rendered image/PDF directly. [See the documentation](https://rendex.dev/docs/api-reference).",
version: "0.0.2",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
rendex,
url: {
type: "string",
label: "URL",
description: "The page URL to render. Provide either `url` or `html`.",
optional: true,
},
html: {
propDefinition: [
rendex,
"html",
],
},
format: {
propDefinition: [
rendex,
"format",
],
},
width: {
propDefinition: [
rendex,
"width",
],
},
height: {
propDefinition: [
rendex,
"height",
],
},
fullPage: {
propDefinition: [
rendex,
"fullPage",
],
},
quality: {
propDefinition: [
rendex,
"quality",
],
},
delay: {
propDefinition: [
rendex,
"delay",
],
},
darkMode: {
propDefinition: [
rendex,
"darkMode",
],
},
deviceScaleFactor: {
propDefinition: [
rendex,
"deviceScaleFactor",
],
},
device: {
propDefinition: [
rendex,
"device",
],
},
selector: {
propDefinition: [
rendex,
"selector",
],
},
hideSelectors: {
propDefinition: [
rendex,
"hideSelectors",
],
},
blockAds: {
propDefinition: [
rendex,
"blockAds",
],
},
blockCookieBanners: {
propDefinition: [
rendex,
"blockCookieBanners",
],
},
timeout: {
propDefinition: [
rendex,
"timeout",
],
},
waitUntil: {
propDefinition: [
rendex,
"waitUntil",
],
},
bestAttempt: {
propDefinition: [
rendex,
"bestAttempt",
],
},
css: {
propDefinition: [
rendex,
"css",
],
},
js: {
propDefinition: [
rendex,
"js",
],
},
userAgent: {
propDefinition: [
rendex,
"userAgent",
],
},
cookies: {
propDefinition: [
rendex,
"cookies",
],
},
headers: {
propDefinition: [
rendex,
"headers",
],
},
pdfFormat: {
propDefinition: [
rendex,
"pdfFormat",
],
},
pdfLandscape: {
propDefinition: [
rendex,
"pdfLandscape",
],
},
pdfPrintBackground: {
propDefinition: [
rendex,
"pdfPrintBackground",
],
},
pdfScale: {
propDefinition: [
rendex,
"pdfScale",
],
},
expiresIn: {
propDefinition: [
rendex,
"expiresIn",
],
},
},
async run({ $ }) {
const hasHtml = Boolean(this.html);
const hasUrl = Boolean(this.url);
if (hasHtml === hasUrl) {
throw new ConfigurationError("Provide exactly one of `html` or `url`.");
}

// `cookies` is a string[] of JSON objects (Pipedream has no array-of-object
// type); parse each into the object shape the API expects.
let cookies;
if (this.cookies?.length) {
try {
cookies = this.cookies.map((cookie) => {
const parsed = typeof cookie === "string"
? JSON.parse(cookie)
: cookie;
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
throw new Error("Invalid cookie shape");
}
return parsed;
});
} catch {
throw new ConfigurationError("Each cookie must be a JSON object, e.g. {\"name\":\"session\",\"value\":\"abc\"}.");
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

// undefined keys are dropped by JSON.stringify, so unset optional params are
// omitted from the request body.
const response = await this.rendex.createRenderLink({
$,
data: {
url: hasUrl
? this.url
: undefined,
html: hasHtml
? this.html
: undefined,
format: this.format,
width: this.width,
height: this.height,
fullPage: this.fullPage,
quality: this.quality,
delay: this.delay,
darkMode: this.darkMode,
deviceScaleFactor: this.deviceScaleFactor !== undefined
? Number(this.deviceScaleFactor)
: undefined,
device: this.device,
selector: this.selector,
hideSelectors: this.hideSelectors,
blockAds: this.blockAds,
blockCookieBanners: this.blockCookieBanners,
timeout: this.timeout,
waitUntil: this.waitUntil,
bestAttempt: this.bestAttempt,
css: this.css,
js: this.js,
userAgent: this.userAgent,
cookies,
headers: this.headers,
pdfFormat: this.pdfFormat,
pdfLandscape: this.pdfLandscape,
pdfPrintBackground: this.pdfPrintBackground,
pdfScale: this.pdfScale !== undefined
? Number(this.pdfScale)
: undefined,
expiresIn: this.expiresIn,
},
});

const data = response.data;
$.export("$summary", `Created render link (expires ${data?.expiresAt})`);
return data;
},
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading
Loading