-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Rendex: add Markdown rendering, content extraction, render links, and Watch suite #21270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dan425953
wants to merge
4
commits into
PipedreamHQ:master
Choose a base branch
from
Dan425953:feat/rendex-watch-markdown-extract
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5555d15
feat(rendex): add Markdown rendering, content extraction, hosted rend…
Dan425953 2b6bc2d
fix(rendex): add action annotations, bump render-to-image, paginate w…
Dan425953 cd5bd4e
feat(rendex): expand capture params, watch render knobs, and add acco…
Dan425953 df82ab6
fix(rendex): address review — validate cookie objects, preserve clear…
Dan425953 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
components/rendex/actions/create-artifact/create-artifact.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
255 changes: 255 additions & 0 deletions
255
components/rendex/actions/create-render-link/create-render-link.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,255 @@ | ||
| 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) => | ||
| typeof cookie === "string" | ||
| ? JSON.parse(cookie) | ||
| : cookie); | ||
| } catch { | ||
| throw new ConfigurationError("Each cookie must be a JSON object, e.g. {\"name\":\"session\",\"value\":\"abc\"}."); | ||
| } | ||
| } | ||
|
|
||
| // 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; | ||
| }, | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.