2023-06-23 05:57:19 +00:00
|
|
|
import { z } from '@sd/ui/src/forms';
|
|
|
|
|
2024-05-04 16:16:49 +00:00
|
|
|
import i18n from './I18n';
|
|
|
|
|
|
|
|
export const SortOrderSchema = z.union([
|
|
|
|
z.literal('Asc').describe(i18n.t('ascending')),
|
|
|
|
z.literal('Desc').describe(i18n.t('descending'))
|
|
|
|
]);
|
2023-06-23 05:57:19 +00:00
|
|
|
export type SortOrder = z.infer<typeof SortOrderSchema>;
|
|
|
|
|
|
|
|
export const NodeIdParamsSchema = z.object({ id: z.string() });
|
|
|
|
export type NodeIdParams = z.infer<typeof NodeIdParamsSchema>;
|
|
|
|
|
|
|
|
export const LibraryIdParamsSchema = z.object({ libraryId: z.string().optional() });
|
|
|
|
export type LibraryIdParams = z.infer<typeof LibraryIdParamsSchema>;
|
|
|
|
|
|
|
|
export const LocationIdParamsSchema = z.object({ id: z.coerce.number() });
|
|
|
|
export type LocationIdParams = z.infer<typeof LocationIdParamsSchema>;
|
|
|
|
|
|
|
|
export const TagsSettingsParamsSchema = LocationIdParamsSchema.extend({
|
|
|
|
id: LocationIdParamsSchema.shape.id.optional()
|
|
|
|
});
|
|
|
|
export type TagsSettingsParams = z.infer<typeof TagsSettingsParamsSchema>;
|
|
|
|
|
|
|
|
export const PathParamsSchema = z.object({ path: z.string().optional() });
|
|
|
|
export type PathParams = z.infer<typeof PathParamsSchema>;
|
|
|
|
|
2023-11-17 06:58:44 +00:00
|
|
|
export const SearchIdParamsSchema = z.object({ id: z.coerce.number() });
|
|
|
|
export type SearchIdParams = z.infer<typeof SearchIdParamsSchema>;
|
|
|
|
|
2023-06-23 05:57:19 +00:00
|
|
|
export const SearchParamsSchema = PathParamsSchema.extend({
|
2023-11-17 21:07:33 +00:00
|
|
|
// take: z.coerce.number().default(100),
|
|
|
|
// order: z
|
|
|
|
// .union([
|
|
|
|
// z.object({ field: z.literal('name'), value: SortOrderSchema }),
|
|
|
|
// z.object({ field: z.literal('dateCreated'), value: SortOrderSchema })
|
|
|
|
// // z.object({ field: z.literal('sizeInBytes'), value: SortOrderSchema })
|
|
|
|
// ])
|
|
|
|
// .optional(),
|
2023-06-23 05:57:19 +00:00
|
|
|
search: z.string().optional()
|
|
|
|
});
|
|
|
|
export type SearchParams = z.infer<typeof SearchParamsSchema>;
|
|
|
|
|
|
|
|
export const ExplorerParamsSchema = PathParamsSchema.extend({
|
|
|
|
take: z.coerce.number().default(100)
|
|
|
|
});
|
|
|
|
export type ExplorerParams = z.infer<typeof ExplorerParamsSchema>;
|