2025-07-07 03:42:35 +02:00
|
|
|
import { z } from "zod/v4";
|
2025-02-12 23:04:44 +01:00
|
|
|
import { Id } from "./common.ts";
|
2025-03-22 18:04:47 +01:00
|
|
|
import { RolePermission } from "./permissions.ts";
|
2025-02-11 18:22:39 +01:00
|
|
|
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
export const Role = z
|
|
|
|
|
.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
id: Id.meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "The role ID in the database.",
|
|
|
|
|
example: "b4a7e0f0-8f6a-479b-910b-9265c070d5bd",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
name: z.string().min(1).max(128).trim().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "The name of the role.",
|
|
|
|
|
example: "Moderator",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
permissions: z.array(z.enum(RolePermission)).meta({
|
|
|
|
|
description: "The permissions granted to the role.",
|
|
|
|
|
example: [
|
|
|
|
|
RolePermission.ManageEmojis,
|
|
|
|
|
RolePermission.ManageAccounts,
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
priority: z.number().int().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description:
|
|
|
|
|
"Role priority. Higher priority roles allow overriding lower priority roles.",
|
|
|
|
|
example: 100,
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
description: z.string().min(0).max(1024).trim().optional().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "Short role description.",
|
|
|
|
|
example: "Allows managing emojis and accounts.",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
visible: z.boolean().default(true).meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "Whether the role should be shown in the UI.",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
icon: z.url().optional().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "URL to the role icon.",
|
|
|
|
|
example: "https://example.com/role-icon.png",
|
|
|
|
|
}),
|
|
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description:
|
|
|
|
|
"Information about a role in the system, as well as its permissions.",
|
2025-07-07 03:42:35 +02:00
|
|
|
id: "Role",
|
2025-02-11 18:22:39 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
export const NoteReaction = z
|
|
|
|
|
.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
name: z.string().min(1).trim().meta({
|
2025-05-13 11:51:59 +02:00
|
|
|
description: "Custom Emoji shortcode or Unicode emoji.",
|
|
|
|
|
example: "blobfox_coffee",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
count: z.number().int().nonnegative().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "Number of users who reacted with this emoji.",
|
|
|
|
|
example: 5,
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
remote: z.boolean().meta({
|
2025-05-28 17:07:24 +02:00
|
|
|
description:
|
|
|
|
|
"Whether this reaction is from a remote instance (federated).",
|
|
|
|
|
example: false,
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
me: z.boolean().optional().meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description:
|
|
|
|
|
"Whether the current authenticated user reacted with this emoji.",
|
|
|
|
|
example: true,
|
|
|
|
|
}),
|
|
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "Information about a reaction to a note.",
|
2025-07-07 03:42:35 +02:00
|
|
|
id: "NoteReaction",
|
2025-02-11 18:22:39 +01:00
|
|
|
});
|
2025-02-12 23:04:44 +01:00
|
|
|
|
2025-05-25 16:11:56 +02:00
|
|
|
/* Versia Server API extension */
|
|
|
|
|
export const NoteReactionWithAccounts = NoteReaction.extend({
|
2025-07-07 03:42:35 +02:00
|
|
|
account_ids: z.array(Id).meta({
|
2025-05-25 16:11:56 +02:00
|
|
|
description: "Array of user IDs who reacted with this emoji.",
|
|
|
|
|
example: [
|
|
|
|
|
"1d0185bc-d949-4ff5-8a15-1d691b256489",
|
|
|
|
|
"d9de4aeb-4591-424d-94ec-659f958aa23d",
|
|
|
|
|
"1f0c4eb9-a742-4c82-96c9-697a39831cd1",
|
|
|
|
|
],
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
}).meta({
|
2025-05-25 16:11:56 +02:00
|
|
|
description: "Information about a reaction to a note with account IDs.",
|
2025-07-07 03:42:35 +02:00
|
|
|
id: "NoteReactionWithAccounts",
|
2025-05-25 16:11:56 +02:00
|
|
|
});
|
|
|
|
|
|
2025-02-12 23:04:44 +01:00
|
|
|
/* Versia Server API extension */
|
|
|
|
|
export const SSOConfig = z.object({
|
|
|
|
|
providers: z
|
|
|
|
|
.array(
|
|
|
|
|
z.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
id: z.string().min(1).meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
description: "The ID of the provider.",
|
|
|
|
|
example: "google",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
name: z.string().min(1).meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
description: "Human-readable provider name.",
|
|
|
|
|
example: "Google",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
icon: z.url().optional().meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
description: "URL to the provider icon.",
|
|
|
|
|
example: "https://cdn.versia.social/google-icon.png",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
)
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-02-12 23:04:44 +01:00
|
|
|
description:
|
|
|
|
|
"An array of external OpenID Connect providers that users can link their accounts to.",
|
|
|
|
|
}),
|
|
|
|
|
});
|
2025-03-22 04:04:06 +01:00
|
|
|
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
export const Challenge = z
|
|
|
|
|
.object({
|
2025-07-07 03:42:35 +02:00
|
|
|
id: Id.meta({}).meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Challenge ID in the database.",
|
|
|
|
|
example: "b4a7e0f0-8f6a-479b-910b-9265c070d5bd",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
algorithm: z.enum(["SHA-1", "SHA-256", "SHA-512"]).meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Algorithm used to generate the challenge.",
|
|
|
|
|
example: "SHA-1",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
challenge: z.string().meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Challenge to solve.",
|
|
|
|
|
example: "1234567890",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
maxnumber: z.number().int().nonnegative().optional().meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Maximum number to solve the challenge.",
|
|
|
|
|
example: 100,
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
salt: z.string().meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Salt used to generate the challenge.",
|
|
|
|
|
example: "1234567890",
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
signature: z.string().meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "Signature of the challenge.",
|
|
|
|
|
example: "1234567890",
|
|
|
|
|
}),
|
|
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-03-22 04:04:06 +01:00
|
|
|
description: "A cryptographic challenge to solve. Used for Captchas.",
|
2025-07-07 03:42:35 +02:00
|
|
|
id: "Challenge",
|
2025-03-22 04:04:06 +01:00
|
|
|
});
|