(
auth: AuthContext | null,
id: string,
dto: {
workflowId?: string;
workflowVersionId?: string;
name?: string;
description?: string;
parsingScript?: string;
expectedInputs?: {
id: string;
label: string;
type: string;
required: boolean;
description?: string;
}[];
status?: 'active' | 'inactive';
},
)
| 99 | } |
| 100 | |
| 101 | async update( |
| 102 | auth: AuthContext | null, |
| 103 | id: string, |
| 104 | dto: { |
| 105 | workflowId?: string; |
| 106 | workflowVersionId?: string; |
| 107 | name?: string; |
| 108 | description?: string; |
| 109 | parsingScript?: string; |
| 110 | expectedInputs?: { |
| 111 | id: string; |
| 112 | label: string; |
| 113 | type: string; |
| 114 | required: boolean; |
| 115 | description?: string; |
| 116 | }[]; |
| 117 | status?: 'active' | 'inactive'; |
| 118 | }, |
| 119 | ): Promise<WebhookConfiguration> { |
| 120 | const existing = await this.repository.findById(id, { organizationId: auth?.organizationId }); |
| 121 | if (!existing) { |
| 122 | throw new NotFoundException(`Webhook ${id} not found`); |
| 123 | } |
| 124 | |
| 125 | // Check access to workflow |
| 126 | const workflowId = dto.workflowId ?? existing.workflowId; |
| 127 | await this.workflowsService.ensureWorkflowAdminAccess(workflowId, auth); |
| 128 | |
| 129 | // Validate expected inputs if provided |
| 130 | if (dto.expectedInputs) { |
| 131 | await this.validateExpectedInputs(workflowId, dto.expectedInputs, auth); |
| 132 | } |
| 133 | |
| 134 | const updated = await this.repository.update( |
| 135 | id, |
| 136 | { |
| 137 | workflowId: dto.workflowId, |
| 138 | workflowVersionId: dto.workflowVersionId ?? null, |
| 139 | name: dto.name, |
| 140 | description: dto.description !== undefined ? dto.description : undefined, |
| 141 | parsingScript: dto.parsingScript, |
| 142 | expectedInputs: dto.expectedInputs as any, |
| 143 | status: dto.status, |
| 144 | }, |
| 145 | { organizationId: auth?.organizationId }, |
| 146 | ); |
| 147 | |
| 148 | if (!updated) { |
| 149 | throw new NotFoundException(`Webhook ${id} not found`); |
| 150 | } |
| 151 | |
| 152 | this.logger.log(`Updated webhook ${id}`); |
| 153 | return this.mapConfigurationRecord(updated); |
| 154 | } |
| 155 | |
| 156 | async delete(auth: AuthContext | null, id: string): Promise<void> { |
| 157 | const existing = await this.repository.findById(id, { organizationId: auth?.organizationId }); |
no test coverage detected