feat: scaffold workspace with search, fetch, and extract packages
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Validate a Workshop item ID (a non-empty run of digits). */
|
||||
export const itemIdSchema = z
|
||||
.string()
|
||||
.regex(/^\d+$/, 'Item ID must be a number')
|
||||
.min(1);
|
||||
|
||||
/** Query params for `GET /search`. */
|
||||
export const searchQuerySchema = z.object({
|
||||
q: z.string().trim().min(1, 'Search query is required'),
|
||||
page: z.coerce.number().int().min(1).default(1),
|
||||
});
|
||||
|
||||
export const assetKindSchema = z.enum([
|
||||
'pdf',
|
||||
'deckFace',
|
||||
'deckBack',
|
||||
'image',
|
||||
'imageSecondary',
|
||||
]);
|
||||
|
||||
export const assetRefSchema = z.object({
|
||||
kind: assetKindSchema,
|
||||
url: z.string().url(),
|
||||
ownerGuid: z.string(),
|
||||
});
|
||||
|
||||
export const extractedObjectSchema = z.object({
|
||||
guid: z.string(),
|
||||
name: z.string(),
|
||||
type: z.string(),
|
||||
parentGuid: z.string().optional(),
|
||||
childrenGuids: z.array(z.string()),
|
||||
refs: z.array(assetRefSchema),
|
||||
});
|
||||
|
||||
export const workshopItemSchema = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
author: z.string(),
|
||||
previewImageUrl: z.string(),
|
||||
fileUrl: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
timeCreated: z.number().optional(),
|
||||
timeUpdated: z.number().optional(),
|
||||
});
|
||||
|
||||
export const searchResultSchema = z.object({
|
||||
items: z.array(workshopItemSchema),
|
||||
page: z.number(),
|
||||
hasMore: z.boolean(),
|
||||
});
|
||||
Reference in New Issue
Block a user