feat(schema-workflow): PATCH /drafts/{id} — edit без recreate (A)

This commit is contained in:
Александр Зимин
2026-05-12 11:33:01 +00:00
parent ab6ec6ebec
commit b3a9104d54
11 changed files with 323 additions and 51 deletions
+30
View File
@@ -18,6 +18,7 @@ import {
type SchemaDraft,
type SubmitDraftRequest,
type SubmitForReviewRequest,
type UpdateSchemaDraftRequest,
type WebhookDelivery,
type WebhookSubscription,
type WebhookTestPingResult,
@@ -514,6 +515,35 @@ export const useCreateSchemaDraft = (dictionaryName: string) => {
})
}
/**
* Update content (proposedSchema / reason) в существующем draft'е без
* recreate. Status-gate: только DRAFT и CHANGES_REQUESTED. Backend
* автоматически переводит CHANGES_REQUESTED → DRAFT после update
* (maker должен ре-submit на ревью осознанно).
*/
export const useUpdateSchemaDraft = (dictionaryName: string) => {
const qc = useQueryClient()
return useMutation({
mutationFn: async (params: {
draftId: string
body: UpdateSchemaDraftRequest
}): Promise<SchemaDraft> => {
const { data } = await apiClient.patch<SchemaDraft>(
`/dictionaries/${dictionaryName}/drafts/${params.draftId}`,
params.body,
)
return data
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['schema-draft-active', dictionaryName] })
qc.invalidateQueries({ queryKey: ['schema-draft', dictionaryName] })
qc.invalidateQueries({ queryKey: ['schema-drafts', dictionaryName] })
qc.invalidateQueries({ queryKey: ['schema-review-queue'] })
qc.invalidateQueries({ queryKey: ['changelog', dictionaryName] })
},
})
}
/** Maker submits draft → review_pending. 202 Accepted. */
export const useSubmitSchemaDraftForReview = (dictionaryName: string) => {
const qc = useQueryClient()