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

Method updateSecret

backend/src/secrets/secrets.service.ts:146–183  ·  view source on GitHub ↗
(
    auth: AuthContext | null,
    secretId: string,
    input: UpdateSecretInput,
  )

Source from the content-addressed store, hash-verified

144 }
145
146 async updateSecret(
147 auth: AuthContext | null,
148 secretId: string,
149 input: UpdateSecretInput,
150 ): Promise<SecretSummary> {
151 const organizationId = this.assertOrganizationId(auth);
152 const updates: SecretUpdateData = {};
153
154 if (input.name !== undefined) {
155 const trimmedName = input.name.trim();
156 if (trimmedName.length === 0) {
157 throw new BadRequestException('Secret name cannot be empty');
158 }
159 updates.name = trimmedName;
160 }
161 if (input.description !== undefined) {
162 if (input.description === null) {
163 updates.description = null;
164 } else {
165 const trimmedDescription = input.description.trim();
166 updates.description = trimmedDescription.length > 0 ? trimmedDescription : null;
167 }
168 }
169 if (input.tags !== undefined) {
170 if (input.tags === null) {
171 updates.tags = null;
172 } else {
173 const normalizedTags = input.tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0);
174 updates.tags = normalizedTags.length > 0 ? normalizedTags : null;
175 }
176 }
177
178 if (Object.keys(updates).length === 0) {
179 return this.repository.findById(secretId, { organizationId });
180 }
181
182 return this.repository.updateSecret(secretId, updates, { organizationId });
183 }
184
185 async deleteSecret(auth: AuthContext | null, secretId: string): Promise<void> {
186 const organizationId = this.assertOrganizationId(auth);

Callers 2

api.tsFile · 0.45

Calls 2

assertOrganizationIdMethod · 0.95
findByIdMethod · 0.45

Tested by

no test coverage detected