Simplify Custom JSX v2 authoring

This commit is contained in:
Thomas Camlong committed 2026-07-21 08:19:22 +02:00
1 parent 1faaf29c3b
commit 05dbad8069
177 files changed
+4775 -43426

No files matched your search

@@ -7,8 +7,7 @@ CREATE TABLE `custom_widget_definition` (
`icon_url` text,
`sources` text NOT NULL,
`requests` text NOT NULL,
`options_schema` text NOT NULL,
`default_options` text NOT NULL,
`options` text NOT NULL,
`template` text NOT NULL,
`enabled` boolean DEFAULT true NOT NULL,
`created_at` timestamp DEFAULT (now()) NOT NULL,
@@ -579,15 +579,8 @@
"notNull": true,
"autoincrement": false
},
"options_schema": {
"name": "options_schema",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"default_options": {
"name": "default_options",
"options": {
"name": "options",
"type": "text",
"primaryKey": false,
"notNull": true,
@@ -7,8 +7,7 @@ CREATE TABLE "custom_widget_definition" (
"icon_url" text,
"sources" text NOT NULL,
"requests" text NOT NULL,
"options_schema" text NOT NULL,
"default_options" text NOT NULL,
"options" text NOT NULL,
"template" text NOT NULL,
"enabled" boolean DEFAULT true NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
@@ -538,14 +538,8 @@
"primaryKey": false,
"notNull": true
},
"options_schema": {
"name": "options_schema",
"type": "text",
"primaryKey": false,
"notNull": true
},
"default_options": {
"name": "default_options",
"options": {
"name": "options",
"type": "text",
"primaryKey": false,
"notNull": true
+1 -2
View File
@@ -571,8 +571,7 @@ const seedDefaultCustomWidgetsAsync = async (db: Database) => {
iconUrl: definition.iconUrl ?? null,
sources: SuperJSON.stringify(definition.sources),
requests: SuperJSON.stringify(definition.requests),
optionsSchema: SuperJSON.stringify(definition.optionsSchema),
defaultOptions: SuperJSON.stringify(definition.defaultOptions),
options: SuperJSON.stringify(definition.options),
template: definition.template,
enabled: false,
creatorId: null,
@@ -8,8 +8,7 @@ CREATE TABLE `custom_widget_definition` (
`icon_url` text,
`sources` text NOT NULL,
`requests` text NOT NULL,
`options_schema` text NOT NULL,
`default_options` text NOT NULL,
`options` text NOT NULL,
`template` text NOT NULL,
`enabled` integer DEFAULT true NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
@@ -560,15 +560,8 @@
"notNull": true,
"autoincrement": false
},
"options_schema": {
"name": "options_schema",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"default_options": {
"name": "default_options",
"options": {
"name": "options",
"type": "text",
"primaryKey": false,
"notNull": true,
+1 -2
View File
@@ -507,8 +507,7 @@ export const customWidgetDefinitions = mysqlTable("custom_widget_definition", {
iconUrl: text(),
sources: text().notNull(),
requests: text().notNull(),
optionsSchema: text().notNull(),
defaultOptions: text().notNull(),
options: text().notNull(),
template: text().notNull(),
enabled: boolean().notNull().default(true),
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
+1 -2
View File
@@ -506,8 +506,7 @@ export const customWidgetDefinitions = pgTable("custom_widget_definition", {
iconUrl: text(),
sources: text().notNull(),
requests: text().notNull(),
optionsSchema: text().notNull(),
defaultOptions: text().notNull(),
options: text().notNull(),
template: text().notNull(),
enabled: boolean().notNull().default(true),
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
+1 -2
View File
@@ -492,8 +492,7 @@ export const customWidgetDefinitions = sqliteTable("custom_widget_definition", {
iconUrl: text(),
sources: text().notNull(),
requests: text().notNull(),
optionsSchema: text().notNull(),
defaultOptions: text().notNull(),
options: text().notNull(),
template: text().notNull(),
enabled: int({ mode: "boolean" }).notNull().default(true),
createdAt: int({ mode: "timestamp" })
@@ -18,8 +18,7 @@ const reconstructWidget = (definition: typeof customWidgetDefinitions.$inferSele
...(definition.iconUrl === null ? {} : { iconUrl: definition.iconUrl }),
sources: parse(definition.sources),
requests: parse(definition.requests),
optionsSchema: parse(definition.optionsSchema),
defaultOptions: parse(definition.defaultOptions),
options: parse(definition.options),
template: definition.template,
});
@@ -36,7 +35,7 @@ export const expectBundledCustomWidgetsSeeded = async (db: Database) => {
for (const definition of definitions) {
const expected = BUNDLED_CUSTOM_WIDGETS.find(({ id }) => id === definition.id);
expect(expected).toBeDefined();
expect(reconstructWidget(definition)).toEqual(expected?.widget);
expect(reconstructWidget(definition)).toEqual(customWidgetDefinitionSchema.parse(expected?.widget));
}
await db
@@ -58,7 +57,9 @@ export const expectBundledCustomWidgetsSeeded = async (db: Database) => {
expect(reseededDefinitions.filter(({ id }) => id !== "seed-dog-facts").every(({ enabled }) => !enabled)).toBe(true);
if (!reseededCurrency) throw new Error("Currency Exchange seed was not restored");
expect(reconstructWidget(reseededCurrency)).toEqual(
BUNDLED_CUSTOM_WIDGETS.find(({ id }) => id === "seed-currency-exchange")?.widget,
customWidgetDefinitionSchema.parse(
BUNDLED_CUSTOM_WIDGETS.find(({ id }) => id === "seed-currency-exchange")?.widget,
),
);
expect(await db.$count(customWidgetSecrets)).toBe(0);
};
+1 -1
View File
@@ -11,7 +11,7 @@ import { seedDataAsync } from "../migrations/seed";
import * as sqliteSchema from "../schema/sqlite";
import { expectBundledCustomWidgetsSeeded } from "./custom-widget-seed-assertions";
test("SQLite migrations seed the four disabled bundled custom widgets", async () => {
test("SQLite migrations seed the five disabled bundled custom widgets", async () => {
const connection = new BetterSqlite3(":memory:");
const database = drizzle(connection, { schema: sqliteSchema, casing: DB_CASING });