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(grist): add AI actions and output schemas (#16047)
Kishan Parmare393f5ff68b7
diff --git a/packages/pieces/community/grist/package.json b/packages/pieces/community/grist/package.jsonindex 9a0c33871a0..d81f1b30833 100644--- a/packages/pieces/community/grist/package.json+++ b/packages/pieces/community/grist/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-grist",- "version": "0.2.0",+ "version": "0.3.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/grist/src/index.ts b/packages/pieces/community/grist/src/index.tsindex 3694db3cd5d..092380a578d 100644--- a/packages/pieces/community/grist/src/index.ts+++ b/packages/pieces/community/grist/src/index.ts@@ -1,9 +1,4 @@-import {- createPiece,- PieceAuth,- PiecePropValueSchema,- Property,-} from '@activepieces/pieces-framework';+import { createPiece } from '@activepieces/pieces-framework';import { gristCreateRecordAction } from './lib/actions/create-record.action';import { gristUpdateRecordAction } from './lib/actions/update-record.action';import { gristUploadAttachmentsToDocumnetAction } from './lib/actions/upload-attachments-to-document.action';@@ -11,53 +6,36 @@ import { createCustomApiCallAction } from '@activepieces/pieces-common';import { gristNewRecordTrigger } from './lib/triggers/new-record.trigger';import { gristUpdatedRecordTrigger } from './lib/triggers/updated-record.trigger';import { gristSearchRecordAction } from './lib/actions/search-record.action';-import { GristAPIClient } from './lib/common/helpers';+import { gristListAttachmentsAction } from './lib/actions/ai/list-attachments.action';+import { gristDownloadAttachmentAction } from './lib/actions/ai/download-attachment.action';+import { gristDownloadAttachmentsArchiveAction } from './lib/actions/ai/download-attachments-archive.action';+import { gristUploadAttachmentAction } from './lib/actions/ai/upload-attachment.action';+import { gristRemoveUnusedAttachmentsAction } from './lib/actions/ai/remove-unused-attachments.action';+import { gristListColumnsAction } from './lib/actions/ai/list-columns.action';+import { gristAddColumnsAction } from './lib/actions/ai/add-columns.action';+import { gristUpdateColumnsAction } from './lib/actions/ai/update-columns.action';+import { gristDeleteColumnAction } from './lib/actions/ai/delete-column.action';+import { gristCreateDocumentAction } from './lib/actions/ai/create-document.action';+import { gristGetDocumentAction } from './lib/actions/ai/get-document.action';+import { gristUpdateDocumentAction } from './lib/actions/ai/update-document.action';+import { gristAddRecordsAction } from './lib/actions/ai/add-records.action';+import { gristUpdateRecordsAction } from './lib/actions/ai/update-records.action';+import { gristListRecordsAction } from './lib/actions/ai/list-records.action';+import { gristDeleteRecordsAction } from './lib/actions/ai/delete-records.action';+import { gristListTablesAction } from './lib/actions/ai/list-tables.action';+import { gristCreateTableAction } from './lib/actions/ai/create-table.action';+import { gristUpdateTableAction } from './lib/actions/ai/update-table.action';+import { gristRunSqlQueryAction } from './lib/actions/ai/run-sql-query.action';+import { gristListOrganizationsAction } from './lib/actions/ai/list-organizations.action';+import { gristGetOrgAccessAction } from './lib/actions/ai/get-org-access.action';+import { gristListWorkspacesAction } from './lib/actions/ai/list-workspaces.action';+import { gristAuth } from './lib/auth';import { PieceCategory } from '@activepieces/pieces-framework';-export const gristAuth = PieceAuth.CustomAuth({- required: true,- description: `- Log in to your Grist account. Navigate to the account menu at the top right, and select **Profile Settings** to manage or create your API Key.- In the **Domain URL** field, enter the domain URL of your Grist instance.For example,if you have team site it will be "https://team.getgist.com".`,- props: {- apiKey: PieceAuth.SecretText({- displayName: 'API Key',- required: true,- }),- domain: Property.ShortText({- displayName: 'Domain URL',- required: true,- defaultValue: 'https://docs.getgrist.com',- }),- },- validate: async ({ auth }) => {- try {- const authValue = auth ;-- const client = new GristAPIClient({- domainUrl: authValue.domain,- apiKey: authValue.apiKey,- });-- // https://support.getgrist.com/api/#tag/orgs- await client.listOrgs();-- return {- valid: true,- };- } catch (error) {- return {- valid: false,- error: 'Please provide valid API key and domain URL.',- };- }- },-});-export const grist = createPiece({displayName: 'Grist',auth: gristAuth,- minimumSupportedRelease: '0.30.0',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/grist.png',description: 'open source spreadsheet',categories: [PieceCategory.PRODUCTIVITY],@@ -67,22 +45,43 @@ export const grist = createPiece({gristSearchRecordAction,gristUpdateRecordAction,gristUploadAttachmentsToDocumnetAction,+ gristAddRecordsAction,+ gristUpdateRecordsAction,+ gristListRecordsAction,+ gristDeleteRecordsAction,+ gristCreateDocumentAction,+ gristGetDocumentAction,+ gristUpdateDocumentAction,+ gristListTablesAction,+ gristCreateTableAction,+ gristUpdateTableAction,+ gristListColumnsAction,+ gristAddColumnsAction,+ gristUpdateColumnsAction,+ gristDeleteColumnAction,+ gristListAttachmentsAction,+ gristDownloadAttachmentAction,+ gristDownloadAttachmentsArchiveAction,+ gristUploadAttachmentAction,+ gristRemoveUnusedAttachmentsAction,+ gristRunSqlQueryAction,+ gristListOrganizationsAction,+ gristGetOrgAccessAction,+ gristListWorkspacesAction,createCustomApiCallAction({auth: gristAuth,baseUrl: (auth) => {if (!auth) {return '';}- return `${- auth.props.domain- }/api/`;+ return `${auth.props.domain}/api/`;},authMapping: async (auth) => ({- Authorization: `Bearer ${- auth.props.apiKey- }`,+ Authorization: `Bearer ${auth.props.apiKey}`,}),}),],triggers: [gristNewRecordTrigger, gristUpdatedRecordTrigger],});++export { gristAuth };diff --git a/packages/pieces/community/grist/src/lib/actions/ai/add-columns.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/add-columns.action.tsnew file mode 100644index 00000000000..ebcbc4a6efc--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/add-columns.action.ts@@ -0,0 +1,45 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristAddColumnsOutputSchema } from '../../output-schemas';++export const gristAddColumnsAction = createAction({+ auth: gristAuth,+ name: 'grist_add_columns',+ outputSchema: gristAddColumnsOutputSchema,+ displayName: 'Add Columns',+ description: 'Adds columns to a table.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds one or more columns to an existing table and returns their IDs. Not idempotent: repeating the call adds further columns (Grist renames duplicates).',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ columns: Property.Json({+ displayName: 'Columns',+ description:+ 'A JSON array like `[{"id": "Age", "fields": {"type": "Int", "label": "Age"}}]`.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, columns } = context.propsValue;+ return await client.makeRequest(+ HttpMethod.POST,+ `/docs/${documentId}/tables/${tableId}/columns`,+ undefined,+ undefined,+ { columns: gristInput.asObjectArray({ value: columns, name: 'Columns' }) }+ );+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/add-records.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/add-records.action.tsnew file mode 100644index 00000000000..a597d3c98af--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/add-records.action.ts@@ -0,0 +1,50 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristAddRecordsOutputSchema } from '../../output-schemas';++export const gristAddRecordsAction = createAction({+ auth: gristAuth,+ name: 'grist_add_records',+ outputSchema: gristAddRecordsOutputSchema,+ displayName: 'Add Records',+ description: 'Adds one or more rows to a Grist table.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Appends rows to a Grist table in one call. Each item maps column IDs to values (use **List Columns** for the column IDs; reference-list and choice-list cells take `["L", ...]`). Returns the new row IDs. Not idempotent: every call inserts new rows.',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ records: Property.Json({+ displayName: 'Records',+ description:+ 'A JSON array of objects, one per row, mapping column ID to value. Example: `[{"Name": "Ada", "Age": 36}]`.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, records } = context.propsValue;+ const rows = gristInput.asObjectArray({ value: records, name: 'Records' });+ const response = await client.makeRequest<{ records: { id: number }[] }>(+ HttpMethod.POST,+ `/docs/${documentId}/tables/${tableId}/records`,+ undefined,+ undefined,+ { records: rows.map((fields) => ({ fields })) }+ );+ return {+ record_ids: response.records.map((record) => record.id),+ count: response.records.length,+ };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/create-document.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/create-document.action.tsnew file mode 100644index 00000000000..8ac9b1bfd48--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/create-document.action.ts@@ -0,0 +1,52 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { gristCreateDocumentOutputSchema } from '../../output-schemas';++export const gristCreateDocumentAction = createAction({+ auth: gristAuth,+ name: 'grist_create_document',+ outputSchema: gristCreateDocumentOutputSchema,+ displayName: 'Create Document',+ description: 'Creates an empty document in a workspace.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a new empty Grist document in a workspace and returns its document ID. The workspace ID comes from **List Workspaces**. Not idempotent: each call creates another document.',+ idempotent: false,+ },+ props: {+ workspaceId: Property.Number({+ displayName: 'Workspace ID',+ description: 'Numeric workspace ID from the **List Workspaces** action.',+ required: true,+ }),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'Name of the new document.',+ required: false,+ }),+ isPinned: Property.Checkbox({+ displayName: 'Pin Document',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { workspaceId, name, isPinned } = context.propsValue;+ const id = await client.makeRequest<string>(+ HttpMethod.POST,+ `/workspaces/${workspaceId}/docs`,+ undefined,+ undefined,+ { ...(name ? { name } : {}), isPinned: isPinned ?? false }+ );+ return { id };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/create-table.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/create-table.action.tsnew file mode 100644index 00000000000..c7e4d7c90c4--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/create-table.action.ts@@ -0,0 +1,60 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristCreateTableOutputSchema } from '../../output-schemas';++export const gristCreateTableAction = createAction({+ auth: gristAuth,+ name: 'grist_create_table',+ outputSchema: gristCreateTableOutputSchema,+ displayName: 'Create Table',+ description: 'Creates a table with columns in a document.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds a new table with the given columns to a Grist document and returns its table ID. Not idempotent: Grist renames the table if the ID already exists, so repeating the call creates another table.',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: Property.ShortText({+ displayName: 'Table ID',+ description:+ 'Desired table ID (must start with a letter). Grist may adjust it; leave empty to let Grist choose.',+ required: false,+ }),+ columns: Property.Json({+ displayName: 'Columns',+ description:+ 'A JSON array of column definitions, e.g. `[{"id": "Name", "fields": {"type": "Text", "label": "Name"}}]`.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, columns } = context.propsValue;+ return await client.makeRequest(+ HttpMethod.POST,+ `/docs/${documentId}/tables`,+ undefined,+ undefined,+ {+ tables: [+ {+ ...(tableId ? { id: tableId } : {}),+ columns: gristInput.asObjectArray({+ value: columns,+ name: 'Columns',+ }),+ },+ ],+ }+ );+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/delete-column.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/delete-column.action.tsnew file mode 100644index 00000000000..d4820fa5a7d--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/delete-column.action.ts@@ -0,0 +1,44 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDeleteColumnOutputSchema } from '../../output-schemas';++export const gristDeleteColumnAction = createAction({+ auth: gristAuth,+ name: 'grist_delete_column',+ outputSchema: gristDeleteColumnOutputSchema,+ displayName: 'Delete Column',+ description: 'Deletes a column and its data from a table.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently removes a column and all its cell values. Get column IDs from **List Columns**. Deleting a column that is already gone fails with not found.',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ columnId: Property.ShortText({+ displayName: 'Column ID',+ description: 'The column ID from **List Columns**.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, columnId } = context.propsValue;+ await client.makeRequest(+ HttpMethod.DELETE,+ `/docs/${documentId}/tables/${tableId}/columns/${columnId}`,+ undefined,+ undefined+ );+ return { success: true };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/delete-records.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/delete-records.action.tsnew file mode 100644index 00000000000..3d9d3f40932--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/delete-records.action.ts@@ -0,0 +1,46 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDeleteRecordsOutputSchema } from '../../output-schemas';++export const gristDeleteRecordsAction = createAction({+ auth: gristAuth,+ name: 'grist_delete_records',+ outputSchema: gristDeleteRecordsOutputSchema,+ displayName: 'Delete Records',+ description: 'Deletes rows from a Grist table by row ID.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes rows by row ID (get IDs from **List Records**). Rows that no longer exist are ignored by Grist, so repeating the call is harmless.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ rowIds: Property.Array({+ displayName: 'Row IDs',+ description: 'The numeric IDs of the rows to delete.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, rowIds } = context.propsValue;+ const ids = gristInput.asNumberArray({ value: rowIds, name: 'Row IDs' });+ await client.makeRequest(+ HttpMethod.POST,+ `/docs/${documentId}/tables/${tableId}/records/delete`,+ undefined,+ undefined,+ ids+ );+ return { success: true, deleted_count: ids.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/download-attachment.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/download-attachment.action.tsnew file mode 100644index 00000000000..3bc91eb79f4--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/download-attachment.action.ts@@ -0,0 +1,47 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDownloadAttachmentsArchiveOutputSchema } from '../../output-schemas';++export const gristDownloadAttachmentAction = createAction({+ auth: gristAuth,+ name: 'grist_download_attachment',+ outputSchema: gristDownloadAttachmentsArchiveOutputSchema,+ displayName: 'Download Attachment',+ description: 'Downloads one attachment as a file.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Downloads the contents of one attachment by ID and returns a file reference plus its name. Get the ID from **List Attachments** or a record's Attachments cell.",+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ attachmentId: Property.Number({+ displayName: 'Attachment ID',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, attachmentId } = context.propsValue;+ const metadata = await client.makeRequest<{ fileName?: string }>(+ HttpMethod.GET,+ `/docs/${documentId}/attachments/${attachmentId}`,+ undefined,+ undefined+ );+ const content = await client.download(+ `/docs/${documentId}/attachments/${attachmentId}/download`+ );+ const fileName = metadata.fileName ?? `attachment-${attachmentId}`;+ const file = await context.files.write({ fileName, data: content });+ return { file, file_name: fileName, size: content.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/download-attachments-archive.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/download-attachments-archive.action.tsnew file mode 100644index 00000000000..e7294c0f4a1--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/download-attachments-archive.action.ts@@ -0,0 +1,49 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDownloadAttachmentsArchiveOutputSchema } from '../../output-schemas';++export const gristDownloadAttachmentsArchiveAction = createAction({+ auth: gristAuth,+ name: 'grist_download_attachments_archive',+ outputSchema: gristDownloadAttachmentsArchiveOutputSchema,+ displayName: 'Download Attachments Archive',+ description: 'Downloads all attachments of a document as one archive.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Downloads every attachment in a document as a single zip or tar file. Can be large; prefer **Download Attachment** when you need one file.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ format: Property.StaticDropdown({+ displayName: 'Format',+ required: false,+ defaultValue: 'zip',+ options: {+ options: [+ { label: 'Zip', value: 'zip' },+ { label: 'Tar', value: 'tar' },+ ],+ },+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, format } = context.propsValue;+ const extension = format ?? 'zip';+ const content = await client.download(+ `/docs/${documentId}/attachments/archive`,+ { format: extension }+ );+ const fileName = `${documentId}-attachments.${extension}`;+ const file = await context.files.write({ fileName, data: content });+ return { file, file_name: fileName, size: content.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/get-document.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/get-document.action.tsnew file mode 100644index 00000000000..fc6460ee583--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/get-document.action.ts@@ -0,0 +1,34 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristGetDocumentOutputSchema } from '../../output-schemas';++export const gristGetDocumentAction = createAction({+ auth: gristAuth,+ name: 'grist_get_document',+ outputSchema: gristGetDocumentOutputSchema,+ displayName: 'Get Document',+ description: 'Gets the metadata of a document.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Returns a Grist document's name, access level, pinned state and workspace. Use it to confirm a document ID before working on its tables.",+ idempotent: true,+ },+ props: { documentId: commonProps.document_id_text },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ return await client.makeRequest(+ HttpMethod.GET,+ `/docs/${context.propsValue.documentId}`,+ undefined,+ undefined+ );+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/get-org-access.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/get-org-access.action.tsnew file mode 100644index 00000000000..69223dd84b6--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/get-org-access.action.ts@@ -0,0 +1,34 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { commonProps } from '../../common/props';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { gristGetOrgAccessOutputSchema } from '../../output-schemas';++export const gristGetOrgAccessAction = createAction({+ auth: gristAuth,+ name: 'grist_get_org_access',+ outputSchema: gristGetOrgAccessOutputSchema,+ displayName: 'Get Org Access',+ description: 'Lists the users with access to an organization.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns the users of an organization with their emails and access roles (owner, editor, viewer). Use it to look up user IDs or check permissions.',+ idempotent: true,+ },+ props: { orgId: commonProps.org_id_text },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ return await client.makeRequest(+ HttpMethod.GET,+ `/orgs/${context.propsValue.orgId || 'current'}/access`,+ undefined,+ undefined+ );+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-attachments.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-attachments.action.tsnew file mode 100644index 00000000000..42c6f7f3c0a--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-attachments.action.ts@@ -0,0 +1,48 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristListAttachmentsOutputSchema } from '../../output-schemas';++export const gristListAttachmentsAction = createAction({+ auth: gristAuth,+ name: 'grist_list_attachments',+ outputSchema: gristListAttachmentsOutputSchema,+ displayName: 'List Attachments',+ description: 'Lists the attachments stored in a document.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns metadata (ID, file name, size, upload time) of the attachments in a document. Use it to get the attachment ID for **Download Attachment**.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ sort: Property.ShortText({+ displayName: 'Sort',+ description:+ 'Optional comma-separated fields, prefix `-` for descending.',+ required: false,+ }),+ limit: Property.Number({+ displayName: 'Limit',+ required: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, sort, limit } = context.propsValue;+ const response = await client.makeRequest<{+ records: { id: number; fields: Record<string, unknown> }[];+ }>(HttpMethod.GET, `/docs/${documentId}/attachments`, undefined, {+ sort: sort || undefined,+ limit: limit ?? undefined,+ });+ return { attachments: response.records, count: response.records.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-columns.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-columns.action.tsnew file mode 100644index 00000000000..262ade82a15--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-columns.action.ts@@ -0,0 +1,44 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristListColumnsOutputSchema } from '../../output-schemas';++export const gristListColumnsAction = createAction({+ auth: gristAuth,+ name: 'grist_list_columns',+ outputSchema: gristListColumnsOutputSchema,+ displayName: 'List Columns',+ description: 'Lists the columns of a table.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Returns each column's ID, type, label and formula flag for a table. Use it to learn the column IDs and types needed by record actions.",+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ includeHidden: Property.Checkbox({+ displayName: 'Include Hidden Columns',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, includeHidden } = context.propsValue;+ const response = await client.makeRequest<{ columns: unknown[] }>(+ HttpMethod.GET,+ `/docs/${documentId}/tables/${tableId}/columns`,+ undefined,+ { hidden: includeHidden ? 'true' : undefined }+ );+ return { columns: response.columns, count: response.columns.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-organizations.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-organizations.action.tsnew file mode 100644index 00000000000..5e86903d1e5--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-organizations.action.ts@@ -0,0 +1,34 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { gristListOrganizationsOutputSchema } from '../../output-schemas';++export const gristListOrganizationsAction = createAction({+ auth: gristAuth,+ name: 'grist_list_organizations',+ outputSchema: gristListOrganizationsOutputSchema,+ displayName: 'List Organizations',+ description: 'Lists the organizations you can access.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the Grist orgs (team sites and personal areas) the API key can access, with their IDs and your access level.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const organizations = await client.makeRequest<unknown[]>(+ HttpMethod.GET,+ '/orgs',+ undefined,+ undefined+ );+ return { organizations, count: organizations.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-records.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-records.action.tsnew file mode 100644index 00000000000..b37bfb85e40--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-records.action.ts@@ -0,0 +1,68 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristListRecordsOutputSchema } from '../../output-schemas';++export const gristListRecordsAction = createAction({+ auth: gristAuth,+ name: 'grist_list_records',+ outputSchema: gristListRecordsOutputSchema,+ displayName: 'List Records',+ description: 'Lists rows of a Grist table, optionally filtered and sorted.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Reads rows from a Grist table with optional exact-match filters, sort and limit (default 100 rows; Grist has no paging, so narrow with a filter or sort to reach other rows). Use it to find row IDs before updating or deleting. Filter values are matched exactly against the listed values for each column.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ filter: Property.Json({+ displayName: 'Filter',+ description:+ 'Optional JSON object mapping column ID to the list of accepted values. Example: `{"Status": ["Open", "Pending"]}`.',+ required: false,+ }),+ sort: Property.ShortText({+ displayName: 'Sort',+ description:+ 'Optional comma-separated column IDs; prefix with `-` for descending, e.g. `-Age,Name`.',+ required: false,+ }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Maximum number of rows to return. Defaults to 100.',+ defaultValue: 100,+ required: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, filter, sort, limit } = context.propsValue;+ const response = await client.makeRequest<{+ records: { id: number; fields: Record<string, unknown> }[];+ }>(+ HttpMethod.GET,+ `/docs/${documentId}/tables/${tableId}/records`,+ undefined,+ {+ filter:+ filter === undefined || filter === null+ ? undefined+ : JSON.stringify(+ gristInput.asObject({ value: filter, name: 'Filter' })+ ),+ sort: sort || undefined,+ limit: limit ?? 100,+ }+ );+ return { records: response.records, count: response.records.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-tables.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-tables.action.tsnew file mode 100644index 00000000000..97717c2b7cb--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-tables.action.ts@@ -0,0 +1,44 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristListTablesOutputSchema } from '../../output-schemas';++export const gristListTablesAction = createAction({+ auth: gristAuth,+ name: 'grist_list_tables',+ outputSchema: gristListTablesOutputSchema,+ displayName: 'List Tables',+ description: 'Lists the tables in a document.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns the table IDs of a Grist document (optionally with their columns). Use it to get the table ID that record, column and SQL actions need.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ includeColumns: Property.Checkbox({+ displayName: 'Include Columns',+ description: "Also return each table's columns.",+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, includeColumns } = context.propsValue;+ const response = await client.makeRequest<{ tables: unknown[] }>(+ HttpMethod.GET,+ `/docs/${documentId}/tables`,+ undefined,+ { expand: includeColumns ? 'column' : undefined }+ );+ return { tables: response.tables, count: response.tables.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/list-workspaces.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/list-workspaces.action.tsnew file mode 100644index 00000000000..1803cab77fe--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/list-workspaces.action.ts@@ -0,0 +1,35 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { commonProps } from '../../common/props';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { gristListWorkspacesOutputSchema } from '../../output-schemas';++export const gristListWorkspacesAction = createAction({+ auth: gristAuth,+ name: 'grist_list_workspaces',+ outputSchema: gristListWorkspacesOutputSchema,+ displayName: 'List Workspaces',+ description: 'Lists the workspaces and documents of an organization.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Returns every workspace in an org together with the documents each contains. This is where workspace IDs (for **Create Document**) and document IDs (for every other action) come from.',+ idempotent: true,+ },+ props: { orgId: commonProps.org_id_text },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const workspaces = await client.makeRequest<unknown[]>(+ HttpMethod.GET,+ `/orgs/${context.propsValue.orgId || 'current'}/workspaces`,+ undefined,+ undefined+ );+ return { workspaces, count: workspaces.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/remove-unused-attachments.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/remove-unused-attachments.action.tsnew file mode 100644index 00000000000..edcc36e4ff9--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/remove-unused-attachments.action.ts@@ -0,0 +1,45 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDeleteColumnOutputSchema } from '../../output-schemas';++export const gristRemoveUnusedAttachmentsAction = createAction({+ auth: gristAuth,+ name: 'grist_remove_unused_attachments',+ outputSchema: gristDeleteColumnOutputSchema,+ displayName: 'Remove Unused Attachments',+ description: 'Deletes attachments that no cell references.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes ALL attachments in a document that no Attachments cell references (it cannot target one attachment). To delete a specific file, first clear its cell with **Update Records**, then run this. Repeating it is harmless.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ expiredOnly: Property.Checkbox({+ displayName: 'Expired Only',+ description:+ 'Only remove attachments unreferenced for longer than the server retention period.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, expiredOnly } = context.propsValue;+ await client.makeRequest(+ HttpMethod.POST,+ `/docs/${documentId}/attachments/removeUnused`,+ undefined,+ { expiredOnly: expiredOnly ? 'true' : undefined }+ );+ return { success: true };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/run-sql-query.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/run-sql-query.action.tsnew file mode 100644index 00000000000..f53e1c94fcb--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/run-sql-query.action.ts@@ -0,0 +1,53 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristRunSqlQueryOutputSchema } from '../../output-schemas';++export const gristRunSqlQueryAction = createAction({+ auth: gristAuth,+ name: 'grist_run_sql_query',+ outputSchema: gristRunSqlQueryOutputSchema,+ displayName: 'Run SQL Query',+ description: 'Runs a read-only SQL SELECT query against a document.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Runs a SQLite SELECT statement against a Grist document (table IDs are SQL table names) and returns rows shaped as `{fields: {...}}`. Use `?` placeholders with Arguments. Read-only; use it for joins and aggregates that **List Records** cannot do.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ sql: Property.LongText({+ displayName: 'SQL',+ description: 'A single SELECT statement.',+ required: true,+ }),+ args: Property.Array({+ displayName: 'Arguments',+ description: 'Values for the `?` placeholders, in order.',+ required: false,+ }),+ timeout: Property.Number({+ displayName: 'Timeout (ms)',+ required: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, sql, args, timeout } = context.propsValue;+ const response = await client.makeRequest<{+ records: { fields: Record<string, unknown> }[];+ }>(HttpMethod.POST, `/docs/${documentId}/sql`, undefined, undefined, {+ sql,+ ...(args && args.length > 0 ? { args } : {}),+ ...(timeout ? { timeout } : {}),+ });+ return { rows: response.records, count: response.records.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/update-columns.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/update-columns.action.tsnew file mode 100644index 00000000000..4758ae24cbc--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/update-columns.action.ts@@ -0,0 +1,50 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristUpdateColumnsOutputSchema } from '../../output-schemas';++export const gristUpdateColumnsAction = createAction({+ auth: gristAuth,+ name: 'grist_update_columns',+ outputSchema: gristUpdateColumnsOutputSchema,+ displayName: 'Update Columns',+ description: 'Changes the settings of existing columns.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Updates column settings (label, type, formula, widget options) by column ID; only the supplied fields change. Changing a label also renames the column ID unless `untieColIdFromLabel` is true, so re-list columns before using the ID again. Not safe to repeat after a rename: the old column ID no longer exists.',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ columns: Property.Json({+ displayName: 'Columns',+ description:+ 'A JSON array like `[{"id": "Age", "fields": {"label": "Years"}}]`.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, columns } = context.propsValue;+ const items = gristInput.asObjectArray({ value: columns, name: 'Columns' });+ items.forEach((item) =>+ gristInput.asObject({ value: item['fields'], name: 'Each column fields' })+ );+ await client.makeRequest(+ HttpMethod.PATCH,+ `/docs/${documentId}/tables/${tableId}/columns`,+ undefined,+ undefined,+ { columns: items }+ );+ return { success: true, updated_count: items.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/update-document.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/update-document.action.tsnew file mode 100644index 00000000000..6b6c850fb69--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/update-document.action.ts@@ -0,0 +1,61 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDeleteColumnOutputSchema } from '../../output-schemas';++export const gristUpdateDocumentAction = createAction({+ auth: gristAuth,+ name: 'grist_update_document',+ outputSchema: gristDeleteColumnOutputSchema,+ displayName: 'Update Document',+ description: 'Renames or pins/unpins a document.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Changes a document's name and/or pinned state; omitted fields are left unchanged. Does not touch document contents. Setting the same values again is a no-op.",+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ name: Property.ShortText({+ displayName: 'Name',+ description: 'New document name. Leave empty to keep the current name.',+ required: false,+ }),+ isPinned: Property.StaticDropdown({+ displayName: 'Pinned',+ description: 'Leave unset to keep the current pinned state.',+ required: false,+ options: {+ options: [+ { label: 'Pinned', value: 'true' },+ { label: 'Not pinned', value: 'false' },+ ],+ },+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, name, isPinned } = context.propsValue;+ if (!name && !isPinned) {+ throw new Error('Provide a name or a pinned state to update.');+ }+ await client.makeRequest(+ HttpMethod.PATCH,+ `/docs/${documentId}`,+ undefined,+ undefined,+ {+ ...(name ? { name } : {}),+ ...(isPinned ? { isPinned: isPinned === 'true' } : {}),+ }+ );+ return { success: true };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/update-records.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/update-records.action.tsnew file mode 100644index 00000000000..a7855265470--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/update-records.action.ts@@ -0,0 +1,53 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristUpdateColumnsOutputSchema } from '../../output-schemas';++export const gristUpdateRecordsAction = createAction({+ auth: gristAuth,+ name: 'grist_update_records',+ outputSchema: gristUpdateColumnsOutputSchema,+ displayName: 'Update Records',+ description: 'Updates fields of existing rows in a Grist table.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Partially updates existing rows by row ID: only the columns you list change, other cells keep their values. Row IDs come from **List Records** or **Add Records**. Setting the same values again is a no-op.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ records: Property.Json({+ displayName: 'Records',+ description:+ 'A JSON array of `{"id": <rowId>, "fields": {"<columnId>": <value>}}` objects.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, records } = context.propsValue;+ const rows = gristInput.asObjectArray({ value: records, name: 'Records' });+ rows.forEach((row) => {+ gristInput.asObject({ value: row['fields'], name: 'Each record fields' });+ if (typeof row['id'] !== 'number') {+ throw new Error('Each record needs a numeric id.');+ }+ });+ await client.makeRequest(+ HttpMethod.PATCH,+ `/docs/${documentId}/tables/${tableId}/records`,+ undefined,+ undefined,+ { records: rows }+ );+ return { success: true, updated_count: rows.length };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/update-table.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/update-table.action.tsnew file mode 100644index 00000000000..dc7bf64547d--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/update-table.action.ts@@ -0,0 +1,52 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { gristAuth } from '../../auth';+import { GristAPIClient, gristInput } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristDeleteColumnOutputSchema } from '../../output-schemas';++export const gristUpdateTableAction = createAction({+ auth: gristAuth,+ name: 'grist_update_table',+ outputSchema: gristDeleteColumnOutputSchema,+ displayName: 'Update Table',+ description: 'Changes table settings such as its ID.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Updates table-level settings (for example renaming via `{"tableId": "NewName"}` or `{"onDemand": true}`). Only the fields supplied change. Setting the same values again is a no-op.',+ idempotent: true,+ },+ props: {+ documentId: commonProps.document_id_text,+ tableId: commonProps.table_id_text,+ fields: Property.Json({+ displayName: 'Fields',+ description: 'A JSON object of table fields to change.',+ required: true,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, tableId, fields } = context.propsValue;+ await client.makeRequest(+ HttpMethod.PATCH,+ `/docs/${documentId}/tables`,+ undefined,+ undefined,+ {+ tables: [+ {+ id: tableId,+ fields: gristInput.asObject({ value: fields, name: 'Fields' }),+ },+ ],+ }+ );+ return { success: true };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/ai/upload-attachment.action.ts b/packages/pieces/community/grist/src/lib/actions/ai/upload-attachment.action.tsnew file mode 100644index 00000000000..61703c5cbd0--- /dev/null+++ b/packages/pieces/community/grist/src/lib/actions/ai/upload-attachment.action.ts@@ -0,0 +1,62 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import FormData from 'form-data';+import { gristAuth } from '../../auth';+import { GristAPIClient } from '../../common/helpers';+import { commonProps } from '../../common/props';+import { gristUploadAttachmentOutputSchema } from '../../output-schemas';++export const gristUploadAttachmentAction = createAction({+ auth: gristAuth,+ name: 'grist_upload_attachment',+ outputSchema: gristUploadAttachmentOutputSchema,+ displayName: 'Upload Attachment',+ description: 'Uploads a file to a document.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Uploads a file into a Grist document and returns its attachment ID and metadata. To show it in a table, set an Attachments column cell to `["L", <attachmentId>]` with **Update Records**. Not idempotent: each call stores a new attachment.',+ idempotent: false,+ },+ props: {+ documentId: commonProps.document_id_text,+ attachment: Property.File({+ displayName: 'Attachment',+ required: true,+ }),+ attachmentName: Property.ShortText({+ displayName: 'Attachment Name',+ description: 'Overrides the file name.',+ required: false,+ }),+ },+ async run(context) {+ const client = new GristAPIClient({+ domainUrl: context.auth.props.domain,+ apiKey: context.auth.props.apiKey,+ });+ const { documentId, attachment, attachmentName } = context.propsValue;+ const formData = new FormData();+ formData.append(+ 'upload',+ Buffer.from(attachment.base64, 'base64'),+ attachmentName || attachment.filename+ );+ const uploaded = await client.makeRequest<number[]>(+ HttpMethod.POST,+ `/docs/${documentId}/attachments`,+ { ...formData.getHeaders() },+ undefined,+ formData+ );+ const id = uploaded[0];+ const metadata = await client.makeRequest<{ fileName?: string }>(+ HttpMethod.GET,+ `/docs/${documentId}/attachments/${id}`,+ undefined,+ undefined+ );+ return { id, fields: metadata };+ },+});diff --git a/packages/pieces/community/grist/src/lib/actions/create-record.action.ts b/packages/pieces/community/grist/src/lib/actions/create-record.action.tsindex b839a9dc081..4ce2664e09f 100644--- a/packages/pieces/community/grist/src/lib/actions/create-record.action.ts+++ b/packages/pieces/community/grist/src/lib/actions/create-record.action.ts@@ -2,14 +2,16 @@ import { gristAuth } from '../..';import { createAction } from '@activepieces/pieces-framework';import { commonProps } from '../common/props';import { GristAPIClient, transformTableColumnValues } from '../common/helpers';+import { gristCreateRecordOutputSchema } from '../output-schemas';export const gristCreateRecordAction = createAction({auth: gristAuth,name: 'grist-create-record',+ outputSchema: gristCreateRecordOutputSchema,classification: 'WRITE',displayName: 'Create Record',description: 'Creates a new record in specific table.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Adds one new row to a Grist table, mapping the values you supply onto that table\'s columns. Use it to append data to a known document/table; requires the document and table identifiers. Not idempotent — each call inserts another record even with identical input.', idempotent: false },props: {workspace_id: commonProps.workspace_id,diff --git a/packages/pieces/community/grist/src/lib/actions/search-record.action.ts b/packages/pieces/community/grist/src/lib/actions/search-record.action.tsindex 2436305f0ff..4772c6cf2df 100644--- a/packages/pieces/community/grist/src/lib/actions/search-record.action.ts+++ b/packages/pieces/community/grist/src/lib/actions/search-record.action.ts@@ -9,14 +9,16 @@ import { commonProps } from '../common/props';import { GristAPIClient } from '../common/helpers';import { HttpMethod } from '@activepieces/pieces-common';+import { gristSearchRecordOutputSchema } from '../output-schemas';export const gristSearchRecordAction = createAction({auth: gristAuth,name: 'grist-search-record',+ outputSchema: gristSearchRecordOutputSchema,classification: 'SEARCH',displayName: 'Search Record',description: 'Search record by matching criteria.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Looks up records in a Grist table by filtering one chosen column against a value. Use it to find rows before reading or updating them; the match is case-sensitive, exact, and only works on Text-type columns. Read-only and idempotent.', idempotent: true },props: {workspace_id: commonProps.workspace_id,diff --git a/packages/pieces/community/grist/src/lib/actions/update-record.action.ts b/packages/pieces/community/grist/src/lib/actions/update-record.action.tsindex d62d7e24dcd..0dc4847f0c7 100644--- a/packages/pieces/community/grist/src/lib/actions/update-record.action.ts+++ b/packages/pieces/community/grist/src/lib/actions/update-record.action.ts@@ -2,14 +2,16 @@ import { gristAuth } from '../..';import { createAction, Property } from '@activepieces/pieces-framework';import { commonProps } from '../common/props';import { GristAPIClient, transformTableColumnValues } from '../common/helpers';+import { gristUpdateRecordOutputSchema } from '../output-schemas';export const gristUpdateRecordAction = createAction({auth: gristAuth,name: 'grist-update-record',+ outputSchema: gristUpdateRecordOutputSchema,classification: 'WRITE',displayName: 'Update Record',description: 'Updates an existing record in specific table.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Updates the fields of an existing Grist record identified by its numeric Record ID in a given document/table. Use it to modify a row you already know the ID of (typically from a search or trigger). Idempotent — re-running with the same ID and values leaves the record in the same state.', idempotent: true },props: {workspace_id: commonProps.workspace_id,diff --git a/packages/pieces/community/grist/src/lib/actions/upload-attachments-to-document.action.ts b/packages/pieces/community/grist/src/lib/actions/upload-attachments-to-document.action.tsindex f118707fc67..b9fa1735a0a 100644--- a/packages/pieces/community/grist/src/lib/actions/upload-attachments-to-document.action.ts+++ b/packages/pieces/community/grist/src/lib/actions/upload-attachments-to-document.action.ts@@ -8,14 +8,16 @@ import {HttpMethod,} from '@activepieces/pieces-common';import { GristAPIClient } from '../common/helpers';+import { gristUploadAttachmentOutputSchema } from '../output-schemas';export const gristUploadAttachmentsToDocumnetAction = createAction({auth: gristAuth,name: 'grist-upload-attachments-to-document',+ outputSchema: gristUploadAttachmentOutputSchema,classification: 'WRITE',displayName: 'Upload Attachment to Document',description: 'Uploads attachments to specific document.',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Uploads a file as an attachment to a specific Grist document and returns its attachment metadata. Use it to store a file in Grist before referencing it from an attachment-type column; requires the document identifier and a file. Not idempotent — each call uploads a new attachment with a fresh ID.', idempotent: false },props: {workspace_id: commonProps.workspace_id,diff --git a/packages/pieces/community/grist/src/lib/auth.ts b/packages/pieces/community/grist/src/lib/auth.tsnew file mode 100644index 00000000000..332b17338ce--- /dev/null+++ b/packages/pieces/community/grist/src/lib/auth.ts@@ -0,0 +1,41 @@+import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { GristAPIClient } from './common/helpers';++export const gristAuth = PieceAuth.CustomAuth({+ required: true,+ description: `+ Log in to your Grist account. Navigate to the account menu at the top right, and select **Profile Settings** to manage or create your API Key.+ In the **Domain URL** field, enter the domain URL of your Grist instance.For example,if you have team site it will be "https://team.getgist.com".`,+ props: {+ apiKey: PieceAuth.SecretText({+ displayName: 'API Key',+ required: true,+ }),+ domain: Property.ShortText({+ displayName: 'Domain URL',+ required: true,+ defaultValue: 'https://docs.getgrist.com',+ }),+ },+ validate: async ({ auth }) => {+ try {+ const authValue = auth;++ const client = new GristAPIClient({+ domainUrl: authValue.domain,+ apiKey: authValue.apiKey,+ });++ await client.listOrgs();++ return {+ valid: true,+ };+ } catch (error) {+ return {+ valid: false,+ error: 'Please provide valid API key and domain URL.',+ };+ }+ },+});diff --git a/packages/pieces/community/grist/src/lib/common/helpers.ts b/packages/pieces/community/grist/src/lib/common/helpers.tsindex 9441168ecd0..1fd51c3e346 100644--- a/packages/pieces/community/grist/src/lib/common/helpers.ts+++ b/packages/pieces/community/grist/src/lib/common/helpers.ts@@ -63,6 +63,27 @@ export class GristAPIClient {return response.body;}+ async download(resourceUri: string, query?: Query) {+ const baseUrl = this.#domaiUrl.replace(/\/$/, '');+ const queryParams: QueryParams = {};+ for (const [key, value] of Object.entries(query ?? {})) {+ if (value !== undefined) {+ queryParams[key] = String(value);+ }+ }+ const response = await httpClient.sendRequest<Buffer>({+ method: HttpMethod.GET,+ url: baseUrl + '/api' + resourceUri,+ authentication: {+ type: AuthenticationType.BEARER_TOKEN,+ token: this.#apiKey,+ },+ queryParams,+ responseType: 'arraybuffer',+ });+ return response.body;+ }+async listOrgs() {return await this.makeRequest<GristOrgResponse[]>(HttpMethod.GET,@@ -217,3 +238,52 @@ export function transformTableColumnValues({return fields;}++function asObject({+ value,+ name,+}: {+ value: unknown;+ name: string;+}): Record<string, unknown> {+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {+ return Object.fromEntries(Object.entries(value));+ }+ throw new Error(`${name} must be a JSON object.`);+}++function asObjectArray({+ value,+ name,+}: {+ value: unknown;+ name: string;+}): Record<string, unknown>[] {+ if (!Array.isArray(value) || value.length === 0) {+ throw new Error(`${name} must be a non-empty JSON array of objects.`);+ }+ return value.map((item) =>+ asObject({ value: item, name: `Each item of ${name}` })+ );+}++function asNumberArray({+ value,+ name,+}: {+ value: unknown;+ name: string;+}): number[] {+ if (!Array.isArray(value) || value.length === 0) {+ throw new Error(`${name} must be a non-empty list of numbers.`);+ }+ return value.map((item) => {+ const parsed = Number(item);+ if (!Number.isFinite(parsed)) {+ throw new Error(`${name} contains a non-numeric value: ${String(item)}`);+ }+ return parsed;+ });+}++export const gristInput = { asObject, asObjectArray, asNumberArray };diff --git a/packages/pieces/community/grist/src/lib/common/props.ts b/packages/pieces/community/grist/src/lib/common/props.tsindex 24286878694..94d12fcdf4e 100644--- a/packages/pieces/community/grist/src/lib/common/props.ts+++ b/packages/pieces/community/grist/src/lib/common/props.ts@@ -4,10 +4,29 @@ import {PiecePropValueSchema,Property,} from '@activepieces/pieces-framework';-import { gristAuth } from '../..';+import { gristAuth } from '../auth';import { GristAPIClient } from './helpers';export const commonProps = {+ org_id_text: Property.ShortText({+ displayName: 'Organization ID',+ description:+ 'Numeric org ID or subdomain from **List Organizations**. Use `current` for the site in the connection domain.',+ required: false,+ defaultValue: 'current',+ }),+ document_id_text: Property.ShortText({+ displayName: 'Document ID',+ description:+ 'The Grist document ID (a string like `kRosSWLjYzm7iaHwV6XnXM`). Get it from the **List Workspaces** action.',+ required: true,+ }),+ table_id_text: Property.ShortText({+ displayName: 'Table ID',+ description:+ 'The table ID, as returned by the **List Tables** action (for example `Table1`).',+ required: true,+ }),workspace_id: Property.Dropdown({displayName: 'Workspace',refreshers: [],diff --git a/packages/pieces/community/grist/src/lib/output-schemas.ts b/packages/pieces/community/grist/src/lib/output-schemas.tsnew file mode 100644index 00000000000..8fc6dd3f4b2--- /dev/null+++ b/packages/pieces/community/grist/src/lib/output-schemas.ts@@ -0,0 +1,309 @@+import { OutputSchema } from '@activepieces/pieces-framework';++export const gristAddColumnsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'columns',+ label: 'Columns',+ labelKey: 'id',+ listItems: [{ key: 'id', label: 'ID' }],+ },+ ],+};++export const gristAddRecordsOutputSchema: OutputSchema = {+ fields: [+ { key: 'record_ids', label: 'Record IDs' },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristDownloadAttachmentsArchiveOutputSchema: OutputSchema = {+ fields: [+ { key: 'file', label: 'File', format: 'url' },+ { key: 'file_name', label: 'File Name' },+ { key: 'size', label: 'Size', format: 'filesize' },+ ],+};++export const gristCreateDocumentOutputSchema: OutputSchema = {+ fields: [{ key: 'id', label: 'ID' }],+};++export const gristCreateTableOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'tables',+ label: 'Tables',+ labelKey: 'id',+ listItems: [{ key: 'id', label: 'ID' }],+ },+ ],+};++export const gristDeleteColumnOutputSchema: OutputSchema = {+ fields: [{ key: 'success', label: 'Success', format: 'boolean' }],+};++export const gristDeleteRecordsOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'deleted_count', label: 'Deleted Count', format: 'number' },+ ],+};++export const gristGetDocumentOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'ID' },+ { key: 'name', label: 'Name' },+ { key: 'access', label: 'Access' },+ { key: 'isPinned', label: 'Is Pinned', format: 'boolean' },+ { key: 'urlId', label: 'URL ID' },+ { key: 'type', label: 'Type' },+ { key: 'createdAt', label: 'Created At', format: 'datetime' },+ { key: 'updatedAt', label: 'Updated At', format: 'datetime' },+ {+ key: 'workspace',+ label: 'Workspace',+ children: [+ { key: 'id', label: 'ID', format: 'number' },+ { key: 'name', label: 'Name' },+ { key: 'access', label: 'Access' },+ {+ key: 'org',+ label: 'Organization',+ children: [+ { key: 'id', label: 'ID', format: 'number' },+ { key: 'name', label: 'Name' },+ { key: 'domain', label: 'Domain' },+ ],+ },+ ],+ },+ ],+};++export const gristListAttachmentsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'attachments',+ label: 'Attachments',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'ID', format: 'number' },+ {+ key: 'fields',+ label: 'Fields',+ children: [+ { key: 'fileName', label: 'File Name' },+ { key: 'fileSize', label: 'File Size', format: 'filesize' },+ { key: 'timeUploaded', label: 'Time Uploaded', format: 'datetime' },+ ],+ },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristListColumnsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'columns',+ label: 'Columns',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Column ID' },+ {+ key: 'fields',+ label: 'Fields',+ children: [+ { key: 'label', label: 'Label' },+ { key: 'type', label: 'Type' },+ { key: 'isFormula', label: 'Is Formula', format: 'boolean' },+ { key: 'formula', label: 'Formula' },+ { key: 'widgetOptions', label: 'Widget Options' },+ { key: 'description', label: 'Description' },+ ],+ },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristListRecordsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'records',+ label: 'Records',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Row ID', format: 'number' },+ { key: 'fields', label: 'Fields', dynamicKey: true },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristListTablesOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'tables',+ label: 'Tables',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Table ID' },+ {+ key: 'fields',+ label: 'Fields',+ children: [+ { key: 'onDemand', label: 'On Demand', format: 'boolean' },+ ],+ },+ {+ key: 'columns',+ label: 'Columns',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Column ID' },+ {+ key: 'fields',+ label: 'Fields',+ children: [+ { key: 'label', label: 'Label' },+ { key: 'type', label: 'Type' },+ ],+ },+ ],+ },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristGetOrgAccessOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'users',+ label: 'Users',+ labelKey: 'name',+ listItems: [+ { key: 'id', label: 'ID', format: 'number' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'name', label: 'Name' },+ { key: 'picture', label: 'Picture', format: 'url' },+ { key: 'ref', label: 'Ref' },+ { key: 'access', label: 'Access' },+ { key: 'isMember', label: 'Is Member', format: 'boolean' },+ ],+ },+ ],+};++export const gristListOrganizationsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'organizations',+ label: 'Organizations',+ labelKey: 'name',+ listItems: [+ { key: 'id', label: 'ID', format: 'number' },+ { key: 'name', label: 'Name' },+ { key: 'domain', label: 'Domain' },+ { key: 'access', label: 'Access' },+ { key: 'createdAt', label: 'Created At', format: 'datetime' },+ { key: 'updatedAt', label: 'Updated At', format: 'datetime' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristRunSqlQueryOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'rows',+ label: 'Rows',+ listItems: [{ key: 'fields', label: 'Fields', dynamicKey: true }],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristNewRecordOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Row ID', format: 'number' },+ { key: 'manualSort', label: 'Manual Sort', format: 'number' },+ ],+};++export const gristUpdateColumnsOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'updated_count', label: 'Updated Count', format: 'number' },+ ],+};++export const gristUploadAttachmentOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'ID', format: 'number' },+ {+ key: 'fields',+ label: 'Fields',+ children: [+ { key: 'fileName', label: 'File Name' },+ { key: 'fileSize', label: 'File Size', format: 'filesize' },+ { key: 'timeUploaded', label: 'Time Uploaded', format: 'datetime' },+ ],+ },+ ],+};++export const gristListWorkspacesOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'workspaces',+ label: 'Workspaces',+ labelKey: 'name',+ listItems: [+ { key: 'id', label: 'ID', format: 'number' },+ { key: 'name', label: 'Name' },+ { key: 'access', label: 'Access' },+ { key: 'orgDomain', label: 'Org Domain' },+ { key: 'docs', label: 'Documents', labelKey: 'name' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const gristCreateRecordOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Row ID', format: 'number' },+ { key: 'fields', label: 'Fields', dynamicKey: true },+ ],+};++export const gristSearchRecordOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'records',+ label: 'Records',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Row ID', format: 'number' },+ { key: 'fields', label: 'Fields', dynamicKey: true },+ ],+ },+ ],+};++export const gristUpdateRecordOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Row ID', format: 'number' },+ { key: 'fields', label: 'Updated Fields', dynamicKey: true },+ ],+};diff --git a/packages/pieces/community/grist/src/lib/triggers/new-record.trigger.ts b/packages/pieces/community/grist/src/lib/triggers/new-record.trigger.tsindex d1fc34b174f..7e6536abfb3 100644--- a/packages/pieces/community/grist/src/lib/triggers/new-record.trigger.ts+++ b/packages/pieces/community/grist/src/lib/triggers/new-record.trigger.ts@@ -3,10 +3,12 @@ import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';import { commonProps } from '../common/props';import { GristAPIClient } from '../common/helpers';import { GristWebhookPayload } from '../common/types';+import { gristNewRecordOutputSchema } from '../output-schemas';export const gristNewRecordTrigger = createTrigger({auth: gristAuth,name: 'grist-new-record',+ outputSchema: gristNewRecordOutputSchema,classification: 'READ',displayName: 'New Record',description: 'Triggers when a new record is added to the table.',diff --git a/packages/pieces/community/grist/src/lib/triggers/updated-record.trigger.ts b/packages/pieces/community/grist/src/lib/triggers/updated-record.trigger.tsindex d545cf75f21..7ed11e94dd4 100644--- a/packages/pieces/community/grist/src/lib/triggers/updated-record.trigger.ts+++ b/packages/pieces/community/grist/src/lib/triggers/updated-record.trigger.ts@@ -3,10 +3,12 @@ import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';import { commonProps } from '../common/props';import { GristAPIClient } from '../common/helpers';import { GristWebhookPayload } from '../common/types';+import { gristNewRecordOutputSchema } from '../output-schemas';export const gristUpdatedRecordTrigger = createTrigger({auth: gristAuth,name: 'grist-updated-record',+ outputSchema: gristNewRecordOutputSchema,classification: 'READ',displayName: 'Updated Record',description: 'Triggers when a record is updated in the table.',