refactor(modules): moved modules to app to control everything based on there active setting

This commit is contained in:
2025-10-29 21:57:11 -05:00
parent 6493e0398a
commit 99b2d762d6
35 changed files with 5807 additions and 121 deletions

View File

@@ -0,0 +1,42 @@
import {
boolean,
jsonb,
pgTable,
text,
timestamp,
uniqueIndex,
uuid,
} from "drizzle-orm/pg-core";
import { createSelectSchema } from "drizzle-zod";
//import {z} from "zod";
export const modules = pgTable(
"modules",
{
module_id: uuid("module_id").defaultRandom().primaryKey(),
name: text("name").notNull(),
active: boolean("active").default(false),
category: text("category"),
icon: text("icon"),
link: text("link"),
//roles: text("roles").notNull().default(`["view", "systemAdmin"]`), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
roles: jsonb("roles").notNull().default(["view", "systemAdmin"]), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
add_User: text("add_User").default("LST_System").notNull(),
add_Date: timestamp("add_Date").defaultNow(),
upd_user: text("upd_User").default("LST_System").notNull(),
upd_date: timestamp("upd_date").defaultNow(),
},
(table) => [
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
uniqueIndex("module_name").on(table.name),
],
);
// Schema for inserting a user - can be used to validate API requests
// export const insertModuleSchema = createInsertSchema(modules, {
// name: z.string().min(3, {message: "Module name should be longer than 3 letters"}),
// });
// Schema for selecting a Expenses - can be used to validate API responses
export const selectModuleSchema = createSelectSchema(modules);
export type Modules = typeof modules;