diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-07 11:53:51 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-07 11:53:51 -0400 |
| commit | f2ee817ba1423b10b382f6b759a19184db8eeacc (patch) | |
| tree | 57d7660024b9b21d2a9ac80c351b2911b5c573e7 /interior.go | |
| parent | 09c91d21b083abc976a4cc6439899fb00438a630 (diff) | |
| download | lulu-f2ee817ba1423b10b382f6b759a19184db8eeacc.zip | |
refactor
Diffstat (limited to 'interior.go')
| -rw-r--r-- | interior.go | 45 |
1 files changed, 45 insertions, 0 deletions
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"` +} |