feat(housekeeping): complete content events workflow
This commit is contained in:
1 parent
f2e67ebace
commit
d6235c37a1
42 files changed
+2868
-307
No files matched your search
@@ -71,9 +71,26 @@ export function parseContentListInput(
|
||||
) {
|
||||
const first = (value: string | readonly string[] | undefined) =>
|
||||
Array.isArray(value) ? value[0] : value;
|
||||
const text = (value: string | readonly string[] | undefined, limit: number) =>
|
||||
String(first(value) ?? "")
|
||||
.normalize("NFC")
|
||||
.trim()
|
||||
.slice(0, limit);
|
||||
const bounded = (
|
||||
value: string | readonly string[] | undefined,
|
||||
fallback: number,
|
||||
minimum: number,
|
||||
maximum: number,
|
||||
) => {
|
||||
const parsed = Number(first(value));
|
||||
return Number.isSafeInteger(parsed)
|
||||
? Math.min(maximum, Math.max(minimum, parsed))
|
||||
: fallback;
|
||||
};
|
||||
return {
|
||||
search: first(searchParams.search),
|
||||
pageSize: Number(first(searchParams.pageSize) ?? 25),
|
||||
offset: Number(first(searchParams.offset) ?? 0),
|
||||
search: text(searchParams.search, 128),
|
||||
status: text(searchParams.status, 32).toLocaleLowerCase(),
|
||||
pageSize: bounded(searchParams.pageSize, 25, 1, 100),
|
||||
offset: bounded(searchParams.offset, 0, 0, 100_000),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user