feat: entry list at /content/:key

This commit is contained in:
Florian Sylvain committed 2026-10-20 21:05:03 +02:00
1 parent b4cbcb0395
commit 91d916fb74
44 files changed
+4984 -32

No files matched your search

+28
View File
@@ -126,6 +126,14 @@ export function entryPage(total: number) {
return { items: [], total, page: 1, size: 1 }
}
function defaultType(key: string) {
const found = customTypes.find((type) => type.key === key)
if (!found) {
throw new ApiError(404, undefined, 'content_type_not_found')
}
return found
}
export interface SchemaMount {
role?: string
create?: (body: PostedRequest['body']) => unknown
@@ -137,6 +145,10 @@ export interface SchemaMount {
builtin?: Responder
verified?: boolean
actions?: string[]
type?: (key: string) => unknown
list?: (key: string, query: URLSearchParams) => unknown
lookup?: (ids: number[]) => unknown
before?: () => void
}
let wrapper: VueWrapper | undefined
@@ -156,6 +168,7 @@ export async function mountAt(path: string, options: SchemaMount = {}, shellOnly
puts.length = 0
deletes.length = 0
localStorage.clear()
options.before?.()
setViewportWidth(options.width ?? DESKTOP_WIDTH)
const pinia = createPinia()
setActivePinia(pinia)
@@ -199,6 +212,21 @@ export async function mountAt(path: string, options: SchemaMount = {}, shellOnly
if (counted) {
return (options.entries ?? ((key) => entryPage(entryCounts[key] ?? 0)))(counted[1]!)
}
const listed = url.match(/^\/v1\/content-type\/([^/?]+)\/entry\?(.*)$/)
if (listed) {
return (options.list ?? (() => entryPage(0)))(
listed[1]!,
new URLSearchParams(listed[2]),
)
}
const looked = url.match(/^\/v1\/user\/lookup\?ids=(.*)$/)
if (looked) {
return (options.lookup ?? (() => []))(looked[1]!.split(',').map(Number))
}
const detailed = url.match(/^\/v1\/content-type\/([^/?]+)$/)
if (detailed) {
return (options.type ?? defaultType)(detailed[1]!)
}
if (url === '/v1/builtin-type') {
return (options.builtin ?? (() => builtinTypes))()
}