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
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
<meta property="og:title" content="Biomimic App">
|
|
8
8
|
<meta property="og:description" content="A full-stack application template with React and Hono">
|
|
9
9
|
<meta property="og:type" content="website">
|
|
10
|
-
<script type="module" crossorigin="" src="/assets/main-
|
|
11
|
-
<link rel="modulepreload" crossorigin="" href="/assets/index-
|
|
12
|
-
<link rel="
|
|
13
|
-
|
|
10
|
+
<script type="module" crossorigin="" src="/assets/main-Cn4IDo2I.js"></script>
|
|
11
|
+
<link rel="modulepreload" crossorigin="" href="/assets/index-B3CRby6r.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin="" href="/assets/sse-client-DGQ072hl.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin="" href="/assets/index-09IqiOaE.css">
|
|
14
|
+
<link rel="modulepreload" as="script" crossorigin="" href="/assets/WebSocketPage-CGEg6QJE.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/LoadingSpinner-BcHjaM1m.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/EmptyState-DEyOQjbY.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/wifi-CwYSE0J4.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/trash-2-BP7fkd5b.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/message-square-BRaZfgbJ.js"><link rel="modulepreload" as="script" crossorigin="" href="/assets/activity-CgTz9Mrd.js"><meta name="description" content="Real-time WebSocket communication demo with type-safe RPC" data-rh="true"><meta property="og:title" content="WebSocket Demo - Biomimic App" data-rh="true"><meta property="og:description" content="Real-time WebSocket communication demo with type-safe RPC" data-rh="true"></head>
|
|
14
15
|
<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="max-w-3xl mx-auto p-6" data-testid="websocket-container"><div class="mb-8"><h1 class="text-3xl font-bold text-gray-900 flex items-center gap-2"><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-plug w-8 h-8 text-indigo-500" aria-hidden="true"><path d="M12 22v-5"></path><path d="M15 8V2"></path><path d="M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"></path><path d="M9 8V2"></path></svg>WebSocket Demo</h1><p class="text-gray-500 mt-2">Demonstrates WebSocket with type inference using useWSStore</p></div><div class="mb-6 p-4 bg-white rounded-xl shadow-sm border border-gray-200 flex flex-wrap items-center justify-between gap-4"><div class="flex items-center gap-2"><span class="font-medium text-gray-700">Status:</span><span class="flex items-center gap-1 text-red-500" data-testid="ws-status-closed"><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-wifi-off w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path><path d="M5 12.859a10 10 0 0 1 5.17-2.69"></path><path d="M19 12.859a10 10 0 0 0-2.007-1.523"></path><path d="M2 8.82a15 15 0 0 1 4.177-2.643"></path><path d="M22 8.82a15 15 0 0 0-11.288-3.764"></path><path d="m2 2 20 20"></path></svg>Closed</span></div><div class="flex items-center gap-2"><button class="flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-green-500 text-white hover:bg-green-600" data-testid="connect-ws-button"><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-wifi w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M2 8.82a15 15 0 0 1 20 0"></path><path d="M5 12.859a10 10 0 0 1 14 0"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path></svg>Connect</button><button disabled="" class="flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-gray-100 text-gray-400 cursor-not-allowed" data-testid="disconnect-ws-button"><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-wifi-off w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path><path d="M5 12.859a10 10 0 0 1 5.17-2.69"></path><path d="M19 12.859a10 10 0 0 0-2.007-1.523"></path><path d="M2 8.82a15 15 0 0 1 4.177-2.643"></path><path d="M22 8.82a15 15 0 0 0-11.288-3.764"></path><path d="m2 2 20 20"></path></svg>Disconnect</button></div></div><div class="mb-6 p-6 bg-white rounded-xl shadow-sm border border-gray-200"><div class="flex gap-4"><select class="px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 outline-none" data-testid="ws-message-type-select"><option value="echo">Echo (RPC)</option><option value="ping">Ping (RPC)</option><option value="broadcast">Broadcast (Event)</option><option value="notification">Notification (Event)</option></select><input type="text" placeholder="Type a message..." disabled="" class="flex-1 px-4 py-3 text-base border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent outline-none disabled:bg-gray-100 disabled:cursor-not-allowed" data-testid="ws-message-input" value=""><button disabled="" class="flex items-center gap-2 px-6 py-3 text-base font-medium rounded-lg transition-colors bg-gray-300 text-gray-500 cursor-not-allowed" data-testid="send-message-button"><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-send w-5 h-5" aria-hidden="true"><path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"></path><path d="m21.854 2.147-10.94 10.939"></path></svg>Send</button></div></div><div class="flex items-center justify-between mb-4"><h3 class="text-lg font-medium text-gray-900" data-testid="message-count">Messages (0)</h3><button class="flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors" data-testid="clear-messages-button"><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-trash2 lucide-trash-2 w-4 h-4" aria-hidden="true"><path d="M10 11v6"></path><path d="M14 11v6"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M3 6h18"></path><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>Clear</button></div><div class="border border-gray-200 rounded-xl bg-gray-50 h-[400px] overflow-y-auto p-4 space-y-3"><div class="flex flex-col items-center justify-center h-full text-gray-500 " data-testid="empty-state"><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-message-square w-16 h-16 mb-4 text-gray-300" aria-hidden="true"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"></path></svg><p class="text-center">No messages yet. Connect and send a message!</p></div></div></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
|
+
<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-todos-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">Todos</a><a data-testid="nav-sse-demo-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="/notifications" data-discover="true">SSE Demo</a><a data-testid="nav-websocket-button" aria-current="page" class="px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 shrink-0 whitespace-nowrap text-white" href="/websocket" data-discover="true" style="background-color: rgba(99, 102, 241, 0.082); color: rgb(99, 102, 241);">WebSocket</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="max-w-3xl mx-auto p-6" data-testid="websocket-container"><div class="mb-8"><h1 class="text-3xl font-bold text-gray-900 flex items-center gap-2"><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-plug w-8 h-8 text-indigo-500" aria-hidden="true"><path d="M12 22v-5"></path><path d="M15 8V2"></path><path d="M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"></path><path d="M9 8V2"></path></svg>WebSocket Demo</h1><p class="text-gray-500 mt-2">Demonstrates WebSocket with type inference using useWSStore</p></div><div class="mb-6 p-4 bg-white rounded-xl shadow-sm border border-gray-200 flex flex-wrap items-center justify-between gap-4"><div class="flex items-center gap-2"><span class="font-medium text-gray-700">Status:</span><span class="flex items-center gap-1 text-red-500" data-testid="ws-status-closed"><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-wifi-off w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path><path d="M5 12.859a10 10 0 0 1 5.17-2.69"></path><path d="M19 12.859a10 10 0 0 0-2.007-1.523"></path><path d="M2 8.82a15 15 0 0 1 4.177-2.643"></path><path d="M22 8.82a15 15 0 0 0-11.288-3.764"></path><path d="m2 2 20 20"></path></svg>Closed</span></div><div class="flex items-center gap-2"><button class="flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-green-500 text-white hover:bg-green-600" data-testid="connect-ws-button"><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-wifi w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M2 8.82a15 15 0 0 1 20 0"></path><path d="M5 12.859a10 10 0 0 1 14 0"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path></svg>Connect</button><button disabled="" class="flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-gray-100 text-gray-400 cursor-not-allowed" data-testid="disconnect-ws-button"><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-wifi-off w-4 h-4" aria-hidden="true"><path d="M12 20h.01"></path><path d="M8.5 16.429a5 5 0 0 1 7 0"></path><path d="M5 12.859a10 10 0 0 1 5.17-2.69"></path><path d="M19 12.859a10 10 0 0 0-2.007-1.523"></path><path d="M2 8.82a15 15 0 0 1 4.177-2.643"></path><path d="M22 8.82a15 15 0 0 0-11.288-3.764"></path><path d="m2 2 20 20"></path></svg>Disconnect</button></div></div><div class="mb-6 p-6 bg-white rounded-xl shadow-sm border border-gray-200"><div class="flex gap-4"><select class="px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 outline-none" data-testid="ws-message-type-select"><option value="echo">Echo (RPC)</option><option value="ping">Ping (RPC)</option><option value="broadcast">Broadcast (Event)</option><option value="notification">Notification (Event)</option></select><input type="text" placeholder="Type a message..." disabled="" class="flex-1 px-4 py-3 text-base border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent outline-none disabled:bg-gray-100 disabled:cursor-not-allowed" data-testid="ws-message-input" value=""><button disabled="" class="flex items-center gap-2 px-6 py-3 text-base font-medium rounded-lg transition-colors bg-gray-300 text-gray-500 cursor-not-allowed" data-testid="send-message-button"><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-send w-5 h-5" aria-hidden="true"><path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"></path><path d="m21.854 2.147-10.94 10.939"></path></svg>Send</button></div></div><div class="flex items-center justify-between mb-4"><h3 class="text-lg font-medium text-gray-900" data-testid="message-count">Messages (0)</h3><button class="flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-500 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors" data-testid="clear-messages-button"><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-trash2 lucide-trash-2 w-4 h-4" aria-hidden="true"><path d="M10 11v6"></path><path d="M14 11v6"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M3 6h18"></path><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>Clear</button></div><div class="border border-gray-200 rounded-xl bg-gray-50 h-[400px] overflow-y-auto p-4 space-y-3"><div class="flex flex-col items-center justify-center h-full text-gray-500 " data-testid="empty-state"><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-message-square w-16 h-16 mb-4 text-gray-300" aria-hidden="true"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"></path></svg><p class="text-center">No messages yet. Connect and send a message!</p></div></div></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-todos" 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" 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-layout-dashboard w-5 h-5 transition-transform" aria-hidden="true"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">Todos</span></a><a data-testid="bottom-tab-sse" 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="/notifications" 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-bell w-5 h-5 transition-transform" aria-hidden="true"><path d="M10.268 21a2 2 0 0 0 3.464 0"></path><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 ">SSE</span></a><a data-testid="bottom-tab-ws" aria-current="page" class="flex flex-col items-center justify-center gap-0.5 flex-1 py-1 rounded-xl transition-all duration-200 min-w-0 active" href="/websocket" 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-layout-dashboard w-5 h-5 transition-transform scale-110" aria-hidden="true"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></svg><span class="text-[10px] font-medium leading-tight truncate w-full text-center px-1 font-semibold">WS</span><div class="absolute top-0 w-8 h-0.5 rounded-full" style="background-color: rgb(99, 102, 241);"></div></a></div></nav></div></div>
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
</body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {x as x$1,c as c$1,C as C$1,B as B$1,f,q,v as v$1,t,ja,e,s,a as a$1,o,p,z as z$1,b,w as w$1,A,y as y$2,d as d$1,u,ia}from'./chunk-Q34AN3RF.js';import {c,C,a as a$2,y as y$1,A as A$1}from'./chunk-IXJL2LE4.js';import {a}from'./chunk-5J6HXUF6.js';import {config}from'dotenv';import {resolve,dirname}from'path';import {existsSync,mkdirSync}from'fs';import {createClient}from'@libsql/client';import q$1 from'pino';var d,z=a(()=>{d=typeof globalThis<"u"&&("WebSocketPair"in globalThis||globalThis.isCloudflare===true),!d&&typeof process<"u"&&process.versions?.node!==void 0;});function Ne(){if(d)return;let t={production:".env.production"}["production"];{let s=resolve(process.cwd(),t);existsSync(s)&&config({path:s});}}function k(){let i="production",e=typeof process<"u"?parseInt(process.env.PORT||"3010",10):3010,t=typeof process<"u"?process.env.ENABLE_DOCS!=="false":false,s=["sqlite","mysql","d1"],r=typeof process<"u"?process.env.DB_DRIVER||"sqlite":"d1",n=s.includes(r)?r:"sqlite";return {nodeEnv:i,port:e,enableDocs:t,database:{driver:d?"d1":n,sqlitePath:typeof process<"u"?process.env.SQLITE_PATH||`./data/${i}.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 w(){return k().database}var _=a(()=>{z();Ne();});var G=a(()=>{x$1();});function fe(i){return Object.keys(i).reduce((e,t)=>(Object.prototype.propertyIsEnumerable.call(i,t)&&(e[t]=i[t]),e),{})}function B(i){if(typeof ArrayBuffer<"u"&&i instanceof ArrayBuffer){if(typeof Buffer<"u")return i instanceof Buffer?i:Buffer.from(i);if(typeof TextDecoder<"u")return new TextDecoder().decode(i);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return i}var I,H,Y,U=a(()=>{G();c();c$1();C();C$1();B$1();f();I=class i extends z$1{constructor(e,t,s,r,n){super(t),this.client=e,this.schema=s,this.options=r,this.tx=n,this.logger=r.logger??new b,this.cache=r.cache??new w$1;}static[a$2]="LibSQLSession";logger;cache;prepareQuery(e,t,s,r,n,o,a){return new Y(this.client,e,this.logger,this.cache,o,a,t,this.tx,s,r,n)}async batch(e){let t=[],s=[];for(let n of e){let o=n._prepare(),a=o.getQuery();t.push(o),s.push({sql:a.sql,args:a.params});}return (await this.client.batch(s)).map((n,o)=>t[o].mapResult(n,true))}async migrate(e){let t=[],s=[];for(let n of e){let o=n._prepare(),a=o.getQuery();t.push(o),s.push({sql:a.sql,args:a.params});}return (await this.client.migrate(s)).map((n,o)=>t[o].mapResult(n,true))}async transaction(e,t){let s=await this.client.transaction(),r=new i(this.client,this.dialect,this.schema,this.options,s),n=new H("async",this.dialect,r,this.schema);try{let o=await e(n);return await s.commit(),o}catch(o){throw await s.rollback(),o}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}},H=class i extends A{static[a$2]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,s=new i("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(y$1.raw(`savepoint ${t}`));try{let r=await e(s);return await this.session.run(y$1.raw(`release savepoint ${t}`)),r}catch(r){throw await this.session.run(y$1.raw(`rollback to savepoint ${t}`)),r}}},Y=class extends y$2{constructor(e,t,s,r,n,o,a,c,l,u,D){super("async",l,t,r,n,o),this.client=e,this.logger=s,this.fields=a,this.tx=c,this._isResponseInArrayMode=u,this.customResultMapper=D,this.customResultMapper=D,this.fields=a;}static[a$2]="LibSQLPreparedQuery";async run(e){let t=A$1(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let s={sql:this.query.sql,args:t};return this.tx?this.tx.execute(s):this.client.execute(s)})}async all(e){let{fields:t,logger:s,query:r,tx:n,client:o,customResultMapper:a}=this;if(!t&&!a){let l=A$1(r.params,e??{});return s.logQuery(r.sql,l),await this.queryWithCache(r.sql,l,async()=>{let u={sql:r.sql,args:l};return (n?n.execute(u):o.execute(u)).then(({rows:D})=>this.mapAllResult(D))})}let c=await this.values(e);return this.mapAllResult(c)}mapAllResult(e,t){return t&&(e=e.rows),!this.fields&&!this.customResultMapper?e.map(s=>fe(s)):this.customResultMapper?this.customResultMapper(e,B):e.map(s=>d$1(this.fields,Array.prototype.slice.call(s).map(r=>B(r)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:s,query:r,tx:n,client:o,customResultMapper:a}=this;if(!t&&!a){let l=A$1(r.params,e??{});return s.logQuery(r.sql,l),await this.queryWithCache(r.sql,l,async()=>{let u={sql:r.sql,args:l};return (n?n.execute(u):o.execute(u)).then(({rows:D})=>this.mapGetResult(D))})}let c=await this.values(e);return this.mapGetResult(c)}mapGetResult(e,t){t&&(e=e.rows);let s=e[0];if(!this.fields&&!this.customResultMapper)return fe(s);if(s)return this.customResultMapper?this.customResultMapper(e,B):d$1(this.fields,Array.prototype.slice.call(s).map(r=>B(r)),this.joinsNotNullableMap)}async values(e){let t=A$1(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let s={sql:this.query.sql,args:t};return (this.tx?this.tx.execute(s):this.client.execute(s)).then(({rows:r})=>r)})}isResponseInArrayMode(){return this._isResponseInArrayMode}};});function v(i,e={}){let t=new s({casing:e.casing}),s$1;e.logger===true?s$1=new a$1:e.logger!==false&&(s$1=e.logger);let r;if(e.schema){let a=o(e.schema,p);r={fullSchema:e.schema,schema:a.tables,tableNamesMap:a.tableNamesMap};}let n=new I(i,t,r,{logger:s$1,cache:e.cache},void 0),o$1=new K("async",t,n,r);return o$1.$client=i,o$1.$cache=e.cache,o$1.$cache&&(o$1.$cache.invalidate=e.cache?.onMutate),o$1}var K,me=a(()=>{c();c$1();q();v$1();t();U();K=class extends u{static[a$2]="LibSQLDatabase";async batch(e){return this.session.batch(e)}};});function O(...i){if(typeof i[0]=="string"){let e=createClient({url:i[0]});return v(e,i[1])}if(e(i[0])){let{connection:e,client:t,...s}=i[0];if(t)return v(t,s);let r=typeof e=="string"?createClient({url:e}):createClient(e);return v(r,s)}return v(i[0],i[1])}var he=a(()=>{f();me();(i=>{function e(t){return v({},t)}i.mock=e;})(O||(O={}));});var de=a(()=>{he();U();});function Z(i){let e=[];for(let t of i){let s=Object.keys(t).map(r=>t[r]);e.push(s);}return e}var j,X,ee,te=a(()=>{G();c();c$1();C();C$1();B$1();f();j=class extends z$1{constructor(e,t,s,r={}){super(t),this.client=e,this.schema=s,this.options=r,this.logger=r.logger??new b,this.cache=r.cache??new w$1;}static[a$2]="SQLiteD1Session";logger;cache;prepareQuery(e,t,s,r,n,o,a){let c=this.client.prepare(e.sql);return new ee(c,e,this.logger,this.cache,o,a,t,s,r,n)}async batch(e){let t=[],s=[];for(let n of e){let o=n._prepare(),a=o.getQuery();if(t.push(o),a.params.length>0)s.push(o.stmt.bind(...a.params));else {let c=o.getQuery();s.push(this.client.prepare(c.sql).bind(...c.params));}}return (await this.client.batch(s)).map((n,o)=>t[o].mapResult(n,true))}extractRawAllValueFromBatchResult(e){return e.results}extractRawGetValueFromBatchResult(e){return e.results[0]}extractRawValuesValueFromBatchResult(e){return Z(e.results)}async transaction(e,t){let s=new X("async",this.dialect,this,this.schema);await this.run(y$1.raw(`begin${t?.behavior?" "+t.behavior:""}`));try{let r=await e(s);return await this.run(y$1`commit`),r}catch(r){throw await this.run(y$1`rollback`),r}}},X=class i extends A{static[a$2]="D1Transaction";async transaction(e){let t=`sp${this.nestedIndex}`,s=new i("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(y$1.raw(`savepoint ${t}`));try{let r=await e(s);return await this.session.run(y$1.raw(`release savepoint ${t}`)),r}catch(r){throw await this.session.run(y$1.raw(`rollback to savepoint ${t}`)),r}}};ee=class extends y$2{constructor(e,t,s,r,n,o,a,c,l,u){super("async",c,t,r,n,o),this.logger=s,this._isResponseInArrayMode=l,this.customResultMapper=u,this.fields=a,this.stmt=e;}static[a$2]="D1PreparedQuery";customResultMapper;fields;stmt;async run(e){let t=A$1(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:s,logger:r,stmt:n,customResultMapper:o}=this;if(!t&&!o){let c=A$1(s.params,e??{});return r.logQuery(s.sql,c),await this.queryWithCache(s.sql,c,async()=>n.bind(...c).all().then(({results:l})=>this.mapAllResult(l)))}let a=await this.values(e);return this.mapAllResult(a)}mapAllResult(e,t){return t&&(e=Z(e.results)),!this.fields&&!this.customResultMapper?e:this.customResultMapper?this.customResultMapper(e):e.map(s=>d$1(this.fields,s,this.joinsNotNullableMap))}async get(e){let{fields:t,joinsNotNullableMap:s,query:r,logger:n,stmt:o,customResultMapper:a}=this;if(!t&&!a){let l=A$1(r.params,e??{});return n.logQuery(r.sql,l),await this.queryWithCache(r.sql,l,async()=>o.bind(...l).all().then(({results:u})=>u[0]))}let c=await this.values(e);if(c[0])return a?a(c):d$1(t,c[0],s)}mapGetResult(e,t){return t&&(e=Z(e.results)[0]),!this.fields&&!this.customResultMapper?e:this.customResultMapper?this.customResultMapper([e]):d$1(this.fields,e,this.joinsNotNullableMap)}async values(e){let t=A$1(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 ge(i,e={}){let t=new s({casing:e.casing}),s$1;e.logger===true?s$1=new a$1:e.logger!==false&&(s$1=e.logger);let r;if(e.schema){let a=o(e.schema,p);r={fullSchema:e.schema,schema:a.tables,tableNamesMap:a.tableNamesMap};}let n=new j(i,t,r,{logger:s$1,cache:e.cache}),o$1=new se("async",t,n,r);return o$1.$client=i,o$1.$cache=e.cache,o$1.$cache&&(o$1.$cache.invalidate=e.cache?.onMutate),o$1}var se,ye=a(()=>{c();c$1();q();v$1();t();te();se=class extends u{static[a$2]="D1Database";async batch(e){return this.session.batch(e)}};});var be=a(()=>{ye();te();});function De(i,e="info"){let t=["trace","debug","info","warn","error","fatal"],s=t.indexOf(e),r=(n,o,a)=>{if(t.indexOf(n)>=s){let u=`${`[${new Date().toISOString()}] ${n.toUpperCase()}: [${i}]`} ${a} ${JSON.stringify(o)}`;switch(n){case "error":case "fatal":console.error(u);break;case "warn":console.warn(u);break;}}};return {trace:(n,o)=>r("trace",n,o),debug:(n,o)=>r("debug",n,o),info:(n,o)=>r("info",n,o),warn:(n,o)=>r("warn",n,o),error:(n,o)=>r("error",n,o),fatal:(n,o)=>r("fatal",n,o),child:()=>De(i,e)}}function Ee(i,e){k();let s=e||("info");let o=resolve(process.cwd(),"logs");existsSync(o)||mkdirSync(o,{recursive:true});let a=resolve(o,`${i}.log`),c=[];return c.push({level:s,stream:q$1.transport({target:"pino/file",options:{destination:a}})}),q$1({level:s},q$1.multistream(c)).child({module:i})}function x(i,e){if(d)return De(i,e||"info");if(re.has(i))return re.get(i);let t=Ee(i,e);return re.set(i,t),t}var re,ve,qe=a(()=>{_();z();re=new Map;ve={app:()=>x("app"),db:()=>x("db"),api:()=>x("api"),ws:()=>x("ws"),bootstrap:()=>x("bootstrap"),module:i=>x(i)};});async function Re(){if(g)return g;let i=w();if(y.debug({driver:i.driver},"Creating database connection"),i.driver==="d1")g=_e(i);else {let e=ke(i);g=e.db,R=e.client;}return y.info({driver:i.driver},"Database connected"),g}function ke(i){if(d)throw new Error("SQLite is not supported in Cloudflare Workers. Use D1 instead.");let e=i.sqlitePath||"./data/app.db";if(e!==":memory:"){let r=dirname(e);existsSync(r)||(mkdirSync(r,{recursive:true}),y.debug({dir:r},"Created database directory"));}let t=createClient({url:e===":memory:"?":memory:":`file:${e}`}),s=O(t,{schema:ia});return y.debug({path:e},"SQLite database created"),{db:s,client:t}}function _e(i){if(!i.d1Database)throw new Error("D1 database binding not found. Make sure D1 is configured in wrangler.toml");return ge(i.d1Database,{schema:ia})}async function Be(){let i=w();return i.driver==="sqlite"?(R||await Re(),R):i.driver==="d1"&&i.d1Database||null}async function Ie(){w().driver==="sqlite"&&R&&(R.close(),R=null,g=null,y.info({},"Database connection closed"));}async function Oe(){if(d){y.info({},"Migrations skipped in Cloudflare Workers");return}if(w().driver==="sqlite"&&g){let e="./drizzle";if(existsSync(e)){let{migrate:t}=await import('./migrator-TEPBVUFO.js');await t(g,{migrationsFolder:e}),y.info({folder:e},"Migrations applied");}else y.warn({folder:e},"No migrations folder found");}}var g,R,y,Le=a(()=>{_();ja();de();be();qe();z();g=null,R=null,y=ve.db();});var Se=a(()=>{_();});var je=a(()=>{Le();Se();ja();});export{d as a,z as b,w as c,x as d,ve as e,qe as f,ge as g,be as h,Re as i,Be as j,Ie as k,Oe as l,je as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-5J6HXUF6.js';function m(r,e){if(!r||typeof r!="object")return false;if(r instanceof e)return true;if(!Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Class "${e.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let t=Object.getPrototypeOf(r).constructor;if(t)for(;t;){if(a in t&&t[a]===e[a])return true;t=Object.getPrototypeOf(t);}return false}var a,S=a$1(()=>{a=Symbol.for("drizzle:entityKind");});var A,Z=a$1(()=>{S();A=class{static[a]="ColumnBuilder";config;constructor(e,t,n){this.config={name:e,keyAsName:e==="",notNull:false,default:void 0,hasDefault:false,primaryKey:false,isUnique:false,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0};}$type(){return this}notNull(){return this.config.notNull=true,this}default(e){return this.config.default=e,this.config.hasDefault=true,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=true,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=true,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=true,this.config.notNull=true,this}setName(e){this.config.name===""&&(this.config.name=e);}};});var N,L=a$1(()=>{S();N=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity;}static[a]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};});var w,V=a$1(()=>{w=Symbol.for("drizzle:Name");});var k=a$1(()=>{S();V();});var E=a$1(()=>{});var te=a$1(()=>{S();V();});var se=a$1(()=>{});var ae=a$1(()=>{Z();L();S();k();E();te();se();});function fe(r){return !!r&&typeof r=="function"&&le in r&&r[le]===true}var le,ce=a$1(()=>{S();ae();le=Symbol.for("drizzle:isPgEnum");});var q,pe,de=a$1(()=>{S();q=class{static[a]="Subquery";constructor(e,t,n,s=false,o=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:n,isWith:s,usedTables:o};}},pe=class extends q{static[a]="WithSubquery"};});var ye=a$1(()=>{});var ge,be=a$1(()=>{E();ye();ge={startActiveSpan(r,e){return e()}};});var D,we=a$1(()=>{D=Symbol.for("drizzle:ViewBaseConfig");});function
|
|
1
|
+
import {a as a$1}from'./chunk-5J6HXUF6.js';function m(r,e){if(!r||typeof r!="object")return false;if(r instanceof e)return true;if(!Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Class "${e.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let t=Object.getPrototypeOf(r).constructor;if(t)for(;t;){if(a in t&&t[a]===e[a])return true;t=Object.getPrototypeOf(t);}return false}var a,S=a$1(()=>{a=Symbol.for("drizzle:entityKind");});var A,Z=a$1(()=>{S();A=class{static[a]="ColumnBuilder";config;constructor(e,t,n){this.config={name:e,keyAsName:e==="",notNull:false,default:void 0,hasDefault:false,primaryKey:false,isUnique:false,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0};}$type(){return this}notNull(){return this.config.notNull=true,this}default(e){return this.config.default=e,this.config.hasDefault=true,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=true,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=true,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=true,this.config.notNull=true,this}setName(e){this.config.name===""&&(this.config.name=e);}};});var N,L=a$1(()=>{S();N=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity;}static[a]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};});var w,V=a$1(()=>{w=Symbol.for("drizzle:Name");});var k=a$1(()=>{S();V();});var E=a$1(()=>{});var te=a$1(()=>{S();V();});var se=a$1(()=>{});var ae=a$1(()=>{Z();L();S();k();E();te();se();});function fe(r){return !!r&&typeof r=="function"&&le in r&&r[le]===true}var le,ce=a$1(()=>{S();ae();le=Symbol.for("drizzle:isPgEnum");});var q,pe,de=a$1(()=>{S();q=class{static[a]="Subquery";constructor(e,t,n,s=false,o=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:n,isWith:s,usedTables:o};}},pe=class extends q{static[a]="WithSubquery"};});var ye=a$1(()=>{});var ge,be=a$1(()=>{E();ye();ge={startActiveSpan(r,e){return e()}};});var D,we=a$1(()=>{D=Symbol.for("drizzle:ViewBaseConfig");});function ht(r){return r[w]}function yt(r){return `${r[I]??"public"}.${r[w]}`}var I,Se,Ne,H,X,x,Ce,Te,y,ve=a$1(()=>{S();V();I=Symbol.for("drizzle:Schema"),Se=Symbol.for("drizzle:Columns"),Ne=Symbol.for("drizzle:ExtraConfigColumns"),H=Symbol.for("drizzle:OriginalName"),X=Symbol.for("drizzle:BaseName"),x=Symbol.for("drizzle:IsAlias"),Ce=Symbol.for("drizzle:ExtraConfigBuilder"),Te=Symbol.for("drizzle:IsDrizzleTable"),y=class{static[a]="Table";static Symbol={Name:w,Schema:I,OriginalName:H,Columns:Se,ExtraConfigColumns:Ne,BaseName:X,IsAlias:x,ExtraConfigBuilder:Ce};[w];[H];[I];[Se];[Ne];[X];[x]=false;[Te]=true;[Ce]=void 0;constructor(e,t,n){this[w]=this[H]=e,this[I]=t,this[X]=n;}};});function Ae(r){return r!=null&&typeof r.getSQL=="function"}function Ve(r){let e={sql:"",params:[]};for(let t of r)e.sql+=t.sql,e.params.push(...t.params),t.typings?.length&&(e.typings||(e.typings=[]),e.typings.push(...t.typings));return e}function qt(r){return typeof r=="object"&&r!==null&&"mapToDriverValue"in r&&typeof r.mapToDriverValue=="function"}function qe(r,...e){let t=[];(e.length>0||r.length>0&&r[0]!=="")&&t.push(new b(r[0]));for(let[n,s]of e.entries())t.push(s,new b(r[n+1]));return new f(t)}function xt(r,e){return r.map(t=>{if(m(t,v)){if(!(t.name in e))throw new Error(`No value for placeholder "${t.name}" was provided`);return e[t.name]}if(m(t,T)&&m(t.value,v)){if(!(t.value.name in e))throw new Error(`No value for placeholder "${t.value.name}" was provided`);return t.encoder.mapToDriverValue(e[t.value.name])}return t})}var b,f,P,De,xe,T,v,Qe,Y,Fe=a$1(()=>{S();ce();de();be();we();L();ve();b=class{static[a]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e];}getSQL(){return new f([this])}},f=class r{constructor(e){this.queryChunks=e;for(let t of e)if(m(t,y)){let n=t[y.Symbol.Schema];this.usedTables.push(n===void 0?t[y.Symbol.Name]:n+"."+t[y.Symbol.Name]);}}static[a]="SQL";decoder=De;shouldInlineParams=false;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return ge.startActiveSpan("drizzle.buildSQL",t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:s,escapeName:o,escapeParam:p,prepareTyping:h,inlineParams:l,paramStartIndex:g}=n;return Ve(e.map(i=>{if(m(i,b))return {sql:i.value.join(""),params:[]};if(m(i,P))return {sql:o(i.value),params:[]};if(i===void 0)return {sql:"",params:[]};if(Array.isArray(i)){let u=[new b("(")];for(let[d,Pe]of i.entries())u.push(Pe),d<i.length-1&&u.push(new b(", "));return u.push(new b(")")),this.buildQueryFromSourceParams(u,n)}if(m(i,r))return this.buildQueryFromSourceParams(i.queryChunks,{...n,inlineParams:l||i.shouldInlineParams});if(m(i,y)){let u=i[y.Symbol.Schema],d=i[y.Symbol.Name];return {sql:u===void 0||i[x]?o(d):o(u)+"."+o(d),params:[]}}if(m(i,N)){let u=s.getColumnCasing(i);if(t.invokeSource==="indexes")return {sql:o(u),params:[]};let d=i.table[y.Symbol.Schema];return {sql:i.table[x]||d===void 0?o(i.table[y.Symbol.Name])+"."+o(u):o(d)+"."+o(i.table[y.Symbol.Name])+"."+o(u),params:[]}}if(m(i,Y)){let u=i[D].schema,d=i[D].name;return {sql:u===void 0||i[D].isAlias?o(d):o(u)+"."+o(d),params:[]}}if(m(i,T)){if(m(i.value,v))return {sql:p(g.value++,i),params:[i],typings:["none"]};let u=i.value===null?null:i.encoder.mapToDriverValue(i.value);if(m(u,r))return this.buildQueryFromSourceParams([u],n);if(l)return {sql:this.mapInlineParam(u,n),params:[]};let d=["none"];return h&&(d=[h(i.encoder)]),{sql:p(g.value++,u),params:[u],typings:d}}return m(i,v)?{sql:p(g.value++,i),params:[i],typings:["none"]}:m(i,r.Aliased)&&i.fieldAlias!==void 0?{sql:o(i.fieldAlias),params:[]}:m(i,q)?i._.isWith?{sql:o(i._.alias),params:[]}:this.buildQueryFromSourceParams([new b("("),i._.sql,new b(") "),new P(i._.alias)],n):fe(i)?i.schema?{sql:o(i.schema)+"."+o(i.enumName),params:[]}:{sql:o(i.enumName),params:[]}:Ae(i)?i.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([i.getSQL()],n):this.buildQueryFromSourceParams([new b("("),i.getSQL(),new b(")")],n):l?{sql:this.mapInlineParam(i,n),params:[]}:{sql:p(g.value++,i),params:[i],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return "null";if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="string")return t(e);if(typeof e=="object"){let n=e.toString();return t(n==="[object Object]"?JSON.stringify(e):n)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new r.Aliased(this,e)}mapWith(e){return this.decoder=typeof e=="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=true,this}if(e){return e?this:void 0}},P=class{constructor(e){this.value=e;}static[a]="Name";brand;getSQL(){return new f([this])}};De={mapFromDriverValue:r=>r},xe={mapToDriverValue:r=>r},{...De,...xe},T=class{constructor(e,t=xe){this.value=e,this.encoder=t;}static[a]="Param";brand;getSQL(){return new f([this])}};(r=>{function e(){return new f([])}r.empty=e;function t(l){return new f(l)}r.fromList=t;function n(l){return new f([new b(l)])}r.raw=n;function s(l,g){let i=[];for(let[u,d]of l.entries())u>0&&g!==void 0&&i.push(g),i.push(d);return new f(i)}r.join=s;function o(l){return new P(l)}r.identifier=o;function p(l){return new v(l)}r.placeholder=p;function h(l,g){return new T(l,g)}r.param=h;})(qe||(qe={}));(r=>{class e{constructor(n,s){this.sql=n,this.fieldAlias=s;}static[a]="SQL.Aliased";isSelectionField=false;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}}r.Aliased=e;})(f||(f={}));v=class{constructor(e){this.name=e;}static[a]="Placeholder";getSQL(){return new f([this])}};Qe=Symbol.for("drizzle:IsDrizzleView"),Y=class{static[a]="View";[D];[Qe]=true;constructor({name:e,schema:t,selectedFields:n,query:s}){this[D]={name:e,originalName:e,schema:t,selectedFields:n,query:s,isExisting:!s,isAlias:false};}getSQL(){return new f([this])}};N.prototype.getSQL=function(){return new f([this])};y.prototype.getSQL=function(){return new f([this])};q.prototype.getSQL=function(){return new f([this])};});export{xt as A,Y as B,Fe as C,a,m as b,S as c,N as d,L as e,A as f,Z as g,w as h,V as i,q as j,pe as k,de as l,D as m,we as n,Se as o,y as p,ht as q,yt as r,ve as s,Ae as t,b as u,f as v,qt as w,T as x,qe as y,v as z};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {e,c,C,s,n,l,i,g,p,a as a$2,y,b as b$1,d,v as v$1,j as j$1,q,u,r,k,x as x$1,w,t,z as z$1,B,f as f$1,m,o,h}from'./chunk-IXJL2LE4.js';import {a as a$1,b}from'./chunk-5J6HXUF6.js';function qe(r,e){return new Proxy(r,new Te(e,false))}function X(r,e){return new Proxy(r,new be(new Proxy(r.table,new Te(e,false))))}function Tt(r,e){return new v$1.Aliased(ve(r.sql,e),r.fieldAlias)}function ve(r,e){return y.join(r.queryChunks.map(t=>b$1(t,d)?X(t,e):b$1(t,v$1)?ve(t,e):b$1(t,v$1.Aliased)?Tt(t,e):t))}var be,Te,Je=a$1(()=>{e();c();C();s();n();be=class{constructor(e){this.table=e;}static[a$2]="ColumnAliasProxyHandler";get(e,t){return t==="table"?this.table:e[t]}},Te=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t;}static[a$2]="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 o={};return Object.keys(s).map(l=>{o[l]=new Proxy(s[l],new be(new Proxy(e,this)));}),o}let i=e[t];return b$1(i,d)?new Proxy(i,new be(new Proxy(e,this))):i}};});var Ur=a$1(()=>{});var zr=a$1(()=>{c();});function Cn(r,e,t){let i={},s=r.reduce((o,{path:l,field:c},d$1)=>{let y;b$1(c,d)?y=c:b$1(c,v$1)?y=c.decoder:b$1(c,j$1)?y=c._.sql.decoder:y=c.sql.decoder;let g=o;for(let[N,_]of l.entries())if(N<l.length-1)_ in g||(g[_]={}),g=g[_];else {let L=e[d$1],A=g[_]=L===null?null:y.mapFromDriverValue(L);if(t&&b$1(c,d)&&l.length===2){let $=l[0];$ in i?typeof i[$]=="string"&&i[$]!==q(c.table)&&(i[$]=false):i[$]=A===null?q(c.table):false;}}return o},{});if(t&&Object.keys(i).length>0)for(let[o,l]of Object.entries(i))typeof l=="string"&&!t[l]&&(s[o]=null);return s}function z(r,e){return Object.entries(r).reduce((t,[i,s])=>{if(typeof i!="string")return t;let o=e?[...e,i]:[i];return b$1(s,d)||b$1(s,v$1)||b$1(s,v$1.Aliased)||b$1(s,j$1)?t.push({path:o,field:s}):b$1(s,p)?t.push(...z(s[p.Symbol.Columns],o)):t.push(...z(s,o)),t},[])}function Qe(r,e){let t=Object.keys(r),i=Object.keys(e);if(t.length!==i.length)return false;for(let[s,o]of t.entries())if(o!==i[s])return false;return true}function ze(r,e){let t=Object.entries(e).filter(([,i])=>i!==void 0).map(([i,s])=>b$1(s,v$1)||b$1(s,d)?[i,s]:[i,new x$1(s,r[p.Symbol.Columns][i])]);if(t.length===0)throw new Error("No values to set");return Object.fromEntries(t)}function Wr(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 We(r){return r[p.Symbol.Columns]}function Le(r){return b$1(r,j$1)?r._.alias:b$1(r,B)?r[m].name:b$1(r,v$1)?void 0:r[p.Symbol.IsAlias]?r[p.Symbol.Name]:r[p.Symbol.BaseName]}function ee(r,e){return {name:typeof r=="string"&&r.length>0?r:"",config:typeof r=="object"?r:e}}function _n(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 _t,U=a$1(()=>{e();c();C();l();s();n();_t=typeof TextDecoder>"u"?null:new TextDecoder;});var He,qt,vt=a$1(()=>{c();i();He=class{static[a$2]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:i,columns:s,foreignColumns:o}=e();return {name:i,columns:s,foreignTable:o[0].table,foreignColumns:o}},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 qt(e,this)}},qt=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[a$2]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(c=>c.name),o=i.map(c=>c.name),l=[this.table[h],...s,i[0].table[h],...o];return e??`${l.join("_")}_fk`}};});function Bt(r,e){return `${r[h]}_${e.join("_")}_unique`}function Hr(r){return new Lt(r)}var Qt,Lt,At,Ot=a$1(()=>{c();i();Qt=class{constructor(e,t){this.name=t,this.columns=e;}static[a$2]="SQLiteUniqueConstraintBuilder";columns;build(e){return new At(e,this.columns,this.name)}},Lt=class{static[a$2]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e;}on(...e){return new Qt(e,this.name)}},At=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??Bt(this.table,this.columns.map(s=>s.name));}static[a$2]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}};});var I,Q,fe=a$1(()=>{g();e();c();vt();Ot();I=class extends f$1{static[a$2]="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})=>((o,l)=>{let c=new He(()=>{let d=o();return {columns:[e],foreignColumns:[d]}});return l.onUpdate&&c.onUpdate(l.onUpdate),l.onDelete&&c.onDelete(l.onDelete),c.build(t)})(i,s))}},Q=class extends d{constructor(e,t){t.uniqueName||(t.uniqueName=Bt(e,[t.name])),super(e,t),this.table=e;}static[a$2]="SQLiteColumn"};});function Yr(r,e){let{name:t,config:i}=ee(r,e);return i?.mode==="json"?new Kt(t):i?.mode==="bigint"?new jt(t):new Ft(t)}var jt,It,Kt,Rt,Ft,Dt,Pt=a$1(()=>{c();U();fe();jt=class extends I{static[a$2]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt");}build(e){return new It(e,this.config)}},It=class extends Q{static[a$2]="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(_t.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},Kt=class extends I{static[a$2]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson");}build(e){return new Rt(e,this.config)}},Rt=class extends Q{static[a$2]="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(_t.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},Ft=class extends I{static[a$2]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer");}build(e){return new Dt(e,this.config)}},Dt=class extends Q{static[a$2]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return "blob"}};});function Gr(r){return (e,t)=>{let{name:i,config:s}=ee(e,t);return new Et(i,s,r)}}var Et,kt,Mt=a$1(()=>{c();U();fe();Et=class extends I{static[a$2]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i;}build(e){return new kt(e,this.config)}},kt=class extends Q{static[a$2]="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 f(r,e){let{name:t,config:i}=ee(r,e);return i?.mode==="timestamp"||i?.mode==="timestamp_ms"?new Jt(t,i.mode):i?.mode==="boolean"?new Wt(t,i.mode):new Vt(t)}var Ae,Be,Vt,Ut,Jt,zt,Wt,Ht,Yt=a$1(()=>{c();C();U();fe();Ae=class extends I{static[a$2]="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()}},Be=class extends Q{static[a$2]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return "integer"}},Vt=class extends Ae{static[a$2]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger");}build(e){return new Ut(e,this.config)}},Ut=class extends Be{static[a$2]="SQLiteInteger"},Jt=class extends Ae{static[a$2]="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 zt(e,this.config)}},zt=class extends Be{static[a$2]="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}},Wt=class extends Ae{static[a$2]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t;}build(e){return new Ht(e,this.config)}},Ht=class extends Be{static[a$2]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}};});function Zr(r,e){let{name:t,config:i}=ee(r,e),s=i?.mode;return s==="number"?new Xt(t):s==="bigint"?new tr(t):new Gt(t)}var Gt,Zt,Xt,er,tr,rr,ir=a$1(()=>{c();U();fe();Gt=class extends I{static[a$2]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric");}build(e){return new Zt(e,this.config)}},Zt=class extends Q{static[a$2]="SQLiteNumeric";mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return "numeric"}},Xt=class extends I{static[a$2]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber");}build(e){return new er(e,this.config)}},er=class extends Q{static[a$2]="SQLiteNumericNumber";mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}mapToDriverValue=String;getSQLType(){return "numeric"}},tr=class extends I{static[a$2]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt");}build(e){return new rr(e,this.config)}},rr=class extends Q{static[a$2]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return "numeric"}};});function Xr(r){return new sr(r??"")}var sr,nr,or=a$1(()=>{c();fe();sr=class extends I{static[a$2]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal");}build(e){return new nr(e,this.config)}},nr=class extends Q{static[a$2]="SQLiteReal";getSQLType(){return "real"}};});function a(r,e={}){let{name:t,config:i}=ee(r,e);return i.mode==="json"?new ur(t):new ar(t,i)}var ar,lr,ur,cr,mr=a$1(()=>{c();U();fe();ar=class extends I{static[a$2]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length;}build(e){return new lr(e,this.config)}},lr=class extends Q{static[a$2]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t);}getSQLType(){return `text${this.config.length?`(${this.config.length})`:""}`}},ur=class extends I{static[a$2]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson");}build(e){return new cr(e,this.config)}},cr=class extends Q{static[a$2]="SQLiteTextJson";getSQLType(){return "text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};});var fr=a$1(()=>{Pt();fe();Mt();Yt();ir();or();mr();});var v,we=a$1(()=>{Je();e();c();C();l();n();v=class r{static[a$2]="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$1)?e._.selectedFields:b$1(e,B)?e[m].selectedFields:e)[t];if(b$1(s,v$1.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;let o=s.clone();return o.isSelectionField=true,o}if(b$1(s,v$1)){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 be(new Proxy(s.table,new Te(this.config.alias,this.config.replaceOriginalName??false)))):s:typeof s!="object"||s===null?s:new Proxy(s,new r(this.config))}};});var D,ae=a$1(()=>{c();D=class{static[a$2]="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:Yr,customType:Gr,integer:f,numeric:Zr,real:Xr,text:a}}var ti=a$1(()=>{Pt();Mt();Yt();ir();or();mr();});function js(r,e,t,i,s=r){let o=new j(r,i,s),l=typeof e=="function"?e(ei()):e,c=Object.fromEntries(Object.entries(l).map(([y,g])=>{let N=g;N.setName(y);let _=N.build(o);return o[dr].push(...N.buildForeignKeys(_,o)),[y,_]})),d=Object.assign(o,c);return d[p.Symbol.Columns]=c,d[p.Symbol.ExtraConfigColumns]=c,t&&(d[j.Symbol.ExtraConfigBuilder]=t),d}var dr,j,x,le=a$1(()=>{c();s();ti();dr=Symbol.for("drizzle:SQLiteInlineForeignKeys"),j=class extends p{static[a$2]="SQLiteTable";static Symbol=Object.assign({},p.Symbol,{InlineForeignKeys:dr});[p.Symbol.Columns];[dr]=[];[p.Symbol.ExtraConfigBuilder]=void 0};x=(r,e,t)=>js(r,e,t);});function Ye(r){return new pr(r,true)}var pr,hr,yr,ri=a$1(()=>{c();pr=class{constructor(e,t){this.name=e,this.unique=t;}static[a$2]="SQLiteIndexBuilderOn";on(...e){return new hr(this.name,e,this.unique)}},hr=class{static[a$2]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0};}where(e){return this.config.where=e,this}build(e){return new yr(this.config,e)}},yr=class{static[a$2]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t};}};});function Ze(...r){return r[0].columns?new Ge(r[0].columns,r[0].name):new Ge(r)}var Ge,gr,ii=a$1(()=>{c();le();Ge=class{static[a$2]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t;}build(e){return new gr(e,this.columns,this.name)}},gr=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i;}static[a$2]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[j.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}};});function Y(r){return b$1(r,j)?[`${r[p.Symbol.BaseName]}`]:b$1(r,j$1)?r._.usedTables??[]:b$1(r,v$1)?r.usedTables??[]:[]}var Ce=a$1(()=>{c();C();l();s();le();});var Oe,si=a$1(()=>{c();ae();we();le();s();U();Ce();Oe=class extends D{constructor(e,t,i,s){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s};}static[a$2]="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 v({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[j.Symbol.Columns]){return this.config.returning=z(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 Is(r){return (r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(t=>t.toLowerCase()).join("_")}function Ks(r){return (r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((t,i,s)=>{let o=s===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return t+o},"")}function Rs(r){return r}var Xe,ni=a$1(()=>{c();s();Xe=class{static[a$2]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Is:e==="camelCase"?Ks:Rs;}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 o of Object.values(e[p.Symbol.Columns])){let l=`${s}.${o.name}`;this.cache[l]=this.convert(o.name);}this.cachedTables[s]=true;}}clearCache(){this.cache={},this.cachedTables={};}};});var Se,ue,et,tt=a$1(()=>{c();Se=class extends Error{static[a$2]="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);}},et=class extends Se{static[a$2]="TransactionRollbackError";constructor(){super({message:"Rollback"});}};});var oi,ai,rt,li=a$1(()=>{c();s();oi=Symbol.for("drizzle:PgInlineForeignKeys"),ai=Symbol.for("drizzle:EnableRLS"),rt=class extends p{static[a$2]="PgTable";static Symbol=Object.assign({},p.Symbol,{InlineForeignKeys:oi,EnableRLS:ai});[oi]=[];[ai]=false;[p.Symbol.ExtraConfigBuilder]=void 0;[p.Symbol.ExtraConfigColumns]={}};});var it,br,ui=a$1(()=>{c();li();it=class{static[a$2]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t;}build(e){return new br(e,this.columns,this.name)}},br=class{constructor(e,t,i){this.table=e,this.columns=t,this.name=i;}static[a$2]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[rt.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}};});function M(r,e){return w(e)&&!t(r)&&!b$1(r,x$1)&&!b$1(r,z$1)&&!b$1(r,d)&&!b$1(r,p)&&!b$1(r,B)?new x$1(r,e):r}function je(...r){let e=r.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new v$1(e):new v$1([new u("("),y.join(e,new u(" and ")),new u(")")])}function mi(...r){let e=r.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new v$1(e):new v$1([new u("("),y.join(e,new u(" or ")),new u(")")])}function fi(r){return y`not ${r}`}function gi(r,e){return Array.isArray(e)?e.length===0?y`false`:y`${r} in ${e.map(t=>M(t,r))}`:y`${r} in ${M(e,r)}`}function bi(r,e){return Array.isArray(e)?e.length===0?y`true`:y`${r} not in ${e.map(t=>M(t,r))}`:y`${r} not in ${M(e,r)}`}function wi(r){return y`${r} is null`}function Si(r){return y`${r} is not null`}function xi(r){return y`exists ${r}`}function Ni(r){return y`not exists ${r}`}function $i(r,e,t){return y`${r} between ${M(e,r)} and ${M(t,r)}`}function Ti(r,e,t){return y`${r} not between ${M(e,r)} and ${M(t,r)}`}function Ci(r,e){return y`${r} like ${e}`}function _i(r,e){return y`${r} not like ${e}`}function qi(r,e){return y`${r} ilike ${e}`}function vi(r,e){return y`${r} not ilike ${e}`}var st,ci,di,pi,hi,yi,Qi=a$1(()=>{e();c();s();C();st=(r,e)=>y`${r} = ${M(e,r)}`,ci=(r,e)=>y`${r} <> ${M(e,r)}`;di=(r,e)=>y`${r} > ${M(e,r)}`,pi=(r,e)=>y`${r} >= ${M(e,r)}`,hi=(r,e)=>y`${r} < ${M(e,r)}`,yi=(r,e)=>y`${r} <= ${M(e,r)}`;});function Li(r){return y`${r} asc`}function Ai(r){return y`${r} desc`}var Bi=a$1(()=>{C();});var wr=a$1(()=>{Qi();Bi();});function Oi(){return {and:je,between:$i,eq:st,exists:xi,gt:di,gte:pi,ilike:qi,inArray:gi,isNull:wi,isNotNull:Si,like:Ci,lt:hi,lte:yi,ne:ci,not:fi,notBetween:Ti,notExists:Ni,notLike:_i,notIlike:vi,notInArray:bi,or:mi,sql:y}}function ji(){return {sql:y,asc:Li,desc:Ai}}function Aa(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[o,l]of Object.entries(r$1))if(b$1(l,p)){let c=r(l),d=i[c];t[c]=o,s[o]={tsName:o,dbName:l[p.Symbol.Name],schema:l[p.Symbol.Schema],columns:l[p.Symbol.Columns],relations:d?.relations??{},primaryKey:d?.primaryKey??[]};for(let g of Object.values(l[p.Symbol.Columns]))g.primary&&s[o].primaryKey.push(g);let y=l[p.Symbol.ExtraConfigBuilder]?.(l[p.Symbol.ExtraConfigColumns]);if(y)for(let g of Object.values(y))b$1(g,it)&&s[o].primaryKey.push(...g.columns);}else if(b$1(l,Sr)){let c=r(l.table),d=t[c],y=l.config(e(l.table)),g;for(let[N,_]of Object.entries(y))if(d){let L=s[d];L.relations[N]=_;}else c in i||(i[c]={relations:{},primaryKey:g}),i[c].relations[N]=_;}return {tables:s,tableNamesMap:t}}function Fs(r){return function(t,i){return new de(r,t,i,i?.fields.reduce((s,o)=>s&&o.notNull,true)??false)}}function Ds(r){return function(t,i){return new Ie(r,t,i)}}function Ii(r$1,e,t){if(b$1(t,de)&&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 o=t.sourceTable,l=e[r(o)];if(!l)throw new Error(`Table "${o[p.Symbol.Name]}" not found in schema`);let c=[];for(let d of Object.values(s.relations))(t.relationName&&t!==d&&d.relationName===t.relationName||!t.relationName&&d.referencedTable===t.sourceTable)&&c.push(d);if(c.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(c[0]&&b$1(c[0],de)&&c[0].config)return {fields:c[0].config.references,references:c[0].config.fields};throw new Error(`There is not enough information to infer relation "${l}.${t.fieldName}"`)}function Ba(r){return {one:Fs(r),many:Ds(r)}}function ot(r,e,t,i,s=o=>o){let o={};for(let[l,c]of i.entries())if(c.isJson){let d=e.relations[c.tsKey],y=t[l],g=typeof y=="string"?JSON.parse(y):y;o[c.tsKey]=b$1(d,de)?g&&ot(r,r[c.relationTableTsKey],g,c.selection,s):g.map(N=>ot(r,r[c.relationTableTsKey],N,c.selection,s));}else {let d$1=s(t[l]),y=c.field,g;b$1(y,d)?g=y:b$1(y,v$1)?g=y.decoder:g=y.sql.decoder,o[c.tsKey]=d$1===null?null:g.mapFromDriverValue(d$1);}return o}var nt,Sr,de,Ie,at=a$1(()=>{s();e();c();ui();wr();C();nt=class{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[p.Symbol.Name];}static[a$2]="Relation";referencedTableName;fieldName},Sr=class{constructor(e,t){this.table=e,this.config=t;}static[a$2]="Relations"},de=class r extends nt{constructor(e,t,i,s){super(e,t,i?.relationName),this.config=i,this.isNullable=s;}static[a$2]="One";withFieldName(e){let t=new r(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}},Ie=class r extends nt{constructor(e,t,i){super(e,t,i?.relationName),this.config=i;}static[a$2]="Many";withFieldName(e){let t=new r(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}};});var Ki=a$1(()=>{});var Ri=a$1(()=>{});var Fi=a$1(()=>{Ki();Ri();});var xr=a$1(()=>{wr();Fi();C();});var te,Ke=a$1(()=>{c();C();te=class extends B{static[a$2]="SQLiteViewBase"};});var xe,lt,Di,Nr=a$1(()=>{Je();ni();e();c();tt();at();xr();C();fr();le();l();s();U();n();Ke();xe=class{static[a$2]="SQLiteDialect";casing;constructor(e){this.casing=new Xe(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:o,orderBy:l}){let c=this.buildWithCTE(s),d=i?y` returning ${this.buildSelection(i,{isSingleTable:true})}`:void 0,y$1=t?y` where ${t}`:void 0,g=this.buildOrderBy(l),N=this.buildLimit(o);return y`${c}delete from ${e}${y$1}${d}${g}${N}`}buildUpdateSet(e,t){let i=e[p.Symbol.Columns],s=Object.keys(i).filter(l=>t[l]!==void 0||i[l]?.onUpdateFn!==void 0),o=s.length;return y.join(s.flatMap((l,c)=>{let d=i[l],y$1=d.onUpdateFn?.(),g=t[l]??(b$1(y$1,v$1)?y$1:y.param(y$1,d)),N=y`${y.identifier(this.casing.getColumnCasing(d))} = ${g}`;return c<o-1?[N,y.raw(", ")]:[N]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:o,joins:l,from:c,limit:d,orderBy:y$1}){let g=this.buildWithCTE(o),N=this.buildUpdateSet(e,t),_=c&&y.join([y.raw(" from "),this.buildFromTable(c)]),L=this.buildJoins(l),A=s?y` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,$=i?y` where ${i}`:void 0,B=this.buildOrderBy(y$1),O=this.buildLimit(d);return y`${g}update ${e} set ${N}${_}${L}${$}${A}${B}${O}`}buildSelection(e,{isSingleTable:t=false}={}){let i=e.length,s=e.flatMap(({field:o},l)=>{let c=[];if(b$1(o,v$1.Aliased)&&o.isSelectionField)c.push(y.identifier(o.fieldAlias));else if(b$1(o,v$1.Aliased)||b$1(o,v$1)){let d$1=b$1(o,v$1.Aliased)?o.sql:o;t?c.push(new v$1(d$1.queryChunks.map(y$1=>b$1(y$1,d)?y.identifier(this.casing.getColumnCasing(y$1)):y$1))):c.push(d$1),b$1(o,v$1.Aliased)&&c.push(y` as ${y.identifier(o.fieldAlias)}`);}else if(b$1(o,d)){let d=o.table[p.Symbol.Name];o.columnType==="SQLiteNumericBigInt"?t?c.push(y`cast(${y.identifier(this.casing.getColumnCasing(o))} as text)`):c.push(y`cast(${y.identifier(d)}.${y.identifier(this.casing.getColumnCasing(o))} as text)`):t?c.push(y.identifier(this.casing.getColumnCasing(o))):c.push(y`${y.identifier(d)}.${y.identifier(this.casing.getColumnCasing(o))}`);}else if(b$1(o,j$1)){let d$1=Object.entries(o._.selectedFields);if(d$1.length===1){let y=d$1[0][1],g=b$1(y,v$1)?y.decoder:b$1(y,d)?{mapFromDriverValue:N=>y.mapFromDriverValue(N)}:y.sql.decoder;g&&(o._.sql.decoder=g);}c.push(o);}return l<i-1&&c.push(y`, `),c});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 o=s.table,l=s.on?y` on ${s.on}`:void 0;if(b$1(o,j)){let c=o[j.Symbol.Name],d=o[j.Symbol.Schema],y$1=o[j.Symbol.OriginalName],g=c===y$1?void 0:s.alias;t.push(y`${y.raw(s.joinType)} join ${d?y`${y.identifier(d)}.`:void 0}${y.identifier(y$1)}${g&&y` ${y.identifier(g)}`}${l}`);}else t.push(y`${y.raw(s.joinType)} join ${o}${l}`);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:o,table:l,joins:c,orderBy:d$1,groupBy:y$1,limit:g,offset:N,distinct:_,setOperators:L}){let A=i??z(t);for(let H of A)if(b$1(H.field,d)&&q(H.field.table)!==(b$1(l,j$1)?l._.alias:b$1(l,te)?l[m].name:b$1(l,v$1)?void 0:q(l))&&!(G=>c?.some(({alias:Ve})=>Ve===(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 $=!c||c.length===0,B=this.buildWithCTE(e),O=_?y` distinct`:void 0,V=this.buildSelection(A,{isSingleTable:$}),P=this.buildFromTable(l),T=this.buildJoins(c),ie=s?y` where ${s}`:void 0,J=o?y` having ${o}`:void 0,w=[];if(y$1)for(let[H,G]of y$1.entries())w.push(G),H<y$1.length-1&&w.push(y`, `);let C=w.length>0?y` group by ${y.join(w)}`:void 0,se=this.buildOrderBy(d$1),Me=this.buildLimit(g),$t=N?y` offset ${N}`:void 0,$e=y`${B}select${O} ${V} from ${P}${T}${ie}${C}${J}${se}${Me}${$t}`;return L.length>0?this.buildSetOperations($e,L):$e}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:o,orderBy:l,offset:c}}){let d=y`${e.getSQL()} `,y$1=y`${s.getSQL()}`,g;if(l&&l.length>0){let A=[];for(let $ of l)if(b$1($,Q))A.push(y.identifier($.name));else if(b$1($,v$1)){for(let B=0;B<$.queryChunks.length;B++){let O=$.queryChunks[B];b$1(O,Q)&&($.queryChunks[B]=y.identifier(this.casing.getColumnCasing(O)));}A.push(y`${$}`);}else A.push(y`${$}`);g=y` order by ${y.join(A,y`, `)}`;}let N=typeof o=="object"||typeof o=="number"&&o>=0?y` limit ${o}`:void 0,_=y.raw(`${t} ${i?"all ":""}`),L=c?y` offset ${c}`:void 0;return y`${d}${_}${y$1}${g}${N}${L}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:o,select:l}){let c=[],d=e[p.Symbol.Columns],y$1=Object.entries(d).filter(([$,B])=>!B.shouldDisableInsert()),g=y$1.map(([,$])=>y.identifier(this.casing.getColumnCasing($)));if(l){let $=t;b$1($,v$1)?c.push($):c.push($.getSQL());}else {let $=t;c.push(y.raw("values "));for(let[B,O]of $.entries()){let V=[];for(let[P,T]of y$1){let ie=O[P];if(ie===void 0||b$1(ie,x$1)&&ie.value===void 0){let J;if(T.default!==null&&T.default!==void 0)J=b$1(T.default,v$1)?T.default:y.param(T.default,T);else if(T.defaultFn!==void 0){let w=T.defaultFn();J=b$1(w,v$1)?w:y.param(w,T);}else if(!T.default&&T.onUpdateFn!==void 0){let w=T.onUpdateFn();J=b$1(w,v$1)?w:y.param(w,T);}else J=y`null`;V.push(J);}else V.push(ie);}c.push(V),B<$.length-1&&c.push(y`, `);}}let N=this.buildWithCTE(o),_=y.join(c),L=s?y` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,A=i?.length?y.join(i):void 0;return y`${N}insert into ${e} ${g} ${_}${A}${L}`}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:o,queryConfig:l,tableAlias:c,nestedQueryRelation:d$1,joinOn:y$1}){let g=[],N,_,L=[],A,$=[];if(l===true)g=Object.entries(o.columns).map(([V,P])=>({dbKey:P.name,tsKey:V,field:X(P,c),relationTableTsKey:void 0,isJson:false,selection:[]}));else {let O=Object.fromEntries(Object.entries(o.columns).map(([w,C])=>[w,X(C,c)]));if(l.where){let w=typeof l.where=="function"?l.where(O,Oi()):l.where;A=w&&ve(w,c);}let V=[],P=[];if(l.columns){let w=false;for(let[C,se]of Object.entries(l.columns))se!==void 0&&C in o.columns&&(!w&&se===true&&(w=true),P.push(C));P.length>0&&(P=w?P.filter(C=>l.columns?.[C]===true):Object.keys(o.columns).filter(C=>!P.includes(C)));}else P=Object.keys(o.columns);for(let w of P){let C=o.columns[w];V.push({tsKey:w,value:C});}let T=[];l.with&&(T=Object.entries(l.with).filter(w=>!!w[1]).map(([w,C])=>({tsKey:w,queryConfig:C,relation:o.relations[w]})));let ie;if(l.extras){ie=typeof l.extras=="function"?l.extras(O,{sql:y}):l.extras;for(let[w,C]of Object.entries(ie))V.push({tsKey:w,value:Tt(C,c)});}for(let{tsKey:w,value:C}of V)g.push({dbKey:b$1(C,v$1.Aliased)?C.fieldAlias:o.columns[w].name,tsKey:w,field:b$1(C,d)?X(C,c):C,relationTableTsKey:void 0,isJson:false,selection:[]});let J=typeof l.orderBy=="function"?l.orderBy(O,ji()):l.orderBy??[];Array.isArray(J)||(J=[J]),L=J.map(w=>b$1(w,d)?X(w,c):ve(w,c)),N=l.limit,_=l.offset;for(let{tsKey:w,queryConfig:C,relation:se}of T){let Me=Ii(t,i,se),$t=r(se.referencedTable),$e=i[$t],H=`${c}_${w}`,G=je(...Me.fields.map((As,Bs)=>st(X(Me.references[Bs],H),X(As,c)))),Ve=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[$e],tableConfig:t[$e],queryConfig:b$1(se,de)?C===true?{limit:1}:{...C,limit:1}:C,tableAlias:H,joinOn:G,nestedQueryRelation:se}),Ls=y`(${Ve.sql})`.as(w);g.push({dbKey:w,tsKey:w,field:Ls,relationTableTsKey:$e,isJson:true,selection:Ve.selection});}}if(g.length===0)throw new Se({message:`No fields selected for table "${o.tsName}" ("${c}"). 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 B;if(A=je(y$1,A),d$1){let O=y`json_array(${y.join(g.map(({field:T})=>b$1(T,Q)?y.identifier(this.casing.getColumnCasing(T)):b$1(T,v$1.Aliased)?T.sql:T),y`, `)})`;b$1(d$1,Ie)&&(O=y`coalesce(json_group_array(${O}), json_array())`);let V=[{dbKey:"data",tsKey:"data",field:O.as("data"),isJson:true,relationTableTsKey:o.tsName,selection:g}];N!==void 0||_!==void 0||L.length>0?(B=this.buildSelectQuery({table:qe(s,c),fields:{},fieldsFlat:[{path:[],field:y.raw("*")}],where:A,limit:N,offset:_,orderBy:L,setOperators:[]}),A=void 0,N=void 0,_=void 0,L=void 0):B=qe(s,c),B=this.buildSelectQuery({table:b$1(B,j)?B:new j$1(B,{},c),fields:{},fieldsFlat:V.map(({field:T})=>({path:[],field:b$1(T,d)?X(T,c):T})),joins:$,where:A,limit:N,offset:_,orderBy:L,setOperators:[]});}else B=this.buildSelectQuery({table:qe(s,c),fields:{},fieldsFlat:g.map(({field:O})=>({path:[],field:b$1(O,d)?X(O,c):O})),joins:$,where:A,limit:N,offset:_,orderBy:L,setOperators:[]});return {tableTsKey:o.tsName,sql:B,selection:g}}},lt=class extends xe{static[a$2]="SQLiteSyncDialect";migrate(e,t,i){let s=i===void 0||typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",o=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(o);let c=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 d of e)if(!c||Number(c[2])<d.folderMillis){for(let y$1 of d.sql)t.run(y.raw(y$1));t.run(y`INSERT INTO ${y.identifier(s)} ("hash", "created_at") VALUES(${d.hash}, ${d.folderMillis})`);}t.run(y`COMMIT`);}catch(d){throw t.run(y`ROLLBACK`),d}}},Di=class extends xe{static[a$2]="SQLiteAsyncDialect";async migrate(e,t,i){let s=i===void 0||typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",o=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(o);let c=(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 d=>{for(let y$1 of e)if(!c||Number(c[2])<y$1.folderMillis){for(let g of y$1.sql)await d.run(y.raw(g));await d.run(y`INSERT INTO ${y.identifier(s)} ("hash", "created_at") VALUES(${y$1.hash}, ${y$1.folderMillis})`);}});}};});var ut,Pi=a$1(()=>{c();ut=class{static[a$2]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}};});function mt(r,e){return (t,i,...s)=>{let o=[i,...s].map(l=>({type:r,isAll:e,rightSelect:l}));for(let l of o)if(!Qe(t.getSelectedFields(),l.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(o)}}var W,$r,ct,Ps,Es,ks,Ms,Vs,Tr=a$1(()=>{c();Pi();ae();we();C();l();s();U();n();Ce();Ke();W=class{static[a$2]="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$1)?i=Object.fromEntries(Object.keys(e._.selectedFields).map(s=>[s,e[s]])):b$1(e,te)?i=e[m].selectedFields:b$1(e,v$1)?i={}:i=We(e),new ct({table:e,fields:i,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}},$r=class extends ut{static[a$2]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:o,withList:l,distinct:c}){super(),this.config={withList:l,table:e,fields:{...t},distinct:c,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=o,this._={selectedFields:t,config:this.config},this.tableName=Le(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:true}:{};for(let d of Y(e))this.usedTables.add(d);}getUsedTables(){return [...this.usedTables]}createJoin(e){return (t,i)=>{let s=this.tableName,o=Le(t);for(let l of Y(t))this.usedTables.add(l);if(typeof o=="string"&&this.config.joins?.some(l=>l.alias===o))throw new Error(`Alias "${o}" 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 o=="string"&&!b$1(t,v$1))){let l=b$1(t,j$1)?t._.selectedFields:b$1(t,B)?t[m].selectedFields:t[p.Symbol.Columns];this.config.fields[o]=l;}if(typeof i=="function"&&(i=i(new Proxy(this.config.fields,new v({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,joinType:e,alias:o}),typeof o=="string")switch(e){case "left":{this.joinsNotNullableMap[o]=false;break}case "right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,false])),this.joinsNotNullableMap[o]=true;break}case "cross":case "inner":{this.joinsNotNullableMap[o]=true;break}case "full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,false])),this.joinsNotNullableMap[o]=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(Ps()):i;if(!Qe(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 v({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new v({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 v({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 v({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$1(this.getSQL(),this.config.fields,e,false,[...new Set(t)]),new v({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new v({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}},ct=class extends $r{static[a$2]="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=z(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()}};Wr(ct,[D]);Ps=()=>({union:Es,unionAll:ks,intersect:Ms,except:Vs}),Es=mt("union",false),ks=mt("union",true),Ms=mt("intersect",false),Vs=mt("except",false);});var pe,ft=a$1(()=>{c();we();Nr();l();Tr();pe=class{static[a$2]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=b$1(e,xe)?e:void 0,this.dialectConfig=b$1(e,xe)?void 0:e;}$with=(e,t)=>{let i=this;return {as:o=>(typeof o=="function"&&(o=o(i)),new Proxy(new k(o.getSQL(),t??("getSelectedFields"in o?o.getSelectedFields()??{}:{}),e,true),new v({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;function i(o){return new W({fields:o??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function s(o){return new W({fields:o??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:true})}return {select:i,selectDistinct:s}}select(e){return new W({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new W({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:true})}getDialect(){return this.dialect||(this.dialect=new lt(this.dialectConfig)),this.dialect}};});var Re,dt,Ei=a$1(()=>{c();ae();C();le();s();U();Ce();ft();Re=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[a$2]="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={},o=this.table[p.Symbol.Columns];for(let l of Object.keys(i)){let c=i[l];s[l]=b$1(c,v$1)?c:new x$1(c,o[l]);}return s});return new dt(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e=="function"?e(new pe):e;if(!b$1(t,v$1)&&!Qe(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 dt(this.table,t,this.session,this.dialect,this.withList,true)}},dt=class extends D{constructor(e,t,i,s,o,l){super(),this.session=i,this.dialect=s,this.config={table:e,values:t,withList:o,select:l};}static[a$2]="SQLiteInsert";config;returning(e=this.config.table[j.Symbol.Columns]){return this.config.returning=z(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,o=Array.isArray(e.target)?y`${e.target}`:y`${[e.target]}`,l=this.dialect.buildUpdateSet(this.config.table,ze(this.config.table,e.set));return this.config.onConflict.push(y` on conflict ${o}${i} do update set ${l}${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 ki=a$1(()=>{});var Fe,Cr,Mi=a$1(()=>{c();ae();we();le();l();s();U();n();Ce();Ke();Fe=class{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s;}static[a$2]="SQLiteUpdateBuilder";set(e){return new Cr(this.table,ze(this.table,e),this.session,this.dialect,this.withList)}},Cr=class extends D{constructor(e,t,i,s,o){super(),this.session=i,this.dialect=s,this.config={set:t,table:e,withList:o,joins:[]};}static[a$2]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return (t,i)=>{let s=Le(t);if(typeof s=="string"&&this.config.joins.some(o=>o.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof i=="function"){let o=this.config.from?b$1(t,j)?t[p.Symbol.Columns]:b$1(t,j$1)?t._.selectedFields:b$1(t,te)?t[m].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[p.Symbol.Columns],new v({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),o&&new Proxy(o,new v({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 v({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[j.Symbol.Columns]){return this.config.returning=z(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 _r=a$1(()=>{si();Ei();ft();Tr();ki();Mi();});var pt,Vi=a$1(()=>{c();C();pt=class r extends v$1{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$2]="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 ht,De,yt,Ui=a$1(()=>{c();ae();at();ht=class{constructor(e,t,i,s,o,l,c,d){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=s,this.table=o,this.tableConfig=l,this.dialect=c,this.session=d;}static[a$2]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new yt(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new De(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return this.mode==="sync"?new yt(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new De(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}},De=class extends D{constructor(e,t,i,s,o,l,c,d,y){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=s,this.tableConfig=o,this.dialect=l,this.session=c,this.config=d,this.mode=y;}static[a$2]="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,o)=>{let l=s.map(c=>ot(this.schema,this.tableConfig,c,t.selection,o));return this.mode==="first"?l[0]:l})}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()}},yt=class extends De{static[a$2]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}};});var Ne,Ji=a$1(()=>{c();ae();Ne=class extends D{constructor(e,t,i,s,o){super(),this.execute=e,this.getSQL=t,this.dialect=s,this.mapBatchResult=o,this.config={action:i};}static[a$2]="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 gt,qr=a$1(()=>{c();we();C();_r();l();Vi();Ui();Ji();gt=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 o=this.query;if(this._.schema)for(let[l,c]of Object.entries(this._.schema))o[l]=new ht(e,s.fullSchema,this._.schema,this._.tableNamesMap,s.fullSchema[l],c,t,i);this.$cache={invalidate:async l=>{}};}static[a$2]="BaseSQLiteDatabase";query;$with=(e,t)=>{let i=this;return {as:o=>(typeof o=="function"&&(o=o(new pe(i.dialect))),new Proxy(new k(o.getSQL(),t??("getSelectedFields"in o?o.getSelectedFields()??{}:{}),e,true),new v({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new pt({source:e,filters:t,session:this.session})}with(...e){let t=this;function i(d){return new W({fields:d??void 0,session:t.session,dialect:t.dialect,withList:e})}function s(d){return new W({fields:d??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:true})}function o(d){return new Fe(d,t.session,t.dialect,e)}function l(d){return new Re(d,t.session,t.dialect,e)}function c(d){return new Oe(d,t.session,t.dialect,e)}return {select:i,selectDistinct:s,update:o,insert:l,delete:c}}select(e){return new W({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new W({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:true})}update(e){return new Fe(e,this.session,this.dialect)}$cache;insert(e){return new Re(e,this.session,this.dialect)}delete(e){return new Oe(e,this.session,this.dialect)}run(e){let t=typeof e=="string"?y.raw(e):e.getSQL();return this.resultKind==="async"?new Ne(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 Ne(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 Ne(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 Ne(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 Qr(r,e){let t=`${r}-${JSON.stringify(e)}`,s=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",s);return [...new Uint8Array(o)].map(d=>d.toString(16).padStart(2,"0")).join("")}var vr,bt,zi=a$1(()=>{c();vr=class{static[a$2]="Cache"},bt=class extends vr{strategy(){return "all"}static[a$2]="NoopCache";async get(e){}async put(e,t,i,s){}async onMutate(e){}};});var Lr,Wi,Hi,Yi,Gi=a$1(()=>{zi();c();tt();ae();qr();Lr=class extends D{constructor(e){super(),this.resultCb=e;}static[a$2]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}},Wi=class{constructor(e,t,i,s,o,l){this.mode=e,this.executeMethod=t,this.query=i,this.cache=s,this.queryMetadata=o,this.cacheConfig=l,s&&s.strategy()==="all"&&l===void 0&&(this.cacheConfig={enable:true,autoInvalidate:true}),this.cacheConfig?.enable||(this.cacheConfig=void 0);}static[a$2]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,i){if(this.cache===void 0||b$1(this.cache,bt)||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 Qr(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(s===void 0){let o;try{o=await i();}catch(l){throw new ue(e,t,l)}return await this.cache.put(this.cacheConfig.tag??await Qr(e,t),o,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),o}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 Lr(()=>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)}}},Hi=class{constructor(e){this.dialect=e;}static[a$2]="SQLiteSession";prepareOneTimeQuery(e,t,i,s,o,l,c){return this.prepareQuery(e,t,i,s,o,l,c)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(i){throw new Se({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")}},Yi=class extends gt{constructor(e,t,i,s,o=0){super(e,t,i,s),this.schema=s,this.nestedIndex=o;}static[a$2]="SQLiteTransaction";rollback(){throw new et}};});var Zi=a$1(()=>{});var ts=a$1(()=>{c();we();U();ft();le();Ke();});var R=a$1(()=>{Ur();zr();fr();qr();Nr();vt();ri();ii();_r();Gi();Zi();le();Ot();Ce();ts();});var Ar,rs,is,ss=a$1(()=>{c();Ar=class{static[a$2]="ConsoleLogWriter";write(e){console.log(e);}},rs=class{static[a$2]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new Ar;}logQuery(e,t){let i=t.map(o=>{try{return JSON.stringify(o)}catch{return String(o)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`);}},is=class{static[a$2]="NoopLogger";logQuery(){}};});var ns=a$1(()=>{});var re=a$1(()=>{Je();g();e();c();tt();ss();ns();ae();at();xr();l();s();U();n();});var os,Br,Or=a$1(()=>{R();re();os=["pending","in_progress","completed"],Br=x("todos",{id:f("id").primaryKey({autoIncrement:true}),title:a("title").notNull(),description:a("description"),status:a("status",{enum:os}).notNull().default("pending"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Us,as=a$1(()=>{R();re();Or();Us=x("todo_attachments",{id:f("id").primaryKey({autoIncrement:true}),todoId:f("todo_id").notNull().references(()=>Br.id,{onDelete:"cascade"}),fileName:a("file_name").notNull(),originalName:a("original_name").notNull(),mimeType:a("mime_type").notNull(),size:f("size").notNull(),path:a("path").notNull(),uploadedBy:a("uploaded_by"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Js,ls=a$1(()=>{R();re();Js=x("notifications",{id:a("id").primaryKey(),type:a("type").notNull(),title:a("title").notNull(),message:a("message").notNull(),read:f("read",{mode:"boolean"}).notNull().default(false),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Ee,St=a$1(()=>{R();Ee=x("permissions",{id:a("id").primaryKey(),code:a("code").notNull().unique(),name:a("name").notNull(),label:a("label").notNull(),category:a("category").notNull(),description:a("description"),sortOrder:f("sort_order").default(0),isActive:f("is_active",{mode:"boolean"}).default(true),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:f("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var ke,xt=a$1(()=>{R();ke=x("roles",{id:a("id").primaryKey(),code:a("code").notNull().unique(),name:a("name").notNull(),label:a("label").notNull(),description:a("description"),isSystem:f("is_system",{mode:"boolean"}).default(false),isActive:f("is_active",{mode:"boolean"}).default(true),sortOrder:f("sort_order").default(0),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:f("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var zs,us=a$1(()=>{R();xt();St();zs=x("role_permissions",{roleId:a("role_id").notNull().references(()=>ke.id,{onDelete:"cascade"}),permissionId:a("permission_id").notNull().references(()=>Ee.id,{onDelete:"cascade"}),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pk:Ze({columns:[r.roleId,r.permissionId]})}));});var Ws,cs=a$1(()=>{R();xt();Ws=x("user_roles",{id:a("id").primaryKey(),userId:a("user_id").notNull(),roleId:a("role_id").notNull().references(()=>ke.id,{onDelete:"cascade"}),assignedBy:a("assigned_by"),assignedAt:f("assigned_at",{mode:"timestamp"}).$defaultFn(()=>new Date),expiresAt:f("expires_at",{mode:"timestamp"}),isActive:f("is_active",{mode:"boolean"}).default(true)});});var jr,Ir=a$1(()=>{R();jr=x("routes",{id:a("id").primaryKey(),path:a("path").notNull(),method:a("method").notNull(),name:a("name"),description:a("description"),module:a("module"),isPublic:f("is_public",{mode:"boolean"}).default(false),isActive:f("is_active",{mode:"boolean"}).default(true),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date),updatedAt:f("updated_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pathMethodUnique:Hr().on(r.path,r.method)}));});var Hs,ms=a$1(()=>{R();St();Ir();Hs=x("permission_routes",{permissionId:a("permission_id").notNull().references(()=>Ee.id,{onDelete:"cascade"}),routeId:a("route_id").notNull().references(()=>jr.id,{onDelete:"cascade"}),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)},r=>({pk:Ze({columns:[r.permissionId,r.routeId]})}));});var Ys,fs=a$1(()=>{R();Ys=x("permission_audit_logs",{id:a("id").primaryKey(),userId:a("user_id").notNull(),action:a("action").notNull(),resourceType:a("resource_type").notNull(),resourceId:a("resource_id"),oldValue:a("old_value"),newValue:a("new_value"),ipAddress:a("ip_address"),userAgent:a("user_agent"),createdAt:f("created_at",{mode:"timestamp"}).$defaultFn(()=>new Date)});});var ds,Gs,ps=a$1(()=>{R();re();ds=["pending","processing","completed","cancelled","disputed"],Gs=x("orders",{id:f("id").primaryKey({autoIncrement:true}),orderNo:a("order_no").notNull(),customerName:a("customer_name").notNull(),customerEmail:a("customer_email").notNull(),productName:a("product_name").notNull(),amount:f("amount").notNull(),status:a("status",{enum:ds}).notNull().default("pending"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var hs,ys,gs,Zs,bs,Xs,ws=a$1(()=>{R();re();hs=["open","in_progress","waiting_customer","resolved","closed"],ys=["low","medium","high","urgent"],gs=["technical","billing","feature_request","bug_report","general"],Zs=["customer","admin","system"],bs=x("tickets",{id:f("id").primaryKey({autoIncrement:true}),ticketNo:a("ticket_no").notNull(),customerName:a("customer_name").notNull(),customerEmail:a("customer_email").notNull(),subject:a("subject").notNull(),description:a("description").notNull(),status:a("status",{enum:hs}).notNull().default("open"),priority:a("priority",{enum:ys}).notNull().default("medium"),category:a("category",{enum:gs}).notNull(),assignedTo:a("assigned_to"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)}),Xs=x("ticket_replies",{id:f("id").primaryKey({autoIncrement:true}),ticketId:f("ticket_id").notNull().references(()=>bs.id,{onDelete:"cascade"}),content:a("content").notNull(),author:a("author").notNull(),isCustomer:f("is_customer",{mode:"boolean"}).notNull().default(false),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Ss,xs,en,Ns=a$1(()=>{R();re();Ss=["refund","product_quality","service_quality","delivery","other"],xs=["pending","investigating","resolved","rejected"],en=x("disputes",{id:f("id").primaryKey({autoIncrement:true}),disputeNo:a("dispute_no").notNull(),orderId:a("order_id").notNull(),orderNo:a("order_no").notNull(),customerName:a("customer_name").notNull(),customerEmail:a("customer_email").notNull(),type:a("type",{enum:Ss}).notNull(),status:a("status",{enum:xs}).notNull().default("pending"),description:a("description").notNull(),resolution:a("resolution"),amount:f("amount").notNull(),resolvedAt:f("resolved_at",{mode:"timestamp"}),resolvedBy:a("resolved_by"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var $s,Ts,tn,Cs=a$1(()=>{R();re();$s=["draft","published","archived"],Ts=["article","announcement","tutorial","news","policy"],tn=x("contents",{id:f("id").primaryKey({autoIncrement:true}),title:a("title").notNull(),body:a("body").notNull(),excerpt:a("excerpt"),category:a("category",{enum:Ts}).notNull(),tags:a("tags"),status:a("status",{enum:$s}).notNull().default("draft"),author:a("author").notNull(),viewCount:f("view_count").notNull().default(0),likeCount:f("like_count").notNull().default(0),publishedAt:f("published_at",{mode:"timestamp"}),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var rn,_s=a$1(()=>{R();re();rn=x("developers",{id:a("id").primaryKey(),username:a("username").notNull().unique(),email:a("email").notNull().unique(),passwordHash:a("password_hash").notNull(),role:a("role").notNull().default("developer"),apiKey:a("api_key").notNull().unique(),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)});});var Kr,Nt,sn,nn,qs,on,vs=a$1(()=>{R();re();Kr=["pending","approved","rejected"],Nt=x("plugins",{id:a("id").primaryKey(),name:a("name").notNull(),slug:a("slug").notNull().unique(),description:a("description").notNull().default(""),readme:a("readme"),authorId:a("author_id").notNull(),authorName:a("author_name").notNull(),repositoryUrl:a("repository_url"),homepageUrl:a("homepage_url"),npmPackage:a("npm_package"),license:a("license"),version:a("version").notNull().default("0.0.1"),status:a("status",{enum:Kr}).notNull().default("pending"),downloadCount:f("download_count").notNull().default(0),viewCount:f("view_count").notNull().default(0),featured:f("featured",{mode:"boolean"}).notNull().default(false),screenshotUrl:a("screenshot_url"),siteUrls:a("site_urls"),tags:a("tags"),commands:a("commands"),rejectReason:a("reject_reason"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`),updatedAt:f("updated_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)}),sn=x("plugin_versions",{id:a("id").primaryKey(),pluginId:a("plugin_id").notNull().references(()=>Nt.id,{onDelete:"cascade"}),version:a("version").notNull(),changelog:a("changelog"),packageUrl:a("package_url"),fileSize:f("file_size"),checksum:a("checksum"),status:a("status",{enum:Kr}).notNull().default("pending"),publishedAt:f("published_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)},r=>({pluginVersionUnique:Ye("plugin_version_unique").on(r.pluginId,r.version)})),nn=x("plugin_reviews",{id:a("id").primaryKey(),pluginId:a("plugin_id").notNull().references(()=>Nt.id,{onDelete:"cascade"}),userId:a("user_id").notNull(),userName:a("user_name").notNull(),rating:f("rating").notNull(),title:a("title"),content:a("content"),createdAt:f("created_at",{mode:"timestamp"}).notNull().default(y`(unixepoch() * 1000)`)},r=>({pluginUserUnique:Ye("plugin_review_user_unique").on(r.pluginId,r.userId)})),qs=x("plugin_categories",{id:a("id").primaryKey(),name:a("name").notNull().unique(),slug:a("slug").notNull().unique(),description:a("description"),icon:a("icon"),sortOrder:f("sort_order").notNull().default(0)}),on=x("plugin_category_mappings",{pluginId:a("plugin_id").notNull().references(()=>Nt.id,{onDelete:"cascade"}),categoryId:a("category_id").notNull().references(()=>qs.id,{onDelete:"cascade"})},r=>({mappingUnique:Ye("plugin_category_mapping_unique").on(r.pluginId,r.categoryId)}));});var an,Qs=a$1(()=>{R();an=x("tenants",{id:f("id").primaryKey({autoIncrement:true}),name:a("name").notNull(),slug:a("slug").notNull().unique(),status:a("status",{enum:["active","suspended","trial"]}).notNull().default("trial"),plan:a("plan",{enum:["free","starter","pro","enterprise"]}).notNull().default("free"),maxUsers:f("max_users").notNull().default(5),settings:a("settings"),createdAt:a("created_at").notNull(),updatedAt:a("updated_at").notNull()});});var ln={};b(ln,{contentCategories:()=>Ts,contentStatuses:()=>$s,contents:()=>tn,developers:()=>rn,disputeStatuses:()=>xs,disputeTypes:()=>Ss,disputes:()=>en,notifications:()=>Js,orderStatuses:()=>ds,orders:()=>Gs,permissionAuditLogs:()=>Ys,permissionRouteMappings:()=>Hs,permissions:()=>Ee,pluginCategories:()=>qs,pluginCategoryMappings:()=>on,pluginReviews:()=>nn,pluginStatus:()=>Kr,pluginVersions:()=>sn,plugins:()=>Nt,rolePermissions:()=>zs,roles:()=>ke,routes:()=>jr,tenants:()=>an,ticketCategories:()=>gs,ticketPriorities:()=>ys,ticketReplies:()=>Xs,ticketReplyAuthorRoles:()=>Zs,ticketStatuses:()=>hs,tickets:()=>bs,todoAttachments:()=>Us,todoStatus:()=>os,todos:()=>Br,userRoles:()=>Ws});var un=a$1(()=>{Or();as();ls();St();xt();us();cs();Ir();ms();fs();ps();ws();Ns();Cs();_s();vs();Qs();});export{tn as $,Yi as A,Gi as B,R as C,os as D,Br as E,Us as F,Js as G,Ee as H,ke as I,zs as J,Ws as K,jr as L,Hs as M,Ys as N,ds as O,Gs as P,hs as Q,ys as R,gs as S,Zs as T,bs as U,Xs as V,Ss as W,xs as X,en as Y,$s as Z,Ts as _,rs as a,rn as aa,is as b,Kr as ba,ss as c,Nt as ca,Cn as d,sn as da,_n as e,nn as ea,U as f,qs as fa,st as g,on as ga,je as h,an as ha,mi as i,ln as ia,pi as j,un as ja,yi as k,Ci as l,Li as m,Ai as n,Aa as o,Ba as p,at as q,re as r,Di as s,Nr as t,gt as u,qr as v,bt as w,zi as x,Wi as y,Hi as z};
|