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

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
export { clerkOrganizationCreatedTrigger } from './organization_created'
export { clerkOrganizationDeletedTrigger } from './organization_deleted'
export { clerkOrganizationMembershipCreatedTrigger } from './organization_membership_created'
export { clerkOrganizationMembershipDeletedTrigger } from './organization_membership_deleted'
export { clerkOrganizationMembershipUpdatedTrigger } from './organization_membership_updated'
export { clerkOrganizationUpdatedTrigger } from './organization_updated'
export { clerkSessionCreatedTrigger } from './session_created'
export { clerkSessionEndedTrigger } from './session_ended'
export { clerkSessionRemovedTrigger } from './session_removed'
export { clerkSessionRevokedTrigger } from './session_revoked'
export { clerkUserCreatedTrigger } from './user_created'
export { clerkUserDeletedTrigger } from './user_deleted'
export { clerkUserUpdatedTrigger } from './user_updated'
export { clerkWebhookTrigger } from './webhook'
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Created Trigger.
* Triggers when a new organization is created.
*/
export const clerkOrganizationCreatedTrigger: TriggerConfig = {
id: 'clerk_organization_created',
name: 'Clerk Organization Created',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization is created',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_created',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organization.created'),
extraFields: buildClerkExtraFields('clerk_organization_created'),
}),
outputs: buildOrganizationOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationDeletedOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Deleted Trigger.
* Triggers when an organization is deleted.
*/
export const clerkOrganizationDeletedTrigger: TriggerConfig = {
id: 'clerk_organization_deleted',
name: 'Clerk Organization Deleted',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization is deleted',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_deleted',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organization.deleted'),
extraFields: buildClerkExtraFields('clerk_organization_deleted'),
}),
outputs: buildOrganizationDeletedOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationMembershipOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Membership Created Trigger.
* Triggers when a user is added as a member of an organization.
*/
export const clerkOrganizationMembershipCreatedTrigger: TriggerConfig = {
id: 'clerk_organization_membership_created',
name: 'Clerk Organization Membership Created',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization membership is created',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_membership_created',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organizationMembership.created'),
extraFields: buildClerkExtraFields('clerk_organization_membership_created'),
}),
outputs: buildOrganizationMembershipOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationMembershipDeletedOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Membership Deleted Trigger.
* Triggers when a member is removed from an organization.
*/
export const clerkOrganizationMembershipDeletedTrigger: TriggerConfig = {
id: 'clerk_organization_membership_deleted',
name: 'Clerk Organization Membership Deleted',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization membership is deleted',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_membership_deleted',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organizationMembership.deleted'),
extraFields: buildClerkExtraFields('clerk_organization_membership_deleted'),
}),
outputs: buildOrganizationMembershipDeletedOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationMembershipOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Membership Updated Trigger.
* Triggers when a member's role within an organization changes.
*/
export const clerkOrganizationMembershipUpdatedTrigger: TriggerConfig = {
id: 'clerk_organization_membership_updated',
name: 'Clerk Organization Membership Updated',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization membership is updated',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_membership_updated',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organizationMembership.updated'),
extraFields: buildClerkExtraFields('clerk_organization_membership_updated'),
}),
outputs: buildOrganizationMembershipOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildOrganizationOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Organization Updated Trigger.
* Triggers when an organization's details are updated.
*/
export const clerkOrganizationUpdatedTrigger: TriggerConfig = {
id: 'clerk_organization_updated',
name: 'Clerk Organization Updated',
provider: 'clerk',
description: 'Trigger workflow when a Clerk organization is updated',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_organization_updated',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('organization.updated'),
extraFields: buildClerkExtraFields('clerk_organization_updated'),
}),
outputs: buildOrganizationOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildSessionOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Session Created Trigger.
* Triggers when a user signs in and a new session is created.
*/
export const clerkSessionCreatedTrigger: TriggerConfig = {
id: 'clerk_session_created',
name: 'Clerk Session Created',
provider: 'clerk',
description: 'Trigger workflow when a Clerk session is created',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_session_created',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('session.created'),
extraFields: buildClerkExtraFields('clerk_session_created'),
}),
outputs: buildSessionOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
+38
View File
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildSessionOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Session Ended Trigger.
* Triggers when a user signs out and the session ends.
*/
export const clerkSessionEndedTrigger: TriggerConfig = {
id: 'clerk_session_ended',
name: 'Clerk Session Ended',
provider: 'clerk',
description: 'Trigger workflow when a Clerk session ends',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_session_ended',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('session.ended'),
extraFields: buildClerkExtraFields('clerk_session_ended'),
}),
outputs: buildSessionOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildSessionOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Session Removed Trigger.
* Triggers when a session is removed, e.g. because the associated user was deleted.
*/
export const clerkSessionRemovedTrigger: TriggerConfig = {
id: 'clerk_session_removed',
name: 'Clerk Session Removed',
provider: 'clerk',
description: 'Trigger workflow when a Clerk session is removed',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_session_removed',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('session.removed'),
extraFields: buildClerkExtraFields('clerk_session_removed'),
}),
outputs: buildSessionOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildSessionOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Session Revoked Trigger.
* Triggers when a session is revoked, e.g. via the Revoke Session API or Dashboard.
*/
export const clerkSessionRevokedTrigger: TriggerConfig = {
id: 'clerk_session_revoked',
name: 'Clerk Session Revoked',
provider: 'clerk',
description: 'Trigger workflow when a Clerk session is revoked',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_session_revoked',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('session.revoked'),
extraFields: buildClerkExtraFields('clerk_session_revoked'),
}),
outputs: buildSessionOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
+39
View File
@@ -0,0 +1,39 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildUserOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk User Created Trigger (primary).
* Triggers when a new user registers or is created via the Dashboard or Backend API.
*/
export const clerkUserCreatedTrigger: TriggerConfig = {
id: 'clerk_user_created',
name: 'Clerk User Created',
provider: 'clerk',
description: 'Trigger workflow when a Clerk user is created',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_user_created',
triggerOptions: clerkTriggerOptions,
includeDropdown: true,
setupInstructions: clerkSetupInstructions('user.created'),
extraFields: buildClerkExtraFields('clerk_user_created'),
}),
outputs: buildUserOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
+38
View File
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildUserDeletedOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk User Deleted Trigger.
* Triggers when a user deletes their account or is deleted.
*/
export const clerkUserDeletedTrigger: TriggerConfig = {
id: 'clerk_user_deleted',
name: 'Clerk User Deleted',
provider: 'clerk',
description: 'Trigger workflow when a Clerk user is deleted',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_user_deleted',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('user.deleted'),
extraFields: buildClerkExtraFields('clerk_user_deleted'),
}),
outputs: buildUserDeletedOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
+38
View File
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildUserOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk User Updated Trigger.
* Triggers when a user's information is updated.
*/
export const clerkUserUpdatedTrigger: TriggerConfig = {
id: 'clerk_user_updated',
name: 'Clerk User Updated',
provider: 'clerk',
description: 'Trigger workflow when a Clerk user is updated',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_user_updated',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('user.updated'),
extraFields: buildClerkExtraFields('clerk_user_updated'),
}),
outputs: buildUserOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}
+243
View File
@@ -0,0 +1,243 @@
import type { SubBlockConfig } from '@/blocks/types'
import type { TriggerOutput } from '@/triggers/types'
/**
* Maps Sim Clerk trigger IDs to their Clerk webhook event type.
* Kept in sync with `matchEvent` in the `clerk` webhook provider.
* Event-type strings are the canonical Clerk webhook event names
* (see https://clerk.com/docs/guides/development/webhooks/overview).
*/
export const CLERK_TRIGGER_TO_EVENT_TYPE: Record<string, string> = {
clerk_user_created: 'user.created',
clerk_user_updated: 'user.updated',
clerk_user_deleted: 'user.deleted',
clerk_session_created: 'session.created',
clerk_session_ended: 'session.ended',
clerk_session_removed: 'session.removed',
clerk_session_revoked: 'session.revoked',
clerk_organization_created: 'organization.created',
clerk_organization_updated: 'organization.updated',
clerk_organization_deleted: 'organization.deleted',
clerk_organization_membership_created: 'organizationMembership.created',
clerk_organization_membership_updated: 'organizationMembership.updated',
clerk_organization_membership_deleted: 'organizationMembership.deleted',
}
/**
* Shared trigger dropdown options for all Clerk triggers.
*/
export const clerkTriggerOptions = [
{ label: 'User Created', id: 'clerk_user_created' },
{ label: 'User Updated', id: 'clerk_user_updated' },
{ label: 'User Deleted', id: 'clerk_user_deleted' },
{ label: 'Session Created', id: 'clerk_session_created' },
{ label: 'Session Ended', id: 'clerk_session_ended' },
{ label: 'Session Removed', id: 'clerk_session_removed' },
{ label: 'Session Revoked', id: 'clerk_session_revoked' },
{ label: 'Organization Created', id: 'clerk_organization_created' },
{ label: 'Organization Updated', id: 'clerk_organization_updated' },
{ label: 'Organization Deleted', id: 'clerk_organization_deleted' },
{ label: 'Organization Membership Created', id: 'clerk_organization_membership_created' },
{ label: 'Organization Membership Updated', id: 'clerk_organization_membership_updated' },
{ label: 'Organization Membership Deleted', id: 'clerk_organization_membership_deleted' },
{ label: 'Generic Webhook (All Events)', id: 'clerk_webhook' },
]
/**
* Generate setup instructions for a specific Clerk webhook event type.
* Clerk webhooks are configured manually in the Clerk Dashboard, and the
* Signing Secret must be pasted into the trigger configuration.
*/
export function clerkSetupInstructions(eventType: string): string {
const instructions = [
'Copy the <strong>Webhook URL</strong> above.',
'In the <a href="https://dashboard.clerk.com" target="_blank" rel="noopener noreferrer">Clerk Dashboard</a>, go to <strong>Configure > Webhooks</strong> and click <strong>Add Endpoint</strong>.',
'Paste the <strong>Webhook URL</strong> into the <strong>Endpoint URL</strong> field.',
`Under <strong>Subscribe to events</strong>, select the <strong>${eventType}</strong> event, then click <strong>Create</strong>.`,
'Open the endpoint you just created and copy its <strong>Signing Secret</strong> (starts with <code>whsec_</code>).',
'Paste the <strong>Signing Secret</strong> into the field below.',
'Click <strong>"Save Configuration"</strong> above to activate your trigger.',
]
return instructions
.map(
(instruction, index) =>
`<div class="mb-3"><strong>${index + 1}.</strong> ${instruction}</div>`
)
.join('')
}
/**
* Build Clerk-specific extra fields.
* Includes the Svix Signing Secret used to verify incoming webhook signatures.
* Use with the generic buildTriggerSubBlocks from @/triggers.
*/
export function buildClerkExtraFields(triggerId: string): SubBlockConfig[] {
return [
{
id: 'signingSecret',
title: 'Signing Secret',
type: 'short-input',
placeholder: 'whsec_...',
description: 'Copy this from your Clerk webhook endpoint to verify event signatures.',
password: true,
paramVisibility: 'user-only',
required: true,
mode: 'trigger',
condition: { field: 'selectedTriggerId', value: triggerId },
},
]
}
/**
* Fields common to every Clerk webhook event payload
* (see https://clerk.com/docs/guides/development/webhooks/overview).
*/
const commonEventOutputs: Record<string, TriggerOutput> = {
type: { type: 'string', description: 'Event type (e.g., user.created, session.created)' },
object: { type: 'string', description: 'Always "event"' },
timestamp: { type: 'number', description: 'Timestamp in milliseconds when the event occurred' },
instance_id: { type: 'string', description: 'Identifier of your Clerk instance' },
data: {
type: 'json',
description: 'Raw event `data` object (shape varies by event type)',
},
}
/**
* Build outputs for `user.created` and `user.updated` events.
* The `data` object is the Clerk User object.
*/
export function buildUserOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
userId: { type: 'string', description: 'Clerk user ID (data.id)' },
firstName: { type: 'string', description: "User's first name" },
lastName: { type: 'string', description: "User's last name" },
username: { type: 'string', description: "User's username" },
imageUrl: { type: 'string', description: 'Profile image URL' },
primaryEmailAddressId: { type: 'string', description: 'Primary email address ID' },
emailAddresses: { type: 'json', description: 'Array of email address objects' },
phoneNumbers: { type: 'json', description: 'Array of phone number objects' },
externalId: { type: 'string', description: 'External system ID linked to the user' },
createdAt: { type: 'number', description: 'User creation timestamp (data.created_at)' },
updatedAt: { type: 'number', description: 'User last update timestamp (data.updated_at)' },
}
}
/**
* Build outputs for `user.deleted` events.
* The `data` object is a deleted-object marker: `{ id, deleted, object }`.
*/
export function buildUserDeletedOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
userId: { type: 'string', description: 'Deleted Clerk user ID (data.id)' },
deleted: { type: 'boolean', description: 'Whether the user was deleted (data.deleted)' },
}
}
/**
* Build outputs for `session.created` events.
* The `data` object is the Clerk Session object.
*/
export function buildSessionOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
sessionId: { type: 'string', description: 'Clerk session ID (data.id)' },
userId: { type: 'string', description: 'User the session belongs to (data.user_id)' },
clientId: { type: 'string', description: 'Client ID for the session (data.client_id)' },
status: { type: 'string', description: 'Session status (data.status)' },
createdAt: { type: 'number', description: 'Session creation timestamp (data.created_at)' },
}
}
/**
* Build outputs for `organization.created` events.
* The `data` object is the Clerk Organization object.
*/
export function buildOrganizationOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
organizationId: { type: 'string', description: 'Clerk organization ID (data.id)' },
name: { type: 'string', description: 'Organization name (data.name)' },
slug: { type: 'string', description: 'Organization slug (data.slug)' },
createdBy: { type: 'string', description: 'User ID of the creator (data.created_by)' },
membersCount: { type: 'number', description: 'Number of members (data.members_count)' },
maxAllowedMemberships: {
type: 'number',
description: 'Maximum allowed memberships (data.max_allowed_memberships)',
},
createdAt: { type: 'number', description: 'Organization creation timestamp (data.created_at)' },
}
}
/**
* Build outputs for `organizationMembership.created` and `.updated` events.
* The `data` object is the Clerk OrganizationMembership object.
*/
export function buildOrganizationMembershipOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
membershipId: { type: 'string', description: 'Membership ID (data.id)' },
role: { type: 'string', description: 'Membership role, e.g. org:admin (data.role)' },
organizationId: {
type: 'string',
description: 'Organization ID (data.organization.id)',
},
userId: {
type: 'string',
description: 'User ID of the member (data.public_user_data.user_id)',
},
createdAt: { type: 'number', description: 'Membership creation timestamp (data.created_at)' },
}
}
/**
* Build outputs for `organization.deleted` events.
* The `data` object is a deleted-object marker: `{ id, deleted, object }`.
*/
export function buildOrganizationDeletedOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
organizationId: { type: 'string', description: 'Deleted Clerk organization ID (data.id)' },
deleted: {
type: 'boolean',
description: 'Whether the organization was deleted (data.deleted)',
},
}
}
/**
* Build outputs for `organizationMembership.deleted` events.
* The `data` object is a deleted-object marker: `{ id, deleted, object }`.
*/
export function buildOrganizationMembershipDeletedOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
membershipId: { type: 'string', description: 'Deleted membership ID (data.id)' },
deleted: { type: 'boolean', description: 'Whether the membership was deleted (data.deleted)' },
}
}
/**
* Build outputs for the generic webhook (all events).
* Only the fields common to every Clerk event are guaranteed; use `data`
* for event-specific fields.
*/
export function buildClerkOutputs(): Record<string, TriggerOutput> {
return {
...commonEventOutputs,
}
}
/**
* Check if a Clerk event payload matches the expected trigger configuration.
*/
export function isClerkEventMatch(triggerId: string, body: Record<string, unknown>): boolean {
const expectedType = CLERK_TRIGGER_TO_EVENT_TYPE[triggerId]
if (!expectedType) {
return true // Unknown trigger or generic webhook, allow through
}
return (body?.type as string | undefined) === expectedType
}
+38
View File
@@ -0,0 +1,38 @@
import { ClerkIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildClerkExtraFields,
buildClerkOutputs,
clerkSetupInstructions,
clerkTriggerOptions,
} from '@/triggers/clerk/utils'
import type { TriggerConfig } from '@/triggers/types'
/**
* Clerk Generic Webhook Trigger (all events).
* Triggers for any Clerk webhook event you subscribe the endpoint to.
*/
export const clerkWebhookTrigger: TriggerConfig = {
id: 'clerk_webhook',
name: 'Clerk Webhook',
provider: 'clerk',
description: 'Trigger workflow on any Clerk webhook event',
version: '1.0.0',
icon: ClerkIcon,
subBlocks: buildTriggerSubBlocks({
triggerId: 'clerk_webhook',
triggerOptions: clerkTriggerOptions,
setupInstructions: clerkSetupInstructions('events you want to receive'),
extraFields: buildClerkExtraFields('clerk_webhook'),
}),
outputs: buildClerkOutputs(),
webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
}