mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-08 17:23:24 +00:00
Add webhook functionality for improved system integration.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/e169437d-3ae3-44b9-a3e9-0587a0e99e6c.jpg
This commit is contained in:
@@ -89,6 +89,20 @@ export const apiTokens = pgTable("api_tokens", {
|
||||
expiresAt: timestamp("expires_at"),
|
||||
});
|
||||
|
||||
// Webhooks
|
||||
export const webhooks = pgTable("webhooks", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
url: text("url").notNull(),
|
||||
organizationId: uuid("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
||||
secret: text("secret"),
|
||||
events: text("events").array().notNull(),
|
||||
isActive: boolean("is_active").default(true).notNull(),
|
||||
lastTriggered: timestamp("last_triggered"),
|
||||
createdBy: uuid("created_by").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
// Custom roles table for user-defined roles beyond system defaults
|
||||
export const customRoles = pgTable("custom_roles", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
@@ -216,6 +230,15 @@ export const insertGroupRoleSchema = createInsertSchema(groupRoles).pick({
|
||||
assignedBy: true,
|
||||
});
|
||||
|
||||
export const insertWebhookSchema = createInsertSchema(webhooks).pick({
|
||||
name: true,
|
||||
url: true,
|
||||
organizationId: true,
|
||||
secret: true,
|
||||
events: true,
|
||||
isActive: true,
|
||||
createdBy: true,
|
||||
});
|
||||
|
||||
|
||||
// Types
|
||||
@@ -247,6 +270,8 @@ export type InsertCustomRole = z.infer<typeof insertCustomRoleSchema>;
|
||||
export type InsertGroup = z.infer<typeof insertGroupSchema>;
|
||||
export type InsertGroupMember = z.infer<typeof insertGroupMemberSchema>;
|
||||
export type InsertGroupRole = z.infer<typeof insertGroupRoleSchema>;
|
||||
export type InsertWebhook = z.infer<typeof insertWebhookSchema>;
|
||||
export type Webhook = typeof webhooks.$inferSelect;
|
||||
|
||||
// Role Types
|
||||
// System default roles - these will still be available alongside custom roles
|
||||
@@ -273,6 +298,7 @@ export const organizationsRelations = relations(organizations, ({ many }) => ({
|
||||
users: many(users),
|
||||
domains: many(domains),
|
||||
apiTokens: many(apiTokens),
|
||||
webhooks: many(webhooks),
|
||||
}));
|
||||
|
||||
export const domainsRelations = relations(domains, ({ one, many }) => ({
|
||||
@@ -321,6 +347,16 @@ export const apiTokensRelations = relations(apiTokens, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const webhooksRelations = relations(webhooks, ({ one }) => ({
|
||||
organization: one(organizations, {
|
||||
fields: [webhooks.organizationId],
|
||||
references: [organizations.id],
|
||||
}),
|
||||
creator: one(users, {
|
||||
fields: [webhooks.createdBy],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
// Custom roles relations
|
||||
|
||||
Reference in New Issue
Block a user