* fix: refactor urlHelpers * fix: move to /plugins/slack/shared * fix: remove .babelrc * fix: remove Outline class * fix: Slack -> SlackUtils * fix: UrlHelper class
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import isUUID from "validator/lib/isUUID";
|
|
import { z } from "zod";
|
|
import { UrlHelper } from "@shared/utils/UrlHelper";
|
|
import { BaseSchema } from "../schema";
|
|
|
|
export const PinsCreateSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
documentId: z
|
|
.string({
|
|
required_error: "required",
|
|
})
|
|
.refine((val) => isUUID(val) || UrlHelper.SLUG_URL_REGEX.test(val), {
|
|
message: "must be uuid or url slug",
|
|
}),
|
|
collectionId: z.string().uuid().nullish(),
|
|
index: z
|
|
.string()
|
|
.regex(new RegExp("^[\x20-\x7E]+$"), {
|
|
message: "must be between x20 to x7E ASCII",
|
|
})
|
|
.optional(),
|
|
}),
|
|
});
|
|
|
|
export type PinsCreateReq = z.infer<typeof PinsCreateSchema>;
|
|
|
|
export const PinsListSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
collectionId: z.string().uuid().nullish(),
|
|
}),
|
|
});
|
|
|
|
export type PinsListReq = z.infer<typeof PinsCreateSchema>;
|
|
|
|
export const PinsUpdateSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
id: z.string().uuid(),
|
|
index: z.string().regex(new RegExp("^[\x20-\x7E]+$"), {
|
|
message: "must be between x20 to x7E ASCII",
|
|
}),
|
|
}),
|
|
});
|
|
|
|
export type PinsUpdateReq = z.infer<typeof PinsUpdateSchema>;
|
|
|
|
export const PinsDeleteSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
id: z.string().uuid(),
|
|
}),
|
|
});
|
|
|
|
export type PinsDeleteReq = z.infer<typeof PinsDeleteSchema>;
|