mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-04 11:01:16 +01:00
Add folders schema and backend API
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
ad961227f5
commit
ef86752e46
24 files changed
+823
-1
No files matched your search
@@ -3,6 +3,10 @@ export const API_PREFIX = "/api";
|
||||
export const API = {
|
||||
health: `${API_PREFIX}/health`,
|
||||
companies: `${API_PREFIX}/companies`,
|
||||
companyFolders: `${API_PREFIX}/companies/:companyId/folders`,
|
||||
companyFolder: `${API_PREFIX}/companies/:companyId/folders/:folderId`,
|
||||
companyFolderMove: `${API_PREFIX}/companies/:companyId/folders/:folderId/move`,
|
||||
companyFolderItemMove: `${API_PREFIX}/companies/:companyId/folders/items/move`,
|
||||
agents: `${API_PREFIX}/agents`,
|
||||
projects: `${API_PREFIX}/projects`,
|
||||
environments: `${API_PREFIX}/environments`,
|
||||
|
||||
@@ -1631,12 +1631,36 @@ export type {
|
||||
} from "./environment-support.js";
|
||||
|
||||
export type { AdapterRegistryEntry } from "./types/adapter-registry.js";
|
||||
export type {
|
||||
FolderKind,
|
||||
Folder,
|
||||
FolderListItem,
|
||||
FolderListResult,
|
||||
CreateFolderRequest,
|
||||
UpdateFolderRequest,
|
||||
MoveFolderRequest,
|
||||
MoveFolderItemRequest,
|
||||
} from "./types/folder.js";
|
||||
|
||||
export {
|
||||
adapterRegistryEntrySchema,
|
||||
adapterRegistrySchema,
|
||||
type AdapterRegistryEntryParsed,
|
||||
} from "./validators/adapter-registry.js";
|
||||
export {
|
||||
folderKindSchema,
|
||||
folderSchema,
|
||||
folderListItemSchema,
|
||||
folderListResultSchema,
|
||||
createFolderSchema,
|
||||
updateFolderSchema,
|
||||
moveFolderSchema,
|
||||
moveFolderItemSchema,
|
||||
type CreateFolder,
|
||||
type UpdateFolder,
|
||||
type MoveFolder,
|
||||
type MoveFolderItem,
|
||||
} from "./validators/folder.js";
|
||||
|
||||
export {
|
||||
environmentCustomImageTemplateKindSchema,
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface CompanySkillVersionFileInventoryEntry extends CompanySkillFileI
|
||||
export interface CompanySkill {
|
||||
id: string;
|
||||
companyId: string;
|
||||
folderId?: string | null;
|
||||
key: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
@@ -55,6 +56,7 @@ export interface CompanySkill {
|
||||
export interface CompanySkillListItem {
|
||||
id: string;
|
||||
companyId: string;
|
||||
folderId?: string | null;
|
||||
key: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
export type FolderKind = "routine" | "skill";
|
||||
|
||||
export interface Folder {
|
||||
id: string;
|
||||
companyId: string;
|
||||
kind: FolderKind;
|
||||
name: string;
|
||||
color: string | null;
|
||||
position: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface FolderListItem extends Folder {
|
||||
itemCount: number;
|
||||
}
|
||||
|
||||
export interface FolderListResult {
|
||||
kind: FolderKind;
|
||||
folders: FolderListItem[];
|
||||
allCount: number;
|
||||
unfiledCount: number;
|
||||
}
|
||||
|
||||
export interface CreateFolderRequest {
|
||||
kind: FolderKind;
|
||||
name: string;
|
||||
color?: string | null;
|
||||
position?: number | null;
|
||||
}
|
||||
|
||||
export interface UpdateFolderRequest {
|
||||
name?: string;
|
||||
color?: string | null;
|
||||
position?: number;
|
||||
}
|
||||
|
||||
export interface MoveFolderRequest {
|
||||
position: number;
|
||||
}
|
||||
|
||||
export interface MoveFolderItemRequest {
|
||||
kind: FolderKind;
|
||||
itemId: string;
|
||||
folderId?: string | null;
|
||||
}
|
||||
@@ -106,6 +106,16 @@ export type {
|
||||
CompanySkillInstallCatalogRequest,
|
||||
CompanySkillInstallCatalogResult,
|
||||
} from "./company-skill.js";
|
||||
export type {
|
||||
FolderKind,
|
||||
Folder,
|
||||
FolderListItem,
|
||||
FolderListResult,
|
||||
CreateFolderRequest,
|
||||
UpdateFolderRequest,
|
||||
MoveFolderRequest,
|
||||
MoveFolderItemRequest,
|
||||
} from "./folder.js";
|
||||
export type {
|
||||
CatalogTeamKind,
|
||||
CatalogTeamTrustLevel,
|
||||
|
||||
@@ -71,6 +71,7 @@ export interface Routine {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string | null;
|
||||
folderId?: string | null;
|
||||
goalId: string | null;
|
||||
parentIssueId: string | null;
|
||||
title: string;
|
||||
|
||||
@@ -19,6 +19,7 @@ export const companySkillVersionFileInventoryEntrySchema = companySkillFileInven
|
||||
export const companySkillSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
folderId: z.string().uuid().nullable().optional(),
|
||||
key: z.string().min(1),
|
||||
slug: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const folderKindSchema = z.enum(["routine", "skill"]);
|
||||
|
||||
export const folderSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
kind: folderKindSchema,
|
||||
name: z.string().min(1),
|
||||
color: z.string().nullable(),
|
||||
position: z.number().int(),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date(),
|
||||
});
|
||||
|
||||
export const folderListItemSchema = folderSchema.extend({
|
||||
itemCount: z.number().int().nonnegative(),
|
||||
});
|
||||
|
||||
export const folderListResultSchema = z.object({
|
||||
kind: folderKindSchema,
|
||||
folders: z.array(folderListItemSchema),
|
||||
allCount: z.number().int().nonnegative(),
|
||||
unfiledCount: z.number().int().nonnegative(),
|
||||
});
|
||||
|
||||
export const createFolderSchema = z.object({
|
||||
kind: folderKindSchema,
|
||||
name: z.string().trim().min(1).max(120),
|
||||
color: z.string().trim().min(1).max(80).optional().nullable(),
|
||||
position: z.number().int().min(0).optional().nullable(),
|
||||
});
|
||||
|
||||
export const updateFolderSchema = z.object({
|
||||
name: z.string().trim().min(1).max(120).optional(),
|
||||
color: z.string().trim().min(1).max(80).optional().nullable(),
|
||||
position: z.number().int().min(0).optional(),
|
||||
}).refine((value) => Object.keys(value).length > 0, {
|
||||
message: "At least one folder field is required",
|
||||
});
|
||||
|
||||
export const moveFolderSchema = z.object({
|
||||
position: z.number().int().min(0),
|
||||
});
|
||||
|
||||
export const moveFolderItemSchema = z.object({
|
||||
kind: folderKindSchema,
|
||||
itemId: z.string().uuid(),
|
||||
folderId: z.string().uuid().optional().nullable(),
|
||||
});
|
||||
|
||||
export type CreateFolder = z.infer<typeof createFolderSchema>;
|
||||
export type UpdateFolder = z.infer<typeof updateFolderSchema>;
|
||||
export type MoveFolder = z.infer<typeof moveFolderSchema>;
|
||||
export type MoveFolderItem = z.infer<typeof moveFolderItemSchema>;
|
||||
@@ -156,6 +156,20 @@ export {
|
||||
type CompanySkillInstallUpdate,
|
||||
type CompanySkillReset,
|
||||
} from "./company-skill.js";
|
||||
export {
|
||||
folderKindSchema,
|
||||
folderSchema,
|
||||
folderListItemSchema,
|
||||
folderListResultSchema,
|
||||
createFolderSchema,
|
||||
updateFolderSchema,
|
||||
moveFolderSchema,
|
||||
moveFolderItemSchema,
|
||||
type CreateFolder,
|
||||
type UpdateFolder,
|
||||
type MoveFolder,
|
||||
type MoveFolderItem,
|
||||
} from "./folder.js";
|
||||
export {
|
||||
catalogTeamKindSchema,
|
||||
catalogTeamTrustLevelSchema,
|
||||
|
||||
@@ -61,6 +61,7 @@ export const routineVariableSchema = z.object({
|
||||
|
||||
export const createRoutineSchema = z.object({
|
||||
projectId: z.string().uuid().optional().nullable(),
|
||||
folderId: z.string().uuid().optional().nullable(),
|
||||
goalId: z.string().uuid().optional().nullable(),
|
||||
parentIssueId: z.string().uuid().optional().nullable(),
|
||||
title: z.string().trim().min(1).max(200),
|
||||
@@ -85,6 +86,7 @@ export const routineRevisionSnapshotRoutineV1Schema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
projectId: z.string().uuid().nullable(),
|
||||
folderId: z.string().uuid().nullable().optional(),
|
||||
goalId: z.string().uuid().nullable(),
|
||||
parentIssueId: z.string().uuid().nullable(),
|
||||
title: z.string().trim().min(1).max(200),
|
||||
|
||||
Reference in new issue
Block a user