feat(spotlight): add support for custom search-engines (#1200)
* feat(spotlight): add search settings link * feat(search-engine): add to manage pages * feat(spotlight): add children option for external search engines * chore: revert search settings * fix: deepsource issue * fix: inconsistent breadcrum placement * chore: address pull request feedback
This commit is contained in:
@@ -9,10 +9,7 @@ const manageAppSchema = z.object({
|
||||
|
||||
const editAppSchema = manageAppSchema.and(z.object({ id: z.string() }));
|
||||
|
||||
const byIdSchema = z.object({ id: z.string() });
|
||||
|
||||
export const appSchemas = {
|
||||
manage: manageAppSchema,
|
||||
edit: editAppSchema,
|
||||
byId: byIdSchema,
|
||||
};
|
||||
|
||||
22
packages/validation/src/common.ts
Normal file
22
packages/validation/src/common.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const paginatedSchema = z.object({
|
||||
search: z.string().optional(),
|
||||
pageSize: z.number().int().positive().default(10),
|
||||
page: z.number().int().positive().default(1),
|
||||
});
|
||||
|
||||
export const byIdSchema = z.object({
|
||||
id: z.string(),
|
||||
});
|
||||
|
||||
const searchSchema = z.object({
|
||||
query: z.string(),
|
||||
limit: z.number().int().positive().default(10),
|
||||
});
|
||||
|
||||
export const commonSchemas = {
|
||||
paginated: paginatedSchema,
|
||||
byId: byIdSchema,
|
||||
search: searchSchema,
|
||||
};
|
||||
@@ -48,7 +48,7 @@ const handleStringError = (issue: z.ZodInvalidStringIssue) => {
|
||||
}
|
||||
|
||||
return {
|
||||
key: "errors.invalid_string.includes",
|
||||
key: "errors.string.includes",
|
||||
params: {
|
||||
includes: issue.validation.includes,
|
||||
},
|
||||
|
||||
@@ -2,18 +2,9 @@ import { z } from "zod";
|
||||
|
||||
import { groupPermissionKeys } from "@homarr/definitions";
|
||||
|
||||
import { byIdSchema } from "./common";
|
||||
import { zodEnumFromArray } from "./enums";
|
||||
|
||||
const paginatedSchema = z.object({
|
||||
search: z.string().optional(),
|
||||
pageSize: z.number().int().positive().default(10),
|
||||
page: z.number().int().positive().default(1),
|
||||
});
|
||||
|
||||
const byIdSchema = z.object({
|
||||
id: z.string(),
|
||||
});
|
||||
|
||||
const createSchema = z.object({
|
||||
name: z.string().max(64),
|
||||
});
|
||||
@@ -28,8 +19,6 @@ const savePermissionsSchema = z.object({
|
||||
const groupUserSchema = z.object({ groupId: z.string(), userId: z.string() });
|
||||
|
||||
export const groupSchemas = {
|
||||
paginated: paginatedSchema,
|
||||
byId: byIdSchema,
|
||||
create: createSchema,
|
||||
update: updateSchema,
|
||||
savePermissions: savePermissionsSchema,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { appSchemas } from "./app";
|
||||
import { boardSchemas } from "./board";
|
||||
import { commonSchemas } from "./common";
|
||||
import { groupSchemas } from "./group";
|
||||
import { iconsSchemas } from "./icons";
|
||||
import { integrationSchemas } from "./integration";
|
||||
import { locationSchemas } from "./location";
|
||||
import { searchEngineSchemas } from "./search-engine";
|
||||
import { userSchemas } from "./user";
|
||||
import { widgetSchemas } from "./widgets";
|
||||
|
||||
@@ -16,15 +18,17 @@ export const validation = {
|
||||
widget: widgetSchemas,
|
||||
location: locationSchemas,
|
||||
icons: iconsSchemas,
|
||||
searchEngine: searchEngineSchemas,
|
||||
common: commonSchemas,
|
||||
};
|
||||
|
||||
export {
|
||||
createSectionSchema,
|
||||
sharedItemSchema,
|
||||
itemAdvancedOptionsSchema,
|
||||
type BoardItemIntegration,
|
||||
type BoardItemAdvancedOptions,
|
||||
} from "./shared";
|
||||
export { passwordRequirements } from "./user";
|
||||
export { oldmarrImportConfigurationSchema, superRefineJsonImportFile } from "./board";
|
||||
export type { OldmarrImportConfiguration } from "./board";
|
||||
export {
|
||||
createSectionSchema,
|
||||
itemAdvancedOptionsSchema,
|
||||
sharedItemSchema,
|
||||
type BoardItemAdvancedOptions,
|
||||
type BoardItemIntegration,
|
||||
} from "./shared";
|
||||
export { passwordRequirements } from "./user";
|
||||
|
||||
20
packages/validation/src/search-engine.ts
Normal file
20
packages/validation/src/search-engine.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const manageSearchEngineSchema = z.object({
|
||||
name: z.string().min(1).max(64),
|
||||
short: z.string().min(1).max(8),
|
||||
iconUrl: z.string().min(1),
|
||||
urlTemplate: z.string().min(1).startsWith("http").includes("%s"),
|
||||
description: z.string().max(512).nullable(),
|
||||
});
|
||||
|
||||
const editSearchEngineSchema = manageSearchEngineSchema
|
||||
.extend({
|
||||
id: z.string(),
|
||||
})
|
||||
.omit({ short: true });
|
||||
|
||||
export const searchEngineSchemas = {
|
||||
manage: manageSearchEngineSchema,
|
||||
edit: editSearchEngineSchema,
|
||||
};
|
||||
Reference in New Issue
Block a user