|
| 1 | +import { PinterestIcon } from '@/components/icons' |
| 2 | +import type { BlockConfig } from '@/blocks/types' |
| 3 | +import { AuthMode } from '@/blocks/types' |
| 4 | +import type { PinterestResponse } from '@/tools/pinterest/types' |
| 5 | + |
| 6 | +export const PinterestBlock: BlockConfig<PinterestResponse> = { |
| 7 | + type: 'pinterest', |
| 8 | + name: 'Pinterest', |
| 9 | + description: 'Create pins on your Pinterest boards', |
| 10 | + authMode: AuthMode.OAuth, |
| 11 | + longDescription: 'Create and share pins on Pinterest. Post images with titles, descriptions, and links to your boards.', |
| 12 | + docsLink: 'https://docs.sim.ai/tools/pinterest', |
| 13 | + category: 'tools', |
| 14 | + bgColor: '#E60023', |
| 15 | + icon: PinterestIcon, |
| 16 | + subBlocks: [ |
| 17 | + { |
| 18 | + id: 'credential', |
| 19 | + title: 'Pinterest Account', |
| 20 | + type: 'oauth-input', |
| 21 | + serviceId: 'pinterest', |
| 22 | + requiredScopes: ['boards:read', 'boards:write', 'pins:read', 'pins:write'], |
| 23 | + placeholder: 'Select Pinterest account', |
| 24 | + required: true, |
| 25 | + }, |
| 26 | + { |
| 27 | + id: 'board_id', |
| 28 | + title: 'Board ID', |
| 29 | + type: 'short-input', |
| 30 | + placeholder: 'Enter board ID (e.g., 1234567890)', |
| 31 | + required: true, |
| 32 | + }, |
| 33 | + { |
| 34 | + id: 'title', |
| 35 | + title: 'Pin Title', |
| 36 | + type: 'short-input', |
| 37 | + placeholder: 'Enter pin title', |
| 38 | + required: true, |
| 39 | + }, |
| 40 | + { |
| 41 | + id: 'description', |
| 42 | + title: 'Pin Description', |
| 43 | + type: 'long-input', |
| 44 | + placeholder: 'Enter pin description', |
| 45 | + required: true, |
| 46 | + }, |
| 47 | + { |
| 48 | + id: 'media_url', |
| 49 | + title: 'Image URL', |
| 50 | + type: 'short-input', |
| 51 | + placeholder: 'Enter image URL', |
| 52 | + required: true, |
| 53 | + }, |
| 54 | + { |
| 55 | + id: 'link', |
| 56 | + title: 'Destination Link', |
| 57 | + type: 'short-input', |
| 58 | + placeholder: 'Enter destination URL (optional)', |
| 59 | + required: false, |
| 60 | + }, |
| 61 | + { |
| 62 | + id: 'alt_text', |
| 63 | + title: 'Alt Text', |
| 64 | + type: 'short-input', |
| 65 | + placeholder: 'Enter alt text for accessibility (optional)', |
| 66 | + required: false, |
| 67 | + }, |
| 68 | + ], |
| 69 | + tools: { |
| 70 | + access: ['pinterest_create_pin'], |
| 71 | + config: { |
| 72 | + tool: () => 'pinterest_create_pin', |
| 73 | + params: (inputs) => { |
| 74 | + const { credential, ...rest } = inputs |
| 75 | + |
| 76 | + return { |
| 77 | + accessToken: credential, |
| 78 | + board_id: rest.board_id, |
| 79 | + title: rest.title, |
| 80 | + description: rest.description, |
| 81 | + media_url: rest.media_url, |
| 82 | + link: rest.link, |
| 83 | + alt_text: rest.alt_text, |
| 84 | + } |
| 85 | + }, |
| 86 | + }, |
| 87 | + }, |
| 88 | + inputs: { |
| 89 | + credential: { type: 'string', description: 'Pinterest access token' }, |
| 90 | + board_id: { type: 'string', description: 'Board ID where the pin will be created' }, |
| 91 | + title: { type: 'string', description: 'Pin title' }, |
| 92 | + description: { type: 'string', description: 'Pin description' }, |
| 93 | + media_url: { type: 'string', description: 'Image URL for the pin' }, |
| 94 | + link: { type: 'string', description: 'Destination link when pin is clicked' }, |
| 95 | + alt_text: { type: 'string', description: 'Alt text for accessibility' }, |
| 96 | + }, |
| 97 | + outputs: { |
| 98 | + success: { type: 'boolean', description: 'Whether the pin was created successfully' }, |
| 99 | + pin: { type: 'json', description: 'Full pin object' }, |
| 100 | + pin_id: { type: 'string', description: 'ID of the created pin' }, |
| 101 | + pin_url: { type: 'string', description: 'URL of the created pin' }, |
| 102 | + error: { type: 'string', description: 'Error message if operation failed' }, |
| 103 | + }, |
| 104 | +} |
0 commit comments