drizzle-orm 0.39.2 → 0.40.0-262a7b0
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/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +6 -5
- package/column-builder.d.ts +6 -5
- package/column-builder.js.map +1 -1
- package/gel/driver.cjs +97 -0
- package/gel/driver.cjs.map +1 -0
- package/gel/driver.d.cts +38 -0
- package/gel/driver.d.ts +38 -0
- package/gel/driver.js +74 -0
- package/gel/driver.js.map +1 -0
- package/gel/index.cjs +25 -0
- package/gel/index.cjs.map +1 -0
- package/gel/index.d.cts +2 -0
- package/gel/index.d.ts +2 -0
- package/gel/index.js +3 -0
- package/gel/index.js.map +1 -0
- package/gel/migrator.cjs +5 -0
- package/gel/migrator.cjs.map +1 -0
- package/gel/migrator.d.cts +1 -0
- package/gel/migrator.d.ts +1 -0
- package/gel/migrator.js +4 -0
- package/gel/migrator.js.map +1 -0
- package/gel/session.cjs +139 -0
- package/gel/session.cjs.map +1 -0
- package/gel/session.d.cts +47 -0
- package/gel/session.d.ts +47 -0
- package/gel/session.js +113 -0
- package/gel/session.js.map +1 -0
- package/gel-core/alias.cjs +32 -0
- package/gel-core/alias.cjs.map +1 -0
- package/gel-core/alias.d.cts +4 -0
- package/gel-core/alias.d.ts +4 -0
- package/gel-core/alias.js +8 -0
- package/gel-core/alias.js.map +1 -0
- package/gel-core/checks.cjs +58 -0
- package/gel-core/checks.cjs.map +1 -0
- package/gel-core/checks.d.cts +18 -0
- package/gel-core/checks.d.ts +18 -0
- package/gel-core/checks.js +32 -0
- package/gel-core/checks.js.map +1 -0
- package/gel-core/columns/all.cjs +72 -0
- package/gel-core/columns/all.cjs.map +1 -0
- package/gel-core/columns/all.d.cts +43 -0
- package/gel-core/columns/all.d.ts +43 -0
- package/gel-core/columns/all.js +48 -0
- package/gel-core/columns/all.js.map +1 -0
- package/gel-core/columns/bigint.cjs +54 -0
- package/gel-core/columns/bigint.cjs.map +1 -0
- package/gel-core/columns/bigint.d.cts +23 -0
- package/gel-core/columns/bigint.d.ts +23 -0
- package/gel-core/columns/bigint.js +28 -0
- package/gel-core/columns/bigint.js.map +1 -0
- package/gel-core/columns/bigintT.cjs +60 -0
- package/gel-core/columns/bigintT.cjs.map +1 -0
- package/gel-core/columns/bigintT.d.cts +24 -0
- package/gel-core/columns/bigintT.d.ts +24 -0
- package/gel-core/columns/bigintT.js +34 -0
- package/gel-core/columns/bigintT.js.map +1 -0
- package/gel-core/columns/boolean.cjs +53 -0
- package/gel-core/columns/boolean.cjs.map +1 -0
- package/gel-core/columns/boolean.d.cts +22 -0
- package/gel-core/columns/boolean.d.ts +22 -0
- package/gel-core/columns/boolean.js +27 -0
- package/gel-core/columns/boolean.js.map +1 -0
- package/gel-core/columns/bytes.cjs +56 -0
- package/gel-core/columns/bytes.cjs.map +1 -0
- package/gel-core/columns/bytes.d.cts +22 -0
- package/gel-core/columns/bytes.d.ts +22 -0
- package/gel-core/columns/bytes.js +30 -0
- package/gel-core/columns/bytes.js.map +1 -0
- package/gel-core/columns/common.cjs +213 -0
- package/gel-core/columns/common.cjs.map +1 -0
- package/gel-core/columns/common.d.cts +147 -0
- package/gel-core/columns/common.d.ts +147 -0
- package/gel-core/columns/common.js +184 -0
- package/gel-core/columns/common.js.map +1 -0
- package/gel-core/columns/custom.cjs +77 -0
- package/gel-core/columns/custom.cjs.map +1 -0
- package/gel-core/columns/custom.d.cts +155 -0
- package/gel-core/columns/custom.d.ts +155 -0
- package/gel-core/columns/custom.js +51 -0
- package/gel-core/columns/custom.js.map +1 -0
- package/gel-core/columns/date-duration.cjs +56 -0
- package/gel-core/columns/date-duration.cjs.map +1 -0
- package/gel-core/columns/date-duration.d.cts +23 -0
- package/gel-core/columns/date-duration.d.ts +23 -0
- package/gel-core/columns/date-duration.js +30 -0
- package/gel-core/columns/date-duration.js.map +1 -0
- package/gel-core/columns/date.common.cjs +37 -0
- package/gel-core/columns/date.common.cjs.map +1 -0
- package/gel-core/columns/date.common.d.cts +7 -0
- package/gel-core/columns/date.common.d.ts +7 -0
- package/gel-core/columns/date.common.js +13 -0
- package/gel-core/columns/date.common.js.map +1 -0
- package/gel-core/columns/decimal.cjs +56 -0
- package/gel-core/columns/decimal.cjs.map +1 -0
- package/gel-core/columns/decimal.d.cts +26 -0
- package/gel-core/columns/decimal.d.ts +26 -0
- package/gel-core/columns/decimal.js +30 -0
- package/gel-core/columns/decimal.js.map +1 -0
- package/gel-core/columns/double-precision.cjs +62 -0
- package/gel-core/columns/double-precision.cjs.map +1 -0
- package/gel-core/columns/double-precision.d.cts +23 -0
- package/gel-core/columns/double-precision.d.ts +23 -0
- package/gel-core/columns/double-precision.js +36 -0
- package/gel-core/columns/double-precision.js.map +1 -0
- package/gel-core/columns/duration.cjs +53 -0
- package/gel-core/columns/duration.cjs.map +1 -0
- package/gel-core/columns/duration.d.cts +23 -0
- package/gel-core/columns/duration.d.ts +23 -0
- package/gel-core/columns/duration.js +27 -0
- package/gel-core/columns/duration.js.map +1 -0
- package/gel-core/columns/index.cjs +65 -0
- package/gel-core/columns/index.cjs.map +1 -0
- package/gel-core/columns/index.d.cts +22 -0
- package/gel-core/columns/index.d.ts +22 -0
- package/gel-core/columns/index.js +23 -0
- package/gel-core/columns/index.js.map +1 -0
- package/gel-core/columns/int.common.cjs +67 -0
- package/gel-core/columns/int.common.cjs.map +1 -0
- package/gel-core/columns/int.common.d.cts +15 -0
- package/gel-core/columns/int.common.d.ts +15 -0
- package/gel-core/columns/int.common.js +43 -0
- package/gel-core/columns/int.common.js.map +1 -0
- package/gel-core/columns/integer.cjs +54 -0
- package/gel-core/columns/integer.cjs.map +1 -0
- package/gel-core/columns/integer.d.cts +23 -0
- package/gel-core/columns/integer.d.ts +23 -0
- package/gel-core/columns/integer.js +28 -0
- package/gel-core/columns/integer.js.map +1 -0
- package/gel-core/columns/json.cjs +56 -0
- package/gel-core/columns/json.cjs.map +1 -0
- package/gel-core/columns/json.d.cts +26 -0
- package/gel-core/columns/json.d.ts +26 -0
- package/gel-core/columns/json.js +30 -0
- package/gel-core/columns/json.js.map +1 -0
- package/gel-core/columns/localdate.cjs +57 -0
- package/gel-core/columns/localdate.cjs.map +1 -0
- package/gel-core/columns/localdate.d.cts +24 -0
- package/gel-core/columns/localdate.d.ts +24 -0
- package/gel-core/columns/localdate.js +31 -0
- package/gel-core/columns/localdate.js.map +1 -0
- package/gel-core/columns/localtime.cjs +57 -0
- package/gel-core/columns/localtime.cjs.map +1 -0
- package/gel-core/columns/localtime.d.cts +24 -0
- package/gel-core/columns/localtime.d.ts +24 -0
- package/gel-core/columns/localtime.js +31 -0
- package/gel-core/columns/localtime.js.map +1 -0
- package/gel-core/columns/real.cjs +57 -0
- package/gel-core/columns/real.cjs.map +1 -0
- package/gel-core/columns/real.d.cts +28 -0
- package/gel-core/columns/real.d.ts +28 -0
- package/gel-core/columns/real.js +31 -0
- package/gel-core/columns/real.js.map +1 -0
- package/gel-core/columns/relative-duration.cjs +56 -0
- package/gel-core/columns/relative-duration.cjs.map +1 -0
- package/gel-core/columns/relative-duration.d.cts +23 -0
- package/gel-core/columns/relative-duration.d.ts +23 -0
- package/gel-core/columns/relative-duration.js +30 -0
- package/gel-core/columns/relative-duration.js.map +1 -0
- package/gel-core/columns/smallint.cjs +54 -0
- package/gel-core/columns/smallint.cjs.map +1 -0
- package/gel-core/columns/smallint.d.cts +23 -0
- package/gel-core/columns/smallint.d.ts +23 -0
- package/gel-core/columns/smallint.js +28 -0
- package/gel-core/columns/smallint.js.map +1 -0
- package/gel-core/columns/text.cjs +54 -0
- package/gel-core/columns/text.cjs.map +1 -0
- package/gel-core/columns/text.d.cts +26 -0
- package/gel-core/columns/text.d.ts +26 -0
- package/gel-core/columns/text.js +28 -0
- package/gel-core/columns/text.js.map +1 -0
- package/gel-core/columns/timestamp.cjs +60 -0
- package/gel-core/columns/timestamp.cjs.map +1 -0
- package/gel-core/columns/timestamp.d.cts +28 -0
- package/gel-core/columns/timestamp.d.ts +28 -0
- package/gel-core/columns/timestamp.js +34 -0
- package/gel-core/columns/timestamp.js.map +1 -0
- package/gel-core/columns/timestamptz.cjs +60 -0
- package/gel-core/columns/timestamptz.cjs.map +1 -0
- package/gel-core/columns/timestamptz.d.cts +27 -0
- package/gel-core/columns/timestamptz.d.ts +27 -0
- package/gel-core/columns/timestamptz.js +34 -0
- package/gel-core/columns/timestamptz.js.map +1 -0
- package/gel-core/columns/uuid.cjs +53 -0
- package/gel-core/columns/uuid.cjs.map +1 -0
- package/gel-core/columns/uuid.d.cts +22 -0
- package/gel-core/columns/uuid.d.ts +22 -0
- package/gel-core/columns/uuid.js +27 -0
- package/gel-core/columns/uuid.js.map +1 -0
- package/gel-core/db.cjs +338 -0
- package/gel-core/db.cjs.map +1 -0
- package/gel-core/db.d.cts +281 -0
- package/gel-core/db.d.ts +281 -0
- package/gel-core/db.js +319 -0
- package/gel-core/db.js.map +1 -0
- package/gel-core/dialect.cjs +1142 -0
- package/gel-core/dialect.cjs.map +1 -0
- package/gel-core/dialect.d.cts +62 -0
- package/gel-core/dialect.d.ts +62 -0
- package/gel-core/dialect.js +1128 -0
- package/gel-core/dialect.js.map +1 -0
- package/gel-core/expressions.cjs +49 -0
- package/gel-core/expressions.cjs.map +1 -0
- package/gel-core/expressions.d.cts +8 -0
- package/gel-core/expressions.d.ts +8 -0
- package/gel-core/expressions.js +22 -0
- package/gel-core/expressions.js.map +1 -0
- package/gel-core/foreign-keys.cjs +100 -0
- package/gel-core/foreign-keys.cjs.map +1 -0
- package/gel-core/foreign-keys.d.cts +48 -0
- package/gel-core/foreign-keys.d.ts +48 -0
- package/gel-core/foreign-keys.js +74 -0
- package/gel-core/foreign-keys.js.map +1 -0
- package/gel-core/index.cjs +61 -0
- package/gel-core/index.cjs.map +1 -0
- package/gel-core/index.d.cts +20 -0
- package/gel-core/index.d.ts +20 -0
- package/gel-core/index.js +21 -0
- package/gel-core/index.js.map +1 -0
- package/gel-core/indexes.cjs +149 -0
- package/gel-core/indexes.cjs.map +1 -0
- package/gel-core/indexes.d.cts +79 -0
- package/gel-core/indexes.d.ts +79 -0
- package/gel-core/indexes.js +121 -0
- package/gel-core/indexes.js.map +1 -0
- package/gel-core/policies.cjs +58 -0
- package/gel-core/policies.cjs.map +1 -0
- package/gel-core/policies.d.cts +24 -0
- package/gel-core/policies.d.ts +24 -0
- package/gel-core/policies.js +33 -0
- package/gel-core/policies.js.map +1 -0
- package/gel-core/primary-keys.cjs +68 -0
- package/gel-core/primary-keys.cjs.map +1 -0
- package/gel-core/primary-keys.d.cts +30 -0
- package/gel-core/primary-keys.d.ts +30 -0
- package/gel-core/primary-keys.js +42 -0
- package/gel-core/primary-keys.js.map +1 -0
- package/gel-core/query-builders/count.cjs +73 -0
- package/gel-core/query-builders/count.cjs.map +1 -0
- package/gel-core/query-builders/count.d.cts +25 -0
- package/gel-core/query-builders/count.d.ts +25 -0
- package/gel-core/query-builders/count.js +49 -0
- package/gel-core/query-builders/count.js.map +1 -0
- package/gel-core/query-builders/delete.cjs +105 -0
- package/gel-core/query-builders/delete.cjs.map +1 -0
- package/gel-core/query-builders/delete.d.cts +99 -0
- package/gel-core/query-builders/delete.d.ts +99 -0
- package/gel-core/query-builders/delete.js +81 -0
- package/gel-core/query-builders/delete.js.map +1 -0
- package/gel-core/query-builders/index.cjs +35 -0
- package/gel-core/query-builders/index.cjs.map +1 -0
- package/gel-core/query-builders/index.d.cts +7 -0
- package/gel-core/query-builders/index.d.ts +7 -0
- package/gel-core/query-builders/index.js +8 -0
- package/gel-core/query-builders/index.js.map +1 -0
- package/gel-core/query-builders/insert.cjs +218 -0
- package/gel-core/query-builders/insert.cjs.map +1 -0
- package/gel-core/query-builders/insert.d.cts +116 -0
- package/gel-core/query-builders/insert.d.ts +116 -0
- package/gel-core/query-builders/insert.js +193 -0
- package/gel-core/query-builders/insert.js.map +1 -0
- package/gel-core/query-builders/query-builder.cjs +114 -0
- package/gel-core/query-builders/query-builder.cjs.map +1 -0
- package/gel-core/query-builders/query-builder.d.cts +40 -0
- package/gel-core/query-builders/query-builder.d.ts +40 -0
- package/gel-core/query-builders/query-builder.js +90 -0
- package/gel-core/query-builders/query-builder.js.map +1 -0
- package/gel-core/query-builders/query.cjs +139 -0
- package/gel-core/query-builders/query.cjs.map +1 -0
- package/gel-core/query-builders/query.d.cts +46 -0
- package/gel-core/query-builders/query.d.ts +46 -0
- package/gel-core/query-builders/query.js +116 -0
- package/gel-core/query-builders/query.js.map +1 -0
- package/gel-core/query-builders/raw.cjs +57 -0
- package/gel-core/query-builders/raw.cjs.map +1 -0
- package/gel-core/query-builders/raw.d.cts +22 -0
- package/gel-core/query-builders/raw.d.ts +22 -0
- package/gel-core/query-builders/raw.js +33 -0
- package/gel-core/query-builders/raw.js.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs +77 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.d.cts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.d.ts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.js +53 -0
- package/gel-core/query-builders/refresh-materialized-view.js.map +1 -0
- package/gel-core/query-builders/select.cjs +775 -0
- package/gel-core/query-builders/select.cjs.map +1 -0
- package/gel-core/query-builders/select.d.cts +721 -0
- package/gel-core/query-builders/select.d.ts +721 -0
- package/gel-core/query-builders/select.js +748 -0
- package/gel-core/query-builders/select.js.map +1 -0
- package/gel-core/query-builders/select.types.cjs +17 -0
- package/gel-core/query-builders/select.types.cjs.map +1 -0
- package/gel-core/query-builders/select.types.d.cts +138 -0
- package/gel-core/query-builders/select.types.d.ts +138 -0
- package/gel-core/query-builders/select.types.js +1 -0
- package/gel-core/query-builders/select.types.js.map +1 -0
- package/gel-core/query-builders/update.cjs +226 -0
- package/gel-core/query-builders/update.cjs.map +1 -0
- package/gel-core/query-builders/update.d.cts +166 -0
- package/gel-core/query-builders/update.d.ts +166 -0
- package/gel-core/query-builders/update.js +205 -0
- package/gel-core/query-builders/update.js.map +1 -0
- package/gel-core/roles.cjs +57 -0
- package/gel-core/roles.cjs.map +1 -0
- package/gel-core/roles.d.cts +13 -0
- package/gel-core/roles.d.ts +13 -0
- package/gel-core/roles.js +32 -0
- package/gel-core/roles.js.map +1 -0
- package/gel-core/schema.cjs +74 -0
- package/gel-core/schema.cjs.map +1 -0
- package/gel-core/schema.d.cts +15 -0
- package/gel-core/schema.d.ts +15 -0
- package/gel-core/schema.js +48 -0
- package/gel-core/schema.js.map +1 -0
- package/gel-core/sequence.cjs +52 -0
- package/gel-core/sequence.cjs.map +1 -0
- package/gel-core/sequence.d.cts +18 -0
- package/gel-core/sequence.d.ts +18 -0
- package/gel-core/sequence.js +25 -0
- package/gel-core/sequence.js.map +1 -0
- package/gel-core/session.cjs +94 -0
- package/gel-core/session.cjs.map +1 -0
- package/gel-core/session.d.cts +56 -0
- package/gel-core/session.d.ts +56 -0
- package/gel-core/session.js +68 -0
- package/gel-core/session.js.map +1 -0
- package/gel-core/subquery.cjs +17 -0
- package/gel-core/subquery.cjs.map +1 -0
- package/gel-core/subquery.d.cts +5 -0
- package/gel-core/subquery.d.ts +5 -0
- package/gel-core/subquery.js +1 -0
- package/gel-core/subquery.js.map +1 -0
- package/gel-core/table.cjs +100 -0
- package/gel-core/table.cjs.map +1 -0
- package/gel-core/table.d.cts +95 -0
- package/gel-core/table.d.ts +95 -0
- package/gel-core/table.js +71 -0
- package/gel-core/table.js.map +1 -0
- package/gel-core/unique-constraint.cjs +89 -0
- package/gel-core/unique-constraint.cjs.map +1 -0
- package/gel-core/unique-constraint.d.cts +25 -0
- package/gel-core/unique-constraint.d.ts +25 -0
- package/gel-core/unique-constraint.js +61 -0
- package/gel-core/unique-constraint.js.map +1 -0
- package/gel-core/utils.cjs +100 -0
- package/gel-core/utils.cjs.map +1 -0
- package/gel-core/utils.d.cts +51 -0
- package/gel-core/utils.d.ts +51 -0
- package/gel-core/utils.js +74 -0
- package/gel-core/utils.js.map +1 -0
- package/gel-core/view-base.cjs +33 -0
- package/gel-core/view-base.cjs.map +1 -0
- package/gel-core/view-base.d.cts +8 -0
- package/gel-core/view-base.d.ts +8 -0
- package/gel-core/view-base.js +9 -0
- package/gel-core/view-base.js.map +1 -0
- package/gel-core/view-common.cjs +29 -0
- package/gel-core/view-common.cjs.map +1 -0
- package/gel-core/view-common.d.cts +1 -0
- package/gel-core/view-common.d.ts +1 -0
- package/gel-core/view-common.js +5 -0
- package/gel-core/view-common.js.map +1 -0
- package/gel-core/view.cjs +302 -0
- package/gel-core/view.cjs.map +1 -0
- package/gel-core/view.d.cts +150 -0
- package/gel-core/view.d.ts +150 -0
- package/gel-core/view.js +268 -0
- package/gel-core/view.js.map +1 -0
- package/package.json +1062 -325
- package/pg-core/table.cjs +2 -0
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.js +2 -0
- package/pg-core/table.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/gel/session.cjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
GelDbPreparedQuery: () => GelDbPreparedQuery,
|
|
22
|
+
GelDbSession: () => GelDbSession,
|
|
23
|
+
GelDbTransaction: () => GelDbTransaction
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(session_exports);
|
|
26
|
+
var import_entity = require("../entity.cjs");
|
|
27
|
+
var import_session = require("../gel-core/session.cjs");
|
|
28
|
+
var import_logger = require("../logger.cjs");
|
|
29
|
+
var import_sql = require("../sql/sql.cjs");
|
|
30
|
+
var import_tracing = require("../tracing.cjs");
|
|
31
|
+
var import_utils = require("../utils.cjs");
|
|
32
|
+
class GelDbPreparedQuery extends import_session.GelPreparedQuery {
|
|
33
|
+
constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper, transaction = false) {
|
|
34
|
+
super({ sql: queryString, params });
|
|
35
|
+
this.client = client;
|
|
36
|
+
this.queryString = queryString;
|
|
37
|
+
this.params = params;
|
|
38
|
+
this.logger = logger;
|
|
39
|
+
this.fields = fields;
|
|
40
|
+
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
41
|
+
this.customResultMapper = customResultMapper;
|
|
42
|
+
this.transaction = transaction;
|
|
43
|
+
}
|
|
44
|
+
static [import_entity.entityKind] = "GelPreparedQuery";
|
|
45
|
+
async execute(placeholderValues = {}) {
|
|
46
|
+
return import_tracing.tracer.startActiveSpan("drizzle.execute", async () => {
|
|
47
|
+
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
48
|
+
this.logger.logQuery(this.queryString, params);
|
|
49
|
+
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
|
|
50
|
+
if (!fields && !customResultMapper) {
|
|
51
|
+
return import_tracing.tracer.startActiveSpan("drizzle.driver.execute", async (span) => {
|
|
52
|
+
span?.setAttributes({
|
|
53
|
+
"drizzle.query.text": query,
|
|
54
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
55
|
+
});
|
|
56
|
+
return client.querySQL(query, params.length ? params : void 0);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const result = await import_tracing.tracer.startActiveSpan("drizzle.driver.execute", (span) => {
|
|
60
|
+
span?.setAttributes({
|
|
61
|
+
"drizzle.query.text": query,
|
|
62
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
63
|
+
});
|
|
64
|
+
return client.withSQLRowMode("array").querySQL(query, params.length ? params : void 0);
|
|
65
|
+
});
|
|
66
|
+
return import_tracing.tracer.startActiveSpan("drizzle.mapResponse", () => {
|
|
67
|
+
return customResultMapper ? customResultMapper(result) : result.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
all(placeholderValues = {}) {
|
|
72
|
+
return import_tracing.tracer.startActiveSpan("drizzle.execute", () => {
|
|
73
|
+
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
74
|
+
this.logger.logQuery(this.queryString, params);
|
|
75
|
+
return import_tracing.tracer.startActiveSpan("drizzle.driver.execute", (span) => {
|
|
76
|
+
span?.setAttributes({
|
|
77
|
+
"drizzle.query.text": this.queryString,
|
|
78
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
79
|
+
});
|
|
80
|
+
return this.client.withSQLRowMode("array").querySQL(this.queryString, params.length ? params : void 0).then((result) => result);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** @internal */
|
|
85
|
+
isResponseInArrayMode() {
|
|
86
|
+
return this._isResponseInArrayMode;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class GelDbSession extends import_session.GelSession {
|
|
90
|
+
constructor(client, dialect, schema, options = {}) {
|
|
91
|
+
super(dialect);
|
|
92
|
+
this.client = client;
|
|
93
|
+
this.schema = schema;
|
|
94
|
+
this.options = options;
|
|
95
|
+
this.logger = options.logger ?? new import_logger.NoopLogger();
|
|
96
|
+
}
|
|
97
|
+
static [import_entity.entityKind] = "GelDbSession";
|
|
98
|
+
logger;
|
|
99
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
|
100
|
+
return new GelDbPreparedQuery(
|
|
101
|
+
this.client,
|
|
102
|
+
query.sql,
|
|
103
|
+
query.params,
|
|
104
|
+
this.logger,
|
|
105
|
+
fields,
|
|
106
|
+
isResponseInArrayMode,
|
|
107
|
+
customResultMapper
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
async transaction(transaction) {
|
|
111
|
+
return await this.client.transaction(async (clientTx) => {
|
|
112
|
+
const session = new GelDbSession(clientTx, this.dialect, this.schema, this.options);
|
|
113
|
+
const tx = new GelDbTransaction(this.dialect, session, this.schema);
|
|
114
|
+
return await transaction(tx);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async count(sql) {
|
|
118
|
+
const res = await this.execute(sql);
|
|
119
|
+
return Number(res[0]["count"]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
class GelDbTransaction extends import_session.GelTransaction {
|
|
123
|
+
static [import_entity.entityKind] = "GelDbTransaction";
|
|
124
|
+
async transaction(transaction) {
|
|
125
|
+
const tx = new GelDbTransaction(
|
|
126
|
+
this.dialect,
|
|
127
|
+
this.session,
|
|
128
|
+
this.schema
|
|
129
|
+
);
|
|
130
|
+
return await transaction(tx);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
GelDbPreparedQuery,
|
|
136
|
+
GelDbSession,
|
|
137
|
+
GelDbTransaction
|
|
138
|
+
});
|
|
139
|
+
//# sourceMappingURL=session.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel/session.ts"],"sourcesContent":["import type { Client } from 'gel';\nimport type { Transaction } from 'gel/dist/transaction';\nimport { entityKind } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/gel-core/query-builders/select.types.ts';\nimport { GelPreparedQuery, GelSession, GelTransaction, type PreparedQueryConfig } from '~/gel-core/session.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL } from '~/sql/sql.ts';\nimport { tracer } from '~/tracing.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type GelClient = Client | Transaction;\n\nexport class GelDbPreparedQuery<T extends PreparedQueryConfig> extends GelPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'GelPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: GelClient,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tprivate transaction: boolean = false,\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\treturn tracer.startActiveSpan('drizzle.execute', async () => {\n\t\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\t\tthis.logger.logQuery(this.queryString, params);\n\t\t\tconst { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;\n\t\t\tif (!fields && !customResultMapper) {\n\t\t\t\treturn tracer.startActiveSpan('drizzle.driver.execute', async (span) => {\n\t\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t\t'drizzle.query.text': query,\n\t\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t\t});\n\n\t\t\t\t\treturn client.querySQL(query, params.length ? params : undefined);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = (await tracer.startActiveSpan('drizzle.driver.execute', (span) => {\n\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t'drizzle.query.text': query,\n\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t});\n\n\t\t\t\treturn client.withSQLRowMode('array').querySQL(query, params.length ? params : undefined);\n\t\t\t})) as unknown[][];\n\n\t\t\treturn tracer.startActiveSpan('drizzle.mapResponse', () => {\n\t\t\t\treturn customResultMapper\n\t\t\t\t\t? customResultMapper(result)\n\t\t\t\t\t: result.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t\t\t});\n\t\t});\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\treturn tracer.startActiveSpan('drizzle.execute', () => {\n\t\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\t\tthis.logger.logQuery(this.queryString, params);\n\t\t\treturn tracer.startActiveSpan('drizzle.driver.execute', (span) => {\n\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t'drizzle.query.text': this.queryString,\n\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t});\n\t\t\t\treturn this.client.withSQLRowMode('array').querySQL(this.queryString, params.length ? params : undefined).then((\n\t\t\t\t\tresult,\n\t\t\t\t) => result);\n\t\t\t});\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface GelSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class GelDbSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends GelSession<GelQueryResultHKT, TFullSchema, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'GelDbSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: GelClient,\n\t\tdialect: GelDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: GelSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): GelDbPreparedQuery<T> {\n\t\treturn new GelDbPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn await (this.client as Client).transaction(async (clientTx) => {\n\t\t\tconst session = new GelDbSession(clientTx, this.dialect, this.schema, this.options);\n\t\t\tconst tx = new GelDbTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\t\treturn await transaction(tx);\n\t\t});\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[{ count: string }]>(sql);\n\t\treturn Number(res[0]['count']);\n\t}\n}\n\nexport class GelDbTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'GelDbTransaction';\n\n\toverride async transaction<T>(transaction: (tx: GelDbTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tconst tx = new GelDbTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t);\n\t\treturn await transaction(tx);\n\t}\n}\n\n// TODO fix this\nexport interface GelQueryResultHKT {\n\treadonly $brand: 'GelQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAG3B,qBAAuF;AACvF,oBAAwC;AAExC,iBAAuD;AACvD,qBAAuB;AACvB,mBAA6B;AAItB,MAAM,2BAA0D,gCAAoB;AAAA,EAG1F,YACS,QACA,aACA,QACA,QACA,QACA,wBACA,oBACA,cAAuB,OAC9B;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAT1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAGT;AAAA,EAbA,QAA0B,wBAAU,IAAY;AAAA,EAehD,MAAM,QAAQ,oBAAyD,CAAC,GAA0B;AACjG,WAAO,sBAAO,gBAAgB,mBAAmB,YAAY;AAC5D,YAAM,aAAS,6BAAiB,KAAK,QAAQ,iBAAiB;AAE9D,WAAK,OAAO,SAAS,KAAK,aAAa,MAAM;AAC7C,YAAM,EAAE,QAAQ,aAAa,OAAO,QAAQ,qBAAqB,mBAAmB,IAAI;AACxF,UAAI,CAAC,UAAU,CAAC,oBAAoB;AACnC,eAAO,sBAAO,gBAAgB,0BAA0B,OAAO,SAAS;AACvE,gBAAM,cAAc;AAAA,YACnB,sBAAsB;AAAA,YACtB,wBAAwB,KAAK,UAAU,MAAM;AAAA,UAC9C,CAAC;AAED,iBAAO,OAAO,SAAS,OAAO,OAAO,SAAS,SAAS,MAAS;AAAA,QACjE,CAAC;AAAA,MACF;AAEA,YAAM,SAAU,MAAM,sBAAO,gBAAgB,0BAA0B,CAAC,SAAS;AAChF,cAAM,cAAc;AAAA,UACnB,sBAAsB;AAAA,UACtB,wBAAwB,KAAK,UAAU,MAAM;AAAA,QAC9C,CAAC;AAED,eAAO,OAAO,eAAe,OAAO,EAAE,SAAS,OAAO,OAAO,SAAS,SAAS,MAAS;AAAA,MACzF,CAAC;AAED,aAAO,sBAAO,gBAAgB,uBAAuB,MAAM;AAC1D,eAAO,qBACJ,mBAAmB,MAAM,IACzB,OAAO,IAAI,CAAC,YAAQ,2BAA2B,QAAS,KAAK,mBAAmB,CAAC;AAAA,MACrF,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA,EAEA,IAAI,oBAAyD,CAAC,GAAsB;AACnF,WAAO,sBAAO,gBAAgB,mBAAmB,MAAM;AACtD,YAAM,aAAS,6BAAiB,KAAK,QAAQ,iBAAiB;AAC9D,WAAK,OAAO,SAAS,KAAK,aAAa,MAAM;AAC7C,aAAO,sBAAO,gBAAgB,0BAA0B,CAAC,SAAS;AACjE,cAAM,cAAc;AAAA,UACnB,sBAAsB,KAAK;AAAA,UAC3B,wBAAwB,KAAK,UAAU,MAAM;AAAA,QAC9C,CAAC;AACD,eAAO,KAAK,OAAO,eAAe,OAAO,EAAE,SAAS,KAAK,aAAa,OAAO,SAAS,SAAS,MAAS,EAAE,KAAK,CAC9G,WACI,MAAM;AAAA,MACZ,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AAAA;AAAA,EAGA,wBAAiC;AAChC,WAAO,KAAK;AAAA,EACb;AACD;AAMO,MAAM,qBACJ,0BACT;AAAA,EAKC,YACS,QACR,SACQ,QACA,UAA6B,CAAC,GACrC;AACD,UAAM,OAAO;AALL;AAEA;AACA;AAGR,SAAK,SAAS,QAAQ,UAAU,IAAI,yBAAW;AAAA,EAChD;AAAA,EAZA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA,EAYR,aACC,OACA,QACA,MACA,uBACA,oBACwB;AACxB,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAe,YACd,aACa;AACb,WAAO,MAAO,KAAK,OAAkB,YAAY,OAAO,aAAa;AACpE,YAAM,UAAU,IAAI,aAAa,UAAU,KAAK,SAAS,KAAK,QAAQ,KAAK,OAAO;AAClF,YAAM,KAAK,IAAI,iBAAuC,KAAK,SAAS,SAAS,KAAK,MAAM;AACxF,aAAO,MAAM,YAAY,EAAE;AAAA,IAC5B,CAAC;AAAA,EACF;AAAA,EAEA,MAAe,MAAM,KAA2B;AAC/C,UAAM,MAAM,MAAM,KAAK,QAA6B,GAAG;AACvD,WAAO,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;AAAA,EAC9B;AACD;AAEO,MAAM,yBACJ,8BACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,MAAe,YAAe,aAAqF;AAClH,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AACA,WAAO,MAAM,YAAY,EAAE;AAAA,EAC5B;AACD;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Client } from 'gel';
|
|
2
|
+
import type { Transaction } from 'gel/dist/transaction';
|
|
3
|
+
import { entityKind } from "../entity.cjs";
|
|
4
|
+
import type { GelDialect } from "../gel-core/dialect.cjs";
|
|
5
|
+
import type { SelectedFieldsOrdered } from "../gel-core/query-builders/select.types.cjs";
|
|
6
|
+
import { GelPreparedQuery, GelSession, GelTransaction, type PreparedQueryConfig } from "../gel-core/session.cjs";
|
|
7
|
+
import { type Logger } from "../logger.cjs";
|
|
8
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
9
|
+
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
10
|
+
export type GelClient = Client | Transaction;
|
|
11
|
+
export declare class GelDbPreparedQuery<T extends PreparedQueryConfig> extends GelPreparedQuery<T> {
|
|
12
|
+
private client;
|
|
13
|
+
private queryString;
|
|
14
|
+
private params;
|
|
15
|
+
private logger;
|
|
16
|
+
private fields;
|
|
17
|
+
private _isResponseInArrayMode;
|
|
18
|
+
private customResultMapper?;
|
|
19
|
+
private transaction;
|
|
20
|
+
static readonly [entityKind]: string;
|
|
21
|
+
constructor(client: GelClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined, transaction?: boolean);
|
|
22
|
+
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
23
|
+
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
24
|
+
}
|
|
25
|
+
export interface GelSessionOptions {
|
|
26
|
+
logger?: Logger;
|
|
27
|
+
}
|
|
28
|
+
export declare class GelDbSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends GelSession<GelQueryResultHKT, TFullSchema, TSchema> {
|
|
29
|
+
private client;
|
|
30
|
+
private schema;
|
|
31
|
+
private options;
|
|
32
|
+
static readonly [entityKind]: string;
|
|
33
|
+
private logger;
|
|
34
|
+
constructor(client: GelClient, dialect: GelDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: GelSessionOptions);
|
|
35
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): GelDbPreparedQuery<T>;
|
|
36
|
+
transaction<T>(transaction: (tx: GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
37
|
+
count(sql: SQL): Promise<number>;
|
|
38
|
+
}
|
|
39
|
+
export declare class GelDbTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends GelTransaction<GelQueryResultHKT, TFullSchema, TSchema> {
|
|
40
|
+
static readonly [entityKind]: string;
|
|
41
|
+
transaction<T>(transaction: (tx: GelDbTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
42
|
+
}
|
|
43
|
+
export interface GelQueryResultHKT {
|
|
44
|
+
readonly $brand: 'GelQueryResultHKT';
|
|
45
|
+
readonly row: unknown;
|
|
46
|
+
readonly type: unknown;
|
|
47
|
+
}
|
package/gel/session.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Client } from 'gel';
|
|
2
|
+
import type { Transaction } from 'gel/dist/transaction';
|
|
3
|
+
import { entityKind } from "../entity.js";
|
|
4
|
+
import type { GelDialect } from "../gel-core/dialect.js";
|
|
5
|
+
import type { SelectedFieldsOrdered } from "../gel-core/query-builders/select.types.js";
|
|
6
|
+
import { GelPreparedQuery, GelSession, GelTransaction, type PreparedQueryConfig } from "../gel-core/session.js";
|
|
7
|
+
import { type Logger } from "../logger.js";
|
|
8
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
9
|
+
import { type Query, type SQL } from "../sql/sql.js";
|
|
10
|
+
export type GelClient = Client | Transaction;
|
|
11
|
+
export declare class GelDbPreparedQuery<T extends PreparedQueryConfig> extends GelPreparedQuery<T> {
|
|
12
|
+
private client;
|
|
13
|
+
private queryString;
|
|
14
|
+
private params;
|
|
15
|
+
private logger;
|
|
16
|
+
private fields;
|
|
17
|
+
private _isResponseInArrayMode;
|
|
18
|
+
private customResultMapper?;
|
|
19
|
+
private transaction;
|
|
20
|
+
static readonly [entityKind]: string;
|
|
21
|
+
constructor(client: GelClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined, transaction?: boolean);
|
|
22
|
+
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
23
|
+
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
24
|
+
}
|
|
25
|
+
export interface GelSessionOptions {
|
|
26
|
+
logger?: Logger;
|
|
27
|
+
}
|
|
28
|
+
export declare class GelDbSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends GelSession<GelQueryResultHKT, TFullSchema, TSchema> {
|
|
29
|
+
private client;
|
|
30
|
+
private schema;
|
|
31
|
+
private options;
|
|
32
|
+
static readonly [entityKind]: string;
|
|
33
|
+
private logger;
|
|
34
|
+
constructor(client: GelClient, dialect: GelDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: GelSessionOptions);
|
|
35
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): GelDbPreparedQuery<T>;
|
|
36
|
+
transaction<T>(transaction: (tx: GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
37
|
+
count(sql: SQL): Promise<number>;
|
|
38
|
+
}
|
|
39
|
+
export declare class GelDbTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends GelTransaction<GelQueryResultHKT, TFullSchema, TSchema> {
|
|
40
|
+
static readonly [entityKind]: string;
|
|
41
|
+
transaction<T>(transaction: (tx: GelDbTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
42
|
+
}
|
|
43
|
+
export interface GelQueryResultHKT {
|
|
44
|
+
readonly $brand: 'GelQueryResultHKT';
|
|
45
|
+
readonly row: unknown;
|
|
46
|
+
readonly type: unknown;
|
|
47
|
+
}
|
package/gel/session.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
2
|
+
import { GelPreparedQuery, GelSession, GelTransaction } from "../gel-core/session.js";
|
|
3
|
+
import { NoopLogger } from "../logger.js";
|
|
4
|
+
import { fillPlaceholders } from "../sql/sql.js";
|
|
5
|
+
import { tracer } from "../tracing.js";
|
|
6
|
+
import { mapResultRow } from "../utils.js";
|
|
7
|
+
class GelDbPreparedQuery extends GelPreparedQuery {
|
|
8
|
+
constructor(client, queryString, params, logger, fields, _isResponseInArrayMode, customResultMapper, transaction = false) {
|
|
9
|
+
super({ sql: queryString, params });
|
|
10
|
+
this.client = client;
|
|
11
|
+
this.queryString = queryString;
|
|
12
|
+
this.params = params;
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
this.fields = fields;
|
|
15
|
+
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
16
|
+
this.customResultMapper = customResultMapper;
|
|
17
|
+
this.transaction = transaction;
|
|
18
|
+
}
|
|
19
|
+
static [entityKind] = "GelPreparedQuery";
|
|
20
|
+
async execute(placeholderValues = {}) {
|
|
21
|
+
return tracer.startActiveSpan("drizzle.execute", async () => {
|
|
22
|
+
const params = fillPlaceholders(this.params, placeholderValues);
|
|
23
|
+
this.logger.logQuery(this.queryString, params);
|
|
24
|
+
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
|
|
25
|
+
if (!fields && !customResultMapper) {
|
|
26
|
+
return tracer.startActiveSpan("drizzle.driver.execute", async (span) => {
|
|
27
|
+
span?.setAttributes({
|
|
28
|
+
"drizzle.query.text": query,
|
|
29
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
30
|
+
});
|
|
31
|
+
return client.querySQL(query, params.length ? params : void 0);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const result = await tracer.startActiveSpan("drizzle.driver.execute", (span) => {
|
|
35
|
+
span?.setAttributes({
|
|
36
|
+
"drizzle.query.text": query,
|
|
37
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
38
|
+
});
|
|
39
|
+
return client.withSQLRowMode("array").querySQL(query, params.length ? params : void 0);
|
|
40
|
+
});
|
|
41
|
+
return tracer.startActiveSpan("drizzle.mapResponse", () => {
|
|
42
|
+
return customResultMapper ? customResultMapper(result) : result.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
all(placeholderValues = {}) {
|
|
47
|
+
return tracer.startActiveSpan("drizzle.execute", () => {
|
|
48
|
+
const params = fillPlaceholders(this.params, placeholderValues);
|
|
49
|
+
this.logger.logQuery(this.queryString, params);
|
|
50
|
+
return tracer.startActiveSpan("drizzle.driver.execute", (span) => {
|
|
51
|
+
span?.setAttributes({
|
|
52
|
+
"drizzle.query.text": this.queryString,
|
|
53
|
+
"drizzle.query.params": JSON.stringify(params)
|
|
54
|
+
});
|
|
55
|
+
return this.client.withSQLRowMode("array").querySQL(this.queryString, params.length ? params : void 0).then((result) => result);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** @internal */
|
|
60
|
+
isResponseInArrayMode() {
|
|
61
|
+
return this._isResponseInArrayMode;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class GelDbSession extends GelSession {
|
|
65
|
+
constructor(client, dialect, schema, options = {}) {
|
|
66
|
+
super(dialect);
|
|
67
|
+
this.client = client;
|
|
68
|
+
this.schema = schema;
|
|
69
|
+
this.options = options;
|
|
70
|
+
this.logger = options.logger ?? new NoopLogger();
|
|
71
|
+
}
|
|
72
|
+
static [entityKind] = "GelDbSession";
|
|
73
|
+
logger;
|
|
74
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
|
75
|
+
return new GelDbPreparedQuery(
|
|
76
|
+
this.client,
|
|
77
|
+
query.sql,
|
|
78
|
+
query.params,
|
|
79
|
+
this.logger,
|
|
80
|
+
fields,
|
|
81
|
+
isResponseInArrayMode,
|
|
82
|
+
customResultMapper
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
async transaction(transaction) {
|
|
86
|
+
return await this.client.transaction(async (clientTx) => {
|
|
87
|
+
const session = new GelDbSession(clientTx, this.dialect, this.schema, this.options);
|
|
88
|
+
const tx = new GelDbTransaction(this.dialect, session, this.schema);
|
|
89
|
+
return await transaction(tx);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async count(sql) {
|
|
93
|
+
const res = await this.execute(sql);
|
|
94
|
+
return Number(res[0]["count"]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class GelDbTransaction extends GelTransaction {
|
|
98
|
+
static [entityKind] = "GelDbTransaction";
|
|
99
|
+
async transaction(transaction) {
|
|
100
|
+
const tx = new GelDbTransaction(
|
|
101
|
+
this.dialect,
|
|
102
|
+
this.session,
|
|
103
|
+
this.schema
|
|
104
|
+
);
|
|
105
|
+
return await transaction(tx);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
GelDbPreparedQuery,
|
|
110
|
+
GelDbSession,
|
|
111
|
+
GelDbTransaction
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel/session.ts"],"sourcesContent":["import type { Client } from 'gel';\nimport type { Transaction } from 'gel/dist/transaction';\nimport { entityKind } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/gel-core/query-builders/select.types.ts';\nimport { GelPreparedQuery, GelSession, GelTransaction, type PreparedQueryConfig } from '~/gel-core/session.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL } from '~/sql/sql.ts';\nimport { tracer } from '~/tracing.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type GelClient = Client | Transaction;\n\nexport class GelDbPreparedQuery<T extends PreparedQueryConfig> extends GelPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'GelPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: GelClient,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tprivate transaction: boolean = false,\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\treturn tracer.startActiveSpan('drizzle.execute', async () => {\n\t\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\t\tthis.logger.logQuery(this.queryString, params);\n\t\t\tconst { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;\n\t\t\tif (!fields && !customResultMapper) {\n\t\t\t\treturn tracer.startActiveSpan('drizzle.driver.execute', async (span) => {\n\t\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t\t'drizzle.query.text': query,\n\t\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t\t});\n\n\t\t\t\t\treturn client.querySQL(query, params.length ? params : undefined);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = (await tracer.startActiveSpan('drizzle.driver.execute', (span) => {\n\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t'drizzle.query.text': query,\n\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t});\n\n\t\t\t\treturn client.withSQLRowMode('array').querySQL(query, params.length ? params : undefined);\n\t\t\t})) as unknown[][];\n\n\t\t\treturn tracer.startActiveSpan('drizzle.mapResponse', () => {\n\t\t\t\treturn customResultMapper\n\t\t\t\t\t? customResultMapper(result)\n\t\t\t\t\t: result.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t\t\t});\n\t\t});\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\treturn tracer.startActiveSpan('drizzle.execute', () => {\n\t\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\t\tthis.logger.logQuery(this.queryString, params);\n\t\t\treturn tracer.startActiveSpan('drizzle.driver.execute', (span) => {\n\t\t\t\tspan?.setAttributes({\n\t\t\t\t\t'drizzle.query.text': this.queryString,\n\t\t\t\t\t'drizzle.query.params': JSON.stringify(params),\n\t\t\t\t});\n\t\t\t\treturn this.client.withSQLRowMode('array').querySQL(this.queryString, params.length ? params : undefined).then((\n\t\t\t\t\tresult,\n\t\t\t\t) => result);\n\t\t\t});\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface GelSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class GelDbSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends GelSession<GelQueryResultHKT, TFullSchema, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'GelDbSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: GelClient,\n\t\tdialect: GelDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: GelSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): GelDbPreparedQuery<T> {\n\t\treturn new GelDbPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn await (this.client as Client).transaction(async (clientTx) => {\n\t\t\tconst session = new GelDbSession(clientTx, this.dialect, this.schema, this.options);\n\t\t\tconst tx = new GelDbTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\t\treturn await transaction(tx);\n\t\t});\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[{ count: string }]>(sql);\n\t\treturn Number(res[0]['count']);\n\t}\n}\n\nexport class GelDbTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends GelTransaction<GelQueryResultHKT, TFullSchema, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'GelDbTransaction';\n\n\toverride async transaction<T>(transaction: (tx: GelDbTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tconst tx = new GelDbTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t);\n\t\treturn await transaction(tx);\n\t}\n}\n\n// TODO fix this\nexport interface GelQueryResultHKT {\n\treadonly $brand: 'GelQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 alias_exports = {};
|
|
20
|
+
__export(alias_exports, {
|
|
21
|
+
alias: () => alias
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(alias_exports);
|
|
24
|
+
var import_alias = require("../alias.cjs");
|
|
25
|
+
function alias(table, alias2) {
|
|
26
|
+
return new Proxy(table, new import_alias.TableAliasProxyHandler(alias2, false));
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
alias
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=alias.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/alias.ts"],"sourcesContent":["import { TableAliasProxyHandler } from '~/alias.ts';\nimport type { BuildAliasTable } from './query-builders/select.types.ts';\n\nimport type { GelTable } from './table.ts';\nimport type { GelViewBase } from './view-base.ts';\n\nexport function alias<TTable extends GelTable | GelViewBase, TAlias extends string>(\n\ttable: TTable,\n\talias: TAlias,\n): BuildAliasTable<TTable, TAlias> {\n\treturn new Proxy(table, new TableAliasProxyHandler(alias, false)) as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AAMhC,SAAS,MACf,OACAA,QACkC;AAClC,SAAO,IAAI,MAAM,OAAO,IAAI,oCAAuBA,QAAO,KAAK,CAAC;AACjE;","names":["alias"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuildAliasTable } from "./query-builders/select.types.cjs";
|
|
2
|
+
import type { GelTable } from "./table.cjs";
|
|
3
|
+
import type { GelViewBase } from "./view-base.cjs";
|
|
4
|
+
export declare function alias<TTable extends GelTable | GelViewBase, TAlias extends string>(table: TTable, alias: TAlias): BuildAliasTable<TTable, TAlias>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuildAliasTable } from "./query-builders/select.types.js";
|
|
2
|
+
import type { GelTable } from "./table.js";
|
|
3
|
+
import type { GelViewBase } from "./view-base.js";
|
|
4
|
+
export declare function alias<TTable extends GelTable | GelViewBase, TAlias extends string>(table: TTable, alias: TAlias): BuildAliasTable<TTable, TAlias>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/alias.ts"],"sourcesContent":["import { TableAliasProxyHandler } from '~/alias.ts';\nimport type { BuildAliasTable } from './query-builders/select.types.ts';\n\nimport type { GelTable } from './table.ts';\nimport type { GelViewBase } from './view-base.ts';\n\nexport function alias<TTable extends GelTable | GelViewBase, TAlias extends string>(\n\ttable: TTable,\n\talias: TAlias,\n): BuildAliasTable<TTable, TAlias> {\n\treturn new Proxy(table, new TableAliasProxyHandler(alias, false)) as any;\n}\n"],"mappings":"AAAA,SAAS,8BAA8B;AAMhC,SAAS,MACf,OACAA,QACkC;AAClC,SAAO,IAAI,MAAM,OAAO,IAAI,uBAAuBA,QAAO,KAAK,CAAC;AACjE;","names":["alias"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 checks_exports = {};
|
|
20
|
+
__export(checks_exports, {
|
|
21
|
+
Check: () => Check,
|
|
22
|
+
CheckBuilder: () => CheckBuilder,
|
|
23
|
+
check: () => check
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(checks_exports);
|
|
26
|
+
var import_entity = require("../entity.cjs");
|
|
27
|
+
class CheckBuilder {
|
|
28
|
+
constructor(name, value) {
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.value = value;
|
|
31
|
+
}
|
|
32
|
+
static [import_entity.entityKind] = "GelCheckBuilder";
|
|
33
|
+
brand;
|
|
34
|
+
/** @internal */
|
|
35
|
+
build(table) {
|
|
36
|
+
return new Check(table, this);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class Check {
|
|
40
|
+
constructor(table, builder) {
|
|
41
|
+
this.table = table;
|
|
42
|
+
this.name = builder.name;
|
|
43
|
+
this.value = builder.value;
|
|
44
|
+
}
|
|
45
|
+
static [import_entity.entityKind] = "GelCheck";
|
|
46
|
+
name;
|
|
47
|
+
value;
|
|
48
|
+
}
|
|
49
|
+
function check(name, value) {
|
|
50
|
+
return new CheckBuilder(name, value);
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
Check,
|
|
55
|
+
CheckBuilder,
|
|
56
|
+
check
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=checks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/checks.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/index.ts';\nimport type { GelTable } from './table.ts';\n\nexport class CheckBuilder {\n\tstatic readonly [entityKind]: string = 'GelCheckBuilder';\n\n\tprotected brand!: 'GelConstraintBuilder';\n\n\tconstructor(public name: string, public value: SQL) {}\n\n\t/** @internal */\n\tbuild(table: GelTable): Check {\n\t\treturn new Check(table, this);\n\t}\n}\n\nexport class Check {\n\tstatic readonly [entityKind]: string = 'GelCheck';\n\n\treadonly name: string;\n\treadonly value: SQL;\n\n\tconstructor(public table: GelTable, builder: CheckBuilder) {\n\t\tthis.name = builder.name;\n\t\tthis.value = builder.value;\n\t}\n}\n\nexport function check(name: string, value: SQL): CheckBuilder {\n\treturn new CheckBuilder(name, value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAM,aAAa;AAAA,EAKzB,YAAmB,MAAqB,OAAY;AAAjC;AAAqB;AAAA,EAAa;AAAA,EAJrD,QAAiB,wBAAU,IAAY;AAAA,EAE7B;AAAA;AAAA,EAKV,MAAM,OAAwB;AAC7B,WAAO,IAAI,MAAM,OAAO,IAAI;AAAA,EAC7B;AACD;AAEO,MAAM,MAAM;AAAA,EAMlB,YAAmB,OAAiB,SAAuB;AAAxC;AAClB,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AAAA,EACtB;AAAA,EARA,QAAiB,wBAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAMV;AAEO,SAAS,MAAM,MAAc,OAA0B;AAC7D,SAAO,IAAI,aAAa,MAAM,KAAK;AACpC;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { entityKind } from "../entity.cjs";
|
|
2
|
+
import type { SQL } from "../sql/index.cjs";
|
|
3
|
+
import type { GelTable } from "./table.cjs";
|
|
4
|
+
export declare class CheckBuilder {
|
|
5
|
+
name: string;
|
|
6
|
+
value: SQL;
|
|
7
|
+
static readonly [entityKind]: string;
|
|
8
|
+
protected brand: 'GelConstraintBuilder';
|
|
9
|
+
constructor(name: string, value: SQL);
|
|
10
|
+
}
|
|
11
|
+
export declare class Check {
|
|
12
|
+
table: GelTable;
|
|
13
|
+
static readonly [entityKind]: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly value: SQL;
|
|
16
|
+
constructor(table: GelTable, builder: CheckBuilder);
|
|
17
|
+
}
|
|
18
|
+
export declare function check(name: string, value: SQL): CheckBuilder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
2
|
+
import type { SQL } from "../sql/index.js";
|
|
3
|
+
import type { GelTable } from "./table.js";
|
|
4
|
+
export declare class CheckBuilder {
|
|
5
|
+
name: string;
|
|
6
|
+
value: SQL;
|
|
7
|
+
static readonly [entityKind]: string;
|
|
8
|
+
protected brand: 'GelConstraintBuilder';
|
|
9
|
+
constructor(name: string, value: SQL);
|
|
10
|
+
}
|
|
11
|
+
export declare class Check {
|
|
12
|
+
table: GelTable;
|
|
13
|
+
static readonly [entityKind]: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly value: SQL;
|
|
16
|
+
constructor(table: GelTable, builder: CheckBuilder);
|
|
17
|
+
}
|
|
18
|
+
export declare function check(name: string, value: SQL): CheckBuilder;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
2
|
+
class CheckBuilder {
|
|
3
|
+
constructor(name, value) {
|
|
4
|
+
this.name = name;
|
|
5
|
+
this.value = value;
|
|
6
|
+
}
|
|
7
|
+
static [entityKind] = "GelCheckBuilder";
|
|
8
|
+
brand;
|
|
9
|
+
/** @internal */
|
|
10
|
+
build(table) {
|
|
11
|
+
return new Check(table, this);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
class Check {
|
|
15
|
+
constructor(table, builder) {
|
|
16
|
+
this.table = table;
|
|
17
|
+
this.name = builder.name;
|
|
18
|
+
this.value = builder.value;
|
|
19
|
+
}
|
|
20
|
+
static [entityKind] = "GelCheck";
|
|
21
|
+
name;
|
|
22
|
+
value;
|
|
23
|
+
}
|
|
24
|
+
function check(name, value) {
|
|
25
|
+
return new CheckBuilder(name, value);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Check,
|
|
29
|
+
CheckBuilder,
|
|
30
|
+
check
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/checks.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/index.ts';\nimport type { GelTable } from './table.ts';\n\nexport class CheckBuilder {\n\tstatic readonly [entityKind]: string = 'GelCheckBuilder';\n\n\tprotected brand!: 'GelConstraintBuilder';\n\n\tconstructor(public name: string, public value: SQL) {}\n\n\t/** @internal */\n\tbuild(table: GelTable): Check {\n\t\treturn new Check(table, this);\n\t}\n}\n\nexport class Check {\n\tstatic readonly [entityKind]: string = 'GelCheck';\n\n\treadonly name: string;\n\treadonly value: SQL;\n\n\tconstructor(public table: GelTable, builder: CheckBuilder) {\n\t\tthis.name = builder.name;\n\t\tthis.value = builder.value;\n\t}\n}\n\nexport function check(name: string, value: SQL): CheckBuilder {\n\treturn new CheckBuilder(name, value);\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAM,aAAa;AAAA,EAKzB,YAAmB,MAAqB,OAAY;AAAjC;AAAqB;AAAA,EAAa;AAAA,EAJrD,QAAiB,UAAU,IAAY;AAAA,EAE7B;AAAA;AAAA,EAKV,MAAM,OAAwB;AAC7B,WAAO,IAAI,MAAM,OAAO,IAAI;AAAA,EAC7B;AACD;AAEO,MAAM,MAAM;AAAA,EAMlB,YAAmB,OAAiB,SAAuB;AAAxC;AAClB,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AAAA,EACtB;AAAA,EARA,QAAiB,UAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAMV;AAEO,SAAS,MAAM,MAAc,OAA0B;AAC7D,SAAO,IAAI,aAAa,MAAM,KAAK;AACpC;","names":[]}
|