fix: MedSchedule ESM import for Router and data table links resolution
This commit is contained in:
@@ -1849,6 +1849,23 @@ export const dataTables = pgTable("data_tables", {
|
||||
folderIdx: index("data_tables_folder_idx").on(table.folderId),
|
||||
}));
|
||||
|
||||
// Data table links (подсправочники / связанные справочники)
|
||||
export const dataTableLinks = pgTable("data_table_links", {
|
||||
id: serial("id").primaryKey(),
|
||||
organizationId: integer("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
||||
parentTableId: integer("parent_table_id").notNull().references(() => dataTables.id, { onDelete: "cascade" }),
|
||||
childTableId: integer("child_table_id").notNull().references(() => dataTables.id, { onDelete: "cascade" }),
|
||||
parentColumnIndex: integer("parent_column_index").notNull().default(0),
|
||||
childColumnIndex: integer("child_column_index").notNull().default(0),
|
||||
parentValues: jsonb("parent_values").notNull().$type<string[]>().default([]),
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
}, (table) => ({
|
||||
parentIdx: index("data_table_links_parent_idx").on(table.parentTableId),
|
||||
childIdx: index("data_table_links_child_idx").on(table.childTableId),
|
||||
uniqueParentChild: unique("data_table_links_parent_child_unique").on(table.parentTableId, table.childTableId),
|
||||
}));
|
||||
|
||||
// Directory/table folders table
|
||||
export const directoryFolders = pgTable("directory_folders", {
|
||||
id: serial("id").primaryKey(),
|
||||
@@ -1920,6 +1937,25 @@ export const dataTablesRelations = relations(dataTables, ({ one, many }) => ({
|
||||
}),
|
||||
rows: many(dataTableRows),
|
||||
permissions: many(dataTablePermissions),
|
||||
parentLinks: many(dataTableLinks, { relationName: "parentLinks" }),
|
||||
childLinks: many(dataTableLinks, { relationName: "childLinks" }),
|
||||
}));
|
||||
|
||||
export const dataTableLinksRelations = relations(dataTableLinks, ({ one }) => ({
|
||||
organization: one(organizations, {
|
||||
fields: [dataTableLinks.organizationId],
|
||||
references: [organizations.id],
|
||||
}),
|
||||
parentTable: one(dataTables, {
|
||||
fields: [dataTableLinks.parentTableId],
|
||||
references: [dataTables.id],
|
||||
relationName: "parentLinks",
|
||||
}),
|
||||
childTable: one(dataTables, {
|
||||
fields: [dataTableLinks.childTableId],
|
||||
references: [dataTables.id],
|
||||
relationName: "childLinks",
|
||||
}),
|
||||
}));
|
||||
|
||||
export const directoryFoldersRelations = relations(directoryFolders, ({ one, many }) => ({
|
||||
@@ -2040,6 +2076,8 @@ export type DataTable = typeof dataTables.$inferSelect;
|
||||
export type DataTableRow = typeof dataTableRows.$inferSelect;
|
||||
export type DataTablePermission = typeof dataTablePermissions.$inferSelect;
|
||||
export type DataTableAccessRule = typeof dataTableAccessRules.$inferSelect;
|
||||
export type DataTableLink = typeof dataTableLinks.$inferSelect;
|
||||
export type InsertDataTableLink = typeof dataTableLinks.$inferInsert;
|
||||
export type InsertDataTable = z.infer<typeof insertDataTableSchema>;
|
||||
export type InsertDataTableRow = z.infer<typeof insertDataTableRowSchema>;
|
||||
export type InsertDataTablePermission = z.infer<typeof insertDataTablePermissionSchema>;
|
||||
@@ -2051,6 +2089,10 @@ export type SetTablePermission = z.infer<typeof setTablePermissionSchema>;
|
||||
export type SyncDataTable = z.infer<typeof syncDataTableSchema>;
|
||||
export type DiffDataTable = z.infer<typeof diffDataTableSchema>;
|
||||
|
||||
export type DataTableSubdirectory = DataTableLink & {
|
||||
childTable?: { id: number; name: string; columns: DataTable['columns'] } | null;
|
||||
};
|
||||
|
||||
export type DataTableWithRows = DataTable & {
|
||||
rows: DataTableRow[];
|
||||
};
|
||||
@@ -2062,6 +2104,7 @@ export type DataTableWithPermissions = DataTable & {
|
||||
export type DataTableFull = DataTable & {
|
||||
rows: DataTableRow[];
|
||||
permissions: (DataTablePermission & { user: { id: number; firstName: string; lastName: string; email: string } })[];
|
||||
subdirectories: DataTableSubdirectory[];
|
||||
};
|
||||
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user