mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-31 03:39:21 +01:00
* wip: add crud for services and integrations * feat: remove services * feat: move integration definitions to homarr/definitions, add temporary test connection solution without actual request * feat: add integration count badge * feat: add translation for integrations * feat: add notifications and translate them * feat: add notice to integration forms about test connection * chore: fix ci check issues * feat: add confirm modals for integration deletion and secret card cancellation, change ordering for list page, add name property to integrations * refactor: move revalidate path action * chore: fix ci check issues * chore: install missing dependencies * chore: fix ci check issues * chore: address pull request feedback
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { integrationKinds, integrationSecretKinds } from "@homarr/definitions";
|
|
|
|
import { zodEnumFromArray } from "./enums";
|
|
|
|
const integrationCreateSchema = z.object({
|
|
name: z.string().nonempty().max(127),
|
|
url: z.string().url(),
|
|
kind: zodEnumFromArray(integrationKinds),
|
|
secrets: z.array(
|
|
z.object({
|
|
kind: zodEnumFromArray(integrationSecretKinds),
|
|
value: z.string().nonempty(),
|
|
}),
|
|
),
|
|
});
|
|
|
|
const integrationUpdateSchema = z.object({
|
|
id: z.string().cuid2(),
|
|
name: z.string().nonempty().max(127),
|
|
url: z.string().url(),
|
|
secrets: z.array(
|
|
z.object({
|
|
kind: zodEnumFromArray(integrationSecretKinds),
|
|
value: z.string().nullable(),
|
|
}),
|
|
),
|
|
});
|
|
|
|
const idSchema = z.object({
|
|
id: z.string(),
|
|
});
|
|
|
|
const testConnectionSchema = z.object({
|
|
id: z.string().cuid2().nullable(), // Is used to use existing secrets if they have not been updated
|
|
url: z.string().url(),
|
|
kind: zodEnumFromArray(integrationKinds),
|
|
secrets: z.array(
|
|
z.object({
|
|
kind: zodEnumFromArray(integrationSecretKinds),
|
|
value: z.string().nullable(),
|
|
}),
|
|
),
|
|
});
|
|
|
|
export const integrationSchemas = {
|
|
create: integrationCreateSchema,
|
|
update: integrationUpdateSchema,
|
|
delete: idSchema,
|
|
byId: idSchema,
|
|
testConnection: testConnectionSchema,
|
|
};
|