mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
2.2 KiB
2.2 KiB
Species synonym creation flow
Endpoints and authorization
- PUT
/species(defined inbackend/src/routes/species.ts) is the write entrypoint for synonym changes. It is protected byrequireOneOf([Role.Admin, Role.EditUnrestricted]), so only admin or edit-unrestricted users can submit synonym writes. On success it returns HTTP 200 with a JSON body{ "species_id": <number> }. - GET
/species/:idreturns the full species payload after writes and includescom_taxa_synonymentries loaded viagetSpeciesDetails. - GET
/species/synonymsreturns all synonym rows without filtering for convenience listings.
Request payload shape
- The PUT route expects a body
{ species: SpeciesDetailsType & EditMetaData }. - Synonyms are supplied on
species.com_taxa_synonymas an array of editable synonym rows. Each row can include:synonym_id(number) – omitted for new rows.species_id(number) – automatically set from the parent species when missing.syn_genus_name(string | null),syn_species_name(string | null),syn_comment(string | null).rowState("new" | "removed" | undefined) – controls how the write handler treats the row.
Write behavior
writeSpeciesdetects whether the species is being created or updated and setsidValueto the finalspecies_idbefore list handling.- Synonym writes call
writeHandler.applyListChanges('com_taxa_synonym', species.com_taxa_synonym, ['synonym_id', 'species_id']). applyListChangesiterates each row and:- Inserts rows where
rowState === 'new'viacreateObject, which fillsspecies_idfrom the parent if it was missing. - Deletes rows where
rowState === 'removed'. - Leaves rows with other
rowStatevalues unchanged.
- Inserts rows where
- There is no explicit duplicate detection in this flow, and the Prisma model for
com_taxa_synonymhas no uniqueness constraint beyond the auto-incrementsynonym_id.
Response schema for verification
- After a successful PUT, only
{ species_id }is returned; synonym rows are not echoed. - A follow-up GET
/species/:idreturns the updated species record withcom_taxa_synonympopulated as plain rows from thecom_taxa_synonymtable.