From f2ee817ba1423b10b382f6b759a19184db8eeacc Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 7 May 2026 11:53:51 -0400 Subject: refactor --- interior.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 interior.go (limited to 'interior.go') diff --git a/interior.go b/interior.go new file mode 100644 index 0000000..19417e5 --- /dev/null +++ b/interior.go @@ -0,0 +1,45 @@ +package lulu + +//go:generate go run github.com/yawnak/string-enumer -t InteriorValidationStatus --text -o ./interior_gen.go . + +// InteriorValidationStatus is the status of a validation job for an +// interior file that is running on the server. +type InteriorValidationStatus string + +const ( + InteriorStatusNull InteriorValidationStatus = "NULL" // file validation is not started yet + InteriorStatusValidating InteriorValidationStatus = "VALIDATING" // file validation is still running + InteriorStatusValidated InteriorValidationStatus = "VALIDATED" // file validation finished without any errors + InteriorStatusNormalizing InteriorValidationStatus = "NORMALIZING" // file normalization (next step of validation, available only if pod_package_id is was passed in the payload) is still running + InteriorStatusNormalized InteriorValidationStatus = "NORMALIZED" // file normalization finished without any errors + InteriorStatusError InteriorValidationStatus = "ERROR" // file is invalid, list of errors is included in the response +) + +func (s InteriorValidationStatus) IsFinal() bool { + switch s { + case InteriorStatusValidated, InteriorStatusNormalized, InteriorStatusError: + return true + } + return false +} + +// validateInteriorReq is the json body of a /validate-interior/ request. +type validateInteriorReq struct { + SrcUrl string `json:"source_url"` + PkgId PkgId `json:"pod_package_id"` +} + +// validateInteriorReq is the json body of a /validate-interior/ request without the optional pod_package_id. +type validateInteriorBasicReq struct { + SrcUrl string `json:"source_url"` +} + +// InteriorValidationRecord contains the validation status of an interior file. +type InteriorValidationRecord struct { + Id uint + SrcUrl string `json:"source_url"` + NPages uint `json:"page_count"` + Errors string + Status InteriorValidationStatus + ValidPkgIds []PkgId `json:"valid_pod_package_ids"` +} -- cgit v1.2.3