feat: custom widgets (#5889)
This commit is contained in:
1 parent
48e1844b5b
commit
aecbca2b81
69 files changed
+14620
-142
No files matched your search
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE `custom_widget_definition` (
|
||||
`id` varchar(64) NOT NULL,
|
||||
`name` varchar(256) NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`base_url` text NOT NULL,
|
||||
`auth_type` varchar(32) NOT NULL DEFAULT 'none',
|
||||
`header_name` varchar(256),
|
||||
`endpoint` text NOT NULL,
|
||||
`method` varchar(16) NOT NULL DEFAULT 'GET',
|
||||
`request_body` text,
|
||||
`display_type` varchar(32) NOT NULL DEFAULT 'singleValue',
|
||||
`display_config` text NOT NULL DEFAULT ('{"json": {}}'),
|
||||
`created_at` timestamp NOT NULL DEFAULT (now()),
|
||||
`updated_at` timestamp NOT NULL DEFAULT (now()),
|
||||
`creator_id` varchar(64),
|
||||
CONSTRAINT `custom_widget_definition_id` PRIMARY KEY(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `custom_widget_secret` (
|
||||
`kind` varchar(64) NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` timestamp NOT NULL,
|
||||
`definition_id` varchar(64) NOT NULL,
|
||||
CONSTRAINT `custom_widget_secret_definition_id_kind_pk` PRIMARY KEY(`definition_id`,`kind`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` ADD CONSTRAINT `custom_widget_definition_creator_id_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_secret` ADD CONSTRAINT `cw_secret_definition_id_cw_definition_id_fk` FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE `custom_widget_definition` ADD `url` text;--> statement-breakpoint
|
||||
UPDATE `custom_widget_definition` SET `url` = CONCAT(`base_url`, `endpoint`);--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` MODIFY `url` text NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` DROP COLUMN `base_url`;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` DROP COLUMN `endpoint`;--> statement-breakpoint
|
||||
ALTER TABLE `custom_widget_definition` ADD `enabled` boolean NOT NULL DEFAULT true;
|
||||
@@ -2,7 +2,7 @@
|
||||
"version": "5",
|
||||
"dialect": "mysql",
|
||||
"id": "ddg-bangs-mysql-0038",
|
||||
"prevId": "ddg-bangs-mysql-0038",
|
||||
"prevId": "730ee1c1-a35e-426f-a828-7ecde882f920",
|
||||
"tables": {
|
||||
"account": {
|
||||
"name": "account",
|
||||
@@ -88,7 +88,9 @@
|
||||
"indexes": {
|
||||
"userId_idx": {
|
||||
"name": "userId_idx",
|
||||
"columns": ["user_id"],
|
||||
"columns": [
|
||||
"user_id"
|
||||
],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
@@ -97,8 +99,12 @@
|
||||
"name": "account_user_id_user_id_fk",
|
||||
"tableFrom": "account",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -106,7 +112,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"account_provider_provider_account_id_pk": {
|
||||
"name": "account_provider_provider_account_id_pk",
|
||||
"columns": ["provider", "provider_account_id"]
|
||||
"columns": [
|
||||
"provider",
|
||||
"provider_account_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -143,8 +152,12 @@
|
||||
"name": "apiKey_user_id_user_id_fk",
|
||||
"tableFrom": "apiKey",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -152,7 +165,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"apiKey_id": {
|
||||
"name": "apiKey_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -209,7 +224,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"app_id": {
|
||||
"name": "app_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -246,8 +263,12 @@
|
||||
"name": "boardGroupPermission_board_id_board_id_fk",
|
||||
"tableFrom": "boardGroupPermission",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -255,8 +276,12 @@
|
||||
"name": "boardGroupPermission_group_id_group_id_fk",
|
||||
"tableFrom": "boardGroupPermission",
|
||||
"tableTo": "group",
|
||||
"columnsFrom": ["group_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"group_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -264,7 +289,11 @@
|
||||
"compositePrimaryKeys": {
|
||||
"boardGroupPermission_board_id_group_id_permission_pk": {
|
||||
"name": "boardGroupPermission_board_id_group_id_permission_pk",
|
||||
"columns": ["board_id", "group_id", "permission"]
|
||||
"columns": [
|
||||
"board_id",
|
||||
"group_id",
|
||||
"permission"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -301,8 +330,12 @@
|
||||
"name": "boardUserPermission_board_id_board_id_fk",
|
||||
"tableFrom": "boardUserPermission",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -310,8 +343,12 @@
|
||||
"name": "boardUserPermission_user_id_user_id_fk",
|
||||
"tableFrom": "boardUserPermission",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -319,7 +356,11 @@
|
||||
"compositePrimaryKeys": {
|
||||
"boardUserPermission_board_id_user_id_permission_pk": {
|
||||
"name": "boardUserPermission_board_id_user_id_permission_pk",
|
||||
"columns": ["board_id", "user_id", "permission"]
|
||||
"columns": [
|
||||
"board_id",
|
||||
"user_id",
|
||||
"permission"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -477,8 +518,12 @@
|
||||
"name": "board_creator_id_user_id_fk",
|
||||
"tableFrom": "board",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["creator_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"creator_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -486,13 +531,17 @@
|
||||
"compositePrimaryKeys": {
|
||||
"board_id": {
|
||||
"name": "board_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"board_name_unique": {
|
||||
"name": "board_name_unique",
|
||||
"columns": ["name"]
|
||||
"columns": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraint": {}
|
||||
@@ -528,7 +577,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"cron_job_configuration_name": {
|
||||
"name": "cron_job_configuration_name",
|
||||
"columns": ["name"]
|
||||
"columns": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -558,8 +609,12 @@
|
||||
"name": "groupMember_group_id_group_id_fk",
|
||||
"tableFrom": "groupMember",
|
||||
"tableTo": "group",
|
||||
"columnsFrom": ["group_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"group_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -567,8 +622,12 @@
|
||||
"name": "groupMember_user_id_user_id_fk",
|
||||
"tableFrom": "groupMember",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -576,7 +635,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"groupMember_group_id_user_id_pk": {
|
||||
"name": "groupMember_group_id_user_id_pk",
|
||||
"columns": ["group_id", "user_id"]
|
||||
"columns": [
|
||||
"group_id",
|
||||
"user_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -606,8 +668,12 @@
|
||||
"name": "groupPermission_group_id_group_id_fk",
|
||||
"tableFrom": "groupPermission",
|
||||
"tableTo": "group",
|
||||
"columnsFrom": ["group_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"group_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -668,8 +734,12 @@
|
||||
"name": "group_owner_id_user_id_fk",
|
||||
"tableFrom": "group",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["owner_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"owner_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -677,8 +747,12 @@
|
||||
"name": "group_home_board_id_board_id_fk",
|
||||
"tableFrom": "group",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["home_board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"home_board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -686,8 +760,12 @@
|
||||
"name": "group_mobile_home_board_id_board_id_fk",
|
||||
"tableFrom": "group",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["mobile_home_board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"mobile_home_board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -695,13 +773,17 @@
|
||||
"compositePrimaryKeys": {
|
||||
"group_id": {
|
||||
"name": "group_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"group_name_unique": {
|
||||
"name": "group_name_unique",
|
||||
"columns": ["name"]
|
||||
"columns": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraint": {}
|
||||
@@ -729,7 +811,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"iconRepository_id": {
|
||||
"name": "iconRepository_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -780,8 +864,12 @@
|
||||
"name": "icon_icon_repository_id_iconRepository_id_fk",
|
||||
"tableFrom": "icon",
|
||||
"tableTo": "iconRepository",
|
||||
"columnsFrom": ["icon_repository_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"icon_repository_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -789,7 +877,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"icon_id": {
|
||||
"name": "icon_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -826,8 +916,12 @@
|
||||
"name": "integrationGroupPermissions_integration_id_integration_id_fk",
|
||||
"tableFrom": "integrationGroupPermissions",
|
||||
"tableTo": "integration",
|
||||
"columnsFrom": ["integration_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"integration_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -835,8 +929,12 @@
|
||||
"name": "integrationGroupPermissions_group_id_group_id_fk",
|
||||
"tableFrom": "integrationGroupPermissions",
|
||||
"tableTo": "group",
|
||||
"columnsFrom": ["group_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"group_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -844,7 +942,11 @@
|
||||
"compositePrimaryKeys": {
|
||||
"integration_group_permission__pk": {
|
||||
"name": "integration_group_permission__pk",
|
||||
"columns": ["integration_id", "group_id", "permission"]
|
||||
"columns": [
|
||||
"integration_id",
|
||||
"group_id",
|
||||
"permission"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -874,8 +976,12 @@
|
||||
"name": "integration_item_item_id_item_id_fk",
|
||||
"tableFrom": "integration_item",
|
||||
"tableTo": "item",
|
||||
"columnsFrom": ["item_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"item_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -883,8 +989,12 @@
|
||||
"name": "integration_item_integration_id_integration_id_fk",
|
||||
"tableFrom": "integration_item",
|
||||
"tableTo": "integration",
|
||||
"columnsFrom": ["integration_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"integration_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -892,7 +1002,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"integration_item_item_id_integration_id_pk": {
|
||||
"name": "integration_item_item_id_integration_id_pk",
|
||||
"columns": ["item_id", "integration_id"]
|
||||
"columns": [
|
||||
"item_id",
|
||||
"integration_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -933,12 +1046,16 @@
|
||||
"indexes": {
|
||||
"integration_secret__kind_idx": {
|
||||
"name": "integration_secret__kind_idx",
|
||||
"columns": ["kind"],
|
||||
"columns": [
|
||||
"kind"
|
||||
],
|
||||
"isUnique": false
|
||||
},
|
||||
"integration_secret__updated_at_idx": {
|
||||
"name": "integration_secret__updated_at_idx",
|
||||
"columns": ["updated_at"],
|
||||
"columns": [
|
||||
"updated_at"
|
||||
],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
@@ -947,8 +1064,12 @@
|
||||
"name": "integrationSecret_integration_id_integration_id_fk",
|
||||
"tableFrom": "integrationSecret",
|
||||
"tableTo": "integration",
|
||||
"columnsFrom": ["integration_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"integration_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -956,7 +1077,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"integrationSecret_integration_id_kind_pk": {
|
||||
"name": "integrationSecret_integration_id_kind_pk",
|
||||
"columns": ["integration_id", "kind"]
|
||||
"columns": [
|
||||
"integration_id",
|
||||
"kind"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -993,8 +1117,12 @@
|
||||
"name": "integrationUserPermission_integration_id_integration_id_fk",
|
||||
"tableFrom": "integrationUserPermission",
|
||||
"tableTo": "integration",
|
||||
"columnsFrom": ["integration_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"integration_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1002,8 +1130,12 @@
|
||||
"name": "integrationUserPermission_user_id_user_id_fk",
|
||||
"tableFrom": "integrationUserPermission",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1011,7 +1143,11 @@
|
||||
"compositePrimaryKeys": {
|
||||
"integrationUserPermission_integration_id_user_id_permission_pk": {
|
||||
"name": "integrationUserPermission_integration_id_user_id_permission_pk",
|
||||
"columns": ["integration_id", "user_id", "permission"]
|
||||
"columns": [
|
||||
"integration_id",
|
||||
"user_id",
|
||||
"permission"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1059,7 +1195,9 @@
|
||||
"indexes": {
|
||||
"integration__kind_idx": {
|
||||
"name": "integration__kind_idx",
|
||||
"columns": ["kind"],
|
||||
"columns": [
|
||||
"kind"
|
||||
],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
@@ -1068,8 +1206,12 @@
|
||||
"name": "integration_app_id_app_id_fk",
|
||||
"tableFrom": "integration",
|
||||
"tableTo": "app",
|
||||
"columnsFrom": ["app_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"app_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1077,7 +1219,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"integration_id": {
|
||||
"name": "integration_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1121,8 +1265,12 @@
|
||||
"name": "invite_creator_id_user_id_fk",
|
||||
"tableFrom": "invite",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["creator_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"creator_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1130,13 +1278,17 @@
|
||||
"compositePrimaryKeys": {
|
||||
"invite_id": {
|
||||
"name": "invite_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"invite_token_unique": {
|
||||
"name": "invite_token_unique",
|
||||
"columns": ["token"]
|
||||
"columns": [
|
||||
"token"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraint": {}
|
||||
@@ -1200,8 +1352,12 @@
|
||||
"name": "item_layout_item_id_item_id_fk",
|
||||
"tableFrom": "item_layout",
|
||||
"tableTo": "item",
|
||||
"columnsFrom": ["item_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"item_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1209,8 +1365,12 @@
|
||||
"name": "item_layout_section_id_section_id_fk",
|
||||
"tableFrom": "item_layout",
|
||||
"tableTo": "section",
|
||||
"columnsFrom": ["section_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"section_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1218,8 +1378,12 @@
|
||||
"name": "item_layout_layout_id_layout_id_fk",
|
||||
"tableFrom": "item_layout",
|
||||
"tableTo": "layout",
|
||||
"columnsFrom": ["layout_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"layout_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1227,7 +1391,11 @@
|
||||
"compositePrimaryKeys": {
|
||||
"item_layout_item_id_section_id_layout_id_pk": {
|
||||
"name": "item_layout_item_id_section_id_layout_id_pk",
|
||||
"columns": ["item_id", "section_id", "layout_id"]
|
||||
"columns": [
|
||||
"item_id",
|
||||
"section_id",
|
||||
"layout_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1280,8 +1448,12 @@
|
||||
"name": "item_board_id_board_id_fk",
|
||||
"tableFrom": "item",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1289,7 +1461,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"item_id": {
|
||||
"name": "item_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1341,8 +1515,12 @@
|
||||
"name": "layout_board_id_board_id_fk",
|
||||
"tableFrom": "layout",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1350,7 +1528,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"layout_id": {
|
||||
"name": "layout_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1416,8 +1596,12 @@
|
||||
"name": "media_creator_id_user_id_fk",
|
||||
"tableFrom": "media",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["creator_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"creator_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1425,7 +1609,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"media_id": {
|
||||
"name": "media_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1461,7 +1647,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"onboarding_id": {
|
||||
"name": "onboarding_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1534,8 +1722,12 @@
|
||||
"name": "search_engine_integration_id_integration_id_fk",
|
||||
"tableFrom": "search_engine",
|
||||
"tableTo": "integration",
|
||||
"columnsFrom": ["integration_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"integration_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1543,13 +1735,17 @@
|
||||
"compositePrimaryKeys": {
|
||||
"search_engine_id": {
|
||||
"name": "search_engine_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"search_engine_short_unique": {
|
||||
"name": "search_engine_short_unique",
|
||||
"columns": ["short"]
|
||||
"columns": [
|
||||
"short"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraint": {}
|
||||
@@ -1586,8 +1782,12 @@
|
||||
"name": "section_collapse_state_user_id_user_id_fk",
|
||||
"tableFrom": "section_collapse_state",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1595,8 +1795,12 @@
|
||||
"name": "section_collapse_state_section_id_section_id_fk",
|
||||
"tableFrom": "section_collapse_state",
|
||||
"tableTo": "section",
|
||||
"columnsFrom": ["section_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"section_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1604,7 +1808,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"section_collapse_state_user_id_section_id_pk": {
|
||||
"name": "section_collapse_state_user_id_section_id_pk",
|
||||
"columns": ["user_id", "section_id"]
|
||||
"columns": [
|
||||
"user_id",
|
||||
"section_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1669,8 +1876,12 @@
|
||||
"name": "section_layout_section_id_section_id_fk",
|
||||
"tableFrom": "section_layout",
|
||||
"tableTo": "section",
|
||||
"columnsFrom": ["section_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"section_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1678,8 +1889,12 @@
|
||||
"name": "section_layout_layout_id_layout_id_fk",
|
||||
"tableFrom": "section_layout",
|
||||
"tableTo": "layout",
|
||||
"columnsFrom": ["layout_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"layout_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1687,8 +1902,12 @@
|
||||
"name": "section_layout_parent_section_id_section_id_fk",
|
||||
"tableFrom": "section_layout",
|
||||
"tableTo": "section",
|
||||
"columnsFrom": ["parent_section_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"parent_section_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1696,7 +1915,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"section_layout_section_id_layout_id_pk": {
|
||||
"name": "section_layout_section_id_layout_id_pk",
|
||||
"columns": ["section_id", "layout_id"]
|
||||
"columns": [
|
||||
"section_id",
|
||||
"layout_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1762,8 +1984,12 @@
|
||||
"name": "section_board_id_board_id_fk",
|
||||
"tableFrom": "section",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1771,7 +1997,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"section_id": {
|
||||
"name": "section_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1801,13 +2029,17 @@
|
||||
"compositePrimaryKeys": {
|
||||
"serverSetting_setting_key": {
|
||||
"name": "serverSetting_setting_key",
|
||||
"columns": ["setting_key"]
|
||||
"columns": [
|
||||
"setting_key"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"serverSetting_settingKey_unique": {
|
||||
"name": "serverSetting_settingKey_unique",
|
||||
"columns": ["setting_key"]
|
||||
"columns": [
|
||||
"setting_key"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraint": {}
|
||||
@@ -1840,7 +2072,9 @@
|
||||
"indexes": {
|
||||
"user_id_idx": {
|
||||
"name": "user_id_idx",
|
||||
"columns": ["user_id"],
|
||||
"columns": [
|
||||
"user_id"
|
||||
],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
@@ -1849,8 +2083,12 @@
|
||||
"name": "session_user_id_user_id_fk",
|
||||
"tableFrom": "session",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": ["user_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -1858,7 +2096,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"session_session_token": {
|
||||
"name": "session_session_token",
|
||||
"columns": ["session_token"]
|
||||
"columns": [
|
||||
"session_token"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -1985,8 +2225,12 @@
|
||||
"name": "user_home_board_id_board_id_fk",
|
||||
"tableFrom": "user",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["home_board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"home_board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -1994,8 +2238,12 @@
|
||||
"name": "user_mobile_home_board_id_board_id_fk",
|
||||
"tableFrom": "user",
|
||||
"tableTo": "board",
|
||||
"columnsFrom": ["mobile_home_board_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"mobile_home_board_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
@@ -2003,8 +2251,12 @@
|
||||
"name": "user_default_search_engine_id_search_engine_id_fk",
|
||||
"tableFrom": "user",
|
||||
"tableTo": "search_engine",
|
||||
"columnsFrom": ["default_search_engine_id"],
|
||||
"columnsTo": ["id"],
|
||||
"columnsFrom": [
|
||||
"default_search_engine_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "set null",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -2012,7 +2264,9 @@
|
||||
"compositePrimaryKeys": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"columns": ["id"]
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -2048,7 +2302,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"verificationToken_identifier_token_pk": {
|
||||
"name": "verificationToken_identifier_token_pk",
|
||||
"columns": ["identifier", "token"]
|
||||
"columns": [
|
||||
"identifier",
|
||||
"token"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -2084,7 +2341,10 @@
|
||||
"compositePrimaryKeys": {
|
||||
"trusted_certificate_hostname_hostname_thumbprint_pk": {
|
||||
"name": "trusted_certificate_hostname_hostname_thumbprint_pk",
|
||||
"columns": ["hostname", "thumbprint"]
|
||||
"columns": [
|
||||
"hostname",
|
||||
"thumbprint"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -2101,4 +2361,4 @@
|
||||
"tables": {},
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -281,6 +281,20 @@
|
||||
"when": 1779199104477,
|
||||
"tag": "0039_add_user_onboarding_tour_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 40,
|
||||
"version": "5",
|
||||
"when": 1780764453945,
|
||||
"tag": "0040_wealthy_thunderbolts",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 41,
|
||||
"version": "5",
|
||||
"when": 1780764500000,
|
||||
"tag": "0041_merge_custom_widget_url",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
CREATE TABLE "custom_widget_definition" (
|
||||
"id" varchar(64) PRIMARY KEY NOT NULL,
|
||||
"name" varchar(256) NOT NULL,
|
||||
"description" text,
|
||||
"icon_url" text,
|
||||
"base_url" text NOT NULL,
|
||||
"auth_type" varchar(32) DEFAULT 'none' NOT NULL,
|
||||
"header_name" varchar(256),
|
||||
"endpoint" text NOT NULL,
|
||||
"method" varchar(16) DEFAULT 'GET' NOT NULL,
|
||||
"request_body" text,
|
||||
"display_type" varchar(32) DEFAULT 'singleValue' NOT NULL,
|
||||
"display_config" text DEFAULT '{"json": {}}' NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"creator_id" varchar(64)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "custom_widget_secret" (
|
||||
"kind" varchar(64) NOT NULL,
|
||||
"value" text NOT NULL,
|
||||
"updated_at" timestamp NOT NULL,
|
||||
"definition_id" varchar(64) NOT NULL,
|
||||
CONSTRAINT "custom_widget_secret_definition_id_kind_pk" PRIMARY KEY("definition_id","kind")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_definition" ADD CONSTRAINT "custom_widget_definition_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_secret" ADD CONSTRAINT "custom_widget_secret_definition_id_custom_widget_definition_id_fk" FOREIGN KEY ("definition_id") REFERENCES "public"."custom_widget_definition"("id") ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE "custom_widget_definition" ADD COLUMN "url" text;--> statement-breakpoint
|
||||
UPDATE "custom_widget_definition" SET "url" = "base_url" || "endpoint";--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_definition" ALTER COLUMN "url" SET NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_definition" DROP COLUMN "base_url";--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_definition" DROP COLUMN "endpoint";--> statement-breakpoint
|
||||
ALTER TABLE "custom_widget_definition" ADD COLUMN "enabled" boolean DEFAULT true NOT NULL;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -43,6 +43,20 @@
|
||||
"when": 1779199097716,
|
||||
"tag": "0005_add_user_onboarding_tour_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1780764416094,
|
||||
"tag": "0006_last_callisto",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "7",
|
||||
"when": 1780764500000,
|
||||
"tag": "0007_merge_custom_widget_url",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import SuperJSON from "superjson";
|
||||
|
||||
import { createId, objectKeys } from "@homarr/common";
|
||||
import { customWidgetImportSchema } from "@homarr/validation/custom-widget";
|
||||
import {
|
||||
createDocumentationLink,
|
||||
credentialsAdminGroup,
|
||||
@@ -15,7 +20,7 @@ import type { WidgetKind } from "@homarr/definitions";
|
||||
import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server-settings";
|
||||
|
||||
import type { Database } from "..";
|
||||
import { eq } from "..";
|
||||
import { eq, inArray } from "..";
|
||||
import { getMaxGroupPositionAsync, placeAllWidgetsAsync } from "../queries";
|
||||
import {
|
||||
getServerSettingByKeyAsync,
|
||||
@@ -38,11 +43,20 @@ import {
|
||||
searchEngines,
|
||||
sections,
|
||||
users,
|
||||
customWidgetDefinitions,
|
||||
} from "../schema";
|
||||
import type { Integration } from "../schema";
|
||||
|
||||
const isTruthyEnv = (value: string | undefined) => ["1", "yes", "t", "true"].includes((value ?? "").toLowerCase());
|
||||
|
||||
const CUSTOM_WIDGET_SEED_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "seed", "custom-widgets");
|
||||
|
||||
const CUSTOM_WIDGET_SEED_IDS: Record<string, string> = {
|
||||
"dog-facts.json": "seed-dog-facts",
|
||||
"currency-exchange.json": "seed-currency-exchange",
|
||||
"jellyfin.json": "seed-jellyfin",
|
||||
};
|
||||
|
||||
export const seedDataAsync = async (db: Database) => {
|
||||
if (isTruthyEnv(process.env.UNSAFE_ENABLE_MOCK_INTEGRATION)) {
|
||||
console.warn(
|
||||
@@ -57,6 +71,7 @@ export const seedDataAsync = async (db: Database) => {
|
||||
await seedDefaultIntegrationsAsync(db);
|
||||
await seedDefaultAppsAsync(db);
|
||||
await seedDefaultBoardAsync(db);
|
||||
await seedDefaultCustomWidgetsAsync(db);
|
||||
await seedBoardWidgetsAsync(db);
|
||||
|
||||
if (isTruthyEnv(process.env.DEMO_MODE)) {
|
||||
@@ -552,6 +567,57 @@ const seedDemoUserAsync = async (db: Database) => {
|
||||
);
|
||||
};
|
||||
|
||||
const seedDefaultCustomWidgetsAsync = async (db: Database) => {
|
||||
const seedIds = Object.values(CUSTOM_WIDGET_SEED_IDS);
|
||||
const beforeCount = await db.$count(customWidgetDefinitions, inArray(customWidgetDefinitions.id, seedIds));
|
||||
|
||||
const seedResults = await Promise.all(
|
||||
Object.entries(CUSTOM_WIDGET_SEED_IDS).map(async ([filename, id]) => {
|
||||
try {
|
||||
const raw = await readFile(join(CUSTOM_WIDGET_SEED_DIR, filename), "utf-8");
|
||||
const parsed = customWidgetImportSchema.parse(JSON.parse(raw));
|
||||
|
||||
return {
|
||||
id,
|
||||
name: parsed.name,
|
||||
description: parsed.description ?? null,
|
||||
iconUrl: parsed.iconUrl ?? null,
|
||||
url: parsed.url,
|
||||
authType: parsed.authType,
|
||||
headerName: parsed.headerName ?? null,
|
||||
method: parsed.method,
|
||||
requestBody: parsed.requestBody ?? null,
|
||||
displayType: parsed.displayType,
|
||||
displayConfig: SuperJSON.stringify(parsed.displayConfig),
|
||||
enabled: false,
|
||||
creatorId: null,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`Failed to parse custom widget seed file: ${filename}`, error);
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
const seedValues = seedResults.filter((v): v is NonNullable<typeof v> => v !== null);
|
||||
if (seedValues.length === 0) return;
|
||||
|
||||
await db
|
||||
.insert(customWidgetDefinitions)
|
||||
.values(seedValues)
|
||||
.onConflictDoNothing({ target: customWidgetDefinitions.id });
|
||||
|
||||
const afterCount = await db.$count(customWidgetDefinitions, inArray(customWidgetDefinitions.id, seedIds));
|
||||
const createdCount = afterCount - beforeCount;
|
||||
|
||||
if (createdCount === 0) {
|
||||
console.log("Skipping seeding of default custom widgets as they already exist");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Created ${createdCount} default custom widgets through seeding process`);
|
||||
};
|
||||
|
||||
const seedBoardWidgetsAsync = async (db: Database) => {
|
||||
const existingItems = await db.$count(items);
|
||||
if (existingItems > 0) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE `custom_widget_definition` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`base_url` text NOT NULL,
|
||||
`auth_type` text DEFAULT 'none' NOT NULL,
|
||||
`header_name` text,
|
||||
`endpoint` text NOT NULL,
|
||||
`method` text DEFAULT 'GET' NOT NULL,
|
||||
`request_body` text,
|
||||
`display_type` text DEFAULT 'singleValue' NOT NULL,
|
||||
`display_config` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`creator_id` text,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `custom_widget_secret` (
|
||||
`kind` text NOT NULL,
|
||||
`value` text NOT NULL,
|
||||
`updated_at` integer NOT NULL,
|
||||
`definition_id` text NOT NULL,
|
||||
PRIMARY KEY(`definition_id`, `kind`),
|
||||
FOREIGN KEY (`definition_id`) REFERENCES `custom_widget_definition`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_custom_widget_definition` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`description` text,
|
||||
`icon_url` text,
|
||||
`url` text NOT NULL,
|
||||
`auth_type` text DEFAULT 'none' NOT NULL,
|
||||
`header_name` text,
|
||||
`method` text DEFAULT 'GET' NOT NULL,
|
||||
`request_body` text,
|
||||
`display_type` text DEFAULT 'singleValue' NOT NULL,
|
||||
`display_config` text DEFAULT '{"json": {}}' NOT NULL,
|
||||
`enabled` integer DEFAULT true NOT NULL,
|
||||
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`creator_id` text,
|
||||
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
|
||||
);--> statement-breakpoint
|
||||
INSERT INTO `__new_custom_widget_definition`("id", "name", "description", "icon_url", "url", "auth_type", "header_name", "method", "request_body", "display_type", "display_config", "enabled", "created_at", "updated_at", "creator_id") SELECT "id", "name", "description", "icon_url", "base_url" || "endpoint", "auth_type", "header_name", "method", "request_body", "display_type", "display_config", 1, "created_at", "updated_at", "creator_id" FROM `custom_widget_definition`;--> statement-breakpoint
|
||||
DROP TABLE `custom_widget_definition`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_custom_widget_definition` RENAME TO `custom_widget_definition`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -267,6 +267,20 @@
|
||||
"when": 1779199046805,
|
||||
"tag": "0037_add_user_onboarding_tour_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 38,
|
||||
"version": "6",
|
||||
"when": 1780764406810,
|
||||
"tag": "0038_crazy_hobgoblin",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 39,
|
||||
"version": "6",
|
||||
"when": 1780764500000,
|
||||
"tag": "0039_merge_custom_widget_url",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@
|
||||
"@homarr/core": "workspace:^0.1.0",
|
||||
"@homarr/definitions": "workspace:^0.1.0",
|
||||
"@homarr/server-settings": "workspace:^0.1.0",
|
||||
"@homarr/validation": "workspace:^0.1.0",
|
||||
"@mantine/core": "catalog:",
|
||||
"@paralleldrive/cuid2": "catalog:",
|
||||
"@testcontainers/mysql": "catalog:",
|
||||
|
||||
@@ -49,6 +49,8 @@ export const {
|
||||
sectionLayouts,
|
||||
trustedCertificateHostnames,
|
||||
cronJobConfigurations,
|
||||
customWidgetDefinitions,
|
||||
customWidgetSecrets,
|
||||
} = schema;
|
||||
|
||||
export type User = InferSelectModel<typeof schema.users>;
|
||||
@@ -57,3 +59,5 @@ export type Session = InferSelectModel<typeof schema.sessions>;
|
||||
export type VerificationToken = InferSelectModel<typeof schema.verificationTokens>;
|
||||
export type Integration = InferSelectModel<typeof schema.integrations>;
|
||||
export type IntegrationSecret = InferSelectModel<typeof schema.integrationSecrets>;
|
||||
export type CustomWidgetDefinition = InferSelectModel<typeof schema.customWidgetDefinitions>;
|
||||
export type CustomWidgetSecret = InferSelectModel<typeof schema.customWidgetSecrets>;
|
||||
@@ -39,6 +39,12 @@ import type {
|
||||
SupportedAuthProvider,
|
||||
WidgetKind,
|
||||
} from "@homarr/definitions";
|
||||
import type {
|
||||
CustomWidgetAuthType,
|
||||
CustomWidgetDisplayType,
|
||||
CustomWidgetMethod,
|
||||
CustomWidgetSecretKind,
|
||||
} from "@homarr/validation/custom-widget";
|
||||
|
||||
const customBlob = customType<{ data: Buffer }>({
|
||||
dataType() {
|
||||
@@ -498,6 +504,43 @@ export const onboarding = mysqlTable("onboarding", {
|
||||
previousStep: varchar({ length: 64 }).$type<OnboardingStep>(),
|
||||
});
|
||||
|
||||
export const customWidgetDefinitions = mysqlTable("custom_widget_definition", {
|
||||
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||
name: varchar({ length: 256 }).notNull(),
|
||||
description: text(),
|
||||
iconUrl: text(),
|
||||
url: text().notNull(),
|
||||
authType: varchar({ length: 32 }).$type<CustomWidgetAuthType>().notNull().default("none"),
|
||||
headerName: varchar({ length: 256 }),
|
||||
method: varchar({ length: 16 }).$type<CustomWidgetMethod>().notNull().default("GET"),
|
||||
requestBody: text(),
|
||||
displayType: varchar({ length: 32 }).$type<CustomWidgetDisplayType>().notNull().default("singleValue"),
|
||||
displayConfig: text().default(emptySuperJSON).notNull(),
|
||||
enabled: boolean().notNull().default(true),
|
||||
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
|
||||
updatedAt: timestamp({ mode: "date" }).notNull().defaultNow(),
|
||||
creatorId: varchar({ length: 64 }).references(() => users.id, { onDelete: "set null" }),
|
||||
});
|
||||
|
||||
export const customWidgetSecrets = mysqlTable(
|
||||
"custom_widget_secret",
|
||||
{
|
||||
kind: varchar({ length: 64 }).$type<CustomWidgetSecretKind>().notNull(),
|
||||
value: text().$type<`${string}.${string}`>().notNull(),
|
||||
updatedAt: timestamp()
|
||||
.$onUpdateFn(() => new Date())
|
||||
.notNull(),
|
||||
definitionId: varchar({ length: 64 })
|
||||
.notNull()
|
||||
.references(() => customWidgetDefinitions.id, { onDelete: "cascade" }),
|
||||
},
|
||||
(table) => ({
|
||||
compoundKey: primaryKey({
|
||||
columns: [table.definitionId, table.kind],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const cronJobConfigurations = mysqlTable("cron_job_configuration", {
|
||||
name: varchar({ length: 256 }).notNull().primaryKey(),
|
||||
cronExpression: varchar({ length: 32 }).notNull(),
|
||||
@@ -768,3 +811,18 @@ export const layoutRelations = relations(layouts, ({ one, many }) => ({
|
||||
references: [boards.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetDefinitionRelations = relations(customWidgetDefinitions, ({ many, one }) => ({
|
||||
secrets: many(customWidgetSecrets),
|
||||
creator: one(users, {
|
||||
fields: [customWidgetDefinitions.creatorId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetSecretRelations = relations(customWidgetSecrets, ({ one }) => ({
|
||||
definition: one(customWidgetDefinitions, {
|
||||
fields: [customWidgetSecrets.definitionId],
|
||||
references: [customWidgetDefinitions.id],
|
||||
}),
|
||||
}));
|
||||
@@ -38,6 +38,12 @@ import type {
|
||||
SupportedAuthProvider,
|
||||
WidgetKind,
|
||||
} from "@homarr/definitions";
|
||||
import type {
|
||||
CustomWidgetAuthType,
|
||||
CustomWidgetDisplayType,
|
||||
CustomWidgetMethod,
|
||||
CustomWidgetSecretKind,
|
||||
} from "@homarr/validation/custom-widget";
|
||||
|
||||
const customBlob = customType<{ data: Buffer }>({
|
||||
dataType() {
|
||||
@@ -497,6 +503,43 @@ export const onboarding = pgTable("onboarding", {
|
||||
previousStep: varchar({ length: 64 }).$type<OnboardingStep>(),
|
||||
});
|
||||
|
||||
export const customWidgetDefinitions = pgTable("custom_widget_definition", {
|
||||
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||
name: varchar({ length: 256 }).notNull(),
|
||||
description: text(),
|
||||
iconUrl: text(),
|
||||
url: text().notNull(),
|
||||
authType: varchar({ length: 32 }).$type<CustomWidgetAuthType>().notNull().default("none"),
|
||||
headerName: varchar({ length: 256 }),
|
||||
method: varchar({ length: 16 }).$type<CustomWidgetMethod>().notNull().default("GET"),
|
||||
requestBody: text(),
|
||||
displayType: varchar({ length: 32 }).$type<CustomWidgetDisplayType>().notNull().default("singleValue"),
|
||||
displayConfig: text().default(emptySuperJSON).notNull(),
|
||||
enabled: boolean().notNull().default(true),
|
||||
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
|
||||
updatedAt: timestamp({ mode: "date" }).notNull().defaultNow(),
|
||||
creatorId: varchar({ length: 64 }).references(() => users.id, { onDelete: "set null" }),
|
||||
});
|
||||
|
||||
export const customWidgetSecrets = pgTable(
|
||||
"custom_widget_secret",
|
||||
{
|
||||
kind: varchar({ length: 64 }).$type<CustomWidgetSecretKind>().notNull(),
|
||||
value: text().$type<`${string}.${string}`>().notNull(),
|
||||
updatedAt: timestamp()
|
||||
.$onUpdateFn(() => new Date())
|
||||
.notNull(),
|
||||
definitionId: varchar({ length: 64 })
|
||||
.notNull()
|
||||
.references(() => customWidgetDefinitions.id, { onDelete: "cascade" }),
|
||||
},
|
||||
(table) => ({
|
||||
compoundKey: primaryKey({
|
||||
columns: [table.definitionId, table.kind],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const cronJobConfigurations = pgTable("cron_job_configuration", {
|
||||
name: varchar({ length: 256 }).notNull().primaryKey(),
|
||||
cronExpression: varchar({ length: 32 }).notNull(),
|
||||
@@ -767,3 +810,18 @@ export const layoutRelations = relations(layouts, ({ one, many }) => ({
|
||||
references: [boards.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetDefinitionRelations = relations(customWidgetDefinitions, ({ many, one }) => ({
|
||||
secrets: many(customWidgetSecrets),
|
||||
creator: one(users, {
|
||||
fields: [customWidgetDefinitions.creatorId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetSecretRelations = relations(customWidgetSecrets, ({ one }) => ({
|
||||
definition: one(customWidgetDefinitions, {
|
||||
fields: [customWidgetSecrets.definitionId],
|
||||
references: [customWidgetDefinitions.id],
|
||||
}),
|
||||
}));
|
||||
@@ -27,6 +27,12 @@ import type {
|
||||
SupportedAuthProvider,
|
||||
WidgetKind,
|
||||
} from "@homarr/definitions";
|
||||
import type {
|
||||
CustomWidgetAuthType,
|
||||
CustomWidgetDisplayType,
|
||||
CustomWidgetMethod,
|
||||
CustomWidgetSecretKind,
|
||||
} from "@homarr/validation/custom-widget";
|
||||
|
||||
export * from "@homarr/core/infrastructure/certificates/hostnames/db/sqlite";
|
||||
|
||||
@@ -483,6 +489,47 @@ export const onboarding = sqliteTable("onboarding", {
|
||||
previousStep: text().$type<OnboardingStep>(),
|
||||
});
|
||||
|
||||
export const customWidgetDefinitions = sqliteTable("custom_widget_definition", {
|
||||
id: text().notNull().primaryKey(),
|
||||
name: text().notNull(),
|
||||
description: text(),
|
||||
iconUrl: text(),
|
||||
url: text().notNull(),
|
||||
authType: text().$type<CustomWidgetAuthType>().notNull().default("none"),
|
||||
headerName: text(),
|
||||
method: text().$type<CustomWidgetMethod>().notNull().default("GET"),
|
||||
requestBody: text(),
|
||||
displayType: text().$type<CustomWidgetDisplayType>().notNull().default("singleValue"),
|
||||
displayConfig: text().default(emptySuperJSON).notNull(),
|
||||
enabled: int({ mode: "boolean" }).notNull().default(true),
|
||||
createdAt: int({ mode: "timestamp" })
|
||||
.notNull()
|
||||
.default(sql`(unixepoch())`),
|
||||
updatedAt: int({ mode: "timestamp" })
|
||||
.notNull()
|
||||
.default(sql`(unixepoch())`),
|
||||
creatorId: text().references(() => users.id, { onDelete: "set null" }),
|
||||
});
|
||||
|
||||
export const customWidgetSecrets = sqliteTable(
|
||||
"custom_widget_secret",
|
||||
{
|
||||
kind: text().$type<CustomWidgetSecretKind>().notNull(),
|
||||
value: text().$type<`${string}.${string}`>().notNull(),
|
||||
updatedAt: int({ mode: "timestamp" })
|
||||
.$onUpdateFn(() => new Date())
|
||||
.notNull(),
|
||||
definitionId: text()
|
||||
.notNull()
|
||||
.references(() => customWidgetDefinitions.id, { onDelete: "cascade" }),
|
||||
},
|
||||
(table) => ({
|
||||
compoundKey: primaryKey({
|
||||
columns: [table.definitionId, table.kind],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const cronJobConfigurations = sqliteTable("cron_job_configuration", {
|
||||
name: text().notNull().primaryKey(),
|
||||
cronExpression: text().notNull(),
|
||||
@@ -753,3 +800,18 @@ export const layoutRelations = relations(layouts, ({ one, many }) => ({
|
||||
references: [boards.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetDefinitionRelations = relations(customWidgetDefinitions, ({ many, one }) => ({
|
||||
secrets: many(customWidgetSecrets),
|
||||
creator: one(users, {
|
||||
fields: [customWidgetDefinitions.creatorId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const customWidgetSecretRelations = relations(customWidgetSecrets, ({ one }) => ({
|
||||
definition: one(customWidgetDefinitions, {
|
||||
fields: [customWidgetSecrets.definitionId],
|
||||
references: [customWidgetDefinitions.id],
|
||||
}),
|
||||
}));
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "homarr-custom-widget-v2",
|
||||
"name": "Currency Exchange (JPY)",
|
||||
"description": "Converts 50 Japanese Yen to EUR and USD using European Central Bank rates",
|
||||
"url": "https://api.frankfurter.dev/v1/latest?from=JPY&to=EUR,USD&amount=50",
|
||||
"authType": "none",
|
||||
"method": "GET",
|
||||
"displayType": "keyValue",
|
||||
"displayConfig": {
|
||||
"type": "keyValue",
|
||||
"mappings": [
|
||||
{ "label": "50 JPY → EUR", "jsonPath": "$.rates.EUR", "unit": "€" },
|
||||
{ "label": "50 JPY → USD", "jsonPath": "$.rates.USD", "unit": "$" }
|
||||
],
|
||||
"layout": "list",
|
||||
"columns": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "homarr-custom-widget-v2",
|
||||
"name": "Random Dog Fact",
|
||||
"description": "Displays a random fun fact about dogs",
|
||||
"url": "https://dogapi.dog/api/v2/facts",
|
||||
"authType": "none",
|
||||
"method": "GET",
|
||||
"displayType": "singleValue",
|
||||
"displayConfig": {
|
||||
"type": "singleValue",
|
||||
"jsonPath": "$.data[0].attributes.body",
|
||||
"label": "Dog Fact",
|
||||
"unit": "",
|
||||
"valueSize": "sm",
|
||||
"labelPosition": "above"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "homarr-custom-widget-v2",
|
||||
"name": "Jellyfin library",
|
||||
"description": "Counts the number of movies, series, episodes and songs in the library",
|
||||
"iconUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/jellyfin.svg",
|
||||
"url": "https://jellyfin.homelab.com/Items/Counts",
|
||||
"authType": "apiKeyHeader",
|
||||
"headerName": "X-Emby-Token",
|
||||
"method": "GET",
|
||||
"requestBody": null,
|
||||
"displayType": "countGrid",
|
||||
"displayConfig": {
|
||||
"type": "countGrid",
|
||||
"items": [
|
||||
{ "label": "Movies", "jsonPath": "$.MovieCount", "unit": "" },
|
||||
{ "label": "Series", "jsonPath": "$.SeriesCount", "unit": "" },
|
||||
{ "label": "Episodes", "jsonPath": "$.EpisodeCount", "unit": "" },
|
||||
{ "label": "Songs", "jsonPath": "$.SongCount", "unit": "" }
|
||||
],
|
||||
"columns": 4,
|
||||
"valueSize": "lg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "homarr-custom-widget-v2",
|
||||
"name": "Pokédex — Charizard",
|
||||
"description": "Detailed Pokémon card with types, stats, tabs, pagination, and collapsible info",
|
||||
"iconUrl": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/poke-ball.png",
|
||||
"url": "https://pokeapi.co/api/v2/pokemon/charizard",
|
||||
"authType": "none",
|
||||
"method": "GET",
|
||||
"displayType": "customJsx",
|
||||
"displayConfig": {
|
||||
"type": "customJsx",
|
||||
"template": "<Stack gap=\"sm\" p=\"xs\">\n <Group wrap=\"nowrap\">\n <Avatar\n src={data.sprites.front_default}\n size={80}\n radius=\"sm\"\n />\n <Stack gap={4} style={{flex: 1}}>\n <Title order={3} tt=\"capitalize\">{data.name}</Title>\n <Text size=\"xs\" c=\"dimmed\">#{String(data.id).padStart(3, \"0\")} · {data.height / 10} m · {data.weight / 10} kg</Text>\n <Group gap=\"xs\">\n {data.types.map(t =>\n <TypeBadge type={t.type.name} />\n )}\n </Group>\n </Stack>\n </Group>\n <TabsContainer defaultTab=\"stats\">\n <TabPanel value=\"stats\" label=\"Stats\">\n <Stack gap=\"xs\" pt=\"xs\">\n {data.stats.map(s =>\n <StatBar label={s.stat.name} value={s.base_stat} max={255} color={s.base_stat > 100 ? \"green\" : s.base_stat > 60 ? \"yellow\" : \"red\"} />\n )}\n </Stack>\n </TabPanel>\n <TabPanel value=\"abilities\" label=\"Abilities\">\n <Collapsible title=\"Abilities\" defaultOpen={true}>\n <Group gap=\"xs\" pt=\"xs\">\n {data.abilities.map(a =>\n <Badge variant={a.is_hidden ? \"outline\" : \"filled\"} color={a.is_hidden ? \"gray\" : \"blue\"} tt=\"capitalize\">\n {a.ability.name}{a.is_hidden ? \" (hidden)\" : \"\"}\n </Badge>\n )}\n </Group>\n </Collapsible>\n </TabPanel>\n <TabPanel value=\"moves\" label=\"Moves\">\n <PaginatedList pageSize={12}>\n {data.moves.map(m =>\n <Badge size=\"xs\" variant=\"light\" tt=\"capitalize\" mb={4}>{m.move.name}</Badge>\n )}\n </PaginatedList>\n </TabPanel>\n </TabsContainer>\n</Stack>"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user