@sonicjs-cms/core 2.19.0 → 3.0.0-beta.3
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.
- package/README.md +4 -3
- package/dist/admin-documents-form.template-KN7JF66Q.cjs +19 -0
- package/dist/{admin-layout-catalyst.template-UMTIN66R.js.map → admin-documents-form.template-KN7JF66Q.cjs.map} +1 -1
- package/dist/admin-documents-form.template-NLSI6Z42.js +6 -0
- package/dist/{admin-layout-catalyst.template-HFD37TY5.cjs.map → admin-documents-form.template-NLSI6Z42.js.map} +1 -1
- package/dist/admin-layout-catalyst.template-WHJGSWWD.js +7 -0
- package/dist/admin-layout-catalyst.template-WHJGSWWD.js.map +1 -0
- package/dist/admin-layout-catalyst.template-ZK5HD545.cjs +17 -0
- package/dist/admin-layout-catalyst.template-ZK5HD545.cjs.map +1 -0
- package/dist/app-Bo0X1OWX.d.ts +1268 -0
- package/dist/app-Do66yCcV.d.cts +1268 -0
- package/dist/cache-DDARE4QE.js +4 -0
- package/dist/cache-DDARE4QE.js.map +1 -0
- package/dist/cache-LVYS4BPL.cjs +33 -0
- package/dist/cache-LVYS4BPL.cjs.map +1 -0
- package/dist/chunk-2CB4KY7I.cjs +771 -0
- package/dist/chunk-2CB4KY7I.cjs.map +1 -0
- package/dist/chunk-2JTWQZHG.cjs +276 -0
- package/dist/chunk-2JTWQZHG.cjs.map +1 -0
- package/dist/{chunk-55RDMDOP.js → chunk-3TB6AT6X.js} +148 -55
- package/dist/chunk-3TB6AT6X.js.map +1 -0
- package/dist/{chunk-E4YFJBM2.cjs → chunk-673S7EBY.cjs} +621 -829
- package/dist/chunk-673S7EBY.cjs.map +1 -0
- package/dist/{chunk-ON5ZMSU4.js → chunk-6JQOUUOB.js} +3 -3
- package/dist/chunk-6JQOUUOB.js.map +1 -0
- package/dist/chunk-7LHUVREV.cjs +158 -0
- package/dist/chunk-7LHUVREV.cjs.map +1 -0
- package/dist/chunk-AI663NBO.js +821 -0
- package/dist/chunk-AI663NBO.js.map +1 -0
- package/dist/chunk-BDDABDAB.cjs +1149 -0
- package/dist/chunk-BDDABDAB.cjs.map +1 -0
- package/dist/chunk-BLMTL57B.js +767 -0
- package/dist/chunk-BLMTL57B.js.map +1 -0
- package/dist/{chunk-ABB34XUS.cjs → chunk-CHCBHIBM.cjs} +667 -19
- package/dist/chunk-CHCBHIBM.cjs.map +1 -0
- package/dist/chunk-DNQCEKUK.cjs +327 -0
- package/dist/chunk-DNQCEKUK.cjs.map +1 -0
- package/dist/chunk-EF2NQUIQ.js +323 -0
- package/dist/chunk-EF2NQUIQ.js.map +1 -0
- package/dist/chunk-GCDZZNIN.js +192 -0
- package/dist/chunk-GCDZZNIN.js.map +1 -0
- package/dist/{chunk-XWIA3HVX.js → chunk-HDWE5FRJ.js} +6 -1249
- package/dist/chunk-HDWE5FRJ.js.map +1 -0
- package/dist/chunk-HIKBY7MS.cjs +70 -0
- package/dist/chunk-HIKBY7MS.cjs.map +1 -0
- package/dist/chunk-IESEVHXL.js +66 -0
- package/dist/chunk-IESEVHXL.js.map +1 -0
- package/dist/chunk-IVPRUGTY.js +242 -0
- package/dist/chunk-IVPRUGTY.js.map +1 -0
- package/dist/{chunk-JZVHLLSI.cjs → chunk-IXUHXTHW.cjs} +2 -151
- package/dist/chunk-IXUHXTHW.cjs.map +1 -0
- package/dist/{chunk-7A4CB7T3.cjs → chunk-J5DCX3F6.cjs} +509 -91
- package/dist/chunk-J5DCX3F6.cjs.map +1 -0
- package/dist/chunk-J6JTWD2A.cjs +100 -0
- package/dist/chunk-J6JTWD2A.cjs.map +1 -0
- package/dist/chunk-JEQ7FLOD.cjs +199 -0
- package/dist/chunk-JEQ7FLOD.cjs.map +1 -0
- package/dist/chunk-K25XHMM3.js +566 -0
- package/dist/chunk-K25XHMM3.js.map +1 -0
- package/dist/{chunk-R4FOLLFB.cjs → chunk-LO6MEPRW.cjs} +8730 -11520
- package/dist/chunk-LO6MEPRW.cjs.map +1 -0
- package/dist/chunk-MHP7HYTT.js +273 -0
- package/dist/chunk-MHP7HYTT.js.map +1 -0
- package/dist/chunk-MP3Q2W76.js +387 -0
- package/dist/chunk-MP3Q2W76.js.map +1 -0
- package/dist/{chunk-OHYBNCVL.cjs → chunk-MVIZJOO5.cjs} +10 -1256
- package/dist/chunk-MVIZJOO5.cjs.map +1 -0
- package/dist/{chunk-UYJ6TJHX.cjs → chunk-NAVPFIG5.cjs} +148 -55
- package/dist/chunk-NAVPFIG5.cjs.map +1 -0
- package/dist/chunk-NUKJ54GA.cjs +245 -0
- package/dist/chunk-NUKJ54GA.cjs.map +1 -0
- package/dist/{chunk-BU7SFHGP.js → chunk-QZGABF2M.js} +3 -149
- package/dist/chunk-QZGABF2M.js.map +1 -0
- package/dist/{chunk-JZV22DEV.js → chunk-RJV6UXLZ.js} +611 -817
- package/dist/chunk-RJV6UXLZ.js.map +1 -0
- package/dist/chunk-RNZFGN4R.js +88 -0
- package/dist/chunk-RNZFGN4R.js.map +1 -0
- package/dist/{chunk-TFNTM3OA.js → chunk-SL6XS6YT.js} +645 -15
- package/dist/chunk-SL6XS6YT.js.map +1 -0
- package/dist/{chunk-OCL3HMEG.js → chunk-SO2T3OXR.js} +7004 -9807
- package/dist/chunk-SO2T3OXR.js.map +1 -0
- package/dist/chunk-VQHAJUZZ.cjs +408 -0
- package/dist/chunk-VQHAJUZZ.cjs.map +1 -0
- package/dist/{chunk-4NPCDK6B.js → chunk-VZ3NHR5Z.js} +505 -90
- package/dist/chunk-VZ3NHR5Z.js.map +1 -0
- package/dist/{chunk-4ZSNJDLS.cjs → chunk-WULONYGB.cjs} +9 -9
- package/dist/chunk-WULONYGB.cjs.map +1 -0
- package/dist/chunk-XFQHK64T.js +154 -0
- package/dist/chunk-XFQHK64T.js.map +1 -0
- package/dist/chunk-YA3TJ65D.cjs +575 -0
- package/dist/chunk-YA3TJ65D.cjs.map +1 -0
- package/dist/chunk-YP7GW2G5.cjs +866 -0
- package/dist/chunk-YP7GW2G5.cjs.map +1 -0
- package/dist/{chunk-QFWHAFEO.js → chunk-ZEZ245PW.js} +148 -858
- package/dist/chunk-ZEZ245PW.js.map +1 -0
- package/dist/{collection-config-B4PG-AaF.d.cts → collection-config-JgHOpFCG.d.cts} +30 -2
- package/dist/{collection-config-B4PG-AaF.d.ts → collection-config-JgHOpFCG.d.ts} +30 -2
- package/dist/config-HFXANXCC.js +6 -0
- package/dist/config-HFXANXCC.js.map +1 -0
- package/dist/config-ON6FNMYX.cjs +19 -0
- package/dist/config-ON6FNMYX.cjs.map +1 -0
- package/dist/define-plugin-BzNHc1ZI.d.ts +1321 -0
- package/dist/define-plugin-IWDKYaVm.d.cts +1321 -0
- package/dist/document-projection-TDWRJX3Z.cjs +13 -0
- package/dist/document-projection-TDWRJX3Z.cjs.map +1 -0
- package/dist/document-projection-YYMC6I4U.js +4 -0
- package/dist/document-projection-YYMC6I4U.js.map +1 -0
- package/dist/index.cjs +13734 -4328
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +329 -492
- package/dist/index.d.ts +329 -492
- package/dist/index.js +13385 -3998
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +36 -32
- package/dist/middleware.d.cts +50 -7
- package/dist/middleware.d.ts +50 -7
- package/dist/middleware.js +7 -3
- package/dist/migrations-DK2YFPLR.js +4 -0
- package/dist/{migrations-H5IXZNCO.js.map → migrations-DK2YFPLR.js.map} +1 -1
- package/dist/migrations-YHNHTJOO.cjs +13 -0
- package/dist/{migrations-566IIPS2.cjs.map → migrations-YHNHTJOO.cjs.map} +1 -1
- package/dist/{plugin-bootstrap-DfVerYV4.d.cts → plugin-bootstrap-B8ThJU21.d.cts} +4315 -1661
- package/dist/{plugin-bootstrap-P_ciLp_C.d.ts → plugin-bootstrap-qu8hJgUt.d.ts} +4315 -1661
- package/dist/plugins.cjs +171 -12
- package/dist/plugins.d.cts +36 -2
- package/dist/plugins.d.ts +36 -2
- package/dist/plugins.js +5 -2
- package/dist/rbac-O73MFKDA.js +5 -0
- package/dist/rbac-O73MFKDA.js.map +1 -0
- package/dist/rbac-VONLJJKB.cjs +14 -0
- package/dist/rbac-VONLJJKB.cjs.map +1 -0
- package/dist/routes.cjs +41 -45
- package/dist/routes.d.cts +56 -146
- package/dist/routes.d.ts +56 -146
- package/dist/routes.js +17 -9
- package/dist/services.cjs +39 -72
- package/dist/services.d.cts +79 -54
- package/dist/services.d.ts +79 -54
- package/dist/services.js +6 -3
- package/dist/templates.cjs +17 -29
- package/dist/templates.d.cts +1 -66
- package/dist/templates.d.ts +1 -66
- package/dist/templates.js +3 -3
- package/dist/types-Dea1eNxU.d.cts +286 -0
- package/dist/types-Dea1eNxU.d.ts +286 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +18 -17
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -1
- package/migrations/0001_core.sql +184 -0
- package/migrations/0002_documents.sql +163 -0
- package/package.json +12 -7
- package/dist/admin-layout-catalyst.template-HFD37TY5.cjs +0 -17
- package/dist/admin-layout-catalyst.template-UMTIN66R.js +0 -7
- package/dist/app-C9esKLmh.d.cts +0 -112
- package/dist/app-C9esKLmh.d.ts +0 -112
- package/dist/chunk-4NPCDK6B.js.map +0 -1
- package/dist/chunk-4ZSNJDLS.cjs.map +0 -1
- package/dist/chunk-55RDMDOP.js.map +0 -1
- package/dist/chunk-635JAMSE.cjs +0 -653
- package/dist/chunk-635JAMSE.cjs.map +0 -1
- package/dist/chunk-7A4CB7T3.cjs.map +0 -1
- package/dist/chunk-ABB34XUS.cjs.map +0 -1
- package/dist/chunk-BU7SFHGP.js.map +0 -1
- package/dist/chunk-E4YFJBM2.cjs.map +0 -1
- package/dist/chunk-EXNEW5US.js +0 -648
- package/dist/chunk-EXNEW5US.js.map +0 -1
- package/dist/chunk-JZV22DEV.js.map +0 -1
- package/dist/chunk-JZVHLLSI.cjs.map +0 -1
- package/dist/chunk-OCL3HMEG.js.map +0 -1
- package/dist/chunk-OHYBNCVL.cjs.map +0 -1
- package/dist/chunk-ON5ZMSU4.js.map +0 -1
- package/dist/chunk-QFWHAFEO.js.map +0 -1
- package/dist/chunk-R4FOLLFB.cjs.map +0 -1
- package/dist/chunk-RLMUFFUD.cjs +0 -2219
- package/dist/chunk-RLMUFFUD.cjs.map +0 -1
- package/dist/chunk-TFNTM3OA.js.map +0 -1
- package/dist/chunk-UYJ6TJHX.cjs.map +0 -1
- package/dist/chunk-WAEQXGCX.cjs +0 -1898
- package/dist/chunk-WAEQXGCX.cjs.map +0 -1
- package/dist/chunk-XWIA3HVX.js.map +0 -1
- package/dist/chunk-ZYAYUIZE.js +0 -2217
- package/dist/chunk-ZYAYUIZE.js.map +0 -1
- package/dist/migrations-566IIPS2.cjs +0 -13
- package/dist/migrations-H5IXZNCO.js +0 -4
- package/dist/plugin-manager-BoM3Q7o7.d.cts +0 -328
- package/dist/plugin-manager-Efx9RyDX.d.ts +0 -328
- package/migrations/001_initial_schema.sql +0 -170
- package/migrations/002_faq_plugin.sql +0 -86
- package/migrations/003_stage5_enhancements.sql +0 -121
- package/migrations/004_stage6_user_management.sql +0 -183
- package/migrations/005_stage7_workflow_automation.sql +0 -294
- package/migrations/006_plugin_system.sql +0 -155
- package/migrations/007_demo_login_plugin.sql +0 -23
- package/migrations/008_fix_slug_validation.sql +0 -22
- package/migrations/009_system_logging.sql +0 -57
- package/migrations/011_config_managed_collections.sql +0 -15
- package/migrations/012_testimonials_plugin.sql +0 -80
- package/migrations/013_code_examples_plugin.sql +0 -177
- package/migrations/014_fix_plugin_registry.sql +0 -88
- package/migrations/015_add_remaining_plugins.sql +0 -89
- package/migrations/016_remove_duplicate_cache_plugin.sql +0 -17
- package/migrations/017_auth_configurable_fields.sql +0 -49
- package/migrations/018_settings_table.sql +0 -23
- package/migrations/019_remove_blog_posts_collection.sql +0 -15
- package/migrations/020_add_email_plugin.sql +0 -22
- package/migrations/021_add_magic_link_auth_plugin.sql +0 -42
- package/migrations/022_add_tinymce_plugin.sql +0 -25
- package/migrations/023_add_easy_mdx_plugin.sql +0 -25
- package/migrations/024_add_quill_editor_plugin.sql +0 -25
- package/migrations/025_add_easymde_plugin.sql +0 -25
- package/migrations/026_add_otp_login.sql +0 -42
- package/migrations/027_fix_slug_field_type.sql +0 -18
- package/migrations/028_fix_slug_field_type_in_schemas.sql +0 -30
- package/migrations/029_add_forms_system.sql +0 -184
- package/migrations/030_add_turnstile_to_forms.sql +0 -14
- package/migrations/031_ai_search_plugin.sql +0 -45
- package/migrations/032_user_profiles.sql +0 -37
- package/migrations/033_form_content_integration.sql +0 -19
- package/migrations/034_security_audit_plugin.sql +0 -27
- package/migrations/035_user_profiles_data_column.sql +0 -16
- package/migrations/036_analytics_events.sql +0 -22
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import { __export } from './chunk-V4OQ3NZ2.js';
|
|
2
|
+
import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
|
+
import { isTable, getTableColumns, getViewSelectedFields, is, Column, SQL, isView } from 'drizzle-orm';
|
|
5
|
+
|
|
6
|
+
// src/db/schema.ts
|
|
7
|
+
var schema_exports = {};
|
|
8
|
+
__export(schema_exports, {
|
|
9
|
+
account: () => account,
|
|
10
|
+
apiTokens: () => apiTokens,
|
|
11
|
+
authAccount: () => authAccount,
|
|
12
|
+
authSession: () => authSession,
|
|
13
|
+
authTenant: () => authTenant,
|
|
14
|
+
authTenantInvitation: () => authTenantInvitation,
|
|
15
|
+
authTenantMember: () => authTenantMember,
|
|
16
|
+
authTenantTeam: () => authTenantTeam,
|
|
17
|
+
authUser: () => authUser,
|
|
18
|
+
authVerification: () => authVerification,
|
|
19
|
+
content: () => content,
|
|
20
|
+
contentVersions: () => contentVersions,
|
|
21
|
+
emailLog: () => emailLog,
|
|
22
|
+
formFiles: () => formFiles,
|
|
23
|
+
formSubmissions: () => formSubmissions,
|
|
24
|
+
forms: () => forms,
|
|
25
|
+
insertContentSchema: () => insertContentSchema,
|
|
26
|
+
insertEmailLogSchema: () => insertEmailLogSchema,
|
|
27
|
+
insertFormFileSchema: () => insertFormFileSchema,
|
|
28
|
+
insertFormSchema: () => insertFormSchema,
|
|
29
|
+
insertFormSubmissionSchema: () => insertFormSubmissionSchema,
|
|
30
|
+
insertLogConfigSchema: () => insertLogConfigSchema,
|
|
31
|
+
insertMediaSchema: () => insertMediaSchema,
|
|
32
|
+
insertPluginActivityLogSchema: () => insertPluginActivityLogSchema,
|
|
33
|
+
insertPluginAssetSchema: () => insertPluginAssetSchema,
|
|
34
|
+
insertPluginHookSchema: () => insertPluginHookSchema,
|
|
35
|
+
insertPluginRouteSchema: () => insertPluginRouteSchema,
|
|
36
|
+
insertPluginSchema: () => insertPluginSchema,
|
|
37
|
+
insertSecurityEventSchema: () => insertSecurityEventSchema,
|
|
38
|
+
insertSystemLogSchema: () => insertSystemLogSchema,
|
|
39
|
+
insertUserSchema: () => insertUserSchema,
|
|
40
|
+
insertWorkflowHistorySchema: () => insertWorkflowHistorySchema,
|
|
41
|
+
logConfig: () => logConfig,
|
|
42
|
+
media: () => media,
|
|
43
|
+
pluginActivityLog: () => pluginActivityLog,
|
|
44
|
+
pluginAssets: () => pluginAssets,
|
|
45
|
+
pluginHooks: () => pluginHooks,
|
|
46
|
+
pluginRoutes: () => pluginRoutes,
|
|
47
|
+
plugins: () => plugins,
|
|
48
|
+
securityEvents: () => securityEvents,
|
|
49
|
+
selectContentSchema: () => selectContentSchema,
|
|
50
|
+
selectEmailLogSchema: () => selectEmailLogSchema,
|
|
51
|
+
selectFormFileSchema: () => selectFormFileSchema,
|
|
52
|
+
selectFormSchema: () => selectFormSchema,
|
|
53
|
+
selectFormSubmissionSchema: () => selectFormSubmissionSchema,
|
|
54
|
+
selectLogConfigSchema: () => selectLogConfigSchema,
|
|
55
|
+
selectMediaSchema: () => selectMediaSchema,
|
|
56
|
+
selectPluginActivityLogSchema: () => selectPluginActivityLogSchema,
|
|
57
|
+
selectPluginAssetSchema: () => selectPluginAssetSchema,
|
|
58
|
+
selectPluginHookSchema: () => selectPluginHookSchema,
|
|
59
|
+
selectPluginRouteSchema: () => selectPluginRouteSchema,
|
|
60
|
+
selectPluginSchema: () => selectPluginSchema,
|
|
61
|
+
selectSecurityEventSchema: () => selectSecurityEventSchema,
|
|
62
|
+
selectSystemLogSchema: () => selectSystemLogSchema,
|
|
63
|
+
selectUserSchema: () => selectUserSchema,
|
|
64
|
+
selectWorkflowHistorySchema: () => selectWorkflowHistorySchema,
|
|
65
|
+
session: () => session,
|
|
66
|
+
systemLogs: () => systemLogs,
|
|
67
|
+
users: () => users,
|
|
68
|
+
verification: () => verification,
|
|
69
|
+
workflowHistory: () => workflowHistory
|
|
70
|
+
});
|
|
71
|
+
var CONSTANTS = {
|
|
72
|
+
INT8_MIN: -128,
|
|
73
|
+
INT8_MAX: 127,
|
|
74
|
+
INT8_UNSIGNED_MAX: 255,
|
|
75
|
+
INT16_MIN: -32768,
|
|
76
|
+
INT16_MAX: 32767,
|
|
77
|
+
INT16_UNSIGNED_MAX: 65535,
|
|
78
|
+
INT24_MIN: -8388608,
|
|
79
|
+
INT24_MAX: 8388607,
|
|
80
|
+
INT24_UNSIGNED_MAX: 16777215,
|
|
81
|
+
INT32_MIN: -2147483648,
|
|
82
|
+
INT32_MAX: 2147483647,
|
|
83
|
+
INT32_UNSIGNED_MAX: 4294967295,
|
|
84
|
+
INT48_MIN: -140737488355328,
|
|
85
|
+
INT48_MAX: 140737488355327,
|
|
86
|
+
INT48_UNSIGNED_MAX: 281474976710655,
|
|
87
|
+
INT64_MIN: -9223372036854775808n,
|
|
88
|
+
INT64_MAX: 9223372036854775807n,
|
|
89
|
+
INT64_UNSIGNED_MAX: 18446744073709551615n
|
|
90
|
+
};
|
|
91
|
+
function isColumnType(column, columnTypes) {
|
|
92
|
+
return columnTypes.includes(column.columnType);
|
|
93
|
+
}
|
|
94
|
+
function isWithEnum(column) {
|
|
95
|
+
return "enumValues" in column && Array.isArray(column.enumValues) && column.enumValues.length > 0;
|
|
96
|
+
}
|
|
97
|
+
var isPgEnum = isWithEnum;
|
|
98
|
+
var literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
99
|
+
var jsonSchema = z.union([
|
|
100
|
+
literalSchema,
|
|
101
|
+
z.record(z.string(), z.any()),
|
|
102
|
+
z.array(z.any())
|
|
103
|
+
]);
|
|
104
|
+
var bufferSchema = z.custom((v) => v instanceof Buffer);
|
|
105
|
+
function columnToSchema(column, factory) {
|
|
106
|
+
const z$1 = z;
|
|
107
|
+
const coerce = {};
|
|
108
|
+
let schema;
|
|
109
|
+
if (isWithEnum(column)) {
|
|
110
|
+
schema = column.enumValues.length ? z$1.enum(column.enumValues) : z$1.string();
|
|
111
|
+
}
|
|
112
|
+
if (!schema) {
|
|
113
|
+
if (isColumnType(column, ["PgGeometry", "PgPointTuple"])) {
|
|
114
|
+
schema = z$1.tuple([z$1.number(), z$1.number()]);
|
|
115
|
+
} else if (isColumnType(column, ["PgGeometryObject", "PgPointObject"])) {
|
|
116
|
+
schema = z$1.object({ x: z$1.number(), y: z$1.number() });
|
|
117
|
+
} else if (isColumnType(column, ["PgHalfVector", "PgVector"])) {
|
|
118
|
+
schema = z$1.array(z$1.number());
|
|
119
|
+
schema = column.dimensions ? schema.length(column.dimensions) : schema;
|
|
120
|
+
} else if (isColumnType(column, ["PgLine"])) {
|
|
121
|
+
schema = z$1.tuple([z$1.number(), z$1.number(), z$1.number()]);
|
|
122
|
+
} else if (isColumnType(column, ["PgLineABC"])) {
|
|
123
|
+
schema = z$1.object({
|
|
124
|
+
a: z$1.number(),
|
|
125
|
+
b: z$1.number(),
|
|
126
|
+
c: z$1.number()
|
|
127
|
+
});
|
|
128
|
+
} else if (isColumnType(column, ["PgArray"])) {
|
|
129
|
+
schema = z$1.array(columnToSchema(column.baseColumn));
|
|
130
|
+
schema = column.size ? schema.length(column.size) : schema;
|
|
131
|
+
} else if (column.dataType === "array") {
|
|
132
|
+
schema = z$1.array(z$1.any());
|
|
133
|
+
} else if (column.dataType === "number") {
|
|
134
|
+
schema = numberColumnToSchema(column, z$1, coerce);
|
|
135
|
+
} else if (column.dataType === "bigint") {
|
|
136
|
+
schema = bigintColumnToSchema(column, z$1, coerce);
|
|
137
|
+
} else if (column.dataType === "boolean") {
|
|
138
|
+
schema = coerce === true || coerce.boolean ? z$1.coerce.boolean() : z$1.boolean();
|
|
139
|
+
} else if (column.dataType === "date") {
|
|
140
|
+
schema = coerce === true || coerce.date ? z$1.coerce.date() : z$1.date();
|
|
141
|
+
} else if (column.dataType === "string") {
|
|
142
|
+
schema = stringColumnToSchema(column, z$1, coerce);
|
|
143
|
+
} else if (column.dataType === "json") {
|
|
144
|
+
schema = jsonSchema;
|
|
145
|
+
} else if (column.dataType === "custom") {
|
|
146
|
+
schema = z$1.any();
|
|
147
|
+
} else if (column.dataType === "buffer") {
|
|
148
|
+
schema = bufferSchema;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (!schema) {
|
|
152
|
+
schema = z$1.any();
|
|
153
|
+
}
|
|
154
|
+
return schema;
|
|
155
|
+
}
|
|
156
|
+
function numberColumnToSchema(column, z2, coerce) {
|
|
157
|
+
let unsigned = column.getSQLType().includes("unsigned");
|
|
158
|
+
let min;
|
|
159
|
+
let max;
|
|
160
|
+
let integer2 = false;
|
|
161
|
+
if (isColumnType(column, ["MySqlTinyInt", "SingleStoreTinyInt"])) {
|
|
162
|
+
min = unsigned ? 0 : CONSTANTS.INT8_MIN;
|
|
163
|
+
max = unsigned ? CONSTANTS.INT8_UNSIGNED_MAX : CONSTANTS.INT8_MAX;
|
|
164
|
+
integer2 = true;
|
|
165
|
+
} else if (isColumnType(column, [
|
|
166
|
+
"PgSmallInt",
|
|
167
|
+
"PgSmallSerial",
|
|
168
|
+
"MySqlSmallInt",
|
|
169
|
+
"SingleStoreSmallInt"
|
|
170
|
+
])) {
|
|
171
|
+
min = unsigned ? 0 : CONSTANTS.INT16_MIN;
|
|
172
|
+
max = unsigned ? CONSTANTS.INT16_UNSIGNED_MAX : CONSTANTS.INT16_MAX;
|
|
173
|
+
integer2 = true;
|
|
174
|
+
} else if (isColumnType(column, [
|
|
175
|
+
"PgReal",
|
|
176
|
+
"MySqlFloat",
|
|
177
|
+
"MySqlMediumInt",
|
|
178
|
+
"SingleStoreMediumInt",
|
|
179
|
+
"SingleStoreFloat"
|
|
180
|
+
])) {
|
|
181
|
+
min = unsigned ? 0 : CONSTANTS.INT24_MIN;
|
|
182
|
+
max = unsigned ? CONSTANTS.INT24_UNSIGNED_MAX : CONSTANTS.INT24_MAX;
|
|
183
|
+
integer2 = isColumnType(column, ["MySqlMediumInt", "SingleStoreMediumInt"]);
|
|
184
|
+
} else if (isColumnType(column, [
|
|
185
|
+
"PgInteger",
|
|
186
|
+
"PgSerial",
|
|
187
|
+
"MySqlInt",
|
|
188
|
+
"SingleStoreInt"
|
|
189
|
+
])) {
|
|
190
|
+
min = unsigned ? 0 : CONSTANTS.INT32_MIN;
|
|
191
|
+
max = unsigned ? CONSTANTS.INT32_UNSIGNED_MAX : CONSTANTS.INT32_MAX;
|
|
192
|
+
integer2 = true;
|
|
193
|
+
} else if (isColumnType(column, [
|
|
194
|
+
"PgDoublePrecision",
|
|
195
|
+
"MySqlReal",
|
|
196
|
+
"MySqlDouble",
|
|
197
|
+
"SingleStoreReal",
|
|
198
|
+
"SingleStoreDouble",
|
|
199
|
+
"SQLiteReal"
|
|
200
|
+
])) {
|
|
201
|
+
min = unsigned ? 0 : CONSTANTS.INT48_MIN;
|
|
202
|
+
max = unsigned ? CONSTANTS.INT48_UNSIGNED_MAX : CONSTANTS.INT48_MAX;
|
|
203
|
+
} else if (isColumnType(column, [
|
|
204
|
+
"PgBigInt53",
|
|
205
|
+
"PgBigSerial53",
|
|
206
|
+
"MySqlBigInt53",
|
|
207
|
+
"MySqlSerial",
|
|
208
|
+
"SingleStoreBigInt53",
|
|
209
|
+
"SingleStoreSerial",
|
|
210
|
+
"SQLiteInteger"
|
|
211
|
+
])) {
|
|
212
|
+
unsigned = unsigned || isColumnType(column, ["MySqlSerial", "SingleStoreSerial"]);
|
|
213
|
+
min = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
|
|
214
|
+
max = Number.MAX_SAFE_INTEGER;
|
|
215
|
+
integer2 = true;
|
|
216
|
+
} else if (isColumnType(column, ["MySqlYear", "SingleStoreYear"])) {
|
|
217
|
+
min = 1901;
|
|
218
|
+
max = 2155;
|
|
219
|
+
integer2 = true;
|
|
220
|
+
} else {
|
|
221
|
+
min = Number.MIN_SAFE_INTEGER;
|
|
222
|
+
max = Number.MAX_SAFE_INTEGER;
|
|
223
|
+
}
|
|
224
|
+
let schema = coerce === true || coerce?.number ? integer2 ? z2.coerce.number() : z2.coerce.number().int() : integer2 ? z2.int() : z2.number();
|
|
225
|
+
schema = schema.gte(min).lte(max);
|
|
226
|
+
return schema;
|
|
227
|
+
}
|
|
228
|
+
function bigintColumnToSchema(column, z2, coerce) {
|
|
229
|
+
const unsigned = column.getSQLType().includes("unsigned");
|
|
230
|
+
const min = unsigned ? 0n : CONSTANTS.INT64_MIN;
|
|
231
|
+
const max = unsigned ? CONSTANTS.INT64_UNSIGNED_MAX : CONSTANTS.INT64_MAX;
|
|
232
|
+
const schema = coerce === true || coerce?.bigint ? z2.coerce.bigint() : z2.bigint();
|
|
233
|
+
return schema.gte(min).lte(max);
|
|
234
|
+
}
|
|
235
|
+
function stringColumnToSchema(column, z2, coerce) {
|
|
236
|
+
if (isColumnType(column, ["PgUUID"])) {
|
|
237
|
+
return z2.uuid();
|
|
238
|
+
}
|
|
239
|
+
let max;
|
|
240
|
+
let regex;
|
|
241
|
+
let fixed = false;
|
|
242
|
+
if (isColumnType(column, ["PgVarchar", "SQLiteText"])) {
|
|
243
|
+
max = column.length;
|
|
244
|
+
} else if (isColumnType(column, ["MySqlVarChar", "SingleStoreVarChar"])) {
|
|
245
|
+
max = column.length ?? CONSTANTS.INT16_UNSIGNED_MAX;
|
|
246
|
+
} else if (isColumnType(column, ["MySqlText", "SingleStoreText"])) {
|
|
247
|
+
if (column.textType === "longtext") {
|
|
248
|
+
max = CONSTANTS.INT32_UNSIGNED_MAX;
|
|
249
|
+
} else if (column.textType === "mediumtext") {
|
|
250
|
+
max = CONSTANTS.INT24_UNSIGNED_MAX;
|
|
251
|
+
} else if (column.textType === "text") {
|
|
252
|
+
max = CONSTANTS.INT16_UNSIGNED_MAX;
|
|
253
|
+
} else {
|
|
254
|
+
max = CONSTANTS.INT8_UNSIGNED_MAX;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (isColumnType(column, [
|
|
258
|
+
"PgChar",
|
|
259
|
+
"MySqlChar",
|
|
260
|
+
"SingleStoreChar"
|
|
261
|
+
])) {
|
|
262
|
+
max = column.length;
|
|
263
|
+
fixed = true;
|
|
264
|
+
}
|
|
265
|
+
if (isColumnType(column, ["PgBinaryVector"])) {
|
|
266
|
+
regex = /^[01]+$/;
|
|
267
|
+
max = column.dimensions;
|
|
268
|
+
}
|
|
269
|
+
let schema = coerce === true || coerce?.string ? z2.coerce.string() : z2.string();
|
|
270
|
+
schema = regex ? schema.regex(regex) : schema;
|
|
271
|
+
return max && fixed ? schema.length(max) : max ? schema.max(max) : schema;
|
|
272
|
+
}
|
|
273
|
+
function getColumns(tableLike) {
|
|
274
|
+
return isTable(tableLike) ? getTableColumns(tableLike) : getViewSelectedFields(tableLike);
|
|
275
|
+
}
|
|
276
|
+
function handleColumns(columns, refinements, conditions, factory) {
|
|
277
|
+
const columnSchemas = {};
|
|
278
|
+
for (const [key, selected] of Object.entries(columns)) {
|
|
279
|
+
if (!is(selected, Column) && !is(selected, SQL) && !is(selected, SQL.Aliased) && typeof selected === "object") {
|
|
280
|
+
const columns2 = isTable(selected) || isView(selected) ? getColumns(selected) : selected;
|
|
281
|
+
columnSchemas[key] = handleColumns(columns2, refinements[key] ?? {}, conditions);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const refinement = refinements[key];
|
|
285
|
+
if (refinement !== void 0 && typeof refinement !== "function") {
|
|
286
|
+
columnSchemas[key] = refinement;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const column = is(selected, Column) ? selected : void 0;
|
|
290
|
+
const schema = column ? columnToSchema(column) : z.any();
|
|
291
|
+
const refined = typeof refinement === "function" ? refinement(schema) : schema;
|
|
292
|
+
if (conditions.never(column)) {
|
|
293
|
+
continue;
|
|
294
|
+
} else {
|
|
295
|
+
columnSchemas[key] = refined;
|
|
296
|
+
}
|
|
297
|
+
if (column) {
|
|
298
|
+
if (conditions.nullable(column)) {
|
|
299
|
+
columnSchemas[key] = columnSchemas[key].nullable();
|
|
300
|
+
}
|
|
301
|
+
if (conditions.optional(column)) {
|
|
302
|
+
columnSchemas[key] = columnSchemas[key].optional();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return z.object(columnSchemas);
|
|
307
|
+
}
|
|
308
|
+
function handleEnum(enum_, factory) {
|
|
309
|
+
const zod = z;
|
|
310
|
+
return zod.enum(enum_.enumValues);
|
|
311
|
+
}
|
|
312
|
+
var selectConditions = {
|
|
313
|
+
never: () => false,
|
|
314
|
+
optional: () => false,
|
|
315
|
+
nullable: (column) => !column.notNull
|
|
316
|
+
};
|
|
317
|
+
var insertConditions = {
|
|
318
|
+
never: (column) => column?.generated?.type === "always" || column?.generatedIdentity?.type === "always",
|
|
319
|
+
optional: (column) => !column.notNull || column.notNull && column.hasDefault,
|
|
320
|
+
nullable: (column) => !column.notNull
|
|
321
|
+
};
|
|
322
|
+
var createSelectSchema = (entity, refine) => {
|
|
323
|
+
if (isPgEnum(entity)) {
|
|
324
|
+
return handleEnum(entity);
|
|
325
|
+
}
|
|
326
|
+
const columns = getColumns(entity);
|
|
327
|
+
return handleColumns(columns, {}, selectConditions);
|
|
328
|
+
};
|
|
329
|
+
var createInsertSchema = (entity, refine) => {
|
|
330
|
+
const columns = getColumns(entity);
|
|
331
|
+
return handleColumns(columns, refine ?? {}, insertConditions);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/db/schema.ts
|
|
335
|
+
var authUser = sqliteTable("auth_user", {
|
|
336
|
+
id: text("id").primaryKey(),
|
|
337
|
+
email: text("email").notNull().unique(),
|
|
338
|
+
firstName: text("first_name").notNull(),
|
|
339
|
+
lastName: text("last_name").notNull(),
|
|
340
|
+
passwordHash: text("password_hash"),
|
|
341
|
+
// Hashed password, nullable for OAuth users
|
|
342
|
+
name: text("name"),
|
|
343
|
+
// Better Auth display name (required by Better Auth for registration)
|
|
344
|
+
emailVerified: integer("email_verified", { mode: "boolean" }).notNull().default(false),
|
|
345
|
+
// Better Auth
|
|
346
|
+
role: text("role").notNull().default("viewer"),
|
|
347
|
+
// 'admin', 'editor', 'author', 'viewer'
|
|
348
|
+
// Platform super-admin: bypasses the multi-tenant membership gate. Opt-in, default false.
|
|
349
|
+
isSuperAdmin: integer("is_super_admin", { mode: "boolean" }).notNull().default(false),
|
|
350
|
+
avatar: text("avatar"),
|
|
351
|
+
isActive: integer("is_active", { mode: "boolean" }).notNull().default(true),
|
|
352
|
+
lastLoginAt: integer("last_login_at"),
|
|
353
|
+
// Password reset (routes/auth.ts)
|
|
354
|
+
passwordResetToken: text("password_reset_token"),
|
|
355
|
+
passwordResetExpires: integer("password_reset_expires"),
|
|
356
|
+
// Invitation flow (routes/auth.ts accept-invitation)
|
|
357
|
+
invitationToken: text("invitation_token"),
|
|
358
|
+
invitedAt: integer("invited_at"),
|
|
359
|
+
acceptedInvitationAt: integer("accepted_invitation_at"),
|
|
360
|
+
// Account lockout: reset on success; set on threshold failures
|
|
361
|
+
failedLoginCount: integer("failed_login_count").notNull().default(0),
|
|
362
|
+
lockedUntil: integer("locked_until"),
|
|
363
|
+
// 2FA enrollment flag (twoFactor BA plugin)
|
|
364
|
+
twoFactorEnabled: integer("two_factor_enabled").notNull().default(0),
|
|
365
|
+
// timestamp_ms so Better Auth's Date values round-trip; matches SonicJS's
|
|
366
|
+
// existing Date.now() (ms) convention for these columns.
|
|
367
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
368
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
369
|
+
});
|
|
370
|
+
var users = authUser;
|
|
371
|
+
var authSession = sqliteTable("auth_session", {
|
|
372
|
+
id: text("id").primaryKey(),
|
|
373
|
+
userId: text("user_id").notNull().references(() => authUser.id, { onDelete: "cascade" }),
|
|
374
|
+
token: text("token").notNull().unique(),
|
|
375
|
+
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
376
|
+
ipAddress: text("ip_address"),
|
|
377
|
+
userAgent: text("user_agent"),
|
|
378
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
379
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
380
|
+
});
|
|
381
|
+
var authAccount = sqliteTable("auth_account", {
|
|
382
|
+
id: text("id").primaryKey(),
|
|
383
|
+
userId: text("user_id").notNull().references(() => authUser.id, { onDelete: "cascade" }),
|
|
384
|
+
accountId: text("account_id").notNull(),
|
|
385
|
+
providerId: text("provider_id").notNull(),
|
|
386
|
+
accessToken: text("access_token"),
|
|
387
|
+
refreshToken: text("refresh_token"),
|
|
388
|
+
accessTokenExpiresAt: integer("access_token_expires_at", { mode: "timestamp_ms" }),
|
|
389
|
+
refreshTokenExpiresAt: integer("refresh_token_expires_at", { mode: "timestamp_ms" }),
|
|
390
|
+
scope: text("scope"),
|
|
391
|
+
idToken: text("id_token"),
|
|
392
|
+
password: text("password"),
|
|
393
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
394
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
395
|
+
});
|
|
396
|
+
var authVerification = sqliteTable("auth_verification", {
|
|
397
|
+
id: text("id").primaryKey(),
|
|
398
|
+
identifier: text("identifier").notNull(),
|
|
399
|
+
value: text("value").notNull(),
|
|
400
|
+
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
401
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
402
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
403
|
+
});
|
|
404
|
+
var session = authSession;
|
|
405
|
+
var account = authAccount;
|
|
406
|
+
var verification = authVerification;
|
|
407
|
+
var authTenant = sqliteTable("auth_tenant", {
|
|
408
|
+
id: text("id").primaryKey(),
|
|
409
|
+
name: text("name").notNull(),
|
|
410
|
+
slug: text("slug").notNull().unique(),
|
|
411
|
+
logo: text("logo"),
|
|
412
|
+
metadata: text("metadata"),
|
|
413
|
+
status: text("status").notNull().default("active"),
|
|
414
|
+
domain: text("domain"),
|
|
415
|
+
notes: text("notes").notNull().default(""),
|
|
416
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
417
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
418
|
+
});
|
|
419
|
+
var authTenantMember = sqliteTable("auth_tenant_member", {
|
|
420
|
+
id: text("id").primaryKey(),
|
|
421
|
+
tenantId: text("tenant_id").notNull().references(() => authTenant.id, { onDelete: "cascade" }),
|
|
422
|
+
userId: text("user_id").notNull().references(() => authUser.id, { onDelete: "cascade" }),
|
|
423
|
+
role: text("role").notNull().default("member"),
|
|
424
|
+
email: text("email"),
|
|
425
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
426
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
427
|
+
});
|
|
428
|
+
var authTenantInvitation = sqliteTable("auth_tenant_invitation", {
|
|
429
|
+
id: text("id").primaryKey(),
|
|
430
|
+
tenantId: text("tenant_id").notNull().references(() => authTenant.id, { onDelete: "cascade" }),
|
|
431
|
+
email: text("email").notNull(),
|
|
432
|
+
role: text("role").notNull().default("member"),
|
|
433
|
+
status: text("status").notNull().default("pending"),
|
|
434
|
+
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
435
|
+
inviterId: text("inviter_id").references(() => authUser.id, { onDelete: "set null" }),
|
|
436
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
437
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
438
|
+
});
|
|
439
|
+
var authTenantTeam = sqliteTable("auth_tenant_team", {
|
|
440
|
+
id: text("id").primaryKey(),
|
|
441
|
+
name: text("name").notNull(),
|
|
442
|
+
tenantId: text("tenant_id").notNull().references(() => authTenant.id, { onDelete: "cascade" }),
|
|
443
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
444
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
|
|
445
|
+
});
|
|
446
|
+
var content = sqliteTable("content", {
|
|
447
|
+
id: text("id").primaryKey(),
|
|
448
|
+
collectionId: text("collection_id").notNull(),
|
|
449
|
+
slug: text("slug").notNull(),
|
|
450
|
+
title: text("title").notNull(),
|
|
451
|
+
data: text("data", { mode: "json" }).notNull(),
|
|
452
|
+
// JSON content data
|
|
453
|
+
status: text("status").notNull().default("draft"),
|
|
454
|
+
// 'draft', 'published', 'archived'
|
|
455
|
+
publishedAt: integer("published_at", { mode: "timestamp" }),
|
|
456
|
+
authorId: text("author_id").notNull().references(() => authUser.id),
|
|
457
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
|
|
458
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
459
|
+
});
|
|
460
|
+
var contentVersions = sqliteTable("content_versions", {
|
|
461
|
+
id: text("id").primaryKey(),
|
|
462
|
+
contentId: text("content_id").notNull().references(() => content.id),
|
|
463
|
+
version: integer("version").notNull(),
|
|
464
|
+
data: text("data", { mode: "json" }).notNull(),
|
|
465
|
+
authorId: text("author_id").notNull().references(() => authUser.id),
|
|
466
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
467
|
+
});
|
|
468
|
+
var media = sqliteTable("media", {
|
|
469
|
+
id: text("id").primaryKey(),
|
|
470
|
+
filename: text("filename").notNull(),
|
|
471
|
+
originalName: text("original_name").notNull(),
|
|
472
|
+
mimeType: text("mime_type").notNull(),
|
|
473
|
+
size: integer("size").notNull(),
|
|
474
|
+
width: integer("width"),
|
|
475
|
+
height: integer("height"),
|
|
476
|
+
folder: text("folder").notNull().default("uploads"),
|
|
477
|
+
r2Key: text("r2_key").notNull(),
|
|
478
|
+
// R2 storage key
|
|
479
|
+
publicUrl: text("public_url").notNull(),
|
|
480
|
+
// CDN URL
|
|
481
|
+
thumbnailUrl: text("thumbnail_url"),
|
|
482
|
+
alt: text("alt"),
|
|
483
|
+
caption: text("caption"),
|
|
484
|
+
tags: text("tags", { mode: "json" }),
|
|
485
|
+
// JSON array of tags
|
|
486
|
+
uploadedBy: text("uploaded_by").notNull().references(() => authUser.id),
|
|
487
|
+
uploadedAt: integer("uploaded_at").notNull(),
|
|
488
|
+
updatedAt: integer("updated_at"),
|
|
489
|
+
publishedAt: integer("published_at"),
|
|
490
|
+
scheduledAt: integer("scheduled_at"),
|
|
491
|
+
archivedAt: integer("archived_at"),
|
|
492
|
+
deletedAt: integer("deleted_at")
|
|
493
|
+
});
|
|
494
|
+
var apiTokens = sqliteTable("auth_api_tokens", {
|
|
495
|
+
id: text("id").primaryKey(),
|
|
496
|
+
name: text("name").notNull(),
|
|
497
|
+
token: text("token").notNull().unique(),
|
|
498
|
+
userId: text("user_id").notNull().references(() => authUser.id),
|
|
499
|
+
permissions: text("permissions", { mode: "json" }).notNull(),
|
|
500
|
+
// Array of permissions
|
|
501
|
+
expiresAt: integer("expires_at", { mode: "timestamp" }),
|
|
502
|
+
lastUsedAt: integer("last_used_at", { mode: "timestamp" }),
|
|
503
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
504
|
+
});
|
|
505
|
+
var workflowHistory = sqliteTable("workflow_history", {
|
|
506
|
+
id: text("id").primaryKey(),
|
|
507
|
+
contentId: text("content_id").notNull().references(() => content.id),
|
|
508
|
+
action: text("action").notNull(),
|
|
509
|
+
fromStatus: text("from_status").notNull(),
|
|
510
|
+
toStatus: text("to_status").notNull(),
|
|
511
|
+
userId: text("user_id").notNull().references(() => authUser.id),
|
|
512
|
+
comment: text("comment"),
|
|
513
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
514
|
+
});
|
|
515
|
+
var plugins = sqliteTable("plugins", {
|
|
516
|
+
id: text("id").primaryKey(),
|
|
517
|
+
name: text("name").notNull().unique(),
|
|
518
|
+
displayName: text("display_name").notNull(),
|
|
519
|
+
description: text("description"),
|
|
520
|
+
version: text("version").notNull(),
|
|
521
|
+
author: text("author").notNull(),
|
|
522
|
+
category: text("category").notNull(),
|
|
523
|
+
icon: text("icon"),
|
|
524
|
+
status: text("status").notNull().default("inactive"),
|
|
525
|
+
// 'active', 'inactive', 'error'
|
|
526
|
+
isCore: integer("is_core", { mode: "boolean" }).notNull().default(false),
|
|
527
|
+
settings: text("settings", { mode: "json" }),
|
|
528
|
+
permissions: text("permissions", { mode: "json" }),
|
|
529
|
+
dependencies: text("dependencies", { mode: "json" }),
|
|
530
|
+
downloadCount: integer("download_count").notNull().default(0),
|
|
531
|
+
rating: integer("rating").notNull().default(0),
|
|
532
|
+
installedAt: integer("installed_at").notNull(),
|
|
533
|
+
activatedAt: integer("activated_at"),
|
|
534
|
+
lastUpdated: integer("last_updated").notNull(),
|
|
535
|
+
errorMessage: text("error_message"),
|
|
536
|
+
createdAt: integer("created_at").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3)),
|
|
537
|
+
updatedAt: integer("updated_at").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3))
|
|
538
|
+
});
|
|
539
|
+
var pluginHooks = sqliteTable("plugin_hooks", {
|
|
540
|
+
id: text("id").primaryKey(),
|
|
541
|
+
pluginId: text("plugin_id").notNull().references(() => plugins.id),
|
|
542
|
+
hookName: text("hook_name").notNull(),
|
|
543
|
+
handlerName: text("handler_name").notNull(),
|
|
544
|
+
priority: integer("priority").notNull().default(10),
|
|
545
|
+
isActive: integer("is_active", { mode: "boolean" }).notNull().default(true),
|
|
546
|
+
createdAt: integer("created_at").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3))
|
|
547
|
+
});
|
|
548
|
+
var pluginRoutes = sqliteTable("plugin_routes", {
|
|
549
|
+
id: text("id").primaryKey(),
|
|
550
|
+
pluginId: text("plugin_id").notNull().references(() => plugins.id),
|
|
551
|
+
path: text("path").notNull(),
|
|
552
|
+
method: text("method").notNull(),
|
|
553
|
+
handlerName: text("handler_name").notNull(),
|
|
554
|
+
middleware: text("middleware", { mode: "json" }),
|
|
555
|
+
isActive: integer("is_active", { mode: "boolean" }).notNull().default(true),
|
|
556
|
+
createdAt: integer("created_at").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3))
|
|
557
|
+
});
|
|
558
|
+
var pluginAssets = sqliteTable("plugin_assets", {
|
|
559
|
+
id: text("id").primaryKey(),
|
|
560
|
+
pluginId: text("plugin_id").notNull().references(() => plugins.id),
|
|
561
|
+
assetType: text("asset_type").notNull(),
|
|
562
|
+
// 'css', 'js', 'image', 'font'
|
|
563
|
+
assetPath: text("asset_path").notNull(),
|
|
564
|
+
loadOrder: integer("load_order").notNull().default(100),
|
|
565
|
+
loadLocation: text("load_location").notNull().default("footer"),
|
|
566
|
+
// 'header', 'footer'
|
|
567
|
+
isActive: integer("is_active", { mode: "boolean" }).notNull().default(true),
|
|
568
|
+
createdAt: integer("created_at").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3))
|
|
569
|
+
});
|
|
570
|
+
var pluginActivityLog = sqliteTable("plugin_activity_log", {
|
|
571
|
+
id: text("id").primaryKey(),
|
|
572
|
+
pluginId: text("plugin_id").notNull().references(() => plugins.id),
|
|
573
|
+
action: text("action").notNull(),
|
|
574
|
+
userId: text("user_id"),
|
|
575
|
+
details: text("details", { mode: "json" }),
|
|
576
|
+
timestamp: integer("timestamp").notNull().$defaultFn(() => Math.floor(Date.now() / 1e3))
|
|
577
|
+
});
|
|
578
|
+
var insertUserSchema = createInsertSchema(authUser, {
|
|
579
|
+
email: (schema) => schema.email(),
|
|
580
|
+
firstName: (schema) => schema.min(1),
|
|
581
|
+
lastName: (schema) => schema.min(1)
|
|
582
|
+
});
|
|
583
|
+
var selectUserSchema = createSelectSchema(authUser);
|
|
584
|
+
var insertContentSchema = createInsertSchema(content, {
|
|
585
|
+
slug: (schema) => schema.min(1).regex(/^[a-zA-Z0-9_-]+$/, "Slug must contain only letters, numbers, underscores, and hyphens"),
|
|
586
|
+
title: (schema) => schema.min(1),
|
|
587
|
+
status: (schema) => schema
|
|
588
|
+
});
|
|
589
|
+
var selectContentSchema = createSelectSchema(content);
|
|
590
|
+
var insertMediaSchema = createInsertSchema(media, {
|
|
591
|
+
filename: (schema) => schema.min(1),
|
|
592
|
+
originalName: (schema) => schema.min(1),
|
|
593
|
+
mimeType: (schema) => schema.min(1),
|
|
594
|
+
size: (schema) => schema.positive(),
|
|
595
|
+
r2Key: (schema) => schema.min(1),
|
|
596
|
+
publicUrl: (schema) => schema.url(),
|
|
597
|
+
folder: (schema) => schema.min(1)
|
|
598
|
+
});
|
|
599
|
+
var selectMediaSchema = createSelectSchema(media);
|
|
600
|
+
var insertWorkflowHistorySchema = createInsertSchema(workflowHistory, {
|
|
601
|
+
action: (schema) => schema.min(1),
|
|
602
|
+
fromStatus: (schema) => schema.min(1),
|
|
603
|
+
toStatus: (schema) => schema.min(1)
|
|
604
|
+
});
|
|
605
|
+
var selectWorkflowHistorySchema = createSelectSchema(workflowHistory);
|
|
606
|
+
var insertPluginSchema = createInsertSchema(plugins, {
|
|
607
|
+
name: (schema) => schema.min(1),
|
|
608
|
+
displayName: (schema) => schema.min(1),
|
|
609
|
+
version: (schema) => schema.min(1),
|
|
610
|
+
author: (schema) => schema.min(1),
|
|
611
|
+
category: (schema) => schema.min(1)
|
|
612
|
+
});
|
|
613
|
+
var selectPluginSchema = createSelectSchema(plugins);
|
|
614
|
+
var insertPluginHookSchema = createInsertSchema(pluginHooks, {
|
|
615
|
+
hookName: (schema) => schema.min(1),
|
|
616
|
+
handlerName: (schema) => schema.min(1)
|
|
617
|
+
});
|
|
618
|
+
var selectPluginHookSchema = createSelectSchema(pluginHooks);
|
|
619
|
+
var insertPluginRouteSchema = createInsertSchema(pluginRoutes, {
|
|
620
|
+
path: (schema) => schema.min(1),
|
|
621
|
+
method: (schema) => schema.min(1),
|
|
622
|
+
handlerName: (schema) => schema.min(1)
|
|
623
|
+
});
|
|
624
|
+
var selectPluginRouteSchema = createSelectSchema(pluginRoutes);
|
|
625
|
+
var insertPluginAssetSchema = createInsertSchema(pluginAssets, {
|
|
626
|
+
assetType: (schema) => schema.min(1),
|
|
627
|
+
assetPath: (schema) => schema.min(1)
|
|
628
|
+
});
|
|
629
|
+
var selectPluginAssetSchema = createSelectSchema(pluginAssets);
|
|
630
|
+
var insertPluginActivityLogSchema = createInsertSchema(pluginActivityLog, {
|
|
631
|
+
action: (schema) => schema.min(1)
|
|
632
|
+
});
|
|
633
|
+
var selectPluginActivityLogSchema = createSelectSchema(pluginActivityLog);
|
|
634
|
+
var systemLogs = sqliteTable("system_logs", {
|
|
635
|
+
id: text("id").primaryKey(),
|
|
636
|
+
level: text("level").notNull(),
|
|
637
|
+
// 'debug', 'info', 'warn', 'error', 'fatal'
|
|
638
|
+
category: text("category").notNull(),
|
|
639
|
+
// 'auth', 'api', 'workflow', 'plugin', 'media', 'system', etc.
|
|
640
|
+
message: text("message").notNull(),
|
|
641
|
+
data: text("data", { mode: "json" }),
|
|
642
|
+
// Additional structured data
|
|
643
|
+
userId: text("user_id").references(() => authUser.id),
|
|
644
|
+
sessionId: text("session_id"),
|
|
645
|
+
requestId: text("request_id"),
|
|
646
|
+
ipAddress: text("ip_address"),
|
|
647
|
+
userAgent: text("user_agent"),
|
|
648
|
+
method: text("method"),
|
|
649
|
+
// HTTP method for API logs
|
|
650
|
+
url: text("url"),
|
|
651
|
+
// Request URL for API logs
|
|
652
|
+
statusCode: integer("status_code"),
|
|
653
|
+
// HTTP status code for API logs
|
|
654
|
+
duration: integer("duration"),
|
|
655
|
+
// Request duration in milliseconds
|
|
656
|
+
stackTrace: text("stack_trace"),
|
|
657
|
+
// Error stack trace for error logs
|
|
658
|
+
tags: text("tags", { mode: "json" }),
|
|
659
|
+
// Array of tags for categorization
|
|
660
|
+
source: text("source"),
|
|
661
|
+
// Source component/module that generated the log
|
|
662
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
663
|
+
});
|
|
664
|
+
var logConfig = sqliteTable("log_config", {
|
|
665
|
+
id: text("id").primaryKey(),
|
|
666
|
+
category: text("category").notNull().unique(),
|
|
667
|
+
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
|
668
|
+
level: text("level").notNull().default("info"),
|
|
669
|
+
// minimum log level to store
|
|
670
|
+
retention: integer("retention").notNull().default(30),
|
|
671
|
+
// days to keep logs
|
|
672
|
+
maxSize: integer("max_size").default(1e4),
|
|
673
|
+
// max number of logs per category
|
|
674
|
+
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
|
|
675
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
|
|
676
|
+
});
|
|
677
|
+
var insertSystemLogSchema = createInsertSchema(systemLogs, {
|
|
678
|
+
level: (schema) => schema.min(1),
|
|
679
|
+
category: (schema) => schema.min(1),
|
|
680
|
+
message: (schema) => schema.min(1)
|
|
681
|
+
});
|
|
682
|
+
var selectSystemLogSchema = createSelectSchema(systemLogs);
|
|
683
|
+
var insertLogConfigSchema = createInsertSchema(logConfig, {
|
|
684
|
+
category: (schema) => schema.min(1),
|
|
685
|
+
level: (schema) => schema.min(1)
|
|
686
|
+
});
|
|
687
|
+
var selectLogConfigSchema = createSelectSchema(logConfig);
|
|
688
|
+
var emailLog = sqliteTable("email_log", {
|
|
689
|
+
id: text("id").primaryKey(),
|
|
690
|
+
toEmail: text("to_email").notNull(),
|
|
691
|
+
// comma-joined recipients
|
|
692
|
+
fromEmail: text("from_email").notNull(),
|
|
693
|
+
subject: text("subject").notNull(),
|
|
694
|
+
status: text("status").notNull().default("pending"),
|
|
695
|
+
// 'pending' | 'sent' | 'failed'
|
|
696
|
+
provider: text("provider"),
|
|
697
|
+
// 'resend' | 'sendgrid' | 'console' | custom
|
|
698
|
+
providerId: text("provider_id"),
|
|
699
|
+
// provider-side message id
|
|
700
|
+
error: text("error"),
|
|
701
|
+
flow: text("flow"),
|
|
702
|
+
// 'password-reset' | 'otp' | 'magic-link' | 'welcome' | 'test' | ...
|
|
703
|
+
metadata: text("metadata", { mode: "json" }),
|
|
704
|
+
failedAtSend: integer("failed_at_send"),
|
|
705
|
+
// epoch ms; set when the send failed immediately
|
|
706
|
+
deliveryState: text("delivery_state"),
|
|
707
|
+
// populated by the reconciliation cron
|
|
708
|
+
deliverySyncedAt: integer("delivery_synced_at"),
|
|
709
|
+
// epoch ms; reconciliation sync marker
|
|
710
|
+
createdAt: integer("created_at").notNull()
|
|
711
|
+
// epoch ms
|
|
712
|
+
});
|
|
713
|
+
var insertEmailLogSchema = createInsertSchema(emailLog);
|
|
714
|
+
var selectEmailLogSchema = createSelectSchema(emailLog);
|
|
715
|
+
var securityEvents = sqliteTable("security_events", {
|
|
716
|
+
id: text("id").primaryKey(),
|
|
717
|
+
eventType: text("event_type").notNull(),
|
|
718
|
+
severity: text("severity").notNull().default("info"),
|
|
719
|
+
userId: text("user_id"),
|
|
720
|
+
email: text("email"),
|
|
721
|
+
ipAddress: text("ip_address"),
|
|
722
|
+
userAgent: text("user_agent"),
|
|
723
|
+
countryCode: text("country_code"),
|
|
724
|
+
requestPath: text("request_path"),
|
|
725
|
+
requestMethod: text("request_method"),
|
|
726
|
+
details: text("details", { mode: "json" }),
|
|
727
|
+
fingerprint: text("fingerprint"),
|
|
728
|
+
blocked: integer("blocked").notNull().default(0),
|
|
729
|
+
createdAt: integer("created_at").notNull().$defaultFn(() => Date.now())
|
|
730
|
+
});
|
|
731
|
+
var insertSecurityEventSchema = createInsertSchema(securityEvents, {
|
|
732
|
+
eventType: (schema) => schema.min(1),
|
|
733
|
+
severity: (schema) => schema.min(1)
|
|
734
|
+
});
|
|
735
|
+
var selectSecurityEventSchema = createSelectSchema(securityEvents);
|
|
736
|
+
var forms = sqliteTable("forms", {
|
|
737
|
+
id: text("id").primaryKey(),
|
|
738
|
+
name: text("name").notNull().unique(),
|
|
739
|
+
// Machine name (e.g., "contact-form")
|
|
740
|
+
displayName: text("display_name").notNull(),
|
|
741
|
+
// Human name (e.g., "Contact Form")
|
|
742
|
+
description: text("description"),
|
|
743
|
+
category: text("category").notNull().default("general"),
|
|
744
|
+
// contact, survey, registration, etc.
|
|
745
|
+
// Form.io schema (JSON)
|
|
746
|
+
formioSchema: text("formio_schema", { mode: "json" }).notNull(),
|
|
747
|
+
// Complete Form.io JSON schema
|
|
748
|
+
// Settings (JSON)
|
|
749
|
+
settings: text("settings", { mode: "json" }),
|
|
750
|
+
// emailNotifications, successMessage, etc.
|
|
751
|
+
// Status & Management
|
|
752
|
+
isActive: integer("is_active", { mode: "boolean" }).notNull().default(true),
|
|
753
|
+
isPublic: integer("is_public", { mode: "boolean" }).notNull().default(true),
|
|
754
|
+
managed: integer("managed", { mode: "boolean" }).notNull().default(false),
|
|
755
|
+
// Metadata
|
|
756
|
+
icon: text("icon"),
|
|
757
|
+
color: text("color"),
|
|
758
|
+
tags: text("tags", { mode: "json" }),
|
|
759
|
+
// JSON array
|
|
760
|
+
// Stats
|
|
761
|
+
submissionCount: integer("submission_count").notNull().default(0),
|
|
762
|
+
viewCount: integer("view_count").notNull().default(0),
|
|
763
|
+
// Ownership
|
|
764
|
+
createdBy: text("created_by").references(() => authUser.id),
|
|
765
|
+
updatedBy: text("updated_by").references(() => authUser.id),
|
|
766
|
+
// Timestamps
|
|
767
|
+
createdAt: integer("created_at").notNull(),
|
|
768
|
+
updatedAt: integer("updated_at").notNull()
|
|
769
|
+
});
|
|
770
|
+
var formSubmissions = sqliteTable("form_submissions", {
|
|
771
|
+
id: text("id").primaryKey(),
|
|
772
|
+
formId: text("form_id").notNull().references(() => forms.id, { onDelete: "cascade" }),
|
|
773
|
+
// Submission data
|
|
774
|
+
submissionData: text("submission_data", { mode: "json" }).notNull(),
|
|
775
|
+
// The actual form data
|
|
776
|
+
// Submission metadata
|
|
777
|
+
status: text("status").notNull().default("pending"),
|
|
778
|
+
// pending, reviewed, approved, rejected, spam
|
|
779
|
+
submissionNumber: integer("submission_number"),
|
|
780
|
+
// User information
|
|
781
|
+
userId: text("user_id").references(() => authUser.id),
|
|
782
|
+
userEmail: text("user_email"),
|
|
783
|
+
// Tracking
|
|
784
|
+
ipAddress: text("ip_address"),
|
|
785
|
+
userAgent: text("user_agent"),
|
|
786
|
+
referrer: text("referrer"),
|
|
787
|
+
utmSource: text("utm_source"),
|
|
788
|
+
utmMedium: text("utm_medium"),
|
|
789
|
+
utmCampaign: text("utm_campaign"),
|
|
790
|
+
// Review/Processing
|
|
791
|
+
reviewedBy: text("reviewed_by").references(() => authUser.id),
|
|
792
|
+
reviewedAt: integer("reviewed_at"),
|
|
793
|
+
reviewNotes: text("review_notes"),
|
|
794
|
+
// Flags
|
|
795
|
+
isSpam: integer("is_spam", { mode: "boolean" }).notNull().default(false),
|
|
796
|
+
isArchived: integer("is_archived", { mode: "boolean" }).notNull().default(false),
|
|
797
|
+
// Content integration
|
|
798
|
+
contentId: text("content_id").references(() => content.id),
|
|
799
|
+
// Links submission to its content item
|
|
800
|
+
// Timestamps
|
|
801
|
+
submittedAt: integer("submitted_at").notNull(),
|
|
802
|
+
updatedAt: integer("updated_at").notNull()
|
|
803
|
+
});
|
|
804
|
+
var formFiles = sqliteTable("form_files", {
|
|
805
|
+
id: text("id").primaryKey(),
|
|
806
|
+
submissionId: text("submission_id").notNull().references(() => formSubmissions.id, { onDelete: "cascade" }),
|
|
807
|
+
mediaId: text("media_id").notNull().references(() => media.id, { onDelete: "cascade" }),
|
|
808
|
+
fieldName: text("field_name").notNull(),
|
|
809
|
+
// Form field that uploaded this file
|
|
810
|
+
uploadedAt: integer("uploaded_at").notNull()
|
|
811
|
+
});
|
|
812
|
+
var insertFormSchema = createInsertSchema(forms);
|
|
813
|
+
var selectFormSchema = createSelectSchema(forms);
|
|
814
|
+
var insertFormSubmissionSchema = createInsertSchema(formSubmissions);
|
|
815
|
+
var selectFormSubmissionSchema = createSelectSchema(formSubmissions);
|
|
816
|
+
var insertFormFileSchema = createInsertSchema(formFiles);
|
|
817
|
+
var selectFormFileSchema = createSelectSchema(formFiles);
|
|
818
|
+
|
|
819
|
+
export { apiTokens, authAccount, authSession, authTenant, authTenantInvitation, authTenantMember, authTenantTeam, authUser, authVerification, content, contentVersions, insertContentSchema, insertLogConfigSchema, insertMediaSchema, insertPluginActivityLogSchema, insertPluginAssetSchema, insertPluginHookSchema, insertPluginRouteSchema, insertPluginSchema, insertSystemLogSchema, insertUserSchema, insertWorkflowHistorySchema, logConfig, media, pluginActivityLog, pluginAssets, pluginHooks, pluginRoutes, plugins, schema_exports, selectContentSchema, selectLogConfigSchema, selectMediaSchema, selectPluginActivityLogSchema, selectPluginAssetSchema, selectPluginHookSchema, selectPluginRouteSchema, selectPluginSchema, selectSystemLogSchema, selectUserSchema, selectWorkflowHistorySchema, systemLogs, users, workflowHistory };
|
|
820
|
+
//# sourceMappingURL=chunk-AI663NBO.js.map
|
|
821
|
+
//# sourceMappingURL=chunk-AI663NBO.js.map
|