mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
cad670f19c
Co-authored-by: Tom Moor <tom@getoutline.com> closes #6795
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import isEmpty from "lodash/isEmpty";
|
|
import { z } from "zod";
|
|
import { BaseSchema } from "@server/routes/api/schema";
|
|
|
|
export const GitLabCallbackSchema = BaseSchema.extend({
|
|
query: z
|
|
.object({
|
|
code: z.string().nullish(),
|
|
state: z.string().uuid().nullish(),
|
|
error: z.string().nullish(),
|
|
})
|
|
.refine((req) => !(isEmpty(req.code) && isEmpty(req.error)), {
|
|
message: "one of code or error is required",
|
|
}),
|
|
});
|
|
|
|
export type GitLabCallbackReq = z.infer<typeof GitLabCallbackSchema>;
|
|
|
|
export const GitLabConnectSchema = BaseSchema.extend({
|
|
body: z
|
|
.object({
|
|
url: z.url().startsWith("https://").optional(),
|
|
clientId: z.string().optional(),
|
|
clientSecret: z.string().optional(),
|
|
})
|
|
.refine(
|
|
(data) => {
|
|
const { url, clientId, clientSecret } = data;
|
|
const allOrNone =
|
|
(url && clientId && clientSecret) ||
|
|
(!url && !clientId && !clientSecret);
|
|
return allOrNone;
|
|
},
|
|
{
|
|
message:
|
|
"Either all of url, clientId, and clientSecret must be provided, or none of them.",
|
|
}
|
|
),
|
|
});
|
|
|
|
export type GitLabConnectReq = z.infer<typeof GitLabConnectSchema>;
|