feat(container): add CRUD operations for container management
- Implemented routes for listing, retrieving, updating, and deleting containers. - Added ContainerModel with necessary fields and methods for data handling. - Created utility functions for fetching container data by ID. feat(page): enhance page management with CRUD and publish functionality - Developed routes for managing pages, including listing, updating, and deleting. - Integrated caching and zip file generation for page exports. - Added publish functionality to manage app versions and file uploads. feat(prompts): implement prompt management with CRUD operations - Created routes for listing, updating, and deleting prompts. - Added pagination and search capabilities for prompt listing. test: add common query utilities and prompt tests - Implemented common query utilities for API interactions. - Added tests for prompt listing functionality.
This commit is contained in:
@@ -68,13 +68,13 @@ export const cfRouterCode = pgTable("cf_router_code", {
|
||||
key: varchar({ length: 255 }).notNull(),
|
||||
active: boolean().default(false),
|
||||
project: varchar({ length: 255 }).default('default'),
|
||||
code: text().default('),
|
||||
code: text().default(''),
|
||||
type: enumCfRouterCodeType().default('route'),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
middleware: varchar({ length: 255 }).array().default(["RRAY[]::character varying[])::character varying(25"]),
|
||||
next: varchar({ length: 255 }).default('),
|
||||
exec: text().default('),
|
||||
next: varchar({ length: 255 }).default(''),
|
||||
exec: text().default(''),
|
||||
data: json().default({}),
|
||||
validator: json().default({}),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
@@ -107,7 +107,7 @@ export const cfUserSecrets = pgTable("cf_user_secrets", {
|
||||
status: varchar({ length: 255 }).default('active'),
|
||||
title: text(),
|
||||
expiredTime: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
token: varchar({ length: 255 }).default(').notNull(),
|
||||
token: varchar({ length: 255 }).default('').notNull(),
|
||||
userId: uuid(),
|
||||
data: jsonb().default({}),
|
||||
orgId: uuid(),
|
||||
@@ -133,7 +133,7 @@ export const chatPrompts = pgTable("chat_prompts", {
|
||||
title: varchar({ length: 255 }).notNull(),
|
||||
description: text(),
|
||||
data: json(),
|
||||
key: varchar({ length: 255 }).default(').notNull(),
|
||||
key: varchar({ length: 255 }).default('').notNull(),
|
||||
uid: varchar({ length: 255 }),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -148,7 +148,7 @@ export const chatSessions = pgTable("chat_sessions", {
|
||||
uid: varchar({ length: 255 }),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
title: varchar({ length: 255 }).default('),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
key: varchar({ length: 255 }),
|
||||
});
|
||||
|
||||
@@ -167,10 +167,10 @@ export const fileSync = pgTable("file_sync", {
|
||||
|
||||
export const kvAiChatHistory = pgTable("kv_ai_chat_history", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
username: varchar({ length: 255 }).default(').notNull(),
|
||||
model: varchar({ length: 255 }).default(').notNull(),
|
||||
group: varchar({ length: 255 }).default(').notNull(),
|
||||
title: varchar({ length: 255 }).default(').notNull(),
|
||||
username: varchar({ length: 255 }).default('').notNull(),
|
||||
model: varchar({ length: 255 }).default('').notNull(),
|
||||
group: varchar({ length: 255 }).default('').notNull(),
|
||||
title: varchar({ length: 255 }).default('').notNull(),
|
||||
messages: jsonb().default([]).notNull(),
|
||||
promptTokens: integer("prompt_tokens").default(0),
|
||||
totalTokens: integer("total_tokens").default(0),
|
||||
@@ -186,14 +186,14 @@ export const kvAiChatHistory = pgTable("kv_ai_chat_history", {
|
||||
export const kvApp = pgTable("kv_app", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
data: jsonb().default({}),
|
||||
version: varchar({ length: 255 }).default('),
|
||||
version: varchar({ length: 255 }).default(''),
|
||||
key: varchar({ length: 255 }),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
title: varchar({ length: 255 }).default('),
|
||||
description: varchar({ length: 255 }).default('),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
description: varchar({ length: 255 }).default(''),
|
||||
user: varchar({ length: 255 }),
|
||||
status: varchar({ length: 255 }).default('running'),
|
||||
pid: uuid(),
|
||||
@@ -220,7 +220,7 @@ export const kvAppDomain = pgTable("kv_app_domain", {
|
||||
export const kvAppList = pgTable("kv_app_list", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
data: json().default({}),
|
||||
version: varchar({ length: 255 }).default('),
|
||||
version: varchar({ length: 255 }).default(''),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -231,24 +231,24 @@ export const kvAppList = pgTable("kv_app_list", {
|
||||
|
||||
export const kvConfig = pgTable("kv_config", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: text().default('),
|
||||
key: text().default('),
|
||||
description: text().default('),
|
||||
title: text().default(''),
|
||||
key: text().default(''),
|
||||
description: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
data: jsonb().default({}),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
hash: text().default('),
|
||||
hash: text().default(''),
|
||||
});
|
||||
|
||||
export const kvContainer = pgTable("kv_container", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: text().default('),
|
||||
description: text().default('),
|
||||
title: text().default(''),
|
||||
description: text().default(''),
|
||||
type: varchar({ length: 255 }).default('render-js'),
|
||||
code: text().default('),
|
||||
code: text().default(''),
|
||||
data: json().default({}),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -256,13 +256,13 @@ export const kvContainer = pgTable("kv_container", {
|
||||
publish: json().default({}),
|
||||
tags: json().default([]),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
hash: text().default('),
|
||||
hash: text().default(''),
|
||||
});
|
||||
|
||||
export const kvGithub = pgTable("kv_github", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: varchar({ length: 255 }).default('),
|
||||
githubToken: varchar({ length: 255 }).default('),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
githubToken: varchar({ length: 255 }).default(''),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -271,8 +271,8 @@ export const kvGithub = pgTable("kv_github", {
|
||||
|
||||
export const kvPackages = pgTable("kv_packages", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: text().default('),
|
||||
description: text().default('),
|
||||
title: text().default(''),
|
||||
description: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
data: jsonb().default({}),
|
||||
publish: jsonb().default({}),
|
||||
@@ -285,9 +285,9 @@ export const kvPackages = pgTable("kv_packages", {
|
||||
|
||||
export const kvPage = pgTable("kv_page", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: varchar({ length: 255 }).default('),
|
||||
description: text().default('),
|
||||
type: varchar({ length: 255 }).default('),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
description: text().default(''),
|
||||
type: varchar({ length: 255 }).default(''),
|
||||
data: json().default({}),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -298,10 +298,10 @@ export const kvPage = pgTable("kv_page", {
|
||||
|
||||
export const kvResource = pgTable("kv_resource", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
name: varchar({ length: 255 }).default('),
|
||||
description: text().default('),
|
||||
source: varchar({ length: 255 }).default('),
|
||||
sourceId: varchar({ length: 255 }).default('),
|
||||
name: varchar({ length: 255 }).default(''),
|
||||
description: text().default(''),
|
||||
source: varchar({ length: 255 }).default(''),
|
||||
sourceId: varchar({ length: 255 }).default(''),
|
||||
version: varchar({ length: 255 }).default('0.0.0'),
|
||||
data: json().default({}),
|
||||
uid: uuid(),
|
||||
@@ -321,20 +321,20 @@ export const kvVip = pgTable("kv_vip", {
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
title: text().default(').notNull(),
|
||||
description: text().default(').notNull(),
|
||||
title: text().default('').notNull(),
|
||||
description: text().default('').notNull(),
|
||||
});
|
||||
|
||||
export const microAppsUpload = pgTable("micro_apps_upload", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: varchar({ length: 255 }).default('),
|
||||
description: varchar({ length: 255 }).default('),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
description: varchar({ length: 255 }).default(''),
|
||||
tags: jsonb().default([]),
|
||||
type: varchar({ length: 255 }).default('),
|
||||
source: varchar({ length: 255 }).default('),
|
||||
type: varchar({ length: 255 }).default(''),
|
||||
source: varchar({ length: 255 }).default(''),
|
||||
data: jsonb().default({}),
|
||||
share: boolean().default(false),
|
||||
uname: varchar({ length: 255 }).default('),
|
||||
uname: varchar({ length: 255 }).default(''),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
@@ -342,54 +342,41 @@ export const microAppsUpload = pgTable("micro_apps_upload", {
|
||||
|
||||
export const microMark = pgTable("micro_mark", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: text().default('),
|
||||
description: text().default('),
|
||||
title: text().default(''),
|
||||
description: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
data: jsonb().default({}),
|
||||
uname: varchar({ length: 255 }).default('),
|
||||
uname: varchar({ length: 255 }).default(''),
|
||||
uid: uuid(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
cover: text().default('),
|
||||
thumbnail: text().default('),
|
||||
link: text().default('),
|
||||
summary: text().default('),
|
||||
cover: text().default(''),
|
||||
thumbnail: text().default(''),
|
||||
link: text().default(''),
|
||||
summary: text().default(''),
|
||||
markType: text().default('md'),
|
||||
config: jsonb().default({}),
|
||||
puid: uuid(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
version: integer().default(1),
|
||||
fileList: jsonb().default([]),
|
||||
key: text().default('),
|
||||
key: text().default(''),
|
||||
});
|
||||
|
||||
export const prompts = pgTable("prompts", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: varchar({ length: 255 }).notNull(),
|
||||
description: text(),
|
||||
presetData: json(),
|
||||
key: varchar({ length: 255 }).notNull(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
}, (table) => [
|
||||
unique("prompts_key_key").on(table.key),
|
||||
]);
|
||||
|
||||
export const workShareMark = pgTable("work_share_mark", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
title: text().default('),
|
||||
key: text().default('),
|
||||
title: text().default(''),
|
||||
key: text().default(''),
|
||||
markType: text().default('md'),
|
||||
description: text().default('),
|
||||
cover: text().default('),
|
||||
link: text().default('),
|
||||
description: text().default(''),
|
||||
cover: text().default(''),
|
||||
link: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
summary: text().default('),
|
||||
summary: text().default(''),
|
||||
config: jsonb().default({}),
|
||||
data: jsonb().default({}),
|
||||
fileList: jsonb().default([]),
|
||||
uname: varchar({ length: 255 }).default('),
|
||||
uname: varchar({ length: 255 }).default(''),
|
||||
version: integer().default(1),
|
||||
markedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
uid: uuid(),
|
||||
@@ -398,3 +385,21 @@ export const workShareMark = pgTable("work_share_mark", {
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull(),
|
||||
deletedAt: timestamp({ withTimezone: true, mode: 'string' }),
|
||||
});
|
||||
|
||||
|
||||
export const prompts = pgTable('cf_prompts', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
uid: uuid('uid'),
|
||||
parents: jsonb('parents').notNull().default([]),
|
||||
data: jsonb('data').notNull().default({}),
|
||||
|
||||
title: text('title').default(''),
|
||||
description: text('description').default(''),
|
||||
summary: text('summary').default(''),
|
||||
tags: jsonb('tags').notNull().default([]),
|
||||
link: text('link').default(''),
|
||||
|
||||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
|
||||
deletedAt: timestamp('deletedAt'),
|
||||
});
|
||||
Reference in New Issue
Block a user