@congzhen/changewayguard 6.8.12
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/LICENSE +21 -0
- package/README.md +270 -0
- package/dashboard-dist/api/104.index.js +1420 -0
- package/dashboard-dist/api/104.index.js.map +1 -0
- package/dashboard-dist/api/113.index.js +496 -0
- package/dashboard-dist/api/113.index.js.map +1 -0
- package/dashboard-dist/api/18.index.js +67 -0
- package/dashboard-dist/api/18.index.js.map +1 -0
- package/dashboard-dist/api/217.index.js +44 -0
- package/dashboard-dist/api/217.index.js.map +1 -0
- package/dashboard-dist/api/222.index.js +90 -0
- package/dashboard-dist/api/222.index.js.map +1 -0
- package/dashboard-dist/api/25.index.js +3562 -0
- package/dashboard-dist/api/25.index.js.map +1 -0
- package/dashboard-dist/api/280.index.js +206 -0
- package/dashboard-dist/api/280.index.js.map +1 -0
- package/dashboard-dist/api/369.index.js +115 -0
- package/dashboard-dist/api/369.index.js.map +1 -0
- package/dashboard-dist/api/377.index.js +1176 -0
- package/dashboard-dist/api/377.index.js.map +1 -0
- package/dashboard-dist/api/411.index.js +4250 -0
- package/dashboard-dist/api/411.index.js.map +1 -0
- package/dashboard-dist/api/424.index.js +135 -0
- package/dashboard-dist/api/424.index.js.map +1 -0
- package/dashboard-dist/api/573.index.js +806 -0
- package/dashboard-dist/api/573.index.js.map +1 -0
- package/dashboard-dist/api/598.index.js +328 -0
- package/dashboard-dist/api/598.index.js.map +1 -0
- package/dashboard-dist/api/62.index.js +4151 -0
- package/dashboard-dist/api/62.index.js.map +1 -0
- package/dashboard-dist/api/67.index.js +23383 -0
- package/dashboard-dist/api/67.index.js.map +1 -0
- package/dashboard-dist/api/678.index.js +2734 -0
- package/dashboard-dist/api/678.index.js.map +1 -0
- package/dashboard-dist/api/698.index.js +1896 -0
- package/dashboard-dist/api/698.index.js.map +1 -0
- package/dashboard-dist/api/720.index.js +98 -0
- package/dashboard-dist/api/720.index.js.map +1 -0
- package/dashboard-dist/api/830.index.js +95 -0
- package/dashboard-dist/api/830.index.js.map +1 -0
- package/dashboard-dist/api/831.index.js +99 -0
- package/dashboard-dist/api/831.index.js.map +1 -0
- package/dashboard-dist/api/84.index.js +64 -0
- package/dashboard-dist/api/84.index.js.map +1 -0
- package/dashboard-dist/api/900.index.js +65 -0
- package/dashboard-dist/api/900.index.js.map +1 -0
- package/dashboard-dist/api/917.index.js +88 -0
- package/dashboard-dist/api/917.index.js.map +1 -0
- package/dashboard-dist/api/948.index.js +64 -0
- package/dashboard-dist/api/948.index.js.map +1 -0
- package/dashboard-dist/api/953.index.js +67 -0
- package/dashboard-dist/api/953.index.js.map +1 -0
- package/dashboard-dist/api/975.index.js +374 -0
- package/dashboard-dist/api/975.index.js.map +1 -0
- package/dashboard-dist/api/drizzle/sqlite/0000_short_captain_stacy.sql +70 -0
- package/dashboard-dist/api/drizzle/sqlite/0001_closed_magus.sql +10 -0
- package/dashboard-dist/api/drizzle/sqlite/0002_agent_capability_observation.sql +38 -0
- package/dashboard-dist/api/drizzle/sqlite/0003_auth_magic_link.sql +28 -0
- package/dashboard-dist/api/drizzle/sqlite/0004_static_scan_fields.sql +8 -0
- package/dashboard-dist/api/drizzle/sqlite/0005_gateway_activity.sql +24 -0
- package/dashboard-dist/api/drizzle/sqlite/0006_sour_marauders.sql +41 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0000_snapshot.json +460 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0001_snapshot.json +536 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0006_snapshot.json +1249 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/_journal.json +55 -0
- package/dashboard-dist/api/index.js +27340 -0
- package/dashboard-dist/api/index.js.map +1 -0
- package/dashboard-dist/api/package.json +16 -0
- package/dashboard-dist/api/sourcemap-register.cjs +1 -0
- package/dashboard-dist/web/assets/index-CqWIeBTD.js +158 -0
- package/dashboard-dist/web/assets/index-Dw7--9q4.css +1 -0
- package/dashboard-dist/web/changeway-logo.png +0 -0
- package/dashboard-dist/web/favicon.svg +29 -0
- package/dashboard-dist/web/index.html +14 -0
- package/dashboard-dist/web/logo.svg +16 -0
- package/dist/agent/auth.d.ts +37 -0
- package/dist/agent/auth.d.ts.map +1 -0
- package/dist/agent/auth.js +151 -0
- package/dist/agent/auth.js.map +1 -0
- package/dist/agent/behavior-detector.d.ts +150 -0
- package/dist/agent/behavior-detector.d.ts.map +1 -0
- package/dist/agent/behavior-detector.js +573 -0
- package/dist/agent/behavior-detector.js.map +1 -0
- package/dist/agent/business-reporter.d.ts +114 -0
- package/dist/agent/business-reporter.d.ts.map +1 -0
- package/dist/agent/business-reporter.js +359 -0
- package/dist/agent/business-reporter.js.map +1 -0
- package/dist/agent/config-sync.d.ts +70 -0
- package/dist/agent/config-sync.d.ts.map +1 -0
- package/dist/agent/config-sync.js +133 -0
- package/dist/agent/config-sync.js.map +1 -0
- package/dist/agent/config.d.ts +97 -0
- package/dist/agent/config.d.ts.map +1 -0
- package/dist/agent/config.js +359 -0
- package/dist/agent/config.js.map +1 -0
- package/dist/agent/content-injection-scanner.d.ts +35 -0
- package/dist/agent/content-injection-scanner.d.ts.map +1 -0
- package/dist/agent/content-injection-scanner.js +270 -0
- package/dist/agent/content-injection-scanner.js.map +1 -0
- package/dist/agent/engine-log-writer.d.ts +6 -0
- package/dist/agent/engine-log-writer.d.ts.map +1 -0
- package/dist/agent/engine-log-writer.js +18 -0
- package/dist/agent/engine-log-writer.js.map +1 -0
- package/dist/agent/env.d.ts +19 -0
- package/dist/agent/env.d.ts.map +1 -0
- package/dist/agent/env.js +43 -0
- package/dist/agent/env.js.map +1 -0
- package/dist/agent/event-reporter.d.ts +87 -0
- package/dist/agent/event-reporter.d.ts.map +1 -0
- package/dist/agent/event-reporter.js +315 -0
- package/dist/agent/event-reporter.js.map +1 -0
- package/dist/agent/file-watcher.d.ts +50 -0
- package/dist/agent/file-watcher.d.ts.map +1 -0
- package/dist/agent/file-watcher.js +135 -0
- package/dist/agent/file-watcher.js.map +1 -0
- package/dist/agent/fs-utils.d.ts +22 -0
- package/dist/agent/fs-utils.d.ts.map +1 -0
- package/dist/agent/fs-utils.js +41 -0
- package/dist/agent/fs-utils.js.map +1 -0
- package/dist/agent/gateway-manager.d.ts +59 -0
- package/dist/agent/gateway-manager.d.ts.map +1 -0
- package/dist/agent/gateway-manager.js +583 -0
- package/dist/agent/gateway-manager.js.map +1 -0
- package/dist/agent/hook-types.d.ts +276 -0
- package/dist/agent/hook-types.d.ts.map +1 -0
- package/dist/agent/hook-types.js +51 -0
- package/dist/agent/hook-types.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +8 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/prompt-gate.d.ts +13 -0
- package/dist/agent/prompt-gate.d.ts.map +1 -0
- package/dist/agent/prompt-gate.js +28 -0
- package/dist/agent/prompt-gate.js.map +1 -0
- package/dist/agent/prompt-input.d.ts +9 -0
- package/dist/agent/prompt-input.d.ts.map +1 -0
- package/dist/agent/prompt-input.js +158 -0
- package/dist/agent/prompt-input.js.map +1 -0
- package/dist/agent/prompt-output.d.ts +4 -0
- package/dist/agent/prompt-output.d.ts.map +1 -0
- package/dist/agent/prompt-output.js +19 -0
- package/dist/agent/prompt-output.js.map +1 -0
- package/dist/agent/runner.d.ts +23 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +154 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/sanitizer.d.ts +10 -0
- package/dist/agent/sanitizer.d.ts.map +1 -0
- package/dist/agent/sanitizer.js +175 -0
- package/dist/agent/sanitizer.js.map +1 -0
- package/dist/agent/scan-activity.d.ts +18 -0
- package/dist/agent/scan-activity.d.ts.map +1 -0
- package/dist/agent/scan-activity.js +32 -0
- package/dist/agent/scan-activity.js.map +1 -0
- package/dist/agent/types.d.ts +177 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +5 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent/workspace-scanner.d.ts +35 -0
- package/dist/agent/workspace-scanner.d.ts.map +1 -0
- package/dist/agent/workspace-scanner.js +137 -0
- package/dist/agent/workspace-scanner.js.map +1 -0
- package/dist/dashboard-launcher.d.ts +52 -0
- package/dist/dashboard-launcher.d.ts.map +1 -0
- package/dist/dashboard-launcher.js +363 -0
- package/dist/dashboard-launcher.js.map +1 -0
- package/dist/gateway/activity.d.ts +52 -0
- package/dist/gateway/activity.d.ts.map +1 -0
- package/dist/gateway/activity.js +111 -0
- package/dist/gateway/activity.js.map +1 -0
- package/dist/gateway/config.d.ts +50 -0
- package/dist/gateway/config.d.ts.map +1 -0
- package/dist/gateway/config.js +200 -0
- package/dist/gateway/config.js.map +1 -0
- package/dist/gateway/gateway/activity.d.ts +52 -0
- package/dist/gateway/gateway/activity.d.ts.map +1 -0
- package/dist/gateway/gateway/activity.js +111 -0
- package/dist/gateway/gateway/activity.js.map +1 -0
- package/dist/gateway/gateway/config.d.ts +50 -0
- package/dist/gateway/gateway/config.d.ts.map +1 -0
- package/dist/gateway/gateway/config.js +200 -0
- package/dist/gateway/gateway/config.js.map +1 -0
- package/dist/gateway/gateway/handlers/anthropic.d.ts +12 -0
- package/dist/gateway/gateway/handlers/anthropic.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/anthropic.js +254 -0
- package/dist/gateway/gateway/handlers/anthropic.js.map +1 -0
- package/dist/gateway/gateway/handlers/gemini.d.ts +12 -0
- package/dist/gateway/gateway/handlers/gemini.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/gemini.js +101 -0
- package/dist/gateway/gateway/handlers/gemini.js.map +1 -0
- package/dist/gateway/gateway/handlers/models.d.ts +4 -0
- package/dist/gateway/gateway/handlers/models.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/models.js +36 -0
- package/dist/gateway/gateway/handlers/models.js.map +1 -0
- package/dist/gateway/gateway/handlers/openai.d.ts +16 -0
- package/dist/gateway/gateway/handlers/openai.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/openai.js +254 -0
- package/dist/gateway/gateway/handlers/openai.js.map +1 -0
- package/dist/gateway/gateway/index.d.ts +27 -0
- package/dist/gateway/gateway/index.d.ts.map +1 -0
- package/dist/gateway/gateway/index.js +293 -0
- package/dist/gateway/gateway/index.js.map +1 -0
- package/dist/gateway/gateway/mapping-store.d.ts +38 -0
- package/dist/gateway/gateway/mapping-store.d.ts.map +1 -0
- package/dist/gateway/gateway/mapping-store.js +74 -0
- package/dist/gateway/gateway/mapping-store.js.map +1 -0
- package/dist/gateway/gateway/restorer.d.ts +63 -0
- package/dist/gateway/gateway/restorer.d.ts.map +1 -0
- package/dist/gateway/gateway/restorer.js +284 -0
- package/dist/gateway/gateway/restorer.js.map +1 -0
- package/dist/gateway/gateway/sanitizer.d.ts +17 -0
- package/dist/gateway/gateway/sanitizer.d.ts.map +1 -0
- package/dist/gateway/gateway/sanitizer.js +228 -0
- package/dist/gateway/gateway/sanitizer.js.map +1 -0
- package/dist/gateway/gateway/types.d.ts +53 -0
- package/dist/gateway/gateway/types.d.ts.map +1 -0
- package/dist/gateway/gateway/types.js +5 -0
- package/dist/gateway/gateway/types.js.map +1 -0
- package/dist/gateway/handlers/anthropic.d.ts +12 -0
- package/dist/gateway/handlers/anthropic.d.ts.map +1 -0
- package/dist/gateway/handlers/anthropic.js +254 -0
- package/dist/gateway/handlers/anthropic.js.map +1 -0
- package/dist/gateway/handlers/gemini.d.ts +12 -0
- package/dist/gateway/handlers/gemini.d.ts.map +1 -0
- package/dist/gateway/handlers/gemini.js +101 -0
- package/dist/gateway/handlers/gemini.js.map +1 -0
- package/dist/gateway/handlers/models.d.ts +4 -0
- package/dist/gateway/handlers/models.d.ts.map +1 -0
- package/dist/gateway/handlers/models.js +36 -0
- package/dist/gateway/handlers/models.js.map +1 -0
- package/dist/gateway/handlers/openai.d.ts +16 -0
- package/dist/gateway/handlers/openai.d.ts.map +1 -0
- package/dist/gateway/handlers/openai.js +254 -0
- package/dist/gateway/handlers/openai.js.map +1 -0
- package/dist/gateway/index.d.ts +27 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +293 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/mapping-store.d.ts +38 -0
- package/dist/gateway/mapping-store.d.ts.map +1 -0
- package/dist/gateway/mapping-store.js +74 -0
- package/dist/gateway/mapping-store.js.map +1 -0
- package/dist/gateway/restorer.d.ts +63 -0
- package/dist/gateway/restorer.d.ts.map +1 -0
- package/dist/gateway/restorer.js +284 -0
- package/dist/gateway/restorer.js.map +1 -0
- package/dist/gateway/sanitizer.d.ts +17 -0
- package/dist/gateway/sanitizer.d.ts.map +1 -0
- package/dist/gateway/sanitizer.js +228 -0
- package/dist/gateway/sanitizer.js.map +1 -0
- package/dist/gateway/types.d.ts +53 -0
- package/dist/gateway/types.d.ts.map +1 -0
- package/dist/gateway/types.js +5 -0
- package/dist/gateway/types.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2084 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +5 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/store.d.ts +82 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +194 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/platform-client/index.d.ts +63 -0
- package/dist/platform-client/index.d.ts.map +1 -0
- package/dist/platform-client/index.js +294 -0
- package/dist/platform-client/index.js.map +1 -0
- package/dist/platform-client/types.d.ts +109 -0
- package/dist/platform-client/types.d.ts.map +1 -0
- package/dist/platform-client/types.js +3 -0
- package/dist/platform-client/types.js.map +1 -0
- package/gateway/activity.d.ts +52 -0
- package/gateway/activity.d.ts.map +1 -0
- package/gateway/activity.js +111 -0
- package/gateway/activity.js.map +1 -0
- package/gateway/config.d.ts +50 -0
- package/gateway/config.d.ts.map +1 -0
- package/gateway/config.js +200 -0
- package/gateway/config.js.map +1 -0
- package/gateway/handlers/anthropic.d.ts +12 -0
- package/gateway/handlers/anthropic.d.ts.map +1 -0
- package/gateway/handlers/anthropic.js +254 -0
- package/gateway/handlers/anthropic.js.map +1 -0
- package/gateway/handlers/gemini.d.ts +12 -0
- package/gateway/handlers/gemini.d.ts.map +1 -0
- package/gateway/handlers/gemini.js +101 -0
- package/gateway/handlers/gemini.js.map +1 -0
- package/gateway/handlers/models.d.ts +4 -0
- package/gateway/handlers/models.d.ts.map +1 -0
- package/gateway/handlers/models.js +36 -0
- package/gateway/handlers/models.js.map +1 -0
- package/gateway/handlers/openai.d.ts +16 -0
- package/gateway/handlers/openai.d.ts.map +1 -0
- package/gateway/handlers/openai.js +254 -0
- package/gateway/handlers/openai.js.map +1 -0
- package/gateway/index.d.ts +27 -0
- package/gateway/index.d.ts.map +1 -0
- package/gateway/index.js +293 -0
- package/gateway/index.js.map +1 -0
- package/gateway/mapping-store.d.ts +38 -0
- package/gateway/mapping-store.d.ts.map +1 -0
- package/gateway/mapping-store.js +74 -0
- package/gateway/mapping-store.js.map +1 -0
- package/gateway/restorer.d.ts +63 -0
- package/gateway/restorer.d.ts.map +1 -0
- package/gateway/restorer.js +284 -0
- package/gateway/restorer.js.map +1 -0
- package/gateway/sanitizer.d.ts +17 -0
- package/gateway/sanitizer.d.ts.map +1 -0
- package/gateway/sanitizer.js +228 -0
- package/gateway/sanitizer.js.map +1 -0
- package/gateway/types.d.ts +53 -0
- package/gateway/types.d.ts.map +1 -0
- package/gateway/types.js +5 -0
- package/gateway/types.js.map +1 -0
- package/openclaw.plugin.json +86 -0
- package/package.json +74 -0
- package/samples/Untitled +1 -0
- package/samples/clean-email.txt +20 -0
- package/samples/test-document.md +53 -0
- package/samples/test-email-popup.txt +44 -0
- package/samples/test-email.txt +32 -0
- package/samples/test-webpage.html +51 -0
- package/scripts/enterprise-enroll.sh +89 -0
- package/scripts/enterprise-unenroll.sh +75 -0
|
@@ -0,0 +1,4250 @@
|
|
|
1
|
+
export const id = 411;
|
|
2
|
+
export const ids = [411];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 8575:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ Hs: () => (/* binding */ mapColumnsInAliasedSQLToAlias),
|
|
10
|
+
/* harmony export */ Ht: () => (/* binding */ ColumnAliasProxyHandler),
|
|
11
|
+
/* harmony export */ h_: () => (/* binding */ TableAliasProxyHandler),
|
|
12
|
+
/* harmony export */ oG: () => (/* binding */ aliasedTable),
|
|
13
|
+
/* harmony export */ ug: () => (/* binding */ aliasedTableColumn),
|
|
14
|
+
/* harmony export */ yY: () => (/* binding */ mapColumnsInSQLToAlias)
|
|
15
|
+
/* harmony export */ });
|
|
16
|
+
/* unused harmony exports RelationTableAliasProxyHandler, aliasedRelation */
|
|
17
|
+
/* harmony import */ var _column_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2345);
|
|
18
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
19
|
+
/* harmony import */ var _sql_sql_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(183);
|
|
20
|
+
/* harmony import */ var _table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8407);
|
|
21
|
+
/* harmony import */ var _view_common_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6146);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ColumnAliasProxyHandler {
|
|
28
|
+
constructor(table) {
|
|
29
|
+
this.table = table;
|
|
30
|
+
}
|
|
31
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "ColumnAliasProxyHandler";
|
|
32
|
+
get(columnObj, prop) {
|
|
33
|
+
if (prop === "table") {
|
|
34
|
+
return this.table;
|
|
35
|
+
}
|
|
36
|
+
return columnObj[prop];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class TableAliasProxyHandler {
|
|
40
|
+
constructor(alias, replaceOriginalName) {
|
|
41
|
+
this.alias = alias;
|
|
42
|
+
this.replaceOriginalName = replaceOriginalName;
|
|
43
|
+
}
|
|
44
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "TableAliasProxyHandler";
|
|
45
|
+
get(target, prop) {
|
|
46
|
+
if (prop === _table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.IsAlias) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (prop === _table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Name) {
|
|
50
|
+
return this.alias;
|
|
51
|
+
}
|
|
52
|
+
if (this.replaceOriginalName && prop === _table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.OriginalName) {
|
|
53
|
+
return this.alias;
|
|
54
|
+
}
|
|
55
|
+
if (prop === _view_common_js__WEBPACK_IMPORTED_MODULE_2__/* .ViewBaseConfig */ .n) {
|
|
56
|
+
return {
|
|
57
|
+
...target[_view_common_js__WEBPACK_IMPORTED_MODULE_2__/* .ViewBaseConfig */ .n],
|
|
58
|
+
name: this.alias,
|
|
59
|
+
isAlias: true
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (prop === _table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Columns) {
|
|
63
|
+
const columns = target[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Columns];
|
|
64
|
+
if (!columns) {
|
|
65
|
+
return columns;
|
|
66
|
+
}
|
|
67
|
+
const proxiedColumns = {};
|
|
68
|
+
Object.keys(columns).map((key) => {
|
|
69
|
+
proxiedColumns[key] = new Proxy(
|
|
70
|
+
columns[key],
|
|
71
|
+
new ColumnAliasProxyHandler(new Proxy(target, this))
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
return proxiedColumns;
|
|
75
|
+
}
|
|
76
|
+
const value = target[prop];
|
|
77
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(value, _column_js__WEBPACK_IMPORTED_MODULE_3__/* .Column */ .V)) {
|
|
78
|
+
return new Proxy(value, new ColumnAliasProxyHandler(new Proxy(target, this)));
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
class RelationTableAliasProxyHandler {
|
|
84
|
+
constructor(alias) {
|
|
85
|
+
this.alias = alias;
|
|
86
|
+
}
|
|
87
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = (/* unused pure expression or super */ null && ("RelationTableAliasProxyHandler"));
|
|
88
|
+
get(target, prop) {
|
|
89
|
+
if (prop === "sourceTable") {
|
|
90
|
+
return aliasedTable(target.sourceTable, this.alias);
|
|
91
|
+
}
|
|
92
|
+
return target[prop];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function aliasedTable(table, tableAlias) {
|
|
96
|
+
return new Proxy(table, new TableAliasProxyHandler(tableAlias, false));
|
|
97
|
+
}
|
|
98
|
+
function aliasedRelation(relation, tableAlias) {
|
|
99
|
+
return new Proxy(relation, new RelationTableAliasProxyHandler(tableAlias));
|
|
100
|
+
}
|
|
101
|
+
function aliasedTableColumn(column, tableAlias) {
|
|
102
|
+
return new Proxy(
|
|
103
|
+
column,
|
|
104
|
+
new ColumnAliasProxyHandler(new Proxy(column.table, new TableAliasProxyHandler(tableAlias, false)))
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function mapColumnsInAliasedSQLToAlias(query, alias) {
|
|
108
|
+
return new _sql_sql_js__WEBPACK_IMPORTED_MODULE_4__/* .SQL */ .Xs.Aliased(mapColumnsInSQLToAlias(query.sql, alias), query.fieldAlias);
|
|
109
|
+
}
|
|
110
|
+
function mapColumnsInSQLToAlias(query, alias) {
|
|
111
|
+
return _sql_sql_js__WEBPACK_IMPORTED_MODULE_4__/* .sql */ .ll.join(query.queryChunks.map((c) => {
|
|
112
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(c, _column_js__WEBPACK_IMPORTED_MODULE_3__/* .Column */ .V)) {
|
|
113
|
+
return aliasedTableColumn(c, alias);
|
|
114
|
+
}
|
|
115
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(c, _sql_sql_js__WEBPACK_IMPORTED_MODULE_4__/* .SQL */ .Xs)) {
|
|
116
|
+
return mapColumnsInSQLToAlias(c, alias);
|
|
117
|
+
}
|
|
118
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(c, _sql_sql_js__WEBPACK_IMPORTED_MODULE_4__/* .SQL */ .Xs.Aliased)) {
|
|
119
|
+
return mapColumnsInAliasedSQLToAlias(c, alias);
|
|
120
|
+
}
|
|
121
|
+
return c;
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=alias.js.map
|
|
126
|
+
|
|
127
|
+
/***/ }),
|
|
128
|
+
|
|
129
|
+
/***/ 568:
|
|
130
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
131
|
+
|
|
132
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
133
|
+
/* harmony export */ Yn: () => (/* binding */ CasingCache)
|
|
134
|
+
/* harmony export */ });
|
|
135
|
+
/* unused harmony exports toCamelCase, toSnakeCase */
|
|
136
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
137
|
+
/* harmony import */ var _table_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8407);
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
function toSnakeCase(input) {
|
|
141
|
+
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
142
|
+
return words.map((word) => word.toLowerCase()).join("_");
|
|
143
|
+
}
|
|
144
|
+
function toCamelCase(input) {
|
|
145
|
+
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
146
|
+
return words.reduce((acc, word, i) => {
|
|
147
|
+
const formattedWord = i === 0 ? word.toLowerCase() : `${word[0].toUpperCase()}${word.slice(1)}`;
|
|
148
|
+
return acc + formattedWord;
|
|
149
|
+
}, "");
|
|
150
|
+
}
|
|
151
|
+
function noopCase(input) {
|
|
152
|
+
return input;
|
|
153
|
+
}
|
|
154
|
+
class CasingCache {
|
|
155
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "CasingCache";
|
|
156
|
+
/** @internal */
|
|
157
|
+
cache = {};
|
|
158
|
+
cachedTables = {};
|
|
159
|
+
convert;
|
|
160
|
+
constructor(casing) {
|
|
161
|
+
this.convert = casing === "snake_case" ? toSnakeCase : casing === "camelCase" ? toCamelCase : noopCase;
|
|
162
|
+
}
|
|
163
|
+
getColumnCasing(column) {
|
|
164
|
+
if (!column.keyAsName)
|
|
165
|
+
return column.name;
|
|
166
|
+
const schema = column.table[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Schema] ?? "public";
|
|
167
|
+
const tableName = column.table[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.OriginalName];
|
|
168
|
+
const key = `${schema}.${tableName}.${column.name}`;
|
|
169
|
+
if (!this.cache[key]) {
|
|
170
|
+
this.cacheTable(column.table);
|
|
171
|
+
}
|
|
172
|
+
return this.cache[key];
|
|
173
|
+
}
|
|
174
|
+
cacheTable(table) {
|
|
175
|
+
const schema = table[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Schema] ?? "public";
|
|
176
|
+
const tableName = table[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.OriginalName];
|
|
177
|
+
const tableKey = `${schema}.${tableName}`;
|
|
178
|
+
if (!this.cachedTables[tableKey]) {
|
|
179
|
+
for (const column of Object.values(table[_table_js__WEBPACK_IMPORTED_MODULE_1__/* .Table */ .XI.Symbol.Columns])) {
|
|
180
|
+
const columnKey = `${tableKey}.${column.name}`;
|
|
181
|
+
this.cache[columnKey] = this.convert(column.name);
|
|
182
|
+
}
|
|
183
|
+
this.cachedTables[tableKey] = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
clearCache() {
|
|
187
|
+
this.cache = {};
|
|
188
|
+
this.cachedTables = {};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=casing.js.map
|
|
193
|
+
|
|
194
|
+
/***/ }),
|
|
195
|
+
|
|
196
|
+
/***/ 6920:
|
|
197
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
198
|
+
|
|
199
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
200
|
+
/* harmony export */ j: () => (/* binding */ TransactionRollbackError),
|
|
201
|
+
/* harmony export */ n: () => (/* binding */ DrizzleError)
|
|
202
|
+
/* harmony export */ });
|
|
203
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
204
|
+
|
|
205
|
+
class DrizzleError extends Error {
|
|
206
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "DrizzleError";
|
|
207
|
+
constructor({ message, cause }) {
|
|
208
|
+
super(message);
|
|
209
|
+
this.name = "DrizzleError";
|
|
210
|
+
this.cause = cause;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
class TransactionRollbackError extends DrizzleError {
|
|
214
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "TransactionRollbackError";
|
|
215
|
+
constructor() {
|
|
216
|
+
super({ message: "Rollback" });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=errors.js.map
|
|
221
|
+
|
|
222
|
+
/***/ }),
|
|
223
|
+
|
|
224
|
+
/***/ 3411:
|
|
225
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
// EXPORTS
|
|
229
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
230
|
+
drizzle: () => (/* reexport */ drizzle)
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// UNUSED EXPORTS: LibSQLDatabase, LibSQLPreparedQuery, LibSQLSession, LibSQLTransaction
|
|
234
|
+
|
|
235
|
+
// EXTERNAL MODULE: external "@libsql/client"
|
|
236
|
+
var client_ = __webpack_require__(8855);
|
|
237
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/utils.js
|
|
238
|
+
var utils = __webpack_require__(3853);
|
|
239
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/entity.js
|
|
240
|
+
var entity = __webpack_require__(9724);
|
|
241
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/logger.js
|
|
242
|
+
var drizzle_orm_logger = __webpack_require__(6743);
|
|
243
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/relations.js + 1 modules
|
|
244
|
+
var relations = __webpack_require__(4750);
|
|
245
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/selection-proxy.js
|
|
246
|
+
var selection_proxy = __webpack_require__(8296);
|
|
247
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sql/sql.js + 1 modules
|
|
248
|
+
var sql = __webpack_require__(183);
|
|
249
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/alias.js
|
|
250
|
+
var alias = __webpack_require__(8575);
|
|
251
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/casing.js
|
|
252
|
+
var casing = __webpack_require__(568);
|
|
253
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/column.js
|
|
254
|
+
var column = __webpack_require__(2345);
|
|
255
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/errors.js
|
|
256
|
+
var errors = __webpack_require__(6920);
|
|
257
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
258
|
+
var conditions = __webpack_require__(420);
|
|
259
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/common.js + 2 modules
|
|
260
|
+
var common = __webpack_require__(3824);
|
|
261
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/table.js + 4 modules
|
|
262
|
+
var sqlite_core_table = __webpack_require__(2084);
|
|
263
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/subquery.js
|
|
264
|
+
var subquery = __webpack_require__(6453);
|
|
265
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/table.js
|
|
266
|
+
var drizzle_orm_table = __webpack_require__(8407);
|
|
267
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/view-common.js
|
|
268
|
+
var view_common = __webpack_require__(6146);
|
|
269
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/view-base.js
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class SQLiteViewBase extends sql/* View */.Ss {
|
|
273
|
+
static [entity/* entityKind */.i] = "SQLiteViewBase";
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=view-base.js.map
|
|
277
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/dialect.js
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class SQLiteDialect {
|
|
294
|
+
static [entity/* entityKind */.i] = "SQLiteDialect";
|
|
295
|
+
/** @internal */
|
|
296
|
+
casing;
|
|
297
|
+
constructor(config) {
|
|
298
|
+
this.casing = new casing/* CasingCache */.Yn(config?.casing);
|
|
299
|
+
}
|
|
300
|
+
escapeName(name) {
|
|
301
|
+
return `"${name}"`;
|
|
302
|
+
}
|
|
303
|
+
escapeParam(_num) {
|
|
304
|
+
return "?";
|
|
305
|
+
}
|
|
306
|
+
escapeString(str) {
|
|
307
|
+
return `'${str.replace(/'/g, "''")}'`;
|
|
308
|
+
}
|
|
309
|
+
buildWithCTE(queries) {
|
|
310
|
+
if (!queries?.length)
|
|
311
|
+
return void 0;
|
|
312
|
+
const withSqlChunks = [(0,sql/* sql */.ll)`with `];
|
|
313
|
+
for (const [i, w] of queries.entries()) {
|
|
314
|
+
withSqlChunks.push((0,sql/* sql */.ll)`${sql/* sql */.ll.identifier(w._.alias)} as (${w._.sql})`);
|
|
315
|
+
if (i < queries.length - 1) {
|
|
316
|
+
withSqlChunks.push((0,sql/* sql */.ll)`, `);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
withSqlChunks.push((0,sql/* sql */.ll)` `);
|
|
320
|
+
return sql/* sql */.ll.join(withSqlChunks);
|
|
321
|
+
}
|
|
322
|
+
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }) {
|
|
323
|
+
const withSql = this.buildWithCTE(withList);
|
|
324
|
+
const returningSql = returning ? (0,sql/* sql */.ll)` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
325
|
+
const whereSql = where ? (0,sql/* sql */.ll)` where ${where}` : void 0;
|
|
326
|
+
const orderBySql = this.buildOrderBy(orderBy);
|
|
327
|
+
const limitSql = this.buildLimit(limit);
|
|
328
|
+
return (0,sql/* sql */.ll)`${withSql}delete from ${table}${whereSql}${returningSql}${orderBySql}${limitSql}`;
|
|
329
|
+
}
|
|
330
|
+
buildUpdateSet(table, set) {
|
|
331
|
+
const tableColumns = table[drizzle_orm_table/* Table */.XI.Symbol.Columns];
|
|
332
|
+
const columnNames = Object.keys(tableColumns).filter(
|
|
333
|
+
(colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
|
|
334
|
+
);
|
|
335
|
+
const setSize = columnNames.length;
|
|
336
|
+
return sql/* sql */.ll.join(columnNames.flatMap((colName, i) => {
|
|
337
|
+
const col = tableColumns[colName];
|
|
338
|
+
const value = set[colName] ?? sql/* sql */.ll.param(col.onUpdateFn(), col);
|
|
339
|
+
const res = (0,sql/* sql */.ll)`${sql/* sql */.ll.identifier(this.casing.getColumnCasing(col))} = ${value}`;
|
|
340
|
+
if (i < setSize - 1) {
|
|
341
|
+
return [res, sql/* sql */.ll.raw(", ")];
|
|
342
|
+
}
|
|
343
|
+
return [res];
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }) {
|
|
347
|
+
const withSql = this.buildWithCTE(withList);
|
|
348
|
+
const setSql = this.buildUpdateSet(table, set);
|
|
349
|
+
const fromSql = from && sql/* sql */.ll.join([sql/* sql */.ll.raw(" from "), this.buildFromTable(from)]);
|
|
350
|
+
const joinsSql = this.buildJoins(joins);
|
|
351
|
+
const returningSql = returning ? (0,sql/* sql */.ll)` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
352
|
+
const whereSql = where ? (0,sql/* sql */.ll)` where ${where}` : void 0;
|
|
353
|
+
const orderBySql = this.buildOrderBy(orderBy);
|
|
354
|
+
const limitSql = this.buildLimit(limit);
|
|
355
|
+
return (0,sql/* sql */.ll)`${withSql}update ${table} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}${orderBySql}${limitSql}`;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Builds selection SQL with provided fields/expressions
|
|
359
|
+
*
|
|
360
|
+
* Examples:
|
|
361
|
+
*
|
|
362
|
+
* `select <selection> from`
|
|
363
|
+
*
|
|
364
|
+
* `insert ... returning <selection>`
|
|
365
|
+
*
|
|
366
|
+
* If `isSingleTable` is true, then columns won't be prefixed with table name
|
|
367
|
+
*/
|
|
368
|
+
buildSelection(fields, { isSingleTable = false } = {}) {
|
|
369
|
+
const columnsLen = fields.length;
|
|
370
|
+
const chunks = fields.flatMap(({ field }, i) => {
|
|
371
|
+
const chunk = [];
|
|
372
|
+
if ((0,entity.is)(field, sql/* SQL */.Xs.Aliased) && field.isSelectionField) {
|
|
373
|
+
chunk.push(sql/* sql */.ll.identifier(field.fieldAlias));
|
|
374
|
+
} else if ((0,entity.is)(field, sql/* SQL */.Xs.Aliased) || (0,entity.is)(field, sql/* SQL */.Xs)) {
|
|
375
|
+
const query = (0,entity.is)(field, sql/* SQL */.Xs.Aliased) ? field.sql : field;
|
|
376
|
+
if (isSingleTable) {
|
|
377
|
+
chunk.push(
|
|
378
|
+
new sql/* SQL */.Xs(
|
|
379
|
+
query.queryChunks.map((c) => {
|
|
380
|
+
if ((0,entity.is)(c, column/* Column */.V)) {
|
|
381
|
+
return sql/* sql */.ll.identifier(this.casing.getColumnCasing(c));
|
|
382
|
+
}
|
|
383
|
+
return c;
|
|
384
|
+
})
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
} else {
|
|
388
|
+
chunk.push(query);
|
|
389
|
+
}
|
|
390
|
+
if ((0,entity.is)(field, sql/* SQL */.Xs.Aliased)) {
|
|
391
|
+
chunk.push((0,sql/* sql */.ll)` as ${sql/* sql */.ll.identifier(field.fieldAlias)}`);
|
|
392
|
+
}
|
|
393
|
+
} else if ((0,entity.is)(field, column/* Column */.V)) {
|
|
394
|
+
const tableName = field.table[drizzle_orm_table/* Table */.XI.Symbol.Name];
|
|
395
|
+
if (isSingleTable) {
|
|
396
|
+
chunk.push(sql/* sql */.ll.identifier(this.casing.getColumnCasing(field)));
|
|
397
|
+
} else {
|
|
398
|
+
chunk.push((0,sql/* sql */.ll)`${sql/* sql */.ll.identifier(tableName)}.${sql/* sql */.ll.identifier(this.casing.getColumnCasing(field))}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (i < columnsLen - 1) {
|
|
402
|
+
chunk.push((0,sql/* sql */.ll)`, `);
|
|
403
|
+
}
|
|
404
|
+
return chunk;
|
|
405
|
+
});
|
|
406
|
+
return sql/* sql */.ll.join(chunks);
|
|
407
|
+
}
|
|
408
|
+
buildJoins(joins) {
|
|
409
|
+
if (!joins || joins.length === 0) {
|
|
410
|
+
return void 0;
|
|
411
|
+
}
|
|
412
|
+
const joinsArray = [];
|
|
413
|
+
if (joins) {
|
|
414
|
+
for (const [index, joinMeta] of joins.entries()) {
|
|
415
|
+
if (index === 0) {
|
|
416
|
+
joinsArray.push((0,sql/* sql */.ll)` `);
|
|
417
|
+
}
|
|
418
|
+
const table = joinMeta.table;
|
|
419
|
+
if ((0,entity.is)(table, sqlite_core_table/* SQLiteTable */.jo)) {
|
|
420
|
+
const tableName = table[sqlite_core_table/* SQLiteTable */.jo.Symbol.Name];
|
|
421
|
+
const tableSchema = table[sqlite_core_table/* SQLiteTable */.jo.Symbol.Schema];
|
|
422
|
+
const origTableName = table[sqlite_core_table/* SQLiteTable */.jo.Symbol.OriginalName];
|
|
423
|
+
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
424
|
+
joinsArray.push(
|
|
425
|
+
(0,sql/* sql */.ll)`${sql/* sql */.ll.raw(joinMeta.joinType)} join ${tableSchema ? (0,sql/* sql */.ll)`${sql/* sql */.ll.identifier(tableSchema)}.` : void 0}${sql/* sql */.ll.identifier(origTableName)}${alias && (0,sql/* sql */.ll)` ${sql/* sql */.ll.identifier(alias)}`} on ${joinMeta.on}`
|
|
426
|
+
);
|
|
427
|
+
} else {
|
|
428
|
+
joinsArray.push(
|
|
429
|
+
(0,sql/* sql */.ll)`${sql/* sql */.ll.raw(joinMeta.joinType)} join ${table} on ${joinMeta.on}`
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
if (index < joins.length - 1) {
|
|
433
|
+
joinsArray.push((0,sql/* sql */.ll)` `);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return sql/* sql */.ll.join(joinsArray);
|
|
438
|
+
}
|
|
439
|
+
buildLimit(limit) {
|
|
440
|
+
return typeof limit === "object" || typeof limit === "number" && limit >= 0 ? (0,sql/* sql */.ll)` limit ${limit}` : void 0;
|
|
441
|
+
}
|
|
442
|
+
buildOrderBy(orderBy) {
|
|
443
|
+
const orderByList = [];
|
|
444
|
+
if (orderBy) {
|
|
445
|
+
for (const [index, orderByValue] of orderBy.entries()) {
|
|
446
|
+
orderByList.push(orderByValue);
|
|
447
|
+
if (index < orderBy.length - 1) {
|
|
448
|
+
orderByList.push((0,sql/* sql */.ll)`, `);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return orderByList.length > 0 ? (0,sql/* sql */.ll)` order by ${sql/* sql */.ll.join(orderByList)}` : void 0;
|
|
453
|
+
}
|
|
454
|
+
buildFromTable(table) {
|
|
455
|
+
if ((0,entity.is)(table, drizzle_orm_table/* Table */.XI) && table[drizzle_orm_table/* Table */.XI.Symbol.OriginalName] !== table[drizzle_orm_table/* Table */.XI.Symbol.Name]) {
|
|
456
|
+
return (0,sql/* sql */.ll)`${sql/* sql */.ll.identifier(table[drizzle_orm_table/* Table */.XI.Symbol.OriginalName])} ${sql/* sql */.ll.identifier(table[drizzle_orm_table/* Table */.XI.Symbol.Name])}`;
|
|
457
|
+
}
|
|
458
|
+
return table;
|
|
459
|
+
}
|
|
460
|
+
buildSelectQuery({
|
|
461
|
+
withList,
|
|
462
|
+
fields,
|
|
463
|
+
fieldsFlat,
|
|
464
|
+
where,
|
|
465
|
+
having,
|
|
466
|
+
table,
|
|
467
|
+
joins,
|
|
468
|
+
orderBy,
|
|
469
|
+
groupBy,
|
|
470
|
+
limit,
|
|
471
|
+
offset,
|
|
472
|
+
distinct,
|
|
473
|
+
setOperators
|
|
474
|
+
}) {
|
|
475
|
+
const fieldsList = fieldsFlat ?? (0,utils/* orderSelectedFields */.He)(fields);
|
|
476
|
+
for (const f of fieldsList) {
|
|
477
|
+
if ((0,entity.is)(f.field, column/* Column */.V) && (0,drizzle_orm_table/* getTableName */.Io)(f.field.table) !== ((0,entity.is)(table, subquery/* Subquery */.n) ? table._.alias : (0,entity.is)(table, SQLiteViewBase) ? table[view_common/* ViewBaseConfig */.n].name : (0,entity.is)(table, sql/* SQL */.Xs) ? void 0 : (0,drizzle_orm_table/* getTableName */.Io)(table)) && !((table2) => joins?.some(
|
|
478
|
+
({ alias }) => alias === (table2[drizzle_orm_table/* Table */.XI.Symbol.IsAlias] ? (0,drizzle_orm_table/* getTableName */.Io)(table2) : table2[drizzle_orm_table/* Table */.XI.Symbol.BaseName])
|
|
479
|
+
))(f.field.table)) {
|
|
480
|
+
const tableName = (0,drizzle_orm_table/* getTableName */.Io)(f.field.table);
|
|
481
|
+
throw new Error(
|
|
482
|
+
`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const isSingleTable = !joins || joins.length === 0;
|
|
487
|
+
const withSql = this.buildWithCTE(withList);
|
|
488
|
+
const distinctSql = distinct ? (0,sql/* sql */.ll)` distinct` : void 0;
|
|
489
|
+
const selection = this.buildSelection(fieldsList, { isSingleTable });
|
|
490
|
+
const tableSql = this.buildFromTable(table);
|
|
491
|
+
const joinsSql = this.buildJoins(joins);
|
|
492
|
+
const whereSql = where ? (0,sql/* sql */.ll)` where ${where}` : void 0;
|
|
493
|
+
const havingSql = having ? (0,sql/* sql */.ll)` having ${having}` : void 0;
|
|
494
|
+
const groupByList = [];
|
|
495
|
+
if (groupBy) {
|
|
496
|
+
for (const [index, groupByValue] of groupBy.entries()) {
|
|
497
|
+
groupByList.push(groupByValue);
|
|
498
|
+
if (index < groupBy.length - 1) {
|
|
499
|
+
groupByList.push((0,sql/* sql */.ll)`, `);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const groupBySql = groupByList.length > 0 ? (0,sql/* sql */.ll)` group by ${sql/* sql */.ll.join(groupByList)}` : void 0;
|
|
504
|
+
const orderBySql = this.buildOrderBy(orderBy);
|
|
505
|
+
const limitSql = this.buildLimit(limit);
|
|
506
|
+
const offsetSql = offset ? (0,sql/* sql */.ll)` offset ${offset}` : void 0;
|
|
507
|
+
const finalQuery = (0,sql/* sql */.ll)`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}`;
|
|
508
|
+
if (setOperators.length > 0) {
|
|
509
|
+
return this.buildSetOperations(finalQuery, setOperators);
|
|
510
|
+
}
|
|
511
|
+
return finalQuery;
|
|
512
|
+
}
|
|
513
|
+
buildSetOperations(leftSelect, setOperators) {
|
|
514
|
+
const [setOperator, ...rest] = setOperators;
|
|
515
|
+
if (!setOperator) {
|
|
516
|
+
throw new Error("Cannot pass undefined values to any set operator");
|
|
517
|
+
}
|
|
518
|
+
if (rest.length === 0) {
|
|
519
|
+
return this.buildSetOperationQuery({ leftSelect, setOperator });
|
|
520
|
+
}
|
|
521
|
+
return this.buildSetOperations(
|
|
522
|
+
this.buildSetOperationQuery({ leftSelect, setOperator }),
|
|
523
|
+
rest
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
buildSetOperationQuery({
|
|
527
|
+
leftSelect,
|
|
528
|
+
setOperator: { type, isAll, rightSelect, limit, orderBy, offset }
|
|
529
|
+
}) {
|
|
530
|
+
const leftChunk = (0,sql/* sql */.ll)`${leftSelect.getSQL()} `;
|
|
531
|
+
const rightChunk = (0,sql/* sql */.ll)`${rightSelect.getSQL()}`;
|
|
532
|
+
let orderBySql;
|
|
533
|
+
if (orderBy && orderBy.length > 0) {
|
|
534
|
+
const orderByValues = [];
|
|
535
|
+
for (const singleOrderBy of orderBy) {
|
|
536
|
+
if ((0,entity.is)(singleOrderBy, common/* SQLiteColumn */.v)) {
|
|
537
|
+
orderByValues.push(sql/* sql */.ll.identifier(singleOrderBy.name));
|
|
538
|
+
} else if ((0,entity.is)(singleOrderBy, sql/* SQL */.Xs)) {
|
|
539
|
+
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
|
|
540
|
+
const chunk = singleOrderBy.queryChunks[i];
|
|
541
|
+
if ((0,entity.is)(chunk, common/* SQLiteColumn */.v)) {
|
|
542
|
+
singleOrderBy.queryChunks[i] = sql/* sql */.ll.identifier(this.casing.getColumnCasing(chunk));
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
orderByValues.push((0,sql/* sql */.ll)`${singleOrderBy}`);
|
|
546
|
+
} else {
|
|
547
|
+
orderByValues.push((0,sql/* sql */.ll)`${singleOrderBy}`);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
orderBySql = (0,sql/* sql */.ll)` order by ${sql/* sql */.ll.join(orderByValues, (0,sql/* sql */.ll)`, `)}`;
|
|
551
|
+
}
|
|
552
|
+
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? (0,sql/* sql */.ll)` limit ${limit}` : void 0;
|
|
553
|
+
const operatorChunk = sql/* sql */.ll.raw(`${type} ${isAll ? "all " : ""}`);
|
|
554
|
+
const offsetSql = offset ? (0,sql/* sql */.ll)` offset ${offset}` : void 0;
|
|
555
|
+
return (0,sql/* sql */.ll)`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
|
|
556
|
+
}
|
|
557
|
+
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }) {
|
|
558
|
+
const valuesSqlList = [];
|
|
559
|
+
const columns = table[drizzle_orm_table/* Table */.XI.Symbol.Columns];
|
|
560
|
+
const colEntries = Object.entries(columns).filter(
|
|
561
|
+
([_, col]) => !col.shouldDisableInsert()
|
|
562
|
+
);
|
|
563
|
+
const insertOrder = colEntries.map(([, column]) => sql/* sql */.ll.identifier(this.casing.getColumnCasing(column)));
|
|
564
|
+
if (select) {
|
|
565
|
+
const select2 = valuesOrSelect;
|
|
566
|
+
if ((0,entity.is)(select2, sql/* SQL */.Xs)) {
|
|
567
|
+
valuesSqlList.push(select2);
|
|
568
|
+
} else {
|
|
569
|
+
valuesSqlList.push(select2.getSQL());
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
const values = valuesOrSelect;
|
|
573
|
+
valuesSqlList.push(sql/* sql */.ll.raw("values "));
|
|
574
|
+
for (const [valueIndex, value] of values.entries()) {
|
|
575
|
+
const valueList = [];
|
|
576
|
+
for (const [fieldName, col] of colEntries) {
|
|
577
|
+
const colValue = value[fieldName];
|
|
578
|
+
if (colValue === void 0 || (0,entity.is)(colValue, sql/* Param */.Iw) && colValue.value === void 0) {
|
|
579
|
+
let defaultValue;
|
|
580
|
+
if (col.default !== null && col.default !== void 0) {
|
|
581
|
+
defaultValue = (0,entity.is)(col.default, sql/* SQL */.Xs) ? col.default : sql/* sql */.ll.param(col.default, col);
|
|
582
|
+
} else if (col.defaultFn !== void 0) {
|
|
583
|
+
const defaultFnResult = col.defaultFn();
|
|
584
|
+
defaultValue = (0,entity.is)(defaultFnResult, sql/* SQL */.Xs) ? defaultFnResult : sql/* sql */.ll.param(defaultFnResult, col);
|
|
585
|
+
} else if (!col.default && col.onUpdateFn !== void 0) {
|
|
586
|
+
const onUpdateFnResult = col.onUpdateFn();
|
|
587
|
+
defaultValue = (0,entity.is)(onUpdateFnResult, sql/* SQL */.Xs) ? onUpdateFnResult : sql/* sql */.ll.param(onUpdateFnResult, col);
|
|
588
|
+
} else {
|
|
589
|
+
defaultValue = (0,sql/* sql */.ll)`null`;
|
|
590
|
+
}
|
|
591
|
+
valueList.push(defaultValue);
|
|
592
|
+
} else {
|
|
593
|
+
valueList.push(colValue);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
valuesSqlList.push(valueList);
|
|
597
|
+
if (valueIndex < values.length - 1) {
|
|
598
|
+
valuesSqlList.push((0,sql/* sql */.ll)`, `);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const withSql = this.buildWithCTE(withList);
|
|
603
|
+
const valuesSql = sql/* sql */.ll.join(valuesSqlList);
|
|
604
|
+
const returningSql = returning ? (0,sql/* sql */.ll)` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
605
|
+
const onConflictSql = onConflict ? (0,sql/* sql */.ll)` on conflict ${onConflict}` : void 0;
|
|
606
|
+
return (0,sql/* sql */.ll)`${withSql}insert into ${table} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
|
|
607
|
+
}
|
|
608
|
+
sqlToQuery(sql2, invokeSource) {
|
|
609
|
+
return sql2.toQuery({
|
|
610
|
+
casing: this.casing,
|
|
611
|
+
escapeName: this.escapeName,
|
|
612
|
+
escapeParam: this.escapeParam,
|
|
613
|
+
escapeString: this.escapeString,
|
|
614
|
+
invokeSource
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
buildRelationalQuery({
|
|
618
|
+
fullSchema,
|
|
619
|
+
schema,
|
|
620
|
+
tableNamesMap,
|
|
621
|
+
table,
|
|
622
|
+
tableConfig,
|
|
623
|
+
queryConfig: config,
|
|
624
|
+
tableAlias,
|
|
625
|
+
nestedQueryRelation,
|
|
626
|
+
joinOn
|
|
627
|
+
}) {
|
|
628
|
+
let selection = [];
|
|
629
|
+
let limit, offset, orderBy = [], where;
|
|
630
|
+
const joins = [];
|
|
631
|
+
if (config === true) {
|
|
632
|
+
const selectionEntries = Object.entries(tableConfig.columns);
|
|
633
|
+
selection = selectionEntries.map(([key, value]) => ({
|
|
634
|
+
dbKey: value.name,
|
|
635
|
+
tsKey: key,
|
|
636
|
+
field: (0,alias/* aliasedTableColumn */.ug)(value, tableAlias),
|
|
637
|
+
relationTableTsKey: void 0,
|
|
638
|
+
isJson: false,
|
|
639
|
+
selection: []
|
|
640
|
+
}));
|
|
641
|
+
} else {
|
|
642
|
+
const aliasedColumns = Object.fromEntries(
|
|
643
|
+
Object.entries(tableConfig.columns).map(([key, value]) => [key, (0,alias/* aliasedTableColumn */.ug)(value, tableAlias)])
|
|
644
|
+
);
|
|
645
|
+
if (config.where) {
|
|
646
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0,relations/* getOperators */.mm)()) : config.where;
|
|
647
|
+
where = whereSql && (0,alias/* mapColumnsInSQLToAlias */.yY)(whereSql, tableAlias);
|
|
648
|
+
}
|
|
649
|
+
const fieldsSelection = [];
|
|
650
|
+
let selectedColumns = [];
|
|
651
|
+
if (config.columns) {
|
|
652
|
+
let isIncludeMode = false;
|
|
653
|
+
for (const [field, value] of Object.entries(config.columns)) {
|
|
654
|
+
if (value === void 0) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
if (field in tableConfig.columns) {
|
|
658
|
+
if (!isIncludeMode && value === true) {
|
|
659
|
+
isIncludeMode = true;
|
|
660
|
+
}
|
|
661
|
+
selectedColumns.push(field);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (selectedColumns.length > 0) {
|
|
665
|
+
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
|
|
666
|
+
}
|
|
667
|
+
} else {
|
|
668
|
+
selectedColumns = Object.keys(tableConfig.columns);
|
|
669
|
+
}
|
|
670
|
+
for (const field of selectedColumns) {
|
|
671
|
+
const column = tableConfig.columns[field];
|
|
672
|
+
fieldsSelection.push({ tsKey: field, value: column });
|
|
673
|
+
}
|
|
674
|
+
let selectedRelations = [];
|
|
675
|
+
if (config.with) {
|
|
676
|
+
selectedRelations = Object.entries(config.with).filter((entry) => !!entry[1]).map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey] }));
|
|
677
|
+
}
|
|
678
|
+
let extras;
|
|
679
|
+
if (config.extras) {
|
|
680
|
+
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql: sql/* sql */.ll }) : config.extras;
|
|
681
|
+
for (const [tsKey, value] of Object.entries(extras)) {
|
|
682
|
+
fieldsSelection.push({
|
|
683
|
+
tsKey,
|
|
684
|
+
value: (0,alias/* mapColumnsInAliasedSQLToAlias */.Hs)(value, tableAlias)
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
for (const { tsKey, value } of fieldsSelection) {
|
|
689
|
+
selection.push({
|
|
690
|
+
dbKey: (0,entity.is)(value, sql/* SQL */.Xs.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
|
|
691
|
+
tsKey,
|
|
692
|
+
field: (0,entity.is)(value, column/* Column */.V) ? (0,alias/* aliasedTableColumn */.ug)(value, tableAlias) : value,
|
|
693
|
+
relationTableTsKey: void 0,
|
|
694
|
+
isJson: false,
|
|
695
|
+
selection: []
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0,relations/* getOrderByOperators */.rl)()) : config.orderBy ?? [];
|
|
699
|
+
if (!Array.isArray(orderByOrig)) {
|
|
700
|
+
orderByOrig = [orderByOrig];
|
|
701
|
+
}
|
|
702
|
+
orderBy = orderByOrig.map((orderByValue) => {
|
|
703
|
+
if ((0,entity.is)(orderByValue, column/* Column */.V)) {
|
|
704
|
+
return (0,alias/* aliasedTableColumn */.ug)(orderByValue, tableAlias);
|
|
705
|
+
}
|
|
706
|
+
return (0,alias/* mapColumnsInSQLToAlias */.yY)(orderByValue, tableAlias);
|
|
707
|
+
});
|
|
708
|
+
limit = config.limit;
|
|
709
|
+
offset = config.offset;
|
|
710
|
+
for (const {
|
|
711
|
+
tsKey: selectedRelationTsKey,
|
|
712
|
+
queryConfig: selectedRelationConfigValue,
|
|
713
|
+
relation
|
|
714
|
+
} of selectedRelations) {
|
|
715
|
+
const normalizedRelation = (0,relations/* normalizeRelation */.W0)(schema, tableNamesMap, relation);
|
|
716
|
+
const relationTableName = (0,drizzle_orm_table/* getTableUniqueName */.Lf)(relation.referencedTable);
|
|
717
|
+
const relationTableTsName = tableNamesMap[relationTableName];
|
|
718
|
+
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
719
|
+
const joinOn2 = (0,conditions/* and */.Uo)(
|
|
720
|
+
...normalizedRelation.fields.map(
|
|
721
|
+
(field2, i) => (0,conditions.eq)(
|
|
722
|
+
(0,alias/* aliasedTableColumn */.ug)(normalizedRelation.references[i], relationTableAlias),
|
|
723
|
+
(0,alias/* aliasedTableColumn */.ug)(field2, tableAlias)
|
|
724
|
+
)
|
|
725
|
+
)
|
|
726
|
+
);
|
|
727
|
+
const builtRelation = this.buildRelationalQuery({
|
|
728
|
+
fullSchema,
|
|
729
|
+
schema,
|
|
730
|
+
tableNamesMap,
|
|
731
|
+
table: fullSchema[relationTableTsName],
|
|
732
|
+
tableConfig: schema[relationTableTsName],
|
|
733
|
+
queryConfig: (0,entity.is)(relation, relations/* One */.pD) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
734
|
+
tableAlias: relationTableAlias,
|
|
735
|
+
joinOn: joinOn2,
|
|
736
|
+
nestedQueryRelation: relation
|
|
737
|
+
});
|
|
738
|
+
const field = (0,sql/* sql */.ll)`(${builtRelation.sql})`.as(selectedRelationTsKey);
|
|
739
|
+
selection.push({
|
|
740
|
+
dbKey: selectedRelationTsKey,
|
|
741
|
+
tsKey: selectedRelationTsKey,
|
|
742
|
+
field,
|
|
743
|
+
relationTableTsKey: relationTableTsName,
|
|
744
|
+
isJson: true,
|
|
745
|
+
selection: builtRelation.selection
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (selection.length === 0) {
|
|
750
|
+
throw new errors/* DrizzleError */.n({
|
|
751
|
+
message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}"). 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.`
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
let result;
|
|
755
|
+
where = (0,conditions/* and */.Uo)(joinOn, where);
|
|
756
|
+
if (nestedQueryRelation) {
|
|
757
|
+
let field = (0,sql/* sql */.ll)`json_array(${sql/* sql */.ll.join(
|
|
758
|
+
selection.map(
|
|
759
|
+
({ field: field2 }) => (0,entity.is)(field2, common/* SQLiteColumn */.v) ? sql/* sql */.ll.identifier(this.casing.getColumnCasing(field2)) : (0,entity.is)(field2, sql/* SQL */.Xs.Aliased) ? field2.sql : field2
|
|
760
|
+
),
|
|
761
|
+
(0,sql/* sql */.ll)`, `
|
|
762
|
+
)})`;
|
|
763
|
+
if ((0,entity.is)(nestedQueryRelation, relations/* Many */.iv)) {
|
|
764
|
+
field = (0,sql/* sql */.ll)`coalesce(json_group_array(${field}), json_array())`;
|
|
765
|
+
}
|
|
766
|
+
const nestedSelection = [{
|
|
767
|
+
dbKey: "data",
|
|
768
|
+
tsKey: "data",
|
|
769
|
+
field: field.as("data"),
|
|
770
|
+
isJson: true,
|
|
771
|
+
relationTableTsKey: tableConfig.tsName,
|
|
772
|
+
selection
|
|
773
|
+
}];
|
|
774
|
+
const needsSubquery = limit !== void 0 || offset !== void 0 || orderBy.length > 0;
|
|
775
|
+
if (needsSubquery) {
|
|
776
|
+
result = this.buildSelectQuery({
|
|
777
|
+
table: (0,alias/* aliasedTable */.oG)(table, tableAlias),
|
|
778
|
+
fields: {},
|
|
779
|
+
fieldsFlat: [
|
|
780
|
+
{
|
|
781
|
+
path: [],
|
|
782
|
+
field: sql/* sql */.ll.raw("*")
|
|
783
|
+
}
|
|
784
|
+
],
|
|
785
|
+
where,
|
|
786
|
+
limit,
|
|
787
|
+
offset,
|
|
788
|
+
orderBy,
|
|
789
|
+
setOperators: []
|
|
790
|
+
});
|
|
791
|
+
where = void 0;
|
|
792
|
+
limit = void 0;
|
|
793
|
+
offset = void 0;
|
|
794
|
+
orderBy = void 0;
|
|
795
|
+
} else {
|
|
796
|
+
result = (0,alias/* aliasedTable */.oG)(table, tableAlias);
|
|
797
|
+
}
|
|
798
|
+
result = this.buildSelectQuery({
|
|
799
|
+
table: (0,entity.is)(result, sqlite_core_table/* SQLiteTable */.jo) ? result : new subquery/* Subquery */.n(result, {}, tableAlias),
|
|
800
|
+
fields: {},
|
|
801
|
+
fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
|
|
802
|
+
path: [],
|
|
803
|
+
field: (0,entity.is)(field2, column/* Column */.V) ? (0,alias/* aliasedTableColumn */.ug)(field2, tableAlias) : field2
|
|
804
|
+
})),
|
|
805
|
+
joins,
|
|
806
|
+
where,
|
|
807
|
+
limit,
|
|
808
|
+
offset,
|
|
809
|
+
orderBy,
|
|
810
|
+
setOperators: []
|
|
811
|
+
});
|
|
812
|
+
} else {
|
|
813
|
+
result = this.buildSelectQuery({
|
|
814
|
+
table: (0,alias/* aliasedTable */.oG)(table, tableAlias),
|
|
815
|
+
fields: {},
|
|
816
|
+
fieldsFlat: selection.map(({ field }) => ({
|
|
817
|
+
path: [],
|
|
818
|
+
field: (0,entity.is)(field, column/* Column */.V) ? (0,alias/* aliasedTableColumn */.ug)(field, tableAlias) : field
|
|
819
|
+
})),
|
|
820
|
+
joins,
|
|
821
|
+
where,
|
|
822
|
+
limit,
|
|
823
|
+
offset,
|
|
824
|
+
orderBy,
|
|
825
|
+
setOperators: []
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
tableTsKey: tableConfig.tsName,
|
|
830
|
+
sql: result,
|
|
831
|
+
selection
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
class SQLiteSyncDialect extends SQLiteDialect {
|
|
836
|
+
static [entity/* entityKind */.i] = "SQLiteSyncDialect";
|
|
837
|
+
migrate(migrations, session, config) {
|
|
838
|
+
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.migrationsTable ?? "__drizzle_migrations";
|
|
839
|
+
const migrationTableCreate = (0,sql/* sql */.ll)`
|
|
840
|
+
CREATE TABLE IF NOT EXISTS ${sql/* sql */.ll.identifier(migrationsTable)} (
|
|
841
|
+
id SERIAL PRIMARY KEY,
|
|
842
|
+
hash text NOT NULL,
|
|
843
|
+
created_at numeric
|
|
844
|
+
)
|
|
845
|
+
`;
|
|
846
|
+
session.run(migrationTableCreate);
|
|
847
|
+
const dbMigrations = session.values(
|
|
848
|
+
(0,sql/* sql */.ll)`SELECT id, hash, created_at FROM ${sql/* sql */.ll.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
|
|
849
|
+
);
|
|
850
|
+
const lastDbMigration = dbMigrations[0] ?? void 0;
|
|
851
|
+
session.run((0,sql/* sql */.ll)`BEGIN`);
|
|
852
|
+
try {
|
|
853
|
+
for (const migration of migrations) {
|
|
854
|
+
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
855
|
+
for (const stmt of migration.sql) {
|
|
856
|
+
session.run(sql/* sql */.ll.raw(stmt));
|
|
857
|
+
}
|
|
858
|
+
session.run(
|
|
859
|
+
(0,sql/* sql */.ll)`INSERT INTO ${sql/* sql */.ll.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
session.run((0,sql/* sql */.ll)`COMMIT`);
|
|
864
|
+
} catch (e) {
|
|
865
|
+
session.run((0,sql/* sql */.ll)`ROLLBACK`);
|
|
866
|
+
throw e;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
class SQLiteAsyncDialect extends SQLiteDialect {
|
|
871
|
+
static [entity/* entityKind */.i] = "SQLiteAsyncDialect";
|
|
872
|
+
async migrate(migrations, session, config) {
|
|
873
|
+
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.migrationsTable ?? "__drizzle_migrations";
|
|
874
|
+
const migrationTableCreate = (0,sql/* sql */.ll)`
|
|
875
|
+
CREATE TABLE IF NOT EXISTS ${sql/* sql */.ll.identifier(migrationsTable)} (
|
|
876
|
+
id SERIAL PRIMARY KEY,
|
|
877
|
+
hash text NOT NULL,
|
|
878
|
+
created_at numeric
|
|
879
|
+
)
|
|
880
|
+
`;
|
|
881
|
+
await session.run(migrationTableCreate);
|
|
882
|
+
const dbMigrations = await session.values(
|
|
883
|
+
(0,sql/* sql */.ll)`SELECT id, hash, created_at FROM ${sql/* sql */.ll.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
|
|
884
|
+
);
|
|
885
|
+
const lastDbMigration = dbMigrations[0] ?? void 0;
|
|
886
|
+
await session.transaction(async (tx) => {
|
|
887
|
+
for (const migration of migrations) {
|
|
888
|
+
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
889
|
+
for (const stmt of migration.sql) {
|
|
890
|
+
await tx.run(sql/* sql */.ll.raw(stmt));
|
|
891
|
+
}
|
|
892
|
+
await tx.run(
|
|
893
|
+
(0,sql/* sql */.ll)`INSERT INTO ${sql/* sql */.ll.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
//# sourceMappingURL=dialect.js.map
|
|
902
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/query-builders/query-builder.js
|
|
903
|
+
var query_builder = __webpack_require__(6685);
|
|
904
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/query-promise.js
|
|
905
|
+
var query_promise = __webpack_require__(4579);
|
|
906
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/select.js
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
class SQLiteSelectBuilder {
|
|
918
|
+
static [entity/* entityKind */.i] = "SQLiteSelectBuilder";
|
|
919
|
+
fields;
|
|
920
|
+
session;
|
|
921
|
+
dialect;
|
|
922
|
+
withList;
|
|
923
|
+
distinct;
|
|
924
|
+
constructor(config) {
|
|
925
|
+
this.fields = config.fields;
|
|
926
|
+
this.session = config.session;
|
|
927
|
+
this.dialect = config.dialect;
|
|
928
|
+
this.withList = config.withList;
|
|
929
|
+
this.distinct = config.distinct;
|
|
930
|
+
}
|
|
931
|
+
from(source) {
|
|
932
|
+
const isPartialSelect = !!this.fields;
|
|
933
|
+
let fields;
|
|
934
|
+
if (this.fields) {
|
|
935
|
+
fields = this.fields;
|
|
936
|
+
} else if ((0,entity.is)(source, subquery/* Subquery */.n)) {
|
|
937
|
+
fields = Object.fromEntries(
|
|
938
|
+
Object.keys(source._.selectedFields).map((key) => [key, source[key]])
|
|
939
|
+
);
|
|
940
|
+
} else if ((0,entity.is)(source, SQLiteViewBase)) {
|
|
941
|
+
fields = source[view_common/* ViewBaseConfig */.n].selectedFields;
|
|
942
|
+
} else if ((0,entity.is)(source, sql/* SQL */.Xs)) {
|
|
943
|
+
fields = {};
|
|
944
|
+
} else {
|
|
945
|
+
fields = (0,utils/* getTableColumns */.YD)(source);
|
|
946
|
+
}
|
|
947
|
+
return new SQLiteSelectBase({
|
|
948
|
+
table: source,
|
|
949
|
+
fields,
|
|
950
|
+
isPartialSelect,
|
|
951
|
+
session: this.session,
|
|
952
|
+
dialect: this.dialect,
|
|
953
|
+
withList: this.withList,
|
|
954
|
+
distinct: this.distinct
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
class SQLiteSelectQueryBuilderBase extends query_builder/* TypedQueryBuilder */.O {
|
|
959
|
+
static [entity/* entityKind */.i] = "SQLiteSelectQueryBuilder";
|
|
960
|
+
_;
|
|
961
|
+
/** @internal */
|
|
962
|
+
config;
|
|
963
|
+
joinsNotNullableMap;
|
|
964
|
+
tableName;
|
|
965
|
+
isPartialSelect;
|
|
966
|
+
session;
|
|
967
|
+
dialect;
|
|
968
|
+
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
|
969
|
+
super();
|
|
970
|
+
this.config = {
|
|
971
|
+
withList,
|
|
972
|
+
table,
|
|
973
|
+
fields: { ...fields },
|
|
974
|
+
distinct,
|
|
975
|
+
setOperators: []
|
|
976
|
+
};
|
|
977
|
+
this.isPartialSelect = isPartialSelect;
|
|
978
|
+
this.session = session;
|
|
979
|
+
this.dialect = dialect;
|
|
980
|
+
this._ = {
|
|
981
|
+
selectedFields: fields
|
|
982
|
+
};
|
|
983
|
+
this.tableName = (0,utils/* getTableLikeName */.zN)(table);
|
|
984
|
+
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
985
|
+
}
|
|
986
|
+
createJoin(joinType) {
|
|
987
|
+
return (table, on) => {
|
|
988
|
+
const baseTableName = this.tableName;
|
|
989
|
+
const tableName = (0,utils/* getTableLikeName */.zN)(table);
|
|
990
|
+
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
|
991
|
+
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
992
|
+
}
|
|
993
|
+
if (!this.isPartialSelect) {
|
|
994
|
+
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") {
|
|
995
|
+
this.config.fields = {
|
|
996
|
+
[baseTableName]: this.config.fields
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
if (typeof tableName === "string" && !(0,entity.is)(table, sql/* SQL */.Xs)) {
|
|
1000
|
+
const selection = (0,entity.is)(table, subquery/* Subquery */.n) ? table._.selectedFields : (0,entity.is)(table, sql/* View */.Ss) ? table[view_common/* ViewBaseConfig */.n].selectedFields : table[drizzle_orm_table/* Table */.XI.Symbol.Columns];
|
|
1001
|
+
this.config.fields[tableName] = selection;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (typeof on === "function") {
|
|
1005
|
+
on = on(
|
|
1006
|
+
new Proxy(
|
|
1007
|
+
this.config.fields,
|
|
1008
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
|
1009
|
+
)
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
if (!this.config.joins) {
|
|
1013
|
+
this.config.joins = [];
|
|
1014
|
+
}
|
|
1015
|
+
this.config.joins.push({ on, table, joinType, alias: tableName });
|
|
1016
|
+
if (typeof tableName === "string") {
|
|
1017
|
+
switch (joinType) {
|
|
1018
|
+
case "left": {
|
|
1019
|
+
this.joinsNotNullableMap[tableName] = false;
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
case "right": {
|
|
1023
|
+
this.joinsNotNullableMap = Object.fromEntries(
|
|
1024
|
+
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
|
1025
|
+
);
|
|
1026
|
+
this.joinsNotNullableMap[tableName] = true;
|
|
1027
|
+
break;
|
|
1028
|
+
}
|
|
1029
|
+
case "inner": {
|
|
1030
|
+
this.joinsNotNullableMap[tableName] = true;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
case "full": {
|
|
1034
|
+
this.joinsNotNullableMap = Object.fromEntries(
|
|
1035
|
+
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
|
1036
|
+
);
|
|
1037
|
+
this.joinsNotNullableMap[tableName] = false;
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return this;
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Executes a `left join` operation by adding another table to the current query.
|
|
1047
|
+
*
|
|
1048
|
+
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
|
1049
|
+
*
|
|
1050
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join}
|
|
1051
|
+
*
|
|
1052
|
+
* @param table the table to join.
|
|
1053
|
+
* @param on the `on` clause.
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
*
|
|
1057
|
+
* ```ts
|
|
1058
|
+
* // Select all users and their pets
|
|
1059
|
+
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
1060
|
+
* .from(users)
|
|
1061
|
+
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
1062
|
+
*
|
|
1063
|
+
* // Select userId and petId
|
|
1064
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
1065
|
+
* userId: users.id,
|
|
1066
|
+
* petId: pets.id,
|
|
1067
|
+
* })
|
|
1068
|
+
* .from(users)
|
|
1069
|
+
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
1072
|
+
leftJoin = this.createJoin("left");
|
|
1073
|
+
/**
|
|
1074
|
+
* Executes a `right join` operation by adding another table to the current query.
|
|
1075
|
+
*
|
|
1076
|
+
* Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.
|
|
1077
|
+
*
|
|
1078
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#right-join}
|
|
1079
|
+
*
|
|
1080
|
+
* @param table the table to join.
|
|
1081
|
+
* @param on the `on` clause.
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
*
|
|
1085
|
+
* ```ts
|
|
1086
|
+
* // Select all users and their pets
|
|
1087
|
+
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
1088
|
+
* .from(users)
|
|
1089
|
+
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
1090
|
+
*
|
|
1091
|
+
* // Select userId and petId
|
|
1092
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
1093
|
+
* userId: users.id,
|
|
1094
|
+
* petId: pets.id,
|
|
1095
|
+
* })
|
|
1096
|
+
* .from(users)
|
|
1097
|
+
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
rightJoin = this.createJoin("right");
|
|
1101
|
+
/**
|
|
1102
|
+
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
1103
|
+
*
|
|
1104
|
+
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
|
1105
|
+
*
|
|
1106
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}
|
|
1107
|
+
*
|
|
1108
|
+
* @param table the table to join.
|
|
1109
|
+
* @param on the `on` clause.
|
|
1110
|
+
*
|
|
1111
|
+
* @example
|
|
1112
|
+
*
|
|
1113
|
+
* ```ts
|
|
1114
|
+
* // Select all users and their pets
|
|
1115
|
+
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
1116
|
+
* .from(users)
|
|
1117
|
+
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
1118
|
+
*
|
|
1119
|
+
* // Select userId and petId
|
|
1120
|
+
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
1121
|
+
* userId: users.id,
|
|
1122
|
+
* petId: pets.id,
|
|
1123
|
+
* })
|
|
1124
|
+
* .from(users)
|
|
1125
|
+
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
innerJoin = this.createJoin("inner");
|
|
1129
|
+
/**
|
|
1130
|
+
* Executes a `full join` operation by combining rows from two tables into a new table.
|
|
1131
|
+
*
|
|
1132
|
+
* Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
|
|
1133
|
+
*
|
|
1134
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
|
|
1135
|
+
*
|
|
1136
|
+
* @param table the table to join.
|
|
1137
|
+
* @param on the `on` clause.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
*
|
|
1141
|
+
* ```ts
|
|
1142
|
+
* // Select all users and their pets
|
|
1143
|
+
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
|
1144
|
+
* .from(users)
|
|
1145
|
+
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
1146
|
+
*
|
|
1147
|
+
* // Select userId and petId
|
|
1148
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
|
1149
|
+
* userId: users.id,
|
|
1150
|
+
* petId: pets.id,
|
|
1151
|
+
* })
|
|
1152
|
+
* .from(users)
|
|
1153
|
+
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
fullJoin = this.createJoin("full");
|
|
1157
|
+
createSetOperator(type, isAll) {
|
|
1158
|
+
return (rightSelection) => {
|
|
1159
|
+
const rightSelect = typeof rightSelection === "function" ? rightSelection(getSQLiteSetOperators()) : rightSelection;
|
|
1160
|
+
if (!(0,utils/* haveSameKeys */.DV)(this.getSelectedFields(), rightSelect.getSelectedFields())) {
|
|
1161
|
+
throw new Error(
|
|
1162
|
+
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
1165
|
+
this.config.setOperators.push({ type, isAll, rightSelect });
|
|
1166
|
+
return this;
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Adds `union` set operator to the query.
|
|
1171
|
+
*
|
|
1172
|
+
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
|
1173
|
+
*
|
|
1174
|
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
*
|
|
1178
|
+
* ```ts
|
|
1179
|
+
* // Select all unique names from customers and users tables
|
|
1180
|
+
* await db.select({ name: users.name })
|
|
1181
|
+
* .from(users)
|
|
1182
|
+
* .union(
|
|
1183
|
+
* db.select({ name: customers.name }).from(customers)
|
|
1184
|
+
* );
|
|
1185
|
+
* // or
|
|
1186
|
+
* import { union } from 'drizzle-orm/sqlite-core'
|
|
1187
|
+
*
|
|
1188
|
+
* await union(
|
|
1189
|
+
* db.select({ name: users.name }).from(users),
|
|
1190
|
+
* db.select({ name: customers.name }).from(customers)
|
|
1191
|
+
* );
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
union = this.createSetOperator("union", false);
|
|
1195
|
+
/**
|
|
1196
|
+
* Adds `union all` set operator to the query.
|
|
1197
|
+
*
|
|
1198
|
+
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
|
1199
|
+
*
|
|
1200
|
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
*
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* // Select all transaction ids from both online and in-store sales
|
|
1206
|
+
* await db.select({ transaction: onlineSales.transactionId })
|
|
1207
|
+
* .from(onlineSales)
|
|
1208
|
+
* .unionAll(
|
|
1209
|
+
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
|
1210
|
+
* );
|
|
1211
|
+
* // or
|
|
1212
|
+
* import { unionAll } from 'drizzle-orm/sqlite-core'
|
|
1213
|
+
*
|
|
1214
|
+
* await unionAll(
|
|
1215
|
+
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
|
1216
|
+
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
|
1217
|
+
* );
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
unionAll = this.createSetOperator("union", true);
|
|
1221
|
+
/**
|
|
1222
|
+
* Adds `intersect` set operator to the query.
|
|
1223
|
+
*
|
|
1224
|
+
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
|
1225
|
+
*
|
|
1226
|
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
*
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* // Select course names that are offered in both departments A and B
|
|
1232
|
+
* await db.select({ courseName: depA.courseName })
|
|
1233
|
+
* .from(depA)
|
|
1234
|
+
* .intersect(
|
|
1235
|
+
* db.select({ courseName: depB.courseName }).from(depB)
|
|
1236
|
+
* );
|
|
1237
|
+
* // or
|
|
1238
|
+
* import { intersect } from 'drizzle-orm/sqlite-core'
|
|
1239
|
+
*
|
|
1240
|
+
* await intersect(
|
|
1241
|
+
* db.select({ courseName: depA.courseName }).from(depA),
|
|
1242
|
+
* db.select({ courseName: depB.courseName }).from(depB)
|
|
1243
|
+
* );
|
|
1244
|
+
* ```
|
|
1245
|
+
*/
|
|
1246
|
+
intersect = this.createSetOperator("intersect", false);
|
|
1247
|
+
/**
|
|
1248
|
+
* Adds `except` set operator to the query.
|
|
1249
|
+
*
|
|
1250
|
+
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
|
1251
|
+
*
|
|
1252
|
+
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
*
|
|
1256
|
+
* ```ts
|
|
1257
|
+
* // Select all courses offered in department A but not in department B
|
|
1258
|
+
* await db.select({ courseName: depA.courseName })
|
|
1259
|
+
* .from(depA)
|
|
1260
|
+
* .except(
|
|
1261
|
+
* db.select({ courseName: depB.courseName }).from(depB)
|
|
1262
|
+
* );
|
|
1263
|
+
* // or
|
|
1264
|
+
* import { except } from 'drizzle-orm/sqlite-core'
|
|
1265
|
+
*
|
|
1266
|
+
* await except(
|
|
1267
|
+
* db.select({ courseName: depA.courseName }).from(depA),
|
|
1268
|
+
* db.select({ courseName: depB.courseName }).from(depB)
|
|
1269
|
+
* );
|
|
1270
|
+
* ```
|
|
1271
|
+
*/
|
|
1272
|
+
except = this.createSetOperator("except", false);
|
|
1273
|
+
/** @internal */
|
|
1274
|
+
addSetOperators(setOperators) {
|
|
1275
|
+
this.config.setOperators.push(...setOperators);
|
|
1276
|
+
return this;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Adds a `where` clause to the query.
|
|
1280
|
+
*
|
|
1281
|
+
* Calling this method will select only those rows that fulfill a specified condition.
|
|
1282
|
+
*
|
|
1283
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#filtering}
|
|
1284
|
+
*
|
|
1285
|
+
* @param where the `where` clause.
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* You can use conditional operators and `sql function` to filter the rows to be selected.
|
|
1289
|
+
*
|
|
1290
|
+
* ```ts
|
|
1291
|
+
* // Select all cars with green color
|
|
1292
|
+
* await db.select().from(cars).where(eq(cars.color, 'green'));
|
|
1293
|
+
* // or
|
|
1294
|
+
* await db.select().from(cars).where(sql`${cars.color} = 'green'`)
|
|
1295
|
+
* ```
|
|
1296
|
+
*
|
|
1297
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
1298
|
+
*
|
|
1299
|
+
* ```ts
|
|
1300
|
+
* // Select all BMW cars with a green color
|
|
1301
|
+
* await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
1302
|
+
*
|
|
1303
|
+
* // Select all cars with the green or blue color
|
|
1304
|
+
* await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
1305
|
+
* ```
|
|
1306
|
+
*/
|
|
1307
|
+
where(where) {
|
|
1308
|
+
if (typeof where === "function") {
|
|
1309
|
+
where = where(
|
|
1310
|
+
new Proxy(
|
|
1311
|
+
this.config.fields,
|
|
1312
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
|
1313
|
+
)
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1316
|
+
this.config.where = where;
|
|
1317
|
+
return this;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Adds a `having` clause to the query.
|
|
1321
|
+
*
|
|
1322
|
+
* Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.
|
|
1323
|
+
*
|
|
1324
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
|
1325
|
+
*
|
|
1326
|
+
* @param having the `having` clause.
|
|
1327
|
+
*
|
|
1328
|
+
* @example
|
|
1329
|
+
*
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* // Select all brands with more than one car
|
|
1332
|
+
* await db.select({
|
|
1333
|
+
* brand: cars.brand,
|
|
1334
|
+
* count: sql<number>`cast(count(${cars.id}) as int)`,
|
|
1335
|
+
* })
|
|
1336
|
+
* .from(cars)
|
|
1337
|
+
* .groupBy(cars.brand)
|
|
1338
|
+
* .having(({ count }) => gt(count, 1));
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
having(having) {
|
|
1342
|
+
if (typeof having === "function") {
|
|
1343
|
+
having = having(
|
|
1344
|
+
new Proxy(
|
|
1345
|
+
this.config.fields,
|
|
1346
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
|
1347
|
+
)
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
this.config.having = having;
|
|
1351
|
+
return this;
|
|
1352
|
+
}
|
|
1353
|
+
groupBy(...columns) {
|
|
1354
|
+
if (typeof columns[0] === "function") {
|
|
1355
|
+
const groupBy = columns[0](
|
|
1356
|
+
new Proxy(
|
|
1357
|
+
this.config.fields,
|
|
1358
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
|
1359
|
+
)
|
|
1360
|
+
);
|
|
1361
|
+
this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
|
|
1362
|
+
} else {
|
|
1363
|
+
this.config.groupBy = columns;
|
|
1364
|
+
}
|
|
1365
|
+
return this;
|
|
1366
|
+
}
|
|
1367
|
+
orderBy(...columns) {
|
|
1368
|
+
if (typeof columns[0] === "function") {
|
|
1369
|
+
const orderBy = columns[0](
|
|
1370
|
+
new Proxy(
|
|
1371
|
+
this.config.fields,
|
|
1372
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
|
1373
|
+
)
|
|
1374
|
+
);
|
|
1375
|
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
1376
|
+
if (this.config.setOperators.length > 0) {
|
|
1377
|
+
this.config.setOperators.at(-1).orderBy = orderByArray;
|
|
1378
|
+
} else {
|
|
1379
|
+
this.config.orderBy = orderByArray;
|
|
1380
|
+
}
|
|
1381
|
+
} else {
|
|
1382
|
+
const orderByArray = columns;
|
|
1383
|
+
if (this.config.setOperators.length > 0) {
|
|
1384
|
+
this.config.setOperators.at(-1).orderBy = orderByArray;
|
|
1385
|
+
} else {
|
|
1386
|
+
this.config.orderBy = orderByArray;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return this;
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Adds a `limit` clause to the query.
|
|
1393
|
+
*
|
|
1394
|
+
* Calling this method will set the maximum number of rows that will be returned by this query.
|
|
1395
|
+
*
|
|
1396
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
|
1397
|
+
*
|
|
1398
|
+
* @param limit the `limit` clause.
|
|
1399
|
+
*
|
|
1400
|
+
* @example
|
|
1401
|
+
*
|
|
1402
|
+
* ```ts
|
|
1403
|
+
* // Get the first 10 people from this query.
|
|
1404
|
+
* await db.select().from(people).limit(10);
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
1407
|
+
limit(limit) {
|
|
1408
|
+
if (this.config.setOperators.length > 0) {
|
|
1409
|
+
this.config.setOperators.at(-1).limit = limit;
|
|
1410
|
+
} else {
|
|
1411
|
+
this.config.limit = limit;
|
|
1412
|
+
}
|
|
1413
|
+
return this;
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Adds an `offset` clause to the query.
|
|
1417
|
+
*
|
|
1418
|
+
* Calling this method will skip a number of rows when returning results from this query.
|
|
1419
|
+
*
|
|
1420
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
|
1421
|
+
*
|
|
1422
|
+
* @param offset the `offset` clause.
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
*
|
|
1426
|
+
* ```ts
|
|
1427
|
+
* // Get the 10th-20th people from this query.
|
|
1428
|
+
* await db.select().from(people).offset(10).limit(10);
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
offset(offset) {
|
|
1432
|
+
if (this.config.setOperators.length > 0) {
|
|
1433
|
+
this.config.setOperators.at(-1).offset = offset;
|
|
1434
|
+
} else {
|
|
1435
|
+
this.config.offset = offset;
|
|
1436
|
+
}
|
|
1437
|
+
return this;
|
|
1438
|
+
}
|
|
1439
|
+
/** @internal */
|
|
1440
|
+
getSQL() {
|
|
1441
|
+
return this.dialect.buildSelectQuery(this.config);
|
|
1442
|
+
}
|
|
1443
|
+
toSQL() {
|
|
1444
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
1445
|
+
return rest;
|
|
1446
|
+
}
|
|
1447
|
+
as(alias) {
|
|
1448
|
+
return new Proxy(
|
|
1449
|
+
new subquery/* Subquery */.n(this.getSQL(), this.config.fields, alias),
|
|
1450
|
+
new selection_proxy/* SelectionProxyHandler */.b({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
/** @internal */
|
|
1454
|
+
getSelectedFields() {
|
|
1455
|
+
return new Proxy(
|
|
1456
|
+
this.config.fields,
|
|
1457
|
+
new selection_proxy/* SelectionProxyHandler */.b({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
$dynamic() {
|
|
1461
|
+
return this;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
class SQLiteSelectBase extends SQLiteSelectQueryBuilderBase {
|
|
1465
|
+
static [entity/* entityKind */.i] = "SQLiteSelect";
|
|
1466
|
+
/** @internal */
|
|
1467
|
+
_prepare(isOneTimeQuery = true) {
|
|
1468
|
+
if (!this.session) {
|
|
1469
|
+
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
|
1470
|
+
}
|
|
1471
|
+
const fieldsList = (0,utils/* orderSelectedFields */.He)(this.config.fields);
|
|
1472
|
+
const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
|
1473
|
+
this.dialect.sqlToQuery(this.getSQL()),
|
|
1474
|
+
fieldsList,
|
|
1475
|
+
"all",
|
|
1476
|
+
true
|
|
1477
|
+
);
|
|
1478
|
+
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
|
1479
|
+
return query;
|
|
1480
|
+
}
|
|
1481
|
+
prepare() {
|
|
1482
|
+
return this._prepare(false);
|
|
1483
|
+
}
|
|
1484
|
+
run = (placeholderValues) => {
|
|
1485
|
+
return this._prepare().run(placeholderValues);
|
|
1486
|
+
};
|
|
1487
|
+
all = (placeholderValues) => {
|
|
1488
|
+
return this._prepare().all(placeholderValues);
|
|
1489
|
+
};
|
|
1490
|
+
get = (placeholderValues) => {
|
|
1491
|
+
return this._prepare().get(placeholderValues);
|
|
1492
|
+
};
|
|
1493
|
+
values = (placeholderValues) => {
|
|
1494
|
+
return this._prepare().values(placeholderValues);
|
|
1495
|
+
};
|
|
1496
|
+
async execute() {
|
|
1497
|
+
return this.all();
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
(0,utils/* applyMixins */.XJ)(SQLiteSelectBase, [query_promise/* QueryPromise */.k]);
|
|
1501
|
+
function createSetOperator(type, isAll) {
|
|
1502
|
+
return (leftSelect, rightSelect, ...restSelects) => {
|
|
1503
|
+
const setOperators = [rightSelect, ...restSelects].map((select) => ({
|
|
1504
|
+
type,
|
|
1505
|
+
isAll,
|
|
1506
|
+
rightSelect: select
|
|
1507
|
+
}));
|
|
1508
|
+
for (const setOperator of setOperators) {
|
|
1509
|
+
if (!(0,utils/* haveSameKeys */.DV)(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {
|
|
1510
|
+
throw new Error(
|
|
1511
|
+
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return leftSelect.addSetOperators(setOperators);
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
const getSQLiteSetOperators = () => ({
|
|
1519
|
+
union,
|
|
1520
|
+
unionAll,
|
|
1521
|
+
intersect,
|
|
1522
|
+
except
|
|
1523
|
+
});
|
|
1524
|
+
const union = createSetOperator("union", false);
|
|
1525
|
+
const unionAll = createSetOperator("union", true);
|
|
1526
|
+
const intersect = createSetOperator("intersect", false);
|
|
1527
|
+
const except = createSetOperator("except", false);
|
|
1528
|
+
|
|
1529
|
+
//# sourceMappingURL=select.js.map
|
|
1530
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
class QueryBuilder {
|
|
1537
|
+
static [entity/* entityKind */.i] = "SQLiteQueryBuilder";
|
|
1538
|
+
dialect;
|
|
1539
|
+
dialectConfig;
|
|
1540
|
+
constructor(dialect) {
|
|
1541
|
+
this.dialect = (0,entity.is)(dialect, SQLiteDialect) ? dialect : void 0;
|
|
1542
|
+
this.dialectConfig = (0,entity.is)(dialect, SQLiteDialect) ? void 0 : dialect;
|
|
1543
|
+
}
|
|
1544
|
+
$with(alias) {
|
|
1545
|
+
const queryBuilder = this;
|
|
1546
|
+
return {
|
|
1547
|
+
as(qb) {
|
|
1548
|
+
if (typeof qb === "function") {
|
|
1549
|
+
qb = qb(queryBuilder);
|
|
1550
|
+
}
|
|
1551
|
+
return new Proxy(
|
|
1552
|
+
new subquery/* WithSubquery */.J(qb.getSQL(), qb.getSelectedFields(), alias, true),
|
|
1553
|
+
new selection_proxy/* SelectionProxyHandler */.b({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
with(...queries) {
|
|
1559
|
+
const self = this;
|
|
1560
|
+
function select(fields) {
|
|
1561
|
+
return new SQLiteSelectBuilder({
|
|
1562
|
+
fields: fields ?? void 0,
|
|
1563
|
+
session: void 0,
|
|
1564
|
+
dialect: self.getDialect(),
|
|
1565
|
+
withList: queries
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
function selectDistinct(fields) {
|
|
1569
|
+
return new SQLiteSelectBuilder({
|
|
1570
|
+
fields: fields ?? void 0,
|
|
1571
|
+
session: void 0,
|
|
1572
|
+
dialect: self.getDialect(),
|
|
1573
|
+
withList: queries,
|
|
1574
|
+
distinct: true
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
return { select, selectDistinct };
|
|
1578
|
+
}
|
|
1579
|
+
select(fields) {
|
|
1580
|
+
return new SQLiteSelectBuilder({ fields: fields ?? void 0, session: void 0, dialect: this.getDialect() });
|
|
1581
|
+
}
|
|
1582
|
+
selectDistinct(fields) {
|
|
1583
|
+
return new SQLiteSelectBuilder({
|
|
1584
|
+
fields: fields ?? void 0,
|
|
1585
|
+
session: void 0,
|
|
1586
|
+
dialect: this.getDialect(),
|
|
1587
|
+
distinct: true
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
// Lazy load dialect to avoid circular dependency
|
|
1591
|
+
getDialect() {
|
|
1592
|
+
if (!this.dialect) {
|
|
1593
|
+
this.dialect = new SQLiteSyncDialect(this.dialectConfig);
|
|
1594
|
+
}
|
|
1595
|
+
return this.dialect;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
//# sourceMappingURL=query-builder.js.map
|
|
1600
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/update.js
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
class SQLiteUpdateBuilder {
|
|
1611
|
+
constructor(table, session, dialect, withList) {
|
|
1612
|
+
this.table = table;
|
|
1613
|
+
this.session = session;
|
|
1614
|
+
this.dialect = dialect;
|
|
1615
|
+
this.withList = withList;
|
|
1616
|
+
}
|
|
1617
|
+
static [entity/* entityKind */.i] = "SQLiteUpdateBuilder";
|
|
1618
|
+
set(values) {
|
|
1619
|
+
return new SQLiteUpdateBase(
|
|
1620
|
+
this.table,
|
|
1621
|
+
(0,utils/* mapUpdateSet */.q)(this.table, values),
|
|
1622
|
+
this.session,
|
|
1623
|
+
this.dialect,
|
|
1624
|
+
this.withList
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
class SQLiteUpdateBase extends query_promise/* QueryPromise */.k {
|
|
1629
|
+
constructor(table, set, session, dialect, withList) {
|
|
1630
|
+
super();
|
|
1631
|
+
this.session = session;
|
|
1632
|
+
this.dialect = dialect;
|
|
1633
|
+
this.config = { set, table, withList, joins: [] };
|
|
1634
|
+
}
|
|
1635
|
+
static [entity/* entityKind */.i] = "SQLiteUpdate";
|
|
1636
|
+
/** @internal */
|
|
1637
|
+
config;
|
|
1638
|
+
from(source) {
|
|
1639
|
+
this.config.from = source;
|
|
1640
|
+
return this;
|
|
1641
|
+
}
|
|
1642
|
+
createJoin(joinType) {
|
|
1643
|
+
return (table, on) => {
|
|
1644
|
+
const tableName = (0,utils/* getTableLikeName */.zN)(table);
|
|
1645
|
+
if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) {
|
|
1646
|
+
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
1647
|
+
}
|
|
1648
|
+
if (typeof on === "function") {
|
|
1649
|
+
const from = this.config.from ? (0,entity.is)(table, sqlite_core_table/* SQLiteTable */.jo) ? table[drizzle_orm_table/* Table */.XI.Symbol.Columns] : (0,entity.is)(table, subquery/* Subquery */.n) ? table._.selectedFields : (0,entity.is)(table, SQLiteViewBase) ? table[view_common/* ViewBaseConfig */.n].selectedFields : void 0 : void 0;
|
|
1650
|
+
on = on(
|
|
1651
|
+
new Proxy(
|
|
1652
|
+
this.config.table[drizzle_orm_table/* Table */.XI.Symbol.Columns],
|
|
1653
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
|
1654
|
+
),
|
|
1655
|
+
from && new Proxy(
|
|
1656
|
+
from,
|
|
1657
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
|
1658
|
+
)
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
this.config.joins.push({ on, table, joinType, alias: tableName });
|
|
1662
|
+
return this;
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
leftJoin = this.createJoin("left");
|
|
1666
|
+
rightJoin = this.createJoin("right");
|
|
1667
|
+
innerJoin = this.createJoin("inner");
|
|
1668
|
+
fullJoin = this.createJoin("full");
|
|
1669
|
+
/**
|
|
1670
|
+
* Adds a 'where' clause to the query.
|
|
1671
|
+
*
|
|
1672
|
+
* Calling this method will update only those rows that fulfill a specified condition.
|
|
1673
|
+
*
|
|
1674
|
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
|
1675
|
+
*
|
|
1676
|
+
* @param where the 'where' clause.
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
|
1680
|
+
*
|
|
1681
|
+
* ```ts
|
|
1682
|
+
* // Update all cars with green color
|
|
1683
|
+
* db.update(cars).set({ color: 'red' })
|
|
1684
|
+
* .where(eq(cars.color, 'green'));
|
|
1685
|
+
* // or
|
|
1686
|
+
* db.update(cars).set({ color: 'red' })
|
|
1687
|
+
* .where(sql`${cars.color} = 'green'`)
|
|
1688
|
+
* ```
|
|
1689
|
+
*
|
|
1690
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
1691
|
+
*
|
|
1692
|
+
* ```ts
|
|
1693
|
+
* // Update all BMW cars with a green color
|
|
1694
|
+
* db.update(cars).set({ color: 'red' })
|
|
1695
|
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
1696
|
+
*
|
|
1697
|
+
* // Update all cars with the green or blue color
|
|
1698
|
+
* db.update(cars).set({ color: 'red' })
|
|
1699
|
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
1700
|
+
* ```
|
|
1701
|
+
*/
|
|
1702
|
+
where(where) {
|
|
1703
|
+
this.config.where = where;
|
|
1704
|
+
return this;
|
|
1705
|
+
}
|
|
1706
|
+
orderBy(...columns) {
|
|
1707
|
+
if (typeof columns[0] === "function") {
|
|
1708
|
+
const orderBy = columns[0](
|
|
1709
|
+
new Proxy(
|
|
1710
|
+
this.config.table[drizzle_orm_table/* Table */.XI.Symbol.Columns],
|
|
1711
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
|
1712
|
+
)
|
|
1713
|
+
);
|
|
1714
|
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
1715
|
+
this.config.orderBy = orderByArray;
|
|
1716
|
+
} else {
|
|
1717
|
+
const orderByArray = columns;
|
|
1718
|
+
this.config.orderBy = orderByArray;
|
|
1719
|
+
}
|
|
1720
|
+
return this;
|
|
1721
|
+
}
|
|
1722
|
+
limit(limit) {
|
|
1723
|
+
this.config.limit = limit;
|
|
1724
|
+
return this;
|
|
1725
|
+
}
|
|
1726
|
+
returning(fields = this.config.table[sqlite_core_table/* SQLiteTable */.jo.Symbol.Columns]) {
|
|
1727
|
+
this.config.returning = (0,utils/* orderSelectedFields */.He)(fields);
|
|
1728
|
+
return this;
|
|
1729
|
+
}
|
|
1730
|
+
/** @internal */
|
|
1731
|
+
getSQL() {
|
|
1732
|
+
return this.dialect.buildUpdateQuery(this.config);
|
|
1733
|
+
}
|
|
1734
|
+
toSQL() {
|
|
1735
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
1736
|
+
return rest;
|
|
1737
|
+
}
|
|
1738
|
+
/** @internal */
|
|
1739
|
+
_prepare(isOneTimeQuery = true) {
|
|
1740
|
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
|
1741
|
+
this.dialect.sqlToQuery(this.getSQL()),
|
|
1742
|
+
this.config.returning,
|
|
1743
|
+
this.config.returning ? "all" : "run",
|
|
1744
|
+
true
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
prepare() {
|
|
1748
|
+
return this._prepare(false);
|
|
1749
|
+
}
|
|
1750
|
+
run = (placeholderValues) => {
|
|
1751
|
+
return this._prepare().run(placeholderValues);
|
|
1752
|
+
};
|
|
1753
|
+
all = (placeholderValues) => {
|
|
1754
|
+
return this._prepare().all(placeholderValues);
|
|
1755
|
+
};
|
|
1756
|
+
get = (placeholderValues) => {
|
|
1757
|
+
return this._prepare().get(placeholderValues);
|
|
1758
|
+
};
|
|
1759
|
+
values = (placeholderValues) => {
|
|
1760
|
+
return this._prepare().values(placeholderValues);
|
|
1761
|
+
};
|
|
1762
|
+
async execute() {
|
|
1763
|
+
return this.config.returning ? this.all() : this.run();
|
|
1764
|
+
}
|
|
1765
|
+
$dynamic() {
|
|
1766
|
+
return this;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
//# sourceMappingURL=update.js.map
|
|
1771
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
class SQLiteInsertBuilder {
|
|
1780
|
+
constructor(table, session, dialect, withList) {
|
|
1781
|
+
this.table = table;
|
|
1782
|
+
this.session = session;
|
|
1783
|
+
this.dialect = dialect;
|
|
1784
|
+
this.withList = withList;
|
|
1785
|
+
}
|
|
1786
|
+
static [entity/* entityKind */.i] = "SQLiteInsertBuilder";
|
|
1787
|
+
values(values) {
|
|
1788
|
+
values = Array.isArray(values) ? values : [values];
|
|
1789
|
+
if (values.length === 0) {
|
|
1790
|
+
throw new Error("values() must be called with at least one value");
|
|
1791
|
+
}
|
|
1792
|
+
const mappedValues = values.map((entry) => {
|
|
1793
|
+
const result = {};
|
|
1794
|
+
const cols = this.table[drizzle_orm_table/* Table */.XI.Symbol.Columns];
|
|
1795
|
+
for (const colKey of Object.keys(entry)) {
|
|
1796
|
+
const colValue = entry[colKey];
|
|
1797
|
+
result[colKey] = (0,entity.is)(colValue, sql/* SQL */.Xs) ? colValue : new sql/* Param */.Iw(colValue, cols[colKey]);
|
|
1798
|
+
}
|
|
1799
|
+
return result;
|
|
1800
|
+
});
|
|
1801
|
+
return new SQLiteInsertBase(this.table, mappedValues, this.session, this.dialect, this.withList);
|
|
1802
|
+
}
|
|
1803
|
+
select(selectQuery) {
|
|
1804
|
+
const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder()) : selectQuery;
|
|
1805
|
+
if (!(0,entity.is)(select, sql/* SQL */.Xs) && !(0,utils/* haveSameKeys */.DV)(this.table[drizzle_orm_table/* Columns */.e], select._.selectedFields)) {
|
|
1806
|
+
throw new Error(
|
|
1807
|
+
"Insert select error: selected fields are not the same or are in a different order compared to the table definition"
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1810
|
+
return new SQLiteInsertBase(this.table, select, this.session, this.dialect, this.withList, true);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
class SQLiteInsertBase extends query_promise/* QueryPromise */.k {
|
|
1814
|
+
constructor(table, values, session, dialect, withList, select) {
|
|
1815
|
+
super();
|
|
1816
|
+
this.session = session;
|
|
1817
|
+
this.dialect = dialect;
|
|
1818
|
+
this.config = { table, values, withList, select };
|
|
1819
|
+
}
|
|
1820
|
+
static [entity/* entityKind */.i] = "SQLiteInsert";
|
|
1821
|
+
/** @internal */
|
|
1822
|
+
config;
|
|
1823
|
+
returning(fields = this.config.table[sqlite_core_table/* SQLiteTable */.jo.Symbol.Columns]) {
|
|
1824
|
+
this.config.returning = (0,utils/* orderSelectedFields */.He)(fields);
|
|
1825
|
+
return this;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Adds an `on conflict do nothing` clause to the query.
|
|
1829
|
+
*
|
|
1830
|
+
* Calling this method simply avoids inserting a row as its alternative action.
|
|
1831
|
+
*
|
|
1832
|
+
* See docs: {@link https://orm.drizzle.team/docs/insert#on-conflict-do-nothing}
|
|
1833
|
+
*
|
|
1834
|
+
* @param config The `target` and `where` clauses.
|
|
1835
|
+
*
|
|
1836
|
+
* @example
|
|
1837
|
+
* ```ts
|
|
1838
|
+
* // Insert one row and cancel the insert if there's a conflict
|
|
1839
|
+
* await db.insert(cars)
|
|
1840
|
+
* .values({ id: 1, brand: 'BMW' })
|
|
1841
|
+
* .onConflictDoNothing();
|
|
1842
|
+
*
|
|
1843
|
+
* // Explicitly specify conflict target
|
|
1844
|
+
* await db.insert(cars)
|
|
1845
|
+
* .values({ id: 1, brand: 'BMW' })
|
|
1846
|
+
* .onConflictDoNothing({ target: cars.id });
|
|
1847
|
+
* ```
|
|
1848
|
+
*/
|
|
1849
|
+
onConflictDoNothing(config = {}) {
|
|
1850
|
+
if (config.target === void 0) {
|
|
1851
|
+
this.config.onConflict = (0,sql/* sql */.ll)`do nothing`;
|
|
1852
|
+
} else {
|
|
1853
|
+
const targetSql = Array.isArray(config.target) ? (0,sql/* sql */.ll)`${config.target}` : (0,sql/* sql */.ll)`${[config.target]}`;
|
|
1854
|
+
const whereSql = config.where ? (0,sql/* sql */.ll)` where ${config.where}` : (0,sql/* sql */.ll)``;
|
|
1855
|
+
this.config.onConflict = (0,sql/* sql */.ll)`${targetSql} do nothing${whereSql}`;
|
|
1856
|
+
}
|
|
1857
|
+
return this;
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Adds an `on conflict do update` clause to the query.
|
|
1861
|
+
*
|
|
1862
|
+
* Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.
|
|
1863
|
+
*
|
|
1864
|
+
* See docs: {@link https://orm.drizzle.team/docs/insert#upserts-and-conflicts}
|
|
1865
|
+
*
|
|
1866
|
+
* @param config The `target`, `set` and `where` clauses.
|
|
1867
|
+
*
|
|
1868
|
+
* @example
|
|
1869
|
+
* ```ts
|
|
1870
|
+
* // Update the row if there's a conflict
|
|
1871
|
+
* await db.insert(cars)
|
|
1872
|
+
* .values({ id: 1, brand: 'BMW' })
|
|
1873
|
+
* .onConflictDoUpdate({
|
|
1874
|
+
* target: cars.id,
|
|
1875
|
+
* set: { brand: 'Porsche' }
|
|
1876
|
+
* });
|
|
1877
|
+
*
|
|
1878
|
+
* // Upsert with 'where' clause
|
|
1879
|
+
* await db.insert(cars)
|
|
1880
|
+
* .values({ id: 1, brand: 'BMW' })
|
|
1881
|
+
* .onConflictDoUpdate({
|
|
1882
|
+
* target: cars.id,
|
|
1883
|
+
* set: { brand: 'newBMW' },
|
|
1884
|
+
* where: sql`${cars.createdAt} > '2023-01-01'::date`,
|
|
1885
|
+
* });
|
|
1886
|
+
* ```
|
|
1887
|
+
*/
|
|
1888
|
+
onConflictDoUpdate(config) {
|
|
1889
|
+
if (config.where && (config.targetWhere || config.setWhere)) {
|
|
1890
|
+
throw new Error(
|
|
1891
|
+
'You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.'
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
const whereSql = config.where ? (0,sql/* sql */.ll)` where ${config.where}` : void 0;
|
|
1895
|
+
const targetWhereSql = config.targetWhere ? (0,sql/* sql */.ll)` where ${config.targetWhere}` : void 0;
|
|
1896
|
+
const setWhereSql = config.setWhere ? (0,sql/* sql */.ll)` where ${config.setWhere}` : void 0;
|
|
1897
|
+
const targetSql = Array.isArray(config.target) ? (0,sql/* sql */.ll)`${config.target}` : (0,sql/* sql */.ll)`${[config.target]}`;
|
|
1898
|
+
const setSql = this.dialect.buildUpdateSet(this.config.table, (0,utils/* mapUpdateSet */.q)(this.config.table, config.set));
|
|
1899
|
+
this.config.onConflict = (0,sql/* sql */.ll)`${targetSql}${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;
|
|
1900
|
+
return this;
|
|
1901
|
+
}
|
|
1902
|
+
/** @internal */
|
|
1903
|
+
getSQL() {
|
|
1904
|
+
return this.dialect.buildInsertQuery(this.config);
|
|
1905
|
+
}
|
|
1906
|
+
toSQL() {
|
|
1907
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
1908
|
+
return rest;
|
|
1909
|
+
}
|
|
1910
|
+
/** @internal */
|
|
1911
|
+
_prepare(isOneTimeQuery = true) {
|
|
1912
|
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
|
1913
|
+
this.dialect.sqlToQuery(this.getSQL()),
|
|
1914
|
+
this.config.returning,
|
|
1915
|
+
this.config.returning ? "all" : "run",
|
|
1916
|
+
true
|
|
1917
|
+
);
|
|
1918
|
+
}
|
|
1919
|
+
prepare() {
|
|
1920
|
+
return this._prepare(false);
|
|
1921
|
+
}
|
|
1922
|
+
run = (placeholderValues) => {
|
|
1923
|
+
return this._prepare().run(placeholderValues);
|
|
1924
|
+
};
|
|
1925
|
+
all = (placeholderValues) => {
|
|
1926
|
+
return this._prepare().all(placeholderValues);
|
|
1927
|
+
};
|
|
1928
|
+
get = (placeholderValues) => {
|
|
1929
|
+
return this._prepare().get(placeholderValues);
|
|
1930
|
+
};
|
|
1931
|
+
values = (placeholderValues) => {
|
|
1932
|
+
return this._prepare().values(placeholderValues);
|
|
1933
|
+
};
|
|
1934
|
+
async execute() {
|
|
1935
|
+
return this.config.returning ? this.all() : this.run();
|
|
1936
|
+
}
|
|
1937
|
+
$dynamic() {
|
|
1938
|
+
return this;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
//# sourceMappingURL=insert.js.map
|
|
1943
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/delete.js
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
class SQLiteDeleteBase extends query_promise/* QueryPromise */.k {
|
|
1951
|
+
constructor(table, session, dialect, withList) {
|
|
1952
|
+
super();
|
|
1953
|
+
this.table = table;
|
|
1954
|
+
this.session = session;
|
|
1955
|
+
this.dialect = dialect;
|
|
1956
|
+
this.config = { table, withList };
|
|
1957
|
+
}
|
|
1958
|
+
static [entity/* entityKind */.i] = "SQLiteDelete";
|
|
1959
|
+
/** @internal */
|
|
1960
|
+
config;
|
|
1961
|
+
/**
|
|
1962
|
+
* Adds a `where` clause to the query.
|
|
1963
|
+
*
|
|
1964
|
+
* Calling this method will delete only those rows that fulfill a specified condition.
|
|
1965
|
+
*
|
|
1966
|
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
|
1967
|
+
*
|
|
1968
|
+
* @param where the `where` clause.
|
|
1969
|
+
*
|
|
1970
|
+
* @example
|
|
1971
|
+
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
|
1972
|
+
*
|
|
1973
|
+
* ```ts
|
|
1974
|
+
* // Delete all cars with green color
|
|
1975
|
+
* db.delete(cars).where(eq(cars.color, 'green'));
|
|
1976
|
+
* // or
|
|
1977
|
+
* db.delete(cars).where(sql`${cars.color} = 'green'`)
|
|
1978
|
+
* ```
|
|
1979
|
+
*
|
|
1980
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
1981
|
+
*
|
|
1982
|
+
* ```ts
|
|
1983
|
+
* // Delete all BMW cars with a green color
|
|
1984
|
+
* db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
1985
|
+
*
|
|
1986
|
+
* // Delete all cars with the green or blue color
|
|
1987
|
+
* db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
1988
|
+
* ```
|
|
1989
|
+
*/
|
|
1990
|
+
where(where) {
|
|
1991
|
+
this.config.where = where;
|
|
1992
|
+
return this;
|
|
1993
|
+
}
|
|
1994
|
+
orderBy(...columns) {
|
|
1995
|
+
if (typeof columns[0] === "function") {
|
|
1996
|
+
const orderBy = columns[0](
|
|
1997
|
+
new Proxy(
|
|
1998
|
+
this.config.table[drizzle_orm_table/* Table */.XI.Symbol.Columns],
|
|
1999
|
+
new selection_proxy/* SelectionProxyHandler */.b({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
|
2000
|
+
)
|
|
2001
|
+
);
|
|
2002
|
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
2003
|
+
this.config.orderBy = orderByArray;
|
|
2004
|
+
} else {
|
|
2005
|
+
const orderByArray = columns;
|
|
2006
|
+
this.config.orderBy = orderByArray;
|
|
2007
|
+
}
|
|
2008
|
+
return this;
|
|
2009
|
+
}
|
|
2010
|
+
limit(limit) {
|
|
2011
|
+
this.config.limit = limit;
|
|
2012
|
+
return this;
|
|
2013
|
+
}
|
|
2014
|
+
returning(fields = this.table[sqlite_core_table/* SQLiteTable */.jo.Symbol.Columns]) {
|
|
2015
|
+
this.config.returning = (0,utils/* orderSelectedFields */.He)(fields);
|
|
2016
|
+
return this;
|
|
2017
|
+
}
|
|
2018
|
+
/** @internal */
|
|
2019
|
+
getSQL() {
|
|
2020
|
+
return this.dialect.buildDeleteQuery(this.config);
|
|
2021
|
+
}
|
|
2022
|
+
toSQL() {
|
|
2023
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
2024
|
+
return rest;
|
|
2025
|
+
}
|
|
2026
|
+
/** @internal */
|
|
2027
|
+
_prepare(isOneTimeQuery = true) {
|
|
2028
|
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
|
2029
|
+
this.dialect.sqlToQuery(this.getSQL()),
|
|
2030
|
+
this.config.returning,
|
|
2031
|
+
this.config.returning ? "all" : "run",
|
|
2032
|
+
true
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
prepare() {
|
|
2036
|
+
return this._prepare(false);
|
|
2037
|
+
}
|
|
2038
|
+
run = (placeholderValues) => {
|
|
2039
|
+
return this._prepare().run(placeholderValues);
|
|
2040
|
+
};
|
|
2041
|
+
all = (placeholderValues) => {
|
|
2042
|
+
return this._prepare().all(placeholderValues);
|
|
2043
|
+
};
|
|
2044
|
+
get = (placeholderValues) => {
|
|
2045
|
+
return this._prepare().get(placeholderValues);
|
|
2046
|
+
};
|
|
2047
|
+
values = (placeholderValues) => {
|
|
2048
|
+
return this._prepare().values(placeholderValues);
|
|
2049
|
+
};
|
|
2050
|
+
async execute(placeholderValues) {
|
|
2051
|
+
return this._prepare().execute(placeholderValues);
|
|
2052
|
+
}
|
|
2053
|
+
$dynamic() {
|
|
2054
|
+
return this;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
//# sourceMappingURL=delete.js.map
|
|
2059
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/count.js
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
class SQLiteCountBuilder extends sql/* SQL */.Xs {
|
|
2063
|
+
constructor(params) {
|
|
2064
|
+
super(SQLiteCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
|
2065
|
+
this.params = params;
|
|
2066
|
+
this.session = params.session;
|
|
2067
|
+
this.sql = SQLiteCountBuilder.buildCount(
|
|
2068
|
+
params.source,
|
|
2069
|
+
params.filters
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
2072
|
+
sql;
|
|
2073
|
+
static [entity/* entityKind */.i] = "SQLiteCountBuilderAsync";
|
|
2074
|
+
[Symbol.toStringTag] = "SQLiteCountBuilderAsync";
|
|
2075
|
+
session;
|
|
2076
|
+
static buildEmbeddedCount(source, filters) {
|
|
2077
|
+
return (0,sql/* sql */.ll)`(select count(*) from ${source}${sql/* sql */.ll.raw(" where ").if(filters)}${filters})`;
|
|
2078
|
+
}
|
|
2079
|
+
static buildCount(source, filters) {
|
|
2080
|
+
return (0,sql/* sql */.ll)`select count(*) from ${source}${sql/* sql */.ll.raw(" where ").if(filters)}${filters}`;
|
|
2081
|
+
}
|
|
2082
|
+
then(onfulfilled, onrejected) {
|
|
2083
|
+
return Promise.resolve(this.session.count(this.sql)).then(
|
|
2084
|
+
onfulfilled,
|
|
2085
|
+
onrejected
|
|
2086
|
+
);
|
|
2087
|
+
}
|
|
2088
|
+
catch(onRejected) {
|
|
2089
|
+
return this.then(void 0, onRejected);
|
|
2090
|
+
}
|
|
2091
|
+
finally(onFinally) {
|
|
2092
|
+
return this.then(
|
|
2093
|
+
(value) => {
|
|
2094
|
+
onFinally?.();
|
|
2095
|
+
return value;
|
|
2096
|
+
},
|
|
2097
|
+
(reason) => {
|
|
2098
|
+
onFinally?.();
|
|
2099
|
+
throw reason;
|
|
2100
|
+
}
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
//# sourceMappingURL=count.js.map
|
|
2106
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/query.js
|
|
2107
|
+
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
class RelationalQueryBuilder {
|
|
2111
|
+
constructor(mode, fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
|
2112
|
+
this.mode = mode;
|
|
2113
|
+
this.fullSchema = fullSchema;
|
|
2114
|
+
this.schema = schema;
|
|
2115
|
+
this.tableNamesMap = tableNamesMap;
|
|
2116
|
+
this.table = table;
|
|
2117
|
+
this.tableConfig = tableConfig;
|
|
2118
|
+
this.dialect = dialect;
|
|
2119
|
+
this.session = session;
|
|
2120
|
+
}
|
|
2121
|
+
static [entity/* entityKind */.i] = "SQLiteAsyncRelationalQueryBuilder";
|
|
2122
|
+
findMany(config) {
|
|
2123
|
+
return this.mode === "sync" ? new SQLiteSyncRelationalQuery(
|
|
2124
|
+
this.fullSchema,
|
|
2125
|
+
this.schema,
|
|
2126
|
+
this.tableNamesMap,
|
|
2127
|
+
this.table,
|
|
2128
|
+
this.tableConfig,
|
|
2129
|
+
this.dialect,
|
|
2130
|
+
this.session,
|
|
2131
|
+
config ? config : {},
|
|
2132
|
+
"many"
|
|
2133
|
+
) : new SQLiteRelationalQuery(
|
|
2134
|
+
this.fullSchema,
|
|
2135
|
+
this.schema,
|
|
2136
|
+
this.tableNamesMap,
|
|
2137
|
+
this.table,
|
|
2138
|
+
this.tableConfig,
|
|
2139
|
+
this.dialect,
|
|
2140
|
+
this.session,
|
|
2141
|
+
config ? config : {},
|
|
2142
|
+
"many"
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
findFirst(config) {
|
|
2146
|
+
return this.mode === "sync" ? new SQLiteSyncRelationalQuery(
|
|
2147
|
+
this.fullSchema,
|
|
2148
|
+
this.schema,
|
|
2149
|
+
this.tableNamesMap,
|
|
2150
|
+
this.table,
|
|
2151
|
+
this.tableConfig,
|
|
2152
|
+
this.dialect,
|
|
2153
|
+
this.session,
|
|
2154
|
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
|
2155
|
+
"first"
|
|
2156
|
+
) : new SQLiteRelationalQuery(
|
|
2157
|
+
this.fullSchema,
|
|
2158
|
+
this.schema,
|
|
2159
|
+
this.tableNamesMap,
|
|
2160
|
+
this.table,
|
|
2161
|
+
this.tableConfig,
|
|
2162
|
+
this.dialect,
|
|
2163
|
+
this.session,
|
|
2164
|
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
|
2165
|
+
"first"
|
|
2166
|
+
);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
class SQLiteRelationalQuery extends query_promise/* QueryPromise */.k {
|
|
2170
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
|
2171
|
+
super();
|
|
2172
|
+
this.fullSchema = fullSchema;
|
|
2173
|
+
this.schema = schema;
|
|
2174
|
+
this.tableNamesMap = tableNamesMap;
|
|
2175
|
+
this.table = table;
|
|
2176
|
+
this.tableConfig = tableConfig;
|
|
2177
|
+
this.dialect = dialect;
|
|
2178
|
+
this.session = session;
|
|
2179
|
+
this.config = config;
|
|
2180
|
+
this.mode = mode;
|
|
2181
|
+
}
|
|
2182
|
+
static [entity/* entityKind */.i] = "SQLiteAsyncRelationalQuery";
|
|
2183
|
+
/** @internal */
|
|
2184
|
+
mode;
|
|
2185
|
+
/** @internal */
|
|
2186
|
+
getSQL() {
|
|
2187
|
+
return this.dialect.buildRelationalQuery({
|
|
2188
|
+
fullSchema: this.fullSchema,
|
|
2189
|
+
schema: this.schema,
|
|
2190
|
+
tableNamesMap: this.tableNamesMap,
|
|
2191
|
+
table: this.table,
|
|
2192
|
+
tableConfig: this.tableConfig,
|
|
2193
|
+
queryConfig: this.config,
|
|
2194
|
+
tableAlias: this.tableConfig.tsName
|
|
2195
|
+
}).sql;
|
|
2196
|
+
}
|
|
2197
|
+
/** @internal */
|
|
2198
|
+
_prepare(isOneTimeQuery = false) {
|
|
2199
|
+
const { query, builtQuery } = this._toSQL();
|
|
2200
|
+
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
|
2201
|
+
builtQuery,
|
|
2202
|
+
void 0,
|
|
2203
|
+
this.mode === "first" ? "get" : "all",
|
|
2204
|
+
true,
|
|
2205
|
+
(rawRows, mapColumnValue) => {
|
|
2206
|
+
const rows = rawRows.map(
|
|
2207
|
+
(row) => (0,relations/* mapRelationalRow */.I$)(this.schema, this.tableConfig, row, query.selection, mapColumnValue)
|
|
2208
|
+
);
|
|
2209
|
+
if (this.mode === "first") {
|
|
2210
|
+
return rows[0];
|
|
2211
|
+
}
|
|
2212
|
+
return rows;
|
|
2213
|
+
}
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2216
|
+
prepare() {
|
|
2217
|
+
return this._prepare(false);
|
|
2218
|
+
}
|
|
2219
|
+
_toSQL() {
|
|
2220
|
+
const query = this.dialect.buildRelationalQuery({
|
|
2221
|
+
fullSchema: this.fullSchema,
|
|
2222
|
+
schema: this.schema,
|
|
2223
|
+
tableNamesMap: this.tableNamesMap,
|
|
2224
|
+
table: this.table,
|
|
2225
|
+
tableConfig: this.tableConfig,
|
|
2226
|
+
queryConfig: this.config,
|
|
2227
|
+
tableAlias: this.tableConfig.tsName
|
|
2228
|
+
});
|
|
2229
|
+
const builtQuery = this.dialect.sqlToQuery(query.sql);
|
|
2230
|
+
return { query, builtQuery };
|
|
2231
|
+
}
|
|
2232
|
+
toSQL() {
|
|
2233
|
+
return this._toSQL().builtQuery;
|
|
2234
|
+
}
|
|
2235
|
+
/** @internal */
|
|
2236
|
+
executeRaw() {
|
|
2237
|
+
if (this.mode === "first") {
|
|
2238
|
+
return this._prepare(false).get();
|
|
2239
|
+
}
|
|
2240
|
+
return this._prepare(false).all();
|
|
2241
|
+
}
|
|
2242
|
+
async execute() {
|
|
2243
|
+
return this.executeRaw();
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
class SQLiteSyncRelationalQuery extends SQLiteRelationalQuery {
|
|
2247
|
+
static [entity/* entityKind */.i] = "SQLiteSyncRelationalQuery";
|
|
2248
|
+
sync() {
|
|
2249
|
+
return this.executeRaw();
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
//# sourceMappingURL=query.js.map
|
|
2254
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/query-builders/raw.js
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
class SQLiteRaw extends query_promise/* QueryPromise */.k {
|
|
2258
|
+
constructor(execute, getSQL, action, dialect, mapBatchResult) {
|
|
2259
|
+
super();
|
|
2260
|
+
this.execute = execute;
|
|
2261
|
+
this.getSQL = getSQL;
|
|
2262
|
+
this.dialect = dialect;
|
|
2263
|
+
this.mapBatchResult = mapBatchResult;
|
|
2264
|
+
this.config = { action };
|
|
2265
|
+
}
|
|
2266
|
+
static [entity/* entityKind */.i] = "SQLiteRaw";
|
|
2267
|
+
/** @internal */
|
|
2268
|
+
config;
|
|
2269
|
+
getQuery() {
|
|
2270
|
+
return { ...this.dialect.sqlToQuery(this.getSQL()), method: this.config.action };
|
|
2271
|
+
}
|
|
2272
|
+
mapResult(result, isFromBatch) {
|
|
2273
|
+
return isFromBatch ? this.mapBatchResult(result) : result;
|
|
2274
|
+
}
|
|
2275
|
+
_prepare() {
|
|
2276
|
+
return this;
|
|
2277
|
+
}
|
|
2278
|
+
/** @internal */
|
|
2279
|
+
isResponseInArrayMode() {
|
|
2280
|
+
return false;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
//# sourceMappingURL=raw.js.map
|
|
2285
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/db.js
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
class BaseSQLiteDatabase {
|
|
2295
|
+
constructor(resultKind, dialect, session, schema) {
|
|
2296
|
+
this.resultKind = resultKind;
|
|
2297
|
+
this.dialect = dialect;
|
|
2298
|
+
this.session = session;
|
|
2299
|
+
this._ = schema ? {
|
|
2300
|
+
schema: schema.schema,
|
|
2301
|
+
fullSchema: schema.fullSchema,
|
|
2302
|
+
tableNamesMap: schema.tableNamesMap
|
|
2303
|
+
} : {
|
|
2304
|
+
schema: void 0,
|
|
2305
|
+
fullSchema: {},
|
|
2306
|
+
tableNamesMap: {}
|
|
2307
|
+
};
|
|
2308
|
+
this.query = {};
|
|
2309
|
+
const query = this.query;
|
|
2310
|
+
if (this._.schema) {
|
|
2311
|
+
for (const [tableName, columns] of Object.entries(this._.schema)) {
|
|
2312
|
+
query[tableName] = new RelationalQueryBuilder(
|
|
2313
|
+
resultKind,
|
|
2314
|
+
schema.fullSchema,
|
|
2315
|
+
this._.schema,
|
|
2316
|
+
this._.tableNamesMap,
|
|
2317
|
+
schema.fullSchema[tableName],
|
|
2318
|
+
columns,
|
|
2319
|
+
dialect,
|
|
2320
|
+
session
|
|
2321
|
+
);
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
static [entity/* entityKind */.i] = "BaseSQLiteDatabase";
|
|
2326
|
+
query;
|
|
2327
|
+
/**
|
|
2328
|
+
* Creates a subquery that defines a temporary named result set as a CTE.
|
|
2329
|
+
*
|
|
2330
|
+
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
|
|
2331
|
+
*
|
|
2332
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
|
|
2333
|
+
*
|
|
2334
|
+
* @param alias The alias for the subquery.
|
|
2335
|
+
*
|
|
2336
|
+
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
|
|
2337
|
+
*
|
|
2338
|
+
* @example
|
|
2339
|
+
*
|
|
2340
|
+
* ```ts
|
|
2341
|
+
* // Create a subquery with alias 'sq' and use it in the select query
|
|
2342
|
+
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
|
|
2343
|
+
*
|
|
2344
|
+
* const result = await db.with(sq).select().from(sq);
|
|
2345
|
+
* ```
|
|
2346
|
+
*
|
|
2347
|
+
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
|
|
2348
|
+
*
|
|
2349
|
+
* ```ts
|
|
2350
|
+
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
|
|
2351
|
+
* const sq = db.$with('sq').as(db.select({
|
|
2352
|
+
* name: sql<string>`upper(${users.name})`.as('name'),
|
|
2353
|
+
* })
|
|
2354
|
+
* .from(users));
|
|
2355
|
+
*
|
|
2356
|
+
* const result = await db.with(sq).select({ name: sq.name }).from(sq);
|
|
2357
|
+
* ```
|
|
2358
|
+
*/
|
|
2359
|
+
$with(alias) {
|
|
2360
|
+
const self = this;
|
|
2361
|
+
return {
|
|
2362
|
+
as(qb) {
|
|
2363
|
+
if (typeof qb === "function") {
|
|
2364
|
+
qb = qb(new QueryBuilder(self.dialect));
|
|
2365
|
+
}
|
|
2366
|
+
return new Proxy(
|
|
2367
|
+
new subquery/* WithSubquery */.J(qb.getSQL(), qb.getSelectedFields(), alias, true),
|
|
2368
|
+
new selection_proxy/* SelectionProxyHandler */.b({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
|
2369
|
+
);
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
$count(source, filters) {
|
|
2374
|
+
return new SQLiteCountBuilder({ source, filters, session: this.session });
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Incorporates a previously defined CTE (using `$with`) into the main query.
|
|
2378
|
+
*
|
|
2379
|
+
* This method allows the main query to reference a temporary named result set.
|
|
2380
|
+
*
|
|
2381
|
+
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
|
|
2382
|
+
*
|
|
2383
|
+
* @param queries The CTEs to incorporate into the main query.
|
|
2384
|
+
*
|
|
2385
|
+
* @example
|
|
2386
|
+
*
|
|
2387
|
+
* ```ts
|
|
2388
|
+
* // Define a subquery 'sq' as a CTE using $with
|
|
2389
|
+
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
|
|
2390
|
+
*
|
|
2391
|
+
* // Incorporate the CTE 'sq' into the main query and select from it
|
|
2392
|
+
* const result = await db.with(sq).select().from(sq);
|
|
2393
|
+
* ```
|
|
2394
|
+
*/
|
|
2395
|
+
with(...queries) {
|
|
2396
|
+
const self = this;
|
|
2397
|
+
function select(fields) {
|
|
2398
|
+
return new SQLiteSelectBuilder({
|
|
2399
|
+
fields: fields ?? void 0,
|
|
2400
|
+
session: self.session,
|
|
2401
|
+
dialect: self.dialect,
|
|
2402
|
+
withList: queries
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
function selectDistinct(fields) {
|
|
2406
|
+
return new SQLiteSelectBuilder({
|
|
2407
|
+
fields: fields ?? void 0,
|
|
2408
|
+
session: self.session,
|
|
2409
|
+
dialect: self.dialect,
|
|
2410
|
+
withList: queries,
|
|
2411
|
+
distinct: true
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
function update(table) {
|
|
2415
|
+
return new SQLiteUpdateBuilder(table, self.session, self.dialect, queries);
|
|
2416
|
+
}
|
|
2417
|
+
function insert(into) {
|
|
2418
|
+
return new SQLiteInsertBuilder(into, self.session, self.dialect, queries);
|
|
2419
|
+
}
|
|
2420
|
+
function delete_(from) {
|
|
2421
|
+
return new SQLiteDeleteBase(from, self.session, self.dialect, queries);
|
|
2422
|
+
}
|
|
2423
|
+
return { select, selectDistinct, update, insert, delete: delete_ };
|
|
2424
|
+
}
|
|
2425
|
+
select(fields) {
|
|
2426
|
+
return new SQLiteSelectBuilder({ fields: fields ?? void 0, session: this.session, dialect: this.dialect });
|
|
2427
|
+
}
|
|
2428
|
+
selectDistinct(fields) {
|
|
2429
|
+
return new SQLiteSelectBuilder({
|
|
2430
|
+
fields: fields ?? void 0,
|
|
2431
|
+
session: this.session,
|
|
2432
|
+
dialect: this.dialect,
|
|
2433
|
+
distinct: true
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Creates an update query.
|
|
2438
|
+
*
|
|
2439
|
+
* Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
|
|
2440
|
+
*
|
|
2441
|
+
* Use `.set()` method to specify which values to update.
|
|
2442
|
+
*
|
|
2443
|
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
|
2444
|
+
*
|
|
2445
|
+
* @param table The table to update.
|
|
2446
|
+
*
|
|
2447
|
+
* @example
|
|
2448
|
+
*
|
|
2449
|
+
* ```ts
|
|
2450
|
+
* // Update all rows in the 'cars' table
|
|
2451
|
+
* await db.update(cars).set({ color: 'red' });
|
|
2452
|
+
*
|
|
2453
|
+
* // Update rows with filters and conditions
|
|
2454
|
+
* await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
|
|
2455
|
+
*
|
|
2456
|
+
* // Update with returning clause
|
|
2457
|
+
* const updatedCar: Car[] = await db.update(cars)
|
|
2458
|
+
* .set({ color: 'red' })
|
|
2459
|
+
* .where(eq(cars.id, 1))
|
|
2460
|
+
* .returning();
|
|
2461
|
+
* ```
|
|
2462
|
+
*/
|
|
2463
|
+
update(table) {
|
|
2464
|
+
return new SQLiteUpdateBuilder(table, this.session, this.dialect);
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Creates an insert query.
|
|
2468
|
+
*
|
|
2469
|
+
* Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
|
|
2470
|
+
*
|
|
2471
|
+
* See docs: {@link https://orm.drizzle.team/docs/insert}
|
|
2472
|
+
*
|
|
2473
|
+
* @param table The table to insert into.
|
|
2474
|
+
*
|
|
2475
|
+
* @example
|
|
2476
|
+
*
|
|
2477
|
+
* ```ts
|
|
2478
|
+
* // Insert one row
|
|
2479
|
+
* await db.insert(cars).values({ brand: 'BMW' });
|
|
2480
|
+
*
|
|
2481
|
+
* // Insert multiple rows
|
|
2482
|
+
* await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
|
|
2483
|
+
*
|
|
2484
|
+
* // Insert with returning clause
|
|
2485
|
+
* const insertedCar: Car[] = await db.insert(cars)
|
|
2486
|
+
* .values({ brand: 'BMW' })
|
|
2487
|
+
* .returning();
|
|
2488
|
+
* ```
|
|
2489
|
+
*/
|
|
2490
|
+
insert(into) {
|
|
2491
|
+
return new SQLiteInsertBuilder(into, this.session, this.dialect);
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Creates a delete query.
|
|
2495
|
+
*
|
|
2496
|
+
* Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
|
|
2497
|
+
*
|
|
2498
|
+
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
|
2499
|
+
*
|
|
2500
|
+
* @param table The table to delete from.
|
|
2501
|
+
*
|
|
2502
|
+
* @example
|
|
2503
|
+
*
|
|
2504
|
+
* ```ts
|
|
2505
|
+
* // Delete all rows in the 'cars' table
|
|
2506
|
+
* await db.delete(cars);
|
|
2507
|
+
*
|
|
2508
|
+
* // Delete rows with filters and conditions
|
|
2509
|
+
* await db.delete(cars).where(eq(cars.color, 'green'));
|
|
2510
|
+
*
|
|
2511
|
+
* // Delete with returning clause
|
|
2512
|
+
* const deletedCar: Car[] = await db.delete(cars)
|
|
2513
|
+
* .where(eq(cars.id, 1))
|
|
2514
|
+
* .returning();
|
|
2515
|
+
* ```
|
|
2516
|
+
*/
|
|
2517
|
+
delete(from) {
|
|
2518
|
+
return new SQLiteDeleteBase(from, this.session, this.dialect);
|
|
2519
|
+
}
|
|
2520
|
+
run(query) {
|
|
2521
|
+
const sequel = typeof query === "string" ? sql/* sql */.ll.raw(query) : query.getSQL();
|
|
2522
|
+
if (this.resultKind === "async") {
|
|
2523
|
+
return new SQLiteRaw(
|
|
2524
|
+
async () => this.session.run(sequel),
|
|
2525
|
+
() => sequel,
|
|
2526
|
+
"run",
|
|
2527
|
+
this.dialect,
|
|
2528
|
+
this.session.extractRawRunValueFromBatchResult.bind(this.session)
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2531
|
+
return this.session.run(sequel);
|
|
2532
|
+
}
|
|
2533
|
+
all(query) {
|
|
2534
|
+
const sequel = typeof query === "string" ? sql/* sql */.ll.raw(query) : query.getSQL();
|
|
2535
|
+
if (this.resultKind === "async") {
|
|
2536
|
+
return new SQLiteRaw(
|
|
2537
|
+
async () => this.session.all(sequel),
|
|
2538
|
+
() => sequel,
|
|
2539
|
+
"all",
|
|
2540
|
+
this.dialect,
|
|
2541
|
+
this.session.extractRawAllValueFromBatchResult.bind(this.session)
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
return this.session.all(sequel);
|
|
2545
|
+
}
|
|
2546
|
+
get(query) {
|
|
2547
|
+
const sequel = typeof query === "string" ? sql/* sql */.ll.raw(query) : query.getSQL();
|
|
2548
|
+
if (this.resultKind === "async") {
|
|
2549
|
+
return new SQLiteRaw(
|
|
2550
|
+
async () => this.session.get(sequel),
|
|
2551
|
+
() => sequel,
|
|
2552
|
+
"get",
|
|
2553
|
+
this.dialect,
|
|
2554
|
+
this.session.extractRawGetValueFromBatchResult.bind(this.session)
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
return this.session.get(sequel);
|
|
2558
|
+
}
|
|
2559
|
+
values(query) {
|
|
2560
|
+
const sequel = typeof query === "string" ? sql/* sql */.ll.raw(query) : query.getSQL();
|
|
2561
|
+
if (this.resultKind === "async") {
|
|
2562
|
+
return new SQLiteRaw(
|
|
2563
|
+
async () => this.session.values(sequel),
|
|
2564
|
+
() => sequel,
|
|
2565
|
+
"values",
|
|
2566
|
+
this.dialect,
|
|
2567
|
+
this.session.extractRawValuesValueFromBatchResult.bind(this.session)
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
return this.session.values(sequel);
|
|
2571
|
+
}
|
|
2572
|
+
transaction(transaction, config) {
|
|
2573
|
+
return this.session.transaction(transaction, config);
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
const withReplicas = (primary, replicas, getReplica = () => replicas[Math.floor(Math.random() * replicas.length)]) => {
|
|
2577
|
+
const select = (...args) => getReplica(replicas).select(...args);
|
|
2578
|
+
const selectDistinct = (...args) => getReplica(replicas).selectDistinct(...args);
|
|
2579
|
+
const $with = (...args) => getReplica(replicas).with(...args);
|
|
2580
|
+
const update = (...args) => primary.update(...args);
|
|
2581
|
+
const insert = (...args) => primary.insert(...args);
|
|
2582
|
+
const $delete = (...args) => primary.delete(...args);
|
|
2583
|
+
const run = (...args) => primary.run(...args);
|
|
2584
|
+
const all = (...args) => primary.all(...args);
|
|
2585
|
+
const get = (...args) => primary.get(...args);
|
|
2586
|
+
const values = (...args) => primary.values(...args);
|
|
2587
|
+
const transaction = (...args) => primary.transaction(...args);
|
|
2588
|
+
return {
|
|
2589
|
+
...primary,
|
|
2590
|
+
update,
|
|
2591
|
+
insert,
|
|
2592
|
+
delete: $delete,
|
|
2593
|
+
run,
|
|
2594
|
+
all,
|
|
2595
|
+
get,
|
|
2596
|
+
values,
|
|
2597
|
+
transaction,
|
|
2598
|
+
$primary: primary,
|
|
2599
|
+
select,
|
|
2600
|
+
selectDistinct,
|
|
2601
|
+
with: $with,
|
|
2602
|
+
get query() {
|
|
2603
|
+
return getReplica(replicas).query;
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2608
|
+
//# sourceMappingURL=db.js.map
|
|
2609
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/session.js
|
|
2610
|
+
|
|
2611
|
+
|
|
2612
|
+
|
|
2613
|
+
|
|
2614
|
+
class ExecuteResultSync extends query_promise/* QueryPromise */.k {
|
|
2615
|
+
constructor(resultCb) {
|
|
2616
|
+
super();
|
|
2617
|
+
this.resultCb = resultCb;
|
|
2618
|
+
}
|
|
2619
|
+
static [entity/* entityKind */.i] = "ExecuteResultSync";
|
|
2620
|
+
async execute() {
|
|
2621
|
+
return this.resultCb();
|
|
2622
|
+
}
|
|
2623
|
+
sync() {
|
|
2624
|
+
return this.resultCb();
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
class SQLitePreparedQuery {
|
|
2628
|
+
constructor(mode, executeMethod, query) {
|
|
2629
|
+
this.mode = mode;
|
|
2630
|
+
this.executeMethod = executeMethod;
|
|
2631
|
+
this.query = query;
|
|
2632
|
+
}
|
|
2633
|
+
static [entity/* entityKind */.i] = "PreparedQuery";
|
|
2634
|
+
/** @internal */
|
|
2635
|
+
joinsNotNullableMap;
|
|
2636
|
+
getQuery() {
|
|
2637
|
+
return this.query;
|
|
2638
|
+
}
|
|
2639
|
+
mapRunResult(result, _isFromBatch) {
|
|
2640
|
+
return result;
|
|
2641
|
+
}
|
|
2642
|
+
mapAllResult(_result, _isFromBatch) {
|
|
2643
|
+
throw new Error("Not implemented");
|
|
2644
|
+
}
|
|
2645
|
+
mapGetResult(_result, _isFromBatch) {
|
|
2646
|
+
throw new Error("Not implemented");
|
|
2647
|
+
}
|
|
2648
|
+
execute(placeholderValues) {
|
|
2649
|
+
if (this.mode === "async") {
|
|
2650
|
+
return this[this.executeMethod](placeholderValues);
|
|
2651
|
+
}
|
|
2652
|
+
return new ExecuteResultSync(() => this[this.executeMethod](placeholderValues));
|
|
2653
|
+
}
|
|
2654
|
+
mapResult(response, isFromBatch) {
|
|
2655
|
+
switch (this.executeMethod) {
|
|
2656
|
+
case "run": {
|
|
2657
|
+
return this.mapRunResult(response, isFromBatch);
|
|
2658
|
+
}
|
|
2659
|
+
case "all": {
|
|
2660
|
+
return this.mapAllResult(response, isFromBatch);
|
|
2661
|
+
}
|
|
2662
|
+
case "get": {
|
|
2663
|
+
return this.mapGetResult(response, isFromBatch);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
class SQLiteSession {
|
|
2669
|
+
constructor(dialect) {
|
|
2670
|
+
this.dialect = dialect;
|
|
2671
|
+
}
|
|
2672
|
+
static [entity/* entityKind */.i] = "SQLiteSession";
|
|
2673
|
+
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode) {
|
|
2674
|
+
return this.prepareQuery(query, fields, executeMethod, isResponseInArrayMode);
|
|
2675
|
+
}
|
|
2676
|
+
run(query) {
|
|
2677
|
+
const staticQuery = this.dialect.sqlToQuery(query);
|
|
2678
|
+
try {
|
|
2679
|
+
return this.prepareOneTimeQuery(staticQuery, void 0, "run", false).run();
|
|
2680
|
+
} catch (err) {
|
|
2681
|
+
throw new errors/* DrizzleError */.n({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
/** @internal */
|
|
2685
|
+
extractRawRunValueFromBatchResult(result) {
|
|
2686
|
+
return result;
|
|
2687
|
+
}
|
|
2688
|
+
all(query) {
|
|
2689
|
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).all();
|
|
2690
|
+
}
|
|
2691
|
+
/** @internal */
|
|
2692
|
+
extractRawAllValueFromBatchResult(_result) {
|
|
2693
|
+
throw new Error("Not implemented");
|
|
2694
|
+
}
|
|
2695
|
+
get(query) {
|
|
2696
|
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).get();
|
|
2697
|
+
}
|
|
2698
|
+
/** @internal */
|
|
2699
|
+
extractRawGetValueFromBatchResult(_result) {
|
|
2700
|
+
throw new Error("Not implemented");
|
|
2701
|
+
}
|
|
2702
|
+
values(query) {
|
|
2703
|
+
return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).values();
|
|
2704
|
+
}
|
|
2705
|
+
async count(sql) {
|
|
2706
|
+
const result = await this.values(sql);
|
|
2707
|
+
return result[0][0];
|
|
2708
|
+
}
|
|
2709
|
+
/** @internal */
|
|
2710
|
+
extractRawValuesValueFromBatchResult(_result) {
|
|
2711
|
+
throw new Error("Not implemented");
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
class SQLiteTransaction extends BaseSQLiteDatabase {
|
|
2715
|
+
constructor(resultType, dialect, session, schema, nestedIndex = 0) {
|
|
2716
|
+
super(resultType, dialect, session, schema);
|
|
2717
|
+
this.schema = schema;
|
|
2718
|
+
this.nestedIndex = nestedIndex;
|
|
2719
|
+
}
|
|
2720
|
+
static [entity/* entityKind */.i] = "SQLiteTransaction";
|
|
2721
|
+
rollback() {
|
|
2722
|
+
throw new errors/* TransactionRollbackError */.j();
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
//# sourceMappingURL=session.js.map
|
|
2727
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/libsql/session.js
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
class LibSQLSession extends SQLiteSession {
|
|
2735
|
+
constructor(client, dialect, schema, options, tx) {
|
|
2736
|
+
super(dialect);
|
|
2737
|
+
this.client = client;
|
|
2738
|
+
this.schema = schema;
|
|
2739
|
+
this.options = options;
|
|
2740
|
+
this.tx = tx;
|
|
2741
|
+
this.logger = options.logger ?? new drizzle_orm_logger/* NoopLogger */.Pv();
|
|
2742
|
+
}
|
|
2743
|
+
static [entity/* entityKind */.i] = "LibSQLSession";
|
|
2744
|
+
logger;
|
|
2745
|
+
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
|
2746
|
+
return new LibSQLPreparedQuery(
|
|
2747
|
+
this.client,
|
|
2748
|
+
query,
|
|
2749
|
+
this.logger,
|
|
2750
|
+
fields,
|
|
2751
|
+
this.tx,
|
|
2752
|
+
executeMethod,
|
|
2753
|
+
isResponseInArrayMode,
|
|
2754
|
+
customResultMapper
|
|
2755
|
+
);
|
|
2756
|
+
}
|
|
2757
|
+
async batch(queries) {
|
|
2758
|
+
const preparedQueries = [];
|
|
2759
|
+
const builtQueries = [];
|
|
2760
|
+
for (const query of queries) {
|
|
2761
|
+
const preparedQuery = query._prepare();
|
|
2762
|
+
const builtQuery = preparedQuery.getQuery();
|
|
2763
|
+
preparedQueries.push(preparedQuery);
|
|
2764
|
+
builtQueries.push({ sql: builtQuery.sql, args: builtQuery.params });
|
|
2765
|
+
}
|
|
2766
|
+
const batchResults = await this.client.batch(builtQueries);
|
|
2767
|
+
return batchResults.map((result, i) => preparedQueries[i].mapResult(result, true));
|
|
2768
|
+
}
|
|
2769
|
+
async migrate(queries) {
|
|
2770
|
+
const preparedQueries = [];
|
|
2771
|
+
const builtQueries = [];
|
|
2772
|
+
for (const query of queries) {
|
|
2773
|
+
const preparedQuery = query._prepare();
|
|
2774
|
+
const builtQuery = preparedQuery.getQuery();
|
|
2775
|
+
preparedQueries.push(preparedQuery);
|
|
2776
|
+
builtQueries.push({ sql: builtQuery.sql, args: builtQuery.params });
|
|
2777
|
+
}
|
|
2778
|
+
const batchResults = await this.client.migrate(builtQueries);
|
|
2779
|
+
return batchResults.map((result, i) => preparedQueries[i].mapResult(result, true));
|
|
2780
|
+
}
|
|
2781
|
+
async transaction(transaction, _config) {
|
|
2782
|
+
const libsqlTx = await this.client.transaction();
|
|
2783
|
+
const session = new LibSQLSession(
|
|
2784
|
+
this.client,
|
|
2785
|
+
this.dialect,
|
|
2786
|
+
this.schema,
|
|
2787
|
+
this.options,
|
|
2788
|
+
libsqlTx
|
|
2789
|
+
);
|
|
2790
|
+
const tx = new LibSQLTransaction("async", this.dialect, session, this.schema);
|
|
2791
|
+
try {
|
|
2792
|
+
const result = await transaction(tx);
|
|
2793
|
+
await libsqlTx.commit();
|
|
2794
|
+
return result;
|
|
2795
|
+
} catch (err) {
|
|
2796
|
+
await libsqlTx.rollback();
|
|
2797
|
+
throw err;
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
extractRawAllValueFromBatchResult(result) {
|
|
2801
|
+
return result.rows;
|
|
2802
|
+
}
|
|
2803
|
+
extractRawGetValueFromBatchResult(result) {
|
|
2804
|
+
return result.rows[0];
|
|
2805
|
+
}
|
|
2806
|
+
extractRawValuesValueFromBatchResult(result) {
|
|
2807
|
+
return result.rows;
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
class LibSQLTransaction extends SQLiteTransaction {
|
|
2811
|
+
static [entity/* entityKind */.i] = "LibSQLTransaction";
|
|
2812
|
+
async transaction(transaction) {
|
|
2813
|
+
const savepointName = `sp${this.nestedIndex}`;
|
|
2814
|
+
const tx = new LibSQLTransaction("async", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
2815
|
+
await this.session.run(sql/* sql */.ll.raw(`savepoint ${savepointName}`));
|
|
2816
|
+
try {
|
|
2817
|
+
const result = await transaction(tx);
|
|
2818
|
+
await this.session.run(sql/* sql */.ll.raw(`release savepoint ${savepointName}`));
|
|
2819
|
+
return result;
|
|
2820
|
+
} catch (err) {
|
|
2821
|
+
await this.session.run(sql/* sql */.ll.raw(`rollback to savepoint ${savepointName}`));
|
|
2822
|
+
throw err;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
class LibSQLPreparedQuery extends SQLitePreparedQuery {
|
|
2827
|
+
constructor(client, query, logger, fields, tx, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
2828
|
+
super("async", executeMethod, query);
|
|
2829
|
+
this.client = client;
|
|
2830
|
+
this.logger = logger;
|
|
2831
|
+
this.fields = fields;
|
|
2832
|
+
this.tx = tx;
|
|
2833
|
+
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
2834
|
+
this.customResultMapper = customResultMapper;
|
|
2835
|
+
this.customResultMapper = customResultMapper;
|
|
2836
|
+
this.fields = fields;
|
|
2837
|
+
}
|
|
2838
|
+
static [entity/* entityKind */.i] = "LibSQLPreparedQuery";
|
|
2839
|
+
run(placeholderValues) {
|
|
2840
|
+
const params = (0,sql/* fillPlaceholders */.Ct)(this.query.params, placeholderValues ?? {});
|
|
2841
|
+
this.logger.logQuery(this.query.sql, params);
|
|
2842
|
+
const stmt = { sql: this.query.sql, args: params };
|
|
2843
|
+
return this.tx ? this.tx.execute(stmt) : this.client.execute(stmt);
|
|
2844
|
+
}
|
|
2845
|
+
async all(placeholderValues) {
|
|
2846
|
+
const { fields, logger, query, tx, client, customResultMapper } = this;
|
|
2847
|
+
if (!fields && !customResultMapper) {
|
|
2848
|
+
const params = (0,sql/* fillPlaceholders */.Ct)(query.params, placeholderValues ?? {});
|
|
2849
|
+
logger.logQuery(query.sql, params);
|
|
2850
|
+
const stmt = { sql: query.sql, args: params };
|
|
2851
|
+
return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapAllResult(rows2));
|
|
2852
|
+
}
|
|
2853
|
+
const rows = await this.values(placeholderValues);
|
|
2854
|
+
return this.mapAllResult(rows);
|
|
2855
|
+
}
|
|
2856
|
+
mapAllResult(rows, isFromBatch) {
|
|
2857
|
+
if (isFromBatch) {
|
|
2858
|
+
rows = rows.rows;
|
|
2859
|
+
}
|
|
2860
|
+
if (!this.fields && !this.customResultMapper) {
|
|
2861
|
+
return rows.map((row) => normalizeRow(row));
|
|
2862
|
+
}
|
|
2863
|
+
if (this.customResultMapper) {
|
|
2864
|
+
return this.customResultMapper(rows, normalizeFieldValue);
|
|
2865
|
+
}
|
|
2866
|
+
return rows.map((row) => {
|
|
2867
|
+
return (0,utils/* mapResultRow */.a6)(
|
|
2868
|
+
this.fields,
|
|
2869
|
+
Array.prototype.slice.call(row).map((v) => normalizeFieldValue(v)),
|
|
2870
|
+
this.joinsNotNullableMap
|
|
2871
|
+
);
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
async get(placeholderValues) {
|
|
2875
|
+
const { fields, logger, query, tx, client, customResultMapper } = this;
|
|
2876
|
+
if (!fields && !customResultMapper) {
|
|
2877
|
+
const params = (0,sql/* fillPlaceholders */.Ct)(query.params, placeholderValues ?? {});
|
|
2878
|
+
logger.logQuery(query.sql, params);
|
|
2879
|
+
const stmt = { sql: query.sql, args: params };
|
|
2880
|
+
return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapGetResult(rows2));
|
|
2881
|
+
}
|
|
2882
|
+
const rows = await this.values(placeholderValues);
|
|
2883
|
+
return this.mapGetResult(rows);
|
|
2884
|
+
}
|
|
2885
|
+
mapGetResult(rows, isFromBatch) {
|
|
2886
|
+
if (isFromBatch) {
|
|
2887
|
+
rows = rows.rows;
|
|
2888
|
+
}
|
|
2889
|
+
const row = rows[0];
|
|
2890
|
+
if (!this.fields && !this.customResultMapper) {
|
|
2891
|
+
return normalizeRow(row);
|
|
2892
|
+
}
|
|
2893
|
+
if (!row) {
|
|
2894
|
+
return void 0;
|
|
2895
|
+
}
|
|
2896
|
+
if (this.customResultMapper) {
|
|
2897
|
+
return this.customResultMapper(rows, normalizeFieldValue);
|
|
2898
|
+
}
|
|
2899
|
+
return (0,utils/* mapResultRow */.a6)(
|
|
2900
|
+
this.fields,
|
|
2901
|
+
Array.prototype.slice.call(row).map((v) => normalizeFieldValue(v)),
|
|
2902
|
+
this.joinsNotNullableMap
|
|
2903
|
+
);
|
|
2904
|
+
}
|
|
2905
|
+
values(placeholderValues) {
|
|
2906
|
+
const params = (0,sql/* fillPlaceholders */.Ct)(this.query.params, placeholderValues ?? {});
|
|
2907
|
+
this.logger.logQuery(this.query.sql, params);
|
|
2908
|
+
const stmt = { sql: this.query.sql, args: params };
|
|
2909
|
+
return (this.tx ? this.tx.execute(stmt) : this.client.execute(stmt)).then(({ rows }) => rows);
|
|
2910
|
+
}
|
|
2911
|
+
/** @internal */
|
|
2912
|
+
isResponseInArrayMode() {
|
|
2913
|
+
return this._isResponseInArrayMode;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
function normalizeRow(obj) {
|
|
2917
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
2918
|
+
if (Object.prototype.propertyIsEnumerable.call(obj, key)) {
|
|
2919
|
+
acc[key] = obj[key];
|
|
2920
|
+
}
|
|
2921
|
+
return acc;
|
|
2922
|
+
}, {});
|
|
2923
|
+
}
|
|
2924
|
+
function normalizeFieldValue(value) {
|
|
2925
|
+
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
|
|
2926
|
+
if (typeof Buffer !== "undefined") {
|
|
2927
|
+
if (!(value instanceof Buffer)) {
|
|
2928
|
+
return Buffer.from(value);
|
|
2929
|
+
}
|
|
2930
|
+
return value;
|
|
2931
|
+
}
|
|
2932
|
+
if (typeof TextDecoder !== "undefined") {
|
|
2933
|
+
return new TextDecoder().decode(value);
|
|
2934
|
+
}
|
|
2935
|
+
throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.");
|
|
2936
|
+
}
|
|
2937
|
+
return value;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
//# sourceMappingURL=session.js.map
|
|
2941
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/libsql/driver-core.js
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
class LibSQLDatabase extends BaseSQLiteDatabase {
|
|
2949
|
+
static [entity/* entityKind */.i] = "LibSQLDatabase";
|
|
2950
|
+
async batch(batch) {
|
|
2951
|
+
return this.session.batch(batch);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
function construct(client, config = {}) {
|
|
2955
|
+
const dialect = new SQLiteAsyncDialect({ casing: config.casing });
|
|
2956
|
+
let logger;
|
|
2957
|
+
if (config.logger === true) {
|
|
2958
|
+
logger = new drizzle_orm_logger/* DefaultLogger */.w();
|
|
2959
|
+
} else if (config.logger !== false) {
|
|
2960
|
+
logger = config.logger;
|
|
2961
|
+
}
|
|
2962
|
+
let schema;
|
|
2963
|
+
if (config.schema) {
|
|
2964
|
+
const tablesConfig = (0,relations/* extractTablesRelationalConfig */._k)(
|
|
2965
|
+
config.schema,
|
|
2966
|
+
relations/* createTableRelationsHelpers */.DZ
|
|
2967
|
+
);
|
|
2968
|
+
schema = {
|
|
2969
|
+
fullSchema: config.schema,
|
|
2970
|
+
schema: tablesConfig.tables,
|
|
2971
|
+
tableNamesMap: tablesConfig.tableNamesMap
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
const session = new LibSQLSession(client, dialect, schema, { logger }, void 0);
|
|
2975
|
+
const db = new LibSQLDatabase("async", dialect, session, schema);
|
|
2976
|
+
db.$client = client;
|
|
2977
|
+
return db;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
//# sourceMappingURL=driver-core.js.map
|
|
2981
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/libsql/driver.js
|
|
2982
|
+
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
function drizzle(...params) {
|
|
2987
|
+
if (typeof params[0] === "string") {
|
|
2988
|
+
const instance = (0,client_.createClient)({
|
|
2989
|
+
url: params[0]
|
|
2990
|
+
});
|
|
2991
|
+
return construct(instance, params[1]);
|
|
2992
|
+
}
|
|
2993
|
+
if ((0,utils/* isConfig */.Lq)(params[0])) {
|
|
2994
|
+
const { connection, client, ...drizzleConfig } = params[0];
|
|
2995
|
+
if (client)
|
|
2996
|
+
return construct(client, drizzleConfig);
|
|
2997
|
+
const instance = typeof connection === "string" ? (0,client_.createClient)({ url: connection }) : (0,client_.createClient)(connection);
|
|
2998
|
+
return construct(instance, drizzleConfig);
|
|
2999
|
+
}
|
|
3000
|
+
return construct(params[0], params[1]);
|
|
3001
|
+
}
|
|
3002
|
+
((drizzle2) => {
|
|
3003
|
+
function mock(config) {
|
|
3004
|
+
return construct({}, config);
|
|
3005
|
+
}
|
|
3006
|
+
drizzle2.mock = mock;
|
|
3007
|
+
})(drizzle || (drizzle = {}));
|
|
3008
|
+
|
|
3009
|
+
//# sourceMappingURL=driver.js.map
|
|
3010
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/libsql/index.js
|
|
3011
|
+
|
|
3012
|
+
|
|
3013
|
+
//# sourceMappingURL=index.js.map
|
|
3014
|
+
|
|
3015
|
+
/***/ }),
|
|
3016
|
+
|
|
3017
|
+
/***/ 6743:
|
|
3018
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3019
|
+
|
|
3020
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3021
|
+
/* harmony export */ Pv: () => (/* binding */ NoopLogger),
|
|
3022
|
+
/* harmony export */ w: () => (/* binding */ DefaultLogger)
|
|
3023
|
+
/* harmony export */ });
|
|
3024
|
+
/* unused harmony export ConsoleLogWriter */
|
|
3025
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
3026
|
+
|
|
3027
|
+
class ConsoleLogWriter {
|
|
3028
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "ConsoleLogWriter";
|
|
3029
|
+
write(message) {
|
|
3030
|
+
console.log(message);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
class DefaultLogger {
|
|
3034
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "DefaultLogger";
|
|
3035
|
+
writer;
|
|
3036
|
+
constructor(config) {
|
|
3037
|
+
this.writer = config?.writer ?? new ConsoleLogWriter();
|
|
3038
|
+
}
|
|
3039
|
+
logQuery(query, params) {
|
|
3040
|
+
const stringifiedParams = params.map((p) => {
|
|
3041
|
+
try {
|
|
3042
|
+
return JSON.stringify(p);
|
|
3043
|
+
} catch {
|
|
3044
|
+
return String(p);
|
|
3045
|
+
}
|
|
3046
|
+
});
|
|
3047
|
+
const paramsStr = stringifiedParams.length ? ` -- params: [${stringifiedParams.join(", ")}]` : "";
|
|
3048
|
+
this.writer.write(`Query: ${query}${paramsStr}`);
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
class NoopLogger {
|
|
3052
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "NoopLogger";
|
|
3053
|
+
logQuery() {
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
//# sourceMappingURL=logger.js.map
|
|
3058
|
+
|
|
3059
|
+
/***/ }),
|
|
3060
|
+
|
|
3061
|
+
/***/ 6685:
|
|
3062
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3063
|
+
|
|
3064
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3065
|
+
/* harmony export */ O: () => (/* binding */ TypedQueryBuilder)
|
|
3066
|
+
/* harmony export */ });
|
|
3067
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
3068
|
+
|
|
3069
|
+
class TypedQueryBuilder {
|
|
3070
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "TypedQueryBuilder";
|
|
3071
|
+
/** @internal */
|
|
3072
|
+
getSelectedFields() {
|
|
3073
|
+
return this._.selectedFields;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
//# sourceMappingURL=query-builder.js.map
|
|
3078
|
+
|
|
3079
|
+
/***/ }),
|
|
3080
|
+
|
|
3081
|
+
/***/ 4579:
|
|
3082
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3083
|
+
|
|
3084
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3085
|
+
/* harmony export */ k: () => (/* binding */ QueryPromise)
|
|
3086
|
+
/* harmony export */ });
|
|
3087
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
3088
|
+
|
|
3089
|
+
class QueryPromise {
|
|
3090
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "QueryPromise";
|
|
3091
|
+
[Symbol.toStringTag] = "QueryPromise";
|
|
3092
|
+
catch(onRejected) {
|
|
3093
|
+
return this.then(void 0, onRejected);
|
|
3094
|
+
}
|
|
3095
|
+
finally(onFinally) {
|
|
3096
|
+
return this.then(
|
|
3097
|
+
(value) => {
|
|
3098
|
+
onFinally?.();
|
|
3099
|
+
return value;
|
|
3100
|
+
},
|
|
3101
|
+
(reason) => {
|
|
3102
|
+
onFinally?.();
|
|
3103
|
+
throw reason;
|
|
3104
|
+
}
|
|
3105
|
+
);
|
|
3106
|
+
}
|
|
3107
|
+
then(onFulfilled, onRejected) {
|
|
3108
|
+
return this.execute().then(onFulfilled, onRejected);
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
//# sourceMappingURL=query-promise.js.map
|
|
3113
|
+
|
|
3114
|
+
/***/ }),
|
|
3115
|
+
|
|
3116
|
+
/***/ 4750:
|
|
3117
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3118
|
+
|
|
3119
|
+
|
|
3120
|
+
// EXPORTS
|
|
3121
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
3122
|
+
iv: () => (/* binding */ Many),
|
|
3123
|
+
pD: () => (/* binding */ One),
|
|
3124
|
+
DZ: () => (/* binding */ createTableRelationsHelpers),
|
|
3125
|
+
_k: () => (/* binding */ extractTablesRelationalConfig),
|
|
3126
|
+
mm: () => (/* binding */ getOperators),
|
|
3127
|
+
rl: () => (/* binding */ getOrderByOperators),
|
|
3128
|
+
I$: () => (/* binding */ mapRelationalRow),
|
|
3129
|
+
W0: () => (/* binding */ normalizeRelation)
|
|
3130
|
+
});
|
|
3131
|
+
|
|
3132
|
+
// UNUSED EXPORTS: Relation, Relations, createMany, createOne, relations
|
|
3133
|
+
|
|
3134
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/table.js
|
|
3135
|
+
var table = __webpack_require__(8407);
|
|
3136
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/column.js
|
|
3137
|
+
var column = __webpack_require__(2345);
|
|
3138
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/entity.js
|
|
3139
|
+
var entity = __webpack_require__(9724);
|
|
3140
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/pg-core/table.js + 22 modules
|
|
3141
|
+
var pg_core_table = __webpack_require__(698);
|
|
3142
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/pg-core/primary-keys.js
|
|
3143
|
+
|
|
3144
|
+
|
|
3145
|
+
function primaryKey(...config) {
|
|
3146
|
+
if (config[0].columns) {
|
|
3147
|
+
return new PrimaryKeyBuilder(config[0].columns, config[0].name);
|
|
3148
|
+
}
|
|
3149
|
+
return new PrimaryKeyBuilder(config);
|
|
3150
|
+
}
|
|
3151
|
+
class PrimaryKeyBuilder {
|
|
3152
|
+
static [entity/* entityKind */.i] = "PgPrimaryKeyBuilder";
|
|
3153
|
+
/** @internal */
|
|
3154
|
+
columns;
|
|
3155
|
+
/** @internal */
|
|
3156
|
+
name;
|
|
3157
|
+
constructor(columns, name) {
|
|
3158
|
+
this.columns = columns;
|
|
3159
|
+
this.name = name;
|
|
3160
|
+
}
|
|
3161
|
+
/** @internal */
|
|
3162
|
+
build(table) {
|
|
3163
|
+
return new PrimaryKey(table, this.columns, this.name);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
class PrimaryKey {
|
|
3167
|
+
constructor(table, columns, name) {
|
|
3168
|
+
this.table = table;
|
|
3169
|
+
this.columns = columns;
|
|
3170
|
+
this.name = name;
|
|
3171
|
+
}
|
|
3172
|
+
static [entity/* entityKind */.i] = "PgPrimaryKey";
|
|
3173
|
+
columns;
|
|
3174
|
+
name;
|
|
3175
|
+
getName() {
|
|
3176
|
+
return this.name ?? `${this.table[pg_core_table/* PgTable */.mu.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
//# sourceMappingURL=primary-keys.js.map
|
|
3181
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
3182
|
+
var conditions = __webpack_require__(420);
|
|
3183
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sql/expressions/select.js
|
|
3184
|
+
var expressions_select = __webpack_require__(7038);
|
|
3185
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sql/sql.js + 1 modules
|
|
3186
|
+
var sql = __webpack_require__(183);
|
|
3187
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/relations.js
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
class Relation {
|
|
3195
|
+
constructor(sourceTable, referencedTable, relationName) {
|
|
3196
|
+
this.sourceTable = sourceTable;
|
|
3197
|
+
this.referencedTable = referencedTable;
|
|
3198
|
+
this.relationName = relationName;
|
|
3199
|
+
this.referencedTableName = referencedTable[table/* Table */.XI.Symbol.Name];
|
|
3200
|
+
}
|
|
3201
|
+
static [entity/* entityKind */.i] = "Relation";
|
|
3202
|
+
referencedTableName;
|
|
3203
|
+
fieldName;
|
|
3204
|
+
}
|
|
3205
|
+
class Relations {
|
|
3206
|
+
constructor(table, config) {
|
|
3207
|
+
this.table = table;
|
|
3208
|
+
this.config = config;
|
|
3209
|
+
}
|
|
3210
|
+
static [entity/* entityKind */.i] = "Relations";
|
|
3211
|
+
}
|
|
3212
|
+
class One extends Relation {
|
|
3213
|
+
constructor(sourceTable, referencedTable, config, isNullable) {
|
|
3214
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
3215
|
+
this.config = config;
|
|
3216
|
+
this.isNullable = isNullable;
|
|
3217
|
+
}
|
|
3218
|
+
static [entity/* entityKind */.i] = "One";
|
|
3219
|
+
withFieldName(fieldName) {
|
|
3220
|
+
const relation = new One(
|
|
3221
|
+
this.sourceTable,
|
|
3222
|
+
this.referencedTable,
|
|
3223
|
+
this.config,
|
|
3224
|
+
this.isNullable
|
|
3225
|
+
);
|
|
3226
|
+
relation.fieldName = fieldName;
|
|
3227
|
+
return relation;
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
class Many extends Relation {
|
|
3231
|
+
constructor(sourceTable, referencedTable, config) {
|
|
3232
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
3233
|
+
this.config = config;
|
|
3234
|
+
}
|
|
3235
|
+
static [entity/* entityKind */.i] = "Many";
|
|
3236
|
+
withFieldName(fieldName) {
|
|
3237
|
+
const relation = new Many(
|
|
3238
|
+
this.sourceTable,
|
|
3239
|
+
this.referencedTable,
|
|
3240
|
+
this.config
|
|
3241
|
+
);
|
|
3242
|
+
relation.fieldName = fieldName;
|
|
3243
|
+
return relation;
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
function getOperators() {
|
|
3247
|
+
return {
|
|
3248
|
+
and: conditions/* and */.Uo,
|
|
3249
|
+
between: conditions/* between */.Tq,
|
|
3250
|
+
eq: conditions.eq,
|
|
3251
|
+
exists: conditions/* exists */.t2,
|
|
3252
|
+
gt: conditions.gt,
|
|
3253
|
+
gte: conditions/* gte */.RO,
|
|
3254
|
+
ilike: conditions/* ilike */.B3,
|
|
3255
|
+
inArray: conditions/* inArray */.RV,
|
|
3256
|
+
isNull: conditions/* isNull */.kZ,
|
|
3257
|
+
isNotNull: conditions/* isNotNull */.Pe,
|
|
3258
|
+
like: conditions/* like */.mj,
|
|
3259
|
+
lt: conditions.lt,
|
|
3260
|
+
lte: conditions/* lte */.wJ,
|
|
3261
|
+
ne: conditions.ne,
|
|
3262
|
+
not: conditions/* not */.AU,
|
|
3263
|
+
notBetween: conditions/* notBetween */.o8,
|
|
3264
|
+
notExists: conditions/* notExists */.KJ,
|
|
3265
|
+
notLike: conditions/* notLike */.RK,
|
|
3266
|
+
notIlike: conditions/* notIlike */.q1,
|
|
3267
|
+
notInArray: conditions/* notInArray */.KL,
|
|
3268
|
+
or: conditions.or,
|
|
3269
|
+
sql: sql/* sql */.ll
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
function getOrderByOperators() {
|
|
3273
|
+
return {
|
|
3274
|
+
sql: sql/* sql */.ll,
|
|
3275
|
+
asc: expressions_select/* asc */.Y,
|
|
3276
|
+
desc: expressions_select/* desc */.i
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
function extractTablesRelationalConfig(schema, configHelpers) {
|
|
3280
|
+
if (Object.keys(schema).length === 1 && "default" in schema && !(0,entity.is)(schema["default"], table/* Table */.XI)) {
|
|
3281
|
+
schema = schema["default"];
|
|
3282
|
+
}
|
|
3283
|
+
const tableNamesMap = {};
|
|
3284
|
+
const relationsBuffer = {};
|
|
3285
|
+
const tablesConfig = {};
|
|
3286
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
3287
|
+
if ((0,entity.is)(value, table/* Table */.XI)) {
|
|
3288
|
+
const dbName = (0,table/* getTableUniqueName */.Lf)(value);
|
|
3289
|
+
const bufferedRelations = relationsBuffer[dbName];
|
|
3290
|
+
tableNamesMap[dbName] = key;
|
|
3291
|
+
tablesConfig[key] = {
|
|
3292
|
+
tsName: key,
|
|
3293
|
+
dbName: value[table/* Table */.XI.Symbol.Name],
|
|
3294
|
+
schema: value[table/* Table */.XI.Symbol.Schema],
|
|
3295
|
+
columns: value[table/* Table */.XI.Symbol.Columns],
|
|
3296
|
+
relations: bufferedRelations?.relations ?? {},
|
|
3297
|
+
primaryKey: bufferedRelations?.primaryKey ?? []
|
|
3298
|
+
};
|
|
3299
|
+
for (const column of Object.values(
|
|
3300
|
+
value[table/* Table */.XI.Symbol.Columns]
|
|
3301
|
+
)) {
|
|
3302
|
+
if (column.primary) {
|
|
3303
|
+
tablesConfig[key].primaryKey.push(column);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
const extraConfig = value[table/* Table */.XI.Symbol.ExtraConfigBuilder]?.(value[table/* Table */.XI.Symbol.ExtraConfigColumns]);
|
|
3307
|
+
if (extraConfig) {
|
|
3308
|
+
for (const configEntry of Object.values(extraConfig)) {
|
|
3309
|
+
if ((0,entity.is)(configEntry, PrimaryKeyBuilder)) {
|
|
3310
|
+
tablesConfig[key].primaryKey.push(...configEntry.columns);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
} else if ((0,entity.is)(value, Relations)) {
|
|
3315
|
+
const dbName = (0,table/* getTableUniqueName */.Lf)(value.table);
|
|
3316
|
+
const tableName = tableNamesMap[dbName];
|
|
3317
|
+
const relations2 = value.config(
|
|
3318
|
+
configHelpers(value.table)
|
|
3319
|
+
);
|
|
3320
|
+
let primaryKey;
|
|
3321
|
+
for (const [relationName, relation] of Object.entries(relations2)) {
|
|
3322
|
+
if (tableName) {
|
|
3323
|
+
const tableConfig = tablesConfig[tableName];
|
|
3324
|
+
tableConfig.relations[relationName] = relation;
|
|
3325
|
+
if (primaryKey) {
|
|
3326
|
+
tableConfig.primaryKey.push(...primaryKey);
|
|
3327
|
+
}
|
|
3328
|
+
} else {
|
|
3329
|
+
if (!(dbName in relationsBuffer)) {
|
|
3330
|
+
relationsBuffer[dbName] = {
|
|
3331
|
+
relations: {},
|
|
3332
|
+
primaryKey
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
relationsBuffer[dbName].relations[relationName] = relation;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
return { tables: tablesConfig, tableNamesMap };
|
|
3341
|
+
}
|
|
3342
|
+
function relations(table, relations2) {
|
|
3343
|
+
return new Relations(
|
|
3344
|
+
table,
|
|
3345
|
+
(helpers) => Object.fromEntries(
|
|
3346
|
+
Object.entries(relations2(helpers)).map(([key, value]) => [
|
|
3347
|
+
key,
|
|
3348
|
+
value.withFieldName(key)
|
|
3349
|
+
])
|
|
3350
|
+
)
|
|
3351
|
+
);
|
|
3352
|
+
}
|
|
3353
|
+
function createOne(sourceTable) {
|
|
3354
|
+
return function one(table, config) {
|
|
3355
|
+
return new One(
|
|
3356
|
+
sourceTable,
|
|
3357
|
+
table,
|
|
3358
|
+
config,
|
|
3359
|
+
config?.fields.reduce((res, f) => res && f.notNull, true) ?? false
|
|
3360
|
+
);
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
function createMany(sourceTable) {
|
|
3364
|
+
return function many(referencedTable, config) {
|
|
3365
|
+
return new Many(sourceTable, referencedTable, config);
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
function normalizeRelation(schema, tableNamesMap, relation) {
|
|
3369
|
+
if ((0,entity.is)(relation, One) && relation.config) {
|
|
3370
|
+
return {
|
|
3371
|
+
fields: relation.config.fields,
|
|
3372
|
+
references: relation.config.references
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
const referencedTableTsName = tableNamesMap[(0,table/* getTableUniqueName */.Lf)(relation.referencedTable)];
|
|
3376
|
+
if (!referencedTableTsName) {
|
|
3377
|
+
throw new Error(
|
|
3378
|
+
`Table "${relation.referencedTable[table/* Table */.XI.Symbol.Name]}" not found in schema`
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3381
|
+
const referencedTableConfig = schema[referencedTableTsName];
|
|
3382
|
+
if (!referencedTableConfig) {
|
|
3383
|
+
throw new Error(`Table "${referencedTableTsName}" not found in schema`);
|
|
3384
|
+
}
|
|
3385
|
+
const sourceTable = relation.sourceTable;
|
|
3386
|
+
const sourceTableTsName = tableNamesMap[(0,table/* getTableUniqueName */.Lf)(sourceTable)];
|
|
3387
|
+
if (!sourceTableTsName) {
|
|
3388
|
+
throw new Error(
|
|
3389
|
+
`Table "${sourceTable[table/* Table */.XI.Symbol.Name]}" not found in schema`
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
const reverseRelations = [];
|
|
3393
|
+
for (const referencedTableRelation of Object.values(
|
|
3394
|
+
referencedTableConfig.relations
|
|
3395
|
+
)) {
|
|
3396
|
+
if (relation.relationName && relation !== referencedTableRelation && referencedTableRelation.relationName === relation.relationName || !relation.relationName && referencedTableRelation.referencedTable === relation.sourceTable) {
|
|
3397
|
+
reverseRelations.push(referencedTableRelation);
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
if (reverseRelations.length > 1) {
|
|
3401
|
+
throw relation.relationName ? new Error(
|
|
3402
|
+
`There are multiple relations with name "${relation.relationName}" in table "${referencedTableTsName}"`
|
|
3403
|
+
) : new Error(
|
|
3404
|
+
`There are multiple relations between "${referencedTableTsName}" and "${relation.sourceTable[table/* Table */.XI.Symbol.Name]}". Please specify relation name`
|
|
3405
|
+
);
|
|
3406
|
+
}
|
|
3407
|
+
if (reverseRelations[0] && (0,entity.is)(reverseRelations[0], One) && reverseRelations[0].config) {
|
|
3408
|
+
return {
|
|
3409
|
+
fields: reverseRelations[0].config.references,
|
|
3410
|
+
references: reverseRelations[0].config.fields
|
|
3411
|
+
};
|
|
3412
|
+
}
|
|
3413
|
+
throw new Error(
|
|
3414
|
+
`There is not enough information to infer relation "${sourceTableTsName}.${relation.fieldName}"`
|
|
3415
|
+
);
|
|
3416
|
+
}
|
|
3417
|
+
function createTableRelationsHelpers(sourceTable) {
|
|
3418
|
+
return {
|
|
3419
|
+
one: createOne(sourceTable),
|
|
3420
|
+
many: createMany(sourceTable)
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelection, mapColumnValue = (value) => value) {
|
|
3424
|
+
const result = {};
|
|
3425
|
+
for (const [
|
|
3426
|
+
selectionItemIndex,
|
|
3427
|
+
selectionItem
|
|
3428
|
+
] of buildQueryResultSelection.entries()) {
|
|
3429
|
+
if (selectionItem.isJson) {
|
|
3430
|
+
const relation = tableConfig.relations[selectionItem.tsKey];
|
|
3431
|
+
const rawSubRows = row[selectionItemIndex];
|
|
3432
|
+
const subRows = typeof rawSubRows === "string" ? JSON.parse(rawSubRows) : rawSubRows;
|
|
3433
|
+
result[selectionItem.tsKey] = (0,entity.is)(relation, One) ? subRows && mapRelationalRow(
|
|
3434
|
+
tablesConfig,
|
|
3435
|
+
tablesConfig[selectionItem.relationTableTsKey],
|
|
3436
|
+
subRows,
|
|
3437
|
+
selectionItem.selection,
|
|
3438
|
+
mapColumnValue
|
|
3439
|
+
) : subRows.map(
|
|
3440
|
+
(subRow) => mapRelationalRow(
|
|
3441
|
+
tablesConfig,
|
|
3442
|
+
tablesConfig[selectionItem.relationTableTsKey],
|
|
3443
|
+
subRow,
|
|
3444
|
+
selectionItem.selection,
|
|
3445
|
+
mapColumnValue
|
|
3446
|
+
)
|
|
3447
|
+
);
|
|
3448
|
+
} else {
|
|
3449
|
+
const value = mapColumnValue(row[selectionItemIndex]);
|
|
3450
|
+
const field = selectionItem.field;
|
|
3451
|
+
let decoder;
|
|
3452
|
+
if ((0,entity.is)(field, column/* Column */.V)) {
|
|
3453
|
+
decoder = field;
|
|
3454
|
+
} else if ((0,entity.is)(field, sql/* SQL */.Xs)) {
|
|
3455
|
+
decoder = field.decoder;
|
|
3456
|
+
} else {
|
|
3457
|
+
decoder = field.sql.decoder;
|
|
3458
|
+
}
|
|
3459
|
+
result[selectionItem.tsKey] = value === null ? null : decoder.mapFromDriverValue(value);
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
return result;
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
//# sourceMappingURL=relations.js.map
|
|
3466
|
+
|
|
3467
|
+
/***/ }),
|
|
3468
|
+
|
|
3469
|
+
/***/ 8296:
|
|
3470
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3471
|
+
|
|
3472
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3473
|
+
/* harmony export */ b: () => (/* binding */ SelectionProxyHandler)
|
|
3474
|
+
/* harmony export */ });
|
|
3475
|
+
/* harmony import */ var _alias_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8575);
|
|
3476
|
+
/* harmony import */ var _column_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2345);
|
|
3477
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9724);
|
|
3478
|
+
/* harmony import */ var _sql_sql_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(183);
|
|
3479
|
+
/* harmony import */ var _subquery_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6453);
|
|
3480
|
+
/* harmony import */ var _view_common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6146);
|
|
3481
|
+
|
|
3482
|
+
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
|
|
3486
|
+
|
|
3487
|
+
class SelectionProxyHandler {
|
|
3488
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_0__/* .entityKind */ .i] = "SelectionProxyHandler";
|
|
3489
|
+
config;
|
|
3490
|
+
constructor(config) {
|
|
3491
|
+
this.config = { ...config };
|
|
3492
|
+
}
|
|
3493
|
+
get(subquery, prop) {
|
|
3494
|
+
if (prop === "_") {
|
|
3495
|
+
return {
|
|
3496
|
+
...subquery["_"],
|
|
3497
|
+
selectedFields: new Proxy(
|
|
3498
|
+
subquery._.selectedFields,
|
|
3499
|
+
this
|
|
3500
|
+
)
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3503
|
+
if (prop === _view_common_js__WEBPACK_IMPORTED_MODULE_1__/* .ViewBaseConfig */ .n) {
|
|
3504
|
+
return {
|
|
3505
|
+
...subquery[_view_common_js__WEBPACK_IMPORTED_MODULE_1__/* .ViewBaseConfig */ .n],
|
|
3506
|
+
selectedFields: new Proxy(
|
|
3507
|
+
subquery[_view_common_js__WEBPACK_IMPORTED_MODULE_1__/* .ViewBaseConfig */ .n].selectedFields,
|
|
3508
|
+
this
|
|
3509
|
+
)
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
if (typeof prop === "symbol") {
|
|
3513
|
+
return subquery[prop];
|
|
3514
|
+
}
|
|
3515
|
+
const columns = (0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(subquery, _subquery_js__WEBPACK_IMPORTED_MODULE_2__/* .Subquery */ .n) ? subquery._.selectedFields : (0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(subquery, _sql_sql_js__WEBPACK_IMPORTED_MODULE_3__/* .View */ .Ss) ? subquery[_view_common_js__WEBPACK_IMPORTED_MODULE_1__/* .ViewBaseConfig */ .n].selectedFields : subquery;
|
|
3516
|
+
const value = columns[prop];
|
|
3517
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(value, _sql_sql_js__WEBPACK_IMPORTED_MODULE_3__/* .SQL */ .Xs.Aliased)) {
|
|
3518
|
+
if (this.config.sqlAliasedBehavior === "sql" && !value.isSelectionField) {
|
|
3519
|
+
return value.sql;
|
|
3520
|
+
}
|
|
3521
|
+
const newValue = value.clone();
|
|
3522
|
+
newValue.isSelectionField = true;
|
|
3523
|
+
return newValue;
|
|
3524
|
+
}
|
|
3525
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(value, _sql_sql_js__WEBPACK_IMPORTED_MODULE_3__/* .SQL */ .Xs)) {
|
|
3526
|
+
if (this.config.sqlBehavior === "sql") {
|
|
3527
|
+
return value;
|
|
3528
|
+
}
|
|
3529
|
+
throw new Error(
|
|
3530
|
+
`You tried to reference "${prop}" 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.`
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
if ((0,_entity_js__WEBPACK_IMPORTED_MODULE_0__.is)(value, _column_js__WEBPACK_IMPORTED_MODULE_4__/* .Column */ .V)) {
|
|
3534
|
+
if (this.config.alias) {
|
|
3535
|
+
return new Proxy(
|
|
3536
|
+
value,
|
|
3537
|
+
new _alias_js__WEBPACK_IMPORTED_MODULE_5__/* .ColumnAliasProxyHandler */ .Ht(
|
|
3538
|
+
new Proxy(
|
|
3539
|
+
value.table,
|
|
3540
|
+
new _alias_js__WEBPACK_IMPORTED_MODULE_5__/* .TableAliasProxyHandler */ .h_(this.config.alias, this.config.replaceOriginalName ?? false)
|
|
3541
|
+
)
|
|
3542
|
+
)
|
|
3543
|
+
);
|
|
3544
|
+
}
|
|
3545
|
+
return value;
|
|
3546
|
+
}
|
|
3547
|
+
if (typeof value !== "object" || value === null) {
|
|
3548
|
+
return value;
|
|
3549
|
+
}
|
|
3550
|
+
return new Proxy(value, new SelectionProxyHandler(this.config));
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
//# sourceMappingURL=selection-proxy.js.map
|
|
3555
|
+
|
|
3556
|
+
/***/ }),
|
|
3557
|
+
|
|
3558
|
+
/***/ 3824:
|
|
3559
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3560
|
+
|
|
3561
|
+
|
|
3562
|
+
// EXPORTS
|
|
3563
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
3564
|
+
v: () => (/* binding */ SQLiteColumn),
|
|
3565
|
+
o: () => (/* binding */ SQLiteColumnBuilder)
|
|
3566
|
+
});
|
|
3567
|
+
|
|
3568
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/column-builder.js
|
|
3569
|
+
var column_builder = __webpack_require__(5099);
|
|
3570
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/column.js
|
|
3571
|
+
var column = __webpack_require__(2345);
|
|
3572
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/entity.js
|
|
3573
|
+
var entity = __webpack_require__(9724);
|
|
3574
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/table.utils.js
|
|
3575
|
+
var table_utils = __webpack_require__(7340);
|
|
3576
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
|
|
3577
|
+
|
|
3578
|
+
|
|
3579
|
+
class ForeignKeyBuilder {
|
|
3580
|
+
static [entity/* entityKind */.i] = "SQLiteForeignKeyBuilder";
|
|
3581
|
+
/** @internal */
|
|
3582
|
+
reference;
|
|
3583
|
+
/** @internal */
|
|
3584
|
+
_onUpdate;
|
|
3585
|
+
/** @internal */
|
|
3586
|
+
_onDelete;
|
|
3587
|
+
constructor(config, actions) {
|
|
3588
|
+
this.reference = () => {
|
|
3589
|
+
const { name, columns, foreignColumns } = config();
|
|
3590
|
+
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
|
|
3591
|
+
};
|
|
3592
|
+
if (actions) {
|
|
3593
|
+
this._onUpdate = actions.onUpdate;
|
|
3594
|
+
this._onDelete = actions.onDelete;
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
onUpdate(action) {
|
|
3598
|
+
this._onUpdate = action;
|
|
3599
|
+
return this;
|
|
3600
|
+
}
|
|
3601
|
+
onDelete(action) {
|
|
3602
|
+
this._onDelete = action;
|
|
3603
|
+
return this;
|
|
3604
|
+
}
|
|
3605
|
+
/** @internal */
|
|
3606
|
+
build(table) {
|
|
3607
|
+
return new ForeignKey(table, this);
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
class ForeignKey {
|
|
3611
|
+
constructor(table, builder) {
|
|
3612
|
+
this.table = table;
|
|
3613
|
+
this.reference = builder.reference;
|
|
3614
|
+
this.onUpdate = builder._onUpdate;
|
|
3615
|
+
this.onDelete = builder._onDelete;
|
|
3616
|
+
}
|
|
3617
|
+
static [entity/* entityKind */.i] = "SQLiteForeignKey";
|
|
3618
|
+
reference;
|
|
3619
|
+
onUpdate;
|
|
3620
|
+
onDelete;
|
|
3621
|
+
getName() {
|
|
3622
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
3623
|
+
const columnNames = columns.map((column) => column.name);
|
|
3624
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
3625
|
+
const chunks = [
|
|
3626
|
+
this.table[table_utils/* TableName */.E],
|
|
3627
|
+
...columnNames,
|
|
3628
|
+
foreignColumns[0].table[table_utils/* TableName */.E],
|
|
3629
|
+
...foreignColumnNames
|
|
3630
|
+
];
|
|
3631
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
function foreignKey(config) {
|
|
3635
|
+
function mappedConfig() {
|
|
3636
|
+
if (typeof config === "function") {
|
|
3637
|
+
const { name, columns, foreignColumns } = config();
|
|
3638
|
+
return {
|
|
3639
|
+
name,
|
|
3640
|
+
columns,
|
|
3641
|
+
foreignColumns
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3644
|
+
return config;
|
|
3645
|
+
}
|
|
3646
|
+
return new ForeignKeyBuilder(mappedConfig);
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
//# sourceMappingURL=foreign-keys.js.map
|
|
3650
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
|
|
3651
|
+
|
|
3652
|
+
|
|
3653
|
+
function uniqueKeyName(table, columns) {
|
|
3654
|
+
return `${table[table_utils/* TableName */.E]}_${columns.join("_")}_unique`;
|
|
3655
|
+
}
|
|
3656
|
+
function unique(name) {
|
|
3657
|
+
return new UniqueOnConstraintBuilder(name);
|
|
3658
|
+
}
|
|
3659
|
+
class UniqueConstraintBuilder {
|
|
3660
|
+
constructor(columns, name) {
|
|
3661
|
+
this.name = name;
|
|
3662
|
+
this.columns = columns;
|
|
3663
|
+
}
|
|
3664
|
+
static [entity/* entityKind */.i] = (/* unused pure expression or super */ null && ("SQLiteUniqueConstraintBuilder"));
|
|
3665
|
+
/** @internal */
|
|
3666
|
+
columns;
|
|
3667
|
+
/** @internal */
|
|
3668
|
+
build(table) {
|
|
3669
|
+
return new UniqueConstraint(table, this.columns, this.name);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
class UniqueOnConstraintBuilder {
|
|
3673
|
+
static [entity/* entityKind */.i] = (/* unused pure expression or super */ null && ("SQLiteUniqueOnConstraintBuilder"));
|
|
3674
|
+
/** @internal */
|
|
3675
|
+
name;
|
|
3676
|
+
constructor(name) {
|
|
3677
|
+
this.name = name;
|
|
3678
|
+
}
|
|
3679
|
+
on(...columns) {
|
|
3680
|
+
return new UniqueConstraintBuilder(columns, this.name);
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
class UniqueConstraint {
|
|
3684
|
+
constructor(table, columns, name) {
|
|
3685
|
+
this.table = table;
|
|
3686
|
+
this.columns = columns;
|
|
3687
|
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
3688
|
+
}
|
|
3689
|
+
static [entity/* entityKind */.i] = (/* unused pure expression or super */ null && ("SQLiteUniqueConstraint"));
|
|
3690
|
+
columns;
|
|
3691
|
+
name;
|
|
3692
|
+
getName() {
|
|
3693
|
+
return this.name;
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
//# sourceMappingURL=unique-constraint.js.map
|
|
3698
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/common.js
|
|
3699
|
+
|
|
3700
|
+
|
|
3701
|
+
|
|
3702
|
+
|
|
3703
|
+
|
|
3704
|
+
class SQLiteColumnBuilder extends column_builder/* ColumnBuilder */.Q {
|
|
3705
|
+
static [entity/* entityKind */.i] = "SQLiteColumnBuilder";
|
|
3706
|
+
foreignKeyConfigs = [];
|
|
3707
|
+
references(ref, actions = {}) {
|
|
3708
|
+
this.foreignKeyConfigs.push({ ref, actions });
|
|
3709
|
+
return this;
|
|
3710
|
+
}
|
|
3711
|
+
unique(name) {
|
|
3712
|
+
this.config.isUnique = true;
|
|
3713
|
+
this.config.uniqueName = name;
|
|
3714
|
+
return this;
|
|
3715
|
+
}
|
|
3716
|
+
generatedAlwaysAs(as, config) {
|
|
3717
|
+
this.config.generated = {
|
|
3718
|
+
as,
|
|
3719
|
+
type: "always",
|
|
3720
|
+
mode: config?.mode ?? "virtual"
|
|
3721
|
+
};
|
|
3722
|
+
return this;
|
|
3723
|
+
}
|
|
3724
|
+
/** @internal */
|
|
3725
|
+
buildForeignKeys(column, table) {
|
|
3726
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
3727
|
+
return ((ref2, actions2) => {
|
|
3728
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
3729
|
+
const foreignColumn = ref2();
|
|
3730
|
+
return { columns: [column], foreignColumns: [foreignColumn] };
|
|
3731
|
+
});
|
|
3732
|
+
if (actions2.onUpdate) {
|
|
3733
|
+
builder.onUpdate(actions2.onUpdate);
|
|
3734
|
+
}
|
|
3735
|
+
if (actions2.onDelete) {
|
|
3736
|
+
builder.onDelete(actions2.onDelete);
|
|
3737
|
+
}
|
|
3738
|
+
return builder.build(table);
|
|
3739
|
+
})(ref, actions);
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
class SQLiteColumn extends column/* Column */.V {
|
|
3744
|
+
constructor(table, config) {
|
|
3745
|
+
if (!config.uniqueName) {
|
|
3746
|
+
config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
3747
|
+
}
|
|
3748
|
+
super(table, config);
|
|
3749
|
+
this.table = table;
|
|
3750
|
+
}
|
|
3751
|
+
static [entity/* entityKind */.i] = "SQLiteColumn";
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
//# sourceMappingURL=common.js.map
|
|
3755
|
+
|
|
3756
|
+
/***/ }),
|
|
3757
|
+
|
|
3758
|
+
/***/ 6654:
|
|
3759
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3760
|
+
|
|
3761
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3762
|
+
/* harmony export */ nd: () => (/* binding */ integer)
|
|
3763
|
+
/* harmony export */ });
|
|
3764
|
+
/* unused harmony exports SQLiteBaseInteger, SQLiteBaseIntegerBuilder, SQLiteBoolean, SQLiteBooleanBuilder, SQLiteInteger, SQLiteIntegerBuilder, SQLiteTimestamp, SQLiteTimestampBuilder, int */
|
|
3765
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9724);
|
|
3766
|
+
/* harmony import */ var _sql_sql_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(183);
|
|
3767
|
+
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3853);
|
|
3768
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3824);
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
|
|
3772
|
+
|
|
3773
|
+
class SQLiteBaseIntegerBuilder extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumnBuilder */ .o {
|
|
3774
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteBaseIntegerBuilder";
|
|
3775
|
+
constructor(name, dataType, columnType) {
|
|
3776
|
+
super(name, dataType, columnType);
|
|
3777
|
+
this.config.autoIncrement = false;
|
|
3778
|
+
}
|
|
3779
|
+
primaryKey(config) {
|
|
3780
|
+
if (config?.autoIncrement) {
|
|
3781
|
+
this.config.autoIncrement = true;
|
|
3782
|
+
}
|
|
3783
|
+
this.config.hasDefault = true;
|
|
3784
|
+
return super.primaryKey();
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
class SQLiteBaseInteger extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumn */ .v {
|
|
3788
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteBaseInteger";
|
|
3789
|
+
autoIncrement = this.config.autoIncrement;
|
|
3790
|
+
getSQLType() {
|
|
3791
|
+
return "integer";
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
class SQLiteIntegerBuilder extends SQLiteBaseIntegerBuilder {
|
|
3795
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteIntegerBuilder";
|
|
3796
|
+
constructor(name) {
|
|
3797
|
+
super(name, "number", "SQLiteInteger");
|
|
3798
|
+
}
|
|
3799
|
+
build(table) {
|
|
3800
|
+
return new SQLiteInteger(
|
|
3801
|
+
table,
|
|
3802
|
+
this.config
|
|
3803
|
+
);
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
class SQLiteInteger extends SQLiteBaseInteger {
|
|
3807
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteInteger";
|
|
3808
|
+
}
|
|
3809
|
+
class SQLiteTimestampBuilder extends SQLiteBaseIntegerBuilder {
|
|
3810
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteTimestampBuilder";
|
|
3811
|
+
constructor(name, mode) {
|
|
3812
|
+
super(name, "date", "SQLiteTimestamp");
|
|
3813
|
+
this.config.mode = mode;
|
|
3814
|
+
}
|
|
3815
|
+
/**
|
|
3816
|
+
* @deprecated Use `default()` with your own expression instead.
|
|
3817
|
+
*
|
|
3818
|
+
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
|
|
3819
|
+
*/
|
|
3820
|
+
defaultNow() {
|
|
3821
|
+
return this.default((0,_sql_sql_js__WEBPACK_IMPORTED_MODULE_2__/* .sql */ .ll)`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
|
|
3822
|
+
}
|
|
3823
|
+
build(table) {
|
|
3824
|
+
return new SQLiteTimestamp(
|
|
3825
|
+
table,
|
|
3826
|
+
this.config
|
|
3827
|
+
);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
class SQLiteTimestamp extends SQLiteBaseInteger {
|
|
3831
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteTimestamp";
|
|
3832
|
+
mode = this.config.mode;
|
|
3833
|
+
mapFromDriverValue(value) {
|
|
3834
|
+
if (this.config.mode === "timestamp") {
|
|
3835
|
+
return new Date(value * 1e3);
|
|
3836
|
+
}
|
|
3837
|
+
return new Date(value);
|
|
3838
|
+
}
|
|
3839
|
+
mapToDriverValue(value) {
|
|
3840
|
+
const unix = value.getTime();
|
|
3841
|
+
if (this.config.mode === "timestamp") {
|
|
3842
|
+
return Math.floor(unix / 1e3);
|
|
3843
|
+
}
|
|
3844
|
+
return unix;
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
class SQLiteBooleanBuilder extends SQLiteBaseIntegerBuilder {
|
|
3848
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteBooleanBuilder";
|
|
3849
|
+
constructor(name, mode) {
|
|
3850
|
+
super(name, "boolean", "SQLiteBoolean");
|
|
3851
|
+
this.config.mode = mode;
|
|
3852
|
+
}
|
|
3853
|
+
build(table) {
|
|
3854
|
+
return new SQLiteBoolean(
|
|
3855
|
+
table,
|
|
3856
|
+
this.config
|
|
3857
|
+
);
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
class SQLiteBoolean extends SQLiteBaseInteger {
|
|
3861
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteBoolean";
|
|
3862
|
+
mode = this.config.mode;
|
|
3863
|
+
mapFromDriverValue(value) {
|
|
3864
|
+
return Number(value) === 1;
|
|
3865
|
+
}
|
|
3866
|
+
mapToDriverValue(value) {
|
|
3867
|
+
return value ? 1 : 0;
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
function integer(a, b) {
|
|
3871
|
+
const { name, config } = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__/* .getColumnNameAndConfig */ .Ll)(a, b);
|
|
3872
|
+
if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
|
|
3873
|
+
return new SQLiteTimestampBuilder(name, config.mode);
|
|
3874
|
+
}
|
|
3875
|
+
if (config?.mode === "boolean") {
|
|
3876
|
+
return new SQLiteBooleanBuilder(name, config.mode);
|
|
3877
|
+
}
|
|
3878
|
+
return new SQLiteIntegerBuilder(name);
|
|
3879
|
+
}
|
|
3880
|
+
const int = (/* unused pure expression or super */ null && (integer));
|
|
3881
|
+
|
|
3882
|
+
//# sourceMappingURL=integer.js.map
|
|
3883
|
+
|
|
3884
|
+
/***/ }),
|
|
3885
|
+
|
|
3886
|
+
/***/ 8470:
|
|
3887
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3888
|
+
|
|
3889
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3890
|
+
/* harmony export */ x: () => (/* binding */ real)
|
|
3891
|
+
/* harmony export */ });
|
|
3892
|
+
/* unused harmony exports SQLiteReal, SQLiteRealBuilder */
|
|
3893
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9724);
|
|
3894
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3824);
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
class SQLiteRealBuilder extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumnBuilder */ .o {
|
|
3898
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteRealBuilder";
|
|
3899
|
+
constructor(name) {
|
|
3900
|
+
super(name, "number", "SQLiteReal");
|
|
3901
|
+
}
|
|
3902
|
+
/** @internal */
|
|
3903
|
+
build(table) {
|
|
3904
|
+
return new SQLiteReal(table, this.config);
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
class SQLiteReal extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumn */ .v {
|
|
3908
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteReal";
|
|
3909
|
+
getSQLType() {
|
|
3910
|
+
return "real";
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
function real(name) {
|
|
3914
|
+
return new SQLiteRealBuilder(name ?? "");
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
//# sourceMappingURL=real.js.map
|
|
3918
|
+
|
|
3919
|
+
/***/ }),
|
|
3920
|
+
|
|
3921
|
+
/***/ 1513:
|
|
3922
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3923
|
+
|
|
3924
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3925
|
+
/* harmony export */ Qq: () => (/* binding */ text)
|
|
3926
|
+
/* harmony export */ });
|
|
3927
|
+
/* unused harmony exports SQLiteText, SQLiteTextBuilder, SQLiteTextJson, SQLiteTextJsonBuilder */
|
|
3928
|
+
/* harmony import */ var _entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9724);
|
|
3929
|
+
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3853);
|
|
3930
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3824);
|
|
3931
|
+
|
|
3932
|
+
|
|
3933
|
+
|
|
3934
|
+
class SQLiteTextBuilder extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumnBuilder */ .o {
|
|
3935
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteTextBuilder";
|
|
3936
|
+
constructor(name, config) {
|
|
3937
|
+
super(name, "string", "SQLiteText");
|
|
3938
|
+
this.config.enumValues = config.enum;
|
|
3939
|
+
this.config.length = config.length;
|
|
3940
|
+
}
|
|
3941
|
+
/** @internal */
|
|
3942
|
+
build(table) {
|
|
3943
|
+
return new SQLiteText(table, this.config);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
class SQLiteText extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumn */ .v {
|
|
3947
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteText";
|
|
3948
|
+
enumValues = this.config.enumValues;
|
|
3949
|
+
length = this.config.length;
|
|
3950
|
+
constructor(table, config) {
|
|
3951
|
+
super(table, config);
|
|
3952
|
+
}
|
|
3953
|
+
getSQLType() {
|
|
3954
|
+
return `text${this.config.length ? `(${this.config.length})` : ""}`;
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
class SQLiteTextJsonBuilder extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumnBuilder */ .o {
|
|
3958
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteTextJsonBuilder";
|
|
3959
|
+
constructor(name) {
|
|
3960
|
+
super(name, "json", "SQLiteTextJson");
|
|
3961
|
+
}
|
|
3962
|
+
/** @internal */
|
|
3963
|
+
build(table) {
|
|
3964
|
+
return new SQLiteTextJson(
|
|
3965
|
+
table,
|
|
3966
|
+
this.config
|
|
3967
|
+
);
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
class SQLiteTextJson extends _common_js__WEBPACK_IMPORTED_MODULE_0__/* .SQLiteColumn */ .v {
|
|
3971
|
+
static [_entity_js__WEBPACK_IMPORTED_MODULE_1__/* .entityKind */ .i] = "SQLiteTextJson";
|
|
3972
|
+
getSQLType() {
|
|
3973
|
+
return "text";
|
|
3974
|
+
}
|
|
3975
|
+
mapFromDriverValue(value) {
|
|
3976
|
+
return JSON.parse(value);
|
|
3977
|
+
}
|
|
3978
|
+
mapToDriverValue(value) {
|
|
3979
|
+
return JSON.stringify(value);
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
function text(a, b = {}) {
|
|
3983
|
+
const { name, config } = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__/* .getColumnNameAndConfig */ .Ll)(a, b);
|
|
3984
|
+
if (config.mode === "json") {
|
|
3985
|
+
return new SQLiteTextJsonBuilder(name);
|
|
3986
|
+
}
|
|
3987
|
+
return new SQLiteTextBuilder(name, config);
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
//# sourceMappingURL=text.js.map
|
|
3991
|
+
|
|
3992
|
+
/***/ }),
|
|
3993
|
+
|
|
3994
|
+
/***/ 2084:
|
|
3995
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
3996
|
+
|
|
3997
|
+
|
|
3998
|
+
// EXPORTS
|
|
3999
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
4000
|
+
jo: () => (/* binding */ SQLiteTable),
|
|
4001
|
+
D: () => (/* binding */ sqliteTable)
|
|
4002
|
+
});
|
|
4003
|
+
|
|
4004
|
+
// UNUSED EXPORTS: InlineForeignKeys, sqliteTableCreator
|
|
4005
|
+
|
|
4006
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/entity.js
|
|
4007
|
+
var entity = __webpack_require__(9724);
|
|
4008
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/table.js
|
|
4009
|
+
var drizzle_orm_table = __webpack_require__(8407);
|
|
4010
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/utils.js
|
|
4011
|
+
var utils = __webpack_require__(3853);
|
|
4012
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/common.js + 2 modules
|
|
4013
|
+
var common = __webpack_require__(3824);
|
|
4014
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/blob.js
|
|
4015
|
+
|
|
4016
|
+
|
|
4017
|
+
|
|
4018
|
+
class SQLiteBigIntBuilder extends common/* SQLiteColumnBuilder */.o {
|
|
4019
|
+
static [entity/* entityKind */.i] = "SQLiteBigIntBuilder";
|
|
4020
|
+
constructor(name) {
|
|
4021
|
+
super(name, "bigint", "SQLiteBigInt");
|
|
4022
|
+
}
|
|
4023
|
+
/** @internal */
|
|
4024
|
+
build(table) {
|
|
4025
|
+
return new SQLiteBigInt(table, this.config);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
class SQLiteBigInt extends common/* SQLiteColumn */.v {
|
|
4029
|
+
static [entity/* entityKind */.i] = "SQLiteBigInt";
|
|
4030
|
+
getSQLType() {
|
|
4031
|
+
return "blob";
|
|
4032
|
+
}
|
|
4033
|
+
mapFromDriverValue(value) {
|
|
4034
|
+
return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
|
4035
|
+
}
|
|
4036
|
+
mapToDriverValue(value) {
|
|
4037
|
+
return Buffer.from(value.toString());
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
class SQLiteBlobJsonBuilder extends common/* SQLiteColumnBuilder */.o {
|
|
4041
|
+
static [entity/* entityKind */.i] = "SQLiteBlobJsonBuilder";
|
|
4042
|
+
constructor(name) {
|
|
4043
|
+
super(name, "json", "SQLiteBlobJson");
|
|
4044
|
+
}
|
|
4045
|
+
/** @internal */
|
|
4046
|
+
build(table) {
|
|
4047
|
+
return new SQLiteBlobJson(
|
|
4048
|
+
table,
|
|
4049
|
+
this.config
|
|
4050
|
+
);
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
class SQLiteBlobJson extends common/* SQLiteColumn */.v {
|
|
4054
|
+
static [entity/* entityKind */.i] = "SQLiteBlobJson";
|
|
4055
|
+
getSQLType() {
|
|
4056
|
+
return "blob";
|
|
4057
|
+
}
|
|
4058
|
+
mapFromDriverValue(value) {
|
|
4059
|
+
return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
|
4060
|
+
}
|
|
4061
|
+
mapToDriverValue(value) {
|
|
4062
|
+
return Buffer.from(JSON.stringify(value));
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
class SQLiteBlobBufferBuilder extends common/* SQLiteColumnBuilder */.o {
|
|
4066
|
+
static [entity/* entityKind */.i] = "SQLiteBlobBufferBuilder";
|
|
4067
|
+
constructor(name) {
|
|
4068
|
+
super(name, "buffer", "SQLiteBlobBuffer");
|
|
4069
|
+
}
|
|
4070
|
+
/** @internal */
|
|
4071
|
+
build(table) {
|
|
4072
|
+
return new SQLiteBlobBuffer(table, this.config);
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
class SQLiteBlobBuffer extends common/* SQLiteColumn */.v {
|
|
4076
|
+
static [entity/* entityKind */.i] = "SQLiteBlobBuffer";
|
|
4077
|
+
getSQLType() {
|
|
4078
|
+
return "blob";
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
function blob(a, b) {
|
|
4082
|
+
const { name, config } = (0,utils/* getColumnNameAndConfig */.Ll)(a, b);
|
|
4083
|
+
if (config?.mode === "json") {
|
|
4084
|
+
return new SQLiteBlobJsonBuilder(name);
|
|
4085
|
+
}
|
|
4086
|
+
if (config?.mode === "bigint") {
|
|
4087
|
+
return new SQLiteBigIntBuilder(name);
|
|
4088
|
+
}
|
|
4089
|
+
return new SQLiteBlobBufferBuilder(name);
|
|
4090
|
+
}
|
|
4091
|
+
|
|
4092
|
+
//# sourceMappingURL=blob.js.map
|
|
4093
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/custom.js
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
class SQLiteCustomColumnBuilder extends common/* SQLiteColumnBuilder */.o {
|
|
4098
|
+
static [entity/* entityKind */.i] = "SQLiteCustomColumnBuilder";
|
|
4099
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
4100
|
+
super(name, "custom", "SQLiteCustomColumn");
|
|
4101
|
+
this.config.fieldConfig = fieldConfig;
|
|
4102
|
+
this.config.customTypeParams = customTypeParams;
|
|
4103
|
+
}
|
|
4104
|
+
/** @internal */
|
|
4105
|
+
build(table) {
|
|
4106
|
+
return new SQLiteCustomColumn(
|
|
4107
|
+
table,
|
|
4108
|
+
this.config
|
|
4109
|
+
);
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
class SQLiteCustomColumn extends common/* SQLiteColumn */.v {
|
|
4113
|
+
static [entity/* entityKind */.i] = "SQLiteCustomColumn";
|
|
4114
|
+
sqlName;
|
|
4115
|
+
mapTo;
|
|
4116
|
+
mapFrom;
|
|
4117
|
+
constructor(table, config) {
|
|
4118
|
+
super(table, config);
|
|
4119
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
4120
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
4121
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
4122
|
+
}
|
|
4123
|
+
getSQLType() {
|
|
4124
|
+
return this.sqlName;
|
|
4125
|
+
}
|
|
4126
|
+
mapFromDriverValue(value) {
|
|
4127
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
4128
|
+
}
|
|
4129
|
+
mapToDriverValue(value) {
|
|
4130
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
function customType(customTypeParams) {
|
|
4134
|
+
return (a, b) => {
|
|
4135
|
+
const { name, config } = (0,utils/* getColumnNameAndConfig */.Ll)(a, b);
|
|
4136
|
+
return new SQLiteCustomColumnBuilder(
|
|
4137
|
+
name,
|
|
4138
|
+
config,
|
|
4139
|
+
customTypeParams
|
|
4140
|
+
);
|
|
4141
|
+
};
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
//# sourceMappingURL=custom.js.map
|
|
4145
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/integer.js
|
|
4146
|
+
var integer = __webpack_require__(6654);
|
|
4147
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
|
|
4148
|
+
|
|
4149
|
+
|
|
4150
|
+
class SQLiteNumericBuilder extends common/* SQLiteColumnBuilder */.o {
|
|
4151
|
+
static [entity/* entityKind */.i] = "SQLiteNumericBuilder";
|
|
4152
|
+
constructor(name) {
|
|
4153
|
+
super(name, "string", "SQLiteNumeric");
|
|
4154
|
+
}
|
|
4155
|
+
/** @internal */
|
|
4156
|
+
build(table) {
|
|
4157
|
+
return new SQLiteNumeric(
|
|
4158
|
+
table,
|
|
4159
|
+
this.config
|
|
4160
|
+
);
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
class SQLiteNumeric extends common/* SQLiteColumn */.v {
|
|
4164
|
+
static [entity/* entityKind */.i] = "SQLiteNumeric";
|
|
4165
|
+
getSQLType() {
|
|
4166
|
+
return "numeric";
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
function numeric(name) {
|
|
4170
|
+
return new SQLiteNumericBuilder(name ?? "");
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
//# sourceMappingURL=numeric.js.map
|
|
4174
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/real.js
|
|
4175
|
+
var real = __webpack_require__(8470);
|
|
4176
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/text.js
|
|
4177
|
+
var columns_text = __webpack_require__(1513);
|
|
4178
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/columns/all.js
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
function getSQLiteColumnBuilders() {
|
|
4186
|
+
return {
|
|
4187
|
+
blob: blob,
|
|
4188
|
+
customType: customType,
|
|
4189
|
+
integer: integer/* integer */.nd,
|
|
4190
|
+
numeric: numeric,
|
|
4191
|
+
real: real/* real */.x,
|
|
4192
|
+
text: columns_text/* text */.Qq
|
|
4193
|
+
};
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
//# sourceMappingURL=all.js.map
|
|
4197
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/drizzle-orm@0.36.4_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_@types+react@18.3.28_be_bhyfo6jtf7gmzt2fsdpal3g2vq/node_modules/drizzle-orm/sqlite-core/table.js
|
|
4198
|
+
|
|
4199
|
+
|
|
4200
|
+
|
|
4201
|
+
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
4202
|
+
class SQLiteTable extends drizzle_orm_table/* Table */.XI {
|
|
4203
|
+
static [entity/* entityKind */.i] = "SQLiteTable";
|
|
4204
|
+
/** @internal */
|
|
4205
|
+
static Symbol = Object.assign({}, drizzle_orm_table/* Table */.XI.Symbol, {
|
|
4206
|
+
InlineForeignKeys
|
|
4207
|
+
});
|
|
4208
|
+
/** @internal */
|
|
4209
|
+
[drizzle_orm_table/* Table */.XI.Symbol.Columns];
|
|
4210
|
+
/** @internal */
|
|
4211
|
+
[InlineForeignKeys] = [];
|
|
4212
|
+
/** @internal */
|
|
4213
|
+
[drizzle_orm_table/* Table */.XI.Symbol.ExtraConfigBuilder] = void 0;
|
|
4214
|
+
}
|
|
4215
|
+
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
|
4216
|
+
const rawTable = new SQLiteTable(name, schema, baseName);
|
|
4217
|
+
const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
|
|
4218
|
+
const builtColumns = Object.fromEntries(
|
|
4219
|
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
4220
|
+
const colBuilder = colBuilderBase;
|
|
4221
|
+
colBuilder.setName(name2);
|
|
4222
|
+
const column = colBuilder.build(rawTable);
|
|
4223
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
4224
|
+
return [name2, column];
|
|
4225
|
+
})
|
|
4226
|
+
);
|
|
4227
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
4228
|
+
table[drizzle_orm_table/* Table */.XI.Symbol.Columns] = builtColumns;
|
|
4229
|
+
table[drizzle_orm_table/* Table */.XI.Symbol.ExtraConfigColumns] = builtColumns;
|
|
4230
|
+
if (extraConfig) {
|
|
4231
|
+
table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
4232
|
+
}
|
|
4233
|
+
return table;
|
|
4234
|
+
}
|
|
4235
|
+
const sqliteTable = (name, columns, extraConfig) => {
|
|
4236
|
+
return sqliteTableBase(name, columns, extraConfig);
|
|
4237
|
+
};
|
|
4238
|
+
function sqliteTableCreator(customizeTableName) {
|
|
4239
|
+
return (name, columns, extraConfig) => {
|
|
4240
|
+
return sqliteTableBase(customizeTableName(name), columns, extraConfig, void 0, name);
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4243
|
+
|
|
4244
|
+
//# sourceMappingURL=table.js.map
|
|
4245
|
+
|
|
4246
|
+
/***/ })
|
|
4247
|
+
|
|
4248
|
+
};
|
|
4249
|
+
|
|
4250
|
+
//# sourceMappingURL=411.index.js.map
|