@evlog/nuxthub 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import * as _nuxt_schema0 from "@nuxt/schema";
2
+
3
+ //#region src/module.d.ts
4
+ interface ModuleOptions {
5
+ /**
6
+ * How long to retain events before cleanup.
7
+ * Supports "30d" (days), "24h" (hours), "60m" (minutes).
8
+ * @default '30d'
9
+ */
10
+ retention?: string;
11
+ }
12
+ declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
13
+ //#endregion
14
+ export { ModuleOptions, _default as default };
15
+ //# sourceMappingURL=module.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.mts","names":[],"sources":["../src/module.ts"],"mappings":";;;UAQiB,aAAA;;;AAAjB;;;EAME,SAAA;AAAA;AAAA,cACD,QAAA"}
@@ -0,0 +1,99 @@
1
+ import { existsSync, promises } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { join, resolve } from "node:path";
4
+ import { addServerHandler, addServerPlugin, defineNuxtModule } from "@nuxt/kit";
5
+ import { consola } from "consola";
6
+ import { createEvlogError } from "evlog";
7
+
8
+ //#region src/module.ts
9
+ function retentionToCron(retention) {
10
+ const match = retention.match(/^(\d+)(d|h|m)$/);
11
+ if (!match) throw createEvlogError({
12
+ message: `[evlog/nuxthub] Invalid retention format: "${retention}"`,
13
+ why: "The retention value must be a number followed by a unit: d (days), h (hours), or m (minutes)",
14
+ fix: `Change retention to a valid format, e.g., "30d", "24h", or "60m"`,
15
+ link: "https://evlog.dev/nuxthub/retention"
16
+ });
17
+ const [, numStr, unit] = match;
18
+ const num = Number(numStr);
19
+ let totalMinutes;
20
+ switch (unit) {
21
+ case "m":
22
+ totalMinutes = num;
23
+ break;
24
+ case "h":
25
+ totalMinutes = num * 60;
26
+ break;
27
+ case "d":
28
+ totalMinutes = num * 24 * 60;
29
+ break;
30
+ default: throw createEvlogError({
31
+ message: `[evlog/nuxthub] Unknown retention unit: "${unit}"`,
32
+ why: "The retention value must use one of the supported units: d (days), h (hours), or m (minutes)",
33
+ fix: `Change retention to a valid format, e.g., "30d", "24h", or "60m"`,
34
+ link: "https://evlog.dev/nuxthub/retention"
35
+ });
36
+ }
37
+ const halfMinutes = Math.max(1, Math.floor(totalMinutes / 2));
38
+ if (halfMinutes < 60) return `*/${halfMinutes} * * * *`;
39
+ const halfHours = Math.floor(halfMinutes / 60);
40
+ if (halfHours >= 24) return "0 3 * * *";
41
+ return `0 */${halfHours} * * *`;
42
+ }
43
+ var module_default = defineNuxtModule({
44
+ meta: {
45
+ name: "@evlog/nuxthub",
46
+ version: "0.0.1-alpha.1"
47
+ },
48
+ moduleDependencies: { "evlog/nuxt": {} },
49
+ async onInstall(nuxt) {
50
+ const shouldSetup = await consola.prompt("Do you want to create a vercel.json with a cron schedule for evlog cleanup?", {
51
+ type: "confirm",
52
+ initial: false
53
+ });
54
+ if (typeof shouldSetup !== "boolean" || !shouldSetup) return;
55
+ const vercelJsonPath = resolve(nuxt.options.rootDir, "vercel.json");
56
+ let config = {};
57
+ if (existsSync(vercelJsonPath)) config = JSON.parse(await promises.readFile(vercelJsonPath, "utf-8"));
58
+ const cron = retentionToCron((nuxt.options.evlog || {}).retention ?? "30d");
59
+ const crons = config.crons || [];
60
+ const existing = crons.findIndex((c) => c.path === "/api/_cron/evlog-cleanup");
61
+ if (existing >= 0) crons[existing].schedule = cron;
62
+ else crons.push({
63
+ path: "/api/_cron/evlog-cleanup",
64
+ schedule: cron
65
+ });
66
+ config.crons = crons;
67
+ await promises.writeFile(vercelJsonPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
68
+ consola.success("Created vercel.json with evlog cleanup cron schedule");
69
+ },
70
+ setup(_moduleOptions, nuxt) {
71
+ const options = { retention: (nuxt.options.evlog || {}).retention ?? "30d" };
72
+ const srcDir = resolve(fileURLToPath(new URL(".", import.meta.url)), "..", "src");
73
+ const runtimeDir = join(srcDir, "runtime");
74
+ nuxt.hook("hub:db:schema:extend", ({ paths, dialect }) => {
75
+ paths.push(resolve(srcDir, "schema", `${dialect}.ts`));
76
+ });
77
+ addServerPlugin(join(runtimeDir, "drain"));
78
+ addServerHandler({
79
+ route: "/api/_cron/evlog-cleanup",
80
+ handler: join(runtimeDir, "api", "_cron", "evlog-cleanup")
81
+ });
82
+ nuxt.hook("nitro:config", (nitroConfig) => {
83
+ nitroConfig.experimental = nitroConfig.experimental || {};
84
+ nitroConfig.experimental.tasks = true;
85
+ nitroConfig.tasks = nitroConfig.tasks || {};
86
+ nitroConfig.tasks["evlog:cleanup"] = { handler: join(runtimeDir, "tasks", "evlog-cleanup") };
87
+ const cron = retentionToCron(options.retention);
88
+ nitroConfig.scheduledTasks = nitroConfig.scheduledTasks || {};
89
+ const existing = nitroConfig.scheduledTasks[cron];
90
+ if (Array.isArray(existing)) existing.push("evlog:cleanup");
91
+ else if (existing) nitroConfig.scheduledTasks[cron] = [existing, "evlog:cleanup"];
92
+ else nitroConfig.scheduledTasks[cron] = ["evlog:cleanup"];
93
+ });
94
+ }
95
+ });
96
+
97
+ //#endregion
98
+ export { module_default as default };
99
+ //# sourceMappingURL=module.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.mjs","names":["fsp"],"sources":["../src/module.ts"],"sourcesContent":["import { existsSync, promises as fsp } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { join, resolve } from 'node:path'\nimport { addServerHandler, addServerPlugin, defineNuxtModule } from '@nuxt/kit'\nimport { consola } from 'consola'\nimport type { NitroConfig } from 'nitropack'\nimport { createEvlogError } from 'evlog'\n\nexport interface ModuleOptions {\n /**\n * How long to retain events before cleanup.\n * Supports \"30d\" (days), \"24h\" (hours), \"60m\" (minutes).\n * @default '30d'\n */\n retention?: string\n}\n\nfunction retentionToCron(retention: string): string {\n const match = retention.match(/^(\\d+)(d|h|m)$/)\n if (!match) {\n throw createEvlogError({\n message: `[evlog/nuxthub] Invalid retention format: \"${retention}\"`,\n why: 'The retention value must be a number followed by a unit: d (days), h (hours), or m (minutes)',\n fix: `Change retention to a valid format, e.g., \"30d\", \"24h\", or \"60m\"`,\n link: 'https://evlog.dev/nuxthub/retention',\n })\n }\n\n const [, numStr, unit] = match\n const num = Number(numStr)\n\n // Convert retention to minutes\n let totalMinutes: number\n switch (unit) {\n case 'm':\n totalMinutes = num\n break\n case 'h':\n totalMinutes = num * 60\n break\n case 'd':\n totalMinutes = num * 24 * 60\n break\n default:\n throw createEvlogError({\n message: `[evlog/nuxthub] Unknown retention unit: \"${unit}\"`,\n why: 'The retention value must use one of the supported units: d (days), h (hours), or m (minutes)',\n fix: `Change retention to a valid format, e.g., \"30d\", \"24h\", or \"60m\"`,\n link: 'https://evlog.dev/nuxthub/retention',\n })\n }\n\n // Cleanup runs every half-retention period\n const halfMinutes = Math.max(1, Math.floor(totalMinutes / 2))\n\n if (halfMinutes < 60) {\n return `*/${halfMinutes} * * * *`\n }\n\n const halfHours = Math.floor(halfMinutes / 60)\n if (halfHours >= 24) {\n return '0 3 * * *'\n }\n\n return `0 */${halfHours} * * *`\n}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@evlog/nuxthub',\n version: '0.0.1-alpha.1',\n },\n moduleDependencies: {\n 'evlog/nuxt': {},\n },\n async onInstall(nuxt) {\n const shouldSetup = await consola.prompt(\n 'Do you want to create a vercel.json with a cron schedule for evlog cleanup?',\n { type: 'confirm', initial: false },\n )\n if (typeof shouldSetup !== 'boolean' || !shouldSetup) return\n\n const vercelJsonPath = resolve(nuxt.options.rootDir, 'vercel.json')\n let config: Record<string, any> = {}\n if (existsSync(vercelJsonPath)) {\n config = JSON.parse(await fsp.readFile(vercelJsonPath, 'utf-8'))\n }\n\n const evlogConfig = (nuxt.options as any).evlog || {}\n const retention = evlogConfig.retention ?? '30d'\n const cron = retentionToCron(retention)\n\n const crons: Array<{ path: string, schedule: string }> = config.crons || []\n const existing = crons.findIndex(c => c.path === '/api/_cron/evlog-cleanup')\n if (existing >= 0) {\n crons[existing].schedule = cron\n } else {\n crons.push({ path: '/api/_cron/evlog-cleanup', schedule: cron })\n }\n config.crons = crons\n\n await fsp.writeFile(vercelJsonPath, `${JSON.stringify(config, null, 2)}\\n`, 'utf-8')\n consola.success('Created vercel.json with evlog cleanup cron schedule')\n },\n setup(_moduleOptions, nuxt) {\n // Read nuxthub options from evlog config key\n const evlogConfig = (nuxt.options as any).evlog || {}\n const options: Required<ModuleOptions> = {\n retention: evlogConfig.retention ?? '30d',\n }\n\n // Runtime files must be resolved from src/ so Nitro can bundle them\n // and resolve virtual imports like @nuxthub/db\n const distDir = fileURLToPath(new URL('.', import.meta.url))\n const srcDir = resolve(distDir, '..', 'src')\n const runtimeDir = join(srcDir, 'runtime')\n\n // Extend NuxtHub DB schema with dialect-specific evlog_events table\n // @ts-expect-error hub:db:schema:extend hook exists but is not in NuxtHooks type\n nuxt.hook('hub:db:schema:extend', ({ paths, dialect }: { paths: string[], dialect: string }) => {\n paths.push(resolve(srcDir, 'schema', `${dialect}.ts`))\n })\n\n // Register the drain server plugin\n addServerPlugin(join(runtimeDir, 'drain'))\n\n // Register the cron API route (works as Vercel cron target or manual trigger)\n addServerHandler({\n route: '/api/_cron/evlog-cleanup',\n handler: join(runtimeDir, 'api', '_cron', 'evlog-cleanup'),\n })\n\n // Register the cleanup task with automatic cron schedule based on retention\n // @ts-expect-error nitro:config hook exists but is not in NuxtHooks type\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n // Enable experimental tasks\n nitroConfig.experimental = nitroConfig.experimental || {}\n nitroConfig.experimental.tasks = true\n\n // Register the task handler\n nitroConfig.tasks = nitroConfig.tasks || {}\n nitroConfig.tasks['evlog:cleanup'] = {\n handler: join(runtimeDir, 'tasks', 'evlog-cleanup'),\n }\n\n // Schedule based on retention (e.g., 1m → every 1 min, 1h → every 30 min, 30d → daily 3AM)\n const cron = retentionToCron(options.retention!)\n nitroConfig.scheduledTasks = nitroConfig.scheduledTasks || {}\n const existing = nitroConfig.scheduledTasks[cron]\n if (Array.isArray(existing)) {\n existing.push('evlog:cleanup')\n } else if (existing) {\n nitroConfig.scheduledTasks[cron] = [existing, 'evlog:cleanup']\n } else {\n nitroConfig.scheduledTasks[cron] = ['evlog:cleanup']\n }\n })\n },\n})\n"],"mappings":";;;;;;;;AAiBA,SAAS,gBAAgB,WAA2B;CAClD,MAAM,QAAQ,UAAU,MAAM,iBAAiB;AAC/C,KAAI,CAAC,MACH,OAAM,iBAAiB;EACrB,SAAS,8CAA8C,UAAU;EACjE,KAAK;EACL,KAAK;EACL,MAAM;EACP,CAAC;CAGJ,MAAM,GAAG,QAAQ,QAAQ;CACzB,MAAM,MAAM,OAAO,OAAO;CAG1B,IAAI;AACJ,SAAQ,MAAR;EACE,KAAK;AACH,kBAAe;AACf;EACF,KAAK;AACH,kBAAe,MAAM;AACrB;EACF,KAAK;AACH,kBAAe,MAAM,KAAK;AAC1B;EACF,QACE,OAAM,iBAAiB;GACrB,SAAS,4CAA4C,KAAK;GAC1D,KAAK;GACL,KAAK;GACL,MAAM;GACP,CAAC;;CAIN,MAAM,cAAc,KAAK,IAAI,GAAG,KAAK,MAAM,eAAe,EAAE,CAAC;AAE7D,KAAI,cAAc,GAChB,QAAO,KAAK,YAAY;CAG1B,MAAM,YAAY,KAAK,MAAM,cAAc,GAAG;AAC9C,KAAI,aAAa,GACf,QAAO;AAGT,QAAO,OAAO,UAAU;;AAG1B,qBAAe,iBAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,SAAS;EACV;CACD,oBAAoB,EAClB,cAAc,EAAE,EACjB;CACD,MAAM,UAAU,MAAM;EACpB,MAAM,cAAc,MAAM,QAAQ,OAChC,+EACA;GAAE,MAAM;GAAW,SAAS;GAAO,CACpC;AACD,MAAI,OAAO,gBAAgB,aAAa,CAAC,YAAa;EAEtD,MAAM,iBAAiB,QAAQ,KAAK,QAAQ,SAAS,cAAc;EACnE,IAAI,SAA8B,EAAE;AACpC,MAAI,WAAW,eAAe,CAC5B,UAAS,KAAK,MAAM,MAAMA,SAAI,SAAS,gBAAgB,QAAQ,CAAC;EAKlE,MAAM,OAAO,iBAFQ,KAAK,QAAgB,SAAS,EAAE,EACvB,aAAa,MACJ;EAEvC,MAAM,QAAmD,OAAO,SAAS,EAAE;EAC3E,MAAM,WAAW,MAAM,WAAU,MAAK,EAAE,SAAS,2BAA2B;AAC5E,MAAI,YAAY,EACd,OAAM,UAAU,WAAW;MAE3B,OAAM,KAAK;GAAE,MAAM;GAA4B,UAAU;GAAM,CAAC;AAElE,SAAO,QAAQ;AAEf,QAAMA,SAAI,UAAU,gBAAgB,GAAG,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC,KAAK,QAAQ;AACpF,UAAQ,QAAQ,uDAAuD;;CAEzE,MAAM,gBAAgB,MAAM;EAG1B,MAAM,UAAmC,EACvC,YAFmB,KAAK,QAAgB,SAAS,EAAE,EAE5B,aAAa,OACrC;EAKD,MAAM,SAAS,QADC,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAC5B,MAAM,MAAM;EAC5C,MAAM,aAAa,KAAK,QAAQ,UAAU;AAI1C,OAAK,KAAK,yBAAyB,EAAE,OAAO,cAAoD;AAC9F,SAAM,KAAK,QAAQ,QAAQ,UAAU,GAAG,QAAQ,KAAK,CAAC;IACtD;AAGF,kBAAgB,KAAK,YAAY,QAAQ,CAAC;AAG1C,mBAAiB;GACf,OAAO;GACP,SAAS,KAAK,YAAY,OAAO,SAAS,gBAAgB;GAC3D,CAAC;AAIF,OAAK,KAAK,iBAAiB,gBAA6B;AAEtD,eAAY,eAAe,YAAY,gBAAgB,EAAE;AACzD,eAAY,aAAa,QAAQ;AAGjC,eAAY,QAAQ,YAAY,SAAS,EAAE;AAC3C,eAAY,MAAM,mBAAmB,EACnC,SAAS,KAAK,YAAY,SAAS,gBAAgB,EACpD;GAGD,MAAM,OAAO,gBAAgB,QAAQ,UAAW;AAChD,eAAY,iBAAiB,YAAY,kBAAkB,EAAE;GAC7D,MAAM,WAAW,YAAY,eAAe;AAC5C,OAAI,MAAM,QAAQ,SAAS,CACzB,UAAS,KAAK,gBAAgB;YACrB,SACT,aAAY,eAAe,QAAQ,CAAC,UAAU,gBAAgB;OAE9D,aAAY,eAAe,QAAQ,CAAC,gBAAgB;IAEtD;;CAEL,CAAC"}
@@ -0,0 +1,251 @@
1
+ import * as drizzle_orm_mysql_core0 from "drizzle-orm/mysql-core";
2
+
3
+ //#region src/schema/mysql.d.ts
4
+ declare const evlogEvents: drizzle_orm_mysql_core0.MySqlTableWithColumns<{
5
+ name: "evlog_events";
6
+ schema: undefined;
7
+ columns: {
8
+ id: drizzle_orm_mysql_core0.MySqlColumn<{
9
+ name: "id";
10
+ tableName: "evlog_events";
11
+ dataType: "string";
12
+ columnType: "MySqlText";
13
+ data: string;
14
+ driverParam: string;
15
+ notNull: true;
16
+ hasDefault: true;
17
+ isPrimaryKey: true;
18
+ isAutoincrement: false;
19
+ hasRuntimeDefault: true;
20
+ enumValues: [string, ...string[]];
21
+ baseColumn: never;
22
+ identity: undefined;
23
+ generated: undefined;
24
+ }, {}, {}>;
25
+ timestamp: drizzle_orm_mysql_core0.MySqlColumn<{
26
+ name: "timestamp";
27
+ tableName: "evlog_events";
28
+ dataType: "string";
29
+ columnType: "MySqlText";
30
+ data: string;
31
+ driverParam: string;
32
+ notNull: true;
33
+ hasDefault: false;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: [string, ...string[]];
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {}>;
42
+ level: drizzle_orm_mysql_core0.MySqlColumn<{
43
+ name: "level";
44
+ tableName: "evlog_events";
45
+ dataType: "string";
46
+ columnType: "MySqlText";
47
+ data: string;
48
+ driverParam: string;
49
+ notNull: true;
50
+ hasDefault: false;
51
+ isPrimaryKey: false;
52
+ isAutoincrement: false;
53
+ hasRuntimeDefault: false;
54
+ enumValues: [string, ...string[]];
55
+ baseColumn: never;
56
+ identity: undefined;
57
+ generated: undefined;
58
+ }, {}, {}>;
59
+ service: drizzle_orm_mysql_core0.MySqlColumn<{
60
+ name: "service";
61
+ tableName: "evlog_events";
62
+ dataType: "string";
63
+ columnType: "MySqlText";
64
+ data: string;
65
+ driverParam: string;
66
+ notNull: true;
67
+ hasDefault: false;
68
+ isPrimaryKey: false;
69
+ isAutoincrement: false;
70
+ hasRuntimeDefault: false;
71
+ enumValues: [string, ...string[]];
72
+ baseColumn: never;
73
+ identity: undefined;
74
+ generated: undefined;
75
+ }, {}, {}>;
76
+ environment: drizzle_orm_mysql_core0.MySqlColumn<{
77
+ name: "environment";
78
+ tableName: "evlog_events";
79
+ dataType: "string";
80
+ columnType: "MySqlText";
81
+ data: string;
82
+ driverParam: string;
83
+ notNull: true;
84
+ hasDefault: false;
85
+ isPrimaryKey: false;
86
+ isAutoincrement: false;
87
+ hasRuntimeDefault: false;
88
+ enumValues: [string, ...string[]];
89
+ baseColumn: never;
90
+ identity: undefined;
91
+ generated: undefined;
92
+ }, {}, {}>;
93
+ method: drizzle_orm_mysql_core0.MySqlColumn<{
94
+ name: "method";
95
+ tableName: "evlog_events";
96
+ dataType: "string";
97
+ columnType: "MySqlText";
98
+ data: string;
99
+ driverParam: string;
100
+ notNull: false;
101
+ hasDefault: false;
102
+ isPrimaryKey: false;
103
+ isAutoincrement: false;
104
+ hasRuntimeDefault: false;
105
+ enumValues: [string, ...string[]];
106
+ baseColumn: never;
107
+ identity: undefined;
108
+ generated: undefined;
109
+ }, {}, {}>;
110
+ path: drizzle_orm_mysql_core0.MySqlColumn<{
111
+ name: "path";
112
+ tableName: "evlog_events";
113
+ dataType: "string";
114
+ columnType: "MySqlText";
115
+ data: string;
116
+ driverParam: string;
117
+ notNull: false;
118
+ hasDefault: false;
119
+ isPrimaryKey: false;
120
+ isAutoincrement: false;
121
+ hasRuntimeDefault: false;
122
+ enumValues: [string, ...string[]];
123
+ baseColumn: never;
124
+ identity: undefined;
125
+ generated: undefined;
126
+ }, {}, {}>;
127
+ status: drizzle_orm_mysql_core0.MySqlColumn<{
128
+ name: "status";
129
+ tableName: "evlog_events";
130
+ dataType: "number";
131
+ columnType: "MySqlInt";
132
+ data: number;
133
+ driverParam: string | number;
134
+ notNull: false;
135
+ hasDefault: false;
136
+ isPrimaryKey: false;
137
+ isAutoincrement: false;
138
+ hasRuntimeDefault: false;
139
+ enumValues: undefined;
140
+ baseColumn: never;
141
+ identity: undefined;
142
+ generated: undefined;
143
+ }, {}, {}>;
144
+ durationMs: drizzle_orm_mysql_core0.MySqlColumn<{
145
+ name: "duration_ms";
146
+ tableName: "evlog_events";
147
+ dataType: "number";
148
+ columnType: "MySqlInt";
149
+ data: number;
150
+ driverParam: string | number;
151
+ notNull: false;
152
+ hasDefault: false;
153
+ isPrimaryKey: false;
154
+ isAutoincrement: false;
155
+ hasRuntimeDefault: false;
156
+ enumValues: undefined;
157
+ baseColumn: never;
158
+ identity: undefined;
159
+ generated: undefined;
160
+ }, {}, {}>;
161
+ requestId: drizzle_orm_mysql_core0.MySqlColumn<{
162
+ name: "request_id";
163
+ tableName: "evlog_events";
164
+ dataType: "string";
165
+ columnType: "MySqlText";
166
+ data: string;
167
+ driverParam: string;
168
+ notNull: false;
169
+ hasDefault: false;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: [string, ...string[]];
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {}>;
178
+ source: drizzle_orm_mysql_core0.MySqlColumn<{
179
+ name: "source";
180
+ tableName: "evlog_events";
181
+ dataType: "string";
182
+ columnType: "MySqlText";
183
+ data: string;
184
+ driverParam: string;
185
+ notNull: false;
186
+ hasDefault: false;
187
+ isPrimaryKey: false;
188
+ isAutoincrement: false;
189
+ hasRuntimeDefault: false;
190
+ enumValues: [string, ...string[]];
191
+ baseColumn: never;
192
+ identity: undefined;
193
+ generated: undefined;
194
+ }, {}, {}>;
195
+ error: drizzle_orm_mysql_core0.MySqlColumn<{
196
+ name: "error";
197
+ tableName: "evlog_events";
198
+ dataType: "json";
199
+ columnType: "MySqlJson";
200
+ data: unknown;
201
+ driverParam: string;
202
+ notNull: false;
203
+ hasDefault: false;
204
+ isPrimaryKey: false;
205
+ isAutoincrement: false;
206
+ hasRuntimeDefault: false;
207
+ enumValues: undefined;
208
+ baseColumn: never;
209
+ identity: undefined;
210
+ generated: undefined;
211
+ }, {}, {}>;
212
+ data: drizzle_orm_mysql_core0.MySqlColumn<{
213
+ name: "data";
214
+ tableName: "evlog_events";
215
+ dataType: "json";
216
+ columnType: "MySqlJson";
217
+ data: unknown;
218
+ driverParam: string;
219
+ notNull: false;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: undefined;
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ createdAt: drizzle_orm_mysql_core0.MySqlColumn<{
230
+ name: "created_at";
231
+ tableName: "evlog_events";
232
+ dataType: "string";
233
+ columnType: "MySqlText";
234
+ data: string;
235
+ driverParam: string;
236
+ notNull: true;
237
+ hasDefault: true;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: true;
241
+ enumValues: [string, ...string[]];
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ };
247
+ dialect: "mysql";
248
+ }>;
249
+ //#endregion
250
+ export { evlogEvents };
251
+ //# sourceMappingURL=mysql.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.d.mts","names":[],"sources":["../../src/schema/mysql.ts"],"mappings":";;;cAEa,WAAA,0BAAW,qBAAA;;;;QAsBtB,uBAAA,CAAA,WAAA"}
@@ -0,0 +1,30 @@
1
+ import { index, int, json, mysqlTable, text } from "drizzle-orm/mysql-core";
2
+
3
+ //#region src/schema/mysql.ts
4
+ const evlogEvents = mysqlTable("evlog_events", {
5
+ id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
6
+ timestamp: text("timestamp").notNull(),
7
+ level: text("level").notNull(),
8
+ service: text("service").notNull(),
9
+ environment: text("environment").notNull(),
10
+ method: text("method"),
11
+ path: text("path"),
12
+ status: int("status"),
13
+ durationMs: int("duration_ms"),
14
+ requestId: text("request_id"),
15
+ source: text("source"),
16
+ error: json("error"),
17
+ data: json("data"),
18
+ createdAt: text("created_at").notNull().$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString())
19
+ }, (table) => [
20
+ index("evlog_events_timestamp_idx").on(table.timestamp),
21
+ index("evlog_events_level_idx").on(table.level),
22
+ index("evlog_events_service_idx").on(table.service),
23
+ index("evlog_events_status_idx").on(table.status),
24
+ index("evlog_events_request_id_idx").on(table.requestId),
25
+ index("evlog_events_created_at_idx").on(table.createdAt)
26
+ ]);
27
+
28
+ //#endregion
29
+ export { evlogEvents };
30
+ //# sourceMappingURL=mysql.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.mjs","names":[],"sources":["../../src/schema/mysql.ts"],"sourcesContent":["import { index, int, json, mysqlTable, text } from 'drizzle-orm/mysql-core'\n\nexport const evlogEvents = mysqlTable('evlog_events', {\n id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),\n timestamp: text('timestamp').notNull(),\n level: text('level').notNull(),\n service: text('service').notNull(),\n environment: text('environment').notNull(),\n method: text('method'),\n path: text('path'),\n status: int('status'),\n durationMs: int('duration_ms'),\n requestId: text('request_id'),\n source: text('source'),\n error: json('error'),\n data: json('data'),\n createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),\n}, table => [\n index('evlog_events_timestamp_idx').on(table.timestamp),\n index('evlog_events_level_idx').on(table.level),\n index('evlog_events_service_idx').on(table.service),\n index('evlog_events_status_idx').on(table.status),\n index('evlog_events_request_id_idx').on(table.requestId),\n index('evlog_events_created_at_idx').on(table.createdAt),\n])\n"],"mappings":";;;AAEA,MAAa,cAAc,WAAW,gBAAgB;CACpD,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC,iBAAiB,OAAO,YAAY,CAAC;CACjE,WAAW,KAAK,YAAY,CAAC,SAAS;CACtC,OAAO,KAAK,QAAQ,CAAC,SAAS;CAC9B,SAAS,KAAK,UAAU,CAAC,SAAS;CAClC,aAAa,KAAK,cAAc,CAAC,SAAS;CAC1C,QAAQ,KAAK,SAAS;CACtB,MAAM,KAAK,OAAO;CAClB,QAAQ,IAAI,SAAS;CACrB,YAAY,IAAI,cAAc;CAC9B,WAAW,KAAK,aAAa;CAC7B,QAAQ,KAAK,SAAS;CACtB,OAAO,KAAK,QAAQ;CACpB,MAAM,KAAK,OAAO;CAClB,WAAW,KAAK,aAAa,CAAC,SAAS,CAAC,kCAAiB,IAAI,MAAM,EAAC,aAAa,CAAC;CACnF,GAAE,UAAS;CACV,MAAM,6BAA6B,CAAC,GAAG,MAAM,UAAU;CACvD,MAAM,yBAAyB,CAAC,GAAG,MAAM,MAAM;CAC/C,MAAM,2BAA2B,CAAC,GAAG,MAAM,QAAQ;CACnD,MAAM,0BAA0B,CAAC,GAAG,MAAM,OAAO;CACjD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACxD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACzD,CAAC"}
@@ -0,0 +1,251 @@
1
+ import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
2
+
3
+ //#region src/schema/postgresql.d.ts
4
+ declare const evlogEvents: drizzle_orm_pg_core0.PgTableWithColumns<{
5
+ name: "evlog_events";
6
+ schema: undefined;
7
+ columns: {
8
+ id: drizzle_orm_pg_core0.PgColumn<{
9
+ name: "id";
10
+ tableName: "evlog_events";
11
+ dataType: "string";
12
+ columnType: "PgText";
13
+ data: string;
14
+ driverParam: string;
15
+ notNull: true;
16
+ hasDefault: true;
17
+ isPrimaryKey: true;
18
+ isAutoincrement: false;
19
+ hasRuntimeDefault: true;
20
+ enumValues: [string, ...string[]];
21
+ baseColumn: never;
22
+ identity: undefined;
23
+ generated: undefined;
24
+ }, {}, {}>;
25
+ timestamp: drizzle_orm_pg_core0.PgColumn<{
26
+ name: "timestamp";
27
+ tableName: "evlog_events";
28
+ dataType: "string";
29
+ columnType: "PgText";
30
+ data: string;
31
+ driverParam: string;
32
+ notNull: true;
33
+ hasDefault: false;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: [string, ...string[]];
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {}>;
42
+ level: drizzle_orm_pg_core0.PgColumn<{
43
+ name: "level";
44
+ tableName: "evlog_events";
45
+ dataType: "string";
46
+ columnType: "PgText";
47
+ data: string;
48
+ driverParam: string;
49
+ notNull: true;
50
+ hasDefault: false;
51
+ isPrimaryKey: false;
52
+ isAutoincrement: false;
53
+ hasRuntimeDefault: false;
54
+ enumValues: [string, ...string[]];
55
+ baseColumn: never;
56
+ identity: undefined;
57
+ generated: undefined;
58
+ }, {}, {}>;
59
+ service: drizzle_orm_pg_core0.PgColumn<{
60
+ name: "service";
61
+ tableName: "evlog_events";
62
+ dataType: "string";
63
+ columnType: "PgText";
64
+ data: string;
65
+ driverParam: string;
66
+ notNull: true;
67
+ hasDefault: false;
68
+ isPrimaryKey: false;
69
+ isAutoincrement: false;
70
+ hasRuntimeDefault: false;
71
+ enumValues: [string, ...string[]];
72
+ baseColumn: never;
73
+ identity: undefined;
74
+ generated: undefined;
75
+ }, {}, {}>;
76
+ environment: drizzle_orm_pg_core0.PgColumn<{
77
+ name: "environment";
78
+ tableName: "evlog_events";
79
+ dataType: "string";
80
+ columnType: "PgText";
81
+ data: string;
82
+ driverParam: string;
83
+ notNull: true;
84
+ hasDefault: false;
85
+ isPrimaryKey: false;
86
+ isAutoincrement: false;
87
+ hasRuntimeDefault: false;
88
+ enumValues: [string, ...string[]];
89
+ baseColumn: never;
90
+ identity: undefined;
91
+ generated: undefined;
92
+ }, {}, {}>;
93
+ method: drizzle_orm_pg_core0.PgColumn<{
94
+ name: "method";
95
+ tableName: "evlog_events";
96
+ dataType: "string";
97
+ columnType: "PgText";
98
+ data: string;
99
+ driverParam: string;
100
+ notNull: false;
101
+ hasDefault: false;
102
+ isPrimaryKey: false;
103
+ isAutoincrement: false;
104
+ hasRuntimeDefault: false;
105
+ enumValues: [string, ...string[]];
106
+ baseColumn: never;
107
+ identity: undefined;
108
+ generated: undefined;
109
+ }, {}, {}>;
110
+ path: drizzle_orm_pg_core0.PgColumn<{
111
+ name: "path";
112
+ tableName: "evlog_events";
113
+ dataType: "string";
114
+ columnType: "PgText";
115
+ data: string;
116
+ driverParam: string;
117
+ notNull: false;
118
+ hasDefault: false;
119
+ isPrimaryKey: false;
120
+ isAutoincrement: false;
121
+ hasRuntimeDefault: false;
122
+ enumValues: [string, ...string[]];
123
+ baseColumn: never;
124
+ identity: undefined;
125
+ generated: undefined;
126
+ }, {}, {}>;
127
+ status: drizzle_orm_pg_core0.PgColumn<{
128
+ name: "status";
129
+ tableName: "evlog_events";
130
+ dataType: "number";
131
+ columnType: "PgInteger";
132
+ data: number;
133
+ driverParam: string | number;
134
+ notNull: false;
135
+ hasDefault: false;
136
+ isPrimaryKey: false;
137
+ isAutoincrement: false;
138
+ hasRuntimeDefault: false;
139
+ enumValues: undefined;
140
+ baseColumn: never;
141
+ identity: undefined;
142
+ generated: undefined;
143
+ }, {}, {}>;
144
+ durationMs: drizzle_orm_pg_core0.PgColumn<{
145
+ name: "duration_ms";
146
+ tableName: "evlog_events";
147
+ dataType: "number";
148
+ columnType: "PgInteger";
149
+ data: number;
150
+ driverParam: string | number;
151
+ notNull: false;
152
+ hasDefault: false;
153
+ isPrimaryKey: false;
154
+ isAutoincrement: false;
155
+ hasRuntimeDefault: false;
156
+ enumValues: undefined;
157
+ baseColumn: never;
158
+ identity: undefined;
159
+ generated: undefined;
160
+ }, {}, {}>;
161
+ requestId: drizzle_orm_pg_core0.PgColumn<{
162
+ name: "request_id";
163
+ tableName: "evlog_events";
164
+ dataType: "string";
165
+ columnType: "PgText";
166
+ data: string;
167
+ driverParam: string;
168
+ notNull: false;
169
+ hasDefault: false;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: [string, ...string[]];
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {}>;
178
+ source: drizzle_orm_pg_core0.PgColumn<{
179
+ name: "source";
180
+ tableName: "evlog_events";
181
+ dataType: "string";
182
+ columnType: "PgText";
183
+ data: string;
184
+ driverParam: string;
185
+ notNull: false;
186
+ hasDefault: false;
187
+ isPrimaryKey: false;
188
+ isAutoincrement: false;
189
+ hasRuntimeDefault: false;
190
+ enumValues: [string, ...string[]];
191
+ baseColumn: never;
192
+ identity: undefined;
193
+ generated: undefined;
194
+ }, {}, {}>;
195
+ error: drizzle_orm_pg_core0.PgColumn<{
196
+ name: "error";
197
+ tableName: "evlog_events";
198
+ dataType: "json";
199
+ columnType: "PgJsonb";
200
+ data: unknown;
201
+ driverParam: unknown;
202
+ notNull: false;
203
+ hasDefault: false;
204
+ isPrimaryKey: false;
205
+ isAutoincrement: false;
206
+ hasRuntimeDefault: false;
207
+ enumValues: undefined;
208
+ baseColumn: never;
209
+ identity: undefined;
210
+ generated: undefined;
211
+ }, {}, {}>;
212
+ data: drizzle_orm_pg_core0.PgColumn<{
213
+ name: "data";
214
+ tableName: "evlog_events";
215
+ dataType: "json";
216
+ columnType: "PgJsonb";
217
+ data: unknown;
218
+ driverParam: unknown;
219
+ notNull: false;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: undefined;
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ createdAt: drizzle_orm_pg_core0.PgColumn<{
230
+ name: "created_at";
231
+ tableName: "evlog_events";
232
+ dataType: "string";
233
+ columnType: "PgText";
234
+ data: string;
235
+ driverParam: string;
236
+ notNull: true;
237
+ hasDefault: true;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: true;
241
+ enumValues: [string, ...string[]];
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ };
247
+ dialect: "pg";
248
+ }>;
249
+ //#endregion
250
+ export { evlogEvents };
251
+ //# sourceMappingURL=postgresql.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgresql.d.mts","names":[],"sources":["../../src/schema/postgresql.ts"],"mappings":";;;cAEa,WAAA,uBAAW,kBAAA;;;;QAsBtB,oBAAA,CAAA,QAAA"}
@@ -0,0 +1,30 @@
1
+ import { index, integer, jsonb, pgTable, text } from "drizzle-orm/pg-core";
2
+
3
+ //#region src/schema/postgresql.ts
4
+ const evlogEvents = pgTable("evlog_events", {
5
+ id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
6
+ timestamp: text("timestamp").notNull(),
7
+ level: text("level").notNull(),
8
+ service: text("service").notNull(),
9
+ environment: text("environment").notNull(),
10
+ method: text("method"),
11
+ path: text("path"),
12
+ status: integer("status"),
13
+ durationMs: integer("duration_ms"),
14
+ requestId: text("request_id"),
15
+ source: text("source"),
16
+ error: jsonb("error"),
17
+ data: jsonb("data"),
18
+ createdAt: text("created_at").notNull().$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString())
19
+ }, (table) => [
20
+ index("evlog_events_timestamp_idx").on(table.timestamp),
21
+ index("evlog_events_level_idx").on(table.level),
22
+ index("evlog_events_service_idx").on(table.service),
23
+ index("evlog_events_status_idx").on(table.status),
24
+ index("evlog_events_request_id_idx").on(table.requestId),
25
+ index("evlog_events_created_at_idx").on(table.createdAt)
26
+ ]);
27
+
28
+ //#endregion
29
+ export { evlogEvents };
30
+ //# sourceMappingURL=postgresql.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgresql.mjs","names":[],"sources":["../../src/schema/postgresql.ts"],"sourcesContent":["import { index, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core'\n\nexport const evlogEvents = pgTable('evlog_events', {\n id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),\n timestamp: text('timestamp').notNull(),\n level: text('level').notNull(),\n service: text('service').notNull(),\n environment: text('environment').notNull(),\n method: text('method'),\n path: text('path'),\n status: integer('status'),\n durationMs: integer('duration_ms'),\n requestId: text('request_id'),\n source: text('source'),\n error: jsonb('error'),\n data: jsonb('data'),\n createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),\n}, table => [\n index('evlog_events_timestamp_idx').on(table.timestamp),\n index('evlog_events_level_idx').on(table.level),\n index('evlog_events_service_idx').on(table.service),\n index('evlog_events_status_idx').on(table.status),\n index('evlog_events_request_id_idx').on(table.requestId),\n index('evlog_events_created_at_idx').on(table.createdAt),\n])\n"],"mappings":";;;AAEA,MAAa,cAAc,QAAQ,gBAAgB;CACjD,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC,iBAAiB,OAAO,YAAY,CAAC;CACjE,WAAW,KAAK,YAAY,CAAC,SAAS;CACtC,OAAO,KAAK,QAAQ,CAAC,SAAS;CAC9B,SAAS,KAAK,UAAU,CAAC,SAAS;CAClC,aAAa,KAAK,cAAc,CAAC,SAAS;CAC1C,QAAQ,KAAK,SAAS;CACtB,MAAM,KAAK,OAAO;CAClB,QAAQ,QAAQ,SAAS;CACzB,YAAY,QAAQ,cAAc;CAClC,WAAW,KAAK,aAAa;CAC7B,QAAQ,KAAK,SAAS;CACtB,OAAO,MAAM,QAAQ;CACrB,MAAM,MAAM,OAAO;CACnB,WAAW,KAAK,aAAa,CAAC,SAAS,CAAC,kCAAiB,IAAI,MAAM,EAAC,aAAa,CAAC;CACnF,GAAE,UAAS;CACV,MAAM,6BAA6B,CAAC,GAAG,MAAM,UAAU;CACvD,MAAM,yBAAyB,CAAC,GAAG,MAAM,MAAM;CAC/C,MAAM,2BAA2B,CAAC,GAAG,MAAM,QAAQ;CACnD,MAAM,0BAA0B,CAAC,GAAG,MAAM,OAAO;CACjD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACxD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACzD,CAAC"}
@@ -0,0 +1,275 @@
1
+ import * as drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
2
+
3
+ //#region src/schema/sqlite.d.ts
4
+ declare const evlogEvents: drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
5
+ name: "evlog_events";
6
+ schema: undefined;
7
+ columns: {
8
+ id: drizzle_orm_sqlite_core0.SQLiteColumn<{
9
+ name: "id";
10
+ tableName: "evlog_events";
11
+ dataType: "string";
12
+ columnType: "SQLiteText";
13
+ data: string;
14
+ driverParam: string;
15
+ notNull: true;
16
+ hasDefault: true;
17
+ isPrimaryKey: true;
18
+ isAutoincrement: false;
19
+ hasRuntimeDefault: true;
20
+ enumValues: [string, ...string[]];
21
+ baseColumn: never;
22
+ identity: undefined;
23
+ generated: undefined;
24
+ }, {}, {
25
+ length: number | undefined;
26
+ }>;
27
+ timestamp: drizzle_orm_sqlite_core0.SQLiteColumn<{
28
+ name: "timestamp";
29
+ tableName: "evlog_events";
30
+ dataType: "string";
31
+ columnType: "SQLiteText";
32
+ data: string;
33
+ driverParam: string;
34
+ notNull: true;
35
+ hasDefault: false;
36
+ isPrimaryKey: false;
37
+ isAutoincrement: false;
38
+ hasRuntimeDefault: false;
39
+ enumValues: [string, ...string[]];
40
+ baseColumn: never;
41
+ identity: undefined;
42
+ generated: undefined;
43
+ }, {}, {
44
+ length: number | undefined;
45
+ }>;
46
+ level: drizzle_orm_sqlite_core0.SQLiteColumn<{
47
+ name: "level";
48
+ tableName: "evlog_events";
49
+ dataType: "string";
50
+ columnType: "SQLiteText";
51
+ data: string;
52
+ driverParam: string;
53
+ notNull: true;
54
+ hasDefault: false;
55
+ isPrimaryKey: false;
56
+ isAutoincrement: false;
57
+ hasRuntimeDefault: false;
58
+ enumValues: [string, ...string[]];
59
+ baseColumn: never;
60
+ identity: undefined;
61
+ generated: undefined;
62
+ }, {}, {
63
+ length: number | undefined;
64
+ }>;
65
+ service: drizzle_orm_sqlite_core0.SQLiteColumn<{
66
+ name: "service";
67
+ tableName: "evlog_events";
68
+ dataType: "string";
69
+ columnType: "SQLiteText";
70
+ data: string;
71
+ driverParam: string;
72
+ notNull: true;
73
+ hasDefault: false;
74
+ isPrimaryKey: false;
75
+ isAutoincrement: false;
76
+ hasRuntimeDefault: false;
77
+ enumValues: [string, ...string[]];
78
+ baseColumn: never;
79
+ identity: undefined;
80
+ generated: undefined;
81
+ }, {}, {
82
+ length: number | undefined;
83
+ }>;
84
+ environment: drizzle_orm_sqlite_core0.SQLiteColumn<{
85
+ name: "environment";
86
+ tableName: "evlog_events";
87
+ dataType: "string";
88
+ columnType: "SQLiteText";
89
+ data: string;
90
+ driverParam: string;
91
+ notNull: true;
92
+ hasDefault: false;
93
+ isPrimaryKey: false;
94
+ isAutoincrement: false;
95
+ hasRuntimeDefault: false;
96
+ enumValues: [string, ...string[]];
97
+ baseColumn: never;
98
+ identity: undefined;
99
+ generated: undefined;
100
+ }, {}, {
101
+ length: number | undefined;
102
+ }>;
103
+ method: drizzle_orm_sqlite_core0.SQLiteColumn<{
104
+ name: "method";
105
+ tableName: "evlog_events";
106
+ dataType: "string";
107
+ columnType: "SQLiteText";
108
+ data: string;
109
+ driverParam: string;
110
+ notNull: false;
111
+ hasDefault: false;
112
+ isPrimaryKey: false;
113
+ isAutoincrement: false;
114
+ hasRuntimeDefault: false;
115
+ enumValues: [string, ...string[]];
116
+ baseColumn: never;
117
+ identity: undefined;
118
+ generated: undefined;
119
+ }, {}, {
120
+ length: number | undefined;
121
+ }>;
122
+ path: drizzle_orm_sqlite_core0.SQLiteColumn<{
123
+ name: "path";
124
+ tableName: "evlog_events";
125
+ dataType: "string";
126
+ columnType: "SQLiteText";
127
+ data: string;
128
+ driverParam: string;
129
+ notNull: false;
130
+ hasDefault: false;
131
+ isPrimaryKey: false;
132
+ isAutoincrement: false;
133
+ hasRuntimeDefault: false;
134
+ enumValues: [string, ...string[]];
135
+ baseColumn: never;
136
+ identity: undefined;
137
+ generated: undefined;
138
+ }, {}, {
139
+ length: number | undefined;
140
+ }>;
141
+ status: drizzle_orm_sqlite_core0.SQLiteColumn<{
142
+ name: "status";
143
+ tableName: "evlog_events";
144
+ dataType: "number";
145
+ columnType: "SQLiteInteger";
146
+ data: number;
147
+ driverParam: number;
148
+ notNull: false;
149
+ hasDefault: false;
150
+ isPrimaryKey: false;
151
+ isAutoincrement: false;
152
+ hasRuntimeDefault: false;
153
+ enumValues: undefined;
154
+ baseColumn: never;
155
+ identity: undefined;
156
+ generated: undefined;
157
+ }, {}, {}>;
158
+ durationMs: drizzle_orm_sqlite_core0.SQLiteColumn<{
159
+ name: "duration_ms";
160
+ tableName: "evlog_events";
161
+ dataType: "number";
162
+ columnType: "SQLiteInteger";
163
+ data: number;
164
+ driverParam: number;
165
+ notNull: false;
166
+ hasDefault: false;
167
+ isPrimaryKey: false;
168
+ isAutoincrement: false;
169
+ hasRuntimeDefault: false;
170
+ enumValues: undefined;
171
+ baseColumn: never;
172
+ identity: undefined;
173
+ generated: undefined;
174
+ }, {}, {}>;
175
+ requestId: drizzle_orm_sqlite_core0.SQLiteColumn<{
176
+ name: "request_id";
177
+ tableName: "evlog_events";
178
+ dataType: "string";
179
+ columnType: "SQLiteText";
180
+ data: string;
181
+ driverParam: string;
182
+ notNull: false;
183
+ hasDefault: false;
184
+ isPrimaryKey: false;
185
+ isAutoincrement: false;
186
+ hasRuntimeDefault: false;
187
+ enumValues: [string, ...string[]];
188
+ baseColumn: never;
189
+ identity: undefined;
190
+ generated: undefined;
191
+ }, {}, {
192
+ length: number | undefined;
193
+ }>;
194
+ source: drizzle_orm_sqlite_core0.SQLiteColumn<{
195
+ name: "source";
196
+ tableName: "evlog_events";
197
+ dataType: "string";
198
+ columnType: "SQLiteText";
199
+ data: string;
200
+ driverParam: string;
201
+ notNull: false;
202
+ hasDefault: false;
203
+ isPrimaryKey: false;
204
+ isAutoincrement: false;
205
+ hasRuntimeDefault: false;
206
+ enumValues: [string, ...string[]];
207
+ baseColumn: never;
208
+ identity: undefined;
209
+ generated: undefined;
210
+ }, {}, {
211
+ length: number | undefined;
212
+ }>;
213
+ error: drizzle_orm_sqlite_core0.SQLiteColumn<{
214
+ name: "error";
215
+ tableName: "evlog_events";
216
+ dataType: "string";
217
+ columnType: "SQLiteText";
218
+ data: string;
219
+ driverParam: string;
220
+ notNull: false;
221
+ hasDefault: false;
222
+ isPrimaryKey: false;
223
+ isAutoincrement: false;
224
+ hasRuntimeDefault: false;
225
+ enumValues: [string, ...string[]];
226
+ baseColumn: never;
227
+ identity: undefined;
228
+ generated: undefined;
229
+ }, {}, {
230
+ length: number | undefined;
231
+ }>;
232
+ data: drizzle_orm_sqlite_core0.SQLiteColumn<{
233
+ name: "data";
234
+ tableName: "evlog_events";
235
+ dataType: "string";
236
+ columnType: "SQLiteText";
237
+ data: string;
238
+ driverParam: string;
239
+ notNull: false;
240
+ hasDefault: false;
241
+ isPrimaryKey: false;
242
+ isAutoincrement: false;
243
+ hasRuntimeDefault: false;
244
+ enumValues: [string, ...string[]];
245
+ baseColumn: never;
246
+ identity: undefined;
247
+ generated: undefined;
248
+ }, {}, {
249
+ length: number | undefined;
250
+ }>;
251
+ createdAt: drizzle_orm_sqlite_core0.SQLiteColumn<{
252
+ name: "created_at";
253
+ tableName: "evlog_events";
254
+ dataType: "string";
255
+ columnType: "SQLiteText";
256
+ data: string;
257
+ driverParam: string;
258
+ notNull: true;
259
+ hasDefault: true;
260
+ isPrimaryKey: false;
261
+ isAutoincrement: false;
262
+ hasRuntimeDefault: true;
263
+ enumValues: [string, ...string[]];
264
+ baseColumn: never;
265
+ identity: undefined;
266
+ generated: undefined;
267
+ }, {}, {
268
+ length: number | undefined;
269
+ }>;
270
+ };
271
+ dialect: "sqlite";
272
+ }>;
273
+ //#endregion
274
+ export { evlogEvents };
275
+ //# sourceMappingURL=sqlite.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.d.mts","names":[],"sources":["../../src/schema/sqlite.ts"],"mappings":";;;cAEa,WAAA,2BAAW,sBAAA;;;;QAsBtB,wBAAA,CAAA,YAAA"}
@@ -0,0 +1,30 @@
1
+ import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
2
+
3
+ //#region src/schema/sqlite.ts
4
+ const evlogEvents = sqliteTable("evlog_events", {
5
+ id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
6
+ timestamp: text("timestamp").notNull(),
7
+ level: text("level").notNull(),
8
+ service: text("service").notNull(),
9
+ environment: text("environment").notNull(),
10
+ method: text("method"),
11
+ path: text("path"),
12
+ status: integer("status"),
13
+ durationMs: integer("duration_ms"),
14
+ requestId: text("request_id"),
15
+ source: text("source"),
16
+ error: text("error"),
17
+ data: text("data"),
18
+ createdAt: text("created_at").notNull().$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString())
19
+ }, (table) => [
20
+ index("evlog_events_timestamp_idx").on(table.timestamp),
21
+ index("evlog_events_level_idx").on(table.level),
22
+ index("evlog_events_service_idx").on(table.service),
23
+ index("evlog_events_status_idx").on(table.status),
24
+ index("evlog_events_request_id_idx").on(table.requestId),
25
+ index("evlog_events_created_at_idx").on(table.createdAt)
26
+ ]);
27
+
28
+ //#endregion
29
+ export { evlogEvents };
30
+ //# sourceMappingURL=sqlite.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.mjs","names":[],"sources":["../../src/schema/sqlite.ts"],"sourcesContent":["import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'\n\nexport const evlogEvents = sqliteTable('evlog_events', {\n id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),\n timestamp: text('timestamp').notNull(),\n level: text('level').notNull(),\n service: text('service').notNull(),\n environment: text('environment').notNull(),\n method: text('method'),\n path: text('path'),\n status: integer('status'),\n durationMs: integer('duration_ms'),\n requestId: text('request_id'),\n source: text('source'),\n error: text('error'),\n data: text('data'),\n createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),\n}, table => [\n index('evlog_events_timestamp_idx').on(table.timestamp),\n index('evlog_events_level_idx').on(table.level),\n index('evlog_events_service_idx').on(table.service),\n index('evlog_events_status_idx').on(table.status),\n index('evlog_events_request_id_idx').on(table.requestId),\n index('evlog_events_created_at_idx').on(table.createdAt),\n])\n"],"mappings":";;;AAEA,MAAa,cAAc,YAAY,gBAAgB;CACrD,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC,iBAAiB,OAAO,YAAY,CAAC;CACjE,WAAW,KAAK,YAAY,CAAC,SAAS;CACtC,OAAO,KAAK,QAAQ,CAAC,SAAS;CAC9B,SAAS,KAAK,UAAU,CAAC,SAAS;CAClC,aAAa,KAAK,cAAc,CAAC,SAAS;CAC1C,QAAQ,KAAK,SAAS;CACtB,MAAM,KAAK,OAAO;CAClB,QAAQ,QAAQ,SAAS;CACzB,YAAY,QAAQ,cAAc;CAClC,WAAW,KAAK,aAAa;CAC7B,QAAQ,KAAK,SAAS;CACtB,OAAO,KAAK,QAAQ;CACpB,MAAM,KAAK,OAAO;CAClB,WAAW,KAAK,aAAa,CAAC,SAAS,CAAC,kCAAiB,IAAI,MAAM,EAAC,aAAa,CAAC;CACnF,GAAE,UAAS;CACV,MAAM,6BAA6B,CAAC,GAAG,MAAM,UAAU;CACvD,MAAM,yBAAyB,CAAC,GAAG,MAAM,MAAM;CAC/C,MAAM,2BAA2B,CAAC,GAAG,MAAM,QAAQ;CACnD,MAAM,0BAA0B,CAAC,GAAG,MAAM,OAAO;CACjD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACxD,MAAM,8BAA8B,CAAC,GAAG,MAAM,UAAU;CACzD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@evlog/nuxthub",
3
+ "version": "0.0.1-alpha.1",
4
+ "description": "Self-hosted log retention for evlog using NuxtHub database storage",
5
+ "author": "HugoRCD <contact@hrcd.fr>",
6
+ "homepage": "https://evlog.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/HugoRCD/evlog.git",
10
+ "directory": "packages/nuxthub"
11
+ },
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/module.d.mts",
17
+ "import": "./dist/module.mjs"
18
+ },
19
+ "./schema/sqlite": {
20
+ "types": "./dist/schema/sqlite.d.mts",
21
+ "import": "./dist/schema/sqlite.mjs"
22
+ },
23
+ "./schema/postgresql": {
24
+ "types": "./dist/schema/postgresql.d.mts",
25
+ "import": "./dist/schema/postgresql.mjs"
26
+ },
27
+ "./schema/mysql": {
28
+ "types": "./dist/schema/mysql.d.mts",
29
+ "import": "./dist/schema/mysql.mjs"
30
+ }
31
+ },
32
+ "main": "./dist/module.mjs",
33
+ "types": "./dist/module.d.mts",
34
+ "files": [
35
+ "dist",
36
+ "src/runtime",
37
+ "src/schema",
38
+ "README.md"
39
+ ],
40
+ "scripts": {
41
+ "build": "tsdown",
42
+ "dev:prepare": "tsdown"
43
+ },
44
+ "dependencies": {
45
+ "evlog": "workspace:*",
46
+ "@nuxthub/core": "^0.10.6"
47
+ },
48
+ "devDependencies": {
49
+ "tsdown": "^0.20.3",
50
+ "typescript": "^5.9.3"
51
+ },
52
+ "peerDependencies": {
53
+ "drizzle-orm": ">=0.45.1"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "drizzle-orm": {
57
+ "optional": false
58
+ }
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ }
63
+ }
@@ -0,0 +1,7 @@
1
+ import { runTask } from 'nitropack/runtime'
2
+ import { eventHandler } from 'h3'
3
+
4
+ export default eventHandler(async () => {
5
+ const result = await runTask('evlog:cleanup')
6
+ return { success: true, ...result }
7
+ })
@@ -0,0 +1,85 @@
1
+ import type { DrainContext, WideEvent } from 'evlog'
2
+ import { defineNitroPlugin } from 'nitropack/runtime'
3
+ // @ts-expect-error nuxthub/db is a virtual module provided by @nuxthub/core
4
+ import { db, schema } from '@nuxthub/db'
5
+
6
+ type EventRow = typeof schema.evlogEvents.$inferInsert
7
+
8
+ function parseDurationMs(event: WideEvent): number | null {
9
+ if (typeof event.durationMs === 'number') return event.durationMs
10
+ if (typeof event.duration === 'number') return event.duration
11
+ if (typeof event.duration === 'string') {
12
+ const str = event.duration as string
13
+ const msMatch = str.match(/^([\d.]+)\s*ms$/)
14
+ if (msMatch) return Math.round(Number.parseFloat(msMatch[1]))
15
+ const sMatch = str.match(/^([\d.]+)\s*s$/)
16
+ if (sMatch) return Math.round(Number.parseFloat(sMatch[1]) * 1000)
17
+ }
18
+ return null
19
+ }
20
+
21
+ function extractRow(ctx: DrainContext): EventRow {
22
+ const { event, request } = ctx
23
+
24
+ // Fields that go into indexed columns
25
+ const indexed = new Set([
26
+ 'timestamp',
27
+ 'level',
28
+ 'service',
29
+ 'environment',
30
+ 'method',
31
+ 'path',
32
+ 'status',
33
+ 'durationMs',
34
+ 'duration',
35
+ 'requestId',
36
+ 'source',
37
+ 'error',
38
+ ])
39
+
40
+ // Collect remaining fields into data
41
+ const data: Record<string, unknown> = {}
42
+ for (const [key, value] of Object.entries(event)) {
43
+ if (!indexed.has(key) && value !== undefined) {
44
+ data[key] = value
45
+ }
46
+ }
47
+
48
+ const errorValue = event.error
49
+ let errorJson: string | null = null
50
+ if (errorValue !== undefined && errorValue !== null) {
51
+ errorJson = typeof errorValue === 'string' ? errorValue : JSON.stringify(errorValue)
52
+ }
53
+
54
+ return {
55
+ id: crypto.randomUUID(),
56
+ timestamp: event.timestamp,
57
+ level: event.level,
58
+ service: event.service,
59
+ environment: event.environment,
60
+ method: (request?.method ?? event.method as string) || null,
61
+ path: (request?.path ?? event.path as string) || null,
62
+ status: typeof event.status === 'number' ? event.status : null,
63
+ durationMs: parseDurationMs(event),
64
+ requestId: (request?.requestId ?? event.requestId as string) || null,
65
+ source: (event.source as string) || null,
66
+ error: errorJson,
67
+ data: Object.keys(data).length > 0 ? JSON.stringify(data) : null,
68
+ createdAt: new Date().toISOString(),
69
+ }
70
+ }
71
+
72
+ export default defineNitroPlugin((nitroApp) => {
73
+ nitroApp.hooks.hook('evlog:drain', async (ctx: DrainContext | DrainContext[]) => {
74
+ try {
75
+ const contexts = Array.isArray(ctx) ? ctx : [ctx]
76
+ if (contexts.length === 0) return
77
+
78
+ const rows = contexts.map(extractRow)
79
+
80
+ await db.insert(schema.evlogEvents).values(rows)
81
+ } catch (error) {
82
+ console.error('[evlog/nuxthub] Failed to insert events:', error)
83
+ }
84
+ })
85
+ })
@@ -0,0 +1,56 @@
1
+ import { defineTask, useRuntimeConfig } from 'nitropack/runtime'
2
+ import { lt } from 'drizzle-orm'
3
+ // @ts-expect-error nuxthub/db is a virtual module provided by @nuxthub/core
4
+ import { db, schema } from '@nuxthub/db'
5
+ import { createEvlogError } from 'evlog'
6
+
7
+ function parseRetention(retention: string): number {
8
+ const match = retention.match(/^(\d+)(d|h|m)$/)
9
+ if (!match) {
10
+ throw createEvlogError({
11
+ message: `[evlog/nuxthub] Invalid retention format: "${retention}"`,
12
+ why: 'The retention value must be a number followed by a unit: d (days), h (hours), or m (minutes)',
13
+ fix: `Change retention to a valid format, e.g., "30d", "24h", or "60m"`,
14
+ link: 'https://evlog.dev/nuxthub/retention',
15
+ })
16
+ }
17
+
18
+ const [, value, unit] = match
19
+
20
+ switch (unit) {
21
+ case 'd': return Number(value) * 24 * 60 * 60 * 1000
22
+ case 'h': return Number(value) * 60 * 60 * 1000
23
+ case 'm': return Number(value) * 60 * 1000
24
+ default:
25
+ throw createEvlogError({
26
+ message: `[evlog/nuxthub] Unknown retention unit: "${unit}"`,
27
+ why: 'The retention value must use one of the supported units: d (days), h (hours), or m (minutes)',
28
+ fix: `Change retention to a valid format, e.g., "30d", "24h", or "60m"`,
29
+ link: 'https://evlog.dev/nuxthub/retention',
30
+ })
31
+ }
32
+ }
33
+
34
+ export default defineTask({
35
+ meta: {
36
+ name: 'evlog:cleanup',
37
+ description: 'Clean up expired evlog events based on retention policy',
38
+ },
39
+ async run() {
40
+ const config = useRuntimeConfig()
41
+ const retention = (config as any).evlog?.retention ?? '30d'
42
+ const retentionMs = parseRetention(retention)
43
+ const cutoff = new Date(Date.now() - retentionMs).toISOString()
44
+
45
+ try {
46
+ const result = await db.delete(schema.evlogEvents)
47
+ .where(lt(schema.evlogEvents.createdAt, cutoff))
48
+
49
+ console.log(`[evlog/nuxthub] Cleanup: deleted events older than ${retention} (before ${cutoff})`, result)
50
+ return { result: 'success' }
51
+ } catch (error) {
52
+ console.error('[evlog/nuxthub] Cleanup task failed:', error)
53
+ return { result: 'error' }
54
+ }
55
+ },
56
+ })
@@ -0,0 +1,25 @@
1
+ import { index, int, json, mysqlTable, text } from 'drizzle-orm/mysql-core'
2
+
3
+ export const evlogEvents = mysqlTable('evlog_events', {
4
+ id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
5
+ timestamp: text('timestamp').notNull(),
6
+ level: text('level').notNull(),
7
+ service: text('service').notNull(),
8
+ environment: text('environment').notNull(),
9
+ method: text('method'),
10
+ path: text('path'),
11
+ status: int('status'),
12
+ durationMs: int('duration_ms'),
13
+ requestId: text('request_id'),
14
+ source: text('source'),
15
+ error: json('error'),
16
+ data: json('data'),
17
+ createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),
18
+ }, table => [
19
+ index('evlog_events_timestamp_idx').on(table.timestamp),
20
+ index('evlog_events_level_idx').on(table.level),
21
+ index('evlog_events_service_idx').on(table.service),
22
+ index('evlog_events_status_idx').on(table.status),
23
+ index('evlog_events_request_id_idx').on(table.requestId),
24
+ index('evlog_events_created_at_idx').on(table.createdAt),
25
+ ])
@@ -0,0 +1,25 @@
1
+ import { index, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core'
2
+
3
+ export const evlogEvents = pgTable('evlog_events', {
4
+ id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
5
+ timestamp: text('timestamp').notNull(),
6
+ level: text('level').notNull(),
7
+ service: text('service').notNull(),
8
+ environment: text('environment').notNull(),
9
+ method: text('method'),
10
+ path: text('path'),
11
+ status: integer('status'),
12
+ durationMs: integer('duration_ms'),
13
+ requestId: text('request_id'),
14
+ source: text('source'),
15
+ error: jsonb('error'),
16
+ data: jsonb('data'),
17
+ createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),
18
+ }, table => [
19
+ index('evlog_events_timestamp_idx').on(table.timestamp),
20
+ index('evlog_events_level_idx').on(table.level),
21
+ index('evlog_events_service_idx').on(table.service),
22
+ index('evlog_events_status_idx').on(table.status),
23
+ index('evlog_events_request_id_idx').on(table.requestId),
24
+ index('evlog_events_created_at_idx').on(table.createdAt),
25
+ ])
@@ -0,0 +1,25 @@
1
+ import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
2
+
3
+ export const evlogEvents = sqliteTable('evlog_events', {
4
+ id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
5
+ timestamp: text('timestamp').notNull(),
6
+ level: text('level').notNull(),
7
+ service: text('service').notNull(),
8
+ environment: text('environment').notNull(),
9
+ method: text('method'),
10
+ path: text('path'),
11
+ status: integer('status'),
12
+ durationMs: integer('duration_ms'),
13
+ requestId: text('request_id'),
14
+ source: text('source'),
15
+ error: text('error'),
16
+ data: text('data'),
17
+ createdAt: text('created_at').notNull().$defaultFn(() => new Date().toISOString()),
18
+ }, table => [
19
+ index('evlog_events_timestamp_idx').on(table.timestamp),
20
+ index('evlog_events_level_idx').on(table.level),
21
+ index('evlog_events_service_idx').on(table.service),
22
+ index('evlog_events_status_idx').on(table.status),
23
+ index('evlog_events_request_id_idx').on(table.requestId),
24
+ index('evlog_events_created_at_idx').on(table.createdAt),
25
+ ])