chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildHighlightOutputs, grainSetupInstructions } from './utils'
|
||||
|
||||
export const grainHighlightCreatedTrigger: TriggerConfig = {
|
||||
id: 'grain_highlight_created',
|
||||
name: 'Grain Highlight Created',
|
||||
provider: 'grain',
|
||||
description: 'Trigger workflow when a new highlight/clip is created in Grain',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain highlight view UUID',
|
||||
description: 'Required by Grain to create the webhook subscription.',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainSetupInstructions('Highlight (new)'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_created',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildHighlightOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildHighlightOutputs, grainSetupInstructions } from './utils'
|
||||
|
||||
export const grainHighlightUpdatedTrigger: TriggerConfig = {
|
||||
id: 'grain_highlight_updated',
|
||||
name: 'Grain Highlight Updated',
|
||||
provider: 'grain',
|
||||
description: 'Trigger workflow when a highlight/clip is updated in Grain',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain highlight view UUID',
|
||||
description: 'Required by Grain to create the webhook subscription.',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainSetupInstructions('Highlight (updated)'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_highlight_updated',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildHighlightOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export { grainHighlightCreatedTrigger } from './highlight_created'
|
||||
export { grainHighlightUpdatedTrigger } from './highlight_updated'
|
||||
export { grainItemAddedTrigger } from './item_added'
|
||||
export { grainItemUpdatedTrigger } from './item_updated'
|
||||
export { grainRecordingCreatedTrigger } from './recording_created'
|
||||
export { grainRecordingUpdatedTrigger } from './recording_updated'
|
||||
export { grainStoryCreatedTrigger } from './story_created'
|
||||
export { grainWebhookTrigger } from './webhook'
|
||||
@@ -0,0 +1,64 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildGenericOutputs, grainV2SetupInstructions } from './utils'
|
||||
|
||||
export const grainItemAddedTrigger: TriggerConfig = {
|
||||
id: 'grain_item_added',
|
||||
name: 'Grain Item Added',
|
||||
provider: 'grain',
|
||||
description: 'Trigger when a new item is added to a Grain view (recording, highlight, or story)',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_added',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain view UUID',
|
||||
description:
|
||||
'The view determines which content type fires events (recordings, highlights, or stories).',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_added',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainV2SetupInstructions('item added'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_added',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildGenericOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildGenericOutputs, grainV2SetupInstructions } from './utils'
|
||||
|
||||
export const grainItemUpdatedTrigger: TriggerConfig = {
|
||||
id: 'grain_item_updated',
|
||||
name: 'Grain Item Updated',
|
||||
provider: 'grain',
|
||||
description: 'Trigger when an item is updated in a Grain view (recording, highlight, or story)',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain view UUID',
|
||||
description:
|
||||
'The view determines which content type fires events (recordings, highlights, or stories).',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainV2SetupInstructions('item updated'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_item_updated',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildGenericOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildRecordingOutputs, grainSetupInstructions } from './utils'
|
||||
|
||||
export const grainRecordingCreatedTrigger: TriggerConfig = {
|
||||
id: 'grain_recording_created',
|
||||
name: 'Grain Recording Created',
|
||||
provider: 'grain',
|
||||
description: 'Trigger workflow when a new recording is added in Grain',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain recording view UUID',
|
||||
description: 'Required by Grain to create the webhook subscription.',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainSetupInstructions('Recording (new)'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_created',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildRecordingOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildRecordingOutputs, grainSetupInstructions } from './utils'
|
||||
|
||||
export const grainRecordingUpdatedTrigger: TriggerConfig = {
|
||||
id: 'grain_recording_updated',
|
||||
name: 'Grain Recording Updated',
|
||||
provider: 'grain',
|
||||
description: 'Trigger workflow when a recording is updated in Grain',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain recording view UUID',
|
||||
description: 'Required by Grain to create the webhook subscription.',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_updated',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainSetupInstructions('Recording (updated)'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_recording_updated',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildRecordingOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildStoryOutputs, grainSetupInstructions } from './utils'
|
||||
|
||||
export const grainStoryCreatedTrigger: TriggerConfig = {
|
||||
id: 'grain_story_created',
|
||||
name: 'Grain Story Created',
|
||||
provider: 'grain',
|
||||
description: 'Trigger workflow when a new story is created in Grain',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_story_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain story view UUID',
|
||||
description: 'Required by Grain to create the webhook subscription.',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_story_created',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainSetupInstructions('Story (new)'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_story_created',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildStoryOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
import type { TriggerOutput } from '@/triggers/types'
|
||||
|
||||
/**
|
||||
* Trigger dropdown options for Grain triggers.
|
||||
* New options (Item Added / Item Updated / All Events) correctly scope by view_id only.
|
||||
* Legacy options are hidden from the picker but still resolve for existing workflows.
|
||||
*/
|
||||
export const grainTriggerOptions = [
|
||||
{ label: 'Item Added', id: 'grain_item_added' },
|
||||
{ label: 'Item Updated', id: 'grain_item_updated' },
|
||||
{ label: 'All Events', id: 'grain_webhook' },
|
||||
{ label: 'Recording Created', id: 'grain_recording_created', hidden: true },
|
||||
{ label: 'Recording Updated', id: 'grain_recording_updated', hidden: true },
|
||||
{ label: 'Highlight Created', id: 'grain_highlight_created', hidden: true },
|
||||
{ label: 'Highlight Updated', id: 'grain_highlight_updated', hidden: true },
|
||||
{ label: 'Story Created', id: 'grain_story_created', hidden: true },
|
||||
]
|
||||
|
||||
/**
|
||||
* Generate setup instructions for a specific Grain event type
|
||||
*/
|
||||
export function grainSetupInstructions(eventType: string): string {
|
||||
const instructions = [
|
||||
'Enter your Grain API Key (Personal Access Token) above.',
|
||||
`Enter the Grain view ID that matches the ${eventType} trigger. Grain requires <code>view_id</code> for webhook creation.`,
|
||||
'Use the Grain "List Views" tool or GET <code>/_/public-api/views</code> to find the correct view ID.',
|
||||
'You can find or create your API key in Grain at <strong>Workspace Settings > API</strong> under Integrations on <a href="https://grain.com/app/settings/integrations?tab=api" target="_blank" rel="noopener noreferrer">grain.com</a>.',
|
||||
'The webhook will be automatically deleted when you remove this trigger.',
|
||||
]
|
||||
|
||||
return instructions
|
||||
.map(
|
||||
(instruction, index) =>
|
||||
`<div class="mb-3"><strong>${index + 1}.</strong> ${instruction}</div>`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup instructions for the v2 triggers that correctly explain view-based scoping.
|
||||
*/
|
||||
export function grainV2SetupInstructions(action: 'item added' | 'item updated' | 'all'): string {
|
||||
const viewSentence =
|
||||
action === 'all'
|
||||
? 'Enter a Grain <strong>view ID</strong>. Each view has a type — <em>recordings</em>, <em>highlights</em>, or <em>stories</em> — and this trigger will fire on every event (added, updated, or removed) for items in that view.'
|
||||
: `Enter a Grain <strong>view ID</strong>. Each view has a type — <em>recordings</em>, <em>highlights</em>, or <em>stories</em> — and only items matching that type will fire the <strong>${action}</strong> event.`
|
||||
|
||||
const instructions = [
|
||||
'Enter your Grain API Key (Personal Access Token). You can find or create one in Grain at <strong>Workspace Settings > API</strong> under Integrations on <a href="https://grain.com/app/settings/integrations?tab=api" target="_blank" rel="noopener noreferrer">grain.com</a>.',
|
||||
viewSentence,
|
||||
'To find your view IDs, use the <strong>List Views</strong> operation on this block or call <code>GET /_/public-api/views</code> directly.',
|
||||
'The webhook is created automatically when you save and will be deleted when you remove this trigger.',
|
||||
]
|
||||
|
||||
return instructions
|
||||
.map(
|
||||
(instruction, index) =>
|
||||
`<div class="mb-3"><strong>${index + 1}.</strong> ${instruction}</div>`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
/**
|
||||
* Build output schema for recording events
|
||||
* Webhook payload structure: { type, user_id, data: { ...recording } }
|
||||
*/
|
||||
export function buildRecordingOutputs(): Record<string, TriggerOutput> {
|
||||
return {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'Event type',
|
||||
},
|
||||
user_id: {
|
||||
type: 'string',
|
||||
description: 'User UUID who triggered the event',
|
||||
},
|
||||
data: {
|
||||
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>
|
||||
}
|
||||
|
||||
/**
|
||||
* Build output schema for highlight events
|
||||
* Note: Grain API docs only show recording webhooks. Highlight webhooks may have similar structure.
|
||||
*/
|
||||
export function buildHighlightOutputs(): Record<string, TriggerOutput> {
|
||||
return {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'Event type',
|
||||
},
|
||||
user_id: {
|
||||
type: 'string',
|
||||
description: 'User UUID who triggered the event',
|
||||
},
|
||||
data: {
|
||||
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>
|
||||
}
|
||||
|
||||
/**
|
||||
* Build output schema for story events
|
||||
* Note: Grain API docs only show recording webhooks. Story webhooks may have similar structure.
|
||||
*/
|
||||
export function buildStoryOutputs(): Record<string, TriggerOutput> {
|
||||
return {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'Event type',
|
||||
},
|
||||
user_id: {
|
||||
type: 'string',
|
||||
description: 'User UUID who triggered the event',
|
||||
},
|
||||
data: {
|
||||
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>
|
||||
}
|
||||
|
||||
/**
|
||||
* Build output schema for generic webhook events
|
||||
* Webhook payload structure: { type, user_id, data: { ... } }
|
||||
*/
|
||||
export function buildGenericOutputs(): Record<string, TriggerOutput> {
|
||||
return {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'Event type (e.g., recording_added)',
|
||||
},
|
||||
user_id: {
|
||||
type: 'string',
|
||||
description: 'User UUID who triggered the event',
|
||||
},
|
||||
data: {
|
||||
type: 'object',
|
||||
description: 'Event data object (recording, highlight, etc.)',
|
||||
},
|
||||
} as Record<string, TriggerOutput>
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { GrainIcon } from '@/components/icons'
|
||||
import type { TriggerConfig } from '@/triggers/types'
|
||||
import { buildGenericOutputs, grainV2SetupInstructions } from './utils'
|
||||
|
||||
export const grainWebhookTrigger: TriggerConfig = {
|
||||
id: 'grain_webhook',
|
||||
name: 'Grain All Events',
|
||||
provider: 'grain',
|
||||
description: 'Trigger on all actions (added, updated, removed) in a Grain view',
|
||||
version: '1.0.0',
|
||||
icon: GrainIcon,
|
||||
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter your Grain API key (Personal Access Token)',
|
||||
description: 'Required to create the webhook in Grain.',
|
||||
password: true,
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_webhook',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'viewId',
|
||||
title: 'View ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Enter Grain view UUID',
|
||||
description:
|
||||
'The view determines which content type fires events (recordings, highlights, or stories).',
|
||||
required: true,
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_webhook',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'triggerInstructions',
|
||||
title: 'Setup Instructions',
|
||||
hideFromPreview: true,
|
||||
type: 'text',
|
||||
defaultValue: grainV2SetupInstructions('all'),
|
||||
mode: 'trigger',
|
||||
condition: {
|
||||
field: 'selectedTriggerId',
|
||||
value: 'grain_webhook',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
outputs: buildGenericOutputs(),
|
||||
|
||||
webhook: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user