create-fullstack-scaffold 0.4.2 → 0.4.4
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/dist/cli/index.js +513 -122
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/template/dist/cli/index.js +237 -94
- package/template/dist/cli/index.js.map +1 -1
- package/template/dist/client/admin.html +15 -10
- package/template/dist/client/assets/App-BpFUIC-5.js +114 -0
- package/template/dist/client/assets/{CartPage-DESSHkaG.js → CartPage-DgDZP-R5.js} +2 -2
- package/template/dist/client/assets/{CategoriesPage-DqLZ_Mom.js → CategoriesPage-fuYNiSmE.js} +2 -2
- package/template/dist/client/assets/ContentDetailPage-BvvFU1Mr.js +1 -0
- package/template/dist/client/assets/ContentListPage-ShPxo6WG.js +1 -0
- package/template/dist/client/assets/DashboardPage-C1rZzZo4.js +11 -0
- package/template/dist/client/assets/{DeveloperDashboardPage-Cum7zFwO.js → DeveloperDashboardPage-_WtmbVoA.js} +2 -2
- package/template/dist/client/assets/{EmptyState-BK7ttK8D.js → EmptyState-DEyOQjbY.js} +1 -1
- package/template/dist/client/assets/LoadingSpinner-BcHjaM1m.js +6 -0
- package/template/dist/client/assets/LoginPage-CjeQqDdO.js +1 -0
- package/template/dist/client/assets/LogoutOutlined-ColFAHdd.js +1 -0
- package/template/dist/client/assets/NotificationPage-DRkEv02s.js +1 -0
- package/template/dist/client/assets/OrdersPage-7I3vPWLP.js +11 -0
- package/template/dist/client/assets/{PluginDetailPage-Br24YS4P.js → PluginDetailPage-CWyxdVCg.js} +3 -13
- package/template/dist/client/assets/PluginsPage-DRgWLeJT.js +6 -0
- package/template/dist/client/assets/ProfilePage-2FFkaii8.js +16 -0
- package/template/dist/client/assets/PublishPage-DW7yvROx.js +1 -0
- package/template/dist/client/assets/{RegisterPage-rPFG4Sry.js → RegisterPage-Dvaf9b0e.js} +2 -2
- package/template/dist/client/assets/SaveOutlined-CLQ2tsSY.js +2 -0
- package/template/dist/client/assets/{SearchPage-DQl1U5Uy.js → SearchPage-DvnEyswS.js} +2 -2
- package/template/dist/client/assets/{SettingsPage-DaYE80wj.js → SettingsPage-IrU-L9Zr.js} +2 -2
- package/template/dist/client/assets/{StatusBadge-BJ3W2Zc7.js → StatusBadge-CG7wVqpu.js} +1 -1
- package/template/dist/client/assets/{TodoPage-zC5wWNBa.js → TodoPage-B7D-bl65.js} +3 -3
- package/template/dist/client/assets/TopicsPage-CYCNr-mn.js +6 -0
- package/template/dist/client/assets/{WebSocketPage-B4NLdz1w.js → WebSocketPage-CGEg6QJE.js} +2 -2
- package/template/dist/client/assets/{activity-B94BUAsD.js → activity-CgTz9Mrd.js} +1 -1
- package/template/dist/client/assets/admin-D2iHWNOg.js +1 -0
- package/template/dist/client/assets/api-request-DIJocPxr.js +356 -0
- package/template/dist/client/assets/{arrow-left-H5JH0iU1.js → arrow-left-DtLQ3tTk.js} +1 -1
- package/template/dist/client/assets/{chevron-down-DwRh_wjD.js → chevron-down-CpIAV_yr.js} +1 -1
- package/template/dist/client/assets/{chevron-right-CpIWaqAL.js → chevron-right-CnU7oPQs.js} +1 -1
- package/template/dist/client/assets/{circle-check-big-CSElLscG.js → circle-check-big-CrZdwS75.js} +1 -1
- package/template/dist/client/assets/{circle-x-CYxr4RAw.js → circle-x-CvN9r3fW.js} +1 -1
- package/template/dist/client/assets/{clock-BseUJ7ex.js → clock-CTeSZBiH.js} +1 -1
- package/template/dist/client/assets/{download-BsGC_Xhq.js → download-OSVfVuNV.js} +1 -1
- package/template/dist/client/assets/{external-link-UTDzdjq8.js → external-link-fBsuHMby.js} +1 -1
- package/template/dist/client/assets/{eye-nR10ui7i.js → eye-CwlZZEsj.js} +1 -1
- package/template/dist/client/assets/index-09IqiOaE.css +1 -0
- package/template/dist/client/assets/index-B3CRby6r.js +51 -0
- package/template/dist/client/assets/index-CC_zy73y.js +17 -0
- package/template/dist/client/assets/main-Cn4IDo2I.js +92 -0
- package/template/dist/client/assets/merchant-DDDN9bMu.js +40 -0
- package/template/dist/client/assets/{message-square-CwWGL-Bh.js → message-square-BRaZfgbJ.js} +1 -1
- package/template/dist/client/assets/pluginStore-DDsWJPe6.js +1 -0
- package/template/dist/client/assets/{plus-pZld_nUL.js → plus-DDZfPiDJ.js} +1 -1
- package/template/dist/client/assets/sse-client-DGQ072hl.js +64 -0
- package/template/dist/client/assets/star-C7tO6w4H.js +11 -0
- package/template/dist/client/assets/{tag-DsiUPF90.js → tag-DBfpQDuJ.js} +1 -1
- package/template/dist/client/assets/tenant-CizbLaLJ.js +1 -0
- package/template/dist/client/assets/{trash-2-DRblNbnA.js → trash-2-BP7fkd5b.js} +1 -1
- package/template/dist/client/assets/{triangle-alert-D1CLh-Vd.js → triangle-alert-CrOQEdJ2.js} +1 -1
- package/template/dist/client/assets/{wifi-BwXjnCqI.js → wifi-CwYSE0J4.js} +1 -1
- package/template/dist/client/assets/{x-BH2rJdFq.js → x-t615pnNR.js} +1 -1
- package/template/dist/client/content/index.html +5 -4
- package/template/dist/client/index.html +4 -3
- package/template/dist/client/merchant.html +18 -0
- package/template/dist/client/notifications/index.html +6 -5
- package/template/dist/client/tenant.html +18 -0
- package/template/dist/client/todos/index.html +6 -5
- package/template/dist/client/websocket/index.html +6 -5
- package/template/dist/cloudflare/chunk-HX7DVRDX.js +1 -0
- package/template/dist/cloudflare/{chunk-QBHAPWIA.js → chunk-IXJL2LE4.js} +1 -1
- package/template/dist/cloudflare/chunk-Q34AN3RF.js +14 -0
- package/template/dist/cloudflare/{chunk-BHPTQ4K2.js → chunk-ZAMVL4EG.js} +2 -2
- package/template/dist/cloudflare/cloudflare.js +35 -29
- package/template/dist/cloudflare/db-4AQOSFAX.js +1 -0
- package/template/dist/cloudflare/{migrator-2ZYYKNI5.js → migrator-TEPBVUFO.js} +1 -1
- package/template/dist/cloudflare/permission-service-impl-RE7NPW3Q.js +1 -0
- package/template/dist/cloudflare/schema-DVEMT3X2.js +1 -0
- package/template/dist/cloudflare/test-setup-Z2RYE5B4.js +265 -0
- package/template/dist/server/chunk-27SIJSPF.js +1 -0
- package/template/dist/server/chunk-37QNGBQU.js +1 -0
- package/template/dist/server/chunk-FIY4CGJJ.js +1 -0
- package/template/dist/server/chunk-HZUDBIT4.js +1 -0
- package/template/dist/server/chunk-I6OBDFDU.js +1 -0
- package/template/dist/server/chunk-JHNYLNG7.js +1 -0
- package/template/dist/server/chunk-MDOVVKKD.js +1 -0
- package/template/dist/server/chunk-NSOCT7E5.js +1 -0
- package/template/dist/server/chunk-OU5IGVVO.js +1 -0
- package/template/dist/server/chunk-OYCBNRMK.js +1 -0
- package/template/dist/server/chunk-P2RJNNGD.js +1 -0
- package/template/dist/server/chunk-UMAQLNPE.js +1 -0
- package/template/dist/server/chunk-XZZTSRSN.js +1 -0
- package/template/dist/server/content-service-5QVHDR5X.js +1 -0
- package/template/dist/server/db-FLI5L5DD.js +1 -0
- package/template/dist/server/dispute-service-E2FCYUEM.js +1 -0
- package/template/dist/server/init-72JXJV3I.js +46 -0
- package/template/dist/server/init-FWYXSKPX.js +46 -0
- package/template/dist/server/node.js +34 -28
- package/template/dist/server/order-service-TKGG5S5K.js +1 -0
- package/template/dist/server/permission-service-impl-M3AKEYNY.js +1 -0
- package/template/dist/server/schema-V4UG7HMU.js +1 -0
- package/template/dist/server/tenant-service-JG6UUWXQ.js +1 -0
- package/template/dist/server/tenant-service-XJWZSEDX.js +1 -0
- package/template/dist/{cloudflare/test-setup-NMZJZLRV.js → server/test-setup-VFOPBGYM.js} +83 -2
- package/template/dist/server/ticket-service-3RSW7V2Z.js +1 -0
- package/template/dist/server/todo-service-S6BGIO7D.js +1 -0
- package/template/package.json +1 -1
- package/template/src/client/App.tsx +3 -1
- package/template/src/client/pages/ContentListPage.tsx +36 -4
- package/template/src/client/pages/PluginsPage.tsx +112 -20
- package/template/src/client/pages/TodoPage.tsx +9 -1
- package/template/src/client/preset-ui-config.ts +79 -2
- package/template/src/merchant/pages/DisputesPage.tsx +11 -11
- package/template/src/merchant/pages/OrdersPage.tsx +4 -3
- package/template/src/merchant/pages/ProductsPage.tsx +2 -2
- package/template/src/merchant/stores/merchantStore.ts +11 -6
- package/template/src/server/db/init.ts +5 -253
- package/template/src/server/module-content/routes/topics-routes.ts +250 -0
- package/template/src/server/module-content/services/content-service.ts +1 -1
- package/template/src/server/module-plugin/services/plugin-seed-service.ts +623 -0
- package/template/src/server/module-tenant/routes/tenant-routes.ts +2 -2
- package/template/src/server/module-tenant/services/tenant-service.ts +63 -17
- package/template/src/server/module-todos/services/todo-service.ts +1 -1
- package/template/src/shared/modules/merchant/index.ts +9 -0
- package/template/src/shared/modules/merchant/schemas.ts +37 -0
- package/template/src/shared/modules/tenant/index.ts +2 -0
- package/template/src/shared/schemas/index.ts +27 -0
- package/template/src/tenant/layouts/Header.tsx +1 -1
- package/template/src/tenant/layouts/Sidebar.tsx +1 -1
- package/template/src/tenant/pages/SettingsPage.tsx +4 -8
- package/template/src/tenant/stores/tenantStore.ts +41 -302
- package/template/tsconfig.json +1 -0
- package/template/tsup.config.ts +11 -3
- package/template/dist/client/assets/ContentDetailPage-DdltMANL.js +0 -1
- package/template/dist/client/assets/ContentListPage-B63sUB6N.js +0 -1
- package/template/dist/client/assets/DashboardPage-tUMilc7Z.js +0 -11
- package/template/dist/client/assets/LoadingSpinner-DVYOLSRM.js +0 -6
- package/template/dist/client/assets/LoginPage-g9mSLIMC.js +0 -6
- package/template/dist/client/assets/NotificationPage-COTzp-HD.js +0 -1
- package/template/dist/client/assets/OrdersPage-BsPh4oEI.js +0 -11
- package/template/dist/client/assets/PluginsPage-BNtAe_yo.js +0 -6
- package/template/dist/client/assets/ProfilePage-dL_iSuZN.js +0 -16
- package/template/dist/client/assets/PublishPage-D96FnbLA.js +0 -1
- package/template/dist/client/assets/TopicsPage-DyLjZa4D.js +0 -6
- package/template/dist/client/assets/admin-Bh1vfz_L.js +0 -486
- package/template/dist/client/assets/index-1bA-ixFv.js +0 -114
- package/template/dist/client/assets/index-CWh3vXC_.css +0 -1
- package/template/dist/client/assets/main-DHnArIp_.js +0 -82
- package/template/dist/client/assets/pluginStore-XQfsm3iR.js +0 -1
- package/template/dist/client/content/content-1/index.html +0 -18
- package/template/dist/client/content/content-13/index.html +0 -18
- package/template/dist/client/content/content-14/index.html +0 -18
- package/template/dist/client/content/content-15/index.html +0 -18
- package/template/dist/client/content/content-19/index.html +0 -18
- package/template/dist/client/content/content-2/index.html +0 -18
- package/template/dist/client/content/content-20/index.html +0 -18
- package/template/dist/cloudflare/chunk-YY6FRMAQ.js +0 -14
- package/template/dist/cloudflare/db-7J42RQ3T.js +0 -1
- package/template/dist/cloudflare/permission-service-impl-TGXVSSSA.js +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head>
|
|
2
|
-
<meta charset="UTF-8">
|
|
3
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5
|
-
<title>Biomimic App</title>
|
|
6
|
-
<meta name="description" content="Biomimic App - A full-stack application template">
|
|
7
|
-
<meta property="og:title" content="Biomimic App">
|
|
8
|
-
<meta property="og:description" content="A full-stack application template with React and Hono">
|
|
9
|
-
<meta property="og:type" content="website">
|
|
10
|
-
<script type="module" crossorigin="" src="/assets/main-DHnArIp_.js"></script>
|
|
11
|
-
<link rel="modulepreload" crossorigin="" href="/assets/index-1bA-ixFv.js">
|
|
12
|
-
<link rel="stylesheet" crossorigin="" href="/assets/index-CWh3vXC_.css">
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div id="root"><div class="min-h-screen bg-white text-gray-900 " data-testid="app-container" style="font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; --preset-primary: #6366f1; --preset-primary-hover: #4f46e5; --preset-bg: #ffffff; --preset-text: #111827; --preset-secondary-bg: #f9fafb; --preset-border: #e5e7eb; --preset-radius: 12px; overflow-x: hidden;"><nav class="hidden md:block bg-white/80 backdrop-blur-md border-b border-gray-200 sticky top-0 z-50" data-testid="app-nav"><div class="max-w-7xl mx-auto px-4 h-16 flex items-center justify-between gap-3"><a data-testid="app-title" class="flex items-center gap-2 group shrink-0" href="/" data-discover="true"><div class="w-8 h-8 rounded-lg flex items-center justify-center shadow-sm group-hover:shadow-md transition-shadow" style="background-color: rgb(99, 102, 241);"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rocket w-4 h-4 text-white" aria-hidden="true"><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"></path><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09"></path><path d="M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z"></path><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05"></path></svg></div><span class="text-lg font-semibold text-gray-900 tracking-tight whitespace-nowrap">Biomimic</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles w-3.5 h-3.5 shrink-0" aria-hidden="true" style="color: rgb(99, 102, 241);"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"></path><path d="M20 2v4"></path><path d="M22 4h-4"></path><circle cx="4" cy="20" r="2"></circle></svg></a><div class="flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0 scrollbar-hide [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"><a data-testid="nav-today-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos" data-discover="true">Today</a><a data-testid="nav-calendar-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos/calendar" data-discover="true">Calendar</a><a data-testid="nav-projects-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos/projects" data-discover="true">Projects</a></div><div class="flex items-center gap-2"><a data-testid="auth-login" class="px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600" href="/login" data-discover="true">Sign In</a><a data-testid="auth-register" class="px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50" href="/register" data-discover="true">Sign Up</a></div></div></nav><main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 pb-24 md:pb-8" data-testid="app-main"><div class="flex items-center justify-center min-h-[50vh] text-gray-400">404 - Page not found</div></main><footer class="py-8 text-center text-gray-500 text-sm border-t border-gray-200 bg-white" data-testid="app-footer"><p class="flex items-center justify-center gap-2">Built with <span class="font-medium text-gray-700">Hono RPC</span> + <span class="font-medium text-gray-700">React</span> + <span class="font-medium text-gray-700">TypeScript</span></p><p class="mt-2 text-xs text-gray-400">Demonstrates: CRUD Operations | SSE (Server-Sent Events) | WebSocket</p></footer><nav class="md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/95 backdrop-blur-md border-t border-gray-200 safe-area-inset-bottom" data-testid="bottom-tab-bar" style="padding-bottom: env(safe-area-inset-bottom, 0px);"><div class="flex items-center justify-around h-16 px-2"><a data-testid="bottom-tab-today" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 " href="/todos" data-discover="true" style="color: rgb(99, 102, 241);"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sun w-5 h-5 transition-transform scale-110" aria-hidden="true"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2"></path><path d="M12 20v2"></path><path d="m4.93 4.93 1.41 1.41"></path><path d="m17.66 17.66 1.41 1.41"></path><path d="M2 12h2"></path><path d="M20 12h2"></path><path d="m6.34 17.66-1.41 1.41"></path><path d="m19.07 4.93-1.41 1.41"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 font-semibold">Today</span><div class="absolute top-0 w-8 h-0.5 rounded-full" style="background-color: rgb(99, 102, 241);"></div></a><a data-testid="bottom-tab-calendar" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 text-gray-400 hover:text-gray-600" href="/todos/calendar" data-discover="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar w-5 h-5 transition-transform" aria-hidden="true"><path d="M8 2v4"></path><path d="M16 2v4"></path><rect width="18" height="18" x="3" y="4" rx="2"></rect><path d="M3 10h18"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">Calendar</span></a><a data-testid="bottom-tab-projects" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 text-gray-400 hover:text-gray-600" href="/todos/projects" data-discover="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-folder-kanban w-5 h-5 transition-transform" aria-hidden="true"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">Projects</span></a></div></nav></div></div>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</body></html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head>
|
|
2
|
-
<meta charset="UTF-8">
|
|
3
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5
|
-
<title>Biomimic App</title>
|
|
6
|
-
<meta name="description" content="Biomimic App - A full-stack application template">
|
|
7
|
-
<meta property="og:title" content="Biomimic App">
|
|
8
|
-
<meta property="og:description" content="A full-stack application template with React and Hono">
|
|
9
|
-
<meta property="og:type" content="website">
|
|
10
|
-
<script type="module" crossorigin="" src="/assets/main-DHnArIp_.js"></script>
|
|
11
|
-
<link rel="modulepreload" crossorigin="" href="/assets/index-1bA-ixFv.js">
|
|
12
|
-
<link rel="stylesheet" crossorigin="" href="/assets/index-CWh3vXC_.css">
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div id="root"><div class="min-h-screen bg-white text-gray-900 " data-testid="app-container" style="font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; --preset-primary: #6366f1; --preset-primary-hover: #4f46e5; --preset-bg: #ffffff; --preset-text: #111827; --preset-secondary-bg: #f9fafb; --preset-border: #e5e7eb; --preset-radius: 12px; overflow-x: hidden;"><nav class="hidden md:block bg-white/80 backdrop-blur-md border-b border-gray-200 sticky top-0 z-50" data-testid="app-nav"><div class="max-w-7xl mx-auto px-4 h-16 flex items-center justify-between gap-3"><a data-testid="app-title" class="flex items-center gap-2 group shrink-0" href="/" data-discover="true"><div class="w-8 h-8 rounded-lg flex items-center justify-center shadow-sm group-hover:shadow-md transition-shadow" style="background-color: rgb(99, 102, 241);"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rocket w-4 h-4 text-white" aria-hidden="true"><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"></path><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09"></path><path d="M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z"></path><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05"></path></svg></div><span class="text-lg font-semibold text-gray-900 tracking-tight whitespace-nowrap">Biomimic</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles w-3.5 h-3.5 shrink-0" aria-hidden="true" style="color: rgb(99, 102, 241);"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"></path><path d="M20 2v4"></path><path d="M22 4h-4"></path><circle cx="4" cy="20" r="2"></circle></svg></a><div class="flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0 scrollbar-hide [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"><a data-testid="nav-today-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos" data-discover="true">Today</a><a data-testid="nav-calendar-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos/calendar" data-discover="true">Calendar</a><a data-testid="nav-projects-button" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-gray-500 hover:text-gray-900 hover:bg-gray-50" href="/todos/projects" data-discover="true">Projects</a></div><div class="flex items-center gap-2"><a data-testid="auth-login" class="px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600" href="/login" data-discover="true">Sign In</a><a data-testid="auth-register" class="px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50" href="/register" data-discover="true">Sign Up</a></div></div></nav><main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 pb-24 md:pb-8" data-testid="app-main"><div class="flex items-center justify-center min-h-[50vh] text-gray-400">404 - Page not found</div></main><footer class="py-8 text-center text-gray-500 text-sm border-t border-gray-200 bg-white" data-testid="app-footer"><p class="flex items-center justify-center gap-2">Built with <span class="font-medium text-gray-700">Hono RPC</span> + <span class="font-medium text-gray-700">React</span> + <span class="font-medium text-gray-700">TypeScript</span></p><p class="mt-2 text-xs text-gray-400">Demonstrates: CRUD Operations | SSE (Server-Sent Events) | WebSocket</p></footer><nav class="md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/95 backdrop-blur-md border-t border-gray-200 safe-area-inset-bottom" data-testid="bottom-tab-bar" style="padding-bottom: env(safe-area-inset-bottom, 0px);"><div class="flex items-center justify-around h-16 px-2"><a data-testid="bottom-tab-today" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 " href="/todos" data-discover="true" style="color: rgb(99, 102, 241);"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sun w-5 h-5 transition-transform scale-110" aria-hidden="true"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2"></path><path d="M12 20v2"></path><path d="m4.93 4.93 1.41 1.41"></path><path d="m17.66 17.66 1.41 1.41"></path><path d="M2 12h2"></path><path d="M20 12h2"></path><path d="m6.34 17.66-1.41 1.41"></path><path d="m19.07 4.93-1.41 1.41"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 font-semibold">Today</span><div class="absolute top-0 w-8 h-0.5 rounded-full" style="background-color: rgb(99, 102, 241);"></div></a><a data-testid="bottom-tab-calendar" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 text-gray-400 hover:text-gray-600" href="/todos/calendar" data-discover="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar w-5 h-5 transition-transform" aria-hidden="true"><path d="M8 2v4"></path><path d="M16 2v4"></path><rect width="18" height="18" x="3" y="4" rx="2"></rect><path d="M3 10h18"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">Calendar</span></a><a data-testid="bottom-tab-projects" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 text-gray-400 hover:text-gray-600" href="/todos/projects" data-discover="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-folder-kanban w-5 h-5 transition-transform" aria-hidden="true"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">Projects</span></a></div></nav></div></div>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</body></html>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {e,c,C,s,n,l,i,g as g$1,p,a as a$1,y,b as b$1,r,v,u,A,x,w,t,z,d,B,j,q,f as f$1,m,k,h,o}from'./chunk-QBHAPWIA.js';import {a,b}from'./chunk-5J6HXUF6.js';import {config}from'dotenv';import {resolve,dirname}from'path';import {existsSync,mkdirSync}from'fs';import {createClient}from'@libsql/client';import ke from'pino';var ae,pt=a(()=>{ae=typeof globalThis<"u"&&("WebSocketPair"in globalThis||globalThis.isCloudflare===true),!ae&&typeof process<"u"&&process.versions?.node!==void 0;});function qn(){if(ae)return;let t={production:".env.production"}["production"];{let i=resolve(process.cwd(),t);existsSync(i)&&config({path:i});}}function ht(){let r="production",e=typeof process<"u"?parseInt(process.env.PORT||"3010",10):3010,t=typeof process<"u"?process.env.ENABLE_DOCS!=="false":false,i=["sqlite","mysql","d1"],s=typeof process<"u"?process.env.DB_DRIVER||"sqlite":"d1",n=i.includes(s)?s:"sqlite";return {nodeEnv:r,port:e,enableDocs:t,database:{driver:ae?"d1":n,sqlitePath:typeof process<"u"?process.env.SQLITE_PATH||`./data/${r}.db`:void 0,mysqlHost:typeof process<"u"?process.env.MYSQL_HOST||"localhost":void 0,mysqlPort:typeof process<"u"?parseInt(process.env.MYSQL_PORT||"3306",10):void 0,mysqlUser:typeof process<"u"?process.env.MYSQL_USER||"root":void 0,mysqlPassword:typeof process<"u"?process.env.MYSQL_PASSWORD||"":void 0,mysqlDatabase:typeof process<"u"?process.env.MYSQL_DATABASE||"app":void 0,d1Database:globalThis.DB}}}function Ce(){return ht().database}var yt=a(()=>{pt();qn();});function We(r,e){return new Proxy(r,new De(e,false))}function ee(r,e){return new Proxy(r,new Te(new Proxy(r.table,new De(e,false))))}function Zt(r,e){return new v.Aliased(Je(r.sql,e),r.fieldAlias)}function Je(r,e){return y.join(r.queryChunks.map(t=>b$1(t,d)?ee(t,e):b$1(t,v)?Je(t,e):b$1(t,v.Aliased)?Zt(t,e):t))}var Te,De,gt=a(()=>{e();c();C();s();n();Te=class{constructor(e){this.table=e;}static[a$1]="ColumnAliasProxyHandler";get(e,t){return t==="table"?this.table:e[t]}},De=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t;}static[a$1]="TableAliasProxyHandler";get(e,t){if(t===p.Symbol.IsAlias)return true;if(t===p.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===p.Symbol.OriginalName)return this.alias;if(t===m)return {...e[m],name:this.alias,isAlias:true};if(t===p.Symbol.Columns){let s=e[p.Symbol.Columns];if(!s)return s;let n={};return Object.keys(s).map(a=>{n[a]=new Proxy(s[a],new Te(new Proxy(e,this)));}),n}let i=e[t];return b$1(i,d)?new Proxy(i,new Te(new Proxy(e,this))):i}};});var Qi=a(()=>{});var Ai=a(()=>{c();});function qe(r,e,t){let i={},s=r.reduce((n,{path:a,field:l},u)=>{let d$1;b$1(l,d)?d$1=l:b$1(l,v)?d$1=l.decoder:b$1(l,j)?d$1=l._.sql.decoder:d$1=l.sql.decoder;let h=n;for(let[x,q$1]of a.entries())if(x<a.length-1)q$1 in h||(h[q$1]={}),h=h[q$1];else {let _=e[u],A=h[q$1]=_===null?null:d$1.mapFromDriverValue(_);if(t&&b$1(l,d)&&a.length===2){let $=a[0];$ in i?typeof i[$]=="string"&&i[$]!==q(l.table)&&(i[$]=false):i[$]=A===null?q(l.table):false;}}return n},{});if(t&&Object.keys(i).length>0)for(let[n,a]of Object.entries(i))typeof a=="string"&&!t[a]&&(s[n]=null);return s}function W(r,e){return Object.entries(r).reduce((t,[i,s])=>{if(typeof i!="string")return t;let n=e?[...e,i]:[i];return b$1(s,d)||b$1(s,v)||b$1(s,v.Aliased)||b$1(s,j)?t.push({path:n,field:s}):b$1(s,p)?t.push(...W(s[p.Symbol.Columns],n)):t.push(...W(s,n)),t},[])}function He(r,e){let t=Object.keys(r),i=Object.keys(e);if(t.length!==i.length)return false;for(let[s,n]of t.entries())if(n!==i[s])return false;return true}function bt(r,e){let t=Object.entries(e).filter(([,i])=>i!==void 0).map(([i,s])=>b$1(s,v)||b$1(s,d)?[i,s]:[i,new x(s,r[p.Symbol.Columns][i])]);if(t.length===0)throw new Error("No values to set");return Object.fromEntries(t)}function Di(r,e){for(let t of e)for(let i of Object.getOwnPropertyNames(t.prototype))i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(t.prototype,i)||Object.create(null));}function wt(r){return r[p.Symbol.Columns]}function Ye(r){return b$1(r,j)?r._.alias:b$1(r,B)?r[m].name:b$1(r,v)?void 0:r[p.Symbol.IsAlias]?r[p.Symbol.Name]:r[p.Symbol.BaseName]}function te(r,e){return {name:typeof r=="string"&&r.length>0?r:"",config:typeof r=="object"?r:e}}function Bi(r){if(typeof r!="object"||r===null||r.constructor.name!=="Object")return false;if("logger"in r){let e=typeof r.logger;return !(e!=="boolean"&&(e!=="object"||typeof r.logger.logQuery!="function")&&e!=="undefined")}if("schema"in r){let e=typeof r.schema;return !(e!=="object"&&e!=="undefined")}if("casing"in r){let e=typeof r.casing;return !(e!=="string"&&e!=="undefined")}if("mode"in r)return !(r.mode!=="default"||r.mode!=="planetscale"||r.mode!==void 0);if("connection"in r){let e=typeof r.connection;return !(e!=="string"&&e!=="object"&&e!=="undefined")}if("client"in r){let e=typeof r.client;return !(e!=="object"&&e!=="function"&&e!=="undefined")}return Object.keys(r).length===0}var er,P=a(()=>{e();c();C();l();s();n();er=typeof TextDecoder>"u"?null:new TextDecoder;});var St,tr,rr=a(()=>{c();i();St=class{static[a$1]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:i,columns:s,foreignColumns:n}=e();return {name:i,columns:s,foreignTable:n[0].table,foreignColumns:n}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete);}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new tr(e,this)}},tr=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[a$1]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(l=>l.name),n=i.map(l=>l.name),a=[this.table[h],...s,i[0].table[h],...n];return e??`${a.join("_")}_fk`}};});function or(r,e){return `${r[h]}_${e.join("_")}_unique`}function Ri(r){return new sr(r)}var ir,sr,nr,ar=a(()=>{c();i();ir=class{constructor(e,t){this.name=t,this.columns=e;}static[a$1]="SQLiteUniqueConstraintBuilder";columns;build(e){return new nr(e,this.columns,this.name)}},sr=class{static[a$1]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e;}on(...e){return new ir(e,this.name)}},nr=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??or(this.table,this.columns.map(s=>s.name));}static[a$1]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}};});var O,Q,de=a(()=>{g$1();e();c();rr();ar();O=class extends f$1{static[a$1]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=true,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>((n,a)=>{let l=new St(()=>{let u=n();return {columns:[e],foreignColumns:[u]}});return a.onUpdate&&l.onUpdate(a.onUpdate),a.onDelete&&l.onDelete(a.onDelete),l.build(t)})(i,s))}},Q=class extends d{constructor(e,t){t.uniqueName||(t.uniqueName=or(e,[t.name])),super(e,t),this.table=e;}static[a$1]="SQLiteColumn"};});function Oi(r,e){let{name:t,config:i}=te(r,e);return i?.mode==="json"?new ur(t):i?.mode==="bigint"?new lr(t):new fr(t)}var lr,cr,ur,mr,fr,dr,pr=a(()=>{c();P();de();lr=class extends O{static[a$1]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt");}build(e){return new cr(e,this.config)}},cr=class extends Q{static[a$1]="SQLiteBigInt";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(er.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},ur=class extends O{static[a$1]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson");}build(e){return new mr(e,this.config)}},mr=class extends Q{static[a$1]="SQLiteBlobJson";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(er.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},fr=class extends O{static[a$1]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer");}build(e){return new dr(e,this.config)}},dr=class extends Q{static[a$1]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return "blob"}};});function Fi(r){return (e,t)=>{let{name:i,config:s}=te(e,t);return new hr(i,s,r)}}var hr,yr,gr=a(()=>{c();P();de();hr=class extends O{static[a$1]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i;}build(e){return new yr(e,this.config)}},yr=class extends Q{static[a$1]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};});function g(r,e){let{name:t,config:i}=te(r,e);return i?.mode==="timestamp"||i?.mode==="timestamp_ms"?new Sr(t,i.mode):i?.mode==="boolean"?new $r(t,i.mode):new br(t)}var Ge,Ze,br,wr,Sr,xr,$r,Nr,Cr=a(()=>{c();C();P();de();Ge=class extends O{static[a$1]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=false;}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=true),this.config.hasDefault=true,super.primaryKey()}},Ze=class extends Q{static[a$1]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return "integer"}},br=class extends Ge{static[a$1]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger");}build(e){return new wr(e,this.config)}},wr=class extends Ze{static[a$1]="SQLiteInteger"},Sr=class extends Ge{static[a$1]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t;}defaultNow(){return this.default(y`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new xr(e,this.config)}},xr=class extends Ze{static[a$1]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return this.config.mode==="timestamp"?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode==="timestamp"?Math.floor(t/1e3):t}},$r=class extends Ge{static[a$1]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t;}build(e){return new Nr(e,this.config)}},Nr=class extends Ze{static[a$1]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}};});function ji(r,e){let{name:t,config:i}=te(r,e),s=i?.mode;return s==="number"?new vr(t):s==="bigint"?new Qr(t):new Tr(t)}var Tr,qr,vr,Lr,Qr,_r,Ar=a(()=>{c();P();de();Tr=class extends O{static[a$1]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric");}build(e){return new qr(e,this.config)}},qr=class extends Q{static[a$1]="SQLiteNumeric";mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return "numeric"}},vr=class extends O{static[a$1]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber");}build(e){return new Lr(e,this.config)}},Lr=class extends Q{static[a$1]="SQLiteNumericNumber";mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}mapToDriverValue=String;getSQLType(){return "numeric"}},Qr=class extends O{static[a$1]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt");}build(e){return new _r(e,this.config)}},_r=class extends Q{static[a$1]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return "numeric"}};});function Mi(r){return new Dr(r??"")}var Dr,Br,Rr=a(()=>{c();de();Dr=class extends O{static[a$1]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal");}build(e){return new Br(e,this.config)}},Br=class extends Q{static[a$1]="SQLiteReal";getSQLType(){return "real"}};});function f(r,e={}){let{name:t,config:i}=te(r,e);return i.mode==="json"?new jr(t):new Or(t,i)}var Or,Fr,jr,Mr,Er=a(()=>{c();P();de();Or=class extends O{static[a$1]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length;}build(e){return new Fr(e,this.config)}},Fr=class extends Q{static[a$1]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t);}getSQLType(){return `text${this.config.length?`(${this.config.length})`:""}`}},jr=class extends O{static[a$1]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson");}build(e){return new Mr(e,this.config)}},Mr=class extends Q{static[a$1]="SQLiteTextJson";getSQLType(){return "text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};});var Pr=a(()=>{pr();de();gr();Cr();Ar();Rr();Er();});var L,ve=a(()=>{gt();e();c();C();l();n();L=class r{static[a$1]="SelectionProxyHandler";config;constructor(e){this.config={...e};}get(e,t){if(t==="_")return {...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===m)return {...e[m],selectedFields:new Proxy(e[m].selectedFields,this)};if(typeof t=="symbol")return e[t];let s=(b$1(e,j)?e._.selectedFields:b$1(e,B)?e[m].selectedFields:e)[t];if(b$1(s,v.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;let n=s.clone();return n.isSelectionField=true,n}if(b$1(s,v)){if(this.config.sqlBehavior==="sql")return s;throw new Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return b$1(s,d)?this.config.alias?new Proxy(s,new Te(new Proxy(s.table,new De(this.config.alias,this.config.replaceOriginalName??false)))):s:typeof s!="object"||s===null?s:new Proxy(s,new r(this.config))}};});var I,le=a(()=>{c();I=class{static[a$1]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}};});function Ei(){return {blob:Oi,customType:Fi,integer:g,numeric:ji,real:Mi,text:f}}var Pi=a(()=>{pr();gr();Cr();Ar();Rr();Er();});function vn(r,e,t,i,s=r){let n=new R(r,i,s),a=typeof e=="function"?e(Ei()):e,l=Object.fromEntries(Object.entries(a).map(([d,h])=>{let x=h;x.setName(d);let q=x.build(n);return n[Ir].push(...x.buildForeignKeys(q,n)),[d,q]})),u=Object.assign(n,l);return u[p.Symbol.Columns]=l,u[p.Symbol.ExtraConfigColumns]=l,t&&(u[R.Symbol.ExtraConfigBuilder]=t),u}var Ir,R,N,ce=a(()=>{c();s();Pi();Ir=Symbol.for("drizzle:SQLiteInlineForeignKeys"),R=class extends p{static[a$1]="SQLiteTable";static Symbol=Object.assign({},p.Symbol,{InlineForeignKeys:Ir});[p.Symbol.Columns];[Ir]=[];[p.Symbol.ExtraConfigBuilder]=void 0};N=(r,e,t)=>vn(r,e,t);});var Ki=a(()=>{c();});function $t(...r){return r[0].columns?new xt(r[0].columns,r[0].name):new xt(r)}var xt,Vr,ki=a(()=>{c();ce();xt=class{static[a$1]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t;}build(e){return new Vr(e,this.columns,this.name)}},Vr=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i;}static[a$1]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[R.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}};});function Y(r){return b$1(r,R)?[`${r[p.Symbol.BaseName]}`]:b$1(r,j)?r._.usedTables??[]:b$1(r,v)?r.usedTables??[]:[]}var Be=a(()=>{c();C();l();s();ce();});var Xe,Vi=a(()=>{c();le();ve();ce();s();P();Be();Xe=class extends I{constructor(e,t,i,s){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s};}static[a$1]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.table[p.Symbol.Columns],new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i;}else {let t=e;this.config.orderBy=t;}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[R.Symbol.Columns]){return this.config.returning=W(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"delete",tables:Y(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}};});function Ln(r){return (r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(t=>t.toLowerCase()).join("_")}function Qn(r){return (r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((t,i,s)=>{let n=s===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return t+n},"")}function _n(r){return r}var Nt,zi=a(()=>{c();s();Nt=class{static[a$1]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Ln:e==="camelCase"?Qn:_n;}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[p.Symbol.Schema]??"public",i=e.table[p.Symbol.OriginalName],s=`${t}.${i}.${e.name}`;return this.cache[s]||this.cacheTable(e.table),this.cache[s]}cacheTable(e){let t=e[p.Symbol.Schema]??"public",i=e[p.Symbol.OriginalName],s=`${t}.${i}`;if(!this.cachedTables[s]){for(let n of Object.values(e[p.Symbol.Columns])){let a=`${s}.${n.name}`;this.cache[a]=this.convert(n.name);}this.cachedTables[s]=true;}}clearCache(){this.cache={},this.cachedTables={};}};});var Le,ue,Ct,Tt=a(()=>{c();Le=class extends Error{static[a$1]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t;}},ue=class r extends Error{constructor(e,t,i){super(`Failed query: ${e}
|
|
2
|
-
params: ${t}`),this.query=e,this.params=t,this.cause=i,Error.captureStackTrace(this,r),i&&(this.cause=i);}},Ct=class extends Le{static[a$1]="TransactionRollbackError";constructor(){super({message:"Rollback"});}};});var Ui,Wi,qt,Ji=a(()=>{c();s();Ui=Symbol.for("drizzle:PgInlineForeignKeys"),Wi=Symbol.for("drizzle:EnableRLS"),qt=class extends p{static[a$1]="PgTable";static Symbol=Object.assign({},p.Symbol,{InlineForeignKeys:Ui,EnableRLS:Wi});[Ui]=[];[Wi]=false;[p.Symbol.ExtraConfigBuilder]=void 0;[p.Symbol.ExtraConfigColumns]={}};});var vt,zr,Hi=a(()=>{c();Ji();vt=class{static[a$1]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t;}build(e){return new zr(e,this.columns,this.name)}},zr=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i;}static[a$1]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[qt.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}};});function V(r,e){return w(e)&&!t(r)&&!b$1(r,x)&&!b$1(r,z)&&!b$1(r,d)&&!b$1(r,p)&&!b$1(r,B)?new x(r,e):r}function et(...r){let e=r.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new v(e):new v([new u("("),y.join(e,new u(" and ")),new u(")")])}function Gi(...r){let e=r.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new v(e):new v([new u("("),y.join(e,new u(" or ")),new u(")")])}function Zi(r){return y`not ${r}`}function is(r,e){return Array.isArray(e)?e.length===0?y`false`:y`${r} in ${e.map(t=>V(t,r))}`:y`${r} in ${V(e,r)}`}function ss(r,e){return Array.isArray(e)?e.length===0?y`true`:y`${r} not in ${e.map(t=>V(t,r))}`:y`${r} not in ${V(e,r)}`}function ns(r){return y`${r} is null`}function os(r){return y`${r} is not null`}function as(r){return y`exists ${r}`}function ls(r){return y`not exists ${r}`}function cs(r,e,t){return y`${r} between ${V(e,r)} and ${V(t,r)}`}function us(r,e,t){return y`${r} not between ${V(e,r)} and ${V(t,r)}`}function ms(r,e){return y`${r} like ${e}`}function fs(r,e){return y`${r} not like ${e}`}function ds(r,e){return y`${r} ilike ${e}`}function ps(r,e){return y`${r} not ilike ${e}`}var Lt,Yi,Xi,es,ts,rs,hs=a(()=>{e();c();s();C();Lt=(r,e)=>y`${r} = ${V(e,r)}`,Yi=(r,e)=>y`${r} <> ${V(e,r)}`;Xi=(r,e)=>y`${r} > ${V(e,r)}`,es=(r,e)=>y`${r} >= ${V(e,r)}`,ts=(r,e)=>y`${r} < ${V(e,r)}`,rs=(r,e)=>y`${r} <= ${V(e,r)}`;});function ys(r){return y`${r} asc`}function gs(r){return y`${r} desc`}var bs=a(()=>{C();});var Ur=a(()=>{hs();bs();});function ws(){return {and:et,between:cs,eq:Lt,exists:as,gt:Xi,gte:es,ilike:ds,inArray:is,isNull:ns,isNotNull:os,like:ms,lt:ts,lte:rs,ne:Yi,not:Zi,notBetween:us,notExists:ls,notLike:fs,notIlike:ps,notInArray:ss,or:Gi,sql:y}}function Ss(){return {sql:y,asc:ys,desc:gs}}function At(r$1,e){Object.keys(r$1).length===1&&"default"in r$1&&!b$1(r$1.default,p)&&(r$1=r$1.default);let t={},i={},s={};for(let[n,a]of Object.entries(r$1))if(b$1(a,p)){let l=r(a),u=i[l];t[l]=n,s[n]={tsName:n,dbName:a[p.Symbol.Name],schema:a[p.Symbol.Schema],columns:a[p.Symbol.Columns],relations:u?.relations??{},primaryKey:u?.primaryKey??[]};for(let h of Object.values(a[p.Symbol.Columns]))h.primary&&s[n].primaryKey.push(h);let d=a[p.Symbol.ExtraConfigBuilder]?.(a[p.Symbol.ExtraConfigColumns]);if(d)for(let h of Object.values(d))b$1(h,vt)&&s[n].primaryKey.push(...h.columns);}else if(b$1(a,Wr)){let l=r(a.table),u=t[l],d=a.config(e(a.table)),h;for(let[x,q]of Object.entries(d))if(u){let _=s[u];_.relations[x]=q;}else l in i||(i[l]={relations:{},primaryKey:h}),i[l].relations[x]=q;}return {tables:s,tableNamesMap:t}}function An(r){return function(t,i){return new pe(r,t,i,i?.fields.reduce((s,n)=>s&&n.notNull,true)??false)}}function Dn(r){return function(t,i){return new tt(r,t,i)}}function xs(r$1,e,t){if(b$1(t,pe)&&t.config)return {fields:t.config.fields,references:t.config.references};let i=e[r(t.referencedTable)];if(!i)throw new Error(`Table "${t.referencedTable[p.Symbol.Name]}" not found in schema`);let s=r$1[i];if(!s)throw new Error(`Table "${i}" not found in schema`);let n=t.sourceTable,a=e[r(n)];if(!a)throw new Error(`Table "${n[p.Symbol.Name]}" not found in schema`);let l=[];for(let u of Object.values(s.relations))(t.relationName&&t!==u&&u.relationName===t.relationName||!t.relationName&&u.referencedTable===t.sourceTable)&&l.push(u);if(l.length>1)throw t.relationName?new Error(`There are multiple relations with name "${t.relationName}" in table "${i}"`):new Error(`There are multiple relations between "${i}" and "${t.sourceTable[p.Symbol.Name]}". Please specify relation name`);if(l[0]&&b$1(l[0],pe)&&l[0].config)return {fields:l[0].config.references,references:l[0].config.fields};throw new Error(`There is not enough information to infer relation "${a}.${t.fieldName}"`)}function Dt(r){return {one:An(r),many:Dn(r)}}function _t(r,e,t,i,s=n=>n){let n={};for(let[a,l]of i.entries())if(l.isJson){let u=e.relations[l.tsKey],d=t[a],h=typeof d=="string"?JSON.parse(d):d;n[l.tsKey]=b$1(u,pe)?h&&_t(r,r[l.relationTableTsKey],h,l.selection,s):h.map(x=>_t(r,r[l.relationTableTsKey],x,l.selection,s));}else {let u=s(t[a]),d$1=l.field,h;b$1(d$1,d)?h=d$1:b$1(d$1,v)?h=d$1.decoder:h=d$1.sql.decoder,n[l.tsKey]=u===null?null:h.mapFromDriverValue(u);}return n}var Qt,Wr,pe,tt,Re=a(()=>{s();e();c();Hi();Ur();C();Qt=class{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[p.Symbol.Name];}static[a$1]="Relation";referencedTableName;fieldName},Wr=class{constructor(e,t){this.table=e,this.config=t;}static[a$1]="Relations"},pe=class r extends Qt{constructor(e,t,i,s){super(e,t,i?.relationName),this.config=i,this.isNullable=s;}static[a$1]="One";withFieldName(e){let t=new r(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}},tt=class r extends Qt{constructor(e,t,i){super(e,t,i?.relationName),this.config=i;}static[a$1]="Many";withFieldName(e){let t=new r(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}};});var $s=a(()=>{});var Ns=a(()=>{});var Cs=a(()=>{$s();Ns();});var Jr=a(()=>{Ur();Cs();C();});var re,rt=a(()=>{c();C();re=class extends B{static[a$1]="SQLiteViewBase"};});var Qe,Bt,Oe,it=a(()=>{gt();zi();e();c();Tt();Re();Jr();C();Pr();ce();l();s();P();n();rt();Qe=class{static[a$1]="SQLiteDialect";casing;constructor(e){this.casing=new Nt(e?.casing);}escapeName(e){return `"${e.replace(/"/g,'""')}"`}escapeParam(e){return "?"}escapeString(e){return `'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[y`with `];for(let[i,s]of e.entries())t.push(y`${y.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push(y`, `);return t.push(y` `),y.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s,limit:n,orderBy:a}){let l=this.buildWithCTE(s),u=i?y` returning ${this.buildSelection(i,{isSingleTable:true})}`:void 0,d=t?y` where ${t}`:void 0,h=this.buildOrderBy(a),x=this.buildLimit(n);return y`${l}delete from ${e}${d}${u}${h}${x}`}buildUpdateSet(e,t){let i=e[p.Symbol.Columns],s=Object.keys(i).filter(a=>t[a]!==void 0||i[a]?.onUpdateFn!==void 0),n=s.length;return y.join(s.flatMap((a,l)=>{let u=i[a],d=u.onUpdateFn?.(),h=t[a]??(b$1(d,v)?d:y.param(d,u)),x=y`${y.identifier(this.casing.getColumnCasing(u))} = ${h}`;return l<n-1?[x,y.raw(", ")]:[x]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:n,joins:a,from:l,limit:u,orderBy:d}){let h=this.buildWithCTE(n),x=this.buildUpdateSet(e,t),q=l&&y.join([y.raw(" from "),this.buildFromTable(l)]),_=this.buildJoins(a),A=s?y` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,$=i?y` where ${i}`:void 0,D=this.buildOrderBy(d),B=this.buildLimit(u);return y`${h}update ${e} set ${x}${q}${_}${$}${A}${D}${B}`}buildSelection(e,{isSingleTable:t=false}={}){let i=e.length,s=e.flatMap(({field:n},a)=>{let l=[];if(b$1(n,v.Aliased)&&n.isSelectionField)l.push(y.identifier(n.fieldAlias));else if(b$1(n,v.Aliased)||b$1(n,v)){let u=b$1(n,v.Aliased)?n.sql:n;t?l.push(new v(u.queryChunks.map(d$1=>b$1(d$1,d)?y.identifier(this.casing.getColumnCasing(d$1)):d$1))):l.push(u),b$1(n,v.Aliased)&&l.push(y` as ${y.identifier(n.fieldAlias)}`);}else if(b$1(n,d)){let u=n.table[p.Symbol.Name];n.columnType==="SQLiteNumericBigInt"?t?l.push(y`cast(${y.identifier(this.casing.getColumnCasing(n))} as text)`):l.push(y`cast(${y.identifier(u)}.${y.identifier(this.casing.getColumnCasing(n))} as text)`):t?l.push(y.identifier(this.casing.getColumnCasing(n))):l.push(y`${y.identifier(u)}.${y.identifier(this.casing.getColumnCasing(n))}`);}else if(b$1(n,j)){let u=Object.entries(n._.selectedFields);if(u.length===1){let d$1=u[0][1],h=b$1(d$1,v)?d$1.decoder:b$1(d$1,d)?{mapFromDriverValue:x=>d$1.mapFromDriverValue(x)}:d$1.sql.decoder;h&&(n._.sql.decoder=h);}l.push(n);}return a<i-1&&l.push(y`, `),l});return y.join(s)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[i,s]of e.entries()){i===0&&t.push(y` `);let n=s.table,a=s.on?y` on ${s.on}`:void 0;if(b$1(n,R)){let l=n[R.Symbol.Name],u=n[R.Symbol.Schema],d=n[R.Symbol.OriginalName],h=l===d?void 0:s.alias;t.push(y`${y.raw(s.joinType)} join ${u?y`${y.identifier(u)}.`:void 0}${y.identifier(d)}${h&&y` ${y.identifier(h)}`}${a}`);}else t.push(y`${y.raw(s.joinType)} join ${n}${a}`);i<e.length-1&&t.push(y` `);}return y.join(t)}buildLimit(e){return typeof e=="object"||typeof e=="number"&&e>=0?y` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push(y`, `);return t.length>0?y` order by ${y.join(t)}`:void 0}buildFromTable(e){return b$1(e,p)&&e[p.Symbol.IsAlias]?y`${y`${y.identifier(e[p.Symbol.Schema]??"")}.`.if(e[p.Symbol.Schema])}${y.identifier(e[p.Symbol.OriginalName])} ${y.identifier(e[p.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:s,having:n,table:a,joins:l,orderBy:u,groupBy:d$1,limit:h,offset:x,distinct:q$1,setOperators:_}){let A=i??W(t);for(let H of A)if(b$1(H.field,d)&&q(H.field.table)!==(b$1(a,j)?a._.alias:b$1(a,re)?a[m].name:b$1(a,v)?void 0:q(a))&&!(G=>l?.some(({alias:ft})=>ft===(G[p.Symbol.IsAlias]?q(G):G[p.Symbol.BaseName])))(H.field.table)){let G=q(H.field.table);throw new Error(`Your "${H.path.join("->")}" field references a column "${G}"."${H.field.name}", but the table "${G}" is not part of the query! Did you forget to join it?`)}let $=!l||l.length===0,D=this.buildWithCTE(e),B=q$1?y` distinct`:void 0,z=this.buildSelection(A,{isSingleTable:$}),K=this.buildFromTable(a),C=this.buildJoins(l),ie=s?y` where ${s}`:void 0,U=n?y` having ${n}`:void 0,S=[];if(d$1)for(let[H,G]of d$1.entries())S.push(G),H<d$1.length-1&&S.push(y`, `);let T=S.length>0?y` group by ${y.join(S)}`:void 0,se=this.buildOrderBy(u),mt=this.buildLimit(h),Gt=x?y` offset ${x}`:void 0,Ae=y`${D}select${B} ${z} from ${K}${C}${ie}${T}${U}${se}${mt}${Gt}`;return _.length>0?this.buildSetOperations(Ae,_):Ae}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw new Error("Cannot pass undefined values to any set operator");return s.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:i,rightSelect:s,limit:n,orderBy:a,offset:l}}){let u=y`${e.getSQL()} `,d=y`${s.getSQL()}`,h;if(a&&a.length>0){let A=[];for(let $ of a)if(b$1($,Q))A.push(y.identifier($.name));else if(b$1($,v)){for(let D=0;D<$.queryChunks.length;D++){let B=$.queryChunks[D];b$1(B,Q)&&($.queryChunks[D]=y.identifier(this.casing.getColumnCasing(B)));}A.push(y`${$}`);}else A.push(y`${$}`);h=y` order by ${y.join(A,y`, `)}`;}let x=typeof n=="object"||typeof n=="number"&&n>=0?y` limit ${n}`:void 0,q=y.raw(`${t} ${i?"all ":""}`),_=l?y` offset ${l}`:void 0;return y`${u}${q}${d}${h}${x}${_}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:n,select:a}){let l=[],u=e[p.Symbol.Columns],d=Object.entries(u).filter(([$,D])=>!D.shouldDisableInsert()),h=d.map(([,$])=>y.identifier(this.casing.getColumnCasing($)));if(a){let $=t;b$1($,v)?l.push($):l.push($.getSQL());}else {let $=t;l.push(y.raw("values "));for(let[D,B]of $.entries()){let z=[];for(let[K,C]of d){let ie=B[K];if(ie===void 0||b$1(ie,x)&&ie.value===void 0){let U;if(C.default!==null&&C.default!==void 0)U=b$1(C.default,v)?C.default:y.param(C.default,C);else if(C.defaultFn!==void 0){let S=C.defaultFn();U=b$1(S,v)?S:y.param(S,C);}else if(!C.default&&C.onUpdateFn!==void 0){let S=C.onUpdateFn();U=b$1(S,v)?S:y.param(S,C);}else U=y`null`;z.push(U);}else z.push(ie);}l.push(z),D<$.length-1&&l.push(y`, `);}}let x$1=this.buildWithCTE(n),q=y.join(l),_=s?y` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,A=i?.length?y.join(i):void 0;return y`${x$1}insert into ${e} ${h} ${q}${A}${_}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:s,tableConfig:n,queryConfig:a,tableAlias:l,nestedQueryRelation:u,joinOn:d$1}){let h=[],x,q,_=[],A,$=[];if(a===true)h=Object.entries(n.columns).map(([z,K])=>({dbKey:K.name,tsKey:z,field:ee(K,l),relationTableTsKey:void 0,isJson:false,selection:[]}));else {let B=Object.fromEntries(Object.entries(n.columns).map(([S,T])=>[S,ee(T,l)]));if(a.where){let S=typeof a.where=="function"?a.where(B,ws()):a.where;A=S&&Je(S,l);}let z=[],K=[];if(a.columns){let S=false;for(let[T,se]of Object.entries(a.columns))se!==void 0&&T in n.columns&&(!S&&se===true&&(S=true),K.push(T));K.length>0&&(K=S?K.filter(T=>a.columns?.[T]===true):Object.keys(n.columns).filter(T=>!K.includes(T)));}else K=Object.keys(n.columns);for(let S of K){let T=n.columns[S];z.push({tsKey:S,value:T});}let C=[];a.with&&(C=Object.entries(a.with).filter(S=>!!S[1]).map(([S,T])=>({tsKey:S,queryConfig:T,relation:n.relations[S]})));let ie;if(a.extras){ie=typeof a.extras=="function"?a.extras(B,{sql:y}):a.extras;for(let[S,T]of Object.entries(ie))z.push({tsKey:S,value:Zt(T,l)});}for(let{tsKey:S,value:T}of z)h.push({dbKey:b$1(T,v.Aliased)?T.fieldAlias:n.columns[S].name,tsKey:S,field:b$1(T,d)?ee(T,l):T,relationTableTsKey:void 0,isJson:false,selection:[]});let U=typeof a.orderBy=="function"?a.orderBy(B,Ss()):a.orderBy??[];Array.isArray(U)||(U=[U]),_=U.map(S=>b$1(S,d)?ee(S,l):Je(S,l)),x=a.limit,q=a.offset;for(let{tsKey:S,queryConfig:T,relation:se}of C){let mt=xs(t,i,se),Gt=r(se.referencedTable),Ae=i[Gt],H=`${l}_${S}`,G=et(...mt.fields.map((Sn,xn)=>Lt(ee(mt.references[xn],H),ee(Sn,l)))),ft=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[Ae],tableConfig:t[Ae],queryConfig:b$1(se,pe)?T===true?{limit:1}:{...T,limit:1}:T,tableAlias:H,joinOn:G,nestedQueryRelation:se}),wn=y`(${ft.sql})`.as(S);h.push({dbKey:S,tsKey:S,field:wn,relationTableTsKey:Ae,isJson:true,selection:ft.selection});}}if(h.length===0)throw new Le({message:`No fields selected for table "${n.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let D;if(A=et(d$1,A),u){let B=y`json_array(${y.join(h.map(({field:C})=>b$1(C,Q)?y.identifier(this.casing.getColumnCasing(C)):b$1(C,v.Aliased)?C.sql:C),y`, `)})`;b$1(u,tt)&&(B=y`coalesce(json_group_array(${B}), json_array())`);let z=[{dbKey:"data",tsKey:"data",field:B.as("data"),isJson:true,relationTableTsKey:n.tsName,selection:h}];x!==void 0||q!==void 0||_.length>0?(D=this.buildSelectQuery({table:We(s,l),fields:{},fieldsFlat:[{path:[],field:y.raw("*")}],where:A,limit:x,offset:q,orderBy:_,setOperators:[]}),A=void 0,x=void 0,q=void 0,_=void 0):D=We(s,l),D=this.buildSelectQuery({table:b$1(D,R)?D:new j(D,{},l),fields:{},fieldsFlat:z.map(({field:C})=>({path:[],field:b$1(C,d)?ee(C,l):C})),joins:$,where:A,limit:x,offset:q,orderBy:_,setOperators:[]});}else D=this.buildSelectQuery({table:We(s,l),fields:{},fieldsFlat:h.map(({field:B})=>({path:[],field:b$1(B,d)?ee(B,l):B})),joins:$,where:A,limit:x,offset:q,orderBy:_,setOperators:[]});return {tableTsKey:n.tsName,sql:D,selection:h}}},Bt=class extends Qe{static[a$1]="SQLiteSyncDialect";migrate(e,t,i){let s=i===void 0||typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",n=y`
|
|
3
|
-
CREATE TABLE IF NOT EXISTS ${y.identifier(s)} (
|
|
4
|
-
id SERIAL PRIMARY KEY,
|
|
5
|
-
hash text NOT NULL,
|
|
6
|
-
created_at numeric
|
|
7
|
-
)
|
|
8
|
-
`;t.run(n);let l=t.values(y`SELECT id, hash, created_at FROM ${y.identifier(s)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(y`BEGIN`);try{for(let u of e)if(!l||Number(l[2])<u.folderMillis){for(let d of u.sql)t.run(y.raw(d));t.run(y`INSERT INTO ${y.identifier(s)} ("hash", "created_at") VALUES(${u.hash}, ${u.folderMillis})`);}t.run(y`COMMIT`);}catch(u){throw t.run(y`ROLLBACK`),u}}},Oe=class extends Qe{static[a$1]="SQLiteAsyncDialect";async migrate(e,t,i){let s=i===void 0||typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",n=y`
|
|
9
|
-
CREATE TABLE IF NOT EXISTS ${y.identifier(s)} (
|
|
10
|
-
id SERIAL PRIMARY KEY,
|
|
11
|
-
hash text NOT NULL,
|
|
12
|
-
created_at numeric
|
|
13
|
-
)
|
|
14
|
-
`;await t.run(n);let l=(await t.values(y`SELECT id, hash, created_at FROM ${y.identifier(s)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async u=>{for(let d of e)if(!l||Number(l[2])<d.folderMillis){for(let h of d.sql)await u.run(y.raw(h));await u.run(y`INSERT INTO ${y.identifier(s)} ("hash", "created_at") VALUES(${d.hash}, ${d.folderMillis})`);}});}};});var Rt,Ts=a(()=>{c();Rt=class{static[a$1]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}};});function Ft(r,e){return (t,i,...s)=>{let n=[i,...s].map(a=>({type:r,isAll:e,rightSelect:a}));for(let a of n)if(!He(t.getSelectedFields(),a.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return t.addSetOperators(n)}}var J,Hr,Ot,Bn,Rn,On,Fn,jn,Yr=a(()=>{c();Ts();le();ve();C();l();s();P();n();Be();rt();J=class{static[a$1]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct;}from(e){let t=!!this.fields,i;return this.fields?i=this.fields:b$1(e,j)?i=Object.fromEntries(Object.keys(e._.selectedFields).map(s=>[s,e[s]])):b$1(e,re)?i=e[m].selectedFields:b$1(e,v)?i={}:i=wt(e),new Ot({table:e,fields:i,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}},Hr=class extends Rt{static[a$1]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:n,withList:a,distinct:l}){super(),this.config={withList:a,table:e,fields:{...t},distinct:l,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=Ye(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:true}:{};for(let u of Y(e))this.usedTables.add(u);}getUsedTables(){return [...this.usedTables]}createJoin(e){return (t,i)=>{let s=this.tableName,n=Ye(t);for(let a of Y(t))this.usedTables.add(a);if(typeof n=="string"&&this.config.joins?.some(a=>a.alias===n))throw new Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof n=="string"&&!b$1(t,v))){let a=b$1(t,j)?t._.selectedFields:b$1(t,B)?t[m].selectedFields:t[p.Symbol.Columns];this.config.fields[n]=a;}if(typeof i=="function"&&(i=i(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,joinType:e,alias:n}),typeof n=="string")switch(e){case "left":{this.joinsNotNullableMap[n]=false;break}case "right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([a])=>[a,false])),this.joinsNotNullableMap[n]=true;break}case "cross":case "inner":{this.joinsNotNullableMap[n]=true;break}case "full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([a])=>[a,false])),this.joinsNotNullableMap[n]=false;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let s=typeof i=="function"?i(Bn()):i;if(!He(this.getSelectedFields(),s.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",false);unionAll=this.createSetOperator("union",true);intersect=this.createSetOperator("intersect",false);except=this.createSetOperator("except",false);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t];}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i;}else {let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t;}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...Y(this.config.table)),this.config.joins)for(let i of this.config.joins)t.push(...Y(i.table));return new Proxy(new j(this.getSQL(),this.config.fields,e,false,[...new Set(t)]),new L({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new L({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}},Ot=class extends Hr{static[a$1]="SQLiteSelect";_prepare(e=true){if(!this.session)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=W(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",true,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:true,autoInvalidate:true}:e===false?{enable:false}:{enable:true,autoInvalidate:true,...e},this}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}};Di(Ot,[I]);Bn=()=>({union:Rn,unionAll:On,intersect:Fn,except:jn}),Rn=Ft("union",false),On=Ft("union",true),Fn=Ft("intersect",false),jn=Ft("except",false);});var he,jt=a(()=>{c();ve();it();l();Yr();he=class{static[a$1]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=b$1(e,Qe)?e:void 0,this.dialectConfig=b$1(e,Qe)?void 0:e;}$with=(e,t)=>{let i=this;return {as:n=>(typeof n=="function"&&(n=n(i)),new Proxy(new k(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,true),new L({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;function i(n){return new J({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function s(n){return new J({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:true})}return {select:i,selectDistinct:s}}select(e){return new J({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new J({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:true})}getDialect(){return this.dialect||(this.dialect=new Bt(this.dialectConfig)),this.dialect}};});var st,Mt,qs=a(()=>{c();le();C();ce();s();P();Be();jt();st=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[a$1]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw new Error("values() must be called with at least one value");let t=e.map(i=>{let s={},n=this.table[p.Symbol.Columns];for(let a of Object.keys(i)){let l=i[a];s[a]=b$1(l,v)?l:new x(l,n[a]);}return s});return new Mt(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e=="function"?e(new he):e;if(!b$1(t,v)&&!He(this.table[o],t._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Mt(this.table,t,this.session,this.dialect,this.withList,true)}},Mt=class extends I{constructor(e,t,i,s,n,a){super(),this.session=i,this.dialect=s,this.config={table:e,values:t,withList:n,select:a};}static[a$1]="SQLiteInsert";config;returning(e=this.config.table[R.Symbol.Columns]){return this.config.returning=W(e),this}onConflictDoNothing(e={}){if(this.config.onConflict||(this.config.onConflict=[]),e.target===void 0)this.config.onConflict.push(y` on conflict do nothing`);else {let t=Array.isArray(e.target)?y`${e.target}`:y`${[e.target]}`,i=e.where?y` where ${e.where}`:y``;this.config.onConflict.push(y` on conflict ${t} do nothing${i}`);}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');this.config.onConflict||(this.config.onConflict=[]);let t=e.where?y` where ${e.where}`:void 0,i=e.targetWhere?y` where ${e.targetWhere}`:void 0,s=e.setWhere?y` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?y`${e.target}`:y`${[e.target]}`,a=this.dialect.buildUpdateSet(this.config.table,bt(this.config.table,e.set));return this.config.onConflict.push(y` on conflict ${n}${i} do update set ${a}${t}${s}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"insert",tables:Y(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};});var vs=a(()=>{});var nt,Gr,Ls=a(()=>{c();le();ve();ce();l();s();P();n();Be();rt();nt=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[a$1]="SQLiteUpdateBuilder";set(e){return new Gr(this.table,bt(this.table,e),this.session,this.dialect,this.withList)}},Gr=class extends I{constructor(e,t,i,s,n){super(),this.session=i,this.dialect=s,this.config={set:t,table:e,withList:n,joins:[]};}static[a$1]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return (t,i)=>{let s=Ye(t);if(typeof s=="string"&&this.config.joins.some(n=>n.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof i=="function"){let n=this.config.from?b$1(t,R)?t[p.Symbol.Columns]:b$1(t,j)?t._.selectedFields:b$1(t,re)?t[m].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[p.Symbol.Columns],new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));}return this.config.joins.push({on:i,table:t,joinType:e,alias:s}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){let t=e[0](new Proxy(this.config.table[p.Symbol.Columns],new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i;}else {let t=e;this.config.orderBy=t;}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[R.Symbol.Columns]){return this.config.returning=W(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=true){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",true,void 0,{type:"insert",tables:Y(this.config.table)})}prepare(){return this._prepare(false)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};});var Zr=a(()=>{Vi();qs();jt();Yr();vs();Ls();});var Et,Qs=a(()=>{c();C();Et=class r extends v{constructor(e){super(r.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=r.buildCount(e.source,e.filters);}sql;static[a$1]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return y`(select count(*) from ${e}${y.raw(" where ").if(t)}${t})`}static buildCount(e,t){return y`select count(*) from ${e}${y.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}};});var Pt,ot,It,_s=a(()=>{c();le();Re();Pt=class{constructor(e,t,i,s,n,a,l,u){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=s,this.table=n,this.tableConfig=a,this.dialect=l,this.session=u;}static[a$1]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new It(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new ot(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return this.mode==="sync"?new It(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new ot(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}},ot=class extends I{constructor(e,t,i,s,n,a,l,u,d){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=s,this.tableConfig=n,this.dialect=a,this.session=l,this.config=u,this.mode=d;}static[a$1]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=false){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,this.mode==="first"?"get":"all",true,(s,n)=>{let a=s.map(l=>_t(this.schema,this.tableConfig,l,t.selection,n));return this.mode==="first"?a[0]:a})}prepare(){return this._prepare(false)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return {query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return this.mode==="first"?this._prepare(false).get():this._prepare(false).all()}async execute(){return this.executeRaw()}},It=class extends ot{static[a$1]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}};});var _e,As=a(()=>{c();le();_e=class extends I{constructor(e,t,i,s,n){super(),this.execute=e,this.getSQL=t,this.dialect=s,this.mapBatchResult=n,this.config={action:i};}static[a$1]="SQLiteRaw";config;getQuery(){return {...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return false}};});var ye,at=a(()=>{c();ve();C();Zr();l();Qs();_s();As();ye=class{constructor(e,t,i,s){this.resultKind=e,this.dialect=t,this.session=i,this._=s?{schema:s.schema,fullSchema:s.fullSchema,tableNamesMap:s.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[a,l]of Object.entries(this._.schema))n[a]=new Pt(e,s.fullSchema,this._.schema,this._.tableNamesMap,s.fullSchema[a],l,t,i);this.$cache={invalidate:async a=>{}};}static[a$1]="BaseSQLiteDatabase";query;$with=(e,t)=>{let i=this;return {as:n=>(typeof n=="function"&&(n=n(new he(i.dialect))),new Proxy(new k(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,true),new L({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new Et({source:e,filters:t,session:this.session})}with(...e){let t=this;function i(u){return new J({fields:u??void 0,session:t.session,dialect:t.dialect,withList:e})}function s(u){return new J({fields:u??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:true})}function n(u){return new nt(u,t.session,t.dialect,e)}function a(u){return new st(u,t.session,t.dialect,e)}function l(u){return new Xe(u,t.session,t.dialect,e)}return {select:i,selectDistinct:s,update:n,insert:a,delete:l}}select(e){return new J({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new J({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:true})}update(e){return new nt(e,this.session,this.dialect)}$cache;insert(e){return new st(e,this.session,this.dialect)}delete(e){return new Xe(e,this.session,this.dialect)}run(e){let t=typeof e=="string"?y.raw(e):e.getSQL();return this.resultKind==="async"?new _e(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t=typeof e=="string"?y.raw(e):e.getSQL();return this.resultKind==="async"?new _e(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t=typeof e=="string"?y.raw(e):e.getSQL();return this.resultKind==="async"?new _e(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t=typeof e=="string"?y.raw(e):e.getSQL();return this.resultKind==="async"?new _e(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}};});async function ei(r,e){let t=`${r}-${JSON.stringify(e)}`,s=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",s);return [...new Uint8Array(n)].map(u=>u.toString(16).padStart(2,"0")).join("")}var Xr,ge,ti=a(()=>{c();Xr=class{static[a$1]="Cache"},ge=class extends Xr{strategy(){return "all"}static[a$1]="NoopCache";async get(e){}async put(e,t,i,s){}async onMutate(e){}};});var ri,Fe,je,Me,Kt=a(()=>{ti();c();Tt();le();at();ri=class extends I{constructor(e){super(),this.resultCb=e;}static[a$1]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}},Fe=class{constructor(e,t,i,s,n,a){this.mode=e,this.executeMethod=t,this.query=i,this.cache=s,this.queryMetadata=n,this.cacheConfig=a,s&&s.strategy()==="all"&&a===void 0&&(this.cacheConfig={enable:true,autoInvalidate:true}),this.cacheConfig?.enable||(this.cacheConfig=void 0);}static[a$1]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,i){if(this.cache===void 0||b$1(this.cache,ge)||this.queryMetadata===void 0)try{return await i()}catch(s){throw new ue(e,t,s)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await i()}catch(s){throw new ue(e,t,s)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[s]=await Promise.all([i(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return s}catch(s){throw new ue(e,t,s)}if(!this.cacheConfig)try{return await i()}catch(s){throw new ue(e,t,s)}if(this.queryMetadata.type==="select"){let s=await this.cache.get(this.cacheConfig.tag??await ei(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(s===void 0){let n;try{n=await i();}catch(a){throw new ue(e,t,a)}return await this.cache.put(this.cacheConfig.tag??await ei(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return s}try{return await i()}catch(s){throw new ue(e,t,s)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw new Error("Not implemented")}mapGetResult(e,t){throw new Error("Not implemented")}execute(e){return this.mode==="async"?this[this.executeMethod](e):new ri(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case "run":return this.mapRunResult(e,t);case "all":return this.mapAllResult(e,t);case "get":return this.mapGetResult(e,t)}}},je=class{constructor(e){this.dialect=e;}static[a$1]="SQLiteSession";prepareOneTimeQuery(e,t,i,s,n,a,l){return this.prepareQuery(e,t,i,s,n,a,l)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(i){throw new Le({cause:i,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).all()}extractRawAllValueFromBatchResult(e){throw new Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).get()}extractRawGetValueFromBatchResult(e){throw new Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",false).values()}async count(e){return (await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw new Error("Not implemented")}},Me=class extends ye{constructor(e,t,i,s,n=0){super(e,t,i,s),this.schema=s,this.nestedIndex=n;}static[a$1]="SQLiteTransaction";rollback(){throw new Ct}};});var Ds=a(()=>{});var Os=a(()=>{c();ve();P();jt();ce();rt();});var E=a(()=>{Qi();Ai();Pr();at();it();rr();Ki();ki();Zr();Kt();Ds();ce();ar();Be();Os();});var ii,Ee,Pe,Ie=a(()=>{c();ii=class{static[a$1]="ConsoleLogWriter";write(e){console.log(e);}},Ee=class{static[a$1]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new ii;}logQuery(e,t){let i=t.map(n=>{try{return JSON.stringify(n)}catch{return String(n)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`);}},Pe=class{static[a$1]="NoopLogger";logQuery(){}};});var Fs=a(()=>{});var be=a(()=>{gt();g$1();e();c();Tt();Ie();Fs();le();Re();Jr();l();s();P();n();});var js,si,ni=a(()=>{E();be();js=["pending","in_progress","completed"],si=N("todos",{id:g("id").primaryKey({autoIncrement:true}),title:f("title").notNull(),description:f("description"),status:f("status",{enum:js}).notNull().default("pending"),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:g("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Mn,Ms=a(()=>{E();be();ni();Mn=N("todo_attachments",{id:g("id").primaryKey({autoIncrement:true}),todoId:g("todo_id").notNull().references(()=>si.id,{onDelete:"cascade"}),fileName:f("file_name").notNull(),originalName:f("original_name").notNull(),mimeType:f("mime_type").notNull(),size:g("size").notNull(),path:f("path").notNull(),uploadedBy:f("uploaded_by"),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var En,Es=a(()=>{E();be();En=N("notifications",{id:f("id").primaryKey(),type:f("type").notNull(),title:f("title").notNull(),message:f("message").notNull(),read:g("read",{mode:"boolean"}).notNull().default(false),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var ct,Vt=a(()=>{E();ct=N("permissions",{id:f("id").primaryKey(),code:f("code").notNull().unique(),name:f("name").notNull(),label:f("label").notNull(),category:f("category").notNull(),description:f("description"),sortOrder:g("sort_order").default(0),isActive:g("is_active",{mode:"boolean"}).default(true),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:g("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var ut,zt=a(()=>{E();ut=N("roles",{id:f("id").primaryKey(),code:f("code").notNull().unique(),name:f("name").notNull(),label:f("label").notNull(),description:f("description"),isSystem:g("is_system",{mode:"boolean"}).default(false),isActive:g("is_active",{mode:"boolean"}).default(true),sortOrder:g("sort_order").default(0),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:g("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var Pn,Ps=a(()=>{E();zt();Vt();Pn=N("role_permissions",{roleId:f("role_id").notNull().references(()=>ut.id,{onDelete:"cascade"}),permissionId:f("permission_id").notNull().references(()=>ct.id,{onDelete:"cascade"}),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pk:$t({columns:[r.roleId,r.permissionId]})}));});var In,Is=a(()=>{E();zt();In=N("user_roles",{id:f("id").primaryKey(),userId:f("user_id").notNull(),roleId:f("role_id").notNull().references(()=>ut.id,{onDelete:"cascade"}),assignedBy:f("assigned_by"),assignedAt:g("assigned_at",{mode:"timestamp"}).$defaultFn(()=>new Date),expiresAt:g("expires_at",{mode:"timestamp"}),isActive:g("is_active",{mode:"boolean"}).default(true)});});var oi,ai=a(()=>{E();oi=N("routes",{id:f("id").primaryKey(),path:f("path").notNull(),method:f("method").notNull(),name:f("name"),description:f("description"),module:f("module"),isPublic:g("is_public",{mode:"boolean"}).default(false),isActive:g("is_active",{mode:"boolean"}).default(true),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:g("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pathMethodUnique:Ri().on(r.path,r.method)}));});var Kn,Ks=a(()=>{E();Vt();ai();Kn=N("permission_routes",{permissionId:f("permission_id").notNull().references(()=>ct.id,{onDelete:"cascade"}),routeId:f("route_id").notNull().references(()=>oi.id,{onDelete:"cascade"}),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pk:$t({columns:[r.permissionId,r.routeId]})}));});var kn,ks=a(()=>{E();kn=N("permission_audit_logs",{id:f("id").primaryKey(),userId:f("user_id").notNull(),action:f("action").notNull(),resourceType:f("resource_type").notNull(),resourceId:f("resource_id"),oldValue:f("old_value"),newValue:f("new_value"),ipAddress:f("ip_address"),userAgent:f("user_agent"),createdAt:g("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var Vs,Vn,zs=a(()=>{E();be();Vs=["pending","processing","completed","cancelled","disputed"],Vn=N("orders",{id:g("id").primaryKey({autoIncrement:true}),orderNo:f("order_no").notNull(),customerName:f("customer_name").notNull(),customerEmail:f("customer_email").notNull(),productName:f("product_name").notNull(),amount:g("amount").notNull(),status:f("status",{enum:Vs}).notNull().default("pending"),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:g("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Us,Ws,Js,zn,Hs,Un,Ys=a(()=>{E();be();Us=["open","in_progress","waiting_customer","resolved","closed"],Ws=["low","medium","high","urgent"],Js=["technical","billing","feature_request","bug_report","general"],zn=["customer","admin","system"],Hs=N("tickets",{id:g("id").primaryKey({autoIncrement:true}),ticketNo:f("ticket_no").notNull(),customerName:f("customer_name").notNull(),customerEmail:f("customer_email").notNull(),subject:f("subject").notNull(),description:f("description").notNull(),status:f("status",{enum:Us}).notNull().default("open"),priority:f("priority",{enum:Ws}).notNull().default("medium"),category:f("category",{enum:Js}).notNull(),assignedTo:f("assigned_to"),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:g("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)}),Un=N("ticket_replies",{id:g("id").primaryKey({autoIncrement:true}),ticketId:g("ticket_id").notNull().references(()=>Hs.id,{onDelete:"cascade"}),content:f("content").notNull(),author:f("author").notNull(),isCustomer:g("is_customer",{mode:"boolean"}).notNull().default(false),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Gs,Zs,Wn,Xs=a(()=>{E();be();Gs=["refund","product_quality","service_quality","delivery","other"],Zs=["pending","investigating","resolved","rejected"],Wn=N("disputes",{id:g("id").primaryKey({autoIncrement:true}),disputeNo:f("dispute_no").notNull(),orderId:f("order_id").notNull(),orderNo:f("order_no").notNull(),customerName:f("customer_name").notNull(),customerEmail:f("customer_email").notNull(),type:f("type",{enum:Gs}).notNull(),status:f("status",{enum:Zs}).notNull().default("pending"),description:f("description").notNull(),resolution:f("resolution"),amount:g("amount").notNull(),resolvedAt:g("resolved_at",{mode:"timestamp"}),resolvedBy:f("resolved_by"),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:g("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var en,tn,Jn,rn=a(()=>{E();be();en=["draft","published","archived"],tn=["article","announcement","tutorial","news","policy"],Jn=N("contents",{id:g("id").primaryKey({autoIncrement:true}),title:f("title").notNull(),body:f("body").notNull(),excerpt:f("excerpt"),category:f("category",{enum:tn}).notNull(),tags:f("tags"),status:f("status",{enum:en}).notNull().default("draft"),author:f("author").notNull(),viewCount:g("view_count").notNull().default(0),likeCount:g("like_count").notNull().default(0),publishedAt:g("published_at",{mode:"timestamp"}),createdAt:g("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:g("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Ut={};b(Ut,{contentCategories:()=>tn,contentStatuses:()=>en,contents:()=>Jn,disputeStatuses:()=>Zs,disputeTypes:()=>Gs,disputes:()=>Wn,notifications:()=>En,orderStatuses:()=>Vs,orders:()=>Vn,permissionAuditLogs:()=>kn,permissionRouteMappings:()=>Kn,permissions:()=>ct,rolePermissions:()=>Pn,roles:()=>ut,routes:()=>oi,ticketCategories:()=>Js,ticketPriorities:()=>Ws,ticketReplies:()=>Un,ticketReplyAuthorRoles:()=>zn,ticketStatuses:()=>Us,tickets:()=>Hs,todoAttachments:()=>Mn,todoStatus:()=>js,todos:()=>si,userRoles:()=>In});var li=a(()=>{ni();Ms();Es();Vt();zt();Ps();Is();ai();Ks();ks();zs();Ys();Xs();rn();});var ci=a(()=>{ti();});function sn(r){return Object.keys(r).reduce((e,t)=>(Object.prototype.propertyIsEnumerable.call(r,t)&&(e[t]=r[t]),e),{})}function Wt(r){if(typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer){if(typeof Buffer<"u")return r instanceof Buffer?r:Buffer.from(r);if(typeof TextDecoder<"u")return new TextDecoder().decode(r);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return r}var Jt,ui,mi,fi=a(()=>{ci();c();Ie();C();E();Kt();P();Jt=class r extends je{constructor(e,t,i,s,n){super(t),this.client=e,this.schema=i,this.options=s,this.tx=n,this.logger=s.logger??new Pe,this.cache=s.cache??new ge;}static[a$1]="LibSQLSession";logger;cache;prepareQuery(e,t,i,s,n,a,l){return new mi(this.client,e,this.logger,this.cache,a,l,t,this.tx,i,s,n)}async batch(e){let t=[],i=[];for(let n of e){let a=n._prepare(),l=a.getQuery();t.push(a),i.push({sql:l.sql,args:l.params});}return (await this.client.batch(i)).map((n,a)=>t[a].mapResult(n,true))}async migrate(e){let t=[],i=[];for(let n of e){let a=n._prepare(),l=a.getQuery();t.push(a),i.push({sql:l.sql,args:l.params});}return (await this.client.migrate(i)).map((n,a)=>t[a].mapResult(n,true))}async transaction(e,t){let i=await this.client.transaction(),s=new r(this.client,this.dialect,this.schema,this.options,i),n=new ui("async",this.dialect,s,this.schema);try{let a=await e(n);return await i.commit(),a}catch(a){throw await i.rollback(),a}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}},ui=class r extends Me{static[a$1]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,i=new r("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(y.raw(`savepoint ${t}`));try{let s=await e(i);return await this.session.run(y.raw(`release savepoint ${t}`)),s}catch(s){throw await this.session.run(y.raw(`rollback to savepoint ${t}`)),s}}},mi=class extends Fe{constructor(e,t,i,s,n,a,l,u,d,h,x){super("async",d,t,s,n,a),this.client=e,this.logger=i,this.fields=l,this.tx=u,this._isResponseInArrayMode=h,this.customResultMapper=x,this.customResultMapper=x,this.fields=l;}static[a$1]="LibSQLPreparedQuery";async run(e){let t=A(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let i={sql:this.query.sql,args:t};return this.tx?this.tx.execute(i):this.client.execute(i)})}async all(e){let{fields:t,logger:i,query:s,tx:n,client:a,customResultMapper:l}=this;if(!t&&!l){let d=A(s.params,e??{});return i.logQuery(s.sql,d),await this.queryWithCache(s.sql,d,async()=>{let h={sql:s.sql,args:d};return (n?n.execute(h):a.execute(h)).then(({rows:x})=>this.mapAllResult(x))})}let u=await this.values(e);return this.mapAllResult(u)}mapAllResult(e,t){return t&&(e=e.rows),!this.fields&&!this.customResultMapper?e.map(i=>sn(i)):this.customResultMapper?this.customResultMapper(e,Wt):e.map(i=>qe(this.fields,Array.prototype.slice.call(i).map(s=>Wt(s)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:i,query:s,tx:n,client:a,customResultMapper:l}=this;if(!t&&!l){let d=A(s.params,e??{});return i.logQuery(s.sql,d),await this.queryWithCache(s.sql,d,async()=>{let h={sql:s.sql,args:d};return (n?n.execute(h):a.execute(h)).then(({rows:x})=>this.mapGetResult(x))})}let u=await this.values(e);return this.mapGetResult(u)}mapGetResult(e,t){t&&(e=e.rows);let i=e[0];if(!this.fields&&!this.customResultMapper)return sn(i);if(i)return this.customResultMapper?this.customResultMapper(e,Wt):qe(this.fields,Array.prototype.slice.call(i).map(s=>Wt(s)),this.joinsNotNullableMap)}async values(e){let t=A(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let i={sql:this.query.sql,args:t};return (this.tx?this.tx.execute(i):this.client.execute(i)).then(({rows:s})=>s)})}isResponseInArrayMode(){return this._isResponseInArrayMode}};});function Ke(r,e={}){let t=new Oe({casing:e.casing}),i;e.logger===true?i=new Ee:e.logger!==false&&(i=e.logger);let s;if(e.schema){let l=At(e.schema,Dt);s={fullSchema:e.schema,schema:l.tables,tableNamesMap:l.tableNamesMap};}let n=new Jt(r,t,s,{logger:i,cache:e.cache},void 0),a=new di("async",t,n,s);return a.$client=r,a.$cache=e.cache,a.$cache&&(a.$cache.invalidate=e.cache?.onMutate),a}var di,nn=a(()=>{c();Ie();Re();at();it();fi();di=class extends ye{static[a$1]="LibSQLDatabase";async batch(e){return this.session.batch(e)}};});function Ht(...r){if(typeof r[0]=="string"){let e=createClient({url:r[0]});return Ke(e,r[1])}if(Bi(r[0])){let{connection:e,client:t,...i}=r[0];if(t)return Ke(t,i);let s=typeof e=="string"?createClient({url:e}):createClient(e);return Ke(s,i)}return Ke(r[0],r[1])}var on=a(()=>{P();nn();(r=>{function e(t){return Ke({},t)}r.mock=e;})(Ht||(Ht={}));});var an=a(()=>{on();fi();});function yi(r){let e=[];for(let t of r){let i=Object.keys(t).map(s=>t[s]);e.push(i);}return e}var Yt,hi,gi,bi=a(()=>{ci();c();Ie();C();E();Kt();P();Yt=class extends je{constructor(e,t,i,s={}){super(t),this.client=e,this.schema=i,this.options=s,this.logger=s.logger??new Pe,this.cache=s.cache??new ge;}static[a$1]="SQLiteD1Session";logger;cache;prepareQuery(e,t,i,s,n,a,l){let u=this.client.prepare(e.sql);return new gi(u,e,this.logger,this.cache,a,l,t,i,s,n)}async batch(e){let t=[],i=[];for(let n of e){let a=n._prepare(),l=a.getQuery();if(t.push(a),l.params.length>0)i.push(a.stmt.bind(...l.params));else {let u=a.getQuery();i.push(this.client.prepare(u.sql).bind(...u.params));}}return (await this.client.batch(i)).map((n,a)=>t[a].mapResult(n,true))}extractRawAllValueFromBatchResult(e){return e.results}extractRawGetValueFromBatchResult(e){return e.results[0]}extractRawValuesValueFromBatchResult(e){return yi(e.results)}async transaction(e,t){let i=new hi("async",this.dialect,this,this.schema);await this.run(y.raw(`begin${t?.behavior?" "+t.behavior:""}`));try{let s=await e(i);return await this.run(y`commit`),s}catch(s){throw await this.run(y`rollback`),s}}},hi=class r extends Me{static[a$1]="D1Transaction";async transaction(e){let t=`sp${this.nestedIndex}`,i=new r("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(y.raw(`savepoint ${t}`));try{let s=await e(i);return await this.session.run(y.raw(`release savepoint ${t}`)),s}catch(s){throw await this.session.run(y.raw(`rollback to savepoint ${t}`)),s}}};gi=class extends Fe{constructor(e,t,i,s,n,a,l,u,d,h){super("async",u,t,s,n,a),this.logger=i,this._isResponseInArrayMode=d,this.customResultMapper=h,this.fields=l,this.stmt=e;}static[a$1]="D1PreparedQuery";customResultMapper;fields;stmt;async run(e){let t=A(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>this.stmt.bind(...t).run())}async all(e){let{fields:t,query:i,logger:s,stmt:n,customResultMapper:a}=this;if(!t&&!a){let u=A(i.params,e??{});return s.logQuery(i.sql,u),await this.queryWithCache(i.sql,u,async()=>n.bind(...u).all().then(({results:d})=>this.mapAllResult(d)))}let l=await this.values(e);return this.mapAllResult(l)}mapAllResult(e,t){return t&&(e=yi(e.results)),!this.fields&&!this.customResultMapper?e:this.customResultMapper?this.customResultMapper(e):e.map(i=>qe(this.fields,i,this.joinsNotNullableMap))}async get(e){let{fields:t,joinsNotNullableMap:i,query:s,logger:n,stmt:a,customResultMapper:l}=this;if(!t&&!l){let d=A(s.params,e??{});return n.logQuery(s.sql,d),await this.queryWithCache(s.sql,d,async()=>a.bind(...d).all().then(({results:h})=>h[0]))}let u=await this.values(e);if(u[0])return l?l(u):qe(t,u[0],i)}mapGetResult(e,t){return t&&(e=yi(e.results)[0]),!this.fields&&!this.customResultMapper?e:this.customResultMapper?this.customResultMapper([e]):qe(this.fields,e,this.joinsNotNullableMap)}async values(e){let t=A(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>this.stmt.bind(...t).raw())}isResponseInArrayMode(){return this._isResponseInArrayMode}};});function ln(r,e={}){let t=new Oe({casing:e.casing}),i;e.logger===true?i=new Ee:e.logger!==false&&(i=e.logger);let s;if(e.schema){let l=At(e.schema,Dt);s={fullSchema:e.schema,schema:l.tables,tableNamesMap:l.tableNamesMap};}let n=new Yt(r,t,s,{logger:i,cache:e.cache}),a=new wi("async",t,n,s);return a.$client=r,a.$cache=e.cache,a.$cache&&(a.$cache.invalidate=e.cache?.onMutate),a}var wi,cn=a(()=>{c();Ie();Re();at();it();bi();wi=class extends ye{static[a$1]="D1Database";async batch(e){return this.session.batch(e)}};});var un=a(()=>{cn();bi();});function fn(r,e="info"){let t=["trace","debug","info","warn","error","fatal"],i=t.indexOf(e),s=(n,a,l)=>{if(t.indexOf(n)>=i){let h=`${`[${new Date().toISOString()}] ${n.toUpperCase()}: [${r}]`} ${l} ${JSON.stringify(a)}`;switch(n){case "error":case "fatal":console.error(h);break;case "warn":console.warn(h);break;}}};return {trace:(n,a)=>s("trace",n,a),debug:(n,a)=>s("debug",n,a),info:(n,a)=>s("info",n,a),warn:(n,a)=>s("warn",n,a),error:(n,a)=>s("error",n,a),fatal:(n,a)=>s("fatal",n,a),child:()=>fn(r,e)}}function Gn(r,e){ht();let i=e||("info");let a=resolve(process.cwd(),"logs");existsSync(a)||mkdirSync(a,{recursive:true});let l=resolve(a,`${r}.log`),u=[];return u.push({level:i,stream:ke.transport({target:"pino/file",options:{destination:l}})}),ke({level:i},ke.multistream(u)).child({module:r})}function Ve(r,e){if(ae)return fn(r,e||"info");if(Si.has(r))return Si.get(r);let t=Gn(r,e);return Si.set(r,t),t}var Si,dn,pn=a(()=>{yt();pt();Si=new Map;dn={app:()=>Ve("app"),db:()=>Ve("db"),api:()=>Ve("api"),ws:()=>Ve("ws"),bootstrap:()=>Ve("bootstrap"),module:r=>Ve(r)};});async function yn(){if(we)return we;let r=Ce();if(Se.debug({driver:r.driver},"Creating database connection"),r.driver==="d1")we=ro(r);else {let e=to(r);we=e.db,ze=e.client;}return Se.info({driver:r.driver},"Database connected"),we}function to(r){if(ae)throw new Error("SQLite is not supported in Cloudflare Workers. Use D1 instead.");let e=r.sqlitePath||"./data/app.db";if(e!==":memory:"){let s=dirname(e);existsSync(s)||(mkdirSync(s,{recursive:true}),Se.debug({dir:s},"Created database directory"));}let t=createClient({url:e===":memory:"?":memory:":`file:${e}`}),i=Ht(t,{schema:Ut});return Se.debug({path:e},"SQLite database created"),{db:i,client:t}}function ro(r){if(!r.d1Database)throw new Error("D1 database binding not found. Make sure D1 is configured in wrangler.toml");return ln(r.d1Database,{schema:Ut})}async function io(){let r=Ce();return r.driver==="sqlite"?(ze||await yn(),ze):r.driver==="d1"&&r.d1Database||null}async function so(){Ce().driver==="sqlite"&&ze&&(ze.close(),ze=null,we=null,Se.info({},"Database connection closed"));}async function no(){if(ae){Se.info({},"Migrations skipped in Cloudflare Workers");return}if(Ce().driver==="sqlite"&&we){let e="./drizzle";if(existsSync(e)){let{migrate:t}=await import('./migrator-2ZYYKNI5.js');await t(we,{migrationsFolder:e}),Se.info({folder:e},"Migrations applied");}else Se.warn({folder:e},"No migrations folder found");}}var we,ze,Se,gn=a(()=>{yt();li();an();un();pn();pt();we=null,ze=null,Se=dn.db();});var bn=a(()=>{yt();});var oo=a(()=>{gn();bn();li();});export{Vn as A,Us as B,Ws as C,Js as D,zn as E,Hs as F,Un as G,Gs as H,Zs as I,Wn as J,en as K,tn as L,Jn as M,Ut as N,li as O,ln as P,un as Q,yn as R,io as S,so as T,no as U,oo as V,ae as a,pt as b,Ce as c,Ve as d,dn as e,pn as f,Lt as g,et as h,Gi as i,es as j,rs as k,ms as l,gs as m,be as n,js as o,si as p,Mn as q,En as r,ct as s,ut as t,Pn as u,In as v,oi as w,Kn as x,kn as y,Vs as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {V}from'./chunk-YY6FRMAQ.js';export{T as closeDb,L as contentCategories,K as contentStatuses,M as contents,I as disputeStatuses,H as disputeTypes,J as disputes,c as getDatabaseConfig,R as getDb,S as getRawClient,r as notifications,z as orderStatuses,A as orders,y as permissionAuditLogs,x as permissionRouteMappings,s as permissions,u as rolePermissions,t as roles,w as routes,U as runMigrations,D as ticketCategories,C as ticketPriorities,G as ticketReplies,E as ticketReplyAuthorRoles,B as ticketStatuses,F as tickets,q as todoAttachments,o as todoStatus,p as todos,v as userRoles}from'./chunk-YY6FRMAQ.js';import'./chunk-QBHAPWIA.js';import'./chunk-5J6HXUF6.js';V();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{C as PermissionService,D as permissionService}from'./chunk-BHPTQ4K2.js';import'./chunk-YY6FRMAQ.js';import'./chunk-QBHAPWIA.js';import'./chunk-5J6HXUF6.js';
|