UNPKG

n8n-nodes-orshottemplates

Version:

Orshot Templates – an n8n community node that turns text/URLs into on-brand images via the Orshot API.

726 lines 40.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrshotTemplates = void 0; function buildFixedCollection(templateId, displayName, values) { return { displayName, name: `${templateId}Params`, type: 'fixedCollection', default: {}, displayOptions: { show: { template: [templateId] } }, typeOptions: { multipleValues: false, }, options: [ { displayName: 'Fields', name: 'fields', values, }, ], }; } const tweetValues = [ { displayName: 'Canvas Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Canvas Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Hide Date/Time', name: 'hideDateTime', type: 'boolean', default: false }, { displayName: 'Hide Media', name: 'hideMedia', type: 'boolean', default: false }, { displayName: 'Hide Metrics', name: 'hideMetrics', type: 'boolean', default: false }, { displayName: 'Hide Quote Tweet', name: 'hideQuoteTweet', type: 'boolean', default: false }, { displayName: 'Hide Shadow', name: 'hideShadow', type: 'boolean', default: false }, { displayName: 'Hide Verified Icon', name: 'hideVerifiedIcon', type: 'boolean', default: false }, { displayName: 'Padding (Px)', name: 'padding', type: 'number', default: 0 }, { displayName: 'Tweet Background Color', name: 'tweetBackgroundColor', type: 'color', default: '' }, { displayName: 'Tweet Font Size (Rem)', name: 'tweetFontSize', type: 'number', default: 0 }, { displayName: 'Tweet ID', name: 'tweetId', type: 'string', default: '' }, { displayName: 'Tweet Text Color', name: 'tweetTextColor', type: 'color', default: '' }, { displayName: 'Tweet URL', name: 'tweetUrl', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ]; class OrshotTemplates { constructor() { this.description = { displayName: 'Orshot Templates', name: 'orshotTemplates', icon: 'file:OrshotLogo.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["template"]}}', description: 'Generate images with the Orshot API (v1)', defaults: { name: 'Orshot Templates' }, inputs: ["main"], outputs: ["main"], credentials: [{ name: 'orshotTemplatesApi', required: true }], requestDefaults: { baseURL: 'https://api.orshot.com/v1/generate/images', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, }, properties: [ { displayName: 'Template', name: 'template', type: 'options', default: 'tweet-image', noDataExpression: true, options: [ { name: 'Tweet Screenshot', value: 'tweet-image' }, { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Canvas Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Canvas Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Hide Date/Time', name: 'hideDateTime', type: 'boolean', default: false }, { displayName: 'Hide Media', name: 'hideMedia', type: 'boolean', default: false }, { displayName: 'Hide Metrics', name: 'hideMetrics', type: 'boolean', default: false }, { displayName: 'Hide Quote Tweet', name: 'hideQuoteTweet', type: 'boolean', default: false }, { displayName: 'Hide Shadow', name: 'hideShadow', type: 'boolean', default: false }, { displayName: 'Hide Verified Icon', name: 'hideVerifiedIcon', type: 'boolean', default: false }, { displayName: 'Padding (Px)', name: 'padding', type: 'number', default: 0 }, { displayName: 'Tweet Background Color', name: 'tweetBackgroundColor', type: 'color', default: '' }, { displayName: 'Tweet Font Size (Rem)', name: 'tweetFontSize', type: 'number', default: 0 }, { displayName: 'Tweet ID', name: 'tweetId', type: 'string', default: '' }, { displayName: 'Tweet Text Color', name: 'tweetTextColor', type: 'color', default: '' }, { displayName: 'Tweet URL', name: 'tweetUrl', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Website Parameters', name: 'websitescreenshotParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['website-screenshot'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Delay (Ms)', name: 'delay', type: 'number', default: 0 }, { displayName: 'Full Capture', name: 'fullCapture', type: 'boolean', default: false }, { displayName: 'Height (Px)', name: 'height', type: 'number', default: 0 }, { displayName: 'Website URL', name: 'websiteUrl', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Link‑Preview Parameters', name: 'linkpreviewimageParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['link-preview-image'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Author', name: 'author', type: 'string', default: '' }, { displayName: 'Author Photo', name: 'authorPhoto', type: 'string', default: '' }, { displayName: 'Author Title', name: 'authorTitle', type: 'string', default: '' }, { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image', name: 'backgroundImage', type: 'string', default: '' }, { displayName: 'Background Pattern', name: 'backgroundPattern', type: 'options', default: 'none', options: [ { name: 'Dots', value: 'dots' }, { name: 'Harmony', value: 'harmony' }, { name: 'None', value: 'none' }, { name: 'Ripples', value: 'ripples' }, { name: 'Waves', value: 'waves' }, ] }, { displayName: 'Date', name: 'date', type: 'string', default: '' }, { displayName: 'Font Family', name: 'fontFamily', type: 'options', default: 'Inter', options: [ { name: 'Geist', value: 'Geist' }, { name: 'Inter', value: 'Inter' }, { name: 'Playfair Display', value: 'Playfair Display' }, { name: 'Poppins', value: 'Poppins' }, { name: 'Roboto', value: 'Roboto' }, ] }, { displayName: 'Read Time', name: 'readTime', type: 'string', default: '' }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, { displayName: 'URL', name: 'url', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Word‑Definition Parameters', name: 'worddefinitionimageParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['word-definition-image'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Font Family', name: 'fontFamily', type: 'options', default: 'Inter', options: [ { name: 'Geist', value: 'Geist' }, { name: 'Inter', value: 'Inter' }, { name: 'Lora', value: 'Lora' }, { name: 'Merriweather', value: 'Merriweather' }, { name: 'Playfair Display', value: 'Playfair Display' }, { name: 'Roboto', value: 'Roboto' }, ] }, { displayName: 'Height (Px)', name: 'height', type: 'number', default: 0 }, { displayName: 'Meaning', name: 'meaning', type: 'string', default: '' }, { displayName: 'Meaning Color', name: 'meaningColor', type: 'color', default: '' }, { displayName: 'Meaning Font Size (Px)', name: 'meaningFontSize', type: 'number', default: 0 }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, { displayName: 'Word', name: 'word', type: 'string', default: '' }, { displayName: 'Word Color', name: 'wordColor', type: 'color', default: '' }, { displayName: 'Word Font Size (Px)', name: 'wordFontSize', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Comparison‑Graph Parameters', name: 'comparisongraphParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['comparison-graph'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Bar Primary Color', name: 'barPrimaryColor', type: 'color', default: '', }, { displayName: 'Bar Secondary Color', name: 'barSecondaryColor', type: 'color', default: '', }, { displayName: 'Canvas Background Color', name: 'backgroundColor', type: 'color', default: '', }, { displayName: 'Change Values', name: 'changeValues', type: 'string', default: '', }, { displayName: 'Current Value Color', name: 'currentValueColor', type: 'color', default: '', }, { displayName: 'Current Values', name: 'currentValues', type: 'string', default: '', }, { displayName: 'Description', name: 'description', type: 'string', default: '', }, { displayName: 'Description Color', name: 'descriptionColor', type: 'color', default: '', }, { displayName: 'Graph Background Color', name: 'graphBackgroundColor', type: 'color', default: '', }, { displayName: 'Icon URL', name: 'icon', type: 'string', default: '', }, { displayName: 'Metric Name Color', name: 'metricNameColor', type: 'color', default: '', }, { displayName: 'Metric Names', name: 'metricNames', type: 'string', default: '', }, { displayName: 'Padding (Px)', name: 'padding', type: 'number', default: 0 }, { displayName: 'Previous Value Color', name: 'previousValueColor', type: 'color', default: '', }, { displayName: 'Previous Values', name: 'previousValues', type: 'string', default: '', }, { displayName: 'Title', name: 'title', type: 'string', default: '', }, { displayName: 'Title Color', name: 'titleColor', type: 'color', default: '', }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'App‑Store Parameters', name: 'appstorescreenshotsimpleParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['app-store-screenshot-simple'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Screenshot Image', name: 'screenshotImage', type: 'string', default: '' }, { displayName: 'Size Variant', name: 'size', type: 'options', default: '6.9-inch', options: [ { name: '5.8-inch', value: '5.8-inch' }, { name: '6.3-inch', value: '6.3-inch' }, { name: '6.5-inch', value: '6.5-inch' }, { name: '6.9-inch', value: '6.9-inch' }, ] }, { displayName: 'Text Color', name: 'textColor', type: 'color', default: '' }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, ], }, ], }, { displayName: 'Beautify Parameters', name: 'beautifyscreenshotParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['beautify-screenshot'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '#111' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Background Pattern', name: 'backgroundPattern', type: 'options', default: 'harmony', options: [ { name: 'Dots', value: 'dots' }, { name: 'Harmony', value: 'harmony' }, { name: 'None', value: 'none' }, { name: 'Ripples', value: 'ripples' }, { name: 'Waves', value: 'waves' }, ] }, { displayName: 'Border Radius (Px)', name: 'borderRadius', type: 'number', default: 12 }, { displayName: 'Height (Px)', name: 'height', type: 'number', default: 1000 }, { displayName: 'Padding (Px)', name: 'padding', type: 'number', default: 80 }, { displayName: 'Screenshot Image', name: 'screenshotImage', type: 'string', default: '' }, { displayName: 'Screenshot Shadow', name: 'screenshotShadow', type: 'string', default: '0 0 12px rgba(0,0,0,0.1)' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 1200 }, ], }, ], }, { displayName: 'Instagram Parameters', name: 'instagrampostimageParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['instagram-post-image'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Caption', name: 'caption', type: 'string', default: '' }, { displayName: 'Height (Px)', name: 'height', type: 'number', default: 0 }, { displayName: 'Likes Count', name: 'likesCount', type: 'number', default: 0 }, { displayName: 'Post Image URL', name: 'postImageUrl', type: 'string', default: '' }, { displayName: 'Profile Picture URL', name: 'profilePictureUrl', type: 'string', default: '' }, { displayName: 'Username', name: 'userName', type: 'string', default: '' }, { displayName: 'Verified', name: 'verified', type: 'boolean', default: false }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'iPhone 14 Mockup Parameters', name: 'iphone14mockupParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['iphone-14-mockup'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Height (Px)', name: 'height', type: 'number', default: 2642 }, { displayName: 'Omit Background', name: 'omitBackground', type: 'boolean', default: true }, { displayName: 'Screenshot Image', name: 'screenshotImage', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 1300 }, ], }, ], }, { displayName: 'Notes Parameters', name: 'iphonenotesscreenshotParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['iphone-notes-screenshot'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Content', name: 'content', type: 'string', default: '' }, { displayName: 'Content Font Size', name: 'contentFontSize', type: 'number', default: 0 }, { displayName: 'Folder Text', name: 'folderText', type: 'string', default: '' }, { displayName: 'Hide Hamburger Icon', name: 'hideHamburgerIcon', type: 'boolean', default: false }, { displayName: 'Hide Redo Icon', name: 'hideRedoIcon', type: 'boolean', default: false }, { displayName: 'Hide Share Icon', name: 'hideShareIcon', type: 'boolean', default: false }, { displayName: 'Hide Undo Icon', name: 'hideUndoIcon', type: 'boolean', default: false }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, { displayName: 'Title Font Size', name: 'titleFontSize', type: 'number', default: 0 }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'OG Blog Parameters', name: 'opengraphimage1Params', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['open-graph-image-1'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Description', name: 'description', type: 'string', default: '' }, { displayName: 'Text Color', name: 'textColor', type: 'color', default: '' }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, ], }, ], }, { displayName: 'OG Profile Parameters', name: 'opengraphimage2Params', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['open-graph-image-2'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'App Logo URL', name: 'appLogoUrl', type: 'string', default: '' }, { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Text Color', name: 'textColor', type: 'color', default: '' }, { displayName: 'User Handle', name: 'userHandle', type: 'string', default: '' }, { displayName: 'User Name', name: 'userName', type: 'string', default: '' }, { displayName: 'User Photo URL', name: 'userPhotoUrl', type: 'string', default: '' }, { displayName: 'User Tagline', name: 'userTagline', type: 'string', default: '' }, ], }, ], }, { displayName: 'OG Article Parameters', name: 'opengraphimage3Params', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['open-graph-image-3'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Author Name', name: 'authorName', type: 'string', default: '' }, { displayName: 'Author Photo URL', name: 'authorPhoto', type: 'string', default: '' }, { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Logo URL', name: 'logo', type: 'string', default: '' }, { displayName: 'Text Color', name: 'textColor', type: 'color', default: '' }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, ], }, ], }, { displayName: 'OG Product Parameters', name: 'opengraphimage4Params', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['open-graph-image-4'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '' }, { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '' }, { displayName: 'Logo URL', name: 'logo', type: 'string', default: '' }, { displayName: 'Screenshot Image', name: 'screenshotImage', type: 'string', default: '' }, { displayName: 'Show Image on Right', name: 'showImageOnRight', type: 'boolean', default: false }, { displayName: 'Title', name: 'title', type: 'string', default: '' }, { displayName: 'Title Color', name: 'titleColor', type: 'color', default: '' }, { displayName: 'Title Font Size', name: 'titleFontSize', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Bar‑Graph Parameters', name: 'simplebargraphParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['simple-bar-graph'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Background Image URL', name: 'backgroundImageUrl', type: 'string', default: '', }, { displayName: 'Bar Fallback Color', name: 'barFallbackColor', type: 'color', default: '', }, { displayName: 'Bar Primary Color', name: 'barPrimaryColor', type: 'color', default: '', }, { displayName: 'Canvas Background Color', name: 'backgroundColor', type: 'color', default: '', }, { displayName: 'Description', name: 'description', type: 'string', default: '', }, { displayName: 'Description Color', name: 'descriptionColor', type: 'color', default: '', }, { displayName: 'Graph Background Color', name: 'graphBackgroundColor', type: 'color', default: '', }, { displayName: 'Height (Px)', name: 'height', type: 'number', default: 0 }, { displayName: 'Icon URL', name: 'icon', type: 'string', default: '', }, { displayName: 'Label Color', name: 'labelColor', type: 'color', default: '', }, { displayName: 'Labels', name: 'labels', type: 'string', default: '', }, { displayName: 'Padding (Px)', name: 'padding', type: 'number', default: 0 }, { displayName: 'Title', name: 'title', type: 'string', default: '', }, { displayName: 'Title Color', name: 'titleColor', type: 'color', default: '', }, { displayName: 'Values', name: 'values', type: 'string', default: '', }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, ], }, { displayName: 'Testimonial Parameters', name: 'testimonialscreenshotParams', type: 'fixedCollection', default: {}, typeOptions: { multipleValues: false, }, displayOptions: { show: { template: ['testimonial-screenshot'] } }, options: [ { displayName: 'Fields', name: 'fields', values: [ { displayName: 'Author Description', name: 'authorDescription', type: 'string', default: '' }, { displayName: 'Author Meta Font Size', name: 'authorMetaFontSize', type: 'number', default: 0 }, { displayName: 'Author Name', name: 'authorName', type: 'string', default: '' }, { displayName: 'Author Photo URL', name: 'authorPhoto', type: 'string', default: '' }, { displayName: 'Rating (0–5)', name: 'rating', type: 'number', default: 0 }, { displayName: 'Testimonial Font Size', name: 'testimonialFontSize', type: 'number', default: 0 }, { displayName: 'Testimonial Text', name: 'testimonialText', type: 'string', default: '' }, { displayName: 'Width (Px)', name: 'width', type: 'number', default: 0 }, ], }, buildFixedCollection('tweet-image', 'Tweet Parameters', tweetValues), ], }, ], }; } async execute() { const inputItems = this.getInputData(); const output = []; const loopItems = inputItems.length ? inputItems : [{ json: {} }]; for (let i = 0; i < loopItems.length; i++) { const templateId = this.getNodeParameter('template', i); const params = this.getNodeParameter(`${templateId.replace(/-/g, '')}Params.fields`, i, {}); const body = { templateId, modifications: params, response: { type: 'url', format: 'png' }, }; const res = await this.helpers.httpRequestWithAuthentication.call(this, 'orshotTemplatesApi', { method: 'POST', url: '/v1/generate/images', json: true, body, }); output.push({ json: res }); } return [output]; } } exports.OrshotTemplates = OrshotTemplates; //# sourceMappingURL=OrshotTemplates.node.js.map