MCPcopy Create free account
hub / github.com/ShipSecAI/studio / create

Method create

backend/src/webhooks/webhooks.service.ts:54–99  ·  view source on GitHub ↗
(
    auth: AuthContext | null,
    dto: {
      workflowId: string;
      workflowVersionId?: string;
      name: string;
      description?: string;
      parsingScript: string;
      expectedInputs: {
        id: string;
        label: string;
        type: string;
        required: boolean;
        description?: string;
      }[];
    },
  )

Source from the content-addressed store, hash-verified

52 }
53
54 async create(
55 auth: AuthContext | null,
56 dto: {
57 workflowId: string;
58 workflowVersionId?: string;
59 name: string;
60 description?: string;
61 parsingScript: string;
62 expectedInputs: {
63 id: string;
64 label: string;
65 type: string;
66 required: boolean;
67 description?: string;
68 }[];
69 },
70 ): Promise<WebhookConfiguration> {
71 // Validate workflow exists and user has admin access
72 await this.workflowsService.ensureWorkflowAdminAccess(dto.workflowId, auth);
73
74 // Get organization ID
75 const organizationId = this.requireOrganizationId(auth);
76
77 // Generate unique webhook path
78 const webhookPath = this.generateWebhookPath();
79
80 // Validate expected inputs against workflow's entry point
81 await this.validateExpectedInputs(dto.workflowId, dto.expectedInputs, auth);
82
83 const record = await this.repository.create({
84 workflowId: dto.workflowId,
85 workflowVersionId: dto.workflowVersionId ?? null,
86 workflowVersion: null,
87 name: dto.name,
88 description: dto.description ?? null,
89 webhookPath,
90 parsingScript: dto.parsingScript,
91 expectedInputs: dto.expectedInputs as any,
92 status: 'active',
93 organizationId,
94 createdBy: auth?.userId ?? 'system',
95 });
96
97 this.logger.log(`Created webhook ${record.id} for workflow ${dto.workflowId}`);
98 return this.mapConfigurationRecord(record);
99 }
100
101 async update(
102 auth: AuthContext | null,

Callers 1

receiveWebhookMethod · 0.45

Calls 5

requireOrganizationIdMethod · 0.95
generateWebhookPathMethod · 0.95

Tested by

no test coverage detected