drizzle-orm 1.0.0-beta.1-f92627f → 1.0.0-beta.1-cdf226f

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.
Files changed (45) hide show
  1. package/effect/effect-wrapper.cjs +46 -0
  2. package/effect/effect-wrapper.cjs.map +1 -0
  3. package/effect/effect-wrapper.d.cts +8 -0
  4. package/effect/effect-wrapper.d.ts +8 -0
  5. package/effect/effect-wrapper.js +22 -0
  6. package/effect/effect-wrapper.js.map +1 -0
  7. package/effect/sqlite/db.cjs +371 -0
  8. package/effect/sqlite/db.cjs.map +1 -0
  9. package/effect/sqlite/db.d.cts +277 -0
  10. package/effect/sqlite/db.d.ts +277 -0
  11. package/effect/sqlite/db.js +351 -0
  12. package/effect/sqlite/db.js.map +1 -0
  13. package/effect/sqlite/driver.cjs +67 -0
  14. package/effect/sqlite/driver.cjs.map +1 -0
  15. package/effect/sqlite/driver.d.cts +4 -0
  16. package/effect/sqlite/driver.d.ts +4 -0
  17. package/effect/sqlite/driver.js +33 -0
  18. package/effect/sqlite/driver.js.map +1 -0
  19. package/effect/sqlite/index.cjs +25 -0
  20. package/effect/sqlite/index.cjs.map +1 -0
  21. package/effect/sqlite/index.d.cts +2 -0
  22. package/effect/sqlite/index.d.ts +2 -0
  23. package/effect/sqlite/index.js +3 -0
  24. package/effect/sqlite/index.js.map +1 -0
  25. package/effect/sqlite/query-builders/select.cjs +122 -0
  26. package/effect/sqlite/query-builders/select.cjs.map +1 -0
  27. package/effect/sqlite/query-builders/select.d.cts +62 -0
  28. package/effect/sqlite/query-builders/select.d.ts +62 -0
  29. package/effect/sqlite/query-builders/select.js +97 -0
  30. package/effect/sqlite/query-builders/select.js.map +1 -0
  31. package/effect/sqlite/session.cjs +237 -0
  32. package/effect/sqlite/session.cjs.map +1 -0
  33. package/effect/sqlite/session.d.cts +79 -0
  34. package/effect/sqlite/session.d.ts +79 -0
  35. package/effect/sqlite/session.js +212 -0
  36. package/effect/sqlite/session.js.map +1 -0
  37. package/package.json +139 -52
  38. package/sqlite-core/session.cjs.map +1 -1
  39. package/sqlite-core/session.d.cts +1 -1
  40. package/sqlite-core/session.d.ts +1 -1
  41. package/sqlite-core/session.js.map +1 -1
  42. package/version.cjs +1 -1
  43. package/version.d.cts +1 -1
  44. package/version.d.ts +1 -1
  45. package/version.js +1 -1
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var select_exports = {};
20
+ __export(select_exports, {
21
+ EffectSQLiteSelectBase: () => EffectSQLiteSelectBase,
22
+ EffectSQLiteSelectBuilder: () => EffectSQLiteSelectBuilder
23
+ });
24
+ module.exports = __toCommonJS(select_exports);
25
+ var import_effect_wrapper = require("../../effect-wrapper.cjs");
26
+ var import_entity = require("../../../entity.cjs");
27
+ var import_sql = require("../../../sql/sql.cjs");
28
+ var import_select = require("../../../sqlite-core/query-builders/select.cjs");
29
+ var import_view_base = require("../../../sqlite-core/view-base.cjs");
30
+ var import_subquery = require("../../../subquery.cjs");
31
+ var import_utils = require("../../../utils.cjs");
32
+ var import_view_common = require("../../../view-common.cjs");
33
+ class EffectSQLiteSelectBuilder {
34
+ static [import_entity.entityKind] = "EffectSQLiteSelectBuilder";
35
+ fields;
36
+ session;
37
+ dialect;
38
+ withList;
39
+ distinct;
40
+ constructor(config) {
41
+ this.fields = config.fields;
42
+ this.session = config.session;
43
+ this.dialect = config.dialect;
44
+ this.withList = config.withList;
45
+ this.distinct = config.distinct;
46
+ }
47
+ from(source) {
48
+ const isPartialSelect = !!this.fields;
49
+ let fields;
50
+ if (this.fields) {
51
+ fields = this.fields;
52
+ } else if ((0, import_entity.is)(source, import_subquery.Subquery)) {
53
+ fields = Object.fromEntries(
54
+ Object.keys(source._.selectedFields).map((key) => [key, source[key]])
55
+ );
56
+ } else if ((0, import_entity.is)(source, import_view_base.SQLiteViewBase)) {
57
+ fields = source[import_view_common.ViewBaseConfig].selectedFields;
58
+ } else if ((0, import_entity.is)(source, import_sql.SQL)) {
59
+ fields = {};
60
+ } else {
61
+ fields = (0, import_utils.getTableColumns)(source);
62
+ }
63
+ return (0, import_effect_wrapper.effectWrap)(
64
+ new EffectSQLiteSelectBase({
65
+ table: source,
66
+ fields,
67
+ isPartialSelect,
68
+ session: this.session,
69
+ dialect: this.dialect,
70
+ withList: this.withList,
71
+ distinct: this.distinct
72
+ })
73
+ );
74
+ }
75
+ }
76
+ class EffectSQLiteSelectBase extends import_select.SQLiteSelectBase {
77
+ static [import_entity.entityKind] = "EffectSQLiteSelect";
78
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
79
+ run = () => {
80
+ throw new Error("Use `.effectRun()` for `Effect` compatibility");
81
+ };
82
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
83
+ all = () => {
84
+ throw new Error("Use `.effectAll()` for `Effect` compatibility");
85
+ };
86
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
87
+ get = () => {
88
+ throw new Error("Use `.effectGet()` for `Effect` compatibility");
89
+ };
90
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
91
+ values = () => {
92
+ throw new Error("Use `.effectValues()` for `Effect` compatibility");
93
+ };
94
+ /** @deprecated Use `.effect()` for `Effect` compatibility */
95
+ execute() {
96
+ throw new Error("Use `.effect()` for `Effect` compatibility");
97
+ }
98
+ effectRun = (placeholderValues) => {
99
+ return this.effectPrepare().run(placeholderValues);
100
+ };
101
+ effectAll = (placeholderValues) => {
102
+ return this.effectPrepare().all(placeholderValues);
103
+ };
104
+ effectGet = (placeholderValues) => {
105
+ return this.effectPrepare().get(placeholderValues);
106
+ };
107
+ effectValues = (placeholderValues) => {
108
+ return this.effectPrepare().values(placeholderValues);
109
+ };
110
+ effect(placeholderValues) {
111
+ return this.effectPrepare().all(placeholderValues);
112
+ }
113
+ effectPrepare() {
114
+ return this._prepare();
115
+ }
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ EffectSQLiteSelectBase,
120
+ EffectSQLiteSelectBuilder
121
+ });
122
+ //# sourceMappingURL=select.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/effect/sqlite/query-builders/select.ts"],"sourcesContent":["import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';\nimport type { SqlError } from '@effect/sql/SqlError';\nimport type { Effect } from 'effect';\nimport { effectWrap } from '~/effect/effect-wrapper.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type {\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tSelectMode,\n\tSelectResult,\n} from '~/query-builders/select.types.ts';\nimport type { ColumnsSelection } from '~/sql/sql.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport type { SQLiteDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteSelectBase } from '~/sqlite-core/query-builders/select.ts';\nimport type { SQLiteSelectQueryBuilderBase } from '~/sqlite-core/query-builders/select.ts';\nimport type {\n\tAnySQLiteSelect,\n\tSelectedFields,\n\tSQLiteSelectExecute,\n\tSQLiteSelectQueryBuilderHKT,\n} from '~/sqlite-core/query-builders/select.types.ts';\nimport type { SQLiteTable } from '~/sqlite-core/table.ts';\nimport { SQLiteViewBase } from '~/sqlite-core/view-base.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { type Assume, getTableColumns } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { EffectSQLitePreparedQuery, EffectSQLiteSession } from '../session.ts';\n\nexport type CreateEffectSQLiteSelectFromBuilderMode<\n\tTBuilderMode extends 'db' | 'qb',\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n> = TBuilderMode extends 'db' ? EffectSQLiteSelectBase<\n\t\tTTableName,\n\t\tTSelection,\n\t\tTSelectMode\n\t>\n\t: SQLiteSelectQueryBuilderBase<\n\t\tSQLiteSelectQueryBuilderHKT,\n\t\tTTableName,\n\t\t'sync',\n\t\tRecord<string, unknown>[],\n\t\tTSelection,\n\t\tTSelectMode\n\t>;\n\nexport class EffectSQLiteSelectBuilder<\n\tTSelection extends SelectedFields | undefined,\n\tTBuilderMode extends 'db' | 'qb' = 'db',\n> {\n\tstatic readonly [entityKind]: string = 'EffectSQLiteSelectBuilder';\n\n\tprivate fields: TSelection;\n\tprivate session: EffectSQLiteSession<any, any, any> | undefined;\n\tprivate dialect: SQLiteDialect;\n\tprivate withList: Subquery[] | undefined;\n\tprivate distinct: boolean | undefined;\n\n\tconstructor(\n\t\tconfig: {\n\t\t\tfields: TSelection;\n\t\t\tsession: EffectSQLiteSession<any, any, any> | undefined;\n\t\t\tdialect: SQLiteDialect;\n\t\t\twithList?: Subquery[];\n\t\t\tdistinct?: boolean;\n\t\t},\n\t) {\n\t\tthis.fields = config.fields;\n\t\tthis.session = config.session;\n\t\tthis.dialect = config.dialect;\n\t\tthis.withList = config.withList;\n\t\tthis.distinct = config.distinct;\n\t}\n\n\tfrom<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(\n\t\tsource: TFrom,\n\t): CreateEffectSQLiteSelectFromBuilderMode<\n\t\tTBuilderMode,\n\t\tGetSelectTableName<TFrom>,\n\t\tTSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,\n\t\tTSelection extends undefined ? 'single' : 'partial'\n\t> {\n\t\tconst isPartialSelect = !!this.fields;\n\n\t\tlet fields: SelectedFields;\n\t\tif (this.fields) {\n\t\t\tfields = this.fields;\n\t\t} else if (is(source, Subquery)) {\n\t\t\t// This is required to use the proxy handler to get the correct field values from the subquery\n\t\t\tfields = Object.fromEntries(\n\t\t\t\tObject.keys(source._.selectedFields).map((\n\t\t\t\t\tkey,\n\t\t\t\t) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),\n\t\t\t);\n\t\t} else if (is(source, SQLiteViewBase)) {\n\t\t\tfields = source[ViewBaseConfig].selectedFields as SelectedFields;\n\t\t} else if (is(source, SQL)) {\n\t\t\tfields = {};\n\t\t} else {\n\t\t\tfields = getTableColumns<SQLiteTable>(source);\n\t\t}\n\n\t\treturn effectWrap(\n\t\t\tnew EffectSQLiteSelectBase({\n\t\t\t\ttable: source,\n\t\t\t\tfields,\n\t\t\t\tisPartialSelect,\n\t\t\t\tsession: this.session,\n\t\t\t\tdialect: this.dialect,\n\t\t\t\twithList: this.withList,\n\t\t\t\tdistinct: this.distinct,\n\t\t\t}),\n\t\t) as any;\n\t}\n}\n\nexport interface EffectSQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends Record<string, unknown>,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends Effect.Effect<TResult, SqlError, SqliteClient> {}\n\nexport class EffectSQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends Record<string, unknown>,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends SQLiteSelectBase<\n\tTTableName,\n\t'sync',\n\tRecord<string, unknown>[],\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\tTDynamic,\n\tTExcludedMethods,\n\tTResult,\n\tTSelectedFields\n> {\n\tstatic override readonly [entityKind]: string = 'EffectSQLiteSelect';\n\n\t/** @deprecated Use `.effectRun()` for `Effect` compatibility */\n\toverride run: any = () => {\n\t\tthrow new Error('Use `.effectRun()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectAll()` for `Effect` compatibility */\n\toverride all: any = () => {\n\t\tthrow new Error('Use `.effectAll()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectGet()` for `Effect` compatibility */\n\toverride get: any = () => {\n\t\tthrow new Error('Use `.effectGet()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectValues()` for `Effect` compatibility */\n\toverride values: any = () => {\n\t\tthrow new Error('Use `.effectValues()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effect()` for `Effect` compatibility */\n\toverride execute(): never {\n\t\tthrow new Error('Use `.effect()` for `Effect` compatibility');\n\t}\n\n\teffectRun: ReturnType<this['effectPrepare']>['run'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().run(placeholderValues) as any;\n\t};\n\n\teffectAll: ReturnType<this['effectPrepare']>['all'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().all(placeholderValues) as any;\n\t};\n\n\teffectGet: ReturnType<this['effectPrepare']>['get'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().get(placeholderValues) as any;\n\t};\n\n\teffectValues: ReturnType<this['effectPrepare']>['values'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().values(placeholderValues) as any;\n\t};\n\n\teffect(placeholderValues?: Record<string, unknown>): Effect.Effect<TResult, SqlError, SqliteClient> {\n\t\treturn this.effectPrepare().all(placeholderValues) as any;\n\t}\n\n\teffectPrepare(): EffectSQLiteSelectPrepare<Assume<this, AnySQLiteSelect>> {\n\t\treturn this._prepare() as any;\n\t}\n}\n\nexport type EffectSQLiteSelectPrepare<T extends AnySQLiteSelect> = EffectSQLitePreparedQuery<\n\t{\n\t\ttype: T['_']['resultType'];\n\t\trun: T['_']['runResult'];\n\t\tall: T['_']['result'];\n\t\tget: T['_']['result'][number] | undefined;\n\t\tvalues: any[][];\n\t\texecute: SQLiteSelectExecute<T>;\n\t}\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA2B;AAC3B,oBAA+B;AAU/B,iBAAoB;AAEpB,oBAAiC;AASjC,uBAA+B;AAC/B,sBAAyB;AACzB,mBAA6C;AAC7C,yBAA+B;AAsBxB,MAAM,0BAGX;AAAA,EACD,QAAiB,wBAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,QAOC;AACD,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACtB,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AAAA,EACxB;AAAA,EAEA,KACC,QAMC;AACD,UAAM,kBAAkB,CAAC,CAAC,KAAK;AAE/B,QAAI;AACJ,QAAI,KAAK,QAAQ;AAChB,eAAS,KAAK;AAAA,IACf,eAAW,kBAAG,QAAQ,wBAAQ,GAAG;AAEhC,eAAS,OAAO;AAAA,QACf,OAAO,KAAK,OAAO,EAAE,cAAc,EAAE,IAAI,CACxC,QACI,CAAC,KAAK,OAAO,GAAqC,CAAsC,CAAC;AAAA,MAC/F;AAAA,IACD,eAAW,kBAAG,QAAQ,+BAAc,GAAG;AACtC,eAAS,OAAO,iCAAc,EAAE;AAAA,IACjC,eAAW,kBAAG,QAAQ,cAAG,GAAG;AAC3B,eAAS,CAAC;AAAA,IACX,OAAO;AACN,mBAAS,8BAA6B,MAAM;AAAA,IAC7C;AAEA,eAAO;AAAA,MACN,IAAI,uBAAuB;AAAA,QAC1B,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA,SAAS,KAAK;AAAA,QACd,SAAS,KAAK;AAAA,QACd,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,MAChB,CAAC;AAAA,IACF;AAAA,EACD;AACD;AAiBO,MAAM,+BAUH,+BAWR;AAAA,EACD,QAA0B,wBAAU,IAAY;AAAA;AAAA,EAGvC,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,SAAc,MAAM;AAC5B,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACnE;AAAA;AAAA,EAGS,UAAiB;AACzB,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC7D;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,eAA4D,CAAC,sBAAgD;AAC5G,WAAO,KAAK,cAAc,EAAE,OAAO,iBAAiB;AAAA,EACrD;AAAA,EAEA,OAAO,mBAA6F;AACnG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,gBAA0E;AACzE,WAAO,KAAK,SAAS;AAAA,EACtB;AACD;","names":[]}
@@ -0,0 +1,62 @@
1
+ import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';
2
+ import type { SqlError } from '@effect/sql/SqlError';
3
+ import type { Effect } from 'effect';
4
+ import { entityKind } from "../../../entity.cjs";
5
+ import type { BuildSubquerySelection, GetSelectTableName, GetSelectTableSelection, JoinNullability, SelectMode, SelectResult } from "../../../query-builders/select.types.cjs";
6
+ import type { ColumnsSelection } from "../../../sql/sql.cjs";
7
+ import { SQL } from "../../../sql/sql.cjs";
8
+ import type { SQLiteDialect } from "../../../sqlite-core/dialect.cjs";
9
+ import { SQLiteSelectBase } from "../../../sqlite-core/query-builders/select.cjs";
10
+ import type { SQLiteSelectQueryBuilderBase } from "../../../sqlite-core/query-builders/select.cjs";
11
+ import type { AnySQLiteSelect, SelectedFields, SQLiteSelectExecute, SQLiteSelectQueryBuilderHKT } from "../../../sqlite-core/query-builders/select.types.cjs";
12
+ import type { SQLiteTable } from "../../../sqlite-core/table.cjs";
13
+ import { SQLiteViewBase } from "../../../sqlite-core/view-base.cjs";
14
+ import { Subquery } from "../../../subquery.cjs";
15
+ import { type Assume } from "../../../utils.cjs";
16
+ import type { EffectSQLitePreparedQuery, EffectSQLiteSession } from "../session.cjs";
17
+ export type CreateEffectSQLiteSelectFromBuilderMode<TBuilderMode extends 'db' | 'qb', TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode> = TBuilderMode extends 'db' ? EffectSQLiteSelectBase<TTableName, TSelection, TSelectMode> : SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, TTableName, 'sync', Record<string, unknown>[], TSelection, TSelectMode>;
18
+ export declare class EffectSQLiteSelectBuilder<TSelection extends SelectedFields | undefined, TBuilderMode extends 'db' | 'qb' = 'db'> {
19
+ static readonly [entityKind]: string;
20
+ private fields;
21
+ private session;
22
+ private dialect;
23
+ private withList;
24
+ private distinct;
25
+ constructor(config: {
26
+ fields: TSelection;
27
+ session: EffectSQLiteSession<any, any, any> | undefined;
28
+ dialect: SQLiteDialect;
29
+ withList?: Subquery[];
30
+ distinct?: boolean;
31
+ });
32
+ from<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(source: TFrom): CreateEffectSQLiteSelectFromBuilderMode<TBuilderMode, GetSelectTableName<TFrom>, TSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection, TSelection extends undefined ? 'single' : 'partial'>;
33
+ }
34
+ export interface EffectSQLiteSelectBase<TTableName extends string | undefined, TSelection extends Record<string, unknown>, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends Effect.Effect<TResult, SqlError, SqliteClient> {
35
+ }
36
+ export declare class EffectSQLiteSelectBase<TTableName extends string | undefined, TSelection extends Record<string, unknown>, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends SQLiteSelectBase<TTableName, 'sync', Record<string, unknown>[], TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields> {
37
+ static readonly [entityKind]: string;
38
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
39
+ run: any;
40
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
41
+ all: any;
42
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
43
+ get: any;
44
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
45
+ values: any;
46
+ /** @deprecated Use `.effect()` for `Effect` compatibility */
47
+ execute(): never;
48
+ effectRun: ReturnType<this['effectPrepare']>['run'];
49
+ effectAll: ReturnType<this['effectPrepare']>['all'];
50
+ effectGet: ReturnType<this['effectPrepare']>['get'];
51
+ effectValues: ReturnType<this['effectPrepare']>['values'];
52
+ effect(placeholderValues?: Record<string, unknown>): Effect.Effect<TResult, SqlError, SqliteClient>;
53
+ effectPrepare(): EffectSQLiteSelectPrepare<Assume<this, AnySQLiteSelect>>;
54
+ }
55
+ export type EffectSQLiteSelectPrepare<T extends AnySQLiteSelect> = EffectSQLitePreparedQuery<{
56
+ type: T['_']['resultType'];
57
+ run: T['_']['runResult'];
58
+ all: T['_']['result'];
59
+ get: T['_']['result'][number] | undefined;
60
+ values: any[][];
61
+ execute: SQLiteSelectExecute<T>;
62
+ }>;
@@ -0,0 +1,62 @@
1
+ import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';
2
+ import type { SqlError } from '@effect/sql/SqlError';
3
+ import type { Effect } from 'effect';
4
+ import { entityKind } from "../../../entity.js";
5
+ import type { BuildSubquerySelection, GetSelectTableName, GetSelectTableSelection, JoinNullability, SelectMode, SelectResult } from "../../../query-builders/select.types.js";
6
+ import type { ColumnsSelection } from "../../../sql/sql.js";
7
+ import { SQL } from "../../../sql/sql.js";
8
+ import type { SQLiteDialect } from "../../../sqlite-core/dialect.js";
9
+ import { SQLiteSelectBase } from "../../../sqlite-core/query-builders/select.js";
10
+ import type { SQLiteSelectQueryBuilderBase } from "../../../sqlite-core/query-builders/select.js";
11
+ import type { AnySQLiteSelect, SelectedFields, SQLiteSelectExecute, SQLiteSelectQueryBuilderHKT } from "../../../sqlite-core/query-builders/select.types.js";
12
+ import type { SQLiteTable } from "../../../sqlite-core/table.js";
13
+ import { SQLiteViewBase } from "../../../sqlite-core/view-base.js";
14
+ import { Subquery } from "../../../subquery.js";
15
+ import { type Assume } from "../../../utils.js";
16
+ import type { EffectSQLitePreparedQuery, EffectSQLiteSession } from "../session.js";
17
+ export type CreateEffectSQLiteSelectFromBuilderMode<TBuilderMode extends 'db' | 'qb', TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode> = TBuilderMode extends 'db' ? EffectSQLiteSelectBase<TTableName, TSelection, TSelectMode> : SQLiteSelectQueryBuilderBase<SQLiteSelectQueryBuilderHKT, TTableName, 'sync', Record<string, unknown>[], TSelection, TSelectMode>;
18
+ export declare class EffectSQLiteSelectBuilder<TSelection extends SelectedFields | undefined, TBuilderMode extends 'db' | 'qb' = 'db'> {
19
+ static readonly [entityKind]: string;
20
+ private fields;
21
+ private session;
22
+ private dialect;
23
+ private withList;
24
+ private distinct;
25
+ constructor(config: {
26
+ fields: TSelection;
27
+ session: EffectSQLiteSession<any, any, any> | undefined;
28
+ dialect: SQLiteDialect;
29
+ withList?: Subquery[];
30
+ distinct?: boolean;
31
+ });
32
+ from<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(source: TFrom): CreateEffectSQLiteSelectFromBuilderMode<TBuilderMode, GetSelectTableName<TFrom>, TSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection, TSelection extends undefined ? 'single' : 'partial'>;
33
+ }
34
+ export interface EffectSQLiteSelectBase<TTableName extends string | undefined, TSelection extends Record<string, unknown>, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends Effect.Effect<TResult, SqlError, SqliteClient> {
35
+ }
36
+ export declare class EffectSQLiteSelectBase<TTableName extends string | undefined, TSelection extends Record<string, unknown>, TSelectMode extends SelectMode = 'single', TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends SQLiteSelectBase<TTableName, 'sync', Record<string, unknown>[], TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields> {
37
+ static readonly [entityKind]: string;
38
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
39
+ run: any;
40
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
41
+ all: any;
42
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
43
+ get: any;
44
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
45
+ values: any;
46
+ /** @deprecated Use `.effect()` for `Effect` compatibility */
47
+ execute(): never;
48
+ effectRun: ReturnType<this['effectPrepare']>['run'];
49
+ effectAll: ReturnType<this['effectPrepare']>['all'];
50
+ effectGet: ReturnType<this['effectPrepare']>['get'];
51
+ effectValues: ReturnType<this['effectPrepare']>['values'];
52
+ effect(placeholderValues?: Record<string, unknown>): Effect.Effect<TResult, SqlError, SqliteClient>;
53
+ effectPrepare(): EffectSQLiteSelectPrepare<Assume<this, AnySQLiteSelect>>;
54
+ }
55
+ export type EffectSQLiteSelectPrepare<T extends AnySQLiteSelect> = EffectSQLitePreparedQuery<{
56
+ type: T['_']['resultType'];
57
+ run: T['_']['runResult'];
58
+ all: T['_']['result'];
59
+ get: T['_']['result'][number] | undefined;
60
+ values: any[][];
61
+ execute: SQLiteSelectExecute<T>;
62
+ }>;
@@ -0,0 +1,97 @@
1
+ import { effectWrap } from "../../effect-wrapper.js";
2
+ import { entityKind, is } from "../../../entity.js";
3
+ import { SQL } from "../../../sql/sql.js";
4
+ import { SQLiteSelectBase } from "../../../sqlite-core/query-builders/select.js";
5
+ import { SQLiteViewBase } from "../../../sqlite-core/view-base.js";
6
+ import { Subquery } from "../../../subquery.js";
7
+ import { getTableColumns } from "../../../utils.js";
8
+ import { ViewBaseConfig } from "../../../view-common.js";
9
+ class EffectSQLiteSelectBuilder {
10
+ static [entityKind] = "EffectSQLiteSelectBuilder";
11
+ fields;
12
+ session;
13
+ dialect;
14
+ withList;
15
+ distinct;
16
+ constructor(config) {
17
+ this.fields = config.fields;
18
+ this.session = config.session;
19
+ this.dialect = config.dialect;
20
+ this.withList = config.withList;
21
+ this.distinct = config.distinct;
22
+ }
23
+ from(source) {
24
+ const isPartialSelect = !!this.fields;
25
+ let fields;
26
+ if (this.fields) {
27
+ fields = this.fields;
28
+ } else if (is(source, Subquery)) {
29
+ fields = Object.fromEntries(
30
+ Object.keys(source._.selectedFields).map((key) => [key, source[key]])
31
+ );
32
+ } else if (is(source, SQLiteViewBase)) {
33
+ fields = source[ViewBaseConfig].selectedFields;
34
+ } else if (is(source, SQL)) {
35
+ fields = {};
36
+ } else {
37
+ fields = getTableColumns(source);
38
+ }
39
+ return effectWrap(
40
+ new EffectSQLiteSelectBase({
41
+ table: source,
42
+ fields,
43
+ isPartialSelect,
44
+ session: this.session,
45
+ dialect: this.dialect,
46
+ withList: this.withList,
47
+ distinct: this.distinct
48
+ })
49
+ );
50
+ }
51
+ }
52
+ class EffectSQLiteSelectBase extends SQLiteSelectBase {
53
+ static [entityKind] = "EffectSQLiteSelect";
54
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
55
+ run = () => {
56
+ throw new Error("Use `.effectRun()` for `Effect` compatibility");
57
+ };
58
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
59
+ all = () => {
60
+ throw new Error("Use `.effectAll()` for `Effect` compatibility");
61
+ };
62
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
63
+ get = () => {
64
+ throw new Error("Use `.effectGet()` for `Effect` compatibility");
65
+ };
66
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
67
+ values = () => {
68
+ throw new Error("Use `.effectValues()` for `Effect` compatibility");
69
+ };
70
+ /** @deprecated Use `.effect()` for `Effect` compatibility */
71
+ execute() {
72
+ throw new Error("Use `.effect()` for `Effect` compatibility");
73
+ }
74
+ effectRun = (placeholderValues) => {
75
+ return this.effectPrepare().run(placeholderValues);
76
+ };
77
+ effectAll = (placeholderValues) => {
78
+ return this.effectPrepare().all(placeholderValues);
79
+ };
80
+ effectGet = (placeholderValues) => {
81
+ return this.effectPrepare().get(placeholderValues);
82
+ };
83
+ effectValues = (placeholderValues) => {
84
+ return this.effectPrepare().values(placeholderValues);
85
+ };
86
+ effect(placeholderValues) {
87
+ return this.effectPrepare().all(placeholderValues);
88
+ }
89
+ effectPrepare() {
90
+ return this._prepare();
91
+ }
92
+ }
93
+ export {
94
+ EffectSQLiteSelectBase,
95
+ EffectSQLiteSelectBuilder
96
+ };
97
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/effect/sqlite/query-builders/select.ts"],"sourcesContent":["import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';\nimport type { SqlError } from '@effect/sql/SqlError';\nimport type { Effect } from 'effect';\nimport { effectWrap } from '~/effect/effect-wrapper.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type {\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tSelectMode,\n\tSelectResult,\n} from '~/query-builders/select.types.ts';\nimport type { ColumnsSelection } from '~/sql/sql.ts';\nimport { SQL } from '~/sql/sql.ts';\nimport type { SQLiteDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteSelectBase } from '~/sqlite-core/query-builders/select.ts';\nimport type { SQLiteSelectQueryBuilderBase } from '~/sqlite-core/query-builders/select.ts';\nimport type {\n\tAnySQLiteSelect,\n\tSelectedFields,\n\tSQLiteSelectExecute,\n\tSQLiteSelectQueryBuilderHKT,\n} from '~/sqlite-core/query-builders/select.types.ts';\nimport type { SQLiteTable } from '~/sqlite-core/table.ts';\nimport { SQLiteViewBase } from '~/sqlite-core/view-base.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { type Assume, getTableColumns } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { EffectSQLitePreparedQuery, EffectSQLiteSession } from '../session.ts';\n\nexport type CreateEffectSQLiteSelectFromBuilderMode<\n\tTBuilderMode extends 'db' | 'qb',\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n> = TBuilderMode extends 'db' ? EffectSQLiteSelectBase<\n\t\tTTableName,\n\t\tTSelection,\n\t\tTSelectMode\n\t>\n\t: SQLiteSelectQueryBuilderBase<\n\t\tSQLiteSelectQueryBuilderHKT,\n\t\tTTableName,\n\t\t'sync',\n\t\tRecord<string, unknown>[],\n\t\tTSelection,\n\t\tTSelectMode\n\t>;\n\nexport class EffectSQLiteSelectBuilder<\n\tTSelection extends SelectedFields | undefined,\n\tTBuilderMode extends 'db' | 'qb' = 'db',\n> {\n\tstatic readonly [entityKind]: string = 'EffectSQLiteSelectBuilder';\n\n\tprivate fields: TSelection;\n\tprivate session: EffectSQLiteSession<any, any, any> | undefined;\n\tprivate dialect: SQLiteDialect;\n\tprivate withList: Subquery[] | undefined;\n\tprivate distinct: boolean | undefined;\n\n\tconstructor(\n\t\tconfig: {\n\t\t\tfields: TSelection;\n\t\t\tsession: EffectSQLiteSession<any, any, any> | undefined;\n\t\t\tdialect: SQLiteDialect;\n\t\t\twithList?: Subquery[];\n\t\t\tdistinct?: boolean;\n\t\t},\n\t) {\n\t\tthis.fields = config.fields;\n\t\tthis.session = config.session;\n\t\tthis.dialect = config.dialect;\n\t\tthis.withList = config.withList;\n\t\tthis.distinct = config.distinct;\n\t}\n\n\tfrom<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(\n\t\tsource: TFrom,\n\t): CreateEffectSQLiteSelectFromBuilderMode<\n\t\tTBuilderMode,\n\t\tGetSelectTableName<TFrom>,\n\t\tTSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,\n\t\tTSelection extends undefined ? 'single' : 'partial'\n\t> {\n\t\tconst isPartialSelect = !!this.fields;\n\n\t\tlet fields: SelectedFields;\n\t\tif (this.fields) {\n\t\t\tfields = this.fields;\n\t\t} else if (is(source, Subquery)) {\n\t\t\t// This is required to use the proxy handler to get the correct field values from the subquery\n\t\t\tfields = Object.fromEntries(\n\t\t\t\tObject.keys(source._.selectedFields).map((\n\t\t\t\t\tkey,\n\t\t\t\t) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),\n\t\t\t);\n\t\t} else if (is(source, SQLiteViewBase)) {\n\t\t\tfields = source[ViewBaseConfig].selectedFields as SelectedFields;\n\t\t} else if (is(source, SQL)) {\n\t\t\tfields = {};\n\t\t} else {\n\t\t\tfields = getTableColumns<SQLiteTable>(source);\n\t\t}\n\n\t\treturn effectWrap(\n\t\t\tnew EffectSQLiteSelectBase({\n\t\t\t\ttable: source,\n\t\t\t\tfields,\n\t\t\t\tisPartialSelect,\n\t\t\t\tsession: this.session,\n\t\t\t\tdialect: this.dialect,\n\t\t\t\twithList: this.withList,\n\t\t\t\tdistinct: this.distinct,\n\t\t\t}),\n\t\t) as any;\n\t}\n}\n\nexport interface EffectSQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends Record<string, unknown>,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends Effect.Effect<TResult, SqlError, SqliteClient> {}\n\nexport class EffectSQLiteSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends Record<string, unknown>,\n\tTSelectMode extends SelectMode = 'single',\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends SQLiteSelectBase<\n\tTTableName,\n\t'sync',\n\tRecord<string, unknown>[],\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\tTDynamic,\n\tTExcludedMethods,\n\tTResult,\n\tTSelectedFields\n> {\n\tstatic override readonly [entityKind]: string = 'EffectSQLiteSelect';\n\n\t/** @deprecated Use `.effectRun()` for `Effect` compatibility */\n\toverride run: any = () => {\n\t\tthrow new Error('Use `.effectRun()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectAll()` for `Effect` compatibility */\n\toverride all: any = () => {\n\t\tthrow new Error('Use `.effectAll()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectGet()` for `Effect` compatibility */\n\toverride get: any = () => {\n\t\tthrow new Error('Use `.effectGet()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effectValues()` for `Effect` compatibility */\n\toverride values: any = () => {\n\t\tthrow new Error('Use `.effectValues()` for `Effect` compatibility');\n\t};\n\n\t/** @deprecated Use `.effect()` for `Effect` compatibility */\n\toverride execute(): never {\n\t\tthrow new Error('Use `.effect()` for `Effect` compatibility');\n\t}\n\n\teffectRun: ReturnType<this['effectPrepare']>['run'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().run(placeholderValues) as any;\n\t};\n\n\teffectAll: ReturnType<this['effectPrepare']>['all'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().all(placeholderValues) as any;\n\t};\n\n\teffectGet: ReturnType<this['effectPrepare']>['get'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().get(placeholderValues) as any;\n\t};\n\n\teffectValues: ReturnType<this['effectPrepare']>['values'] = (placeholderValues?: Record<string, unknown>) => {\n\t\treturn this.effectPrepare().values(placeholderValues) as any;\n\t};\n\n\teffect(placeholderValues?: Record<string, unknown>): Effect.Effect<TResult, SqlError, SqliteClient> {\n\t\treturn this.effectPrepare().all(placeholderValues) as any;\n\t}\n\n\teffectPrepare(): EffectSQLiteSelectPrepare<Assume<this, AnySQLiteSelect>> {\n\t\treturn this._prepare() as any;\n\t}\n}\n\nexport type EffectSQLiteSelectPrepare<T extends AnySQLiteSelect> = EffectSQLitePreparedQuery<\n\t{\n\t\ttype: T['_']['resultType'];\n\t\trun: T['_']['runResult'];\n\t\tall: T['_']['result'];\n\t\tget: T['_']['result'][number] | undefined;\n\t\tvalues: any[][];\n\t\texecute: SQLiteSelectExecute<T>;\n\t}\n>;\n"],"mappings":"AAGA,SAAS,kBAAkB;AAC3B,SAAS,YAAY,UAAU;AAU/B,SAAS,WAAW;AAEpB,SAAS,wBAAwB;AASjC,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAsB,uBAAuB;AAC7C,SAAS,sBAAsB;AAsBxB,MAAM,0BAGX;AAAA,EACD,QAAiB,UAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,QAOC;AACD,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACtB,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AAAA,EACxB;AAAA,EAEA,KACC,QAMC;AACD,UAAM,kBAAkB,CAAC,CAAC,KAAK;AAE/B,QAAI;AACJ,QAAI,KAAK,QAAQ;AAChB,eAAS,KAAK;AAAA,IACf,WAAW,GAAG,QAAQ,QAAQ,GAAG;AAEhC,eAAS,OAAO;AAAA,QACf,OAAO,KAAK,OAAO,EAAE,cAAc,EAAE,IAAI,CACxC,QACI,CAAC,KAAK,OAAO,GAAqC,CAAsC,CAAC;AAAA,MAC/F;AAAA,IACD,WAAW,GAAG,QAAQ,cAAc,GAAG;AACtC,eAAS,OAAO,cAAc,EAAE;AAAA,IACjC,WAAW,GAAG,QAAQ,GAAG,GAAG;AAC3B,eAAS,CAAC;AAAA,IACX,OAAO;AACN,eAAS,gBAA6B,MAAM;AAAA,IAC7C;AAEA,WAAO;AAAA,MACN,IAAI,uBAAuB;AAAA,QAC1B,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA,SAAS,KAAK;AAAA,QACd,SAAS,KAAK;AAAA,QACd,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,MAChB,CAAC;AAAA,IACF;AAAA,EACD;AACD;AAiBO,MAAM,+BAUH,iBAWR;AAAA,EACD,QAA0B,UAAU,IAAY;AAAA;AAAA,EAGvC,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,MAAW,MAAM;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA;AAAA,EAGS,SAAc,MAAM;AAC5B,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACnE;AAAA;AAAA,EAGS,UAAiB;AACzB,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC7D;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,YAAsD,CAAC,sBAAgD;AACtG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,eAA4D,CAAC,sBAAgD;AAC5G,WAAO,KAAK,cAAc,EAAE,OAAO,iBAAiB;AAAA,EACrD;AAAA,EAEA,OAAO,mBAA6F;AACnG,WAAO,KAAK,cAAc,EAAE,IAAI,iBAAiB;AAAA,EAClD;AAAA,EAEA,gBAA0E;AACzE,WAAO,KAAK,SAAS;AAAA,EACtB;AACD;","names":[]}
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var session_exports = {};
20
+ __export(session_exports, {
21
+ EffectSQLitePreparedQuery: () => EffectSQLitePreparedQuery,
22
+ EffectSQLiteSession: () => EffectSQLiteSession
23
+ });
24
+ module.exports = __toCommonJS(session_exports);
25
+ var import_SqliteClient = require("@effect/sql-sqlite-node/SqliteClient");
26
+ var import_effect = require("effect");
27
+ var import_core = require("../../cache/core/index.cjs");
28
+ var import_entity = require("../../entity.cjs");
29
+ var import_logger = require("../../logger.cjs");
30
+ var import_sql = require("../../sql/sql.cjs");
31
+ var import_session = require("../../sqlite-core/session.cjs");
32
+ var import_utils = require("../../utils.cjs");
33
+ class EffectSQLiteSession extends import_session.SQLiteSession {
34
+ constructor(dialect, relations, schema, options) {
35
+ super(dialect);
36
+ this.relations = relations;
37
+ this.schema = schema;
38
+ this.options = options;
39
+ this.logger = this.options.logger ?? new import_logger.NoopLogger();
40
+ this.cache = new import_core.NoopCache();
41
+ }
42
+ static [import_entity.entityKind] = "EffectSQLiteSession";
43
+ logger;
44
+ cache;
45
+ prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
46
+ return new EffectSQLitePreparedQuery(
47
+ query,
48
+ this.logger,
49
+ this.cache,
50
+ queryMetadata,
51
+ cacheConfig,
52
+ fields,
53
+ executeMethod,
54
+ isResponseInArrayMode,
55
+ customResultMapper
56
+ );
57
+ }
58
+ prepareRelationalQuery(query, fields, executeMethod, customResultMapper) {
59
+ return new EffectSQLitePreparedQuery(
60
+ query,
61
+ this.logger,
62
+ this.cache,
63
+ void 0,
64
+ void 0,
65
+ fields,
66
+ executeMethod,
67
+ false,
68
+ customResultMapper,
69
+ true
70
+ );
71
+ }
72
+ effectRun(query) {
73
+ return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).run();
74
+ }
75
+ effectAll(query) {
76
+ return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).all();
77
+ }
78
+ effectGet(query) {
79
+ return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).get();
80
+ }
81
+ effectValues(query) {
82
+ return this.prepareOneTimeQuery(this.dialect.sqlToQuery(query), void 0, "run", false).values();
83
+ }
84
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
85
+ run = () => {
86
+ throw new Error("Use `.effectRun()` for `Effect` compatibility");
87
+ };
88
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
89
+ all = () => {
90
+ throw new Error("Use `.effectAll()` for `Effect` compatibility");
91
+ };
92
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
93
+ get = () => {
94
+ throw new Error("Use `.effectGet()` for `Effect` compatibility");
95
+ };
96
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
97
+ values = () => {
98
+ throw new Error("Use `.effectValues()` for `Effect` compatibility");
99
+ };
100
+ async batch(_queries) {
101
+ throw new Error("Not implemented!");
102
+ }
103
+ async migrate(_queries) {
104
+ throw new Error("Not implemented!");
105
+ }
106
+ transaction(_transaction, _config) {
107
+ throw new Error("Not implemented!");
108
+ }
109
+ extractRawAllValueFromBatchResult(result) {
110
+ return result.rows;
111
+ }
112
+ extractRawGetValueFromBatchResult(result) {
113
+ return result.rows[0];
114
+ }
115
+ extractRawValuesValueFromBatchResult(result) {
116
+ return result.rows;
117
+ }
118
+ }
119
+ class EffectSQLitePreparedQuery extends import_session.SQLitePreparedQuery {
120
+ constructor(query, logger, cache, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper, isRqbV2Query) {
121
+ super("sync", executeMethod, query, cache, queryMetadata, cacheConfig);
122
+ this.logger = logger;
123
+ this.fields = fields;
124
+ this._isResponseInArrayMode = _isResponseInArrayMode;
125
+ this.customResultMapper = customResultMapper;
126
+ this.isRqbV2Query = isRqbV2Query;
127
+ this.customResultMapper = customResultMapper;
128
+ this.fields = fields;
129
+ }
130
+ static [import_entity.entityKind] = "EffectSQLitePreparedQuery";
131
+ run(placeholderValues) {
132
+ const { query, logger } = this;
133
+ const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
134
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
135
+ logger.logQuery(query.sql, params);
136
+ return client.unsafe(query.sql, params);
137
+ });
138
+ }
139
+ all(placeholderValues) {
140
+ if (this.isRqbV2Query) return this.allRqbV2(placeholderValues);
141
+ const { query, logger, customResultMapper, fields, joinsNotNullableMap } = this;
142
+ const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
143
+ if (!fields && !customResultMapper) {
144
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
145
+ logger.logQuery(query.sql, params);
146
+ return client.unsafe(query.sql, params).withoutTransform;
147
+ });
148
+ }
149
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
150
+ logger.logQuery(query.sql, params);
151
+ return client.unsafe(query.sql, params).values;
152
+ }).pipe(import_effect.Effect.andThen(
153
+ (rows) => {
154
+ return rows.map(
155
+ (row) => (0, import_utils.mapResultRow)(
156
+ fields,
157
+ row,
158
+ joinsNotNullableMap
159
+ )
160
+ );
161
+ }
162
+ ));
163
+ }
164
+ allRqbV2(placeholderValues) {
165
+ const { query, logger, customResultMapper } = this;
166
+ const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
167
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
168
+ logger.logQuery(query.sql, params);
169
+ return client.unsafe(query.sql, params).withoutTransform;
170
+ }).pipe(import_effect.Effect.andThen(
171
+ (v) => customResultMapper(v)
172
+ ));
173
+ }
174
+ get(placeholderValues) {
175
+ if (this.isRqbV2Query) return this.getRqbV2(placeholderValues);
176
+ const { query, logger, customResultMapper, fields, joinsNotNullableMap } = this;
177
+ const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
178
+ if (!fields && !customResultMapper) {
179
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
180
+ logger.logQuery(query.sql, params);
181
+ return client.unsafe(query.sql, params).withoutTransform;
182
+ }).pipe(import_effect.Effect.andThen((v) => v[0]));
183
+ }
184
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
185
+ logger.logQuery(query.sql, params);
186
+ return client.unsafe(query.sql, params).values;
187
+ }).pipe(import_effect.Effect.andThen(
188
+ (v) => {
189
+ const row = v[0];
190
+ if (row === void 0) return row;
191
+ return (0, import_utils.mapResultRow)(
192
+ fields,
193
+ row,
194
+ joinsNotNullableMap
195
+ );
196
+ }
197
+ ));
198
+ }
199
+ getRqbV2(placeholderValues) {
200
+ const { query, logger, customResultMapper } = this;
201
+ const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
202
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
203
+ logger.logQuery(query.sql, params);
204
+ return client.unsafe(query.sql, params).withoutTransform;
205
+ }).pipe(import_effect.Effect.andThen(
206
+ (v) => {
207
+ const row = v[0];
208
+ if (row === void 0) return row;
209
+ return customResultMapper([row]);
210
+ }
211
+ ));
212
+ }
213
+ values(placeholderValues) {
214
+ const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
215
+ return import_effect.Effect.flatMap(import_SqliteClient.SqliteClient, (client) => {
216
+ this.logger.logQuery(this.query.sql, params);
217
+ return client.unsafe(this.query.sql, params).values;
218
+ });
219
+ }
220
+ effect(placeholderValues) {
221
+ return this[this.executeMethod](placeholderValues);
222
+ }
223
+ /** @deprecated Use `.effect()` for `Effect` compatibility */
224
+ execute(_placeholderValues) {
225
+ throw new Error("Use `.effect()` for `Effect` compatibility");
226
+ }
227
+ /** @internal */
228
+ isResponseInArrayMode() {
229
+ return this._isResponseInArrayMode;
230
+ }
231
+ }
232
+ // Annotate the CommonJS export names for ESM import in node:
233
+ 0 && (module.exports = {
234
+ EffectSQLitePreparedQuery,
235
+ EffectSQLiteSession
236
+ });
237
+ //# sourceMappingURL=session.cjs.map