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,99 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { uploadFileFromRawData } from '@/lib/uploads/contexts/execution'
|
||||
import type { UserFile } from '@/executor/types'
|
||||
|
||||
const logger = createLogger('WebhookAttachmentProcessor')
|
||||
|
||||
export interface WebhookAttachment {
|
||||
name: string
|
||||
data: Buffer
|
||||
contentType?: string
|
||||
mimeType?: string
|
||||
size: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes webhook/trigger attachments and converts them to UserFile objects.
|
||||
* This enables triggers to include file attachments that get automatically stored
|
||||
* in the execution filesystem and made available as UserFile objects for workflow use.
|
||||
*/
|
||||
export class WebhookAttachmentProcessor {
|
||||
/**
|
||||
* Process attachments and upload them to execution storage
|
||||
*/
|
||||
static async processAttachments(
|
||||
attachments: WebhookAttachment[],
|
||||
executionContext: {
|
||||
workspaceId: string
|
||||
workflowId: string
|
||||
executionId: string
|
||||
requestId: string
|
||||
userId?: string
|
||||
}
|
||||
): Promise<UserFile[]> {
|
||||
if (!attachments || attachments.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${executionContext.requestId}] Processing ${attachments.length} attachments for execution ${executionContext.executionId}`
|
||||
)
|
||||
|
||||
const processedFiles: UserFile[] = []
|
||||
|
||||
for (const attachment of attachments) {
|
||||
try {
|
||||
const userFile = await WebhookAttachmentProcessor.processAttachment(
|
||||
attachment,
|
||||
executionContext
|
||||
)
|
||||
processedFiles.push(userFile)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`[${executionContext.requestId}] Error processing attachment '${attachment.name}':`,
|
||||
error
|
||||
)
|
||||
// Continue with other attachments rather than failing the entire request
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${executionContext.requestId}] Successfully processed ${processedFiles.length}/${attachments.length} attachments`
|
||||
)
|
||||
|
||||
return processedFiles
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a single attachment and upload to execution storage
|
||||
*/
|
||||
private static async processAttachment(
|
||||
attachment: WebhookAttachment,
|
||||
executionContext: {
|
||||
workspaceId: string
|
||||
workflowId: string
|
||||
executionId: string
|
||||
requestId: string
|
||||
userId?: string
|
||||
}
|
||||
): Promise<UserFile> {
|
||||
const userFile = await uploadFileFromRawData(
|
||||
{
|
||||
name: attachment.name,
|
||||
data: attachment.data,
|
||||
mimeType: attachment.contentType || attachment.mimeType,
|
||||
},
|
||||
executionContext,
|
||||
executionContext.userId
|
||||
)
|
||||
|
||||
if (userFile.base64) {
|
||||
return userFile
|
||||
}
|
||||
|
||||
return {
|
||||
...userFile,
|
||||
base64: attachment.data.toString('base64'),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user