fix(grain): fixed output and dropdown (#2685)

* fixed output and dropdown

* changed payload

* removed comments
This commit is contained in:
Adam Gough
2026-01-05 17:05:45 -08:00
committed by GitHub
parent cc3f565d5e
commit 445932c1c8
8 changed files with 175 additions and 356 deletions

View File

@@ -2,6 +2,7 @@ import { GrainIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import { AuthMode } from '@/blocks/types'
import { getTrigger } from '@/triggers'
import { grainTriggerOptions } from '@/triggers/grain/utils'
export const GrainBlock: BlockConfig = {
type: 'grain',
@@ -207,13 +208,21 @@ export const GrainBlock: BlockConfig = {
value: ['grain_delete_hook'],
},
},
// Trigger SubBlocks
...getTrigger('grain_recording_created').subBlocks,
...getTrigger('grain_recording_updated').subBlocks,
...getTrigger('grain_highlight_created').subBlocks,
...getTrigger('grain_highlight_updated').subBlocks,
...getTrigger('grain_story_created').subBlocks,
...getTrigger('grain_webhook').subBlocks,
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_webhook',
required: true,
},
...getTrigger('grain_recording_created').subBlocks.slice(1),
...getTrigger('grain_recording_updated').subBlocks.slice(1),
...getTrigger('grain_highlight_created').subBlocks.slice(1),
...getTrigger('grain_highlight_updated').subBlocks.slice(1),
...getTrigger('grain_story_created').subBlocks.slice(1),
...getTrigger('grain_webhook').subBlocks.slice(1),
],
tools: {
access: [

View File

@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildHighlightOutputs, grainSetupInstructions } from './utils'
import { buildHighlightOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
export const grainHighlightCreatedTrigger: TriggerConfig = {
id: 'grain_highlight_created',
@@ -11,6 +11,15 @@ export const grainHighlightCreatedTrigger: TriggerConfig = {
icon: GrainIcon,
subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_highlight_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
@@ -25,42 +34,6 @@ export const grainHighlightCreatedTrigger: TriggerConfig = {
value: 'grain_highlight_created',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_created',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_created',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_created',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',

View File

@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildHighlightOutputs, grainSetupInstructions } from './utils'
import { buildHighlightOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
export const grainHighlightUpdatedTrigger: TriggerConfig = {
id: 'grain_highlight_updated',
@@ -11,6 +11,15 @@ export const grainHighlightUpdatedTrigger: TriggerConfig = {
icon: GrainIcon,
subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_highlight_updated',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
@@ -25,42 +34,6 @@ export const grainHighlightUpdatedTrigger: TriggerConfig = {
value: 'grain_highlight_updated',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_updated',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_updated',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_highlight_updated',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',

View File

@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildRecordingOutputs, grainSetupInstructions } from './utils'
import { buildRecordingOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
export const grainRecordingCreatedTrigger: TriggerConfig = {
id: 'grain_recording_created',
@@ -11,6 +11,15 @@ export const grainRecordingCreatedTrigger: TriggerConfig = {
icon: GrainIcon,
subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_recording_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
@@ -25,42 +34,6 @@ export const grainRecordingCreatedTrigger: TriggerConfig = {
value: 'grain_recording_created',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_created',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_created',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_created',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',

View File

@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildRecordingOutputs, grainSetupInstructions } from './utils'
import { buildRecordingOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
export const grainRecordingUpdatedTrigger: TriggerConfig = {
id: 'grain_recording_updated',
@@ -11,6 +11,15 @@ export const grainRecordingUpdatedTrigger: TriggerConfig = {
icon: GrainIcon,
subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_recording_updated',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
@@ -25,42 +34,6 @@ export const grainRecordingUpdatedTrigger: TriggerConfig = {
value: 'grain_recording_updated',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_updated',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_updated',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_recording_updated',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',

View File

@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildStoryOutputs, grainSetupInstructions } from './utils'
import { buildStoryOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
export const grainStoryCreatedTrigger: TriggerConfig = {
id: 'grain_story_created',
@@ -11,6 +11,15 @@ export const grainStoryCreatedTrigger: TriggerConfig = {
icon: GrainIcon,
subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_story_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
@@ -25,42 +34,6 @@ export const grainStoryCreatedTrigger: TriggerConfig = {
value: 'grain_story_created',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_story_created',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_story_created',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_story_created',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',

View File

@@ -19,7 +19,6 @@ export function grainSetupInstructions(eventType: string): string {
const instructions = [
'Enter your Grain API Key (Personal Access Token) above.',
'You can find or create your API key in Grain at <strong>Settings > Integrations > API</strong>.',
'Optionally configure filters to narrow which recordings trigger the webhook.',
`Click <strong>"Save Configuration"</strong> to automatically create the webhook in Grain for <strong>${eventType}</strong> events.`,
'The webhook will be automatically deleted when you remove this trigger.',
]
@@ -40,75 +39,61 @@ export function buildRecordingOutputs(): Record<string, TriggerOutput> {
return {
type: {
type: 'string',
description: 'Event type (recording_added)',
description: 'Event type',
},
user_id: {
type: 'string',
description: 'User UUID who triggered the event',
},
data: {
type: 'object',
description: 'Recording data object',
},
'data.id': {
type: 'string',
description: 'Recording UUID',
},
'data.title': {
type: 'string',
description: 'Recording title',
},
'data.start_datetime': {
type: 'string',
description: 'ISO8601 start timestamp',
},
'data.end_datetime': {
type: 'string',
description: 'ISO8601 end timestamp',
},
'data.duration_ms': {
type: 'number',
description: 'Duration in milliseconds',
},
'data.media_type': {
type: 'string',
description: 'audio, transcript, or video',
},
'data.source': {
type: 'string',
description: 'Recording source (zoom, meet, teams, etc.)',
},
'data.url': {
type: 'string',
description: 'URL to view in Grain',
},
'data.thumbnail_url': {
type: 'string',
description: 'Thumbnail URL (nullable)',
},
'data.tags': {
type: 'array',
description: 'Array of tag strings',
},
'data.teams': {
type: 'array',
description: 'Teams the recording belongs to',
},
'data.meeting_type': {
type: 'object',
description: 'Meeting type info (nullable)',
},
'data.highlights': {
type: 'array',
description: 'Highlights (if configured in hook)',
},
'data.participants': {
type: 'array',
description: 'Participants (if configured in hook)',
},
'data.ai_summary': {
type: 'object',
description: 'AI summary (if configured in hook)',
id: {
type: 'string',
description: 'Recording UUID',
},
title: {
type: 'string',
description: 'Recording title',
},
start_datetime: {
type: 'string',
description: 'ISO8601 start timestamp',
},
end_datetime: {
type: 'string',
description: 'ISO8601 end timestamp',
},
duration_ms: {
type: 'number',
description: 'Duration in milliseconds',
},
media_type: {
type: 'string',
description: 'audio, transcript, or video',
},
source: {
type: 'string',
description: 'Recording source (zoom, meet, local_capture, etc.)',
},
url: {
type: 'string',
description: 'URL to view in Grain',
},
thumbnail_url: {
type: 'string',
description: 'Thumbnail URL (nullable)',
},
tags: {
type: 'array',
description: 'Array of tag strings',
},
teams: {
type: 'array',
description: 'Array of team objects',
},
meeting_type: {
type: 'object',
description: 'Meeting type info with id, name, scope (nullable)',
},
},
} as Record<string, TriggerOutput>
}
@@ -128,52 +113,50 @@ export function buildHighlightOutputs(): Record<string, TriggerOutput> {
description: 'User UUID who triggered the event',
},
data: {
type: 'object',
description: 'Highlight data object',
},
'data.id': {
type: 'string',
description: 'Highlight UUID',
},
'data.recording_id': {
type: 'string',
description: 'Parent recording UUID',
},
'data.text': {
type: 'string',
description: 'Highlight title/description',
},
'data.transcript': {
type: 'string',
description: 'Transcript text of the clip',
},
'data.speakers': {
type: 'array',
description: 'Array of speaker names',
},
'data.timestamp': {
type: 'number',
description: 'Start timestamp in ms',
},
'data.duration': {
type: 'number',
description: 'Duration in ms',
},
'data.tags': {
type: 'array',
description: 'Array of tag strings',
},
'data.url': {
type: 'string',
description: 'URL to view in Grain',
},
'data.thumbnail_url': {
type: 'string',
description: 'Thumbnail URL',
},
'data.created_datetime': {
type: 'string',
description: 'ISO8601 creation timestamp',
id: {
type: 'string',
description: 'Highlight UUID',
},
recording_id: {
type: 'string',
description: 'Parent recording UUID',
},
text: {
type: 'string',
description: 'Highlight title/description',
},
transcript: {
type: 'string',
description: 'Transcript text of the clip',
},
speakers: {
type: 'array',
description: 'Array of speaker names',
},
timestamp: {
type: 'number',
description: 'Start timestamp in ms',
},
duration: {
type: 'number',
description: 'Duration in ms',
},
tags: {
type: 'array',
description: 'Array of tag strings',
},
url: {
type: 'string',
description: 'URL to view in Grain',
},
thumbnail_url: {
type: 'string',
description: 'Thumbnail URL',
},
created_datetime: {
type: 'string',
description: 'ISO8601 creation timestamp',
},
},
} as Record<string, TriggerOutput>
}
@@ -193,24 +176,22 @@ export function buildStoryOutputs(): Record<string, TriggerOutput> {
description: 'User UUID who triggered the event',
},
data: {
type: 'object',
description: 'Story data object',
},
'data.id': {
type: 'string',
description: 'Story UUID',
},
'data.title': {
type: 'string',
description: 'Story title',
},
'data.url': {
type: 'string',
description: 'URL to view in Grain',
},
'data.created_datetime': {
type: 'string',
description: 'ISO8601 creation timestamp',
id: {
type: 'string',
description: 'Story UUID',
},
title: {
type: 'string',
description: 'Story title',
},
url: {
type: 'string',
description: 'URL to view in Grain',
},
created_datetime: {
type: 'string',
description: 'ISO8601 creation timestamp',
},
},
} as Record<string, TriggerOutput>
}

View File

@@ -34,42 +34,6 @@ export const grainWebhookTrigger: TriggerConfig = {
value: 'grain_webhook',
},
},
{
id: 'includeHighlights',
title: 'Include Highlights',
type: 'switch',
description: 'Include highlights/clips in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_webhook',
},
},
{
id: 'includeParticipants',
title: 'Include Participants',
type: 'switch',
description: 'Include participant list in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_webhook',
},
},
{
id: 'includeAiSummary',
title: 'Include AI Summary',
type: 'switch',
description: 'Include AI-generated summary in webhook payload.',
defaultValue: false,
mode: 'trigger',
condition: {
field: 'selectedTriggerId',
value: 'grain_webhook',
},
},
{
id: 'triggerInstructions',
title: 'Setup Instructions',