AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(google-docs): improve the step forms (#15298)
Talal Jabere0287714ac67
diff --git a/bun.lock b/bun.lockindex a4683ffd812..108f12b7bf7 100644--- a/bun.lock+++ b/bun.lock@@ -3813,7 +3813,7 @@},"packages/pieces/community/google-docs": {"name": "@activepieces/piece-google-docs",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3826,6 +3826,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/google-drive": {diff --git a/packages/pieces/community/google-docs/package.json b/packages/pieces/community/google-docs/package.jsonindex f64599767a2..c3cfc717829 100644--- a/packages/pieces/community/google-docs/package.json+++ b/packages/pieces/community/google-docs/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-google-docs",- "version": "0.5.0",+ "version": "0.5.1","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","dependencies": {@@ -14,11 +14,13 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"},"scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"}}diff --git a/packages/pieces/community/google-docs/src/i18n/translation.json b/packages/pieces/community/google-docs/src/i18n/translation.jsonindex dc8aac51545..fe76a74a28b 100644--- a/packages/pieces/community/google-docs/src/i18n/translation.json+++ b/packages/pieces/community/google-docs/src/i18n/translation.json@@ -1,7 +1,7 @@{"Create and edit documents online": "Create and edit documents online","Create Document": "Create Document",- "Edit template file": "Edit template file",+ "Edit Template File": "Edit Template File","Read Document": "Read Document","Find Document": "Find Document","Get Document Plain Text": "Get Document Plain Text",@@ -42,11 +42,11 @@"Replace Section with Markdown": "Replace Section with Markdown","Batch Update (Advanced)": "Batch Update (Advanced)","Custom API Call": "Custom API Call",- "Append text to google docs": "Append text to google docs",- "Create a document on Google Docs": "Create a document on Google Docs",- "Edit a template file and replace the values with the ones provided": "Edit a template file and replace the values with the ones provided",- "Read a document from Google Docs": "Read a document from Google Docs",- "Search for document by name.": "Search for document by name.",+ "Append Text": "Append Text",+ "Create a document on Google Docs.": "Create a document on Google Docs.",+ "Fill a template by replacing its placeholders with your values.": "Fill a template by replacing its placeholders with your values.",+ "Read a document from Google Docs.": "Read a document from Google Docs.",+ "Find a document by name, optionally creating it.": "Find a document by name, optionally creating it.","Get the plain text content of a Google Docs document.": "Get the plain text content of a Google Docs document.","Replace every occurrence of a literal string in a Google Docs document with another string.": "Replace every occurrence of a literal string in a Google Docs document with another string.","Search Google Drive for Google Docs documents by name or full-text content.": "Search Google Drive for Google Docs documents by name or full-text content.",@@ -85,18 +85,18 @@"Replace a character range of a Google Docs document with Markdown content": "Replace a character range of a Google Docs document with Markdown content","Send a raw Google Docs batchUpdate requests array to a document": "Send a raw Google Docs batchUpdate requests array to a document","Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",- "Appends text to google docs": "Appends text to google docs",+ "Add text to the end of a document.": "Add text to the end of a document.","Document Title": "Document Title","Document Content": "Document Content",- "Destination File": "Destination File",- "Variables": "Variables",- "Images": "Images",+ "Document": "Document","Placeholder Format": "Placeholder Format",- "Document ID": "Document ID",+ "Variables": "Variables",+ "Image Replacements": "Image Replacements","Document Name": "Document Name","Folder": "Folder",- "Create a new document if not found?": "Create a new document if not found?",+ "Create If Not Found": "Create If Not Found","New Document Properties": "New Document Properties",+ "Document ID": "Document ID","Find Text": "Find Text","Replace With": "Replace With","Match Case": "Match Case",@@ -151,16 +151,15 @@"Query Parameters": "Query Parameters","Body Type": "Body Type","Body": "Body",- "Response is Binary ?": "Response is Binary ?",- "No Error on Failure": "No Error on Failure",- "Timeout (in seconds)": "Timeout (in seconds)",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout","Follow redirects": "Follow redirects",- "Text to append": "Text to append",- "The ID of the file to replace the values": "The ID of the file to replace the values",- "Dont include the placeholder format \"[[]]\" or \"{{}}\", only the key name and its value": "Dont include the placeholder format \"[[]]\" or \"{{}}\", only the key name and its value",- "Key: Image ID (get it manually from the Read File Action), Value: Image URL": "Key: Image ID (get it manually from the Read File Action), Value: Image URL",- "Choose the format of placeholders in your template": "Choose the format of placeholders in your template",- "The ID of the document to read": "The ID of the document to read",+ "Placeholders in this document are replaced in place.": "Placeholders in this document are replaced in place.",+ "Key names without brackets. Each value replaces its placeholder.": "Key names without brackets. Each value replaces its placeholder.",+ "Each row swaps one image in the document for a new one.": "Each row swaps one image in the document for a new one.",+ "Matches any document whose name contains this text.": "Matches any document whose name contains this text.",+ "Leave empty to include all of Drive.": "Leave empty to include all of Drive.","The ID of the document to read, found in its URL: 'https://docs.google.com/document/d/<documentId>/edit'. Obtain it from Search Documents or Find Document if you only have a name.": "The ID of the document to read, found in its URL: 'https://docs.google.com/document/d/<documentId>/edit'. Obtain it from Search Documents or Find Document if you only have a name.","The ID of the document to edit, found in its URL: 'https://docs.google.com/document/d/<documentId>/edit'.": "The ID of the document to edit, found in its URL: 'https://docs.google.com/document/d/<documentId>/edit'.","The literal text to search for in the document.": "The literal text to search for in the document.",@@ -255,13 +254,16 @@"The ID of the document to update.": "The ID of the document to update.","An array of raw Google Docs batchUpdate request objects, e.g. [{\"insertText\":{\"text\":\"hi\",\"location\":{\"index\":1}}}]. See the Google Docs API documents.batchUpdate reference for the available request kinds.": "An array of raw Google Docs batchUpdate request objects, e.g. [{\"insertText\":{\"text\":\"hi\",\"location\":{\"index\":1}}}]. See the Google Docs API documents.batchUpdate reference for the available request kinds.","Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",- "Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",- "The text to append to the document": "The text to append to the document",- "The ID of the document to append text to": "The ID of the document to append text to",- "Curly Braces {{}}": "Curly Braces {{}}",- "Square Brackets [[]]": "Square Brackets [[]]",- "Single Curly Braces {}": "Single Curly Braces {}",- "Single Square Brackets []": "Single Square Brackets []",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",+ "Return the response as base64, for files like PDFs.": "Return the response as base64, for files like PDFs.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning the response.": "Follow 3xx redirects instead of returning the response.",+ "Added to the end of the document.": "Added to the end of the document.",+ "{{KEY}}": "{{KEY}}",+ "[[KEY]]": "[[KEY]]",+ "{KEY}": "{KEY}",+ "[KEY]": "[KEY]","Last modified (newest first)": "Last modified (newest first)","Last modified (oldest first)": "Last modified (oldest first)","Created (newest first)": "Created (newest first)",@@ -295,5 +297,5 @@"Form Data": "Form Data","Raw": "Raw","New Document": "New Document",- "Triggers when a new document is added to a specific folder(optional).": "Triggers when a new document is added to a specific folder(optional)."+ "Triggers when a new document is created in Drive or a chosen folder.": "Triggers when a new document is created in Drive or a chosen folder."}\ No newline at end of filediff --git a/packages/pieces/community/google-docs/src/index.ts b/packages/pieces/community/google-docs/src/index.tsindex a052811ba7a..c122f5c2eeb 100644--- a/packages/pieces/community/google-docs/src/index.ts+++ b/packages/pieces/community/google-docs/src/index.ts@@ -52,7 +52,7 @@ export { googleDocsAuth, getAccessToken, GoogleDocsAuthValue } from './lib/auth'export const googleDocs = createPiece({displayName: 'Google Docs',description: 'Create and edit documents online',- minimumSupportedRelease: '0.86.4',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/google-docs.png',categories: [PieceCategory.CONTENT_AND_FILES],authors: [diff --git a/packages/pieces/community/google-docs/src/lib/actions/append-text.ts b/packages/pieces/community/google-docs/src/lib/actions/append-text.tsindex ab8ff63ddb3..ee4175d0f25 100644--- a/packages/pieces/community/google-docs/src/lib/actions/append-text.ts+++ b/packages/pieces/community/google-docs/src/lib/actions/append-text.ts@@ -1,31 +1,28 @@import { docsCommon } from '../common';import { googleDocsAuth, getAccessToken } from '../auth';import { Property, createAction } from "@activepieces/pieces-framework";+import { documentIdProp } from '../common/props';import { appendTextActionOutputSchema } from '../output-schemas';export const appendText = createAction({auth: googleDocsAuth,name: 'append_text',classification: 'WRITE',- description: 'Appends text to google docs',+ description: 'Add text to the end of a document.',audience: 'human',aiMetadata: {description:'Appends text to the end of an existing Google Docs document identified by its ID. Use when an agent needs to add content to a known document without altering its existing text. Requires the document ID; not idempotent, since each call inserts the text again, accumulating duplicates.',idempotent: false,},- displayName: 'Append text to google docs',+ displayName: 'Append Text',props: {+ documentId: documentIdProp(),text: Property.LongText({- displayName: 'Text to append',- description: 'The text to append to the document',+ displayName: 'Text',+ description: 'Added to the end of the document.',required: true,}),- documentId: Property.ShortText({- displayName: 'Document ID',- description: 'The ID of the document to append text to',- required: true,- })},outputSchema: appendTextActionOutputSchema,async run(context) {diff --git a/packages/pieces/community/google-docs/src/lib/actions/create-document-based-on-template.action.ts b/packages/pieces/community/google-docs/src/lib/actions/create-document-based-on-template.action.tsindex 1654ebb4506..37c94834456 100644--- a/packages/pieces/community/google-docs/src/lib/actions/create-document-based-on-template.action.ts+++ b/packages/pieces/community/google-docs/src/lib/actions/create-document-based-on-template.action.ts@@ -3,6 +3,8 @@ import { googleDocsAuth, createGoogleClient } from '../auth';import { Property, createAction } from '@activepieces/pieces-framework';import { docs as googleDocs } from '@googleapis/docs';import { editTemplateActionOutputSchema } from '../output-schemas';+import { documentIdProp } from '../common/props';+import { toImageReplacements } from '../common/image-replacements';const PLACEHOLDER_FORMATS: Record<string, string> = {'curly_braces': '{{KEY}}',@@ -20,46 +22,56 @@ export const createDocumentBasedOnTemplate = createAction({name: 'create_document_based_on_template',classification: 'WRITE',description:- 'Edit a template file and replace the values with the ones provided',+ 'Fill a template by replacing its placeholders with your values.',audience: 'both',aiMetadata: {description:'Fills a Google Docs template in place by find-and-replacing placeholder tokens (e.g. [[KEY]] or {{KEY}}) with supplied key/value pairs and swapping placeholder images by object ID. Use when an agent has an existing template document and wants to merge data into it rather than build a doc from scratch. Requires the target document ID and the matching placeholder format; idempotent since re-running with the same values replaces no remaining placeholders and leaves the document unchanged.',idempotent: true,},- displayName: 'Edit template file',+ displayName: 'Edit Template File',props: {- template: Property.ShortText({- displayName: 'Destination File',- description: 'The ID of the file to replace the values',+ template: documentIdProp({+ description: 'Placeholders in this document are replaced in place.',+ }),+ placeholder_format: Property.StaticDropdown({+ displayName: 'Placeholder Format',required: true,+ defaultValue: 'square_brackets',+ display: 'cards',+ options: {+ options: [+ { label: '{{KEY}}', value: 'curly_braces', description: 'Double curly braces' },+ { label: '[[KEY]]', value: 'square_brackets', description: 'Double square brackets' },+ { label: '{KEY}', value: 'single_curly', description: 'Single curly braces' },+ { label: '[KEY]', value: 'single_square', description: 'Single square brackets' },+ ],+ },}),values: Property.Object({displayName: 'Variables',- description: 'Dont include the placeholder format "[[]]" or "{{}}", only the key name and its value',+ description: 'Key names without brackets. Each value replaces its placeholder.',required: true,}),- images: Property.Object({- displayName: 'Images',- description:- 'Key: Image ID (get it manually from the Read File Action), Value: Image URL',- required: true,+ images: Property.Array({+ displayName: 'Image Replacements',+ description: 'Each row swaps one image in the document for a new one.',+ required: false,+ advanced: true,+ properties: {+ imageObjectId: Property.ShortText({+ displayName: 'Image Object ID',+ description: 'Found under inlineObjects in the Read Document output.',+ required: true,+ placeholder: 'kix.abc123def456',+ }),+ url: Property.ShortText({+ displayName: 'New Image URL',+ required: true,+ placeholder: 'https://example.com/logo.png',+ }),+ },}),- placeholder_format: Property.StaticDropdown({- displayName: 'Placeholder Format',- description: 'Choose the format of placeholders in your template',- required: true,- defaultValue: 'square_brackets',- options: {- disabled: false,- options: [- { label: 'Curly Braces {{}}', value: 'curly_braces' },- { label: 'Square Brackets [[]]', value: 'square_brackets' },- { label: 'Single Curly Braces {}', value: 'single_curly' },- { label: 'Single Square Brackets []', value: 'single_square' }- ],- },- }),},outputSchema: editTemplateActionOutputSchema,async run(context) {@@ -88,12 +100,11 @@ export const createDocumentBasedOnTemplate = createAction({});}- for (const key in context.propsValue.images) {- const value = context.propsValue.images[key];+ for (const { imageObjectId, url } of toImageReplacements(context.propsValue.images)) {requests.push({replaceImage: {- imageObjectId: key,- uri: String(value),+ imageObjectId,+ uri: url,},});}diff --git a/packages/pieces/community/google-docs/src/lib/actions/create-document.ts b/packages/pieces/community/google-docs/src/lib/actions/create-document.tsindex d2560fa2a78..37cafef9bf4 100644--- a/packages/pieces/community/google-docs/src/lib/actions/create-document.ts+++ b/packages/pieces/community/google-docs/src/lib/actions/create-document.ts@@ -7,7 +7,7 @@ export const createDocument = createAction({auth: googleDocsAuth,name: 'create_document',classification: 'WRITE',- description: 'Create a document on Google Docs',+ description: 'Create a document on Google Docs.',audience: 'human',aiMetadata: {description:diff --git a/packages/pieces/community/google-docs/src/lib/actions/find-document.ts b/packages/pieces/community/google-docs/src/lib/actions/find-document.tsindex e87f5e0795c..ee7f74fbc5d 100644--- a/packages/pieces/community/google-docs/src/lib/actions/find-document.ts+++ b/packages/pieces/community/google-docs/src/lib/actions/find-document.ts@@ -14,7 +14,7 @@ export const findDocumentAction = createAction({name: 'google-docs-find-document',classification: 'SEARCH',displayName: 'Find Document',- description: 'Search for document by name.',+ description: 'Find a document by name, optionally creating it.',audience: 'human',aiMetadata: {description:@@ -24,11 +24,13 @@ export const findDocumentAction = createAction({props: {name: Property.ShortText({displayName: 'Document Name',+ description: 'Matches any document whose name contains this text.',+ placeholder: 'Q3 report',required: true,}),folderId: folderIdProp,createIfNotFound: Property.Checkbox({- displayName: 'Create a new document if not found?',+ displayName: 'Create If Not Found',defaultValue: false,required: false,}),@@ -37,7 +39,7 @@ export const findDocumentAction = createAction({displayName: 'New Document Properties',required: false,refreshers: ['createIfNotFound'],- props: async ({ auth, createIfNotFound }) => {+ props: async ({ auth, createIfNotFound }): Promise<DynamicPropsValue> => {if (!auth) return {};if (!createIfNotFound) return {};@@ -46,6 +48,7 @@ export const findDocumentAction = createAction({if (createIfNotFound) {props['content'] = Property.LongText({displayName: 'Document Content',+ placeholder: 'Agenda, decisions, action items',required: true,});}diff --git a/packages/pieces/community/google-docs/src/lib/actions/read-document.action.ts b/packages/pieces/community/google-docs/src/lib/actions/read-document.action.tsindex 3db65b0cea6..40b86ca2e8a 100644--- a/packages/pieces/community/google-docs/src/lib/actions/read-document.action.ts+++ b/packages/pieces/community/google-docs/src/lib/actions/read-document.action.ts@@ -1,6 +1,7 @@import { googleDocsAuth, createGoogleClient } from '../auth';-import { Property, createAction } from '@activepieces/pieces-framework';+import { createAction } from '@activepieces/pieces-framework';import { docs as googleDocs } from '@googleapis/docs';+import { documentIdProp } from '../common/props';import { readDocumentActionOutputSchema } from '../output-schemas';export const readDocument = createAction({@@ -8,7 +9,7 @@ export const readDocument = createAction({auth: googleDocsAuth,name: 'read_document',classification: 'READ',- description: 'Read a document from Google Docs',+ description: 'Read a document from Google Docs.',audience: 'human',aiMetadata: {description:@@ -16,11 +17,7 @@ export const readDocument = createAction({idempotent: true,},props: {- documentId: Property.ShortText({- displayName: 'Document ID',- description: 'The ID of the document to read',- required: true,- }),+ documentId: documentIdProp(),},outputSchema: readDocumentActionOutputSchema,async run(context) {diff --git a/packages/pieces/community/google-docs/src/lib/auth.ts b/packages/pieces/community/google-docs/src/lib/auth.tsindex 86c8107e83f..2ec030bd651 100644--- a/packages/pieces/community/google-docs/src/lib/auth.ts+++ b/packages/pieces/community/google-docs/src/lib/auth.ts@@ -17,12 +17,19 @@ export const googleDocsAuth = [PieceAuth.OAuth2({scope: googleDocsScopes,}), PieceAuth.CustomAuth({displayName: 'Service Account (Advanced)',- description: 'Authenticate via service account from https://console.cloud.google.com/ > IAM & Admin > Service Accounts > Create Service Account > Keys > Add key. <br> <br> You can optionally use domain-wide delegation (https://support.google.com/a/answer/162106?hl=en#zippy=%2Cset-up-domain-wide-delegation-for-a-client) to access documents without adding the service account to each one. <br> <br> **Note:** Without a user email, the service account only has access to files/folders you explicitly share with it.',+ description: `Connect with a Google Cloud service account.++**How to get the key:**+1. Open the [Google Cloud console](https://console.cloud.google.com/iam-admin/serviceaccounts) → **IAM & Admin** → **Service Accounts**.+2. Create a service account, or pick an existing one.+3. Open **Keys** → **Add key** → **Create new key** → **JSON** and download the file.+4. Share each document with the service account's email, or set up [domain-wide delegation](https://support.google.com/a/answer/162106) and fill in **User Email** below.`,required: true,props: {serviceAccount: Property.LongText({displayName: 'Service Account JSON Key',required: true,+ description: 'Paste the full contents of the downloaded key file.',}),userEmail: Property.ShortText({displayName: 'User Email',diff --git a/packages/pieces/community/google-docs/src/lib/common/image-replacements.test.ts b/packages/pieces/community/google-docs/src/lib/common/image-replacements.test.tsnew file mode 100644index 00000000000..54ff31ea8fb--- /dev/null+++ b/packages/pieces/community/google-docs/src/lib/common/image-replacements.test.ts@@ -0,0 +1,62 @@+import { describe, expect, it } from 'vitest';+import { toImageReplacements } from './image-replacements';++describe('toImageReplacements', () => {+ it('maps the row editor array shape', () => {+ expect(+ toImageReplacements([+ { imageObjectId: 'kix.one', url: 'https://example.com/one.png' },+ { imageObjectId: 'kix.two', url: 'https://example.com/two.png' },+ ]),+ ).toEqual([+ { imageObjectId: 'kix.one', url: 'https://example.com/one.png' },+ { imageObjectId: 'kix.two', url: 'https://example.com/two.png' },+ ]);+ });++ it('maps the legacy dictionary after the engine wraps it in a one-element array', () => {+ expect(+ toImageReplacements([+ {+ 'kix.one': 'https://example.com/one.png',+ 'kix.two': 'https://example.com/two.png',+ },+ ]),+ ).toEqual([+ { imageObjectId: 'kix.one', url: 'https://example.com/one.png' },+ { imageObjectId: 'kix.two', url: 'https://example.com/two.png' },+ ]);+ });++ it('maps the bare legacy dictionary shape', () => {+ expect(+ toImageReplacements({+ 'kix.one': 'https://example.com/one.png',+ 'kix.two': 'https://example.com/two.png',+ }),+ ).toEqual([+ { imageObjectId: 'kix.one', url: 'https://example.com/one.png' },+ { imageObjectId: 'kix.two', url: 'https://example.com/two.png' },+ ]);+ });++ it('skips half-filled editor rows and non-object rows', () => {+ expect(+ toImageReplacements([+ { imageObjectId: 'kix.one' },+ { url: 'https://example.com/two.png' },+ 'not-a-row',+ null,+ { imageObjectId: 'kix.three', url: 'https://example.com/three.png' },+ ]),+ ).toEqual([{ imageObjectId: 'kix.three', url: 'https://example.com/three.png' }]);+ });++ it('returns nothing when images are absent', () => {+ expect(toImageReplacements(undefined)).toEqual([]);+ expect(toImageReplacements(null)).toEqual([]);+ expect(toImageReplacements([])).toEqual([]);+ expect(toImageReplacements({})).toEqual([]);+ expect(toImageReplacements([{}])).toEqual([]);+ });+});diff --git a/packages/pieces/community/google-docs/src/lib/common/image-replacements.ts b/packages/pieces/community/google-docs/src/lib/common/image-replacements.tsnew file mode 100644index 00000000000..da509814aff--- /dev/null+++ b/packages/pieces/community/google-docs/src/lib/common/image-replacements.ts@@ -0,0 +1,38 @@+export function toImageReplacements(images: unknown): ImageReplacement[] {+ if (Array.isArray(images)) {+ return images.flatMap((row) => {+ if (typeof row !== 'object' || row === null) {+ return [];+ }+ if (isEditorRow(row)) {+ return hasBothColumns(row) ? [{ imageObjectId: String(row.imageObjectId), url: String(row.url) }] : [];+ }+ return fromDictionary(row);+ });+ }+ if (typeof images === 'object' && images !== null) {+ return fromDictionary(images);+ }+ return [];+}++function isEditorRow(row: object): boolean {+ return EDITOR_COLUMNS.some((column) => column in row);+}++function hasBothColumns(row: object): row is Record<EditorColumn, unknown> {+ return EDITOR_COLUMNS.every((column) => column in row);+}++function fromDictionary(dictionary: object): ImageReplacement[] {+ return Object.entries(dictionary).map(([imageObjectId, url]) => ({ imageObjectId, url: String(url) }));+}++const EDITOR_COLUMNS = ['imageObjectId', 'url'] as const;++type EditorColumn = (typeof EDITOR_COLUMNS)[number];++export type ImageReplacement = {+ imageObjectId: string;+ url: string;+};diff --git a/packages/pieces/community/google-docs/src/lib/common/index.ts b/packages/pieces/community/google-docs/src/lib/common/index.tsindex b5d705073be..35ff13fb376 100644--- a/packages/pieces/community/google-docs/src/lib/common/index.ts+++ b/packages/pieces/community/google-docs/src/lib/common/index.ts@@ -7,10 +7,12 @@ export const docsCommon = {baseUrl: 'https://docs.googleapis.com/v1',title: Property.ShortText({displayName: 'Document Title',+ placeholder: 'Weekly sync notes',required: true,}),body: Property.LongText({displayName: 'Document Content',+ placeholder: 'Agenda, decisions, action items',required: true,}),diff --git a/packages/pieces/community/google-docs/src/lib/common/props.ts b/packages/pieces/community/google-docs/src/lib/common/props.tsindex d0ba732e6a4..35c7c772a5e 100644--- a/packages/pieces/community/google-docs/src/lib/common/props.ts+++ b/packages/pieces/community/google-docs/src/lib/common/props.ts@@ -1,9 +1,10 @@import { googleDocsAuth, createGoogleClient, GoogleDocsAuthValue } from '../auth';-import { DropdownOption, Property } from '@activepieces/pieces-framework';+import { DropdownOption, isNil, Property } from '@activepieces/pieces-framework';import { drive as googleDrive, drive_v3 } from '@googleapis/drive';export const folderIdProp = Property.Dropdown({displayName: 'Folder',+ description: 'Leave empty to include all of Drive.',refreshers: [],auth: googleDocsAuth,required: false,@@ -11,7 +12,7 @@ export const folderIdProp = Property.Dropdown({if (!auth) {return {disabled: true,- placeholder: 'Please connect to your Google Drive account.',+ placeholder: 'Connect your account first',options: [],};}@@ -53,3 +54,63 @@ export const folderIdProp = Property.Dropdown({};},});++export const documentIdProp = ({ description }: { description?: string } = {}) =>+ Property.Dropdown({+ displayName: 'Document',+ description,+ auth: googleDocsAuth,+ required: true,+ refreshers: [],+ refreshOnSearch: true,+ options: async ({ auth }, { searchValue }) => {+ if (!auth) {+ return {+ disabled: true,+ placeholder: 'Connect your account first',+ options: [],+ };+ }++ const authClient = await createGoogleClient(auth);++ const drive = googleDrive({ version: 'v3', auth: authClient });++ const trimmedSearchValue = searchValue?.trim() ?? '';+ const q = ["mimeType='application/vnd.google-apps.document'", 'trashed = false'];++ if (trimmedSearchValue.length > 0) {+ q.push(`name contains '${escapeDriveQueryLiteral(trimmedSearchValue)}'`);+ }++ const response = await drive.files.list({+ q: q.join(' and '),+ pageSize: DOCUMENT_DROPDOWN_PAGE_SIZE,+ orderBy: 'createdTime desc',+ fields: 'nextPageToken, files(id, name)',+ supportsAllDrives: true,+ includeItemsFromAllDrives: true,+ corpora: 'allDrives',+ });++ const fileList: drive_v3.Schema$FileList = response.data;++ const options: DropdownOption<string>[] = (fileList.files ?? []).flatMap((file) =>+ isNil(file.id) || isNil(file.name) ? [] : [{ label: file.name, value: file.id }],+ );++ return {+ disabled: false,+ placeholder: isNil(fileList.nextPageToken)+ ? undefined+ : `Showing the first ${options.length} documents. Type to narrow the list.`,+ options,+ };+ },+ });++function escapeDriveQueryLiteral(value: string): string {+ return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");+}++const DOCUMENT_DROPDOWN_PAGE_SIZE = 1000;diff --git a/packages/pieces/community/google-docs/src/lib/triggers/new-document.ts b/packages/pieces/community/google-docs/src/lib/triggers/new-document.tsindex 9bee0d03ec7..5b764b23ef3 100644--- a/packages/pieces/community/google-docs/src/lib/triggers/new-document.ts+++ b/packages/pieces/community/google-docs/src/lib/triggers/new-document.ts@@ -68,7 +68,7 @@ export const newDocumentTrigger = createTrigger({name: 'new-document',classification: 'READ',displayName: 'New Document',- description: 'Triggers when a new document is added to a specific folder(optional).',+ description: 'Triggers when a new document is created in Drive or a chosen folder.',aiMetadata: {description:'Fires when a new Google Docs document is created, optionally limited to a specific Drive folder. Use to react when a document first appears; it does not fire on edits to existing documents.',diff --git a/packages/pieces/community/google-docs/vitest.config.ts b/packages/pieces/community/google-docs/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/google-docs/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})